@zuplo/cli 7.13.6 → 7.13.7
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/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-NWYAKCSU.js → chunk-D4D3WYPP.js} +95 -95
- package/node_modules/@zuplo/runtime/out/esm/chunk-D4D3WYPP.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +8 -0
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-NWYAKCSU.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-NWYAKCSU.js.LEGAL.txt → chunk-D4D3WYPP.js.LEGAL.txt} +0 -0
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
import{$ as Zn,$a as Wd,$b as Ku,$c as Nl,$f as fs,$g as Np,Aa as vd,Ab as bu,Ac as as,Af as We,Ag as Ss,Ba as Cd,Bb as vu,Bc as cs,Bf as ap,Bg as Rp,C as nd,Ca as Id,Cb as Cu,Cc as pl,Cf as ot,Cg as _s,Da as Td,Db as Iu,Dc as ml,Df as M,Dg as qi,E as ns,Ea as Ed,Eb as Tu,Ec as hl,Ef as ms,Eg as ws,Fa as kd,Fb as Eu,Fc as fl,Fd as Ql,Ff as ve,Fg as bp,Ga as Ad,Gb as ku,Gc as gl,Gf as bt,Gg as ue,Ha as Pd,Hb as Au,Hc as yl,Hf as VS,Hg as vp,Ia as xd,Ib as Pu,Ic as Sl,If as KS,Ig as Cp,Ja as Od,Jb as xu,Jc as _l,Jf as WS,Jg as zi,Ka as Ud,Kb as Ou,Kc as wl,Kf as ZS,Kg as Ip,La as Md,Lb as Uu,Lc as Rl,Lf as YS,Lg as Tp,Ma as qd,Mb as Mu,Mc as bl,Mf as XS,Mg as Ni,Na as zd,Nb as qu,Nc as vl,Nf as QS,Ng as Ep,O as od,Oa as Nd,Ob as zu,Oc as Cl,Of as e_,Og as Yt,Pa as jd,Pb as Nu,Pc as Il,Pf as t_,Pg as kp,Qa as Ri,Qb as ju,Qc as Tl,Qf as r_,Qg as so,R as sd,Ra as Dd,Rb as Du,Rc as El,Rf as cp,Rg as Ap,Sa as $d,Sb as $u,Sc as kl,Sf as dp,Sg as Rs,Ta as Ld,Tb as Lu,Tc as Al,Tf as hs,Tg as io,Ua as Hd,Ub as Hu,Uc as Pl,Uf as to,Ug as Pp,Va as Bd,Vb as Bu,Vc as xl,Vf as ro,Vg as xp,Wa as Jd,Wb as Ju,Wc as Ol,Wf as Mr,Wg as Op,Xa as Fd,Xb as Fu,Xc as Ul,Xf as up,Xg as Up,Y as os,Ya as Gd,Yb as Gu,Yc as Ml,Yf as xi,Yg as Mp,Z as yi,Za as Vd,Zb as bi,Zc as ql,Zf as lp,Zg as qp,_ as wr,_a as Kd,_b as Vu,_c as zl,_f as no,_g as zp,aa as Rr,ab as Zd,ac as Wu,ad as jl,ag as pp,ah as bs,b as td,ba as br,bb as Yd,bc as Zu,bd as Dl,bg as mp,bh as jp,ca as Yn,cb as Xd,cc as Yu,cd as $l,cg as hp,ch as Dp,da as vr,db as Qd,dc as Xu,dd as Ll,dg as fp,dh as H,ea as id,eb as eu,ec as Qu,ed as Hl,eg as _e,eh as X,fa as ad,fb as tu,fc as el,fd as Bl,ff as ep,fg as me,fh as $p,ga as cd,gb as ru,gc as tl,gd as Jl,gf as qe,gg as gp,gh as he,ha as dd,hb as nu,hc as rl,hd as Fl,hf as tp,hg as yp,hh as at,ia as ud,ib as ou,ic as nl,id as Cr,if as rp,ig as J,ih as oe,ja as ld,jb as su,jc as ol,jd as Ir,jf as np,jg as st,jh as vs,ka as pd,kb as iu,kc as sl,kd as Gl,kf as ne,kg as qr,kh as Lp,la as md,lb as au,lc as il,ld as Tr,lf as op,lg as Ce,lh as n_,ma as hd,mb as cu,mc as al,md as Rt,mf as Er,mg as ce,mh as o_,n as Qe,na as fd,nb as du,nc as cl,nd as Pi,nf as sp,ng as Sp,oa as gd,ob as uu,oc as vi,od as ds,of as kr,og as te,pa as yd,pb as lu,pc as ss,pd as Vl,pf as E,pg as _p,qa as Sd,qb as pu,qc as is,qd as Qn,qf as Ar,qg as vt,ra as _d,rb as mu,rc as Ci,rd as Zt,rf as Pr,rg as Oi,sa as wd,sb as hu,sc as Ii,sd as Kl,sf as rt,sg as gs,ta as Rd,tb as fu,tc as Ti,td as Wl,tf as nt,tg as Ui,u as He,ua as Wt,ub as gu,uc as dl,ud as eo,uf as ls,ug as ys,v as rd,va as Si,vb as yu,vc as Ei,vd as Zl,vf as xr,vg as oo,wa as _i,wb as Su,wc as ki,wd as Yl,wf as Or,wg as zr,x as F,xa as Xn,xb as _u,xc as ul,xd as Xl,xf as Ur,xg as wp,ya as wi,yb as wu,yc as ll,yd as us,yf as ps,yg as it,za as bd,zb as Ru,zc as Ai,zf as ip,zg as Mi}from"../chunk-NWYAKCSU.js";import"../chunk-ZCJ5QBVD.js";import{a as Hp,b as Bp}from"../chunk-7FFIW3HF.js";import{a as _r}from"../chunk-QGAJTUPE.js";import"../chunk-A3QGJZO7.js";import{$ as es,Ba as p,a as be,aa as Yc,c as T,ca as hi,d as Y,da as Xc,ea as u,fa as Qc,ga as ed,ha as C,ia as z,ja as ts,la as D,ma as b,na as g,oa as L,pa as U,qa as fi,ra as Kn,sa as P,ta as B,ua as _,va as $,wa as gi,xa as rs,za as Wn}from"../chunk-PXS4NOKU.js";import"../chunk-UKQQD2JN.js";import{a as n}from"../chunk-TYV53J3B.js";var s_=Object.create,Cs=Object.defineProperty,i_=Object.getOwnPropertyDescriptor,a_=Object.getOwnPropertyNames,c_=Object.getPrototypeOf,d_=Object.prototype.hasOwnProperty,Jp=n((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),"__commonJSMin"),Fp=n((e,t)=>{let r={};for(var o in e)Cs(r,o,{get:e[o],enumerable:!0});return t&&Cs(r,Symbol.toStringTag,{value:"Module"}),r},"__exportAll"),u_=n((e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(var s=a_(t),i=0,a=s.length,c;i<a;i++)c=s[i],!d_.call(e,c)&&c!==r&&Cs(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(o=i_(t,c))||o.enumerable});return e},"__copyProps"),Gp=n((e,t,r)=>(r=e!=null?s_(c_(e)):{},u_(t||!e||!e.__esModule?Cs(r,"default",{value:e,enumerable:!0}):r,e)),"__toESM");var l_=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]);function Vp(e){return typeof e=="string"&&l_.has(e.replace(/#$/,""))}n(Vp,"declares2019Dialect");var Bi=Symbol.for("mcp.sdk.errorBrands");function Xt(e,t){let r=new Set,o=t;for(;typeof o=="function";){let s=o.mcpBrand;Object.prototype.hasOwnProperty.call(o,"mcpBrand")&&typeof s=="string"&&r.add(s),o=Object.getPrototypeOf(o)}r.size!==0&&Object.defineProperty(e,Bi,{value:r,enumerable:!1,configurable:!0})}n(Xt,"stampErrorBrands");function ze(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,Bi)){let r=t[Bi];if(r&&typeof r.has=="function"&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}n(ze,"brandedHasInstance");var le=(function(e){return e.InvalidRequest="invalid_request",e.InvalidClient="invalid_client",e.InvalidGrant="invalid_grant",e.UnauthorizedClient="unauthorized_client",e.UnsupportedGrantType="unsupported_grant_type",e.InvalidScope="invalid_scope",e.AccessDenied="access_denied",e.ServerError="server_error",e.TemporarilyUnavailable="temporarily_unavailable",e.UnsupportedResponseType="unsupported_response_type",e.UnsupportedTokenType="unsupported_token_type",e.InvalidToken="invalid_token",e.MethodNotAllowed="method_not_allowed",e.TooManyRequests="too_many_requests",e.InvalidClientMetadata="invalid_client_metadata",e.InvalidRedirectUri="invalid_redirect_uri",e.InsufficientScope="insufficient_scope",e.InvalidTarget="invalid_target",e.InvalidDpopProof="invalid_dpop_proof",e.UseDpopNonce="use_dpop_nonce",e})({}),Ct=class om extends Error{static{n(this,"OAuthError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return ze(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,t)}constructor(t,r,o){super(r),this.code=t,this.errorUri=o,this.name="OAuthError",Xt(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(t){return new om(t.error,t.error_description??t.error,t.error_uri)}},fe=(function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e})({}),de=class extends Error{static{n(this,"SdkError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e,t,r,o){super(t,o),this.code=e,this.data=r,this.name="SdkError",Xt(this,new.target)}},v_=class extends de{static{n(this,"SdkHttpError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,o){super(e,t,r,o),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};function sm(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}n(sm,"resourceUrlFromServerUrl");function Wi(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}n(Wi,"withoutIssuer");function As({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;let s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return s.startsWith(i)}n(As,"checkResourceAllowed");var C_="2026-07-28";function im(e){return e>=C_}n(im,"isModernProtocolVersion");function am(e){let t=e.structuredContent;return t===void 0||!(typeof t!="object"||t===null||Array.isArray(t))||(e.content?.some(r=>r.type==="text")??!1)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}n(am,"appendTextFallbackForNonObject");var cm=["task","inputRequests","requestState"];function I_(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||cm.some(t=>t in e)?e:{...e,content:[]}}n(I_,"normalizeContentlessToolResult");function T_(){let e=gi(()=>U([u(),C(),z(),ts(),P(u(),e),b(e)])),t=P(u(),e),r=U([u(),C().int()]),o=u(),s=g({ttl:C().optional()}),i=g({taskId:u()}),a=L({progressToken:r.optional(),"io.modelcontextprotocol/related-task":i.optional()}),c=g({_meta:a.optional()}),d=c.extend({task:s.optional()}),l=g({method:u(),params:c.loose().optional()}),m=g({_meta:a.optional()}),h=g({method:u(),params:m.loose().optional()}),y=L({_meta:a.optional()}),f=U([u(),C().int()]),R=y.strict(),S=m.extend({requestId:f.optional(),reason:u().optional()}),w=h.extend({method:_("notifications/cancelled"),params:S}),x=g({src:u(),mimeType:u().optional(),sizes:b(u()).optional(),theme:B(["light","dark"]).optional()}),I=g({icons:b(x).optional()}),O=g({name:u(),title:u().optional()}),N=O.extend({...O.shape,...I.shape,version:u(),websiteUrl:u().optional(),description:u().optional()}),we=Kn(g({applyDefaults:z().optional()}),t),q=rs(Se=>Se&&typeof Se=="object"&&!Array.isArray(Se)&&Object.keys(Se).length===0?{form:{}}:Se,Kn(g({form:we.optional(),url:t.optional()}),t.optional())),ie=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),pe=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),A=g({experimental:P(u(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:q.optional(),roots:g({listChanged:z().optional()}).optional(),tasks:ie.optional(),extensions:P(u(),t).optional()}),K=c.extend({protocolVersion:u(),capabilities:A,clientInfo:N}),j=l.extend({method:_("initialize"),params:K}),W=g({experimental:P(u(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:z().optional()}).optional(),resources:g({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:g({listChanged:z().optional()}).optional(),tasks:pe.optional(),extensions:P(u(),t).optional()}),Z=y.extend({protocolVersion:u(),capabilities:W,serverInfo:N,instructions:u().optional()}),De=h.extend({method:_("notifications/initialized"),params:m.optional()}),Oe=l.extend({method:_("ping"),params:c.optional()}),$e=g({progress:C(),total:$(C()),message:$(u())}),G=g({...m.shape,...$e.shape,progressToken:r}),ae=h.extend({method:_("notifications/progress"),params:G}),ke=c.extend({cursor:o.optional()}),ee=l.extend({params:ke.optional()}),Ge=y.extend({nextCursor:o.optional()}),or=g({uri:u(),mimeType:$(u()),_meta:P(u(),D()).optional()}),sr=or.extend({text:u()}),Nt=u().refine(Se=>{try{return atob(Se),!0}catch{return!1}},{message:"Invalid Base64 string"}),ir=or.extend({blob:Nt}),Xe=B(["user","assistant"]),Ve=g({audience:b(Xe).optional(),priority:C().min(0).max(1).optional(),lastModified:Wn.datetime({offset:!0}).optional()}),jt=g({...O.shape,...I.shape,uri:u(),description:$(u()),mimeType:$(u()),size:$(C()),annotations:Ve.optional(),_meta:$(L({}))}),en=g({...O.shape,...I.shape,uriTemplate:u(),description:$(u()),mimeType:$(u()),annotations:Ve.optional(),_meta:$(L({}))}),tn=ee.extend({method:_("resources/list")}),rn=Ge.extend({resources:b(jt)}),yt=ee.extend({method:_("resources/templates/list")}),ar=Ge.extend({resourceTemplates:b(en)}),Dt=c.extend({uri:u()}),nn=Dt,on=l.extend({method:_("resources/read"),params:nn}),sn=y.extend({contents:b(U([sr,ir]))}),an=h.extend({method:_("notifications/resources/list_changed"),params:m.optional()}),cn=Dt,dn=l.extend({method:_("resources/subscribe"),params:cn}),un=Dt,ln=l.extend({method:_("resources/unsubscribe"),params:un}),pn=m.extend({uri:u()}),mn=h.extend({method:_("notifications/resources/updated"),params:pn}),hn=g({name:u(),description:$(u()),required:$(z())}),fn=g({...O.shape,...I.shape,description:$(u()),arguments:$(b(hn)),_meta:$(L({}))}),gn=ee.extend({method:_("prompts/list")}),yn=Ge.extend({prompts:b(fn)}),Sn=c.extend({name:u(),arguments:P(u(),u()).optional()}),_n=l.extend({method:_("prompts/get"),params:Sn}),$t=g({type:_("text"),text:u(),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),Lt=g({type:_("image"),data:Nt,mimeType:u(),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),Ht=g({type:_("audio"),data:Nt,mimeType:u(),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),wn=g({type:_("tool_use"),name:u(),id:u(),input:P(u(),D()),_meta:P(u(),D()).optional()}),St=g({type:_("resource"),resource:U([sr,ir]),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),Rn=jt.extend({type:_("resource_link")}),Le=U([$t,Lt,Ht,Rn,St]),cr=g({role:Xe,content:Le}),dr=y.extend({description:u().optional(),messages:b(cr)}),Bt=h.extend({method:_("notifications/prompts/list_changed"),params:m.optional()}),bn=g({title:u().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),ur=g({taskSupport:B(["required","optional","forbidden"]).optional()}),Jt=g({...O.shape,...I.shape,description:u().optional(),inputSchema:g({type:_("object"),properties:P(u(),e).optional(),required:b(u()).optional()}).catchall(D()),outputSchema:g({type:_("object"),properties:P(u(),e).optional(),required:b(u()).optional()}).catchall(D()).optional(),annotations:bn.optional(),execution:ur.optional(),_meta:P(u(),D()).optional()}),lr=ee.extend({method:_("tools/list")}),pr=Ge.extend({tools:b(Jt)}),mr=y.extend({content:b(Le),structuredContent:P(u(),D()).optional(),isError:z().optional()}),ye=d.extend({name:u(),arguments:P(u(),D()).optional()}),vn=l.extend({method:_("tools/call"),params:ye}),jo=h.extend({method:_("notifications/tools/list_changed"),params:m.optional()}),hr=B(["debug","info","notice","warning","error","critical","alert","emergency"]),Cn=c.extend({level:hr}),In=l.extend({method:_("logging/setLevel"),params:Cn}),Tn=m.extend({level:hr,logger:u().optional(),data:D()}),En=h.extend({method:_("notifications/message"),params:Tn}),kn=g({name:u().optional()}),An=g({hints:b(kn).optional(),costPriority:C().min(0).max(1).optional(),speedPriority:C().min(0).max(1).optional(),intelligencePriority:C().min(0).max(1).optional()}),Pn=g({mode:B(["auto","required","none"]).optional()}),Do=g({type:_("tool_result"),toolUseId:u().describe("The unique identifier for the corresponding tool call."),content:b(Le),structuredContent:g({}).loose().optional(),isError:z().optional(),_meta:P(u(),D()).optional()}),xn=fi("type",[$t,Lt,Ht]),_t=fi("type",[$t,Lt,Ht,wn,Do]),On=g({role:Xe,content:U([_t,b(_t)]),_meta:P(u(),D()).optional()}),Un=d.extend({messages:b(On),modelPreferences:An.optional(),systemPrompt:u().optional(),includeContext:B(["none","thisServer","allServers"]).optional(),temperature:C().optional(),maxTokens:C().int(),stopSequences:b(u()).optional(),metadata:t.optional(),tools:b(Jt).optional(),toolChoice:Pn.optional()}),Mn=l.extend({method:_("sampling/createMessage"),params:Un}),qn=y.extend({model:u(),stopReason:$(B(["endTurn","stopSequence","maxTokens"]).or(u())),role:Xe,content:xn}),zn=y.extend({model:u(),stopReason:$(B(["endTurn","stopSequence","maxTokens","toolUse"]).or(u())),role:Xe,content:U([_t,b(_t)])}),Nn=g({type:_("boolean"),title:u().optional(),description:u().optional(),default:z().optional()}),jn=g({type:_("string"),title:u().optional(),description:u().optional(),minLength:C().optional(),maxLength:C().optional(),format:B(["email","uri","date","date-time"]).optional(),default:u().optional()}),Dn=g({type:B(["number","integer"]),title:u().optional(),description:u().optional(),minimum:C().optional(),maximum:C().optional(),default:C().optional()}),$n=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),default:u().optional()}),Ln=g({type:_("string"),title:u().optional(),description:u().optional(),oneOf:b(g({const:u(),title:u()})),default:u().optional()}),Hn=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),enumNames:b(u()).optional(),default:u().optional()}),Bn=U([$n,Ln]),Ft=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({type:_("string"),enum:b(u())}),default:b(u()).optional()}),Gt=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({anyOf:b(g({const:u(),title:u()}))}),default:b(u()).optional()}),$o=U([Ft,Gt]),Lo=U([Hn,Bn,$o]),Ue=U([Lo,Nn,jn,Dn]),Me=d.extend({mode:_("form").optional(),message:u(),requestedSchema:g({type:_("object"),properties:P(u(),Ue),required:b(u()).optional()}).catchall(D())}),Jn=d.extend({mode:_("url"),message:u(),elicitationId:u(),url:u().url()}),Ke=U([Me,Jn]),Ho=l.extend({method:_("elicitation/create"),params:Ke}),Bo=m.extend({elicitationId:u()}),Jo=h.extend({method:_("notifications/elicitation/complete"),params:Bo}),Fo=y.extend({action:B(["accept","decline","cancel"]),content:rs(Se=>Se===null?void 0:Se,P(u(),U([u(),C(),z(),b(u())])).optional())}),Go=g({type:_("ref/resource"),uri:u()}),Vo=g({type:_("ref/prompt"),name:u()}),Ko=c.extend({ref:U([Vo,Go]),argument:g({name:u(),value:u()}),context:g({arguments:P(u(),u()).optional()}).optional()}),Fn=l.extend({method:_("completion/complete"),params:Ko}),Wo=y.extend({completion:L({values:b(u()).max(100),total:$(C().int()),hasMore:$(z())})}),Zo=g({uri:u().startsWith("file://"),name:u().optional(),_meta:P(u(),D()).optional()}),fr=l.extend({method:_("roots/list"),params:c.optional()}),Gn=y.extend({roots:b(Zo)}),Yo=h.extend({method:_("notifications/roots/list_changed"),params:m.optional()}),Xo=L({ttl:C().optional(),pollInterval:C().optional()}),Vn=B(["working","input_required","completed","failed","cancelled"]),wt=g({taskId:u(),status:Vn,ttl:U([C(),ts()]),createdAt:u(),lastUpdatedAt:u(),pollInterval:$(C()),statusMessage:$(u())}),Ae=y.extend({task:wt}),Qo=m.merge(wt),Vt=h.extend({method:_("notifications/tasks/status"),params:Qo}),gr=l.extend({method:_("tasks/get"),params:c.extend({taskId:u()})}),yr=y.merge(wt),Sr=l.extend({method:_("tasks/result"),params:c.extend({taskId:u()})}),mi=y.loose(),Re=ee.extend({method:_("tasks/list")}),re=Ge.extend({tasks:b(wt)}),Kt=l.extend({method:_("tasks/cancel"),params:c.extend({taskId:u()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,TaskMetadataSchema:s,RelatedTaskMetadataSchema:i,RequestMetaSchema:a,BaseRequestParamsSchema:c,TaskAugmentedRequestParamsSchema:d,RequestSchema:l,NotificationsParamsSchema:m,NotificationSchema:h,ResultSchema:y,RequestIdSchema:f,EmptyResultSchema:R,CancelledNotificationParamsSchema:S,CancelledNotificationSchema:w,IconSchema:x,IconsSchema:I,BaseMetadataSchema:O,ImplementationSchema:N,ClientTasksCapabilitySchema:ie,ServerTasksCapabilitySchema:pe,ClientCapabilitiesSchema:A,InitializeRequestParamsSchema:K,InitializeRequestSchema:j,ServerCapabilitiesSchema:W,InitializeResultSchema:Z,InitializedNotificationSchema:De,PingRequestSchema:Oe,ProgressSchema:$e,ProgressNotificationParamsSchema:G,ProgressNotificationSchema:ae,PaginatedRequestParamsSchema:ke,PaginatedRequestSchema:ee,PaginatedResultSchema:Ge,ResourceContentsSchema:or,TextResourceContentsSchema:sr,BlobResourceContentsSchema:ir,RoleSchema:Xe,AnnotationsSchema:Ve,ResourceSchema:jt,ResourceTemplateSchema:en,ListResourcesRequestSchema:tn,ListResourcesResultSchema:rn,ListResourceTemplatesRequestSchema:yt,ListResourceTemplatesResultSchema:ar,ResourceRequestParamsSchema:Dt,ReadResourceRequestParamsSchema:nn,ReadResourceRequestSchema:on,ReadResourceResultSchema:sn,ResourceListChangedNotificationSchema:an,SubscribeRequestParamsSchema:cn,SubscribeRequestSchema:dn,UnsubscribeRequestParamsSchema:un,UnsubscribeRequestSchema:ln,ResourceUpdatedNotificationParamsSchema:pn,ResourceUpdatedNotificationSchema:mn,PromptArgumentSchema:hn,PromptSchema:fn,ListPromptsRequestSchema:gn,ListPromptsResultSchema:yn,GetPromptRequestParamsSchema:Sn,GetPromptRequestSchema:_n,TextContentSchema:$t,ImageContentSchema:Lt,AudioContentSchema:Ht,ToolUseContentSchema:wn,EmbeddedResourceSchema:St,ResourceLinkSchema:Rn,ContentBlockSchema:Le,PromptMessageSchema:cr,GetPromptResultSchema:dr,PromptListChangedNotificationSchema:Bt,ToolAnnotationsSchema:bn,ToolExecutionSchema:ur,ToolSchema:Jt,ListToolsRequestSchema:lr,ListToolsResultSchema:pr,CallToolResultSchema:mr,CallToolRequestParamsSchema:ye,CallToolRequestSchema:vn,ToolListChangedNotificationSchema:jo,LoggingLevelSchema:hr,SetLevelRequestParamsSchema:Cn,SetLevelRequestSchema:In,LoggingMessageNotificationParamsSchema:Tn,LoggingMessageNotificationSchema:En,ModelHintSchema:kn,ModelPreferencesSchema:An,ToolChoiceSchema:Pn,ToolResultContentSchema:Do,SamplingContentSchema:xn,SamplingMessageContentBlockSchema:_t,SamplingMessageSchema:On,CreateMessageRequestParamsSchema:Un,CreateMessageRequestSchema:Mn,CreateMessageResultSchema:qn,CreateMessageResultWithToolsSchema:zn,BooleanSchemaSchema:Nn,StringSchemaSchema:jn,NumberSchemaSchema:Dn,UntitledSingleSelectEnumSchemaSchema:$n,TitledSingleSelectEnumSchemaSchema:Ln,LegacyTitledEnumSchemaSchema:Hn,SingleSelectEnumSchemaSchema:Bn,UntitledMultiSelectEnumSchemaSchema:Ft,TitledMultiSelectEnumSchemaSchema:Gt,MultiSelectEnumSchemaSchema:$o,EnumSchemaSchema:Lo,PrimitiveSchemaDefinitionSchema:Ue,ElicitRequestFormParamsSchema:Me,ElicitRequestURLParamsSchema:Jn,ElicitRequestParamsSchema:Ke,ElicitRequestSchema:Ho,ElicitationCompleteNotificationParamsSchema:Bo,ElicitationCompleteNotificationSchema:Jo,ElicitResultSchema:Fo,ResourceTemplateReferenceSchema:Go,PromptReferenceSchema:Vo,CompleteRequestParamsSchema:Ko,CompleteRequestSchema:Fn,CompleteResultSchema:Wo,RootSchema:Zo,ListRootsRequestSchema:fr,ListRootsResultSchema:Gn,RootsListChangedNotificationSchema:Yo,TaskCreationParamsSchema:Xo,TaskStatusSchema:Vn,TaskSchema:wt,CreateTaskResultSchema:Ae,TaskStatusNotificationParamsSchema:Qo,TaskStatusNotificationSchema:Vt,GetTaskRequestSchema:gr,GetTaskResultSchema:yr,GetTaskPayloadRequestSchema:Sr,GetTaskPayloadResultSchema:mi,ListTasksRequestSchema:Re,ListTasksResultSchema:re,CancelTaskRequestSchema:Kt,CancelTaskResultSchema:y.merge(wt),ClientRequestSchema:U([Oe,j,Fn,In,_n,gn,tn,yt,on,dn,ln,vn,lr,gr,Sr,Re,Kt]),ClientNotificationSchema:U([w,ae,De,Yo,Vt]),ClientResultSchema:U([R,qn,zn,Fo,Gn,yr,re,Ae]),ServerRequestSchema:U([Oe,Mn,Ho,fr,gr,Sr,Re,Kt]),ServerNotificationSchema:U([w,ae,En,mn,an,jo,Bt,Vt,Jo]),ServerResultSchema:U([R,Z,Wo,dr,yn,rn,ar,sn,mr,pr,yr,re,Ae]),CallToolResultWireSchema:D().superRefine((Se,GS)=>{if(!(typeof Se!="object"||Se===null||Array.isArray(Se)||Se.content!==void 0)){for(let Zc of cm)if(Zc in Se){GS.addIssue({code:"custom",message:`content is required when the body carries '${Zc}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(I_).pipe(mr)}}n(T_,"build$1");var E_;function Zi(){return E_??=T_()}n(Zi,"buildSchemas2025");function dm(e){return e.type!=="object"}n(dm,"isNonObjectJsonSchemaRoot");var k_=new Set(["const","enum","default","examples"]),A_=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function Kp(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}n(Kp,"establishesNewBase");function P_(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(Kp(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let r=Vp(e.$schema)&&e.$recursiveAnchor!==!0,o=n((s,i)=>{if(Array.isArray(s))return s.map(d=>o(d,!1));if(s===null||typeof s!="object"||!i&&Kp(s.$id))return s;let a={},c=!1;for(let[d,l]of Object.entries(s))i?a[d]=o(l,!1):(d==="$ref"||d==="$dynamicRef")&&typeof l=="string"?a[d]=l==="#"?"#/properties/result":l.startsWith("#/")?`#/properties/result${l.slice(1)}`:l:d==="$recursiveRef"&&l==="#"&&r?c=!0:k_.has(d)?a[d]=l:A_.has(d)?a[d]=o(l,!0):a[d]=o(l,!1);return c&&("$ref"in a?a.allOf=[...Array.isArray(a.allOf)?a.allOf:[],{$ref:"#/properties/result"}]:a.$ref="#/properties/result"),a},"rewriteRefs");return{...t!==void 0&&{$schema:t},type:"object",properties:{result:o(e,!1)},required:["result"]}}n(P_,"wrapOutputSchemaForLegacy");var um={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},lm={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},x_={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Is;function Ps(){if(Is)return Is;let e=Zi();return Is={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Is}n(Ps,"registryMaps");function O_(){Ps()}n(O_,"warmRegistryMaps2025");function pm(e){return Object.prototype.hasOwnProperty.call(um,e)}n(pm,"hasRequestMethod2025");function mm(e){return Object.prototype.hasOwnProperty.call(lm,e)}n(mm,"hasNotificationMethod2025");function U_(e){return Object.prototype.hasOwnProperty.call(x_,e)}n(U_,"hasResultMethod");function M_(e){return U_(e)?Ps().resultSchemas[e]:void 0}n(M_,"getResultSchema");function q_(e){return pm(e)?Ps().requestSchemas[e]:void 0}n(q_,"getRequestSchema");function z_(e){return mm(e)?Ps().notificationSchemas[e]:void 0}n(z_,"getNotificationSchema");var NP=Object.keys(um),jP=Object.keys(lm);function Ji(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(Ji,"isPlainObject$5");function Ts(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}n(Ts,"triState$1");var Wp={ok:!1,reason:"not-in-era"};function Zp(e){return Ji(e)&&Ji(e.outputSchema)&&dm(e.outputSchema)}n(Zp,"toolNeedsLegacyWrap");var Yi={era:"2025-11-25",hasRequestMethod:pm,hasNotificationMethod:mm,validateRequest:n((e,t)=>Ts(q_(e),t),"validateRequest"),validateResult:n((e,t)=>Ts(M_(e),t),"validateResult"),validateNotification:n((e,t)=>Ts(z_(e),t),"validateNotification"),hasInputRequestMethod:n(()=>!1,"hasInputRequestMethod"),validateInputRequest:n(()=>Wp,"validateInputRequest"),validateInputResponse:n(()=>Wp,"validateInputResponse"),samplingResultVariant:n(((e,t)=>{let r=Zi();return Ts(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)}),"samplingResultVariant"),outboundEnvelope:n(e=>{},"outboundEnvelope"),validateEnvelopeMeta:n(e=>[],"validateEnvelopeMeta"),projectCallToolResult(e,t){let r=am(e),o=r.structuredContent;if(o===void 0)return r;let s=typeof o!="object"||o===null||Array.isArray(o),i=t!==void 0&&dm(t);return!s&&!i?r:{...r,structuredContent:{result:o}}},decodeResult(e,t){if(Ji(t)&&"resultType"in t){let r={...t};return delete r.resultType,{kind:"complete",result:r}}return{kind:"complete",result:t}},encodeResult(e,t){if(e!=="tools/list")return t;let r=t.tools;return!Array.isArray(r)||!r.some(o=>Zp(o))?t:{...t,tools:r.map(o=>Zp(o)?{...o,outputSchema:P_(o.outputSchema)}:o)}},encodeErrorCode:n(e=>e===-32002?-32602:e,"encodeErrorCode"),checkInboundEnvelope:n(e=>{},"checkInboundEnvelope")};function N_(){let e=gi(()=>U([u(),C(),z(),ts(),P(u(),e),b(e)])),t=P(u(),e),r=U([u(),C().int()]),o=u(),s=U([u(),C().int()]),i=B(["user","assistant"]),a=B(["debug","info","notice","warning","error","critical","alert","emergency"]),c=u().refine(re=>{try{return atob(re),!0}catch{return!1}},{message:"Invalid Base64 string"}),d=g({ttl:C().optional()}),l=g({taskId:u()}),m=L({progressToken:r.optional(),"io.modelcontextprotocol/related-task":l.optional()}),h=g({_meta:m.optional()}),y=h.extend({task:d.optional()}),f=g({_meta:m.optional()}),R=g({method:u(),params:f.loose().optional()}),S=g({src:u(),mimeType:u().optional(),sizes:b(u()).optional(),theme:B(["light","dark"]).optional()}),w=g({icons:b(S).optional()}),x=g({name:u(),title:u().optional()}),I=x.extend({...x.shape,...w.shape,version:u(),websiteUrl:u().optional(),description:u().optional()}),O=Kn(g({applyDefaults:z().optional()}),t),N=rs(re=>re&&typeof re=="object"&&!Array.isArray(re)&&Object.keys(re).length===0?{form:{}}:re,Kn(g({form:O.optional(),url:t.optional()}),t.optional())),we=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),q=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),ie=g({experimental:P(u(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:N.optional(),roots:g({listChanged:z().optional()}).optional(),tasks:we.optional(),extensions:P(u(),t).optional()}),pe=g({experimental:P(u(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:z().optional()}).optional(),resources:g({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:g({listChanged:z().optional()}).optional(),tasks:q.optional(),extensions:P(u(),t).optional()}),A=g({progress:C(),total:$(C()),message:$(u())}),K=g({...f.shape,...A.shape,progressToken:r}),j=R.extend({method:_("notifications/progress"),params:K}),W=f.extend({level:a,logger:u().optional(),data:D()}),Z=R.extend({method:_("notifications/message"),params:W}),De=g({uri:u(),mimeType:$(u()),_meta:P(u(),D()).optional()}),Oe=De.extend({text:u()}),$e=De.extend({blob:c}),G=g({audience:b(i).optional(),priority:C().min(0).max(1).optional(),lastModified:Wn.datetime({offset:!0}).optional()}),ae=g({...x.shape,...w.shape,uri:u(),description:$(u()),mimeType:$(u()),size:$(C()),annotations:G.optional(),_meta:$(L({}))}),ke=g({...x.shape,...w.shape,uriTemplate:u(),description:$(u()),mimeType:$(u()),annotations:G.optional(),_meta:$(L({}))}),ee=R.extend({method:_("notifications/resources/list_changed"),params:f.optional()}),Ge=f.extend({uri:u()}),or=R.extend({method:_("notifications/resources/updated"),params:Ge}),sr=g({name:u(),description:$(u()),required:$(z())}),Nt=g({...x.shape,...w.shape,description:$(u()),arguments:$(b(sr)),_meta:$(L({}))}),ir=R.extend({method:_("notifications/prompts/list_changed"),params:f.optional()}),Xe=g({type:_("text"),text:u(),annotations:G.optional(),_meta:P(u(),D()).optional()}),Ve=g({type:_("image"),data:c,mimeType:u(),annotations:G.optional(),_meta:P(u(),D()).optional()}),jt=g({type:_("audio"),data:c,mimeType:u(),annotations:G.optional(),_meta:P(u(),D()).optional()}),en=g({type:_("tool_use"),name:u(),id:u(),input:P(u(),D()),_meta:P(u(),D()).optional()}),tn=g({type:_("resource"),resource:U([Oe,$e]),annotations:G.optional(),_meta:P(u(),D()).optional()}),rn=ae.extend({type:_("resource_link")}),yt=U([Xe,Ve,jt,rn,tn]),ar=g({role:i,content:yt}),Dt=g({title:u().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),nn=R.extend({method:_("notifications/tools/list_changed"),params:f.optional()}),on=g({name:u().optional()}),sn=g({hints:b(on).optional(),costPriority:C().min(0).max(1).optional(),speedPriority:C().min(0).max(1).optional(),intelligencePriority:C().min(0).max(1).optional()}),an=g({mode:B(["auto","required","none"]).optional()}),cn=g({type:_("boolean"),title:u().optional(),description:u().optional(),default:z().optional()}),dn=g({type:_("string"),title:u().optional(),description:u().optional(),minLength:C().optional(),maxLength:C().optional(),format:B(["email","uri","date","date-time"]).optional(),default:u().optional()}),un=g({type:B(["number","integer"]),title:u().optional(),description:u().optional(),minimum:C().optional(),maximum:C().optional(),default:C().optional()}),ln=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),default:u().optional()}),pn=g({type:_("string"),title:u().optional(),description:u().optional(),oneOf:b(g({const:u(),title:u()})),default:u().optional()}),mn=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),enumNames:b(u()).optional(),default:u().optional()}),hn=U([ln,pn]),fn=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({type:_("string"),enum:b(u())}),default:b(u()).optional()}),gn=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({anyOf:b(g({const:u(),title:u()}))}),default:b(u()).optional()}),yn=U([fn,gn]),Sn=U([mn,hn,yn]),_n=U([Sn,cn,dn,un]),$t=y.extend({mode:_("form").optional(),message:u(),requestedSchema:g({type:_("object"),properties:P(u(),_n),required:b(u()).optional()}).catchall(D())}),Lt=g({type:_("ref/resource"),uri:u()}),Ht=g({type:_("ref/prompt"),name:u()}),wn=g({uri:u().startsWith("file://"),name:u().optional(),_meta:P(u(),D()).optional()}),St=ie.shape,Rn=g({experimental:St.experimental,sampling:St.sampling,elicitation:St.elicitation,roots:St.roots,extensions:St.extensions}),Le=pe.shape,cr=g({experimental:Le.experimental,logging:Le.logging,completions:Le.completions,prompts:Le.prompts,resources:Le.resources,tools:Le.tools,extensions:Le.extensions}),dr=L({progressToken:r.optional(),[wr]:u(),[Zn]:I.optional(),[br]:Rn,[Yn]:a.optional()}),Bt=g({...x.shape,...w.shape,description:u().optional(),inputSchema:L({$schema:u().optional(),type:_("object")}),outputSchema:L({$schema:u().optional()}).optional(),annotations:Dt.optional(),_meta:P(u(),D()).optional()}),bn=g({type:_("tool_result"),toolUseId:u(),content:b(yt),structuredContent:D().optional(),isError:z().optional(),_meta:P(u(),D()).optional()}),ur=U([Xe,Ve,jt,en,bn]),Jt=g({role:i,content:U([ur,b(ur)]),_meta:P(u(),D()).optional()}),lr=u(),pr=L({[Rr]:I.optional().catch(void 0)}),mr=pr.optional();function ye(re){return L({_meta:mr,resultType:lr.default("complete"),...re})}n(ye,"wireResult");let vn=ye({}),jo=ye({nextCursor:o.optional()}),hr=ye({content:b(yt),structuredContent:D().optional(),isError:z().optional()}),Cn=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),tools:b(Bt),nextCursor:o.optional()}),In=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),prompts:b(Nt),nextCursor:o.optional()}),Tn=ye({description:u().optional(),messages:b(ar)}),En=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resources:b(ae),nextCursor:o.optional()}),kn=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resourceTemplates:b(ke),nextCursor:o.optional()}),An=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),contents:b(U([Oe,$e]))}),Pn=ye({completion:g({values:b(u()).max(100),total:C().int().optional(),hasMore:z().optional()}).loose()}),Do=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"])}),xn=ye({ttlMs:C().int().min(0).catch(0),cacheScope:B(["public","private"]).catch("private"),supportedVersions:b(u()),capabilities:cr,instructions:u().optional()}),_t=g({messages:b(Jt),modelPreferences:sn.optional(),systemPrompt:u().optional(),includeContext:B(["none","thisServer","allServers"]).optional(),temperature:C().optional(),maxTokens:C().int(),stopSequences:b(u()).optional(),metadata:t.optional(),tools:b(Bt).optional(),toolChoice:an.optional()}),On=g({method:_("sampling/createMessage"),params:_t}),Un=g({method:_("roots/list"),params:g({_meta:P(u(),D()).optional()}).optional()}),Mn=g({...Jt.shape,model:u(),stopReason:u().optional()}),qn=g({roots:b(wn)}),zn=g({action:B(["accept","decline","cancel"]),content:P(u(),U([u(),C(),z(),b(u())])).optional()}),Nn=g({mode:_("url"),message:u(),url:u().url()}),jn=U([$t,Nn]),Dn=g({method:_("elicitation/create"),params:jn}),$n=U([On,Un,Dn]),Ln=U([Mn,qn,zn]),Hn=P(u(),$n),Bn=P(u(),Ln),Ft=ye({inputRequests:Hn.optional(),requestState:u().optional()}),Gt={inputResponses:Bn.optional(),requestState:u().optional()},$o=g({_meta:dr,...Gt}),Lo=L({progressToken:r.optional()});function Ue(re,Kt){return g({method:_(re),params:g({_meta:dr,...Kt})})}n(Ue,"wireRequest");function Me(re,Kt){return g({method:_(re),params:g({_meta:Lo.optional(),...Kt}).optional()})}n(Me,"dispatchRequest");let Jn={name:u(),arguments:P(u(),D()).optional(),...Gt},Ke={cursor:o.optional()},Ho=Ue("tools/call",Jn),Bo=Ue("tools/list",Ke),Jo=Ue("prompts/list",Ke),Fo=Ue("prompts/get",{name:u(),arguments:P(u(),u()).optional(),...Gt}),Go=Ue("resources/list",Ke),Vo=Ue("resources/templates/list",Ke),Ko=Ue("resources/read",{uri:u(),...Gt}),Fn={ref:U([Ht,Lt]),argument:g({name:u(),value:u()}),context:g({arguments:P(u(),u()).optional()}).optional()},Wo=Ue("completion/complete",Fn),Zo=Ue("server/discover",{}),fr=g({toolsListChanged:z().optional(),promptsListChanged:z().optional(),resourcesListChanged:z().optional(),resourceSubscriptions:b(u()).optional()}),Gn={notifications:fr},Yo=Ue("subscriptions/listen",Gn),Xo=pr.extend({"io.modelcontextprotocol/subscriptionId":s}),Vn=L({_meta:Xo,resultType:lr.default("complete")}),wt={"tools/call":Me("tools/call",Jn),"tools/list":Me("tools/list",Ke),"prompts/get":Me("prompts/get",{name:u(),arguments:P(u(),u()).optional()}),"prompts/list":Me("prompts/list",Ke),"resources/list":Me("resources/list",Ke),"resources/templates/list":Me("resources/templates/list",Ke),"resources/read":Me("resources/read",{uri:u()}),"completion/complete":Me("completion/complete",Fn),"server/discover":Me("server/discover",{}),"subscriptions/listen":Me("subscriptions/listen",Gn)};function Ae(re){return L({_meta:mr,...re})}n(Ae,"liftedResult");let Qo={"tools/call":Ae({content:b(yt),structuredContent:D().optional(),isError:z().optional()}),"tools/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),tools:b(Bt),nextCursor:o.optional()}),"prompts/get":Ae({description:u().optional(),messages:b(ar)}),"prompts/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),prompts:b(Nt),nextCursor:o.optional()}),"resources/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resources:b(ae),nextCursor:o.optional()}),"resources/templates/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resourceTemplates:b(ke),nextCursor:o.optional()}),"resources/read":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),contents:b(U([Oe,$e]))}),"completion/complete":Ae({completion:g({values:b(u()).max(100),total:C().int().optional(),hasMore:z().optional()}).loose()}),"server/discover":Ae({ttlMs:C().int().min(0).catch(0),cacheScope:B(["public","private"]).catch("private"),supportedVersions:b(u()),capabilities:cr,instructions:u().optional()}),"subscriptions/listen":Ae({})},Vt=L({"io.modelcontextprotocol/subscriptionId":s.optional()}),gr=g({method:_("notifications/subscriptions/acknowledged"),params:g({_meta:Vt.optional(),notifications:fr})}),yr=g({_meta:Vt.optional(),requestId:s,reason:u().optional()}),Sr=g({method:_("notifications/cancelled"),params:yr}),mi={"notifications/cancelled":Sr,"notifications/progress":j,"notifications/message":Z,"notifications/resources/updated":or,"notifications/resources/list_changed":ee,"notifications/tools/list_changed":nn,"notifications/prompts/list_changed":ir,"notifications/subscriptions/acknowledged":gr},Re=n(re=>g({jsonrpc:_("2.0"),id:U([u(),C().int()]),result:re}).strict(),"wireResultResponse");return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,RequestIdSchema:s,RoleSchema:i,LoggingLevelSchema:a,TaskMetadataSchema:d,RelatedTaskMetadataSchema:l,RequestMetaSchema:m,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:y,NotificationsParamsSchema:f,NotificationSchema:R,IconSchema:S,IconsSchema:w,BaseMetadataSchema:x,ImplementationSchema:I,ClientTasksCapabilitySchema:we,ServerTasksCapabilitySchema:q,ClientCapabilitiesSchema:ie,ServerCapabilitiesSchema:pe,ProgressSchema:A,ProgressNotificationParamsSchema:K,ProgressNotificationSchema:j,LoggingMessageNotificationParamsSchema:W,LoggingMessageNotificationSchema:Z,ResourceContentsSchema:De,TextResourceContentsSchema:Oe,BlobResourceContentsSchema:$e,AnnotationsSchema:G,ResourceSchema:ae,ResourceTemplateSchema:ke,ResourceListChangedNotificationSchema:ee,ResourceUpdatedNotificationParamsSchema:Ge,ResourceUpdatedNotificationSchema:or,PromptArgumentSchema:sr,PromptSchema:Nt,PromptListChangedNotificationSchema:ir,TextContentSchema:Xe,ImageContentSchema:Ve,AudioContentSchema:jt,ToolUseContentSchema:en,EmbeddedResourceSchema:tn,ResourceLinkSchema:rn,ContentBlockSchema:yt,PromptMessageSchema:ar,ToolAnnotationsSchema:Dt,ToolListChangedNotificationSchema:nn,ModelHintSchema:on,ModelPreferencesSchema:sn,ToolChoiceSchema:an,BooleanSchemaSchema:cn,StringSchemaSchema:dn,NumberSchemaSchema:un,UntitledSingleSelectEnumSchemaSchema:ln,TitledSingleSelectEnumSchemaSchema:pn,LegacyTitledEnumSchemaSchema:mn,SingleSelectEnumSchemaSchema:hn,UntitledMultiSelectEnumSchemaSchema:fn,TitledMultiSelectEnumSchemaSchema:gn,MultiSelectEnumSchemaSchema:yn,EnumSchemaSchema:Sn,PrimitiveSchemaDefinitionSchema:_n,ElicitRequestFormParamsSchema:$t,ResourceTemplateReferenceSchema:Lt,PromptReferenceSchema:Ht,RootSchema:wn,ClientCapabilities2026Schema:Rn,ServerCapabilities2026Schema:cr,RequestMetaEnvelopeSchema:dr,ToolSchema:Bt,ToolResultContentSchema:bn,SamplingMessageContentBlockSchema:ur,SamplingMessageSchema:Jt,ResultTypeSchema:lr,ResultMetaSchema:pr,ResultSchema:vn,PaginatedResultSchema:jo,CallToolResultSchema:hr,ListToolsResultSchema:Cn,ListPromptsResultSchema:In,GetPromptResultSchema:Tn,ListResourcesResultSchema:En,ListResourceTemplatesResultSchema:kn,ReadResourceResultSchema:An,CompleteResultSchema:Pn,CacheableResultSchema:Do,DiscoverResultSchema:xn,CreateMessageRequestParamsSchema:_t,CreateMessageRequestSchema:On,ListRootsRequestSchema:Un,CreateMessageResultSchema:Mn,ListRootsResultSchema:qn,ElicitResultSchema:zn,ElicitRequestURLParamsSchema:Nn,ElicitRequestParamsSchema:jn,ElicitRequestSchema:Dn,InputRequestSchema:$n,InputResponseSchema:Ln,InputRequestsSchema:Hn,InputResponsesSchema:Bn,InputRequiredResultSchema:Ft,InputResponseRequestParamsSchema:$o,CallToolRequestSchema:Ho,ListToolsRequestSchema:Bo,ListPromptsRequestSchema:Jo,GetPromptRequestSchema:Fo,ListResourcesRequestSchema:Go,ListResourceTemplatesRequestSchema:Vo,ReadResourceRequestSchema:Ko,CompleteRequestSchema:Wo,DiscoverRequestSchema:Zo,SubscriptionFilterSchema:fr,SubscriptionsListenRequestSchema:Yo,SubscriptionsListenResultMetaSchema:Xo,SubscriptionsListenResultSchema:Vn,dispatchRequestSchemas:wt,dispatchResultSchemas:Qo,NotificationMetaSchema:Vt,SubscriptionsAcknowledgedNotificationSchema:gr,CancelledNotificationParamsSchema:yr,CancelledNotificationSchema:Sr,notificationSchemas2026:mi,JSONRPCResultResponseSchema:Re(vn),CallToolResultResponseSchema:Re(U([hr,Ft])),ListToolsResultResponseSchema:Re(Cn),ListPromptsResultResponseSchema:Re(In),GetPromptResultResponseSchema:Re(U([Tn,Ft])),ListResourcesResultResponseSchema:Re(En),ListResourceTemplatesResultResponseSchema:Re(kn),ReadResourceResultResponseSchema:Re(U([An,Ft])),CompleteResultResponseSchema:Re(Pn),DiscoverResultResponseSchema:Re(xn),SubscriptionsListenResultResponseSchema:Re(Vn)}}n(N_,"build");var j_;function ct(){return j_??=N_()}n(ct,"buildSchemas2026");var D_=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function $_(e){return D_.includes(e)}n($_,"isCacheableResultMethod");var Xi=Symbol("modelcontextprotocol.resultCacheHintFallback");function L_(e){return e[Xi]}n(L_,"cacheHintFallbackOf");function hm(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}n(hm,"isValidCacheTtlMs");function fm(e){return e==="public"||e==="private"}n(fm,"isValidCacheScope");var k=(function(e){return e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e})({}),ge=class gm extends Error{static{n(this,"ProtocolError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return ze(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,t)}constructor(t,r,o){super(r),this.code=t,this.data=o,this.name="ProtocolError",Xt(this,new.target)}static fromError(t,r,o){if(t===k.UrlElicitationRequired&&o){let s=o;if(s.elicitations)return new xs(s.elicitations,r)}if(t===k.UnsupportedProtocolVersion&&o){let s=o;if(Array.isArray(s.supported)&&typeof s.requested=="string")return new Sm({supported:s.supported,requested:s.requested},r)}if(t===k.InvalidParams||t===k.ResourceNotFound){let s=o;if(typeof s?.uri=="string"&&(t===k.ResourceNotFound||Object.keys(s).length===1))return new ym(s.uri,r)}if(t===k.MissingRequiredClientCapability&&o){let s=o;if(s.requiredCapabilities!==null&&typeof s.requiredCapabilities=="object"&&!Array.isArray(s.requiredCapabilities))return new _m({requiredCapabilities:s.requiredCapabilities},r)}return new gm(t,r,o)}},ym=class extends ge{static{n(this,"ResourceNotFoundError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(k.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},xs=class extends ge{static{n(this,"UrlElicitationRequiredError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(k.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Sm=class extends ge{static{n(this,"UnsupportedProtocolVersionError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(k.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},_m=class extends ge{static{n(this,"MissingRequiredClientCapabilityError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(k.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},H_=0,B_="private",J_=["tools/call","prompts/get","resources/read"];function F_(e,t){let r=t.resultType;if(r===void 0)return{...t,resultType:"complete"};if(r==="complete"||J_.includes(e))return t;throw new ge(k.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}n(F_,"stampResultType");function G_(e,t){let r=L_(t);if(t.resultType!=="complete"||!$_(e))return r===void 0?t:Y_(t);let o=t,s=hm(o.ttlMs)?o.ttlMs:W_(r),i=fm(o.cacheScope)?o.cacheScope:Z_(r),a={...o,ttlMs:s,cacheScope:i};return delete a[Xi],a}n(G_,"fillCacheFields");function V_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(V_,"isPlainObject$4");function K_(e,t){if(t===void 0)return e;let r=e._meta;return r===void 0?{...e,_meta:{[Rr]:t}}:!V_(r)||r[Rr]!==void 0?e:{...e,_meta:{...r,[Rr]:t}}}n(K_,"stampServerInfoMeta");function W_(e){return e!==void 0&&hm(e.ttlMs)?e.ttlMs:H_}n(W_,"resolveTtlMs");function Z_(e){return e!==void 0&&fm(e.cacheScope)?e.cacheScope:B_}n(Z_,"resolveCacheScope");function Y_(e){let t={...e};return delete t[Xi],t}n(Y_,"stripCacheHintFallback");var X_=["elicitation/create","sampling/createMessage","roots/list"],Es;function Qi(){if(Es)return Es;let e=ct();return Es={request:{"elicitation/create":g({method:_("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":g({method:_("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":g({method:_("roots/list"),params:L({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Es}n(Qi,"inputSchemaMaps");function Q_(){Qi()}n(Q_,"warmInputSchemaMaps2026");function wm(e){return X_.includes(e)}n(wm,"isInputRequestMethod2026");function ji(e){return wm(e)?Qi().request[e]:void 0}n(ji,"getInputRequestSchema2026");function ew(e){return wm(e)?Qi().response[e]:void 0}n(ew,"getInputResponseSchema2026");var ea={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},Rm={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function bm(e){return Object.prototype.hasOwnProperty.call(ea,e)}n(bm,"hasRequestMethod2026");function vm(e){return Object.prototype.hasOwnProperty.call(Rm,e)}n(vm,"hasNotificationMethod2026");function tw(e){return Object.prototype.hasOwnProperty.call(ea,e)}n(tw,"hasResultMethod2026");function rw(e){return bm(e)?ct().dispatchRequestSchemas[e]:void 0}n(rw,"getRequestSchema2026");function nw(e){return tw(e)?ct().dispatchResultSchemas[e]:void 0}n(nw,"getResultSchema2026");function ow(e){return vm(e)?ct().notificationSchemas2026[e]:void 0}n(ow,"getNotificationSchema2026");var DP=Object.keys(ea),$P=Object.keys(Rm);function uo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(uo,"isPlainObject$3");function ao(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}n(ao,"triState");var sw={ok:!1,reason:"not-in-era"},iw=[wr,br];function aw(e,t){let r=t,o=!1,s=n(()=>(o||(r={...r},o=!0),r),"copy"),i=t.tools;e==="tools/list"&&Array.isArray(i)&&i.some(c=>uo(c)&&"execution"in c)&&(s().tools=i.map(c=>{if(!uo(c)||!("execution"in c))return c;let d={...c};return delete d.execution,d}));let a=t.capabilities;if(uo(a)&&"tasks"in a){let c={...a};delete c.tasks,s().capabilities=c}return r}n(aw,"enforceDeletedFields");var ta={era:"2026-07-28",hasRequestMethod:bm,hasNotificationMethod:vm,hasInputRequestMethod:n(e=>ji(e)!==void 0,"hasInputRequestMethod"),validateRequest:n((e,t)=>ao(rw(e),t),"validateRequest"),validateResult:n((e,t)=>ao(nw(e),t),"validateResult"),validateNotification:n((e,t)=>ao(ow(e),t),"validateNotification"),validateInputRequest:n((e,t)=>ao(ji(e),t),"validateInputRequest"),validateInputResponse:n((e,t)=>ao(ew(e),t),"validateInputResponse"),samplingResultVariant:n(()=>sw,"samplingResultVariant"),outboundEnvelope(e){return{[wr]:e.protocolVersion,[Zn]:e.clientInfo,[br]:e.clientCapabilities,...e.logLevel!==void 0&&{[Yn]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let o of iw)o in e||t.push({key:o,problem:"missing"});let r=ct().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let o of r.error.issues){let s=o.path.map(String),i=s.length>0?s.join("."):"_meta";s.length===1&&t.some(a=>a.key===i&&a.problem==="missing")||t.push({key:i,problem:o.message})}return t},projectCallToolResult:n(e=>am(e),"projectCallToolResult"),inputRequestSchema:ji,decodeResult(e,t){if(!uo(t))return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(r===void 0)return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: missing required resultType \u2014 servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof r!="string")return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if(r==="input_required"){let a=t.inputRequests,c=uo(a)?a:{},d=t.requestState,l=t._meta===void 0?void 0:ct().ResultMetaSchema.safeParse(t._meta),m=l?.success?l.data:void 0;return Object.keys(c).length===0&&typeof d!="string"?{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:c,...typeof d=="string"&&{requestState:d},...m!==void 0&&{_meta:m}}}if(r!=="complete")return{kind:"invalid",error:new de(fe.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let o=Cm(),s=Object.hasOwn(o,e)?o[e]:void 0;if(s!==void 0){let a=s.safeParse(t);if(!a.success)return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: ${a.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,r){return K_(G_(e,F_(e,aw(e,t))),r)},encodeErrorCode:n(e=>e===-32002?-32602:e,"encodeErrorCode"),checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=ct().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(r=>r.message).join("; ")}`}},ks;function Cm(){if(ks)return ks;let e=ct();return ks={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},ks}n(Cm,"getWireResultSchemas");function cw(){Cm()}n(cw,"warmWireResultSchemas2026");var ra="2026-07-28";function po(e){return e!==void 0&&im(e)?ta:Yi}n(po,"codecForVersion");function Yp(e){return e.revision!==void 0?po(e.revision).era:e.era==="modern"?ta.era:Yi.era}n(Yp,"classifiedWireEra");function Di(e){return Im.some(t=>t.hasRequestMethod(e))}n(Di,"isSpecRequestMethod");function $i(e){return Im.some(t=>t.hasNotificationMethod(e))}n($i,"isSpecNotificationMethod");function Xp(e){return e==="tasks/get"||e==="tasks/cancel"}n(Xp,"isExtensionReusedRequestMethod");var Im=[Yi,ta],dw=Fp({AnnotationsSchema:n(()=>Zd,"AnnotationsSchema"),AudioContentSchema:n(()=>Au,"AudioContentSchema"),BaseMetadataSchema:n(()=>kd,"BaseMetadataSchema"),BaseRequestParamsSchema:n(()=>hd,"BaseRequestParamsSchema"),BlobResourceContentsSchema:n(()=>Kd,"BlobResourceContentsSchema"),BooleanSchemaSchema:n(()=>vi,"BooleanSchemaSchema"),CallToolRequestParamsSchema:n(()=>Ju,"CallToolRequestParamsSchema"),CallToolRequestSchema:n(()=>Fu,"CallToolRequestSchema"),CallToolResultSchema:n(()=>Hu,"CallToolResultSchema"),CancelTaskRequestSchema:n(()=>jl,"CancelTaskRequestSchema"),CancelTaskResultSchema:n(()=>Dl,"CancelTaskResultSchema"),CancelledNotificationParamsSchema:n(()=>Cd,"CancelledNotificationParamsSchema"),CancelledNotificationSchema:n(()=>Id,"CancelledNotificationSchema"),ClientCapabilitiesSchema:n(()=>Od,"ClientCapabilitiesSchema"),ClientNotificationSchema:n(()=>Ll,"ClientNotificationSchema"),ClientRequestSchema:n(()=>$l,"ClientRequestSchema"),ClientResultSchema:n(()=>Hl,"ClientResultSchema"),ClientTasksCapabilitySchema:n(()=>Pd,"ClientTasksCapabilitySchema"),CompatibilityCallToolResultSchema:n(()=>Bu,"CompatibilityCallToolResultSchema"),CompleteRequestParamsSchema:n(()=>_l,"CompleteRequestParamsSchema"),CompleteRequestSchema:n(()=>wl,"CompleteRequestSchema"),CompleteResultSchema:n(()=>Rl,"CompleteResultSchema"),ContentBlockSchema:n(()=>Uu,"ContentBlockSchema"),CreateMessageRequestParamsSchema:n(()=>sl,"CreateMessageRequestParamsSchema"),CreateMessageRequestSchema:n(()=>il,"CreateMessageRequestSchema"),CreateMessageResultSchema:n(()=>al,"CreateMessageResultSchema"),CreateMessageResultWithToolsSchema:n(()=>cl,"CreateMessageResultWithToolsSchema"),CreateTaskResultSchema:n(()=>Al,"CreateTaskResultSchema"),CursorSchema:n(()=>ud,"CursorSchema"),DiscoverRequestSchema:n(()=>jd,"DiscoverRequestSchema"),DiscoverResultSchema:n(()=>Ri,"DiscoverResultSchema"),ElicitRequestFormParamsSchema:n(()=>as,"ElicitRequestFormParamsSchema"),ElicitRequestParamsSchema:n(()=>pl,"ElicitRequestParamsSchema"),ElicitRequestSchema:n(()=>ml,"ElicitRequestSchema"),ElicitRequestURLParamsSchema:n(()=>cs,"ElicitRequestURLParamsSchema"),ElicitResultSchema:n(()=>gl,"ElicitResultSchema"),ElicitationCompleteNotificationParamsSchema:n(()=>hl,"ElicitationCompleteNotificationParamsSchema"),ElicitationCompleteNotificationSchema:n(()=>fl,"ElicitationCompleteNotificationSchema"),EmbeddedResourceSchema:n(()=>xu,"EmbeddedResourceSchema"),EmptyResultSchema:n(()=>vd,"EmptyResultSchema"),EnumSchemaSchema:n(()=>ll,"EnumSchemaSchema"),GetPromptRequestParamsSchema:n(()=>Iu,"GetPromptRequestParamsSchema"),GetPromptRequestSchema:n(()=>Tu,"GetPromptRequestSchema"),GetPromptResultSchema:n(()=>qu,"GetPromptResultSchema"),GetTaskPayloadRequestSchema:n(()=>Ml,"GetTaskPayloadRequestSchema"),GetTaskPayloadResultSchema:n(()=>ql,"GetTaskPayloadResultSchema"),GetTaskRequestSchema:n(()=>Ol,"GetTaskRequestSchema"),GetTaskResultSchema:n(()=>Ul,"GetTaskResultSchema"),IconSchema:n(()=>Td,"IconSchema"),IconsSchema:n(()=>Ed,"IconsSchema"),ImageContentSchema:n(()=>ku,"ImageContentSchema"),ImplementationSchema:n(()=>Ad,"ImplementationSchema"),InitializeRequestParamsSchema:n(()=>Ud,"InitializeRequestParamsSchema"),InitializeRequestSchema:n(()=>Md,"InitializeRequestSchema"),InitializeResultSchema:n(()=>zd,"InitializeResultSchema"),InitializedNotificationSchema:n(()=>Nd,"InitializedNotificationSchema"),JSONArraySchema:n(()=>cd,"JSONArraySchema"),JSONObjectSchema:n(()=>ad,"JSONObjectSchema"),JSONRPCErrorResponseSchema:n(()=>Xn,"JSONRPCErrorResponseSchema"),JSONRPCMessageSchema:n(()=>wi,"JSONRPCMessageSchema"),JSONRPCNotificationSchema:n(()=>Si,"JSONRPCNotificationSchema"),JSONRPCRequestSchema:n(()=>Wt,"JSONRPCRequestSchema"),JSONRPCResponseSchema:n(()=>bd,"JSONRPCResponseSchema"),JSONRPCResultResponseSchema:n(()=>_i,"JSONRPCResultResponseSchema"),JSONValueSchema:n(()=>id,"JSONValueSchema"),LegacyTitledEnumSchemaSchema:n(()=>Ti,"LegacyTitledEnumSchemaSchema"),ListChangedOptionsBaseSchema:n(()=>bi,"ListChangedOptionsBaseSchema"),ListPromptsRequestSchema:n(()=>vu,"ListPromptsRequestSchema"),ListPromptsResultSchema:n(()=>Cu,"ListPromptsResultSchema"),ListResourceTemplatesRequestSchema:n(()=>tu,"ListResourceTemplatesRequestSchema"),ListResourceTemplatesResultSchema:n(()=>ru,"ListResourceTemplatesResultSchema"),ListResourcesRequestSchema:n(()=>Qd,"ListResourcesRequestSchema"),ListResourcesResultSchema:n(()=>eu,"ListResourcesResultSchema"),ListRootsRequestSchema:n(()=>vl,"ListRootsRequestSchema"),ListRootsResultSchema:n(()=>Cl,"ListRootsResultSchema"),ListTasksRequestSchema:n(()=>zl,"ListTasksRequestSchema"),ListTasksResultSchema:n(()=>Nl,"ListTasksResultSchema"),ListToolsRequestSchema:n(()=>$u,"ListToolsRequestSchema"),ListToolsResultSchema:n(()=>Lu,"ListToolsResultSchema"),LoggingLevelSchema:n(()=>Vu,"LoggingLevelSchema"),LoggingMessageNotificationParamsSchema:n(()=>Zu,"LoggingMessageNotificationParamsSchema"),LoggingMessageNotificationSchema:n(()=>Yu,"LoggingMessageNotificationSchema"),ModelHintSchema:n(()=>Xu,"ModelHintSchema"),ModelPreferencesSchema:n(()=>Qu,"ModelPreferencesSchema"),MultiSelectEnumSchemaSchema:n(()=>ul,"MultiSelectEnumSchemaSchema"),NotificationSchema:n(()=>Sd,"NotificationSchema"),NotificationsParamsSchema:n(()=>yd,"NotificationsParamsSchema"),NumberSchemaSchema:n(()=>is,"NumberSchemaSchema"),PaginatedRequestParamsSchema:n(()=>Bd,"PaginatedRequestParamsSchema"),PaginatedRequestSchema:n(()=>Jd,"PaginatedRequestSchema"),PaginatedResultSchema:n(()=>Fd,"PaginatedResultSchema"),PingRequestSchema:n(()=>Dd,"PingRequestSchema"),PrimitiveSchemaDefinitionSchema:n(()=>Ai,"PrimitiveSchemaDefinitionSchema"),ProgressNotificationParamsSchema:n(()=>Ld,"ProgressNotificationParamsSchema"),ProgressNotificationSchema:n(()=>Hd,"ProgressNotificationSchema"),ProgressSchema:n(()=>$d,"ProgressSchema"),ProgressTokenSchema:n(()=>dd,"ProgressTokenSchema"),PromptArgumentSchema:n(()=>Ru,"PromptArgumentSchema"),PromptListChangedNotificationSchema:n(()=>zu,"PromptListChangedNotificationSchema"),PromptMessageSchema:n(()=>Mu,"PromptMessageSchema"),PromptReferenceSchema:n(()=>Sl,"PromptReferenceSchema"),PromptSchema:n(()=>bu,"PromptSchema"),ReadResourceRequestParamsSchema:n(()=>ou,"ReadResourceRequestParamsSchema"),ReadResourceRequestSchema:n(()=>su,"ReadResourceRequestSchema"),ReadResourceResultSchema:n(()=>iu,"ReadResourceResultSchema"),RelatedTaskMetadataSchema:n(()=>pd,"RelatedTaskMetadataSchema"),RequestIdSchema:n(()=>Rd,"RequestIdSchema"),RequestMetaSchema:n(()=>md,"RequestMetaSchema"),RequestSchema:n(()=>gd,"RequestSchema"),ResourceContentsSchema:n(()=>Gd,"ResourceContentsSchema"),ResourceLinkSchema:n(()=>Ou,"ResourceLinkSchema"),ResourceListChangedNotificationSchema:n(()=>au,"ResourceListChangedNotificationSchema"),ResourceRequestParamsSchema:n(()=>nu,"ResourceRequestParamsSchema"),ResourceSchema:n(()=>Yd,"ResourceSchema"),ResourceTemplateReferenceSchema:n(()=>yl,"ResourceTemplateReferenceSchema"),ResourceTemplateSchema:n(()=>Xd,"ResourceTemplateSchema"),ResourceUpdatedNotificationParamsSchema:n(()=>_u,"ResourceUpdatedNotificationParamsSchema"),ResourceUpdatedNotificationSchema:n(()=>wu,"ResourceUpdatedNotificationSchema"),ResultMetaObjectSchema:n(()=>_d,"ResultMetaObjectSchema"),ResultSchema:n(()=>wd,"ResultSchema"),RoleSchema:n(()=>Wd,"RoleSchema"),RootSchema:n(()=>bl,"RootSchema"),RootsListChangedNotificationSchema:n(()=>Il,"RootsListChangedNotificationSchema"),SamplingContentSchema:n(()=>rl,"SamplingContentSchema"),SamplingMessageContentBlockSchema:n(()=>nl,"SamplingMessageContentBlockSchema"),SamplingMessageSchema:n(()=>ol,"SamplingMessageSchema"),ServerCapabilitiesSchema:n(()=>qd,"ServerCapabilitiesSchema"),ServerNotificationSchema:n(()=>Jl,"ServerNotificationSchema"),ServerRequestSchema:n(()=>Bl,"ServerRequestSchema"),ServerResultSchema:n(()=>Fl,"ServerResultSchema"),ServerTasksCapabilitySchema:n(()=>xd,"ServerTasksCapabilitySchema"),SetLevelRequestParamsSchema:n(()=>Ku,"SetLevelRequestParamsSchema"),SetLevelRequestSchema:n(()=>Wu,"SetLevelRequestSchema"),SingleSelectEnumSchemaSchema:n(()=>dl,"SingleSelectEnumSchemaSchema"),StringSchemaSchema:n(()=>ss,"StringSchemaSchema"),SubscribeRequestParamsSchema:n(()=>cu,"SubscribeRequestParamsSchema"),SubscribeRequestSchema:n(()=>du,"SubscribeRequestSchema"),SubscriptionFilterSchema:n(()=>pu,"SubscriptionFilterSchema"),SubscriptionsAcknowledgedNotificationParamsSchema:n(()=>fu,"SubscriptionsAcknowledgedNotificationParamsSchema"),SubscriptionsAcknowledgedNotificationSchema:n(()=>gu,"SubscriptionsAcknowledgedNotificationSchema"),SubscriptionsListenRequestParamsSchema:n(()=>mu,"SubscriptionsListenRequestParamsSchema"),SubscriptionsListenRequestSchema:n(()=>hu,"SubscriptionsListenRequestSchema"),SubscriptionsListenResultMetaSchema:n(()=>yu,"SubscriptionsListenResultMetaSchema"),SubscriptionsListenResultSchema:n(()=>Su,"SubscriptionsListenResultSchema"),TaskAugmentedRequestParamsSchema:n(()=>fd,"TaskAugmentedRequestParamsSchema"),TaskCreationParamsSchema:n(()=>Tl,"TaskCreationParamsSchema"),TaskMetadataSchema:n(()=>ld,"TaskMetadataSchema"),TaskSchema:n(()=>kl,"TaskSchema"),TaskStatusNotificationParamsSchema:n(()=>Pl,"TaskStatusNotificationParamsSchema"),TaskStatusNotificationSchema:n(()=>xl,"TaskStatusNotificationSchema"),TaskStatusSchema:n(()=>El,"TaskStatusSchema"),TextContentSchema:n(()=>Eu,"TextContentSchema"),TextResourceContentsSchema:n(()=>Vd,"TextResourceContentsSchema"),TitledMultiSelectEnumSchemaSchema:n(()=>ki,"TitledMultiSelectEnumSchemaSchema"),TitledSingleSelectEnumSchemaSchema:n(()=>Ii,"TitledSingleSelectEnumSchemaSchema"),ToolAnnotationsSchema:n(()=>Nu,"ToolAnnotationsSchema"),ToolChoiceSchema:n(()=>el,"ToolChoiceSchema"),ToolExecutionSchema:n(()=>ju,"ToolExecutionSchema"),ToolListChangedNotificationSchema:n(()=>Gu,"ToolListChangedNotificationSchema"),ToolResultContentSchema:n(()=>tl,"ToolResultContentSchema"),ToolSchema:n(()=>Du,"ToolSchema"),ToolUseContentSchema:n(()=>Pu,"ToolUseContentSchema"),UnsubscribeRequestParamsSchema:n(()=>uu,"UnsubscribeRequestParamsSchema"),UnsubscribeRequestSchema:n(()=>lu,"UnsubscribeRequestSchema"),UntitledMultiSelectEnumSchemaSchema:n(()=>Ei,"UntitledMultiSelectEnumSchemaSchema"),UntitledSingleSelectEnumSchemaSchema:n(()=>Ci,"UntitledSingleSelectEnumSchemaSchema")});var Tm=n(e=>Wt.safeParse(e).success,"isJSONRPCRequest"),Em=n(e=>Si.safeParse(e).success,"isJSONRPCNotification"),Fi=n(e=>_i.safeParse(e).success,"isJSONRPCResultResponse"),km=n(e=>Xn.safeParse(e).success,"isJSONRPCErrorResponse");var lo=-32020,LP=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32e3],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[k.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[lo,k.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[k.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope \u2014 and a missing envelope on a request whose protocol-version header names a modern revision \u2014 is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[k.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision\u2019s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[k.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[lo],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[k.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced \u2014 pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[lo],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool\u2019s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],HP={[k.ParseError]:400,[k.InvalidRequest]:400,[k.MethodNotFound]:404,[k.UnsupportedProtocolVersion]:400,[k.MissingRequiredClientCapability]:400,[lo]:400};function na(e,t){return Xc(e,t)}n(na,"parseSchema");function co(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}n(co,"shapeKeys");function Gi(e){if(e==null)return!1;let t=typeof e;return t!=="object"&&t!=="function"||!("~standard"in e)?!1:typeof e["~standard"]?.validate=="function"}n(Gi,"isStandardSchema");var Qp=!1,Vi="draft-2020-12";function uw(e,t="input"){let r=e["~standard"],o;if(r.jsonSchema)o=r.jsonSchema[t]({target:Vi});else if(r.vendor==="zod"){if(!("_zod"in e))throw new Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");Qp||(Qp=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),o=hi(e,{target:Vi,io:t})}else throw new Error(`Schema library "${r.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output")return o.type!==void 0?o:Am(o)?{type:"object",...o}:o;if(o.type!==void 0&&o.type!=="object")throw new Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(o.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...o}}n(uw,"standardSchemaToJsonSchema");function Am(e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;for(let t of["oneOf","anyOf","allOf"]){let r=e[t];if(Array.isArray(r)&&r.length>0)return r.every(o=>o!==null&&typeof o=="object"&&(o.type==="object"||Am(o)))}return!1}n(Am,"isProvablyObjectShapedRoot");function lw(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}n(lw,"formatIssue");async function Li(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(o=>lw(o)).join(", ")}:{success:!0,data:r.value}}n(Li,"validateStandardSchema");function pw(e){let t=hi(e,{target:Vi,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}n(pw,"zodEmittedPattern");var mw=/\\\.\\d\{(\d+)\}/;function hw(e){let t=mw.exec(e),r=[void 0,-1,0];return t&&r.push(Number(t[1])),[!1,!0].flatMap(o=>[!1,!0].flatMap(s=>r.map(i=>Wn.datetime({local:o,offset:s,precision:i}))))}n(hw,"datetimeReferenceSchemas");function fw(e,t){let r;switch(e){case"email":r=[Qc()];break;case"uri":r=[ed()];break;case"date":r=[Wn.date()];break;case"date-time":r=hw(t);break}return new Set(r.map(o=>pw(o)).filter(o=>o!==void 0))}n(fw,"referencePatternsForFormat");function gw(e,t,r){return r!=="zod"?!0:fw(e,t).has(t)}n(gw,"isLibraryFormatPattern");function mo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}n(mo,"isJsonObject");function yw(e){try{return uw(e,"input")}catch(t){let r=t instanceof Error?t.message:String(t);throw new ge(k.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${r}`)}}n(yw,"convertStandardElicitationSchema");var Sw=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function oa(e){return Sw.has(e)||e.startsWith("x-")}n(oa,"isAnnotationOnlyJsonSchemaKeyword");var _w=new Set(["$schema",...Object.keys(as.shape.requestedSchema.shape)]),em={string:co([ss,Ci,Ii,Ti]),number:co([is]),integer:co([is]),boolean:co([vi]),array:co([Ei,ki])},ww=new Set(ss.shape.format.unwrap().options);function Rw(e,t,r,o){if(!mo(e))return e;let s=typeof e.type=="string"&&Object.hasOwn(em,e.type)?em[e.type]:void 0;if(s===void 0)return e;let i={};for(let[a,c]of Object.entries(e))s.has(a)||oa(a)?i[a]=c:a==="pattern"&&e.type==="string"&&typeof e.format=="string"?ww.has(e.format)?(typeof c!="string"||!gw(e.format,c,r))&&o.push(`${t}.${a}`):i[a]=c:o.push(`${t}.${a}`);return i}n(Rw,"walkProperty");function bw(e,t){let r={},o=[];for(let[s,i]of Object.entries(e))s==="properties"&&mo(i)?r[s]=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,Rw(c,`properties.${a}`,t,o)])):_w.has(s)?r[s]=i:oa(s)||o.push(s);if(o.length>0)throw new ge(k.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);return r}n(bw,"walkRequestedSchema");function vw(e,t){if(!mo(e.properties))return t;let r=Object.entries(e.properties).filter(([,o])=>!na(Ai,o).success).map(([o])=>`properties.${o}`);return r.length>0?r.join(", "):t}n(vw,"describeUnsupportedProperties");function Ki(e,t,r=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((o,s)=>Ki(o,t[s],`${r}[${s}]`)):!mo(e)||!mo(t)?[]:Object.entries(e).flatMap(([o,s])=>{let i=r?`${r}.${o}`:o;return Object.prototype.hasOwnProperty.call(t,o)?Ki(s,t[o],i):oa(o)?[]:[i]})}n(Ki,"findDroppedConstraintPaths");function Cw(e){if(!Gi(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,r=bw(yw(e.requestedSchema),t),o=na(as.shape.requestedSchema,r);if(!o.success)throw new ge(k.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${vw(r,o.error.message)}`);let s=Ki(r,o.data);if(s.length>0)throw new ge(k.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${s.join(", ")}`);let i=(o.data.required??[]).filter(a=>!Object.prototype.hasOwnProperty.call(o.data.properties,a));if(i.length>0)throw new ge(k.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:o.data}}n(Cw,"normalizeElicitInputParams");function Iw(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,r=typeof e.requestState=="string";if(!t&&!r)throw new TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}n(Iw,"buildInputRequired");var BP=Object.assign(Iw,{elicit(e){try{return{method:"elicitation/create",params:Cw(e)}}catch(t){throw t instanceof ge?new TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var Tw=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],Ew={IdJagTokenExchangeResponseSchema:Pi,OAuthClientInformationFullSchema:Zt,OAuthClientInformationSchema:Qn,OAuthClientMetadataSchema:Vl,OAuthClientRegistrationErrorSchema:Kl,OAuthErrorResponseSchema:ds,OAuthMetadataSchema:Ir,OAuthProtectedResourceMetadataSchema:Cr,OAuthTokenRevocationRequestSchema:Wl,OAuthTokensSchema:Rt,OpenIdProviderDiscoveryMetadataSchema:Tr,OpenIdProviderMetadataSchema:Gl},Pm={},xm={};function Om(e,t){let r=e.slice(0,-6);Pm[r]=t,xm[r]=o=>t.safeParse(o).success}n(Om,"register");for(let e of Tw)Om(e,dw[e]);for(let[e,t]of Object.entries(Ew))Om(e,t);var kw=Object.freeze(Pm),Aw=Object.freeze(xm);function Pw(e){switch(e){case"initialize":case"notifications/initialized":return po(void 0);case"server/discover":return po(ra);default:return}}n(Pw,"bootstrapOutboundCodec");var Um=6e4,xw=[wr,Zn,br,Yn],Ow=["inputResponses","requestState"];function tm(e,t){let r=e.params;if(!Hi(r))return{message:e,lifted:{}};let o=r._meta,s=Hi(o)?xw.filter(d=>d in o):[],i=t==="request"?Ow.filter(d=>d in r):[];if(s.length===0&&i.length===0)return{message:e,lifted:{}};let a={},c={...r};if(s.length>0&&Hi(o)){let d={},l={...o};for(let m of s)d[m]=o[m],delete l[m];a.envelope=d,Object.keys(l).length>0?c._meta=l:delete c._meta}for(let d of i)d==="inputResponses"&&(a.inputResponses=c[d]),d==="requestState"&&(a.requestState=c[d]),delete c[d];return{message:{...e,params:c},lifted:a}}n(tm,"liftWireOnlyMaterial");function rm(e,t){let r=e.validateResult(t,void 0);if(!(!r.ok&&r.reason==="not-in-era"))return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(o){let s=e.validateResult(t,o);return s.ok?{value:s.value}:{issues:[{message:s.reason==="invalid"?s.message:`not-in-era: ${t}`}]}}}}}n(rm,"codecResultValidator");function Mm(e){return()=>e}n(Mm,"requestStateAccessor");var Uw=Mm(void 0),Mw,qw=class{static{n(this,"Protocol")}_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{Mw=n((e,t)=>{e._negotiatedProtocolVersion=t},"writeNegotiatedProtocolVersion")}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??yi,this.setNotificationHandler("notifications/cancelled",t=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",t=>{this._onprogress(t)}),this.setRequestHandler("ping",t=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new de(fe.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new de(fe.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=s=>{r?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Fi(s)||km(s)?this._onresponse(s):Tm(s)?this._onrequest(s,i):Em(s)?this._onnotification(s,i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new de(fe.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let o of e.values())o(r);for(let o of t.values())o.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=tm(e,"notification"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let a=Yp(t.classification);if(a!==o.era){this._onerror(new Error(`Era mismatch on inbound notification '${r.method}': classified as ${a} but this instance serves ${o.era}`));return}}if($i(r.method)&&!o.hasNotificationMethod(r.method))return;let s=this._notificationHandlers.get(r.method),i=this.fallbackNotificationHandler;s===void 0&&i===void 0||Promise.resolve().then(()=>s===void 0?i(r):s(r,o)).catch(a=>this._onerror(new Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(e,t){let{message:r,lifted:o}=tm(e,"request"),s=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(new Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let i=this._transport,a=n((S,w,x)=>{let I={jsonrpc:"2.0",id:r.id,error:{code:S,message:w,...x!==void 0&&{data:x}}};i?.send(I).catch(O=>this._onerror(new Error(`Failed to send an error response: ${O}`)))},"sendErrorResponse");if(t?.classification!==void 0){let S=Yp(t.classification);if(S!==s.era){this._onerror(new Error(`Era mismatch on inbound request '${r.method}': classified as ${S} but this instance serves ${s.era}`));let w=t.classification.revision??S;a(k.UnsupportedProtocolVersion,`Unsupported protocol version: ${w}`,{supported:this._supportedProtocolVersions,requested:w});return}}if(Di(r.method)&&!s.hasRequestMethod(r.method)&&!(Xp(r.method)&&this._customSchemaRequestMethods.has(r.method))){a(k.MethodNotFound,"Method not found");return}let c=this._requestHandlers.get(r.method)??this.fallbackRequestHandler;if(c===void 0){a(k.MethodNotFound,"Method not found");return}let d=s.checkInboundEnvelope(o);if(d!==void 0){a(k.InvalidParams,d);return}let l=n((S,w)=>this._notificationViaCodec(this._resolveOutboundCodec(S.method),S,{...w,relatedRequestId:r.id}),"sendNotification"),m=n((S,w,x)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(S.method),S,w,{...x,relatedRequestId:r.id}),"sendRequest"),h=new AbortController;this._requestHandlerAbortControllers.set(r.id,h);let y=o.inputResponses===void 0?void 0:zw(o.inputResponses),f={sessionId:i?.sessionId,mcpReq:{id:r.id,method:r.method,_meta:r.params?._meta,...o.envelope!==void 0&&{envelope:o.envelope},...y!==void 0&&{inputResponses:y.accepted},...y!==void 0&&y.droppedKeys.length>0&&{droppedInputResponseKeys:y.droppedKeys},requestState:o.requestState===void 0?Uw:Mm(o.requestState),signal:h.signal,send:n(((S,w,x)=>{let I=this._resolveOutboundCodec(S.method);if(this._assertOutboundRequestInEra(I,S.method),Gi(w))return m(S,w,x);let O=rm(I,S.method);if(O===void 0)throw new TypeError(`'${S.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return m(S,O,w)}),"send"),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},R=this.buildContext(f,t);Promise.resolve().then(()=>c(r,R)).then(async S=>{if(h.signal.aborted)return;let w;try{w=s.encodeResult(r.method,S,this._outboundServerInfo())}catch(I){this._onerror(new Error(`Failed to encode result for ${r.method}: ${I}`)),a(k.InternalError,"Internal error");return}let x={result:w,jsonrpc:"2.0",id:r.id};await i?.send(x)},async S=>{if(h.signal.aborted)return;let w=Number.isSafeInteger(S.code)?S.code:k.InternalError,x={jsonrpc:"2.0",id:r.id,error:{code:s.encodeErrorCode(w),message:S.message??"Internal error",...S.data!==void 0&&{data:S.data}}};await i?.send(x)}).catch(S=>this._onerror(new Error(`Failed to send response: ${S}`))).finally(()=>{this._requestHandlerAbortControllers.get(r.id)===h&&this._requestHandlerAbortControllers.delete(r.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,o=Number(t),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Fi(e)?r(e):r(ge.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let o=this._resolveOutboundCodec(e.method);if(Gi(t))return Xp(e.method)||this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r);this._assertOutboundRequestInEra(o,e.method);let s=rm(o,e.method);if(s===void 0)throw new TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(o,e,s,t)}_negotiatedWireCodec(){return po(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=Pw(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Di(t)&&!e.hasRequestMethod(t))throw new de(fe.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let o=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r)}_requestWithSchemaViaCodec(e,t,r,o){let{relatedRequestId:s,resumptionToken:i,onresumptiontoken:a,headers:c}=o??{},d=Date.now(),l,m;return new Promise((h,y)=>{let f=n(q=>{y(q)},"earlyReject");if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(q){f(q);return}if(o?.signal?.aborted){let q=o.signal.reason;throw q instanceof de?q:new de(fe.RequestTimeout,String(q))}let R=e.era===ra&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,S=this._requestMessageId++;m=S;let w={...t,jsonrpc:"2.0",id:S};o?.onprogress&&(this._progressHandlers.set(S,o.onprogress),w.params={...t.params,_meta:{...t.params?._meta,progressToken:S}});let x=this._envelopeOutbound(w),I=!1,O=n(q=>{I||(this._progressHandlers.delete(S),R===void 0?t.method!=="initialize"&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:S,reason:String(q)}}),{relatedRequestId:s,resumptionToken:i,onresumptiontoken:a}).catch(ie=>this._onerror(new Error(`Failed to send cancellation: ${ie}`))):R.abort(),y(q instanceof de?q:new de(fe.RequestTimeout,String(q))))},"cancel");this._responseHandlers.set(S,q=>{if(o?.signal?.aborted)return;if(I=!0,q instanceof Error)return y(q);let ie;try{ie=e.decodeResult(t.method,q.result)}catch(A){return y(A instanceof Error?A:new Error(String(A)))}if(ie.kind==="invalid")return y(ie.error);if(ie.kind==="input_required"){if(o?.allowInputRequired===!0)return h(Nw(ie));let A={codec:e,request:t,resultSchema:r,options:o,flowStartedAt:d,retry:n((K,j)=>this._requestWithSchemaViaCodec(e,K===void 0?{method:t.method}:{method:t.method,params:K},r,j),"retry")};return h(this._resolveNonCompleteResult(ie,A))}let pe=ie.result;Li(r,pe).then(A=>{A.success?h(A.data):y(new de(fe.InvalidResult,`Invalid result for ${t.method}: ${A.error}`))},y)}),l=n(()=>O(o?.signal?.reason),"onAbort"),o?.signal?.addEventListener("abort",l,{once:!0});let N=o?.timeout??Um,we=n(()=>O(new de(fe.RequestTimeout,"Request timed out",{timeout:N})),"timeoutHandler");this._setupTimeout(S,N,o?.maxTotalTimeout,we,o?.resetTimeoutOnProgress??!1),this._transport.send(x,{relatedRequestId:s,resumptionToken:i,onresumptiontoken:a,headers:c,requestSignal:R?.signal}).catch(q=>{this._progressHandlers.delete(S),y(q)})}).finally(()=>{l&&o?.signal?.removeEventListener("abort",l),m!==void 0&&(this._responseHandlers.delete(m),this._cleanupTimeout(m))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new de(fe.NotConnected,"Not connected");if($i(t.method)&&!e.hasNotificationMethod(t.method))throw new de(fe.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let o=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(o,r).catch(s=>this._onerror(s))});return}await this._transport.send(o,r)}setRequestHandler(e,t,r){this.assertRequestHandlerCapability(e);let o;if(typeof t=="function"){if(!Di(e))throw new TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);o=n((s,i)=>{let a=this._negotiatedWireCodec(),c=a.validateRequest(e,s);if(!c.ok&&c.reason==="not-in-era"&&(c=a.validateInputRequest(e,s)),!c.ok)throw c.reason==="not-in-era"?new ge(k.InternalError,`No wire schema for ${e} in the resolved era`):new Error(c.message);return Promise.resolve(t(c.value,i))},"stored")}else if(r)o=n(async(s,i)=>{let a=await Li(t.params,{...s.params});if(!a.success)throw new ge(k.InvalidParams,`Invalid params for ${e}: ${a.error}`);return r(a.data,i)},"stored");else throw new TypeError("setRequestHandler: handler is required");typeof t=="function"?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,o))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if(typeof t=="function"){if(!$i(e))throw new TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(o,s)=>{let i=s.validateNotification(e,o);if(!i.ok)throw i.reason==="not-in-era"?new ge(k.InternalError,`No wire schema for ${e} in the resolved era`):new Error(i.message);return Promise.resolve(t(i.value))});return}if(!r)throw new TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async o=>{let s=await Li(t.params,{...o.params});if(!s.success)throw new ge(k.InvalidParams,`Invalid params for notification ${e}: ${s.error}`);await r(s.data,o)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Hi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(Hi,"isPlainObject$1");function nm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}n(nm,"isPlainObject");function zw(e){let t={},r=[];if(!nm(e))return{accepted:t,droppedKeys:r};for(let[o,s]of Object.entries(e)){if(!nm(s)||"method"in s||"result"in s){r.push(o);continue}t[o]=s}return{accepted:t,droppedKeys:r}}n(zw,"partitionInputResponses");function Nw(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}n(Nw,"manualInputRequiredValue");var jw=Jp((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,o=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=s;function s(c){if(!c)throw new TypeError("argument string is required");var d=typeof c=="object"?i(c):c;if(typeof d!="string")throw new TypeError("argument string is required to be a string");var l=d.indexOf(";"),m=l!==-1?d.slice(0,l).trim():d.trim();if(!o.test(m))throw new TypeError("invalid media type");var h=new a(m.toLowerCase());if(l!==-1){var y,f,R;for(t.lastIndex=l;f=t.exec(d);){if(f.index!==l)throw new TypeError("invalid parameter format");l+=f[0].length,y=f[1].toLowerCase(),R=f[2],R.charCodeAt(0)===34&&(R=R.slice(1,-1),R.indexOf("\\")!==-1&&(R=R.replace(r,"$1"))),h.parameters[y]=R}if(l!==d.length)throw new TypeError("invalid parameter format")}return h}n(s,"parse");function i(c){var d;if(typeof c.getHeader=="function"?d=c.getHeader("content-type"):typeof c.headers=="object"&&(d=c.headers&&c.headers["content-type"]),typeof d!="string")throw new TypeError("content-type header is missing from object");return d}n(i,"getcontenttype");function a(c){this.parameters=Object.create(null),this.type=c}n(a,"ContentType")})),JP=Gp(jw(),1);var Dw=10*1024*1024;var $w=new Set([301,302,303,307,308]),Lw=5;function Hw(e,t){return e.protocol===t.protocol&&e.host===t.host?!0:e.protocol==="http:"&&t.protocol==="https:"&&e.hostname===t.hostname&&!e.port&&!t.port}n(Hw,"isWithinOrigin");function Bw(e,t){let r=$w.has(t.status)?t.headers?.get("location"):void 0;if(r)try{return new URL(r,e)}catch{return}}n(Bw,"redirectTarget");var Jw=new WeakSet;function Os(e){return Jw.has(e)?e:async(t,r)=>{if(r?.redirect==="error"||r?.redirect==="manual")return e(t,r);let o=(r?.method??"GET").toUpperCase(),s=t;for(let i=0;;i++){let a=await e(s,{...r,redirect:"manual"}),c=Bw(s,a);if(!c||i===Lw)return a;let d=new URL(s),l=o==="GET"||a.status===307||a.status===308,m=!(c.username||c.password)||c.username===d.username&&c.password===d.password;if(!l||!m||!Hw(d,c))return a;await a.text?.().catch(()=>{}),s=c}}}n(Os,"fetchWithinOrigin");function sa(){Zi(),ct(),O_(),Q_(),cw()}n(sa,"preloadSchemas");var rx=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");var Fw=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Gw=[0,31,28,31,30,31,30,31,31,30,31,30,31],Vw=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Kw=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Ww=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Zw=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Yw=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Xw=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Qw=/^(?:\/(?:[^~/]|~0|~1)*)*$/,eR=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,tR=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,rR=n(e=>{if(e[0]==='"')return!1;let[t,r,...o]=e.split("@");return!t||!r||o.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(s=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(s))},"EMAIL"),nR=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,oR=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,sR=n(e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),"DURATION");function et(e){return e.test.bind(e)}n(et,"bind");var nx={date:qm,time:zm.bind(void 0,!1),"date-time":cR,duration:sR,uri:lR,"uri-reference":et(Ww),"uri-template":et(Zw),url:et(Yw),email:rR,hostname:et(Kw),ipv4:et(nR),ipv6:et(oR),regex:mR,uuid:et(Xw),"json-pointer":et(Qw),"json-pointer-uri-fragment":et(eR),"relative-json-pointer":et(tR)};function iR(e){return e%4===0&&(e%100!==0||e%400===0)}n(iR,"isLeapYear");function qm(e){let t=e.match(Fw);if(!t)return!1;let r=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o==2&&iR(r)?29:Gw[o])}n(qm,"date");function zm(e,t){let r=t.match(Vw);if(!r)return!1;let o=+r[1],s=+r[2],i=+r[3],a=!!r[5];return(o<=23&&s<=59&&i<=59||o==23&&s==59&&i==60)&&(!e||a)}n(zm,"time");var aR=/t|\s/i;function cR(e){let t=e.split(aR);return t.length==2&&qm(t[0])&&zm(!0,t[1])}n(cR,"date_time");var dR=/\/|:/,uR=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function lR(e){return dR.test(e)&&uR.test(e)}n(lR,"uri");var pR=/[^\\]\\Z/;function mR(e){if(pR.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}n(mR,"regex");sa();var Nm=!1;var ia;ia=globalThis.crypto;async function fR(e){return(await ia).getRandomValues(new Uint8Array(e))}n(fR,"getRandomValues");async function gR(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,o="";for(;o.length<e;){let s=await fR(e-o.length);for(let i of s)i<r&&(o+=t[i%t.length])}return o}n(gR,"random");async function yR(e){return await gR(e)}n(yR,"generateVerifier");async function SR(e){let t=await(await ia).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}n(SR,"generateChallenge");async function aa(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await yR(e),r=await SR(t);return{code_verifier:t,code_challenge:r}}n(aa,"pkceChallenge");var fo=class extends Error{static{n(this,"OAuthClientFlowError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e){super(e),this.name=new.target.name,Xt(this,new.target)}},ho=class extends fo{static{n(this,"IssuerMismatchError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,r){super(`Issuer mismatch in ${e==="metadata"?"authorization server metadata (RFC 8414 \xA73.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(r)}`),this.kind=e,this.expected=t,this.received=r}},pa=class extends fo{static{n(this,"RegistrationRejectedError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`),this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},qs=class extends fo{static{n(this,"InsecureTokenEndpointError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`),this.tokenEndpoint=e}},Ms=class extends fo{static{n(this,"AuthorizationServerMismatchError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`),this.recordedIssuer=e,this.currentIssuer=t}},Gx=class extends fo{static{n(this,"InsufficientScopeError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`),this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};function la(e,t,r){if(e)return typeof e.issuer!="string"?(r?.canPersistStamp!==!1&&console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field."),e.issuer===void 0?e:{...e,issuer:void 0}):Lm(e.issuer,t)?e:void 0}n(la,"discardIfIssuerMismatch");function Lm(e,t){return e===t||e.endsWith("/")&&e.slice(0,-1)===t||t.endsWith("/")&&t.slice(0,-1)===e}n(Lm,"issuersMatch");var Vx=class extends Error{static{n(this,"UnauthorizedError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e){super(e??"Unauthorized"),this.name="UnauthorizedError",Xt(this,new.target)}};function Hm(e){return e?.authorization_response_iss_parameter_supported===!0}n(Hm,"isIssParameterSupported");function Bm({iss:e,expectedIssuer:t,issParameterSupported:r}){if(t!==void 0){if(e===void 0){if(r)throw new ho("authorization_response",t,void 0);return}if(e!==t)throw new ho("authorization_response",t,e)}}n(Bm,"validateAuthorizationResponseIssuer");function _R(e){return["client_secret_basic","client_secret_post","none"].includes(e)}n(_R,"isClientAuthMethod");var ca="code",da="S256";function wR(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&_R(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}n(wR,"selectClientAuthMethod");function RR(e,t,r,o){let{client_id:s,client_secret:i}=t;switch(e){case"client_secret_basic":bR(s,i,r);return;case"client_secret_post":vR(s,i,o);return;case"none":CR(s,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}n(RR,"applyClientAuthentication");function bR(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}n(bR,"applyBasicAuth");function vR(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}n(vR,"applyPostAuth");function CR(e,t){t.set("client_id",e)}n(CR,"applyPublicAuth");function Jm(e){return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="[::1]"||e==="::1"}n(Jm,"isLoopbackHost");function IR(e){let t=new URL(String(e));if(t.protocol!=="https:"&&!Jm(t.hostname))throw new qs(t.href);return t}n(IR,"assertSecureTokenEndpoint");function TR(e){for(let t of e??[]){let r;try{r=new URL(t)}catch{continue}if(r.protocol!=="http:"&&r.protocol!=="https:"||Jm(r.hostname))return"native"}return"web"}n(TR,"deriveApplicationType");function ER(e){let t=e.clientMetadata;return{...t,grant_types:t.grant_types??(e.redirectUrl===void 0?void 0:["authorization_code","refresh_token"]),application_type:t.application_type??TR(t.redirect_uris)}}n(ER,"resolveClientMetadata");async function jm(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let o=ds.parse(JSON.parse(r));return Ct.fromResponse(o)}catch(o){let s=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new Ct(le.ServerError,s)}}n(jm,"parseErrorResponse");function Dm(e,t,r){let o=e.invalidateCredentials===void 0?`retrying authorization without discarding the stored ${r} (provider implements no invalidateCredentials())`:`invalidating the stored ${r} and retrying authorization`;console.warn(`[mcp-sdk] OAuth ${JSON.stringify(t.code)} \u2014 ${o}. Cause: ${JSON.stringify(t.message)}`)}n(Dm,"warnCredentialInvalidation");async function ma(e,t){try{return await ua(e,t)}catch(r){if(r instanceof Ct){if(r.code===le.InvalidClient||r.code===le.UnauthorizedClient)return Dm(e,r,"client credentials and tokens"),await e.invalidateCredentials?.("client"),await e.invalidateCredentials?.("tokens"),await ua(e,t);if(r.code===le.InvalidGrant||r.code===le.InvalidDpopProof)return Dm(e,r,"tokens"),await e.invalidateCredentials?.("tokens"),await ua(e,t)}throw r}}n(ma,"auth");function kR(e){let{requestedScope:t,resourceMetadata:r,authServerMetadata:o,clientMetadata:s}=e,i=t||r?.scopes_supported?.join(" ")||s.scope;return i&&o?.scopes_supported?.includes("offline_access")&&!i.split(" ").includes("offline_access")&&s.grant_types?.includes("refresh_token")&&(i=`${i} offline_access`),i}n(kR,"determineScope");async function ua(e,{serverUrl:t,authorizationCode:r,iss:o,scope:s,resourceMetadataUrl:i,fetchFn:a,skipIssuerMetadataValidation:c,forceReauthorization:d}){let l=ER(e),m=await e.discoveryState?.(),h,y,f,R,S=i;if(!S&&m?.resourceMetadataUrl&&(S=new URL(m.resourceMetadataUrl)),m?.authorizationServerUrl){if(y=m.authorizationServerUrl,h=m.resourceMetadata,f=m.authorizationServerMetadata??await Km(y,{fetchFn:a,skipIssuerValidation:c}),!h)try{h=await Gm(t,{resourceMetadataUrl:S},a)}catch(W){if(W instanceof TypeError)throw W}(f!==m.authorizationServerMetadata||h!==m.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(y),resourceMetadataUrl:S?.toString(),resourceMetadata:h,authorizationServerMetadata:f})}else{let W=await qR(t,{resourceMetadataUrl:S,fetchFn:a,skipIssuerMetadataValidation:c});y=W.authorizationServerUrl,f=W.authorizationServerMetadata,h=W.resourceMetadata,R={authorizationServerUrl:String(y),resourceMetadataUrl:S?.toString(),resourceMetadata:h,authorizationServerMetadata:f}}let w=f?.issuer??String(y),x={issuer:w};if(await e.saveAuthorizationServerUrl?.(w),r!==void 0){let W=m?.authorizationServerMetadata?.issuer??m?.authorizationServerUrl;if(W===void 0){if(e.saveDiscoveryState!==void 0)throw new Ms("discoveryState was not available on the callback leg; ensure your provider persists discoveryState alongside codeVerifier",w);console.warn("[mcp-sdk] OAuthClientProvider does not implement saveDiscoveryState()/discoveryState(); the SEP-2352 callback-leg authorization-server binding cannot be checked. Implement discoveryState (persist alongside codeVerifier) \u2014 see docs/migration/upgrade-to-v2.md \xA7SEP-2352.")}else if(!Lm(W,w))throw new Ms(W,w)}R&&await e.saveDiscoveryState?.(R);let I=await AR(t,e,h),O=I&&h&&!e.validateResourceURL?h.resource:I;O&&await e.saveResourceUrl?.(fa(O));let N=kR({requestedScope:s,resourceMetadata:h,authServerMetadata:f,clientMetadata:e.clientMetadata}),we=await Promise.resolve(e.clientInformation(x)),q=la(we,w,{canPersistStamp:e.saveClientInformation!==void 0});if(q===void 0&&we?.issuer&&e.saveClientInformation===void 0)throw new Ms(we.issuer,w);if(q&&q.issuer===void 0&&(q={...q,issuer:w},await e.saveClientInformation?.(q,x)),!q){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let W=f?.client_id_metadata_document_supported===!0,Z=e.clientMetadataUrl;if(Z&&!ha(Z))throw new Ct(le.InvalidClientMetadata,`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${Z}`);if(W&&Z)q={client_id:Z,issuer:w},await e.saveClientInformation?.(q,x);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");q={...await $R(y,{metadata:f,clientMetadata:l,scope:N,fetchFn:a}),issuer:w},await e.saveClientInformation(q,x)}}let ie=!e.redirectUrl;if(r!==void 0||ie){r!==void 0&&Bm({iss:o,expectedIssuer:f?.issuer,issParameterSupported:Hm(f)});let W=await DR(e,y,{metadata:f,resource:O,authorizationCode:r,iss:o,scope:N,fetchFn:a});return await e.saveTokens({...W,issuer:w},x),"AUTHORIZED"}let pe=la(await e.tokens(x),w);if(pe&&pe.issuer===void 0&&(pe={...pe,issuer:w},await e.saveTokens(pe,x)),pe?.refresh_token&&!d){let W;try{W=await jR(y,{metadata:f,clientInformation:q,refreshToken:pe.refresh_token,resource:O,addClientAuthentication:e.addClientAuthentication,dpop:await e.dpop?.(),fetchFn:a})}catch(Z){if(Z instanceof qs)throw Z;if(!(Z instanceof Ct)||Z.code===le.ServerError)console.warn(`[mcp-sdk] Could not refresh OAuth tokens; falling back to a new authorization request. Cause: ${JSON.stringify(Z instanceof Error?Z.message:String(Z))}`);else throw Z}if(W)return await e.saveTokens({...W,issuer:w},x),"AUTHORIZED"}let A=e.state?await e.state():void 0,{authorizationUrl:K,codeVerifier:j}=await zR(y,{metadata:f,clientInformation:q,state:A,redirectUrl:e.redirectUrl,scope:N,resource:O});return await e.saveCodeVerifier(j),await e.redirectToAuthorization(K),"REDIRECT"}n(ua,"authInternal");function ha(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}n(ha,"isHttpsUrl");async function AR(e,t,r){let o=sm(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!As({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}n(AR,"selectResourceURL");var PR=new Set(["bearer","dpop"]);function Fm(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,o]=t.split(" ");if(!r||!PR.has(r.toLowerCase())||!o)return{};let s=Us(e,"resource_metadata")||void 0,i;if(s)try{i=new URL(s)}catch{}let a=Us(e,"scope")||void 0,c=Us(e,"error")||void 0,d=Us(e,"error_description")||void 0;return{resourceMetadataUrl:i,scope:a,error:c,errorDescription:d}}n(Fm,"extractWWWAuthenticateParams");function Us(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let o=new RegExp(String.raw`${t}=(?:"([^"]+)"|([^\s,]+))`),s=r.match(o);if(s){let i=s[1]||s[2];if(i)return i}return null}n(Us,"extractFieldFromWwwAuth");async function Gm(e,t,r=fetch){let o=await UR(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw await o?.text?.().catch(()=>{}),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw await o.text?.().catch(()=>{}),new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return Cr.parse(await o.json())}n(Gm,"discoverOAuthProtectedResourceMetadata");async function Vm(e,t,r=fetch){let o=Os(r);try{return await o(e,{headers:t})}catch(s){if(!(s instanceof TypeError)||!Nm)throw s;if(t)try{return await o(e,{})}catch(i){if(!(i instanceof TypeError))throw i;return}return}}n(Vm,"fetchWithCorsRetry");function xR(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}n(xR,"buildWellKnownPath");async function $m(e,t,r=fetch){return await Vm(e,{"MCP-Protocol-Version":t},r)}n($m,"tryMetadataDiscovery");function OR(e,t){return e?t==="/"?!1:!e.ok&&e.status<500||e.status===502:!0}n(OR,"shouldAttemptFallback");async function UR(e,t,r,o){let s=new URL(e),i=o?.protocolVersion??os,a;if(o?.metadataUrl)a=new URL(o.metadataUrl);else{let d=xR(t,s.pathname);a=new URL(d,o?.metadataServerUrl??s),a.search=s.search}let c=await $m(a,i,r);return!o?.metadataUrl&&OR(c,s.pathname)&&(c=await $m(new URL(`/.well-known/${t}`,s),i,r)),c}n(UR,"discoverMetadataWithFallback");function MR(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"},{url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let s=t.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,t.origin),type:"oauth"},{url:new URL(`/.well-known/openid-configuration${s}`,t.origin),type:"oidc"},{url:new URL(`${s}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}n(MR,"buildDiscoveryUrls");async function Km(e,{fetchFn:t=fetch,protocolVersion:r=os,skipIssuerValidation:o=!1}={}){let s={"MCP-Protocol-Version":r,Accept:"application/json"},i=MR(e);for(let{url:a,type:c}of i){let d=await Vm(a,s,t);if(!d)continue;if(!d.ok){if(await d.text?.().catch(()=>{}),d.status<500||d.status===502)continue;throw new Error(`HTTP ${d.status} trying to load ${c==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}let l=c==="oauth"?Ir.parse(await d.json()):Tr.parse(await d.json());if(!o){let m=typeof e=="string"?e:e.href;if(!(l.issuer===m||m.endsWith("/")&&l.issuer===m.slice(0,-1)))throw new ho("metadata",m,l.issuer)}return l}}n(Km,"discoverAuthorizationServerMetadata");async function qR(e,t){let r,o;try{r=await Gm(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(o=r.authorization_servers[0])}catch(i){if(i instanceof TypeError)throw i}o||(o=String(new URL("/",e)));let s=await Km(o,{fetchFn:t?.fetchFn,skipIssuerValidation:t?.skipIssuerMetadataValidation});return{authorizationServerUrl:o,authorizationServerMetadata:s,resourceMetadata:r}}n(qR,"discoverOAuthServerInfo");function fa(e){return typeof e=="string"?e:e.href}n(fa,"resourceIndicatorToString");async function zR(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:s,state:i,resource:a}){let c;if(t){if(c=new URL(t.authorization_endpoint),!t.response_types_supported.includes(ca))throw new Error(`Incompatible auth server: does not support response type ${ca}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(da))throw new Error(`Incompatible auth server: does not support code challenge method ${da}`)}else c=new URL("/authorize",e);let d=await aa(),l=d.code_verifier,m=d.code_challenge;return c.searchParams.set("response_type",ca),c.searchParams.set("client_id",r.client_id),c.searchParams.set("code_challenge",m),c.searchParams.set("code_challenge_method",da),c.searchParams.set("redirect_uri",String(o)),i&&c.searchParams.set("state",i),s&&c.searchParams.set("scope",s),s?.split(" ").includes("offline_access")&&c.searchParams.append("prompt","consent"),a&&c.searchParams.set("resource",fa(a)),{authorizationUrl:c,codeVerifier:l}}n(zR,"startAuthorization");function NR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}n(NR,"prepareAuthorizationCodeRequest");async function Wm(e,{metadata:t,tokenRequestParams:r,clientInformation:o,addClientAuthentication:s,resource:i,dpop:a,fetchFn:c}){let d=IR(t?.token_endpoint??new URL("/token",e)),l=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});i&&r.set("resource",fa(i)),!s&&o&&RR(wR(o,t?.token_endpoint_auth_methods_supported??[]),o,l,r);let m=n(async()=>{let f=new Headers(l);return s&&await s(f,r,d,t),a&&f.set("DPoP",await a.buildProof({htm:"POST",htu:d})),Os(c??fetch)(d,{method:"POST",headers:f,body:r})},"requestOnce"),h=await m();if(a&&h.status===400&&(await h.clone().json().catch(()=>{}))?.error===le.UseDpopNonce&&(a.observeNonce(h,d),h=await m()),a?.observeNonce(h,d),!h.ok)throw await jm(h);let y=await h.json();try{return Rt.parse(Wi(y))}catch(f){throw typeof y=="object"&&y!==null&&"error"in y?await jm(JSON.stringify(y)):f}}n(Wm,"executeTokenRequest");async function jR(e,{metadata:t,clientInformation:r,refreshToken:o,resource:s,addClientAuthentication:i,dpop:a,fetchFn:c}){return{refresh_token:o,...await Wm(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:"refresh_token",refresh_token:o}),clientInformation:r,addClientAuthentication:i,resource:s,dpop:a,fetchFn:c})}}n(jR,"refreshAuthorization");async function DR(e,t,{metadata:r,resource:o,authorizationCode:s,iss:i,scope:a,fetchFn:c}={}){s!==void 0&&Bm({iss:i,expectedIssuer:r?.issuer,issParameterSupported:Hm(r)});let d=r?.issuer??String(t),l=n(async()=>{let f=await e.clientInformation({issuer:d}),R=la(f,d,{canPersistStamp:!1});if(f&&R===void 0)throw new Ms(String(f.issuer),d);return R},"readClientInformation"),m=await l(),h=a??e.clientMetadata.scope,y;if(e.prepareTokenRequest&&(y=await e.prepareTokenRequest(h)),!y){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");y=NR(s,await e.codeVerifier(),e.redirectUrl)}return m??=await l(),Wm(t,{metadata:r,tokenRequestParams:y,clientInformation:m,addClientAuthentication:e.addClientAuthentication,resource:o,dpop:await e.dpop?.(),fetchFn:c})}n(DR,"fetchToken");async function $R(e,{metadata:t,clientMetadata:r,scope:o,fetchFn:s}){let i;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");i=new URL(t.registration_endpoint)}else i=new URL("/register",e);let a={...r,...o===void 0?{}:{scope:o}},c=await Os(s??fetch)(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!c.ok)throw new pa({status:c.status,body:await c.text(),submittedMetadata:a});return Zt.parse(Wi(await c.json()))}n($R,"registerClient");var Kx=class extends Error{static{n(this,"SseError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e,t,r){super(`SSE error: ${t}`),this.code=e,this.event=r,Xt(this,new.target)}};function go(e){let t=Wt.safeParse(e);return t.success?t.data.id:void 0}n(go,"parseJsonRpcRequestId");function ga(e){if(e!==void 0)try{let t=JSON.parse(new TextDecoder().decode(e));return go(t)}catch{return}}n(ga,"readJsonRpcRequestIdFromBody");function ya(e){return Xn.parse({jsonrpc:vr,...e.id===void 0?{}:{id:e.id},error:{code:e.error.code,message:e.error.message,...e.error.data===void 0?{}:{data:e.error.data}}})}n(ya,"jsonRpcErrorResponse");function Zm(e){return new xs([cs.parse({mode:"url",message:e.message,elicitationId:e.elicitationId,url:e.url})],e.message)}n(Zm,"urlElicitationRequiredError");function It(e){return(e??"").split(";")[0].trim().toLowerCase()}n(It,"mediaTypeEssence");var LR=["content-encoding","content-length","content-md5","digest","content-digest","repr-digest"];function dt(e){for(let t of LR)e.delete(t);return e}n(dt,"deleteEncodedBodyHeaders");function Ym(){let e=es.instance;return e.isDeno?"deno":e.isCloudflare?"workerd":"node"}n(Ym,"currentRuntime");var HR=new Set(["gzip","x-gzip","deflate","br","zstd"]);function Tt(e,t=Ym()){let r=e.get("content-encoding")?.trim();if(!r||r.toLowerCase()==="identity")return!1;switch(t){case"deno":return!0;case"workerd":return r!=="gzip"&&r!=="br";default:return!r.toLowerCase().split(",").every(o=>HR.has(o.trim()))}}n(Tt,"isBodyStillEncoded");function Xm(e){return Tt(e)?e:dt(e)}n(Xm,"deleteEncodedBodyHeadersIfDecoded");function Qm(e,t=Ym()){let r=e.get("content-encoding")?.trim().toLowerCase();return(r!==void 0&&r!==""&&r!=="identity"?Tt(e,t):e.has("content-length"))?e:dt(e)}n(Qm,"deleteEncodedBodyHeadersIfRuntimeDecoded");var th=10*1024*1024,BR=1024,JR=32,FR=64,Qt=class extends Error{constructor(r,o=!1){super(`SSE event exceeds the ${r}-character limit`);this.maxEventChars=r;this.comment=o;this.name="SseEventTooLargeError"}maxEventChars;comment;static{n(this,"SseEventTooLargeError")}},GR=10;function VR(e,t){typeof e=="object"&&e!==null&&typeof e.then=="function"&&e.then(void 0,t)}n(VR,"handleRejection");function rh(e){let t=e.indexOf(":");return t===-1?e:e.slice(0,t)}n(rh,"fieldName");var yo=class{static{n(this,"SseParser")}#e;#r;#t;#n=new TextDecoder("utf-8",{ignoreBOM:!0});#d=!1;#g=/\r\n|\r|\n/g;#s="";#u=[];#o=[];#c=0;#l=!1;#p=!1;#y=!1;#i=!1;#m=!1;#S=0;#C=0;#a=[];#h=0;#f=[];#_;#w;#R;#b=[];constructor(t={}){let r=t.maxEventChars??th;if(!Number.isInteger(r)||r<=0)throw new RangeError(`maxEventChars must be a positive integer, got ${r}`);this.#e=r,this.#r=t.onOversize==="discard",this.#t=t.emitLoneComments===!0}get discardedEvents(){return this.#S}get discardedComments(){return this.#C}get discarding(){return this.#i||this.#m}get idle(){return this.#c===0&&!this.#l&&!this.#i&&this.#a.length===0}push(t){let r=[];return this.#T(this.#I(this.#n.decode(t,{stream:!0})),r),r}end(){let t=[];return this.#T(this.#I(this.#n.decode()),t),(this.#c>0||this.#l)&&this.#A(t,!1),this.#i||this.#P(t,!1),this.#i=!1,t}#I(t){return this.#d||t===""?t:(this.#d=!0,t.charCodeAt(0)===65279?t.slice(1):t)}#T(t,r){if(t==="")return;let o=0;this.#y&&(this.#y=!1,t.charCodeAt(0)===GR&&(o=1));let s=this.#g;s.lastIndex=o;let i=s.exec(t);for(;i!==null;)this.#E(t.slice(o,i.index)),this.#A(r),o=i.index+i[0].length,i[0]==="\r"&&o===t.length&&(this.#y=!0),i=s.exec(t);this.#E(t.slice(o))}#E(t){if(t!==""){if(this.#i||this.#m){this.#l=!0;return}if(this.#c===0?this.#s=t:(this.#o.push(t),this.#o.length>=FR&&(this.#u.push(this.#o.join("")),this.#o=[])),this.#c+=t.length,this.#h+this.#c>this.#e){let r=this.#O();r&&this.#r?(this.#v(),this.#m=!0,this.#S++,this.#C++):this.#k(r),this.#l=!0}}}#O(){return this.#t&&this.#a.length===0&&this.#s.charCodeAt(0)===58}#k(t=!1){if(!this.#r)throw new Qt(this.#e,t);this.#x(),this.#p=!1,this.#v(),this.#i=!0,this.#S++}#v(){this.#s="",this.#u.length>0&&(this.#u=[]),this.#o.length>0&&(this.#o=[]),this.#c=0}#A(t,r=!0){let o=this.#u.length===0&&this.#o.length===0?this.#s:this.#s+this.#u.join("")+this.#o.join(""),s=o===""&&!this.#l;if(this.#v(),this.#l=!1,this.#m){this.#m=!1,this.#p=!0;return}if(s){this.#i?this.#i=!1:this.#p&&this.#a.length===0?(this.#p=!1,t.push({lines:[],data:void 0,event:void 0,id:void 0,retry:void 0,comments:[],terminated:!0})):(this.#p=!1,this.#P(t,!0));return}if(this.#i)return;if(this.#t&&r&&this.#a.length===0&&o.charCodeAt(0)===58){t.push({lines:[o],data:void 0,event:void 0,id:void 0,retry:void 0,comments:[o.slice(1)],terminated:!0,lone:!0}),this.#p=!0;return}if(this.#h+=o.length,this.#a.push(o),this.#a.length>BR&&(this.#h+=Math.max(0,JR-o.length),this.#h>this.#e)){this.#k();return}if(o.charCodeAt(0)===58){this.#b.push(o.slice(1));return}let i=o.indexOf(":"),a=i===-1?o:o.slice(0,i),c=i===-1?"":o.slice(i+1);switch(c.charCodeAt(0)===32&&(c=c.slice(1)),a){case"data":this.#f.push(c);break;case"event":this.#_=c;break;case"id":c.includes("\0")||(this.#w=c);break;case"retry":/^[0-9]+$/.test(c)&&(this.#R=Number(c));break;default:break}}#P(t,r){this.#a.length>0&&t.push({lines:this.#a,data:this.#f.length>0?this.#f.join(`
|
|
25
|
+
import{$ as Zn,$a as Wd,$b as Ku,$c as Nl,$f as fs,$g as Np,Aa as vd,Ab as bu,Ac as as,Af as We,Ag as Ss,Ba as Cd,Bb as vu,Bc as cs,Bf as ap,Bg as Rp,C as nd,Ca as Id,Cb as Cu,Cc as pl,Cf as ot,Cg as _s,Da as Td,Db as Iu,Dc as ml,Df as M,Dg as qi,E as ns,Ea as Ed,Eb as Tu,Ec as hl,Ef as ms,Eg as ws,Fa as kd,Fb as Eu,Fc as fl,Fd as Ql,Ff as ve,Fg as bp,Ga as Ad,Gb as ku,Gc as gl,Gf as bt,Gg as ue,Ha as Pd,Hb as Au,Hc as yl,Hf as VS,Hg as vp,Ia as xd,Ib as Pu,Ic as Sl,If as KS,Ig as Cp,Ja as Od,Jb as xu,Jc as _l,Jf as WS,Jg as zi,Ka as Ud,Kb as Ou,Kc as wl,Kf as ZS,Kg as Ip,La as Md,Lb as Uu,Lc as Rl,Lf as YS,Lg as Tp,Ma as qd,Mb as Mu,Mc as bl,Mf as XS,Mg as Ni,Na as zd,Nb as qu,Nc as vl,Nf as QS,Ng as Ep,O as od,Oa as Nd,Ob as zu,Oc as Cl,Of as e_,Og as Yt,Pa as jd,Pb as Nu,Pc as Il,Pf as t_,Pg as kp,Qa as Ri,Qb as ju,Qc as Tl,Qf as r_,Qg as so,R as sd,Ra as Dd,Rb as Du,Rc as El,Rf as cp,Rg as Ap,Sa as $d,Sb as $u,Sc as kl,Sf as dp,Sg as Rs,Ta as Ld,Tb as Lu,Tc as Al,Tf as hs,Tg as io,Ua as Hd,Ub as Hu,Uc as Pl,Uf as to,Ug as Pp,Va as Bd,Vb as Bu,Vc as xl,Vf as ro,Vg as xp,Wa as Jd,Wb as Ju,Wc as Ol,Wf as Mr,Wg as Op,Xa as Fd,Xb as Fu,Xc as Ul,Xf as up,Xg as Up,Y as os,Ya as Gd,Yb as Gu,Yc as Ml,Yf as xi,Yg as Mp,Z as yi,Za as Vd,Zb as bi,Zc as ql,Zf as lp,Zg as qp,_ as wr,_a as Kd,_b as Vu,_c as zl,_f as no,_g as zp,aa as Rr,ab as Zd,ac as Wu,ad as jl,ag as pp,ah as bs,b as td,ba as br,bb as Yd,bc as Zu,bd as Dl,bg as mp,bh as jp,ca as Yn,cb as Xd,cc as Yu,cd as $l,cg as hp,ch as Dp,da as vr,db as Qd,dc as Xu,dd as Ll,dg as fp,dh as H,ea as id,eb as eu,ec as Qu,ed as Hl,eg as _e,eh as X,fa as ad,fb as tu,fc as el,fd as Bl,ff as ep,fg as me,fh as $p,ga as cd,gb as ru,gc as tl,gd as Jl,gf as qe,gg as gp,gh as he,ha as dd,hb as nu,hc as rl,hd as Fl,hf as tp,hg as yp,hh as at,ia as ud,ib as ou,ic as nl,id as Cr,if as rp,ig as J,ih as oe,ja as ld,jb as su,jc as ol,jd as Ir,jf as np,jg as st,jh as vs,ka as pd,kb as iu,kc as sl,kd as Gl,kf as ne,kg as qr,kh as Lp,la as md,lb as au,lc as il,ld as Tr,lf as op,lg as Ce,lh as n_,ma as hd,mb as cu,mc as al,md as Rt,mf as Er,mg as ce,mh as o_,n as Qe,na as fd,nb as du,nc as cl,nd as Pi,nf as sp,ng as Sp,oa as gd,ob as uu,oc as vi,od as ds,of as kr,og as te,pa as yd,pb as lu,pc as ss,pd as Vl,pf as E,pg as _p,qa as Sd,qb as pu,qc as is,qd as Qn,qf as Ar,qg as vt,ra as _d,rb as mu,rc as Ci,rd as Zt,rf as Pr,rg as Oi,sa as wd,sb as hu,sc as Ii,sd as Kl,sf as rt,sg as gs,ta as Rd,tb as fu,tc as Ti,td as Wl,tf as nt,tg as Ui,u as He,ua as Wt,ub as gu,uc as dl,ud as eo,uf as ls,ug as ys,v as rd,va as Si,vb as yu,vc as Ei,vd as Zl,vf as xr,vg as oo,wa as _i,wb as Su,wc as ki,wd as Yl,wf as Or,wg as zr,x as F,xa as Xn,xb as _u,xc as ul,xd as Xl,xf as Ur,xg as wp,ya as wi,yb as wu,yc as ll,yd as us,yf as ps,yg as it,za as bd,zb as Ru,zc as Ai,zf as ip,zg as Mi}from"../chunk-D4D3WYPP.js";import"../chunk-ZCJ5QBVD.js";import{a as Hp,b as Bp}from"../chunk-7FFIW3HF.js";import{a as _r}from"../chunk-QGAJTUPE.js";import"../chunk-A3QGJZO7.js";import{$ as es,Ba as p,a as be,aa as Yc,c as T,ca as hi,d as Y,da as Xc,ea as u,fa as Qc,ga as ed,ha as C,ia as z,ja as ts,la as D,ma as b,na as g,oa as L,pa as U,qa as fi,ra as Kn,sa as P,ta as B,ua as _,va as $,wa as gi,xa as rs,za as Wn}from"../chunk-PXS4NOKU.js";import"../chunk-UKQQD2JN.js";import{a as n}from"../chunk-TYV53J3B.js";var s_=Object.create,Cs=Object.defineProperty,i_=Object.getOwnPropertyDescriptor,a_=Object.getOwnPropertyNames,c_=Object.getPrototypeOf,d_=Object.prototype.hasOwnProperty,Jp=n((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),"__commonJSMin"),Fp=n((e,t)=>{let r={};for(var o in e)Cs(r,o,{get:e[o],enumerable:!0});return t&&Cs(r,Symbol.toStringTag,{value:"Module"}),r},"__exportAll"),u_=n((e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(var s=a_(t),i=0,a=s.length,c;i<a;i++)c=s[i],!d_.call(e,c)&&c!==r&&Cs(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(o=i_(t,c))||o.enumerable});return e},"__copyProps"),Gp=n((e,t,r)=>(r=e!=null?s_(c_(e)):{},u_(t||!e||!e.__esModule?Cs(r,"default",{value:e,enumerable:!0}):r,e)),"__toESM");var l_=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]);function Vp(e){return typeof e=="string"&&l_.has(e.replace(/#$/,""))}n(Vp,"declares2019Dialect");var Bi=Symbol.for("mcp.sdk.errorBrands");function Xt(e,t){let r=new Set,o=t;for(;typeof o=="function";){let s=o.mcpBrand;Object.prototype.hasOwnProperty.call(o,"mcpBrand")&&typeof s=="string"&&r.add(s),o=Object.getPrototypeOf(o)}r.size!==0&&Object.defineProperty(e,Bi,{value:r,enumerable:!1,configurable:!0})}n(Xt,"stampErrorBrands");function ze(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,Bi)){let r=t[Bi];if(r&&typeof r.has=="function"&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}n(ze,"brandedHasInstance");var le=(function(e){return e.InvalidRequest="invalid_request",e.InvalidClient="invalid_client",e.InvalidGrant="invalid_grant",e.UnauthorizedClient="unauthorized_client",e.UnsupportedGrantType="unsupported_grant_type",e.InvalidScope="invalid_scope",e.AccessDenied="access_denied",e.ServerError="server_error",e.TemporarilyUnavailable="temporarily_unavailable",e.UnsupportedResponseType="unsupported_response_type",e.UnsupportedTokenType="unsupported_token_type",e.InvalidToken="invalid_token",e.MethodNotAllowed="method_not_allowed",e.TooManyRequests="too_many_requests",e.InvalidClientMetadata="invalid_client_metadata",e.InvalidRedirectUri="invalid_redirect_uri",e.InsufficientScope="insufficient_scope",e.InvalidTarget="invalid_target",e.InvalidDpopProof="invalid_dpop_proof",e.UseDpopNonce="use_dpop_nonce",e})({}),Ct=class om extends Error{static{n(this,"OAuthError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return ze(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,t)}constructor(t,r,o){super(r),this.code=t,this.errorUri=o,this.name="OAuthError",Xt(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(t){return new om(t.error,t.error_description??t.error,t.error_uri)}},fe=(function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e})({}),de=class extends Error{static{n(this,"SdkError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e,t,r,o){super(t,o),this.code=e,this.data=r,this.name="SdkError",Xt(this,new.target)}},v_=class extends de{static{n(this,"SdkHttpError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,o){super(e,t,r,o),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};function sm(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}n(sm,"resourceUrlFromServerUrl");function Wi(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}n(Wi,"withoutIssuer");function As({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;let s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return s.startsWith(i)}n(As,"checkResourceAllowed");var C_="2026-07-28";function im(e){return e>=C_}n(im,"isModernProtocolVersion");function am(e){let t=e.structuredContent;return t===void 0||!(typeof t!="object"||t===null||Array.isArray(t))||(e.content?.some(r=>r.type==="text")??!1)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}n(am,"appendTextFallbackForNonObject");var cm=["task","inputRequests","requestState"];function I_(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||cm.some(t=>t in e)?e:{...e,content:[]}}n(I_,"normalizeContentlessToolResult");function T_(){let e=gi(()=>U([u(),C(),z(),ts(),P(u(),e),b(e)])),t=P(u(),e),r=U([u(),C().int()]),o=u(),s=g({ttl:C().optional()}),i=g({taskId:u()}),a=L({progressToken:r.optional(),"io.modelcontextprotocol/related-task":i.optional()}),c=g({_meta:a.optional()}),d=c.extend({task:s.optional()}),l=g({method:u(),params:c.loose().optional()}),m=g({_meta:a.optional()}),h=g({method:u(),params:m.loose().optional()}),y=L({_meta:a.optional()}),f=U([u(),C().int()]),R=y.strict(),S=m.extend({requestId:f.optional(),reason:u().optional()}),w=h.extend({method:_("notifications/cancelled"),params:S}),x=g({src:u(),mimeType:u().optional(),sizes:b(u()).optional(),theme:B(["light","dark"]).optional()}),I=g({icons:b(x).optional()}),O=g({name:u(),title:u().optional()}),N=O.extend({...O.shape,...I.shape,version:u(),websiteUrl:u().optional(),description:u().optional()}),we=Kn(g({applyDefaults:z().optional()}),t),q=rs(Se=>Se&&typeof Se=="object"&&!Array.isArray(Se)&&Object.keys(Se).length===0?{form:{}}:Se,Kn(g({form:we.optional(),url:t.optional()}),t.optional())),ie=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),pe=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),A=g({experimental:P(u(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:q.optional(),roots:g({listChanged:z().optional()}).optional(),tasks:ie.optional(),extensions:P(u(),t).optional()}),K=c.extend({protocolVersion:u(),capabilities:A,clientInfo:N}),j=l.extend({method:_("initialize"),params:K}),W=g({experimental:P(u(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:z().optional()}).optional(),resources:g({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:g({listChanged:z().optional()}).optional(),tasks:pe.optional(),extensions:P(u(),t).optional()}),Z=y.extend({protocolVersion:u(),capabilities:W,serverInfo:N,instructions:u().optional()}),De=h.extend({method:_("notifications/initialized"),params:m.optional()}),Oe=l.extend({method:_("ping"),params:c.optional()}),$e=g({progress:C(),total:$(C()),message:$(u())}),G=g({...m.shape,...$e.shape,progressToken:r}),ae=h.extend({method:_("notifications/progress"),params:G}),ke=c.extend({cursor:o.optional()}),ee=l.extend({params:ke.optional()}),Ge=y.extend({nextCursor:o.optional()}),or=g({uri:u(),mimeType:$(u()),_meta:P(u(),D()).optional()}),sr=or.extend({text:u()}),Nt=u().refine(Se=>{try{return atob(Se),!0}catch{return!1}},{message:"Invalid Base64 string"}),ir=or.extend({blob:Nt}),Xe=B(["user","assistant"]),Ve=g({audience:b(Xe).optional(),priority:C().min(0).max(1).optional(),lastModified:Wn.datetime({offset:!0}).optional()}),jt=g({...O.shape,...I.shape,uri:u(),description:$(u()),mimeType:$(u()),size:$(C()),annotations:Ve.optional(),_meta:$(L({}))}),en=g({...O.shape,...I.shape,uriTemplate:u(),description:$(u()),mimeType:$(u()),annotations:Ve.optional(),_meta:$(L({}))}),tn=ee.extend({method:_("resources/list")}),rn=Ge.extend({resources:b(jt)}),yt=ee.extend({method:_("resources/templates/list")}),ar=Ge.extend({resourceTemplates:b(en)}),Dt=c.extend({uri:u()}),nn=Dt,on=l.extend({method:_("resources/read"),params:nn}),sn=y.extend({contents:b(U([sr,ir]))}),an=h.extend({method:_("notifications/resources/list_changed"),params:m.optional()}),cn=Dt,dn=l.extend({method:_("resources/subscribe"),params:cn}),un=Dt,ln=l.extend({method:_("resources/unsubscribe"),params:un}),pn=m.extend({uri:u()}),mn=h.extend({method:_("notifications/resources/updated"),params:pn}),hn=g({name:u(),description:$(u()),required:$(z())}),fn=g({...O.shape,...I.shape,description:$(u()),arguments:$(b(hn)),_meta:$(L({}))}),gn=ee.extend({method:_("prompts/list")}),yn=Ge.extend({prompts:b(fn)}),Sn=c.extend({name:u(),arguments:P(u(),u()).optional()}),_n=l.extend({method:_("prompts/get"),params:Sn}),$t=g({type:_("text"),text:u(),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),Lt=g({type:_("image"),data:Nt,mimeType:u(),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),Ht=g({type:_("audio"),data:Nt,mimeType:u(),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),wn=g({type:_("tool_use"),name:u(),id:u(),input:P(u(),D()),_meta:P(u(),D()).optional()}),St=g({type:_("resource"),resource:U([sr,ir]),annotations:Ve.optional(),_meta:P(u(),D()).optional()}),Rn=jt.extend({type:_("resource_link")}),Le=U([$t,Lt,Ht,Rn,St]),cr=g({role:Xe,content:Le}),dr=y.extend({description:u().optional(),messages:b(cr)}),Bt=h.extend({method:_("notifications/prompts/list_changed"),params:m.optional()}),bn=g({title:u().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),ur=g({taskSupport:B(["required","optional","forbidden"]).optional()}),Jt=g({...O.shape,...I.shape,description:u().optional(),inputSchema:g({type:_("object"),properties:P(u(),e).optional(),required:b(u()).optional()}).catchall(D()),outputSchema:g({type:_("object"),properties:P(u(),e).optional(),required:b(u()).optional()}).catchall(D()).optional(),annotations:bn.optional(),execution:ur.optional(),_meta:P(u(),D()).optional()}),lr=ee.extend({method:_("tools/list")}),pr=Ge.extend({tools:b(Jt)}),mr=y.extend({content:b(Le),structuredContent:P(u(),D()).optional(),isError:z().optional()}),ye=d.extend({name:u(),arguments:P(u(),D()).optional()}),vn=l.extend({method:_("tools/call"),params:ye}),jo=h.extend({method:_("notifications/tools/list_changed"),params:m.optional()}),hr=B(["debug","info","notice","warning","error","critical","alert","emergency"]),Cn=c.extend({level:hr}),In=l.extend({method:_("logging/setLevel"),params:Cn}),Tn=m.extend({level:hr,logger:u().optional(),data:D()}),En=h.extend({method:_("notifications/message"),params:Tn}),kn=g({name:u().optional()}),An=g({hints:b(kn).optional(),costPriority:C().min(0).max(1).optional(),speedPriority:C().min(0).max(1).optional(),intelligencePriority:C().min(0).max(1).optional()}),Pn=g({mode:B(["auto","required","none"]).optional()}),Do=g({type:_("tool_result"),toolUseId:u().describe("The unique identifier for the corresponding tool call."),content:b(Le),structuredContent:g({}).loose().optional(),isError:z().optional(),_meta:P(u(),D()).optional()}),xn=fi("type",[$t,Lt,Ht]),_t=fi("type",[$t,Lt,Ht,wn,Do]),On=g({role:Xe,content:U([_t,b(_t)]),_meta:P(u(),D()).optional()}),Un=d.extend({messages:b(On),modelPreferences:An.optional(),systemPrompt:u().optional(),includeContext:B(["none","thisServer","allServers"]).optional(),temperature:C().optional(),maxTokens:C().int(),stopSequences:b(u()).optional(),metadata:t.optional(),tools:b(Jt).optional(),toolChoice:Pn.optional()}),Mn=l.extend({method:_("sampling/createMessage"),params:Un}),qn=y.extend({model:u(),stopReason:$(B(["endTurn","stopSequence","maxTokens"]).or(u())),role:Xe,content:xn}),zn=y.extend({model:u(),stopReason:$(B(["endTurn","stopSequence","maxTokens","toolUse"]).or(u())),role:Xe,content:U([_t,b(_t)])}),Nn=g({type:_("boolean"),title:u().optional(),description:u().optional(),default:z().optional()}),jn=g({type:_("string"),title:u().optional(),description:u().optional(),minLength:C().optional(),maxLength:C().optional(),format:B(["email","uri","date","date-time"]).optional(),default:u().optional()}),Dn=g({type:B(["number","integer"]),title:u().optional(),description:u().optional(),minimum:C().optional(),maximum:C().optional(),default:C().optional()}),$n=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),default:u().optional()}),Ln=g({type:_("string"),title:u().optional(),description:u().optional(),oneOf:b(g({const:u(),title:u()})),default:u().optional()}),Hn=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),enumNames:b(u()).optional(),default:u().optional()}),Bn=U([$n,Ln]),Ft=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({type:_("string"),enum:b(u())}),default:b(u()).optional()}),Gt=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({anyOf:b(g({const:u(),title:u()}))}),default:b(u()).optional()}),$o=U([Ft,Gt]),Lo=U([Hn,Bn,$o]),Ue=U([Lo,Nn,jn,Dn]),Me=d.extend({mode:_("form").optional(),message:u(),requestedSchema:g({type:_("object"),properties:P(u(),Ue),required:b(u()).optional()}).catchall(D())}),Jn=d.extend({mode:_("url"),message:u(),elicitationId:u(),url:u().url()}),Ke=U([Me,Jn]),Ho=l.extend({method:_("elicitation/create"),params:Ke}),Bo=m.extend({elicitationId:u()}),Jo=h.extend({method:_("notifications/elicitation/complete"),params:Bo}),Fo=y.extend({action:B(["accept","decline","cancel"]),content:rs(Se=>Se===null?void 0:Se,P(u(),U([u(),C(),z(),b(u())])).optional())}),Go=g({type:_("ref/resource"),uri:u()}),Vo=g({type:_("ref/prompt"),name:u()}),Ko=c.extend({ref:U([Vo,Go]),argument:g({name:u(),value:u()}),context:g({arguments:P(u(),u()).optional()}).optional()}),Fn=l.extend({method:_("completion/complete"),params:Ko}),Wo=y.extend({completion:L({values:b(u()).max(100),total:$(C().int()),hasMore:$(z())})}),Zo=g({uri:u().startsWith("file://"),name:u().optional(),_meta:P(u(),D()).optional()}),fr=l.extend({method:_("roots/list"),params:c.optional()}),Gn=y.extend({roots:b(Zo)}),Yo=h.extend({method:_("notifications/roots/list_changed"),params:m.optional()}),Xo=L({ttl:C().optional(),pollInterval:C().optional()}),Vn=B(["working","input_required","completed","failed","cancelled"]),wt=g({taskId:u(),status:Vn,ttl:U([C(),ts()]),createdAt:u(),lastUpdatedAt:u(),pollInterval:$(C()),statusMessage:$(u())}),Ae=y.extend({task:wt}),Qo=m.merge(wt),Vt=h.extend({method:_("notifications/tasks/status"),params:Qo}),gr=l.extend({method:_("tasks/get"),params:c.extend({taskId:u()})}),yr=y.merge(wt),Sr=l.extend({method:_("tasks/result"),params:c.extend({taskId:u()})}),mi=y.loose(),Re=ee.extend({method:_("tasks/list")}),re=Ge.extend({tasks:b(wt)}),Kt=l.extend({method:_("tasks/cancel"),params:c.extend({taskId:u()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,TaskMetadataSchema:s,RelatedTaskMetadataSchema:i,RequestMetaSchema:a,BaseRequestParamsSchema:c,TaskAugmentedRequestParamsSchema:d,RequestSchema:l,NotificationsParamsSchema:m,NotificationSchema:h,ResultSchema:y,RequestIdSchema:f,EmptyResultSchema:R,CancelledNotificationParamsSchema:S,CancelledNotificationSchema:w,IconSchema:x,IconsSchema:I,BaseMetadataSchema:O,ImplementationSchema:N,ClientTasksCapabilitySchema:ie,ServerTasksCapabilitySchema:pe,ClientCapabilitiesSchema:A,InitializeRequestParamsSchema:K,InitializeRequestSchema:j,ServerCapabilitiesSchema:W,InitializeResultSchema:Z,InitializedNotificationSchema:De,PingRequestSchema:Oe,ProgressSchema:$e,ProgressNotificationParamsSchema:G,ProgressNotificationSchema:ae,PaginatedRequestParamsSchema:ke,PaginatedRequestSchema:ee,PaginatedResultSchema:Ge,ResourceContentsSchema:or,TextResourceContentsSchema:sr,BlobResourceContentsSchema:ir,RoleSchema:Xe,AnnotationsSchema:Ve,ResourceSchema:jt,ResourceTemplateSchema:en,ListResourcesRequestSchema:tn,ListResourcesResultSchema:rn,ListResourceTemplatesRequestSchema:yt,ListResourceTemplatesResultSchema:ar,ResourceRequestParamsSchema:Dt,ReadResourceRequestParamsSchema:nn,ReadResourceRequestSchema:on,ReadResourceResultSchema:sn,ResourceListChangedNotificationSchema:an,SubscribeRequestParamsSchema:cn,SubscribeRequestSchema:dn,UnsubscribeRequestParamsSchema:un,UnsubscribeRequestSchema:ln,ResourceUpdatedNotificationParamsSchema:pn,ResourceUpdatedNotificationSchema:mn,PromptArgumentSchema:hn,PromptSchema:fn,ListPromptsRequestSchema:gn,ListPromptsResultSchema:yn,GetPromptRequestParamsSchema:Sn,GetPromptRequestSchema:_n,TextContentSchema:$t,ImageContentSchema:Lt,AudioContentSchema:Ht,ToolUseContentSchema:wn,EmbeddedResourceSchema:St,ResourceLinkSchema:Rn,ContentBlockSchema:Le,PromptMessageSchema:cr,GetPromptResultSchema:dr,PromptListChangedNotificationSchema:Bt,ToolAnnotationsSchema:bn,ToolExecutionSchema:ur,ToolSchema:Jt,ListToolsRequestSchema:lr,ListToolsResultSchema:pr,CallToolResultSchema:mr,CallToolRequestParamsSchema:ye,CallToolRequestSchema:vn,ToolListChangedNotificationSchema:jo,LoggingLevelSchema:hr,SetLevelRequestParamsSchema:Cn,SetLevelRequestSchema:In,LoggingMessageNotificationParamsSchema:Tn,LoggingMessageNotificationSchema:En,ModelHintSchema:kn,ModelPreferencesSchema:An,ToolChoiceSchema:Pn,ToolResultContentSchema:Do,SamplingContentSchema:xn,SamplingMessageContentBlockSchema:_t,SamplingMessageSchema:On,CreateMessageRequestParamsSchema:Un,CreateMessageRequestSchema:Mn,CreateMessageResultSchema:qn,CreateMessageResultWithToolsSchema:zn,BooleanSchemaSchema:Nn,StringSchemaSchema:jn,NumberSchemaSchema:Dn,UntitledSingleSelectEnumSchemaSchema:$n,TitledSingleSelectEnumSchemaSchema:Ln,LegacyTitledEnumSchemaSchema:Hn,SingleSelectEnumSchemaSchema:Bn,UntitledMultiSelectEnumSchemaSchema:Ft,TitledMultiSelectEnumSchemaSchema:Gt,MultiSelectEnumSchemaSchema:$o,EnumSchemaSchema:Lo,PrimitiveSchemaDefinitionSchema:Ue,ElicitRequestFormParamsSchema:Me,ElicitRequestURLParamsSchema:Jn,ElicitRequestParamsSchema:Ke,ElicitRequestSchema:Ho,ElicitationCompleteNotificationParamsSchema:Bo,ElicitationCompleteNotificationSchema:Jo,ElicitResultSchema:Fo,ResourceTemplateReferenceSchema:Go,PromptReferenceSchema:Vo,CompleteRequestParamsSchema:Ko,CompleteRequestSchema:Fn,CompleteResultSchema:Wo,RootSchema:Zo,ListRootsRequestSchema:fr,ListRootsResultSchema:Gn,RootsListChangedNotificationSchema:Yo,TaskCreationParamsSchema:Xo,TaskStatusSchema:Vn,TaskSchema:wt,CreateTaskResultSchema:Ae,TaskStatusNotificationParamsSchema:Qo,TaskStatusNotificationSchema:Vt,GetTaskRequestSchema:gr,GetTaskResultSchema:yr,GetTaskPayloadRequestSchema:Sr,GetTaskPayloadResultSchema:mi,ListTasksRequestSchema:Re,ListTasksResultSchema:re,CancelTaskRequestSchema:Kt,CancelTaskResultSchema:y.merge(wt),ClientRequestSchema:U([Oe,j,Fn,In,_n,gn,tn,yt,on,dn,ln,vn,lr,gr,Sr,Re,Kt]),ClientNotificationSchema:U([w,ae,De,Yo,Vt]),ClientResultSchema:U([R,qn,zn,Fo,Gn,yr,re,Ae]),ServerRequestSchema:U([Oe,Mn,Ho,fr,gr,Sr,Re,Kt]),ServerNotificationSchema:U([w,ae,En,mn,an,jo,Bt,Vt,Jo]),ServerResultSchema:U([R,Z,Wo,dr,yn,rn,ar,sn,mr,pr,yr,re,Ae]),CallToolResultWireSchema:D().superRefine((Se,GS)=>{if(!(typeof Se!="object"||Se===null||Array.isArray(Se)||Se.content!==void 0)){for(let Zc of cm)if(Zc in Se){GS.addIssue({code:"custom",message:`content is required when the body carries '${Zc}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(I_).pipe(mr)}}n(T_,"build$1");var E_;function Zi(){return E_??=T_()}n(Zi,"buildSchemas2025");function dm(e){return e.type!=="object"}n(dm,"isNonObjectJsonSchemaRoot");var k_=new Set(["const","enum","default","examples"]),A_=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function Kp(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}n(Kp,"establishesNewBase");function P_(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(Kp(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let r=Vp(e.$schema)&&e.$recursiveAnchor!==!0,o=n((s,i)=>{if(Array.isArray(s))return s.map(d=>o(d,!1));if(s===null||typeof s!="object"||!i&&Kp(s.$id))return s;let a={},c=!1;for(let[d,l]of Object.entries(s))i?a[d]=o(l,!1):(d==="$ref"||d==="$dynamicRef")&&typeof l=="string"?a[d]=l==="#"?"#/properties/result":l.startsWith("#/")?`#/properties/result${l.slice(1)}`:l:d==="$recursiveRef"&&l==="#"&&r?c=!0:k_.has(d)?a[d]=l:A_.has(d)?a[d]=o(l,!0):a[d]=o(l,!1);return c&&("$ref"in a?a.allOf=[...Array.isArray(a.allOf)?a.allOf:[],{$ref:"#/properties/result"}]:a.$ref="#/properties/result"),a},"rewriteRefs");return{...t!==void 0&&{$schema:t},type:"object",properties:{result:o(e,!1)},required:["result"]}}n(P_,"wrapOutputSchemaForLegacy");var um={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},lm={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},x_={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Is;function Ps(){if(Is)return Is;let e=Zi();return Is={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Is}n(Ps,"registryMaps");function O_(){Ps()}n(O_,"warmRegistryMaps2025");function pm(e){return Object.prototype.hasOwnProperty.call(um,e)}n(pm,"hasRequestMethod2025");function mm(e){return Object.prototype.hasOwnProperty.call(lm,e)}n(mm,"hasNotificationMethod2025");function U_(e){return Object.prototype.hasOwnProperty.call(x_,e)}n(U_,"hasResultMethod");function M_(e){return U_(e)?Ps().resultSchemas[e]:void 0}n(M_,"getResultSchema");function q_(e){return pm(e)?Ps().requestSchemas[e]:void 0}n(q_,"getRequestSchema");function z_(e){return mm(e)?Ps().notificationSchemas[e]:void 0}n(z_,"getNotificationSchema");var NP=Object.keys(um),jP=Object.keys(lm);function Ji(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(Ji,"isPlainObject$5");function Ts(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}n(Ts,"triState$1");var Wp={ok:!1,reason:"not-in-era"};function Zp(e){return Ji(e)&&Ji(e.outputSchema)&&dm(e.outputSchema)}n(Zp,"toolNeedsLegacyWrap");var Yi={era:"2025-11-25",hasRequestMethod:pm,hasNotificationMethod:mm,validateRequest:n((e,t)=>Ts(q_(e),t),"validateRequest"),validateResult:n((e,t)=>Ts(M_(e),t),"validateResult"),validateNotification:n((e,t)=>Ts(z_(e),t),"validateNotification"),hasInputRequestMethod:n(()=>!1,"hasInputRequestMethod"),validateInputRequest:n(()=>Wp,"validateInputRequest"),validateInputResponse:n(()=>Wp,"validateInputResponse"),samplingResultVariant:n(((e,t)=>{let r=Zi();return Ts(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)}),"samplingResultVariant"),outboundEnvelope:n(e=>{},"outboundEnvelope"),validateEnvelopeMeta:n(e=>[],"validateEnvelopeMeta"),projectCallToolResult(e,t){let r=am(e),o=r.structuredContent;if(o===void 0)return r;let s=typeof o!="object"||o===null||Array.isArray(o),i=t!==void 0&&dm(t);return!s&&!i?r:{...r,structuredContent:{result:o}}},decodeResult(e,t){if(Ji(t)&&"resultType"in t){let r={...t};return delete r.resultType,{kind:"complete",result:r}}return{kind:"complete",result:t}},encodeResult(e,t){if(e!=="tools/list")return t;let r=t.tools;return!Array.isArray(r)||!r.some(o=>Zp(o))?t:{...t,tools:r.map(o=>Zp(o)?{...o,outputSchema:P_(o.outputSchema)}:o)}},encodeErrorCode:n(e=>e===-32002?-32602:e,"encodeErrorCode"),checkInboundEnvelope:n(e=>{},"checkInboundEnvelope")};function N_(){let e=gi(()=>U([u(),C(),z(),ts(),P(u(),e),b(e)])),t=P(u(),e),r=U([u(),C().int()]),o=u(),s=U([u(),C().int()]),i=B(["user","assistant"]),a=B(["debug","info","notice","warning","error","critical","alert","emergency"]),c=u().refine(re=>{try{return atob(re),!0}catch{return!1}},{message:"Invalid Base64 string"}),d=g({ttl:C().optional()}),l=g({taskId:u()}),m=L({progressToken:r.optional(),"io.modelcontextprotocol/related-task":l.optional()}),h=g({_meta:m.optional()}),y=h.extend({task:d.optional()}),f=g({_meta:m.optional()}),R=g({method:u(),params:f.loose().optional()}),S=g({src:u(),mimeType:u().optional(),sizes:b(u()).optional(),theme:B(["light","dark"]).optional()}),w=g({icons:b(S).optional()}),x=g({name:u(),title:u().optional()}),I=x.extend({...x.shape,...w.shape,version:u(),websiteUrl:u().optional(),description:u().optional()}),O=Kn(g({applyDefaults:z().optional()}),t),N=rs(re=>re&&typeof re=="object"&&!Array.isArray(re)&&Object.keys(re).length===0?{form:{}}:re,Kn(g({form:O.optional(),url:t.optional()}),t.optional())),we=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),q=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),ie=g({experimental:P(u(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:N.optional(),roots:g({listChanged:z().optional()}).optional(),tasks:we.optional(),extensions:P(u(),t).optional()}),pe=g({experimental:P(u(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:z().optional()}).optional(),resources:g({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:g({listChanged:z().optional()}).optional(),tasks:q.optional(),extensions:P(u(),t).optional()}),A=g({progress:C(),total:$(C()),message:$(u())}),K=g({...f.shape,...A.shape,progressToken:r}),j=R.extend({method:_("notifications/progress"),params:K}),W=f.extend({level:a,logger:u().optional(),data:D()}),Z=R.extend({method:_("notifications/message"),params:W}),De=g({uri:u(),mimeType:$(u()),_meta:P(u(),D()).optional()}),Oe=De.extend({text:u()}),$e=De.extend({blob:c}),G=g({audience:b(i).optional(),priority:C().min(0).max(1).optional(),lastModified:Wn.datetime({offset:!0}).optional()}),ae=g({...x.shape,...w.shape,uri:u(),description:$(u()),mimeType:$(u()),size:$(C()),annotations:G.optional(),_meta:$(L({}))}),ke=g({...x.shape,...w.shape,uriTemplate:u(),description:$(u()),mimeType:$(u()),annotations:G.optional(),_meta:$(L({}))}),ee=R.extend({method:_("notifications/resources/list_changed"),params:f.optional()}),Ge=f.extend({uri:u()}),or=R.extend({method:_("notifications/resources/updated"),params:Ge}),sr=g({name:u(),description:$(u()),required:$(z())}),Nt=g({...x.shape,...w.shape,description:$(u()),arguments:$(b(sr)),_meta:$(L({}))}),ir=R.extend({method:_("notifications/prompts/list_changed"),params:f.optional()}),Xe=g({type:_("text"),text:u(),annotations:G.optional(),_meta:P(u(),D()).optional()}),Ve=g({type:_("image"),data:c,mimeType:u(),annotations:G.optional(),_meta:P(u(),D()).optional()}),jt=g({type:_("audio"),data:c,mimeType:u(),annotations:G.optional(),_meta:P(u(),D()).optional()}),en=g({type:_("tool_use"),name:u(),id:u(),input:P(u(),D()),_meta:P(u(),D()).optional()}),tn=g({type:_("resource"),resource:U([Oe,$e]),annotations:G.optional(),_meta:P(u(),D()).optional()}),rn=ae.extend({type:_("resource_link")}),yt=U([Xe,Ve,jt,rn,tn]),ar=g({role:i,content:yt}),Dt=g({title:u().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),nn=R.extend({method:_("notifications/tools/list_changed"),params:f.optional()}),on=g({name:u().optional()}),sn=g({hints:b(on).optional(),costPriority:C().min(0).max(1).optional(),speedPriority:C().min(0).max(1).optional(),intelligencePriority:C().min(0).max(1).optional()}),an=g({mode:B(["auto","required","none"]).optional()}),cn=g({type:_("boolean"),title:u().optional(),description:u().optional(),default:z().optional()}),dn=g({type:_("string"),title:u().optional(),description:u().optional(),minLength:C().optional(),maxLength:C().optional(),format:B(["email","uri","date","date-time"]).optional(),default:u().optional()}),un=g({type:B(["number","integer"]),title:u().optional(),description:u().optional(),minimum:C().optional(),maximum:C().optional(),default:C().optional()}),ln=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),default:u().optional()}),pn=g({type:_("string"),title:u().optional(),description:u().optional(),oneOf:b(g({const:u(),title:u()})),default:u().optional()}),mn=g({type:_("string"),title:u().optional(),description:u().optional(),enum:b(u()),enumNames:b(u()).optional(),default:u().optional()}),hn=U([ln,pn]),fn=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({type:_("string"),enum:b(u())}),default:b(u()).optional()}),gn=g({type:_("array"),title:u().optional(),description:u().optional(),minItems:C().optional(),maxItems:C().optional(),items:g({anyOf:b(g({const:u(),title:u()}))}),default:b(u()).optional()}),yn=U([fn,gn]),Sn=U([mn,hn,yn]),_n=U([Sn,cn,dn,un]),$t=y.extend({mode:_("form").optional(),message:u(),requestedSchema:g({type:_("object"),properties:P(u(),_n),required:b(u()).optional()}).catchall(D())}),Lt=g({type:_("ref/resource"),uri:u()}),Ht=g({type:_("ref/prompt"),name:u()}),wn=g({uri:u().startsWith("file://"),name:u().optional(),_meta:P(u(),D()).optional()}),St=ie.shape,Rn=g({experimental:St.experimental,sampling:St.sampling,elicitation:St.elicitation,roots:St.roots,extensions:St.extensions}),Le=pe.shape,cr=g({experimental:Le.experimental,logging:Le.logging,completions:Le.completions,prompts:Le.prompts,resources:Le.resources,tools:Le.tools,extensions:Le.extensions}),dr=L({progressToken:r.optional(),[wr]:u(),[Zn]:I.optional(),[br]:Rn,[Yn]:a.optional()}),Bt=g({...x.shape,...w.shape,description:u().optional(),inputSchema:L({$schema:u().optional(),type:_("object")}),outputSchema:L({$schema:u().optional()}).optional(),annotations:Dt.optional(),_meta:P(u(),D()).optional()}),bn=g({type:_("tool_result"),toolUseId:u(),content:b(yt),structuredContent:D().optional(),isError:z().optional(),_meta:P(u(),D()).optional()}),ur=U([Xe,Ve,jt,en,bn]),Jt=g({role:i,content:U([ur,b(ur)]),_meta:P(u(),D()).optional()}),lr=u(),pr=L({[Rr]:I.optional().catch(void 0)}),mr=pr.optional();function ye(re){return L({_meta:mr,resultType:lr.default("complete"),...re})}n(ye,"wireResult");let vn=ye({}),jo=ye({nextCursor:o.optional()}),hr=ye({content:b(yt),structuredContent:D().optional(),isError:z().optional()}),Cn=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),tools:b(Bt),nextCursor:o.optional()}),In=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),prompts:b(Nt),nextCursor:o.optional()}),Tn=ye({description:u().optional(),messages:b(ar)}),En=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resources:b(ae),nextCursor:o.optional()}),kn=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resourceTemplates:b(ke),nextCursor:o.optional()}),An=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),contents:b(U([Oe,$e]))}),Pn=ye({completion:g({values:b(u()).max(100),total:C().int().optional(),hasMore:z().optional()}).loose()}),Do=ye({ttlMs:C().int().min(0),cacheScope:B(["public","private"])}),xn=ye({ttlMs:C().int().min(0).catch(0),cacheScope:B(["public","private"]).catch("private"),supportedVersions:b(u()),capabilities:cr,instructions:u().optional()}),_t=g({messages:b(Jt),modelPreferences:sn.optional(),systemPrompt:u().optional(),includeContext:B(["none","thisServer","allServers"]).optional(),temperature:C().optional(),maxTokens:C().int(),stopSequences:b(u()).optional(),metadata:t.optional(),tools:b(Bt).optional(),toolChoice:an.optional()}),On=g({method:_("sampling/createMessage"),params:_t}),Un=g({method:_("roots/list"),params:g({_meta:P(u(),D()).optional()}).optional()}),Mn=g({...Jt.shape,model:u(),stopReason:u().optional()}),qn=g({roots:b(wn)}),zn=g({action:B(["accept","decline","cancel"]),content:P(u(),U([u(),C(),z(),b(u())])).optional()}),Nn=g({mode:_("url"),message:u(),url:u().url()}),jn=U([$t,Nn]),Dn=g({method:_("elicitation/create"),params:jn}),$n=U([On,Un,Dn]),Ln=U([Mn,qn,zn]),Hn=P(u(),$n),Bn=P(u(),Ln),Ft=ye({inputRequests:Hn.optional(),requestState:u().optional()}),Gt={inputResponses:Bn.optional(),requestState:u().optional()},$o=g({_meta:dr,...Gt}),Lo=L({progressToken:r.optional()});function Ue(re,Kt){return g({method:_(re),params:g({_meta:dr,...Kt})})}n(Ue,"wireRequest");function Me(re,Kt){return g({method:_(re),params:g({_meta:Lo.optional(),...Kt}).optional()})}n(Me,"dispatchRequest");let Jn={name:u(),arguments:P(u(),D()).optional(),...Gt},Ke={cursor:o.optional()},Ho=Ue("tools/call",Jn),Bo=Ue("tools/list",Ke),Jo=Ue("prompts/list",Ke),Fo=Ue("prompts/get",{name:u(),arguments:P(u(),u()).optional(),...Gt}),Go=Ue("resources/list",Ke),Vo=Ue("resources/templates/list",Ke),Ko=Ue("resources/read",{uri:u(),...Gt}),Fn={ref:U([Ht,Lt]),argument:g({name:u(),value:u()}),context:g({arguments:P(u(),u()).optional()}).optional()},Wo=Ue("completion/complete",Fn),Zo=Ue("server/discover",{}),fr=g({toolsListChanged:z().optional(),promptsListChanged:z().optional(),resourcesListChanged:z().optional(),resourceSubscriptions:b(u()).optional()}),Gn={notifications:fr},Yo=Ue("subscriptions/listen",Gn),Xo=pr.extend({"io.modelcontextprotocol/subscriptionId":s}),Vn=L({_meta:Xo,resultType:lr.default("complete")}),wt={"tools/call":Me("tools/call",Jn),"tools/list":Me("tools/list",Ke),"prompts/get":Me("prompts/get",{name:u(),arguments:P(u(),u()).optional()}),"prompts/list":Me("prompts/list",Ke),"resources/list":Me("resources/list",Ke),"resources/templates/list":Me("resources/templates/list",Ke),"resources/read":Me("resources/read",{uri:u()}),"completion/complete":Me("completion/complete",Fn),"server/discover":Me("server/discover",{}),"subscriptions/listen":Me("subscriptions/listen",Gn)};function Ae(re){return L({_meta:mr,...re})}n(Ae,"liftedResult");let Qo={"tools/call":Ae({content:b(yt),structuredContent:D().optional(),isError:z().optional()}),"tools/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),tools:b(Bt),nextCursor:o.optional()}),"prompts/get":Ae({description:u().optional(),messages:b(ar)}),"prompts/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),prompts:b(Nt),nextCursor:o.optional()}),"resources/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resources:b(ae),nextCursor:o.optional()}),"resources/templates/list":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),resourceTemplates:b(ke),nextCursor:o.optional()}),"resources/read":Ae({ttlMs:C().int().min(0),cacheScope:B(["public","private"]),contents:b(U([Oe,$e]))}),"completion/complete":Ae({completion:g({values:b(u()).max(100),total:C().int().optional(),hasMore:z().optional()}).loose()}),"server/discover":Ae({ttlMs:C().int().min(0).catch(0),cacheScope:B(["public","private"]).catch("private"),supportedVersions:b(u()),capabilities:cr,instructions:u().optional()}),"subscriptions/listen":Ae({})},Vt=L({"io.modelcontextprotocol/subscriptionId":s.optional()}),gr=g({method:_("notifications/subscriptions/acknowledged"),params:g({_meta:Vt.optional(),notifications:fr})}),yr=g({_meta:Vt.optional(),requestId:s,reason:u().optional()}),Sr=g({method:_("notifications/cancelled"),params:yr}),mi={"notifications/cancelled":Sr,"notifications/progress":j,"notifications/message":Z,"notifications/resources/updated":or,"notifications/resources/list_changed":ee,"notifications/tools/list_changed":nn,"notifications/prompts/list_changed":ir,"notifications/subscriptions/acknowledged":gr},Re=n(re=>g({jsonrpc:_("2.0"),id:U([u(),C().int()]),result:re}).strict(),"wireResultResponse");return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,RequestIdSchema:s,RoleSchema:i,LoggingLevelSchema:a,TaskMetadataSchema:d,RelatedTaskMetadataSchema:l,RequestMetaSchema:m,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:y,NotificationsParamsSchema:f,NotificationSchema:R,IconSchema:S,IconsSchema:w,BaseMetadataSchema:x,ImplementationSchema:I,ClientTasksCapabilitySchema:we,ServerTasksCapabilitySchema:q,ClientCapabilitiesSchema:ie,ServerCapabilitiesSchema:pe,ProgressSchema:A,ProgressNotificationParamsSchema:K,ProgressNotificationSchema:j,LoggingMessageNotificationParamsSchema:W,LoggingMessageNotificationSchema:Z,ResourceContentsSchema:De,TextResourceContentsSchema:Oe,BlobResourceContentsSchema:$e,AnnotationsSchema:G,ResourceSchema:ae,ResourceTemplateSchema:ke,ResourceListChangedNotificationSchema:ee,ResourceUpdatedNotificationParamsSchema:Ge,ResourceUpdatedNotificationSchema:or,PromptArgumentSchema:sr,PromptSchema:Nt,PromptListChangedNotificationSchema:ir,TextContentSchema:Xe,ImageContentSchema:Ve,AudioContentSchema:jt,ToolUseContentSchema:en,EmbeddedResourceSchema:tn,ResourceLinkSchema:rn,ContentBlockSchema:yt,PromptMessageSchema:ar,ToolAnnotationsSchema:Dt,ToolListChangedNotificationSchema:nn,ModelHintSchema:on,ModelPreferencesSchema:sn,ToolChoiceSchema:an,BooleanSchemaSchema:cn,StringSchemaSchema:dn,NumberSchemaSchema:un,UntitledSingleSelectEnumSchemaSchema:ln,TitledSingleSelectEnumSchemaSchema:pn,LegacyTitledEnumSchemaSchema:mn,SingleSelectEnumSchemaSchema:hn,UntitledMultiSelectEnumSchemaSchema:fn,TitledMultiSelectEnumSchemaSchema:gn,MultiSelectEnumSchemaSchema:yn,EnumSchemaSchema:Sn,PrimitiveSchemaDefinitionSchema:_n,ElicitRequestFormParamsSchema:$t,ResourceTemplateReferenceSchema:Lt,PromptReferenceSchema:Ht,RootSchema:wn,ClientCapabilities2026Schema:Rn,ServerCapabilities2026Schema:cr,RequestMetaEnvelopeSchema:dr,ToolSchema:Bt,ToolResultContentSchema:bn,SamplingMessageContentBlockSchema:ur,SamplingMessageSchema:Jt,ResultTypeSchema:lr,ResultMetaSchema:pr,ResultSchema:vn,PaginatedResultSchema:jo,CallToolResultSchema:hr,ListToolsResultSchema:Cn,ListPromptsResultSchema:In,GetPromptResultSchema:Tn,ListResourcesResultSchema:En,ListResourceTemplatesResultSchema:kn,ReadResourceResultSchema:An,CompleteResultSchema:Pn,CacheableResultSchema:Do,DiscoverResultSchema:xn,CreateMessageRequestParamsSchema:_t,CreateMessageRequestSchema:On,ListRootsRequestSchema:Un,CreateMessageResultSchema:Mn,ListRootsResultSchema:qn,ElicitResultSchema:zn,ElicitRequestURLParamsSchema:Nn,ElicitRequestParamsSchema:jn,ElicitRequestSchema:Dn,InputRequestSchema:$n,InputResponseSchema:Ln,InputRequestsSchema:Hn,InputResponsesSchema:Bn,InputRequiredResultSchema:Ft,InputResponseRequestParamsSchema:$o,CallToolRequestSchema:Ho,ListToolsRequestSchema:Bo,ListPromptsRequestSchema:Jo,GetPromptRequestSchema:Fo,ListResourcesRequestSchema:Go,ListResourceTemplatesRequestSchema:Vo,ReadResourceRequestSchema:Ko,CompleteRequestSchema:Wo,DiscoverRequestSchema:Zo,SubscriptionFilterSchema:fr,SubscriptionsListenRequestSchema:Yo,SubscriptionsListenResultMetaSchema:Xo,SubscriptionsListenResultSchema:Vn,dispatchRequestSchemas:wt,dispatchResultSchemas:Qo,NotificationMetaSchema:Vt,SubscriptionsAcknowledgedNotificationSchema:gr,CancelledNotificationParamsSchema:yr,CancelledNotificationSchema:Sr,notificationSchemas2026:mi,JSONRPCResultResponseSchema:Re(vn),CallToolResultResponseSchema:Re(U([hr,Ft])),ListToolsResultResponseSchema:Re(Cn),ListPromptsResultResponseSchema:Re(In),GetPromptResultResponseSchema:Re(U([Tn,Ft])),ListResourcesResultResponseSchema:Re(En),ListResourceTemplatesResultResponseSchema:Re(kn),ReadResourceResultResponseSchema:Re(U([An,Ft])),CompleteResultResponseSchema:Re(Pn),DiscoverResultResponseSchema:Re(xn),SubscriptionsListenResultResponseSchema:Re(Vn)}}n(N_,"build");var j_;function ct(){return j_??=N_()}n(ct,"buildSchemas2026");var D_=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function $_(e){return D_.includes(e)}n($_,"isCacheableResultMethod");var Xi=Symbol("modelcontextprotocol.resultCacheHintFallback");function L_(e){return e[Xi]}n(L_,"cacheHintFallbackOf");function hm(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}n(hm,"isValidCacheTtlMs");function fm(e){return e==="public"||e==="private"}n(fm,"isValidCacheScope");var k=(function(e){return e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e})({}),ge=class gm extends Error{static{n(this,"ProtocolError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return ze(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,t)}constructor(t,r,o){super(r),this.code=t,this.data=o,this.name="ProtocolError",Xt(this,new.target)}static fromError(t,r,o){if(t===k.UrlElicitationRequired&&o){let s=o;if(s.elicitations)return new xs(s.elicitations,r)}if(t===k.UnsupportedProtocolVersion&&o){let s=o;if(Array.isArray(s.supported)&&typeof s.requested=="string")return new Sm({supported:s.supported,requested:s.requested},r)}if(t===k.InvalidParams||t===k.ResourceNotFound){let s=o;if(typeof s?.uri=="string"&&(t===k.ResourceNotFound||Object.keys(s).length===1))return new ym(s.uri,r)}if(t===k.MissingRequiredClientCapability&&o){let s=o;if(s.requiredCapabilities!==null&&typeof s.requiredCapabilities=="object"&&!Array.isArray(s.requiredCapabilities))return new _m({requiredCapabilities:s.requiredCapabilities},r)}return new gm(t,r,o)}},ym=class extends ge{static{n(this,"ResourceNotFoundError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(k.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},xs=class extends ge{static{n(this,"UrlElicitationRequiredError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(k.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Sm=class extends ge{static{n(this,"UnsupportedProtocolVersionError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(k.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},_m=class extends ge{static{n(this,"MissingRequiredClientCapabilityError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(k.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},H_=0,B_="private",J_=["tools/call","prompts/get","resources/read"];function F_(e,t){let r=t.resultType;if(r===void 0)return{...t,resultType:"complete"};if(r==="complete"||J_.includes(e))return t;throw new ge(k.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}n(F_,"stampResultType");function G_(e,t){let r=L_(t);if(t.resultType!=="complete"||!$_(e))return r===void 0?t:Y_(t);let o=t,s=hm(o.ttlMs)?o.ttlMs:W_(r),i=fm(o.cacheScope)?o.cacheScope:Z_(r),a={...o,ttlMs:s,cacheScope:i};return delete a[Xi],a}n(G_,"fillCacheFields");function V_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(V_,"isPlainObject$4");function K_(e,t){if(t===void 0)return e;let r=e._meta;return r===void 0?{...e,_meta:{[Rr]:t}}:!V_(r)||r[Rr]!==void 0?e:{...e,_meta:{...r,[Rr]:t}}}n(K_,"stampServerInfoMeta");function W_(e){return e!==void 0&&hm(e.ttlMs)?e.ttlMs:H_}n(W_,"resolveTtlMs");function Z_(e){return e!==void 0&&fm(e.cacheScope)?e.cacheScope:B_}n(Z_,"resolveCacheScope");function Y_(e){let t={...e};return delete t[Xi],t}n(Y_,"stripCacheHintFallback");var X_=["elicitation/create","sampling/createMessage","roots/list"],Es;function Qi(){if(Es)return Es;let e=ct();return Es={request:{"elicitation/create":g({method:_("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":g({method:_("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":g({method:_("roots/list"),params:L({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Es}n(Qi,"inputSchemaMaps");function Q_(){Qi()}n(Q_,"warmInputSchemaMaps2026");function wm(e){return X_.includes(e)}n(wm,"isInputRequestMethod2026");function ji(e){return wm(e)?Qi().request[e]:void 0}n(ji,"getInputRequestSchema2026");function ew(e){return wm(e)?Qi().response[e]:void 0}n(ew,"getInputResponseSchema2026");var ea={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},Rm={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function bm(e){return Object.prototype.hasOwnProperty.call(ea,e)}n(bm,"hasRequestMethod2026");function vm(e){return Object.prototype.hasOwnProperty.call(Rm,e)}n(vm,"hasNotificationMethod2026");function tw(e){return Object.prototype.hasOwnProperty.call(ea,e)}n(tw,"hasResultMethod2026");function rw(e){return bm(e)?ct().dispatchRequestSchemas[e]:void 0}n(rw,"getRequestSchema2026");function nw(e){return tw(e)?ct().dispatchResultSchemas[e]:void 0}n(nw,"getResultSchema2026");function ow(e){return vm(e)?ct().notificationSchemas2026[e]:void 0}n(ow,"getNotificationSchema2026");var DP=Object.keys(ea),$P=Object.keys(Rm);function uo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(uo,"isPlainObject$3");function ao(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}n(ao,"triState");var sw={ok:!1,reason:"not-in-era"},iw=[wr,br];function aw(e,t){let r=t,o=!1,s=n(()=>(o||(r={...r},o=!0),r),"copy"),i=t.tools;e==="tools/list"&&Array.isArray(i)&&i.some(c=>uo(c)&&"execution"in c)&&(s().tools=i.map(c=>{if(!uo(c)||!("execution"in c))return c;let d={...c};return delete d.execution,d}));let a=t.capabilities;if(uo(a)&&"tasks"in a){let c={...a};delete c.tasks,s().capabilities=c}return r}n(aw,"enforceDeletedFields");var ta={era:"2026-07-28",hasRequestMethod:bm,hasNotificationMethod:vm,hasInputRequestMethod:n(e=>ji(e)!==void 0,"hasInputRequestMethod"),validateRequest:n((e,t)=>ao(rw(e),t),"validateRequest"),validateResult:n((e,t)=>ao(nw(e),t),"validateResult"),validateNotification:n((e,t)=>ao(ow(e),t),"validateNotification"),validateInputRequest:n((e,t)=>ao(ji(e),t),"validateInputRequest"),validateInputResponse:n((e,t)=>ao(ew(e),t),"validateInputResponse"),samplingResultVariant:n(()=>sw,"samplingResultVariant"),outboundEnvelope(e){return{[wr]:e.protocolVersion,[Zn]:e.clientInfo,[br]:e.clientCapabilities,...e.logLevel!==void 0&&{[Yn]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let o of iw)o in e||t.push({key:o,problem:"missing"});let r=ct().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let o of r.error.issues){let s=o.path.map(String),i=s.length>0?s.join("."):"_meta";s.length===1&&t.some(a=>a.key===i&&a.problem==="missing")||t.push({key:i,problem:o.message})}return t},projectCallToolResult:n(e=>am(e),"projectCallToolResult"),inputRequestSchema:ji,decodeResult(e,t){if(!uo(t))return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(r===void 0)return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: missing required resultType \u2014 servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof r!="string")return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if(r==="input_required"){let a=t.inputRequests,c=uo(a)?a:{},d=t.requestState,l=t._meta===void 0?void 0:ct().ResultMetaSchema.safeParse(t._meta),m=l?.success?l.data:void 0;return Object.keys(c).length===0&&typeof d!="string"?{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:c,...typeof d=="string"&&{requestState:d},...m!==void 0&&{_meta:m}}}if(r!=="complete")return{kind:"invalid",error:new de(fe.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let o=Cm(),s=Object.hasOwn(o,e)?o[e]:void 0;if(s!==void 0){let a=s.safeParse(t);if(!a.success)return{kind:"invalid",error:new de(fe.InvalidResult,`Invalid result for ${e}: ${a.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,r){return K_(G_(e,F_(e,aw(e,t))),r)},encodeErrorCode:n(e=>e===-32002?-32602:e,"encodeErrorCode"),checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=ct().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(r=>r.message).join("; ")}`}},ks;function Cm(){if(ks)return ks;let e=ct();return ks={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},ks}n(Cm,"getWireResultSchemas");function cw(){Cm()}n(cw,"warmWireResultSchemas2026");var ra="2026-07-28";function po(e){return e!==void 0&&im(e)?ta:Yi}n(po,"codecForVersion");function Yp(e){return e.revision!==void 0?po(e.revision).era:e.era==="modern"?ta.era:Yi.era}n(Yp,"classifiedWireEra");function Di(e){return Im.some(t=>t.hasRequestMethod(e))}n(Di,"isSpecRequestMethod");function $i(e){return Im.some(t=>t.hasNotificationMethod(e))}n($i,"isSpecNotificationMethod");function Xp(e){return e==="tasks/get"||e==="tasks/cancel"}n(Xp,"isExtensionReusedRequestMethod");var Im=[Yi,ta],dw=Fp({AnnotationsSchema:n(()=>Zd,"AnnotationsSchema"),AudioContentSchema:n(()=>Au,"AudioContentSchema"),BaseMetadataSchema:n(()=>kd,"BaseMetadataSchema"),BaseRequestParamsSchema:n(()=>hd,"BaseRequestParamsSchema"),BlobResourceContentsSchema:n(()=>Kd,"BlobResourceContentsSchema"),BooleanSchemaSchema:n(()=>vi,"BooleanSchemaSchema"),CallToolRequestParamsSchema:n(()=>Ju,"CallToolRequestParamsSchema"),CallToolRequestSchema:n(()=>Fu,"CallToolRequestSchema"),CallToolResultSchema:n(()=>Hu,"CallToolResultSchema"),CancelTaskRequestSchema:n(()=>jl,"CancelTaskRequestSchema"),CancelTaskResultSchema:n(()=>Dl,"CancelTaskResultSchema"),CancelledNotificationParamsSchema:n(()=>Cd,"CancelledNotificationParamsSchema"),CancelledNotificationSchema:n(()=>Id,"CancelledNotificationSchema"),ClientCapabilitiesSchema:n(()=>Od,"ClientCapabilitiesSchema"),ClientNotificationSchema:n(()=>Ll,"ClientNotificationSchema"),ClientRequestSchema:n(()=>$l,"ClientRequestSchema"),ClientResultSchema:n(()=>Hl,"ClientResultSchema"),ClientTasksCapabilitySchema:n(()=>Pd,"ClientTasksCapabilitySchema"),CompatibilityCallToolResultSchema:n(()=>Bu,"CompatibilityCallToolResultSchema"),CompleteRequestParamsSchema:n(()=>_l,"CompleteRequestParamsSchema"),CompleteRequestSchema:n(()=>wl,"CompleteRequestSchema"),CompleteResultSchema:n(()=>Rl,"CompleteResultSchema"),ContentBlockSchema:n(()=>Uu,"ContentBlockSchema"),CreateMessageRequestParamsSchema:n(()=>sl,"CreateMessageRequestParamsSchema"),CreateMessageRequestSchema:n(()=>il,"CreateMessageRequestSchema"),CreateMessageResultSchema:n(()=>al,"CreateMessageResultSchema"),CreateMessageResultWithToolsSchema:n(()=>cl,"CreateMessageResultWithToolsSchema"),CreateTaskResultSchema:n(()=>Al,"CreateTaskResultSchema"),CursorSchema:n(()=>ud,"CursorSchema"),DiscoverRequestSchema:n(()=>jd,"DiscoverRequestSchema"),DiscoverResultSchema:n(()=>Ri,"DiscoverResultSchema"),ElicitRequestFormParamsSchema:n(()=>as,"ElicitRequestFormParamsSchema"),ElicitRequestParamsSchema:n(()=>pl,"ElicitRequestParamsSchema"),ElicitRequestSchema:n(()=>ml,"ElicitRequestSchema"),ElicitRequestURLParamsSchema:n(()=>cs,"ElicitRequestURLParamsSchema"),ElicitResultSchema:n(()=>gl,"ElicitResultSchema"),ElicitationCompleteNotificationParamsSchema:n(()=>hl,"ElicitationCompleteNotificationParamsSchema"),ElicitationCompleteNotificationSchema:n(()=>fl,"ElicitationCompleteNotificationSchema"),EmbeddedResourceSchema:n(()=>xu,"EmbeddedResourceSchema"),EmptyResultSchema:n(()=>vd,"EmptyResultSchema"),EnumSchemaSchema:n(()=>ll,"EnumSchemaSchema"),GetPromptRequestParamsSchema:n(()=>Iu,"GetPromptRequestParamsSchema"),GetPromptRequestSchema:n(()=>Tu,"GetPromptRequestSchema"),GetPromptResultSchema:n(()=>qu,"GetPromptResultSchema"),GetTaskPayloadRequestSchema:n(()=>Ml,"GetTaskPayloadRequestSchema"),GetTaskPayloadResultSchema:n(()=>ql,"GetTaskPayloadResultSchema"),GetTaskRequestSchema:n(()=>Ol,"GetTaskRequestSchema"),GetTaskResultSchema:n(()=>Ul,"GetTaskResultSchema"),IconSchema:n(()=>Td,"IconSchema"),IconsSchema:n(()=>Ed,"IconsSchema"),ImageContentSchema:n(()=>ku,"ImageContentSchema"),ImplementationSchema:n(()=>Ad,"ImplementationSchema"),InitializeRequestParamsSchema:n(()=>Ud,"InitializeRequestParamsSchema"),InitializeRequestSchema:n(()=>Md,"InitializeRequestSchema"),InitializeResultSchema:n(()=>zd,"InitializeResultSchema"),InitializedNotificationSchema:n(()=>Nd,"InitializedNotificationSchema"),JSONArraySchema:n(()=>cd,"JSONArraySchema"),JSONObjectSchema:n(()=>ad,"JSONObjectSchema"),JSONRPCErrorResponseSchema:n(()=>Xn,"JSONRPCErrorResponseSchema"),JSONRPCMessageSchema:n(()=>wi,"JSONRPCMessageSchema"),JSONRPCNotificationSchema:n(()=>Si,"JSONRPCNotificationSchema"),JSONRPCRequestSchema:n(()=>Wt,"JSONRPCRequestSchema"),JSONRPCResponseSchema:n(()=>bd,"JSONRPCResponseSchema"),JSONRPCResultResponseSchema:n(()=>_i,"JSONRPCResultResponseSchema"),JSONValueSchema:n(()=>id,"JSONValueSchema"),LegacyTitledEnumSchemaSchema:n(()=>Ti,"LegacyTitledEnumSchemaSchema"),ListChangedOptionsBaseSchema:n(()=>bi,"ListChangedOptionsBaseSchema"),ListPromptsRequestSchema:n(()=>vu,"ListPromptsRequestSchema"),ListPromptsResultSchema:n(()=>Cu,"ListPromptsResultSchema"),ListResourceTemplatesRequestSchema:n(()=>tu,"ListResourceTemplatesRequestSchema"),ListResourceTemplatesResultSchema:n(()=>ru,"ListResourceTemplatesResultSchema"),ListResourcesRequestSchema:n(()=>Qd,"ListResourcesRequestSchema"),ListResourcesResultSchema:n(()=>eu,"ListResourcesResultSchema"),ListRootsRequestSchema:n(()=>vl,"ListRootsRequestSchema"),ListRootsResultSchema:n(()=>Cl,"ListRootsResultSchema"),ListTasksRequestSchema:n(()=>zl,"ListTasksRequestSchema"),ListTasksResultSchema:n(()=>Nl,"ListTasksResultSchema"),ListToolsRequestSchema:n(()=>$u,"ListToolsRequestSchema"),ListToolsResultSchema:n(()=>Lu,"ListToolsResultSchema"),LoggingLevelSchema:n(()=>Vu,"LoggingLevelSchema"),LoggingMessageNotificationParamsSchema:n(()=>Zu,"LoggingMessageNotificationParamsSchema"),LoggingMessageNotificationSchema:n(()=>Yu,"LoggingMessageNotificationSchema"),ModelHintSchema:n(()=>Xu,"ModelHintSchema"),ModelPreferencesSchema:n(()=>Qu,"ModelPreferencesSchema"),MultiSelectEnumSchemaSchema:n(()=>ul,"MultiSelectEnumSchemaSchema"),NotificationSchema:n(()=>Sd,"NotificationSchema"),NotificationsParamsSchema:n(()=>yd,"NotificationsParamsSchema"),NumberSchemaSchema:n(()=>is,"NumberSchemaSchema"),PaginatedRequestParamsSchema:n(()=>Bd,"PaginatedRequestParamsSchema"),PaginatedRequestSchema:n(()=>Jd,"PaginatedRequestSchema"),PaginatedResultSchema:n(()=>Fd,"PaginatedResultSchema"),PingRequestSchema:n(()=>Dd,"PingRequestSchema"),PrimitiveSchemaDefinitionSchema:n(()=>Ai,"PrimitiveSchemaDefinitionSchema"),ProgressNotificationParamsSchema:n(()=>Ld,"ProgressNotificationParamsSchema"),ProgressNotificationSchema:n(()=>Hd,"ProgressNotificationSchema"),ProgressSchema:n(()=>$d,"ProgressSchema"),ProgressTokenSchema:n(()=>dd,"ProgressTokenSchema"),PromptArgumentSchema:n(()=>Ru,"PromptArgumentSchema"),PromptListChangedNotificationSchema:n(()=>zu,"PromptListChangedNotificationSchema"),PromptMessageSchema:n(()=>Mu,"PromptMessageSchema"),PromptReferenceSchema:n(()=>Sl,"PromptReferenceSchema"),PromptSchema:n(()=>bu,"PromptSchema"),ReadResourceRequestParamsSchema:n(()=>ou,"ReadResourceRequestParamsSchema"),ReadResourceRequestSchema:n(()=>su,"ReadResourceRequestSchema"),ReadResourceResultSchema:n(()=>iu,"ReadResourceResultSchema"),RelatedTaskMetadataSchema:n(()=>pd,"RelatedTaskMetadataSchema"),RequestIdSchema:n(()=>Rd,"RequestIdSchema"),RequestMetaSchema:n(()=>md,"RequestMetaSchema"),RequestSchema:n(()=>gd,"RequestSchema"),ResourceContentsSchema:n(()=>Gd,"ResourceContentsSchema"),ResourceLinkSchema:n(()=>Ou,"ResourceLinkSchema"),ResourceListChangedNotificationSchema:n(()=>au,"ResourceListChangedNotificationSchema"),ResourceRequestParamsSchema:n(()=>nu,"ResourceRequestParamsSchema"),ResourceSchema:n(()=>Yd,"ResourceSchema"),ResourceTemplateReferenceSchema:n(()=>yl,"ResourceTemplateReferenceSchema"),ResourceTemplateSchema:n(()=>Xd,"ResourceTemplateSchema"),ResourceUpdatedNotificationParamsSchema:n(()=>_u,"ResourceUpdatedNotificationParamsSchema"),ResourceUpdatedNotificationSchema:n(()=>wu,"ResourceUpdatedNotificationSchema"),ResultMetaObjectSchema:n(()=>_d,"ResultMetaObjectSchema"),ResultSchema:n(()=>wd,"ResultSchema"),RoleSchema:n(()=>Wd,"RoleSchema"),RootSchema:n(()=>bl,"RootSchema"),RootsListChangedNotificationSchema:n(()=>Il,"RootsListChangedNotificationSchema"),SamplingContentSchema:n(()=>rl,"SamplingContentSchema"),SamplingMessageContentBlockSchema:n(()=>nl,"SamplingMessageContentBlockSchema"),SamplingMessageSchema:n(()=>ol,"SamplingMessageSchema"),ServerCapabilitiesSchema:n(()=>qd,"ServerCapabilitiesSchema"),ServerNotificationSchema:n(()=>Jl,"ServerNotificationSchema"),ServerRequestSchema:n(()=>Bl,"ServerRequestSchema"),ServerResultSchema:n(()=>Fl,"ServerResultSchema"),ServerTasksCapabilitySchema:n(()=>xd,"ServerTasksCapabilitySchema"),SetLevelRequestParamsSchema:n(()=>Ku,"SetLevelRequestParamsSchema"),SetLevelRequestSchema:n(()=>Wu,"SetLevelRequestSchema"),SingleSelectEnumSchemaSchema:n(()=>dl,"SingleSelectEnumSchemaSchema"),StringSchemaSchema:n(()=>ss,"StringSchemaSchema"),SubscribeRequestParamsSchema:n(()=>cu,"SubscribeRequestParamsSchema"),SubscribeRequestSchema:n(()=>du,"SubscribeRequestSchema"),SubscriptionFilterSchema:n(()=>pu,"SubscriptionFilterSchema"),SubscriptionsAcknowledgedNotificationParamsSchema:n(()=>fu,"SubscriptionsAcknowledgedNotificationParamsSchema"),SubscriptionsAcknowledgedNotificationSchema:n(()=>gu,"SubscriptionsAcknowledgedNotificationSchema"),SubscriptionsListenRequestParamsSchema:n(()=>mu,"SubscriptionsListenRequestParamsSchema"),SubscriptionsListenRequestSchema:n(()=>hu,"SubscriptionsListenRequestSchema"),SubscriptionsListenResultMetaSchema:n(()=>yu,"SubscriptionsListenResultMetaSchema"),SubscriptionsListenResultSchema:n(()=>Su,"SubscriptionsListenResultSchema"),TaskAugmentedRequestParamsSchema:n(()=>fd,"TaskAugmentedRequestParamsSchema"),TaskCreationParamsSchema:n(()=>Tl,"TaskCreationParamsSchema"),TaskMetadataSchema:n(()=>ld,"TaskMetadataSchema"),TaskSchema:n(()=>kl,"TaskSchema"),TaskStatusNotificationParamsSchema:n(()=>Pl,"TaskStatusNotificationParamsSchema"),TaskStatusNotificationSchema:n(()=>xl,"TaskStatusNotificationSchema"),TaskStatusSchema:n(()=>El,"TaskStatusSchema"),TextContentSchema:n(()=>Eu,"TextContentSchema"),TextResourceContentsSchema:n(()=>Vd,"TextResourceContentsSchema"),TitledMultiSelectEnumSchemaSchema:n(()=>ki,"TitledMultiSelectEnumSchemaSchema"),TitledSingleSelectEnumSchemaSchema:n(()=>Ii,"TitledSingleSelectEnumSchemaSchema"),ToolAnnotationsSchema:n(()=>Nu,"ToolAnnotationsSchema"),ToolChoiceSchema:n(()=>el,"ToolChoiceSchema"),ToolExecutionSchema:n(()=>ju,"ToolExecutionSchema"),ToolListChangedNotificationSchema:n(()=>Gu,"ToolListChangedNotificationSchema"),ToolResultContentSchema:n(()=>tl,"ToolResultContentSchema"),ToolSchema:n(()=>Du,"ToolSchema"),ToolUseContentSchema:n(()=>Pu,"ToolUseContentSchema"),UnsubscribeRequestParamsSchema:n(()=>uu,"UnsubscribeRequestParamsSchema"),UnsubscribeRequestSchema:n(()=>lu,"UnsubscribeRequestSchema"),UntitledMultiSelectEnumSchemaSchema:n(()=>Ei,"UntitledMultiSelectEnumSchemaSchema"),UntitledSingleSelectEnumSchemaSchema:n(()=>Ci,"UntitledSingleSelectEnumSchemaSchema")});var Tm=n(e=>Wt.safeParse(e).success,"isJSONRPCRequest"),Em=n(e=>Si.safeParse(e).success,"isJSONRPCNotification"),Fi=n(e=>_i.safeParse(e).success,"isJSONRPCResultResponse"),km=n(e=>Xn.safeParse(e).success,"isJSONRPCErrorResponse");var lo=-32020,LP=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32e3],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[k.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[lo,k.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[k.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope \u2014 and a missing envelope on a request whose protocol-version header names a modern revision \u2014 is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[k.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision\u2019s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[k.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[lo],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[k.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced \u2014 pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[lo],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool\u2019s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],HP={[k.ParseError]:400,[k.InvalidRequest]:400,[k.MethodNotFound]:404,[k.UnsupportedProtocolVersion]:400,[k.MissingRequiredClientCapability]:400,[lo]:400};function na(e,t){return Xc(e,t)}n(na,"parseSchema");function co(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}n(co,"shapeKeys");function Gi(e){if(e==null)return!1;let t=typeof e;return t!=="object"&&t!=="function"||!("~standard"in e)?!1:typeof e["~standard"]?.validate=="function"}n(Gi,"isStandardSchema");var Qp=!1,Vi="draft-2020-12";function uw(e,t="input"){let r=e["~standard"],o;if(r.jsonSchema)o=r.jsonSchema[t]({target:Vi});else if(r.vendor==="zod"){if(!("_zod"in e))throw new Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");Qp||(Qp=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),o=hi(e,{target:Vi,io:t})}else throw new Error(`Schema library "${r.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output")return o.type!==void 0?o:Am(o)?{type:"object",...o}:o;if(o.type!==void 0&&o.type!=="object")throw new Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(o.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...o}}n(uw,"standardSchemaToJsonSchema");function Am(e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;for(let t of["oneOf","anyOf","allOf"]){let r=e[t];if(Array.isArray(r)&&r.length>0)return r.every(o=>o!==null&&typeof o=="object"&&(o.type==="object"||Am(o)))}return!1}n(Am,"isProvablyObjectShapedRoot");function lw(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}n(lw,"formatIssue");async function Li(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(o=>lw(o)).join(", ")}:{success:!0,data:r.value}}n(Li,"validateStandardSchema");function pw(e){let t=hi(e,{target:Vi,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}n(pw,"zodEmittedPattern");var mw=/\\\.\\d\{(\d+)\}/;function hw(e){let t=mw.exec(e),r=[void 0,-1,0];return t&&r.push(Number(t[1])),[!1,!0].flatMap(o=>[!1,!0].flatMap(s=>r.map(i=>Wn.datetime({local:o,offset:s,precision:i}))))}n(hw,"datetimeReferenceSchemas");function fw(e,t){let r;switch(e){case"email":r=[Qc()];break;case"uri":r=[ed()];break;case"date":r=[Wn.date()];break;case"date-time":r=hw(t);break}return new Set(r.map(o=>pw(o)).filter(o=>o!==void 0))}n(fw,"referencePatternsForFormat");function gw(e,t,r){return r!=="zod"?!0:fw(e,t).has(t)}n(gw,"isLibraryFormatPattern");function mo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}n(mo,"isJsonObject");function yw(e){try{return uw(e,"input")}catch(t){let r=t instanceof Error?t.message:String(t);throw new ge(k.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${r}`)}}n(yw,"convertStandardElicitationSchema");var Sw=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function oa(e){return Sw.has(e)||e.startsWith("x-")}n(oa,"isAnnotationOnlyJsonSchemaKeyword");var _w=new Set(["$schema",...Object.keys(as.shape.requestedSchema.shape)]),em={string:co([ss,Ci,Ii,Ti]),number:co([is]),integer:co([is]),boolean:co([vi]),array:co([Ei,ki])},ww=new Set(ss.shape.format.unwrap().options);function Rw(e,t,r,o){if(!mo(e))return e;let s=typeof e.type=="string"&&Object.hasOwn(em,e.type)?em[e.type]:void 0;if(s===void 0)return e;let i={};for(let[a,c]of Object.entries(e))s.has(a)||oa(a)?i[a]=c:a==="pattern"&&e.type==="string"&&typeof e.format=="string"?ww.has(e.format)?(typeof c!="string"||!gw(e.format,c,r))&&o.push(`${t}.${a}`):i[a]=c:o.push(`${t}.${a}`);return i}n(Rw,"walkProperty");function bw(e,t){let r={},o=[];for(let[s,i]of Object.entries(e))s==="properties"&&mo(i)?r[s]=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,Rw(c,`properties.${a}`,t,o)])):_w.has(s)?r[s]=i:oa(s)||o.push(s);if(o.length>0)throw new ge(k.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);return r}n(bw,"walkRequestedSchema");function vw(e,t){if(!mo(e.properties))return t;let r=Object.entries(e.properties).filter(([,o])=>!na(Ai,o).success).map(([o])=>`properties.${o}`);return r.length>0?r.join(", "):t}n(vw,"describeUnsupportedProperties");function Ki(e,t,r=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((o,s)=>Ki(o,t[s],`${r}[${s}]`)):!mo(e)||!mo(t)?[]:Object.entries(e).flatMap(([o,s])=>{let i=r?`${r}.${o}`:o;return Object.prototype.hasOwnProperty.call(t,o)?Ki(s,t[o],i):oa(o)?[]:[i]})}n(Ki,"findDroppedConstraintPaths");function Cw(e){if(!Gi(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,r=bw(yw(e.requestedSchema),t),o=na(as.shape.requestedSchema,r);if(!o.success)throw new ge(k.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${vw(r,o.error.message)}`);let s=Ki(r,o.data);if(s.length>0)throw new ge(k.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${s.join(", ")}`);let i=(o.data.required??[]).filter(a=>!Object.prototype.hasOwnProperty.call(o.data.properties,a));if(i.length>0)throw new ge(k.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:o.data}}n(Cw,"normalizeElicitInputParams");function Iw(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,r=typeof e.requestState=="string";if(!t&&!r)throw new TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}n(Iw,"buildInputRequired");var BP=Object.assign(Iw,{elicit(e){try{return{method:"elicitation/create",params:Cw(e)}}catch(t){throw t instanceof ge?new TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var Tw=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],Ew={IdJagTokenExchangeResponseSchema:Pi,OAuthClientInformationFullSchema:Zt,OAuthClientInformationSchema:Qn,OAuthClientMetadataSchema:Vl,OAuthClientRegistrationErrorSchema:Kl,OAuthErrorResponseSchema:ds,OAuthMetadataSchema:Ir,OAuthProtectedResourceMetadataSchema:Cr,OAuthTokenRevocationRequestSchema:Wl,OAuthTokensSchema:Rt,OpenIdProviderDiscoveryMetadataSchema:Tr,OpenIdProviderMetadataSchema:Gl},Pm={},xm={};function Om(e,t){let r=e.slice(0,-6);Pm[r]=t,xm[r]=o=>t.safeParse(o).success}n(Om,"register");for(let e of Tw)Om(e,dw[e]);for(let[e,t]of Object.entries(Ew))Om(e,t);var kw=Object.freeze(Pm),Aw=Object.freeze(xm);function Pw(e){switch(e){case"initialize":case"notifications/initialized":return po(void 0);case"server/discover":return po(ra);default:return}}n(Pw,"bootstrapOutboundCodec");var Um=6e4,xw=[wr,Zn,br,Yn],Ow=["inputResponses","requestState"];function tm(e,t){let r=e.params;if(!Hi(r))return{message:e,lifted:{}};let o=r._meta,s=Hi(o)?xw.filter(d=>d in o):[],i=t==="request"?Ow.filter(d=>d in r):[];if(s.length===0&&i.length===0)return{message:e,lifted:{}};let a={},c={...r};if(s.length>0&&Hi(o)){let d={},l={...o};for(let m of s)d[m]=o[m],delete l[m];a.envelope=d,Object.keys(l).length>0?c._meta=l:delete c._meta}for(let d of i)d==="inputResponses"&&(a.inputResponses=c[d]),d==="requestState"&&(a.requestState=c[d]),delete c[d];return{message:{...e,params:c},lifted:a}}n(tm,"liftWireOnlyMaterial");function rm(e,t){let r=e.validateResult(t,void 0);if(!(!r.ok&&r.reason==="not-in-era"))return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(o){let s=e.validateResult(t,o);return s.ok?{value:s.value}:{issues:[{message:s.reason==="invalid"?s.message:`not-in-era: ${t}`}]}}}}}n(rm,"codecResultValidator");function Mm(e){return()=>e}n(Mm,"requestStateAccessor");var Uw=Mm(void 0),Mw,qw=class{static{n(this,"Protocol")}_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{Mw=n((e,t)=>{e._negotiatedProtocolVersion=t},"writeNegotiatedProtocolVersion")}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??yi,this.setNotificationHandler("notifications/cancelled",t=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",t=>{this._onprogress(t)}),this.setRequestHandler("ping",t=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new de(fe.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new de(fe.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=s=>{r?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Fi(s)||km(s)?this._onresponse(s):Tm(s)?this._onrequest(s,i):Em(s)?this._onnotification(s,i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new de(fe.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let o of e.values())o(r);for(let o of t.values())o.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=tm(e,"notification"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let a=Yp(t.classification);if(a!==o.era){this._onerror(new Error(`Era mismatch on inbound notification '${r.method}': classified as ${a} but this instance serves ${o.era}`));return}}if($i(r.method)&&!o.hasNotificationMethod(r.method))return;let s=this._notificationHandlers.get(r.method),i=this.fallbackNotificationHandler;s===void 0&&i===void 0||Promise.resolve().then(()=>s===void 0?i(r):s(r,o)).catch(a=>this._onerror(new Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(e,t){let{message:r,lifted:o}=tm(e,"request"),s=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(new Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let i=this._transport,a=n((S,w,x)=>{let I={jsonrpc:"2.0",id:r.id,error:{code:S,message:w,...x!==void 0&&{data:x}}};i?.send(I).catch(O=>this._onerror(new Error(`Failed to send an error response: ${O}`)))},"sendErrorResponse");if(t?.classification!==void 0){let S=Yp(t.classification);if(S!==s.era){this._onerror(new Error(`Era mismatch on inbound request '${r.method}': classified as ${S} but this instance serves ${s.era}`));let w=t.classification.revision??S;a(k.UnsupportedProtocolVersion,`Unsupported protocol version: ${w}`,{supported:this._supportedProtocolVersions,requested:w});return}}if(Di(r.method)&&!s.hasRequestMethod(r.method)&&!(Xp(r.method)&&this._customSchemaRequestMethods.has(r.method))){a(k.MethodNotFound,"Method not found");return}let c=this._requestHandlers.get(r.method)??this.fallbackRequestHandler;if(c===void 0){a(k.MethodNotFound,"Method not found");return}let d=s.checkInboundEnvelope(o);if(d!==void 0){a(k.InvalidParams,d);return}let l=n((S,w)=>this._notificationViaCodec(this._resolveOutboundCodec(S.method),S,{...w,relatedRequestId:r.id}),"sendNotification"),m=n((S,w,x)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(S.method),S,w,{...x,relatedRequestId:r.id}),"sendRequest"),h=new AbortController;this._requestHandlerAbortControllers.set(r.id,h);let y=o.inputResponses===void 0?void 0:zw(o.inputResponses),f={sessionId:i?.sessionId,mcpReq:{id:r.id,method:r.method,_meta:r.params?._meta,...o.envelope!==void 0&&{envelope:o.envelope},...y!==void 0&&{inputResponses:y.accepted},...y!==void 0&&y.droppedKeys.length>0&&{droppedInputResponseKeys:y.droppedKeys},requestState:o.requestState===void 0?Uw:Mm(o.requestState),signal:h.signal,send:n(((S,w,x)=>{let I=this._resolveOutboundCodec(S.method);if(this._assertOutboundRequestInEra(I,S.method),Gi(w))return m(S,w,x);let O=rm(I,S.method);if(O===void 0)throw new TypeError(`'${S.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return m(S,O,w)}),"send"),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},R=this.buildContext(f,t);Promise.resolve().then(()=>c(r,R)).then(async S=>{if(h.signal.aborted)return;let w;try{w=s.encodeResult(r.method,S,this._outboundServerInfo())}catch(I){this._onerror(new Error(`Failed to encode result for ${r.method}: ${I}`)),a(k.InternalError,"Internal error");return}let x={result:w,jsonrpc:"2.0",id:r.id};await i?.send(x)},async S=>{if(h.signal.aborted)return;let w=Number.isSafeInteger(S.code)?S.code:k.InternalError,x={jsonrpc:"2.0",id:r.id,error:{code:s.encodeErrorCode(w),message:S.message??"Internal error",...S.data!==void 0&&{data:S.data}}};await i?.send(x)}).catch(S=>this._onerror(new Error(`Failed to send response: ${S}`))).finally(()=>{this._requestHandlerAbortControllers.get(r.id)===h&&this._requestHandlerAbortControllers.delete(r.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,o=Number(t),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Fi(e)?r(e):r(ge.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let o=this._resolveOutboundCodec(e.method);if(Gi(t))return Xp(e.method)||this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r);this._assertOutboundRequestInEra(o,e.method);let s=rm(o,e.method);if(s===void 0)throw new TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(o,e,s,t)}_negotiatedWireCodec(){return po(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=Pw(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Di(t)&&!e.hasRequestMethod(t))throw new de(fe.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let o=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r)}_requestWithSchemaViaCodec(e,t,r,o){let{relatedRequestId:s,resumptionToken:i,onresumptiontoken:a,headers:c}=o??{},d=Date.now(),l,m;return new Promise((h,y)=>{let f=n(q=>{y(q)},"earlyReject");if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(q){f(q);return}if(o?.signal?.aborted){let q=o.signal.reason;throw q instanceof de?q:new de(fe.RequestTimeout,String(q))}let R=e.era===ra&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,S=this._requestMessageId++;m=S;let w={...t,jsonrpc:"2.0",id:S};o?.onprogress&&(this._progressHandlers.set(S,o.onprogress),w.params={...t.params,_meta:{...t.params?._meta,progressToken:S}});let x=this._envelopeOutbound(w),I=!1,O=n(q=>{I||(this._progressHandlers.delete(S),R===void 0?t.method!=="initialize"&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:S,reason:String(q)}}),{relatedRequestId:s,resumptionToken:i,onresumptiontoken:a}).catch(ie=>this._onerror(new Error(`Failed to send cancellation: ${ie}`))):R.abort(),y(q instanceof de?q:new de(fe.RequestTimeout,String(q))))},"cancel");this._responseHandlers.set(S,q=>{if(o?.signal?.aborted)return;if(I=!0,q instanceof Error)return y(q);let ie;try{ie=e.decodeResult(t.method,q.result)}catch(A){return y(A instanceof Error?A:new Error(String(A)))}if(ie.kind==="invalid")return y(ie.error);if(ie.kind==="input_required"){if(o?.allowInputRequired===!0)return h(Nw(ie));let A={codec:e,request:t,resultSchema:r,options:o,flowStartedAt:d,retry:n((K,j)=>this._requestWithSchemaViaCodec(e,K===void 0?{method:t.method}:{method:t.method,params:K},r,j),"retry")};return h(this._resolveNonCompleteResult(ie,A))}let pe=ie.result;Li(r,pe).then(A=>{A.success?h(A.data):y(new de(fe.InvalidResult,`Invalid result for ${t.method}: ${A.error}`))},y)}),l=n(()=>O(o?.signal?.reason),"onAbort"),o?.signal?.addEventListener("abort",l,{once:!0});let N=o?.timeout??Um,we=n(()=>O(new de(fe.RequestTimeout,"Request timed out",{timeout:N})),"timeoutHandler");this._setupTimeout(S,N,o?.maxTotalTimeout,we,o?.resetTimeoutOnProgress??!1),this._transport.send(x,{relatedRequestId:s,resumptionToken:i,onresumptiontoken:a,headers:c,requestSignal:R?.signal}).catch(q=>{this._progressHandlers.delete(S),y(q)})}).finally(()=>{l&&o?.signal?.removeEventListener("abort",l),m!==void 0&&(this._responseHandlers.delete(m),this._cleanupTimeout(m))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new de(fe.NotConnected,"Not connected");if($i(t.method)&&!e.hasNotificationMethod(t.method))throw new de(fe.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let o=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(o,r).catch(s=>this._onerror(s))});return}await this._transport.send(o,r)}setRequestHandler(e,t,r){this.assertRequestHandlerCapability(e);let o;if(typeof t=="function"){if(!Di(e))throw new TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);o=n((s,i)=>{let a=this._negotiatedWireCodec(),c=a.validateRequest(e,s);if(!c.ok&&c.reason==="not-in-era"&&(c=a.validateInputRequest(e,s)),!c.ok)throw c.reason==="not-in-era"?new ge(k.InternalError,`No wire schema for ${e} in the resolved era`):new Error(c.message);return Promise.resolve(t(c.value,i))},"stored")}else if(r)o=n(async(s,i)=>{let a=await Li(t.params,{...s.params});if(!a.success)throw new ge(k.InvalidParams,`Invalid params for ${e}: ${a.error}`);return r(a.data,i)},"stored");else throw new TypeError("setRequestHandler: handler is required");typeof t=="function"?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,o))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if(typeof t=="function"){if(!$i(e))throw new TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(o,s)=>{let i=s.validateNotification(e,o);if(!i.ok)throw i.reason==="not-in-era"?new ge(k.InternalError,`No wire schema for ${e} in the resolved era`):new Error(i.message);return Promise.resolve(t(i.value))});return}if(!r)throw new TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async o=>{let s=await Li(t.params,{...o.params});if(!s.success)throw new ge(k.InvalidParams,`Invalid params for notification ${e}: ${s.error}`);await r(s.data,o)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Hi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}n(Hi,"isPlainObject$1");function nm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}n(nm,"isPlainObject");function zw(e){let t={},r=[];if(!nm(e))return{accepted:t,droppedKeys:r};for(let[o,s]of Object.entries(e)){if(!nm(s)||"method"in s||"result"in s){r.push(o);continue}t[o]=s}return{accepted:t,droppedKeys:r}}n(zw,"partitionInputResponses");function Nw(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}n(Nw,"manualInputRequiredValue");var jw=Jp((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,o=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=s;function s(c){if(!c)throw new TypeError("argument string is required");var d=typeof c=="object"?i(c):c;if(typeof d!="string")throw new TypeError("argument string is required to be a string");var l=d.indexOf(";"),m=l!==-1?d.slice(0,l).trim():d.trim();if(!o.test(m))throw new TypeError("invalid media type");var h=new a(m.toLowerCase());if(l!==-1){var y,f,R;for(t.lastIndex=l;f=t.exec(d);){if(f.index!==l)throw new TypeError("invalid parameter format");l+=f[0].length,y=f[1].toLowerCase(),R=f[2],R.charCodeAt(0)===34&&(R=R.slice(1,-1),R.indexOf("\\")!==-1&&(R=R.replace(r,"$1"))),h.parameters[y]=R}if(l!==d.length)throw new TypeError("invalid parameter format")}return h}n(s,"parse");function i(c){var d;if(typeof c.getHeader=="function"?d=c.getHeader("content-type"):typeof c.headers=="object"&&(d=c.headers&&c.headers["content-type"]),typeof d!="string")throw new TypeError("content-type header is missing from object");return d}n(i,"getcontenttype");function a(c){this.parameters=Object.create(null),this.type=c}n(a,"ContentType")})),JP=Gp(jw(),1);var Dw=10*1024*1024;var $w=new Set([301,302,303,307,308]),Lw=5;function Hw(e,t){return e.protocol===t.protocol&&e.host===t.host?!0:e.protocol==="http:"&&t.protocol==="https:"&&e.hostname===t.hostname&&!e.port&&!t.port}n(Hw,"isWithinOrigin");function Bw(e,t){let r=$w.has(t.status)?t.headers?.get("location"):void 0;if(r)try{return new URL(r,e)}catch{return}}n(Bw,"redirectTarget");var Jw=new WeakSet;function Os(e){return Jw.has(e)?e:async(t,r)=>{if(r?.redirect==="error"||r?.redirect==="manual")return e(t,r);let o=(r?.method??"GET").toUpperCase(),s=t;for(let i=0;;i++){let a=await e(s,{...r,redirect:"manual"}),c=Bw(s,a);if(!c||i===Lw)return a;let d=new URL(s),l=o==="GET"||a.status===307||a.status===308,m=!(c.username||c.password)||c.username===d.username&&c.password===d.password;if(!l||!m||!Hw(d,c))return a;await a.text?.().catch(()=>{}),s=c}}}n(Os,"fetchWithinOrigin");function sa(){Zi(),ct(),O_(),Q_(),cw()}n(sa,"preloadSchemas");var rx=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");var Fw=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Gw=[0,31,28,31,30,31,30,31,31,30,31,30,31],Vw=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Kw=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Ww=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Zw=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Yw=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Xw=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Qw=/^(?:\/(?:[^~/]|~0|~1)*)*$/,eR=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,tR=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,rR=n(e=>{if(e[0]==='"')return!1;let[t,r,...o]=e.split("@");return!t||!r||o.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(s=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(s))},"EMAIL"),nR=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,oR=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,sR=n(e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),"DURATION");function et(e){return e.test.bind(e)}n(et,"bind");var nx={date:qm,time:zm.bind(void 0,!1),"date-time":cR,duration:sR,uri:lR,"uri-reference":et(Ww),"uri-template":et(Zw),url:et(Yw),email:rR,hostname:et(Kw),ipv4:et(nR),ipv6:et(oR),regex:mR,uuid:et(Xw),"json-pointer":et(Qw),"json-pointer-uri-fragment":et(eR),"relative-json-pointer":et(tR)};function iR(e){return e%4===0&&(e%100!==0||e%400===0)}n(iR,"isLeapYear");function qm(e){let t=e.match(Fw);if(!t)return!1;let r=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o==2&&iR(r)?29:Gw[o])}n(qm,"date");function zm(e,t){let r=t.match(Vw);if(!r)return!1;let o=+r[1],s=+r[2],i=+r[3],a=!!r[5];return(o<=23&&s<=59&&i<=59||o==23&&s==59&&i==60)&&(!e||a)}n(zm,"time");var aR=/t|\s/i;function cR(e){let t=e.split(aR);return t.length==2&&qm(t[0])&&zm(!0,t[1])}n(cR,"date_time");var dR=/\/|:/,uR=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function lR(e){return dR.test(e)&&uR.test(e)}n(lR,"uri");var pR=/[^\\]\\Z/;function mR(e){if(pR.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}n(mR,"regex");sa();var Nm=!1;var ia;ia=globalThis.crypto;async function fR(e){return(await ia).getRandomValues(new Uint8Array(e))}n(fR,"getRandomValues");async function gR(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,o="";for(;o.length<e;){let s=await fR(e-o.length);for(let i of s)i<r&&(o+=t[i%t.length])}return o}n(gR,"random");async function yR(e){return await gR(e)}n(yR,"generateVerifier");async function SR(e){let t=await(await ia).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}n(SR,"generateChallenge");async function aa(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await yR(e),r=await SR(t);return{code_verifier:t,code_challenge:r}}n(aa,"pkceChallenge");var fo=class extends Error{static{n(this,"OAuthClientFlowError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e){super(e),this.name=new.target.name,Xt(this,new.target)}},ho=class extends fo{static{n(this,"IssuerMismatchError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,r){super(`Issuer mismatch in ${e==="metadata"?"authorization server metadata (RFC 8414 \xA73.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(r)}`),this.kind=e,this.expected=t,this.received=r}},pa=class extends fo{static{n(this,"RegistrationRejectedError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`),this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},qs=class extends fo{static{n(this,"InsecureTokenEndpointError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`),this.tokenEndpoint=e}},Ms=class extends fo{static{n(this,"AuthorizationServerMismatchError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`),this.recordedIssuer=e,this.currentIssuer=t}},Gx=class extends fo{static{n(this,"InsufficientScopeError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`),this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};function la(e,t,r){if(e)return typeof e.issuer!="string"?(r?.canPersistStamp!==!1&&console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field."),e.issuer===void 0?e:{...e,issuer:void 0}):Lm(e.issuer,t)?e:void 0}n(la,"discardIfIssuerMismatch");function Lm(e,t){return e===t||e.endsWith("/")&&e.slice(0,-1)===t||t.endsWith("/")&&t.slice(0,-1)===e}n(Lm,"issuersMatch");var Vx=class extends Error{static{n(this,"UnauthorizedError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e){super(e??"Unauthorized"),this.name="UnauthorizedError",Xt(this,new.target)}};function Hm(e){return e?.authorization_response_iss_parameter_supported===!0}n(Hm,"isIssParameterSupported");function Bm({iss:e,expectedIssuer:t,issParameterSupported:r}){if(t!==void 0){if(e===void 0){if(r)throw new ho("authorization_response",t,void 0);return}if(e!==t)throw new ho("authorization_response",t,e)}}n(Bm,"validateAuthorizationResponseIssuer");function _R(e){return["client_secret_basic","client_secret_post","none"].includes(e)}n(_R,"isClientAuthMethod");var ca="code",da="S256";function wR(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&_R(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}n(wR,"selectClientAuthMethod");function RR(e,t,r,o){let{client_id:s,client_secret:i}=t;switch(e){case"client_secret_basic":bR(s,i,r);return;case"client_secret_post":vR(s,i,o);return;case"none":CR(s,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}n(RR,"applyClientAuthentication");function bR(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}n(bR,"applyBasicAuth");function vR(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}n(vR,"applyPostAuth");function CR(e,t){t.set("client_id",e)}n(CR,"applyPublicAuth");function Jm(e){return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="[::1]"||e==="::1"}n(Jm,"isLoopbackHost");function IR(e){let t=new URL(String(e));if(t.protocol!=="https:"&&!Jm(t.hostname))throw new qs(t.href);return t}n(IR,"assertSecureTokenEndpoint");function TR(e){for(let t of e??[]){let r;try{r=new URL(t)}catch{continue}if(r.protocol!=="http:"&&r.protocol!=="https:"||Jm(r.hostname))return"native"}return"web"}n(TR,"deriveApplicationType");function ER(e){let t=e.clientMetadata;return{...t,grant_types:t.grant_types??(e.redirectUrl===void 0?void 0:["authorization_code","refresh_token"]),application_type:t.application_type??TR(t.redirect_uris)}}n(ER,"resolveClientMetadata");async function jm(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let o=ds.parse(JSON.parse(r));return Ct.fromResponse(o)}catch(o){let s=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new Ct(le.ServerError,s)}}n(jm,"parseErrorResponse");function Dm(e,t,r){let o=e.invalidateCredentials===void 0?`retrying authorization without discarding the stored ${r} (provider implements no invalidateCredentials())`:`invalidating the stored ${r} and retrying authorization`;console.warn(`[mcp-sdk] OAuth ${JSON.stringify(t.code)} \u2014 ${o}. Cause: ${JSON.stringify(t.message)}`)}n(Dm,"warnCredentialInvalidation");async function ma(e,t){try{return await ua(e,t)}catch(r){if(r instanceof Ct){if(r.code===le.InvalidClient||r.code===le.UnauthorizedClient)return Dm(e,r,"client credentials and tokens"),await e.invalidateCredentials?.("client"),await e.invalidateCredentials?.("tokens"),await ua(e,t);if(r.code===le.InvalidGrant||r.code===le.InvalidDpopProof)return Dm(e,r,"tokens"),await e.invalidateCredentials?.("tokens"),await ua(e,t)}throw r}}n(ma,"auth");function kR(e){let{requestedScope:t,resourceMetadata:r,authServerMetadata:o,clientMetadata:s}=e,i=t||r?.scopes_supported?.join(" ")||s.scope;return i&&o?.scopes_supported?.includes("offline_access")&&!i.split(" ").includes("offline_access")&&s.grant_types?.includes("refresh_token")&&(i=`${i} offline_access`),i}n(kR,"determineScope");async function ua(e,{serverUrl:t,authorizationCode:r,iss:o,scope:s,resourceMetadataUrl:i,fetchFn:a,skipIssuerMetadataValidation:c,forceReauthorization:d}){let l=ER(e),m=await e.discoveryState?.(),h,y,f,R,S=i;if(!S&&m?.resourceMetadataUrl&&(S=new URL(m.resourceMetadataUrl)),m?.authorizationServerUrl){if(y=m.authorizationServerUrl,h=m.resourceMetadata,f=m.authorizationServerMetadata??await Km(y,{fetchFn:a,skipIssuerValidation:c}),!h)try{h=await Gm(t,{resourceMetadataUrl:S},a)}catch(W){if(W instanceof TypeError)throw W}(f!==m.authorizationServerMetadata||h!==m.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(y),resourceMetadataUrl:S?.toString(),resourceMetadata:h,authorizationServerMetadata:f})}else{let W=await qR(t,{resourceMetadataUrl:S,fetchFn:a,skipIssuerMetadataValidation:c});y=W.authorizationServerUrl,f=W.authorizationServerMetadata,h=W.resourceMetadata,R={authorizationServerUrl:String(y),resourceMetadataUrl:S?.toString(),resourceMetadata:h,authorizationServerMetadata:f}}let w=f?.issuer??String(y),x={issuer:w};if(await e.saveAuthorizationServerUrl?.(w),r!==void 0){let W=m?.authorizationServerMetadata?.issuer??m?.authorizationServerUrl;if(W===void 0){if(e.saveDiscoveryState!==void 0)throw new Ms("discoveryState was not available on the callback leg; ensure your provider persists discoveryState alongside codeVerifier",w);console.warn("[mcp-sdk] OAuthClientProvider does not implement saveDiscoveryState()/discoveryState(); the SEP-2352 callback-leg authorization-server binding cannot be checked. Implement discoveryState (persist alongside codeVerifier) \u2014 see docs/migration/upgrade-to-v2.md \xA7SEP-2352.")}else if(!Lm(W,w))throw new Ms(W,w)}R&&await e.saveDiscoveryState?.(R);let I=await AR(t,e,h),O=I&&h&&!e.validateResourceURL?h.resource:I;O&&await e.saveResourceUrl?.(fa(O));let N=kR({requestedScope:s,resourceMetadata:h,authServerMetadata:f,clientMetadata:e.clientMetadata}),we=await Promise.resolve(e.clientInformation(x)),q=la(we,w,{canPersistStamp:e.saveClientInformation!==void 0});if(q===void 0&&we?.issuer&&e.saveClientInformation===void 0)throw new Ms(we.issuer,w);if(q&&q.issuer===void 0&&(q={...q,issuer:w},await e.saveClientInformation?.(q,x)),!q){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let W=f?.client_id_metadata_document_supported===!0,Z=e.clientMetadataUrl;if(Z&&!ha(Z))throw new Ct(le.InvalidClientMetadata,`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${Z}`);if(W&&Z)q={client_id:Z,issuer:w},await e.saveClientInformation?.(q,x);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");q={...await $R(y,{metadata:f,clientMetadata:l,scope:N,fetchFn:a}),issuer:w},await e.saveClientInformation(q,x)}}let ie=!e.redirectUrl;if(r!==void 0||ie){r!==void 0&&Bm({iss:o,expectedIssuer:f?.issuer,issParameterSupported:Hm(f)});let W=await DR(e,y,{metadata:f,resource:O,authorizationCode:r,iss:o,scope:N,fetchFn:a});return await e.saveTokens({...W,issuer:w},x),"AUTHORIZED"}let pe=la(await e.tokens(x),w);if(pe&&pe.issuer===void 0&&(pe={...pe,issuer:w},await e.saveTokens(pe,x)),pe?.refresh_token&&!d){let W;try{W=await jR(y,{metadata:f,clientInformation:q,refreshToken:pe.refresh_token,resource:O,addClientAuthentication:e.addClientAuthentication,dpop:await e.dpop?.(),fetchFn:a})}catch(Z){if(Z instanceof qs)throw Z;if(!(Z instanceof Ct)||Z.code===le.ServerError)console.warn(`[mcp-sdk] Could not refresh OAuth tokens; falling back to a new authorization request. Cause: ${JSON.stringify(Z instanceof Error?Z.message:String(Z))}`);else throw Z}if(W)return await e.saveTokens({...W,issuer:w},x),"AUTHORIZED"}let A=e.state?await e.state():void 0,{authorizationUrl:K,codeVerifier:j}=await zR(y,{metadata:f,clientInformation:q,state:A,redirectUrl:e.redirectUrl,scope:N,resource:O});return await e.saveCodeVerifier(j),await e.redirectToAuthorization(K),"REDIRECT"}n(ua,"authInternal");function ha(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}n(ha,"isHttpsUrl");async function AR(e,t,r){let o=sm(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!As({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}n(AR,"selectResourceURL");var PR=new Set(["bearer","dpop"]);function Fm(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,o]=t.split(" ");if(!r||!PR.has(r.toLowerCase())||!o)return{};let s=Us(e,"resource_metadata")||void 0,i;if(s)try{i=new URL(s)}catch{}let a=Us(e,"scope")||void 0,c=Us(e,"error")||void 0,d=Us(e,"error_description")||void 0;return{resourceMetadataUrl:i,scope:a,error:c,errorDescription:d}}n(Fm,"extractWWWAuthenticateParams");function Us(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let o=new RegExp(String.raw`${t}=(?:"([^"]+)"|([^\s,]+))`),s=r.match(o);if(s){let i=s[1]||s[2];if(i)return i}return null}n(Us,"extractFieldFromWwwAuth");async function Gm(e,t,r=fetch){let o=await UR(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw await o?.text?.().catch(()=>{}),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw await o.text?.().catch(()=>{}),new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return Cr.parse(await o.json())}n(Gm,"discoverOAuthProtectedResourceMetadata");async function Vm(e,t,r=fetch){let o=Os(r);try{return await o(e,{headers:t})}catch(s){if(!(s instanceof TypeError)||!Nm)throw s;if(t)try{return await o(e,{})}catch(i){if(!(i instanceof TypeError))throw i;return}return}}n(Vm,"fetchWithCorsRetry");function xR(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}n(xR,"buildWellKnownPath");async function $m(e,t,r=fetch){return await Vm(e,{"MCP-Protocol-Version":t},r)}n($m,"tryMetadataDiscovery");function OR(e,t){return e?t==="/"?!1:!e.ok&&e.status<500||e.status===502:!0}n(OR,"shouldAttemptFallback");async function UR(e,t,r,o){let s=new URL(e),i=o?.protocolVersion??os,a;if(o?.metadataUrl)a=new URL(o.metadataUrl);else{let d=xR(t,s.pathname);a=new URL(d,o?.metadataServerUrl??s),a.search=s.search}let c=await $m(a,i,r);return!o?.metadataUrl&&OR(c,s.pathname)&&(c=await $m(new URL(`/.well-known/${t}`,s),i,r)),c}n(UR,"discoverMetadataWithFallback");function MR(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"},{url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let s=t.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,t.origin),type:"oauth"},{url:new URL(`/.well-known/openid-configuration${s}`,t.origin),type:"oidc"},{url:new URL(`${s}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}n(MR,"buildDiscoveryUrls");async function Km(e,{fetchFn:t=fetch,protocolVersion:r=os,skipIssuerValidation:o=!1}={}){let s={"MCP-Protocol-Version":r,Accept:"application/json"},i=MR(e);for(let{url:a,type:c}of i){let d=await Vm(a,s,t);if(!d)continue;if(!d.ok){if(await d.text?.().catch(()=>{}),d.status<500||d.status===502)continue;throw new Error(`HTTP ${d.status} trying to load ${c==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}let l=c==="oauth"?Ir.parse(await d.json()):Tr.parse(await d.json());if(!o){let m=typeof e=="string"?e:e.href;if(!(l.issuer===m||m.endsWith("/")&&l.issuer===m.slice(0,-1)))throw new ho("metadata",m,l.issuer)}return l}}n(Km,"discoverAuthorizationServerMetadata");async function qR(e,t){let r,o;try{r=await Gm(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(o=r.authorization_servers[0])}catch(i){if(i instanceof TypeError)throw i}o||(o=String(new URL("/",e)));let s=await Km(o,{fetchFn:t?.fetchFn,skipIssuerValidation:t?.skipIssuerMetadataValidation});return{authorizationServerUrl:o,authorizationServerMetadata:s,resourceMetadata:r}}n(qR,"discoverOAuthServerInfo");function fa(e){return typeof e=="string"?e:e.href}n(fa,"resourceIndicatorToString");async function zR(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:s,state:i,resource:a}){let c;if(t){if(c=new URL(t.authorization_endpoint),!t.response_types_supported.includes(ca))throw new Error(`Incompatible auth server: does not support response type ${ca}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(da))throw new Error(`Incompatible auth server: does not support code challenge method ${da}`)}else c=new URL("/authorize",e);let d=await aa(),l=d.code_verifier,m=d.code_challenge;return c.searchParams.set("response_type",ca),c.searchParams.set("client_id",r.client_id),c.searchParams.set("code_challenge",m),c.searchParams.set("code_challenge_method",da),c.searchParams.set("redirect_uri",String(o)),i&&c.searchParams.set("state",i),s&&c.searchParams.set("scope",s),s?.split(" ").includes("offline_access")&&c.searchParams.append("prompt","consent"),a&&c.searchParams.set("resource",fa(a)),{authorizationUrl:c,codeVerifier:l}}n(zR,"startAuthorization");function NR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}n(NR,"prepareAuthorizationCodeRequest");async function Wm(e,{metadata:t,tokenRequestParams:r,clientInformation:o,addClientAuthentication:s,resource:i,dpop:a,fetchFn:c}){let d=IR(t?.token_endpoint??new URL("/token",e)),l=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});i&&r.set("resource",fa(i)),!s&&o&&RR(wR(o,t?.token_endpoint_auth_methods_supported??[]),o,l,r);let m=n(async()=>{let f=new Headers(l);return s&&await s(f,r,d,t),a&&f.set("DPoP",await a.buildProof({htm:"POST",htu:d})),Os(c??fetch)(d,{method:"POST",headers:f,body:r})},"requestOnce"),h=await m();if(a&&h.status===400&&(await h.clone().json().catch(()=>{}))?.error===le.UseDpopNonce&&(a.observeNonce(h,d),h=await m()),a?.observeNonce(h,d),!h.ok)throw await jm(h);let y=await h.json();try{return Rt.parse(Wi(y))}catch(f){throw typeof y=="object"&&y!==null&&"error"in y?await jm(JSON.stringify(y)):f}}n(Wm,"executeTokenRequest");async function jR(e,{metadata:t,clientInformation:r,refreshToken:o,resource:s,addClientAuthentication:i,dpop:a,fetchFn:c}){return{refresh_token:o,...await Wm(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:"refresh_token",refresh_token:o}),clientInformation:r,addClientAuthentication:i,resource:s,dpop:a,fetchFn:c})}}n(jR,"refreshAuthorization");async function DR(e,t,{metadata:r,resource:o,authorizationCode:s,iss:i,scope:a,fetchFn:c}={}){s!==void 0&&Bm({iss:i,expectedIssuer:r?.issuer,issParameterSupported:Hm(r)});let d=r?.issuer??String(t),l=n(async()=>{let f=await e.clientInformation({issuer:d}),R=la(f,d,{canPersistStamp:!1});if(f&&R===void 0)throw new Ms(String(f.issuer),d);return R},"readClientInformation"),m=await l(),h=a??e.clientMetadata.scope,y;if(e.prepareTokenRequest&&(y=await e.prepareTokenRequest(h)),!y){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");y=NR(s,await e.codeVerifier(),e.redirectUrl)}return m??=await l(),Wm(t,{metadata:r,tokenRequestParams:y,clientInformation:m,addClientAuthentication:e.addClientAuthentication,resource:o,dpop:await e.dpop?.(),fetchFn:c})}n(DR,"fetchToken");async function $R(e,{metadata:t,clientMetadata:r,scope:o,fetchFn:s}){let i;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");i=new URL(t.registration_endpoint)}else i=new URL("/register",e);let a={...r,...o===void 0?{}:{scope:o}},c=await Os(s??fetch)(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!c.ok)throw new pa({status:c.status,body:await c.text(),submittedMetadata:a});return Zt.parse(Wi(await c.json()))}n($R,"registerClient");var Kx=class extends Error{static{n(this,"SseError")}static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return ze(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ze(this,e)}constructor(e,t,r){super(`SSE error: ${t}`),this.code=e,this.event=r,Xt(this,new.target)}};function go(e){let t=Wt.safeParse(e);return t.success?t.data.id:void 0}n(go,"parseJsonRpcRequestId");function ga(e){if(e!==void 0)try{let t=JSON.parse(new TextDecoder().decode(e));return go(t)}catch{return}}n(ga,"readJsonRpcRequestIdFromBody");function ya(e){return Xn.parse({jsonrpc:vr,...e.id===void 0?{}:{id:e.id},error:{code:e.error.code,message:e.error.message,...e.error.data===void 0?{}:{data:e.error.data}}})}n(ya,"jsonRpcErrorResponse");function Zm(e){return new xs([cs.parse({mode:"url",message:e.message,elicitationId:e.elicitationId,url:e.url})],e.message)}n(Zm,"urlElicitationRequiredError");function It(e){return(e??"").split(";")[0].trim().toLowerCase()}n(It,"mediaTypeEssence");var LR=["content-encoding","content-length","content-md5","digest","content-digest","repr-digest"];function dt(e){for(let t of LR)e.delete(t);return e}n(dt,"deleteEncodedBodyHeaders");function Ym(){let e=es.instance;return e.isDeno?"deno":e.isCloudflare?"workerd":"node"}n(Ym,"currentRuntime");var HR=new Set(["gzip","x-gzip","deflate","br","zstd"]);function Tt(e,t=Ym()){let r=e.get("content-encoding")?.trim();if(!r||r.toLowerCase()==="identity")return!1;switch(t){case"deno":return!0;case"workerd":return r!=="gzip"&&r!=="br";default:return!r.toLowerCase().split(",").every(o=>HR.has(o.trim()))}}n(Tt,"isBodyStillEncoded");function Xm(e){return Tt(e)?e:dt(e)}n(Xm,"deleteEncodedBodyHeadersIfDecoded");function Qm(e,t=Ym()){let r=e.get("content-encoding")?.trim().toLowerCase();return(r!==void 0&&r!==""&&r!=="identity"?Tt(e,t):e.has("content-length"))?e:dt(e)}n(Qm,"deleteEncodedBodyHeadersIfRuntimeDecoded");var th=10*1024*1024,BR=1024,JR=32,FR=64,Qt=class extends Error{constructor(r,o=!1){super(`SSE event exceeds the ${r}-character limit`);this.maxEventChars=r;this.comment=o;this.name="SseEventTooLargeError"}maxEventChars;comment;static{n(this,"SseEventTooLargeError")}},GR=10;function VR(e,t){typeof e=="object"&&e!==null&&typeof e.then=="function"&&e.then(void 0,t)}n(VR,"handleRejection");function rh(e){let t=e.indexOf(":");return t===-1?e:e.slice(0,t)}n(rh,"fieldName");var yo=class{static{n(this,"SseParser")}#e;#r;#t;#n=new TextDecoder("utf-8",{ignoreBOM:!0});#d=!1;#g=/\r\n|\r|\n/g;#s="";#u=[];#o=[];#c=0;#l=!1;#p=!1;#y=!1;#i=!1;#m=!1;#S=0;#C=0;#a=[];#h=0;#f=[];#_;#w;#R;#b=[];constructor(t={}){let r=t.maxEventChars??th;if(!Number.isInteger(r)||r<=0)throw new RangeError(`maxEventChars must be a positive integer, got ${r}`);this.#e=r,this.#r=t.onOversize==="discard",this.#t=t.emitLoneComments===!0}get discardedEvents(){return this.#S}get discardedComments(){return this.#C}get discarding(){return this.#i||this.#m}get idle(){return this.#c===0&&!this.#l&&!this.#i&&this.#a.length===0}push(t){let r=[];return this.#T(this.#I(this.#n.decode(t,{stream:!0})),r),r}end(){let t=[];return this.#T(this.#I(this.#n.decode()),t),(this.#c>0||this.#l)&&this.#A(t,!1),this.#i||this.#P(t,!1),this.#i=!1,t}#I(t){return this.#d||t===""?t:(this.#d=!0,t.charCodeAt(0)===65279?t.slice(1):t)}#T(t,r){if(t==="")return;let o=0;this.#y&&(this.#y=!1,t.charCodeAt(0)===GR&&(o=1));let s=this.#g;s.lastIndex=o;let i=s.exec(t);for(;i!==null;)this.#E(t.slice(o,i.index)),this.#A(r),o=i.index+i[0].length,i[0]==="\r"&&o===t.length&&(this.#y=!0),i=s.exec(t);this.#E(t.slice(o))}#E(t){if(t!==""){if(this.#i||this.#m){this.#l=!0;return}if(this.#c===0?this.#s=t:(this.#o.push(t),this.#o.length>=FR&&(this.#u.push(this.#o.join("")),this.#o=[])),this.#c+=t.length,this.#h+this.#c>this.#e){let r=this.#O();r&&this.#r?(this.#v(),this.#m=!0,this.#S++,this.#C++):this.#k(r),this.#l=!0}}}#O(){return this.#t&&this.#a.length===0&&this.#s.charCodeAt(0)===58}#k(t=!1){if(!this.#r)throw new Qt(this.#e,t);this.#x(),this.#p=!1,this.#v(),this.#i=!0,this.#S++}#v(){this.#s="",this.#u.length>0&&(this.#u=[]),this.#o.length>0&&(this.#o=[]),this.#c=0}#A(t,r=!0){let o=this.#u.length===0&&this.#o.length===0?this.#s:this.#s+this.#u.join("")+this.#o.join(""),s=o===""&&!this.#l;if(this.#v(),this.#l=!1,this.#m){this.#m=!1,this.#p=!0;return}if(s){this.#i?this.#i=!1:this.#p&&this.#a.length===0?(this.#p=!1,t.push({lines:[],data:void 0,event:void 0,id:void 0,retry:void 0,comments:[],terminated:!0})):(this.#p=!1,this.#P(t,!0));return}if(this.#i)return;if(this.#t&&r&&this.#a.length===0&&o.charCodeAt(0)===58){t.push({lines:[o],data:void 0,event:void 0,id:void 0,retry:void 0,comments:[o.slice(1)],terminated:!0,lone:!0}),this.#p=!0;return}if(this.#h+=o.length,this.#a.push(o),this.#a.length>BR&&(this.#h+=Math.max(0,JR-o.length),this.#h>this.#e)){this.#k();return}if(o.charCodeAt(0)===58){this.#b.push(o.slice(1));return}let i=o.indexOf(":"),a=i===-1?o:o.slice(0,i),c=i===-1?"":o.slice(i+1);switch(c.charCodeAt(0)===32&&(c=c.slice(1)),a){case"data":this.#f.push(c);break;case"event":this.#_=c;break;case"id":c.includes("\0")||(this.#w=c);break;case"retry":/^[0-9]+$/.test(c)&&(this.#R=Number(c));break;default:break}}#P(t,r){this.#a.length>0&&t.push({lines:this.#a,data:this.#f.length>0?this.#f.join(`
|
|
26
26
|
`):void 0,event:this.#_,id:this.#w,retry:this.#R,comments:this.#b,terminated:r}),this.#x()}#x(){this.#a=[],this.#h=0,this.#f=[],this.#_=void 0,this.#w=void 0,this.#R=void 0,this.#b=[]}};function Sa(e,t){if(/[\r\n]/.test(t))throw new TypeError(`SSE ${e} must not contain a line break`)}n(Sa,"assertSingleLine");function _a(e){if("lines"in e){for(let o of e.lines){if(/[\r\n]/.test(o))throw new TypeError("SSE event line must not contain a line break");if(o==="")throw new TypeError("SSE event line must not be empty")}let r=e.lines.map(o=>`${o}
|
|
27
27
|
`).join("");return e.lines[0]?.charCodeAt(0)===65279&&(r=`
|
|
28
28
|
${r}`),e.terminated?`${r}
|