openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
76 lines • 147 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{At as t,Br as n,Li as r,jt as i,qr as a,zr as o}from"./control-ui-foundation-ZY_Flbbd.js";import{Gl as s,an as c,du as l,hu as u,on as d,ql as f,uu as p}from"./control-ui-core-3P365fbR.js";import{vi as m,yi as h}from"./control-ui-core-CFW9Qtjn.js";import{$ as g,F as _,M as v,N as y,X as ee,Y as te,mt as ne,nt as re,ut as ie}from"./lit-runtime-P5vbNq6b.js";import{L as ae,R as oe,V as se}from"./control-ui-boot-shared-DBJri5ri.js";import{A as b,C as x,E as S,F as ce,I as le,L as ue,M as de,N as fe,O as C,P as pe,R as me,S as w,T as he,_ as ge,a as _e,b as T,c as E,d as ve,f as D,g as ye,h as be,i as xe,j as O,l as Se,m as Ce,n as we,o as Te,p as k,r as Ee,s as De,t as Oe,u as ke,v as Ae,w as A,x as je,y as j}from"./config-runtime-CgOgfOrG.js";import{cn as Me,dn as Ne,fn as Pe,mn as Fe,pn as Ie}from"./control-ui-boot-shared-CG9HtEG-.js";var Le,Re,ze;function Be(){return(Be=e((()=>{Le=Object.defineProperty,Re=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ze=(e,t)=>{let n={};for(var r in e)Le(n,r,{get:e[r],enumerable:!0});return t&&Le(n,Symbol.toStringTag,{value:`Module`}),n}})))()}function Ve(e){return typeof e==`string`&&He.has(e.replace(/#$/,``))}var He;function Ue(){return(Ue=e((()=>{He=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`])})))()}var We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,M,N,$e,et,tt,nt,rt,it,P,at,F,I,L,ot,R,z,st,ct,lt,ut,B,dt,ft,pt,mt,ht,gt,V,_t,vt,yt,bt,xt,St,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,H,U,Ft,It,W,G,Lt,K,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,q,en,tn,nn,rn,an,on,J,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Y,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni;function ri(){return(ri=e((()=>{ye(),_e(),De(),me(),Oe(),We=`2025-11-25`,Ge=[We,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Ke=`io.modelcontextprotocol/related-task`,qe=`io.modelcontextprotocol/protocolVersion`,Je=`io.modelcontextprotocol/clientInfo`,Ye=`io.modelcontextprotocol/serverInfo`,Xe=`io.modelcontextprotocol/clientCapabilities`,Ze=`io.modelcontextprotocol/subscriptionId`,Qe=`io.modelcontextprotocol/logLevel`,M=Ae(()=>b([C(),w(),k(),Se(),S(C(),M),D(M)])),N=S(C(),M),$e=D(M),et=b([C(),w().int()]),tt=C(),nt=x({ttl:w().optional()}),rt=x({taskId:C()}),it=T({progressToken:et.optional(),[Ke]:rt.optional()}),P=x({_meta:it.optional()}),at=P.extend({task:nt.optional()}),F=x({method:C(),params:P.loose().optional()}),I=x({_meta:it.optional()}),L=x({method:C(),params:I.loose().optional()}),ot=T({get[Ye](){return _t.optional().catch(void 0)}}),R=T({_meta:ot.optional()}),z=b([C(),w().int()]),st=x({jsonrpc:j(`2.0`),id:z,...F.shape}).strict(),ct=x({jsonrpc:j(`2.0`),...L.shape}).strict(),lt=x({jsonrpc:j(`2.0`),id:z,result:R}).strict(),ut=x({jsonrpc:j(`2.0`),id:z.optional(),error:x({code:w().int(),message:C(),data:O().optional()})}).strict(),B=b([st,ct,lt,ut]),dt=b([lt,ut]),ft=R.strict(),pt=I.extend({requestId:z.optional(),reason:C().optional()}),mt=L.extend({method:j(`notifications/cancelled`),params:pt}),ht=x({src:C(),mimeType:C().optional(),sizes:D(C()).optional(),theme:E([`light`,`dark`]).optional()}),gt=x({icons:D(ht).optional()}),V=x({name:C(),title:C().optional()}),_t=V.extend({...V.shape,...gt.shape,version:C(),websiteUrl:C().optional(),description:C().optional()}),vt=ge(x({applyDefaults:k().optional()}),N),yt=he(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ge(x({form:vt.optional(),url:N.optional()}),N.optional())),bt=T({list:N.optional(),cancel:N.optional(),requests:T({sampling:T({createMessage:N.optional()}).optional(),elicitation:T({create:N.optional()}).optional()}).optional()}),xt=T({list:N.optional(),cancel:N.optional(),requests:T({tools:T({call:N.optional()}).optional()}).optional()}),St=x({experimental:S(C(),N).optional(),sampling:x({context:N.optional(),tools:N.optional()}).optional(),elicitation:yt.optional(),roots:x({listChanged:k().optional()}).optional(),tasks:bt.optional(),extensions:S(C(),N).optional()}),Ct=P.extend({protocolVersion:C(),capabilities:St,clientInfo:_t}),wt=F.extend({method:j(`initialize`),params:Ct}),Tt=x({experimental:S(C(),N).optional(),logging:N.optional(),completions:N.optional(),prompts:x({listChanged:k().optional()}).optional(),resources:x({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:x({listChanged:k().optional()}).optional(),tasks:xt.optional(),extensions:S(C(),N).optional()}),Et=R.extend({protocolVersion:C(),capabilities:Tt,serverInfo:_t,instructions:C().optional()}),Dt=L.extend({method:j(`notifications/initialized`),params:I.optional()}),Ot=F.extend({method:j(`server/discover`),params:P.optional()}),kt=R.extend({supportedVersions:D(C()),capabilities:Tt,instructions:C().optional()}),At=F.extend({method:j(`ping`),params:P.optional()}),jt=x({progress:w(),total:A(w()),message:A(C())}),Mt=x({...I.shape,...jt.shape,progressToken:et}),Nt=L.extend({method:j(`notifications/progress`),params:Mt}),Pt=P.extend({cursor:tt.optional()}),H=F.extend({params:Pt.optional()}),U=R.extend({nextCursor:tt.optional()}),Ft=x({uri:C(),mimeType:A(C()),_meta:S(C(),O()).optional()}),It=Ft.extend({text:C()}),W=C().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),G=Ft.extend({blob:W}),Lt=E([`user`,`assistant`]),K=x({audience:D(Lt).optional(),priority:w().min(0).max(1).optional(),lastModified:xe({offset:!0}).optional()}),Rt=x({...V.shape,...gt.shape,uri:C(),description:A(C()),mimeType:A(C()),size:A(w()),annotations:K.optional(),_meta:A(T({}))}),zt=x({...V.shape,...gt.shape,uriTemplate:C(),description:A(C()),mimeType:A(C()),annotations:K.optional(),_meta:A(T({}))}),Bt=H.extend({method:j(`resources/list`)}),Vt=U.extend({resources:D(Rt)}),Ht=H.extend({method:j(`resources/templates/list`)}),Ut=U.extend({resourceTemplates:D(zt)}),Wt=P.extend({uri:C()}),Gt=Wt,Kt=F.extend({method:j(`resources/read`),params:Gt}),qt=R.extend({contents:D(b([It,G]))}),Jt=L.extend({method:j(`notifications/resources/list_changed`),params:I.optional()}),Yt=Wt,Xt=F.extend({method:j(`resources/subscribe`),params:Yt}),Zt=Wt,Qt=F.extend({method:j(`resources/unsubscribe`),params:Zt}),$t=x({toolsListChanged:k().optional(),promptsListChanged:k().optional(),resourcesListChanged:k().optional(),resourceSubscriptions:D(C()).optional()}),q=P.extend({notifications:$t}),en=F.extend({method:j(`subscriptions/listen`),params:q}),tn=I.extend({notifications:$t}),nn=L.extend({method:j(`notifications/subscriptions/acknowledged`),params:tn}),rn=ot.extend({[Ze]:z}),an=R.extend({_meta:rn}),on=I.extend({uri:C()}),J=L.extend({method:j(`notifications/resources/updated`),params:on}),sn=x({name:C(),description:A(C()),required:A(k())}),cn=x({...V.shape,...gt.shape,description:A(C()),arguments:A(D(sn)),_meta:A(T({}))}),ln=H.extend({method:j(`prompts/list`)}),un=U.extend({prompts:D(cn)}),dn=P.extend({name:C(),arguments:S(C(),C()).optional()}),fn=F.extend({method:j(`prompts/get`),params:dn}),pn=x({type:j(`text`),text:C(),annotations:K.optional(),_meta:S(C(),O()).optional()}),mn=x({type:j(`image`),data:W,mimeType:C(),annotations:K.optional(),_meta:S(C(),O()).optional()}),hn=x({type:j(`audio`),data:W,mimeType:C(),annotations:K.optional(),_meta:S(C(),O()).optional()}),gn=x({type:j(`tool_use`),name:C(),id:C(),input:S(C(),O()),_meta:S(C(),O()).optional()}),_n=x({type:j(`resource`),resource:b([It,G]),annotations:K.optional(),_meta:S(C(),O()).optional()}),vn=Rt.extend({type:j(`resource_link`)}),yn=b([pn,mn,hn,vn,_n]),bn=x({role:Lt,content:yn}),xn=R.extend({description:C().optional(),messages:D(bn)}),Sn=L.extend({method:j(`notifications/prompts/list_changed`),params:I.optional()}),Cn=x({title:C().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),wn=x({taskSupport:E([`required`,`optional`,`forbidden`]).optional()}),Tn=x({...V.shape,...gt.shape,description:C().optional(),inputSchema:x({type:j(`object`),properties:S(C(),M).optional(),required:D(C()).optional()}).catchall(O()),outputSchema:T({$schema:C().optional()}).optional(),annotations:Cn.optional(),execution:wn.optional(),_meta:S(C(),O()).optional()}),En=H.extend({method:j(`tools/list`)}),Dn=U.extend({tools:D(Tn)}),On=R.extend({content:D(yn).default([]),structuredContent:O().optional(),isError:k().optional()}),kn=On.or(R.extend({toolResult:O()})),An=at.extend({name:C(),arguments:S(C(),O()).optional()}),jn=F.extend({method:j(`tools/call`),params:An}),Mn=L.extend({method:j(`notifications/tools/list_changed`),params:I.optional()}),Nn=x({autoRefresh:k().default(!0),debounceMs:w().int().nonnegative().default(300)}),Pn=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Fn=P.extend({level:Pn}),In=F.extend({method:j(`logging/setLevel`),params:Fn}),Ln=I.extend({level:Pn,logger:C().optional(),data:O()}),Rn=L.extend({method:j(`notifications/message`),params:Ln}),zn=x({name:C().optional()}),Bn=x({hints:D(zn).optional(),costPriority:w().min(0).max(1).optional(),speedPriority:w().min(0).max(1).optional(),intelligencePriority:w().min(0).max(1).optional()}),Vn=x({mode:E([`auto`,`required`,`none`]).optional()}),Hn=x({type:j(`tool_result`),toolUseId:C().describe(`The unique identifier for the corresponding tool call.`),content:D(yn),structuredContent:O().optional(),isError:k().optional(),_meta:S(C(),O()).optional()}),Un=Ce(`type`,[pn,mn,hn]),Wn=Ce(`type`,[pn,mn,hn,gn,Hn]),Gn=x({role:Lt,content:b([Wn,D(Wn)]),_meta:S(C(),O()).optional()}),Kn=at.extend({messages:D(Gn),modelPreferences:Bn.optional(),systemPrompt:C().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:w().optional(),maxTokens:w().int(),stopSequences:D(C()).optional(),metadata:N.optional(),tools:D(Tn).optional(),toolChoice:Vn.optional()}),qn=F.extend({method:j(`sampling/createMessage`),params:Kn}),Jn=R.extend({model:C(),stopReason:A(E([`endTurn`,`stopSequence`,`maxTokens`]).or(C())),role:Lt,content:Un}),Yn=R.extend({model:C(),stopReason:A(E([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(C())),role:Lt,content:b([Wn,D(Wn)])}),Xn=x({type:j(`boolean`),title:C().optional(),description:C().optional(),default:k().optional()}),Zn=x({type:j(`string`),title:C().optional(),description:C().optional(),minLength:w().optional(),maxLength:w().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:C().optional()}),Qn=x({type:E([`number`,`integer`]),title:C().optional(),description:C().optional(),minimum:w().optional(),maximum:w().optional(),default:w().optional()}),$n=x({type:j(`string`),title:C().optional(),description:C().optional(),enum:D(C()),default:C().optional()}),er=x({type:j(`string`),title:C().optional(),description:C().optional(),oneOf:D(x({const:C(),title:C()})),default:C().optional()}),tr=x({type:j(`string`),title:C().optional(),description:C().optional(),enum:D(C()),enumNames:D(C()).optional(),default:C().optional()}),nr=b([$n,er]),rr=x({type:j(`array`),title:C().optional(),description:C().optional(),minItems:w().optional(),maxItems:w().optional(),items:x({type:j(`string`),enum:D(C())}),default:D(C()).optional()}),ir=x({type:j(`array`),title:C().optional(),description:C().optional(),minItems:w().optional(),maxItems:w().optional(),items:x({anyOf:D(x({const:C(),title:C()}))}),default:D(C()).optional()}),ar=b([rr,ir]),or=b([tr,nr,ar]),sr=b([or,Xn,Zn,Qn]),cr=at.extend({mode:j(`form`).optional(),message:C(),requestedSchema:x({type:j(`object`),properties:S(C(),sr),required:D(C()).optional()}).catchall(O())}),lr=at.extend({mode:j(`url`),message:C(),elicitationId:C(),url:C().url()}),ur=b([cr,lr]),dr=F.extend({method:j(`elicitation/create`),params:ur}),fr=I.extend({elicitationId:C()}),pr=L.extend({method:j(`notifications/elicitation/complete`),params:fr}),mr=R.extend({action:E([`accept`,`decline`,`cancel`]),content:he(e=>e===null?void 0:e,S(C(),b([C(),w(),k(),D(C())])).optional())}),hr=x({type:j(`ref/resource`),uri:C()}),gr=x({type:j(`ref/prompt`),name:C()}),_r=P.extend({ref:b([gr,hr]),argument:x({name:C(),value:C()}),context:x({arguments:S(C(),C()).optional()}).optional()}),vr=F.extend({method:j(`completion/complete`),params:_r}),yr=R.extend({completion:T({values:D(C()).max(100),total:A(w().int()),hasMore:A(k())})}),br=x({uri:C().startsWith(`file://`),name:C().optional(),_meta:S(C(),O()).optional()}),xr=F.extend({method:j(`roots/list`),params:P.optional()}),Sr=R.extend({roots:D(br)}),Cr=L.extend({method:j(`notifications/roots/list_changed`),params:I.optional()}),wr=T({ttl:w().optional(),pollInterval:w().optional()}),Tr=E([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Er=x({taskId:C(),status:Tr,ttl:b([w(),Se()]),createdAt:C(),lastUpdatedAt:C(),pollInterval:A(w()),statusMessage:A(C())}),Dr=R.extend({task:Er}),Or=I.merge(Er),kr=L.extend({method:j(`notifications/tasks/status`),params:Or}),Ar=F.extend({method:j(`tasks/get`),params:P.extend({taskId:C()})}),jr=R.merge(Er),Mr=F.extend({method:j(`tasks/result`),params:P.extend({taskId:C()})}),Nr=R.loose(),Pr=H.extend({method:j(`tasks/list`)}),Fr=U.extend({tasks:D(Er)}),Ir=F.extend({method:j(`tasks/cancel`),params:P.extend({taskId:C()})}),Lr=R.merge(Er),Rr=b([At,wt,Ot,vr,In,fn,ln,Bt,Ht,Kt,Xt,Qt,en,jn,En]),zr=b([mt,Nt,Dt,Cr]),Br=b([ft,Jn,Yn,mr,Sr]),Vr=b([At,qn,dr,xr]),Hr=b([mt,Nt,Rn,J,Jt,Mn,Sn,nn,pr]),Ur=b([ft,Et,kt,yr,xn,un,Vt,Ut,qt,On,Dn,an]),Y=de().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Te.custom,message:`URL must be parseable`,fatal:!0}),ue}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Wr=T({resource:C().url(),authorization_servers:D(Y).optional(),jwks_uri:C().url().optional(),scopes_supported:D(C()).optional(),bearer_methods_supported:D(C()).optional(),resource_signing_alg_values_supported:D(C()).optional(),resource_name:C().optional(),resource_documentation:C().optional(),resource_policy_uri:C().url().optional(),resource_tos_uri:C().url().optional(),tls_client_certificate_bound_access_tokens:k().optional(),authorization_details_types_supported:D(C()).optional(),dpop_signing_alg_values_supported:D(C()).optional(),dpop_bound_access_tokens_required:k().optional()}),Gr=T({issuer:C(),authorization_endpoint:Y,token_endpoint:Y,registration_endpoint:Y.optional(),scopes_supported:D(C()).optional(),response_types_supported:D(C()),response_modes_supported:D(C()).optional(),grant_types_supported:D(C()).optional(),token_endpoint_auth_methods_supported:D(C()).optional(),token_endpoint_auth_signing_alg_values_supported:D(C()).optional(),service_documentation:Y.optional(),revocation_endpoint:Y.optional(),revocation_endpoint_auth_methods_supported:D(C()).optional(),revocation_endpoint_auth_signing_alg_values_supported:D(C()).optional(),introspection_endpoint:C().optional(),introspection_endpoint_auth_methods_supported:D(C()).optional(),introspection_endpoint_auth_signing_alg_values_supported:D(C()).optional(),code_challenge_methods_supported:D(C()).optional(),client_id_metadata_document_supported:k().optional(),authorization_response_iss_parameter_supported:k().optional().catch(void 0),dpop_signing_alg_values_supported:D(C()).optional()}),Kr=T({issuer:C(),authorization_endpoint:Y,token_endpoint:Y,userinfo_endpoint:Y.optional(),jwks_uri:Y,registration_endpoint:Y.optional(),scopes_supported:D(C()).optional(),response_types_supported:D(C()),response_modes_supported:D(C()).optional(),grant_types_supported:D(C()).optional(),acr_values_supported:D(C()).optional(),subject_types_supported:D(C()),id_token_signing_alg_values_supported:D(C()),id_token_encryption_alg_values_supported:D(C()).optional(),id_token_encryption_enc_values_supported:D(C()).optional(),userinfo_signing_alg_values_supported:D(C()).optional(),userinfo_encryption_alg_values_supported:D(C()).optional(),userinfo_encryption_enc_values_supported:D(C()).optional(),request_object_signing_alg_values_supported:D(C()).optional(),request_object_encryption_alg_values_supported:D(C()).optional(),request_object_encryption_enc_values_supported:D(C()).optional(),token_endpoint_auth_methods_supported:D(C()).optional(),token_endpoint_auth_signing_alg_values_supported:D(C()).optional(),display_values_supported:D(C()).optional(),claim_types_supported:D(C()).optional(),claims_supported:D(C()).optional(),service_documentation:C().optional(),claims_locales_supported:D(C()).optional(),ui_locales_supported:D(C()).optional(),claims_parameter_supported:k().optional(),request_parameter_supported:k().optional(),request_uri_parameter_supported:k().optional(),require_request_uri_registration:k().optional(),op_policy_uri:Y.optional(),op_tos_uri:Y.optional(),client_id_metadata_document_supported:k().optional(),authorization_response_iss_parameter_supported:k().optional().catch(void 0)}),qr=x({...Kr.shape,...Gr.pick({code_challenge_methods_supported:!0}).shape}),Jr=x({access_token:C(),id_token:C().optional(),token_type:C(),expires_in:we().optional(),scope:C().optional(),refresh_token:C().optional(),issuer:C().optional().catch(void 0)}).strip(),Yr=x({issued_token_type:j(`urn:ietf:params:oauth:token-type:id-jag`),access_token:C(),token_type:C().optional(),expires_in:w().optional(),scope:C().optional()}).strip(),Xr=x({error:C(),error_description:C().optional(),error_uri:C().optional()}),Zr=Y.optional().or(j(``).transform(()=>void 0)),Qr=x({redirect_uris:D(Y),token_endpoint_auth_method:C().optional(),grant_types:D(C()).optional(),response_types:D(C()).optional(),application_type:C().optional(),client_name:C().optional(),client_uri:Y.optional(),logo_uri:Zr,scope:C().optional(),contacts:D(C()).optional(),tos_uri:Zr,policy_uri:C().optional(),jwks_uri:Y.optional(),jwks:ve().optional(),software_id:C().optional(),software_version:C().optional(),software_statement:C().optional()}).strip(),$r=x({client_id:C(),client_secret:C().optional(),client_id_issued_at:w().optional(),client_secret_expires_at:w().optional(),issuer:C().optional().catch(void 0)}).strip(),ei=Qr.merge($r),ti=x({error:C(),error_description:C().optional()}).strip(),ni=x({token:C(),token_type_hint:C().optional()}).strip()})))()}function ii(){return(ii=e((()=>{ri()})))()}function ai(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Ma,{value:n,enumerable:!1,configurable:!0})}function oi(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Ma)){let n=t[Ma];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}function si(e){return e>=Na}function ci(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}function li(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||Pa.some(t=>t in e)?e:{...e,content:[]}}function ui(){let e=Ae(()=>b([C(),w(),k(),Se(),S(C(),e),D(e)])),t=S(C(),e),n=b([C(),w().int()]),r=C(),i=x({ttl:w().optional()}),a=x({taskId:C()}),o=T({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=x({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=x({method:C(),params:s.loose().optional()}),u=x({_meta:o.optional()}),d=x({method:C(),params:u.loose().optional()}),f=T({_meta:o.optional()}),p=b([C(),w().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:C().optional()}),g=d.extend({method:j(`notifications/cancelled`),params:h}),_=x({src:C(),mimeType:C().optional(),sizes:D(C()).optional(),theme:E([`light`,`dark`]).optional()}),v=x({icons:D(_).optional()}),y=x({name:C(),title:C().optional()}),ee=y.extend({...y.shape,...v.shape,version:C(),websiteUrl:C().optional(),description:C().optional()}),te=ge(x({applyDefaults:k().optional()}),t),ne=he(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ge(x({form:te.optional(),url:t.optional()}),t.optional())),re=T({list:t.optional(),cancel:t.optional(),requests:T({sampling:T({createMessage:t.optional()}).optional(),elicitation:T({create:t.optional()}).optional()}).optional()}),ie=T({list:t.optional(),cancel:t.optional(),requests:T({tools:T({call:t.optional()}).optional()}).optional()}),ae=x({experimental:S(C(),t).optional(),sampling:x({context:t.optional(),tools:t.optional()}).optional(),elicitation:ne.optional(),roots:x({listChanged:k().optional()}).optional(),tasks:re.optional(),extensions:S(C(),t).optional()}),oe=s.extend({protocolVersion:C(),capabilities:ae,clientInfo:ee}),se=l.extend({method:j(`initialize`),params:oe}),ce=x({experimental:S(C(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:x({listChanged:k().optional()}).optional(),resources:x({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:x({listChanged:k().optional()}).optional(),tasks:ie.optional(),extensions:S(C(),t).optional()}),le=f.extend({protocolVersion:C(),capabilities:ce,serverInfo:ee,instructions:C().optional()}),ue=d.extend({method:j(`notifications/initialized`),params:u.optional()}),de=l.extend({method:j(`ping`),params:s.optional()}),fe=x({progress:w(),total:A(w()),message:A(C())}),pe=x({...u.shape,...fe.shape,progressToken:n}),me=d.extend({method:j(`notifications/progress`),params:pe}),_e=s.extend({cursor:r.optional()}),ve=l.extend({params:_e.optional()}),ye=f.extend({nextCursor:r.optional()}),be=x({uri:C(),mimeType:A(C()),_meta:S(C(),O()).optional()}),we=be.extend({text:C()}),Te=C().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Ee=be.extend({blob:Te}),De=E([`user`,`assistant`]),Oe=x({audience:D(De).optional(),priority:w().min(0).max(1).optional(),lastModified:xe({offset:!0}).optional()}),ke=x({...y.shape,...v.shape,uri:C(),description:A(C()),mimeType:A(C()),size:A(w()),annotations:Oe.optional(),_meta:A(T({}))}),je=x({...y.shape,...v.shape,uriTemplate:C(),description:A(C()),mimeType:A(C()),annotations:Oe.optional(),_meta:A(T({}))}),Me=ve.extend({method:j(`resources/list`)}),Ne=ye.extend({resources:D(ke)}),Pe=ve.extend({method:j(`resources/templates/list`)}),Fe=ye.extend({resourceTemplates:D(je)}),Ie=s.extend({uri:C()}),Le=Ie,Re=l.extend({method:j(`resources/read`),params:Le}),ze=f.extend({contents:D(b([we,Ee]))}),Be=d.extend({method:j(`notifications/resources/list_changed`),params:u.optional()}),Ve=Ie,He=l.extend({method:j(`resources/subscribe`),params:Ve}),Ue=Ie,We=l.extend({method:j(`resources/unsubscribe`),params:Ue}),Ge=u.extend({uri:C()}),Ke=d.extend({method:j(`notifications/resources/updated`),params:Ge}),qe=x({name:C(),description:A(C()),required:A(k())}),Je=x({...y.shape,...v.shape,description:A(C()),arguments:A(D(qe)),_meta:A(T({}))}),Ye=ve.extend({method:j(`prompts/list`)}),Xe=ye.extend({prompts:D(Je)}),Ze=s.extend({name:C(),arguments:S(C(),C()).optional()}),Qe=l.extend({method:j(`prompts/get`),params:Ze}),M=x({type:j(`text`),text:C(),annotations:Oe.optional(),_meta:S(C(),O()).optional()}),N=x({type:j(`image`),data:Te,mimeType:C(),annotations:Oe.optional(),_meta:S(C(),O()).optional()}),$e=x({type:j(`audio`),data:Te,mimeType:C(),annotations:Oe.optional(),_meta:S(C(),O()).optional()}),et=x({type:j(`tool_use`),name:C(),id:C(),input:S(C(),O()),_meta:S(C(),O()).optional()}),tt=x({type:j(`resource`),resource:b([we,Ee]),annotations:Oe.optional(),_meta:S(C(),O()).optional()}),nt=ke.extend({type:j(`resource_link`)}),rt=b([M,N,$e,nt,tt]),it=x({role:De,content:rt}),P=f.extend({description:C().optional(),messages:D(it)}),at=d.extend({method:j(`notifications/prompts/list_changed`),params:u.optional()}),F=x({title:C().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),I=x({taskSupport:E([`required`,`optional`,`forbidden`]).optional()}),L=x({...y.shape,...v.shape,description:C().optional(),inputSchema:x({type:j(`object`),properties:S(C(),e).optional(),required:D(C()).optional()}).catchall(O()),outputSchema:x({type:j(`object`),properties:S(C(),e).optional(),required:D(C()).optional()}).catchall(O()).optional(),annotations:F.optional(),execution:I.optional(),_meta:S(C(),O()).optional()}),ot=ve.extend({method:j(`tools/list`)}),R=ye.extend({tools:D(L)}),z=f.extend({content:D(rt),structuredContent:S(C(),O()).optional(),isError:k().optional()}),st=c.extend({name:C(),arguments:S(C(),O()).optional()}),ct=l.extend({method:j(`tools/call`),params:st}),lt=d.extend({method:j(`notifications/tools/list_changed`),params:u.optional()}),ut=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),B=s.extend({level:ut}),dt=l.extend({method:j(`logging/setLevel`),params:B}),ft=u.extend({level:ut,logger:C().optional(),data:O()}),pt=d.extend({method:j(`notifications/message`),params:ft}),mt=x({name:C().optional()}),ht=x({hints:D(mt).optional(),costPriority:w().min(0).max(1).optional(),speedPriority:w().min(0).max(1).optional(),intelligencePriority:w().min(0).max(1).optional()}),gt=x({mode:E([`auto`,`required`,`none`]).optional()}),V=x({type:j(`tool_result`),toolUseId:C().describe(`The unique identifier for the corresponding tool call.`),content:D(rt),structuredContent:x({}).loose().optional(),isError:k().optional(),_meta:S(C(),O()).optional()}),_t=Ce(`type`,[M,N,$e]),vt=Ce(`type`,[M,N,$e,et,V]),yt=x({role:De,content:b([vt,D(vt)]),_meta:S(C(),O()).optional()}),bt=c.extend({messages:D(yt),modelPreferences:ht.optional(),systemPrompt:C().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:w().optional(),maxTokens:w().int(),stopSequences:D(C()).optional(),metadata:t.optional(),tools:D(L).optional(),toolChoice:gt.optional()}),xt=l.extend({method:j(`sampling/createMessage`),params:bt}),St=f.extend({model:C(),stopReason:A(E([`endTurn`,`stopSequence`,`maxTokens`]).or(C())),role:De,content:_t}),Ct=f.extend({model:C(),stopReason:A(E([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(C())),role:De,content:b([vt,D(vt)])}),wt=x({type:j(`boolean`),title:C().optional(),description:C().optional(),default:k().optional()}),Tt=x({type:j(`string`),title:C().optional(),description:C().optional(),minLength:w().optional(),maxLength:w().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:C().optional()}),Et=x({type:E([`number`,`integer`]),title:C().optional(),description:C().optional(),minimum:w().optional(),maximum:w().optional(),default:w().optional()}),Dt=x({type:j(`string`),title:C().optional(),description:C().optional(),enum:D(C()),default:C().optional()}),Ot=x({type:j(`string`),title:C().optional(),description:C().optional(),oneOf:D(x({const:C(),title:C()})),default:C().optional()}),kt=x({type:j(`string`),title:C().optional(),description:C().optional(),enum:D(C()),enumNames:D(C()).optional(),default:C().optional()}),At=b([Dt,Ot]),jt=x({type:j(`array`),title:C().optional(),description:C().optional(),minItems:w().optional(),maxItems:w().optional(),items:x({type:j(`string`),enum:D(C())}),default:D(C()).optional()}),Mt=x({type:j(`array`),title:C().optional(),description:C().optional(),minItems:w().optional(),maxItems:w().optional(),items:x({anyOf:D(x({const:C(),title:C()}))}),default:D(C()).optional()}),Nt=b([jt,Mt]),Pt=b([kt,At,Nt]),H=b([Pt,wt,Tt,Et]),U=c.extend({mode:j(`form`).optional(),message:C(),requestedSchema:x({type:j(`object`),properties:S(C(),H),required:D(C()).optional()}).catchall(O())}),Ft=c.extend({mode:j(`url`),message:C(),elicitationId:C(),url:C().url()}),It=b([U,Ft]),W=l.extend({method:j(`elicitation/create`),params:It}),G=u.extend({elicitationId:C()}),Lt=d.extend({method:j(`notifications/elicitation/complete`),params:G}),K=f.extend({action:E([`accept`,`decline`,`cancel`]),content:he(e=>e===null?void 0:e,S(C(),b([C(),w(),k(),D(C())])).optional())}),Rt=x({type:j(`ref/resource`),uri:C()}),zt=x({type:j(`ref/prompt`),name:C()}),Bt=s.extend({ref:b([zt,Rt]),argument:x({name:C(),value:C()}),context:x({arguments:S(C(),C()).optional()}).optional()}),Vt=l.extend({method:j(`completion/complete`),params:Bt}),Ht=f.extend({completion:T({values:D(C()).max(100),total:A(w().int()),hasMore:A(k())})}),Ut=x({uri:C().startsWith(`file://`),name:C().optional(),_meta:S(C(),O()).optional()}),Wt=l.extend({method:j(`roots/list`),params:s.optional()}),Gt=f.extend({roots:D(Ut)}),Kt=d.extend({method:j(`notifications/roots/list_changed`),params:u.optional()}),qt=T({ttl:w().optional(),pollInterval:w().optional()}),Jt=E([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Yt=x({taskId:C(),status:Jt,ttl:b([w(),Se()]),createdAt:C(),lastUpdatedAt:C(),pollInterval:A(w()),statusMessage:A(C())}),Xt=f.extend({task:Yt}),Zt=u.merge(Yt),Qt=d.extend({method:j(`notifications/tasks/status`),params:Zt}),$t=l.extend({method:j(`tasks/get`),params:s.extend({taskId:C()})}),q=f.merge(Yt),en=l.extend({method:j(`tasks/result`),params:s.extend({taskId:C()})}),tn=f.loose(),nn=ve.extend({method:j(`tasks/list`)}),rn=ye.extend({tasks:D(Yt)}),an=l.extend({method:j(`tasks/cancel`),params:s.extend({taskId:C()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:m,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:ee,ClientTasksCapabilitySchema:re,ServerTasksCapabilitySchema:ie,ClientCapabilitiesSchema:ae,InitializeRequestParamsSchema:oe,InitializeRequestSchema:se,ServerCapabilitiesSchema:ce,InitializeResultSchema:le,InitializedNotificationSchema:ue,PingRequestSchema:de,ProgressSchema:fe,ProgressNotificationParamsSchema:pe,ProgressNotificationSchema:me,PaginatedRequestParamsSchema:_e,PaginatedRequestSchema:ve,PaginatedResultSchema:ye,ResourceContentsSchema:be,TextResourceContentsSchema:we,BlobResourceContentsSchema:Ee,RoleSchema:De,AnnotationsSchema:Oe,ResourceSchema:ke,ResourceTemplateSchema:je,ListResourcesRequestSchema:Me,ListResourcesResultSchema:Ne,ListResourceTemplatesRequestSchema:Pe,ListResourceTemplatesResultSchema:Fe,ResourceRequestParamsSchema:Ie,ReadResourceRequestParamsSchema:Le,ReadResourceRequestSchema:Re,ReadResourceResultSchema:ze,ResourceListChangedNotificationSchema:Be,SubscribeRequestParamsSchema:Ve,SubscribeRequestSchema:He,UnsubscribeRequestParamsSchema:Ue,UnsubscribeRequestSchema:We,ResourceUpdatedNotificationParamsSchema:Ge,ResourceUpdatedNotificationSchema:Ke,PromptArgumentSchema:qe,PromptSchema:Je,ListPromptsRequestSchema:Ye,ListPromptsResultSchema:Xe,GetPromptRequestParamsSchema:Ze,GetPromptRequestSchema:Qe,TextContentSchema:M,ImageContentSchema:N,AudioContentSchema:$e,ToolUseContentSchema:et,EmbeddedResourceSchema:tt,ResourceLinkSchema:nt,ContentBlockSchema:rt,PromptMessageSchema:it,GetPromptResultSchema:P,PromptListChangedNotificationSchema:at,ToolAnnotationsSchema:F,ToolExecutionSchema:I,ToolSchema:L,ListToolsRequestSchema:ot,ListToolsResultSchema:R,CallToolResultSchema:z,CallToolRequestParamsSchema:st,CallToolRequestSchema:ct,ToolListChangedNotificationSchema:lt,LoggingLevelSchema:ut,SetLevelRequestParamsSchema:B,SetLevelRequestSchema:dt,LoggingMessageNotificationParamsSchema:ft,LoggingMessageNotificationSchema:pt,ModelHintSchema:mt,ModelPreferencesSchema:ht,ToolChoiceSchema:gt,ToolResultContentSchema:V,SamplingContentSchema:_t,SamplingMessageContentBlockSchema:vt,SamplingMessageSchema:yt,CreateMessageRequestParamsSchema:bt,CreateMessageRequestSchema:xt,CreateMessageResultSchema:St,CreateMessageResultWithToolsSchema:Ct,BooleanSchemaSchema:wt,StringSchemaSchema:Tt,NumberSchemaSchema:Et,UntitledSingleSelectEnumSchemaSchema:Dt,TitledSingleSelectEnumSchemaSchema:Ot,LegacyTitledEnumSchemaSchema:kt,SingleSelectEnumSchemaSchema:At,UntitledMultiSelectEnumSchemaSchema:jt,TitledMultiSelectEnumSchemaSchema:Mt,MultiSelectEnumSchemaSchema:Nt,EnumSchemaSchema:Pt,PrimitiveSchemaDefinitionSchema:H,ElicitRequestFormParamsSchema:U,ElicitRequestURLParamsSchema:Ft,ElicitRequestParamsSchema:It,ElicitRequestSchema:W,ElicitationCompleteNotificationParamsSchema:G,ElicitationCompleteNotificationSchema:Lt,ElicitResultSchema:K,ResourceTemplateReferenceSchema:Rt,PromptReferenceSchema:zt,CompleteRequestParamsSchema:Bt,CompleteRequestSchema:Vt,CompleteResultSchema:Ht,RootSchema:Ut,ListRootsRequestSchema:Wt,ListRootsResultSchema:Gt,RootsListChangedNotificationSchema:Kt,TaskCreationParamsSchema:qt,TaskStatusSchema:Jt,TaskSchema:Yt,CreateTaskResultSchema:Xt,TaskStatusNotificationParamsSchema:Zt,TaskStatusNotificationSchema:Qt,GetTaskRequestSchema:$t,GetTaskResultSchema:q,GetTaskPayloadRequestSchema:en,GetTaskPayloadResultSchema:tn,ListTasksRequestSchema:nn,ListTasksResultSchema:rn,CancelTaskRequestSchema:an,CancelTaskResultSchema:f.merge(Yt),ClientRequestSchema:b([de,se,Vt,dt,Qe,Ye,Me,Pe,Re,He,We,ct,ot,$t,en,nn,an]),ClientNotificationSchema:b([g,me,ue,Kt,Qt]),ClientResultSchema:b([m,St,Ct,K,Gt,q,rn,Xt]),ServerRequestSchema:b([de,xt,W,Wt,$t,en,nn,an]),ServerNotificationSchema:b([g,me,pt,Ke,Be,lt,at,Qt,Lt]),ServerResultSchema:b([m,le,Ht,P,Xe,Ne,Fe,ze,z,R,q,rn,Xt]),CallToolResultWireSchema:O().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of Pa)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(li).pipe(z)}}function di(){return Fa??=ui()}function fi(e){return e.type!==`object`}function pi(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function mi(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(pi(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=Ve(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&pi(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=Ia.has(o)?s:La.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}function hi(){if(Va)return Va;let e=di();return Va={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}},Va}function gi(e){return Object.prototype.hasOwnProperty.call(Ra,e)}function _i(e){return Object.prototype.hasOwnProperty.call(za,e)}function vi(e){return Object.prototype.hasOwnProperty.call(Ba,e)}function yi(e){return vi(e)?hi().resultSchemas[e]:void 0}function bi(e){return gi(e)?hi().requestSchemas[e]:void 0}function xi(e){return _i(e)?hi().notificationSchemas[e]:void 0}function Si(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ci(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}function wi(e){return Si(e)&&Si(e.outputSchema)&&fi(e.outputSchema)}function Ti(e){return e}function Ei(){let e=Ae(()=>b([C(),w(),k(),Se(),S(C(),e),D(e)])),t=S(C(),e),n=b([C(),w().int()]),r=C(),i=b([C(),w().int()]),a=E([`user`,`assistant`]),o=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=C().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=x({ttl:w().optional()}),l=x({taskId:C()}),u=T({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=x({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=x({_meta:u.optional()}),m=x({method:C(),params:p.loose().optional()}),h=x({src:C(),mimeType:C().optional(),sizes:D(C()).optional(),theme:E([`light`,`dark`]).optional()}),g=x({icons:D(h).optional()}),_=x({name:C(),title:C().optional()}),v=_.extend({..._.shape,...g.shape,version:C(),websiteUrl:C().optional(),description:C().optional()}),y=ge(x({applyDefaults:k().optional()}),t),ee=he(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ge(x({form:y.optional(),url:t.optional()}),t.optional())),te=T({list:t.optional(),cancel:t.optional(),requests:T({sampling:T({createMessage:t.optional()}).optional(),elicitation:T({create:t.optional()}).optional()}).optional()}),ne=T({list:t.optional(),cancel:t.optional(),requests:T({tools:T({call:t.optional()}).optional()}).optional()}),re=x({experimental:S(C(),t).optional(),sampling:x({context:t.optional(),tools:t.optional()}).optional(),elicitation:ee.optional(),roots:x({listChanged:k().optional()}).optional(),tasks:te.optional(),extensions:S(C(),t).optional()}),ie=x({experimental:S(C(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:x({listChanged:k().optional()}).optional(),resources:x({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:x({listChanged:k().optional()}).optional(),tasks:ne.optional(),extensions:S(C(),t).optional()}),ae=x({progress:w(),total:A(w()),message:A(C())}),oe=x({...p.shape,...ae.shape,progressToken:n}),se=m.extend({method:j(`notifications/progress`),params:oe}),ce=p.extend({level:o,logger:C().optional(),data:O()}),le=m.extend({method:j(`notifications/message`),params:ce}),ue=x({uri:C(),mimeType:A(C()),_meta:S(C(),O()).optional()}),de=ue.extend({text:C()}),fe=ue.extend({blob:s}),pe=x({audience:D(a).optional(),priority:w().min(0).max(1).optional(),lastModified:xe({offset:!0}).optional()}),me=x({..._.shape,...g.shape,uri:C(),description:A(C()),mimeType:A(C()),size:A(w()),annotations:pe.optional(),_meta:A(T({}))}),_e=x({..._.shape,...g.shape,uriTemplate:C(),description:A(C()),mimeType:A(C()),annotations:pe.optional(),_meta:A(T({}))}),ve=m.extend({method:j(`notifications/resources/list_changed`),params:p.optional()}),ye=p.extend({uri:C()}),be=m.extend({method:j(`notifications/resources/updated`),params:ye}),Ce=x({name:C(),description:A(C()),required:A(k())}),we=x({..._.shape,...g.shape,description:A(C()),arguments:A(D(Ce)),_meta:A(T({}))}),Te=m.extend({method:j(`notifications/prompts/list_changed`),params:p.optional()}),Ee=x({type:j(`text`),text:C(),annotations:pe.optional(),_meta:S(C(),O()).optional()}),De=x({type:j(`image`),data:s,mimeType:C(),annotations:pe.optional(),_meta:S(C(),O()).optional()}),Oe=x({type:j(`audio`),data:s,mimeType:C(),annotations:pe.optional(),_meta:S(C(),O()).optional()}),ke=x({type:j(`tool_use`),name:C(),id:C(),input:S(C(),O()),_meta:S(C(),O()).optional()}),je=x({type:j(`resource`),resource:b([de,fe]),annotations:pe.optional(),_meta:S(C(),O()).optional()}),Me=me.extend({type:j(`resource_link`)}),Ne=b([Ee,De,Oe,Me,je]),Pe=x({role:a,content:Ne}),Fe=x({title:C().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),Ie=m.extend({method:j(`notifications/tools/list_changed`),params:p.optional()}),Le=x({name:C().optional()}),Re=x({hints:D(Le).optional(),costPriority:w().min(0).max(1).optional(),speedPriority:w().min(0).max(1).optional(),intelligencePriority:w().min(0).max(1).optional()}),ze=x({mode:E([`auto`,`required`,`none`]).optional()}),Be=x({type:j(`boolean`),title:C().optional(),description:C().optional(),default:k().optional()}),Ve=x({type:j(`string`),title:C().optional(),description:C().optional(),minLength:w().optional(),maxLength:w().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:C().optional()}),He=x({type:E([`number`,`integer`]),title:C().optional(),description:C().optional(),minimum:w().optional(),maximum:w().optional(),default:w().optional()}),Ue=x({type:j(`string`),title:C().optional(),description:C().optional(),enum:D(C()),default:C().optional()}),We=x({type:j(`string`),title:C().optional(),description:C().optional(),oneOf:D(x({const:C(),title:C()})),default:C().optional()}),Ge=x({type:j(`string`),title:C().optional(),description:C().optional(),enum:D(C()),enumNames:D(C()).optional(),default:C().optional()}),Ke=b([Ue,We]),Ze=x({type:j(`array`),title:C().optional(),description:C().optional(),minItems:w().optional(),maxItems:w().optional(),items:x({type:j(`string`),enum:D(C())}),default:D(C()).optional()}),M=x({type:j(`array`),title:C().optional(),description:C().optional(),minItems:w().optional(),maxItems:w().optional(),items:x({anyOf:D(x({const:C(),title:C()}))}),default:D(C()).optional()}),N=b([Ze,M]),$e=b([Ge,Ke,N]),et=b([$e,Be,Ve,He]),tt=f.extend({mode:j(`form`).optional(),message:C(),requestedSchema:x({type:j(`object`),properties:S(C(),et),required:D(C()).optional()}).catchall(O())}),nt=x({type:j(`ref/resource`),uri:C()}),rt=x({type:j(`ref/prompt`),name:C()}),it=x({uri:C().startsWith(`file://`),name:C().optional(),_meta:S(C(),O()).optional()}),P=re.shape,at=x({experimental:P.experimental,sampling:P.sampling,elicitation:P.elicitation,roots:P.roots,extensions:P.extensions}),F=ie.shape,I=x({experimental:F.experimental,logging:F.logging,completions:F.completions,prompts:F.prompts,resources:F.resources,tools:F.tools,extensions:F.extensions}),L=T({progressToken:n.optional(),[qe]:C(),[Je]:v.optional(),[Xe]:at,[Qe]:o.optional()}),ot=x({..._.shape,...g.shape,description:C().optional(),inputSchema:T({$schema:C().optional(),type:j(`object`)}),outputSchema:T({$schema:C().optional()}).optional(),annotations:Fe.optional(),_meta:S(C(),O()).optional()}),R=x({type:j(`tool_result`),toolUseId:C(),content:D(Ne),structuredContent:O().optional(),isError:k().optional(),_meta:S(C(),O()).optional()}),z=b([Ee,De,Oe,ke,R]),st=x({role:a,content:b([z,D(z)]),_meta:S(C(),O()).optional()}),ct=C(),lt=T({[Ye]:v.optional().catch(void 0)}),ut=lt.optional();function B(e){return T({_meta:ut,resultType:ct.default(`complete`),...e})}let dt=B({}),ft=B({nextCursor:r.optional()}),pt=B({content:D(Ne),structuredContent:O().optional(),isError:k().optional()}),mt=B({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),tools:D(ot),nextCursor:r.optional()}),ht=B({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),prompts:D(we),nextCursor:r.optional()}),gt=B({description:C().optional(),messages:D(Pe)}),V=B({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),resources:D(me),nextCursor:r.optional()}),_t=B({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),resourceTemplates:D(_e),nextCursor:r.optional()}),vt=B({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),contents:D(b([de,fe]))}),yt=B({completion:x({values:D(C()).max(100),total:w().int().optional(),hasMore:k().optional()}).loose()}),bt=B({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`])}),xt=B({ttlMs:w().int().min(0).catch(0),cacheScope:E([`public`,`private`]).catch(`private`),supportedVersions:D(C()),capabilities:I,instructions:C().optional()}),St=x({messages:D(st),modelPreferences:Re.optional(),systemPrompt:C().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:w().optional(),maxTokens:w().int(),stopSequences:D(C()).optional(),metadata:t.optional(),tools:D(ot).optional(),toolChoice:ze.optional()}),Ct=x({method:j(`sampling/createMessage`),params:St}),wt=x({method:j(`roots/list`),params:x({_meta:S(C(),O()).optional()}).optional()}),Tt=x({...st.shape,model:C(),stopReason:C().optional()}),Et=x({roots:D(it)}),Dt=x({action:E([`accept`,`decline`,`cancel`]),content:S(C(),b([C(),w(),k(),D(C())])).optional()}),Ot=x({mode:j(`url`),message:C(),url:C().url()}),kt=b([tt,Ot]),At=x({method:j(`elicitation/create`),params:kt}),jt=b([Ct,wt,At]),Mt=b([Tt,Et,Dt]),Nt=S(C(),jt),Pt=S(C(),Mt),H=B({inputRequests:Nt.optional(),requestState:C().optional()}),U={inputResponses:Pt.optional(),requestState:C().optional()},Ft=x({_meta:L,...U}),It=T({progressToken:n.optional()});function W(e,t){return x({method:j(e),params:x({_meta:L,...t})})}function G(e,t){return x({method:j(e),params:x({_meta:It.optional(),...t}).optional()})}let Lt={name:C(),arguments:S(C(),O()).optional(),...U},K={cursor:r.optional()},Rt=W(`tools/call`,Lt),zt=W(`tools/list`,K),Bt=W(`prompts/list`,K),Vt=W(`prompts/get`,{name:C(),arguments:S(C(),C()).optional(),...U}),Ht=W(`resources/list`,K),Ut=W(`resources/templates/list`,K),Wt=W(`resources/read`,{uri:C(),...U}),Gt={ref:b([rt,nt]),argument:x({name:C(),value:C()}),context:x({arguments:S(C(),C()).optional()}).optional()},Kt=W(`completion/complete`,Gt),qt=W(`server/discover`,{}),Jt=x({toolsListChanged:k().optional(),promptsListChanged:k().optional(),resourcesListChanged:k().optional(),resourceSubscriptions:D(C()).optional()}),Yt={notifications:Jt},Xt=W(`subscriptions/listen`,Yt),Zt=lt.extend({"io.modelcontextprotocol/subscriptionId":i}),Qt=T({_meta:Zt,resultType:ct.default(`complete`)}),$t={"tools/call":G(`tools/call`,Lt),"tools/list":G(`tools/list`,K),"prompts/get":G(`prompts/get`,{name:C(),arguments:S(C(),C()).optional()}),"prompts/list":G(`prompts/list`,K),"resources/list":G(`resources/list`,K),"resources/templates/list":G(`resources/templates/list`,K),"resources/read":G(`resources/read`,{uri:C()}),"completion/complete":G(`completion/complete`,Gt),"server/discover":G(`server/discover`,{}),"subscriptions/listen":G(`subscriptions/listen`,Yt)};function q(e){return T({_meta:ut,...e})}let en={"tools/call":q({content:D(Ne),structuredContent:O().optional(),isError:k().optional()}),"tools/list":q({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),tools:D(ot),nextCursor:r.optional()}),"prompts/get":q({description:C().optional(),messages:D(Pe)}),"prompts/list":q({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),prompts:D(we),nextCursor:r.optional()}),"resources/list":q({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),resources:D(me),nextCursor:r.optional()}),"resources/templates/list":q({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),resourceTemplates:D(_e),nextCursor:r.optional()}),"resources/read":q({ttlMs:w().int().min(0),cacheScope:E([`public`,`private`]),contents:D(b([de,fe]))}),"completion/complete":q({completion:x({values:D(C()).max(100),total:w().int().optional(),hasMore:k().optional()}).loose()}),"server/discover":q({ttlMs:w().int().min(0).catch(0),cacheScope:E([`public`,`private`]).catch(`private`),supportedVersions:D(C()),capabilities:I,instructions:C().optional()}),"subscriptions/listen":q({})},tn=T({"io.modelcontextprotocol/subscriptionId":i.optional()}),nn=x({method:j(`notifications/subscriptions/acknowledged`),params:x({_meta:tn.optional(),notifications:Jt})}),rn=x({_meta:tn.optional(),requestId:i,reason:C().optional()}),an=x({method:j(`notifications/cancelled`),params:rn}),on={"notifications/cancelled":an,"notifications/progress":se,"notifications/message":le,"notifications/resources/updated":be,"notifications/resources/list_changed":ve,"notifications/tools/list_changed":Ie,"notifications/prompts/list_changed":Te,"notifications/subscriptions/acknowledged":nn},J=e=>x({jsonrpc:j(`2.0`),id:b([C(),w().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:p,NotificationSchema:m,IconSchema:h,IconsSchema:g,BaseMetadataSchema:_,ImplementationSchema:v,ClientTasksCapabilitySchema:te,ServerTasksCapabilitySchema:ne,ClientCapabilitiesSchema:re,ServerCapabilitiesSchema:ie,ProgressSchema:ae,ProgressNotificationParamsSchema:oe,ProgressNotificationSchema:se,LoggingMessageNotificationParamsSchema:ce,LoggingMessageNotificationSchema:le,ResourceContentsSchema:ue,TextResourceContentsSchema:de,BlobResourceContentsSchema:fe,AnnotationsSchema:pe,ResourceSchema:me,ResourceTemplateSchema:_e,ResourceListChangedNotificationSchema:ve,ResourceUpdatedNotificationParamsSchema:ye,ResourceUpdatedNotificationSchema:be,PromptArgumentSchema:Ce,PromptSchema:we,PromptListChangedNotificationSchema:Te,TextContentSchema:Ee,ImageContentSchema:De,AudioContentSchema:Oe,ToolUseContentSchema:ke,EmbeddedResourceSchema:je,ResourceLinkSchema:Me,ContentBlockSchema:Ne,PromptMessageSchema:Pe,ToolAnnotationsSchema:Fe,ToolListChangedNotificationSchema:Ie,ModelHintSchema:Le,ModelPreferencesSchema:Re,ToolChoiceSchema:ze,BooleanSchemaSchema:Be,StringSchemaSchema:Ve,NumberSchemaSchema:He,UntitledSingleSelectEnumSchemaSchema:Ue,TitledSingleSelectEnumSchemaSchema:We,LegacyTitledEnumSchemaSchema:Ge,SingleSelectEnumSchemaSchema:Ke,UntitledMultiSelectEnumSchemaSchema:Ze,TitledMultiSelectEnumSchemaSchema:M,MultiSelectEnumSchemaSchema:N,EnumSchemaSchema:$e,PrimitiveSchemaDefinitionSchema:et,ElicitRequestFormParamsSchema:tt,ResourceTemplateReferenceSchema:nt,PromptReferenceSchema:rt,RootSchema:it,ClientCapabilities2026Schema:at,ServerCapabilities2026Schema:I,RequestMetaEnvelopeSchema:L,ToolSchema:ot,ToolResultContentSchema:R,SamplingMessageContentBlockSchema:z,SamplingMessageSchema:st,ResultTypeSchema:ct,ResultMetaSchema:lt,ResultSchema:dt,PaginatedResultSchema:ft,CallToolResultSchema:pt,ListToolsResultSchema:mt,ListPromptsResultSchema:ht,GetPromptResultSchema:gt,ListResourcesResultSchema:V,ListResourceTemplatesResultSchema:_t,ReadResourceResultSchema:vt,CompleteResultSchema:yt,CacheableResultSchema:bt,DiscoverResultSchema:xt,CreateMessageRequestParamsSchema:St,CreateMessageRequestSchema:Ct,ListRootsRequestSchema:wt,CreateMessageResultSchema:Tt,ListRootsResultSchema:Et,ElicitResultSchema:Dt,ElicitRequestURLParamsSchema:Ot,ElicitRequestParamsSchema:kt,ElicitRequestSchema:At,InputRequestSchema:jt,InputResponseSchema:Mt,InputRequestsSchema:Nt,InputResponsesSchema:Pt,InputRequiredResultSchema:H,InputResponseRequestParamsSchema:Ft,CallToolRequestSchema:Rt,ListToolsRequestSchema:zt,ListPromptsRequestSchema:Bt,GetPromptRequestSchema:Vt,ListResourcesRequestSchema:Ht,ListResourceTemplatesRequestSchema:Ut,ReadResourceRequestSchema:Wt,CompleteRequestSchema:Kt,DiscoverRequestSchema:qt,SubscriptionFilterSchema:Jt,SubscriptionsListenRequestSchema:Xt,SubscriptionsListenResultMetaSchema:Zt,SubscriptionsListenResultSchema:Qt,dispatchRequestSchemas:$t,dispatchResultSchemas:en,NotificationMetaSchema:tn,SubscriptionsAcknowledgedNotificationSchema:nn,CancelledNotificationParamsSchema:rn,CancelledNotificationSchema:an,notificationSchemas2026:on,JSONRPCResultResponseSchema:J(dt),CallToolResultResponseSchema:J(b([pt,H])),ListToolsResultResponseSchema:J(mt),ListPromptsResultResponseSchema:J(ht),GetPromptResultResponseSchema:J(b([gt,H])),ListResourcesResultResponseSchema:J(V),ListResourceTemplatesResultResponseSchema:J(_t),ReadResourceResultResponseSchema:J(b([vt,H])),CompleteResultResponseSchema:J(yt),DiscoverResultResponseSchema:J(xt)}}function Di(){return Wa??=Ei()}function Oi(e){return Ga.includes(e)}function ki(e){return e[Ka]}function Ai(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ji(e){return e===`public`||e===`private`}function Mi(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||$a.includes(e))return t;throw new $(Q.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Ni(e,t){let n=ki(t);if(t.resultType!==`complete`||!Oi(e))return n===void 0?t:Ri(t);let r=t,i=Ai(r.ttlMs)?r.ttlMs:Ii(n),a=ji(r.cacheScope)?r.cacheScope:Li(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Ka],o}function Pi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fi(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[Ye]:t}}:!Pi(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[Ye]:t}}}function Ii(e){return e!==void 0&&Ai(e.ttlMs)?e.ttlMs:Za}function Li(e){return e!==void 0&&ji(e.cacheScope)?e.cacheScope:Qa}function Ri(e){let t={...e};return delete t[Ka],t}function zi(){if(to)return to;let e=Di();return to={request:{"elicitation/create":x({method:j(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":x({method:j(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":x({method:j(`roots/list`),params:T({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},to}function Bi(e){return eo.includes(e)}function Vi(e){return Bi(e)?zi().request[e]:void 0}function Hi(e){return Bi(e)?zi().response[e]:void 0}function Ui(e){return Object.prototype.hasOwnProperty.call(no,e)}function Wi(e){return Object.prototype.hasOwnProperty.call(ro,e)}function Gi(e){return Object.prototype.hasOwnProperty.call(no,e)}function Ki(e){return Ui(e)?Di().dispatchRequestSchemas[e]:void 0}function qi(e){return Gi(e)?Di().dispatchResultSchemas[e]:void 0}function Ji(e){return Wi(e)?Di().notificationSchemas2026[e]:void 0}function Yi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xi(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}function Zi(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>Yi(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!Yi(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(Yi(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}function Qi(){if(so)return so;let e=Di();return so={"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},so}function $i(e){return e!==void 0&&si(e)?oo:Ua}function ea(e){return e.revision===void 0?e.era===`modern`?oo.era:Ua.era:$i(e.revision).era}function ta(e){return lo.some(t=>t.hasRequestMethod(e))}function na(e){return lo.some(t=>t.hasNotificationMethod(e))}function ra(e,t){return pe(e,t)}function ia(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function aa(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}function oa(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:_o});else if(n.vendor===`zod`){if(!(`_zod`in e))throw 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().`);go||(go=!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.")),r=le(e,{target:_o,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&sa(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function sa(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||sa(e)))}return!1}function ca(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function la(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>ca(e)).join(`, `)}:{success:!0,data:n.value}}function ua(e){let t=le(e,{target:_o,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}function da(e){let t=vo.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>xe({local:e,offset:t,precision:n}))))}function fa(e,t){let n;switch(e){case`email`:n=[be()];break;case`uri`:n=[de()];break;case`date`:n=[Ee()];break;case`date-time`:n=da(t)}return new Set(n.map(e=>ua(e)).filter(e=>e!==void 0))}function pa(e,t,n){return n!==`zod`||fa(e,t).has(t)}function ma(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ha(e){try{return oa(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new $(Q.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}function ga(e){return yo.has(e)||e.startsWith(`x-`)}function _a(e,t,n,r){if(!ma(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(xo,e.type)?xo[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||ga(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?So.has(e.format)?(typeof s!=`string`||!pa(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function va(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&ma(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,_a(n,`properties.${e}`,t,r)])):bo.has(i)?n[i]=a:ga(i)||r.push(i);if(r.length>0)throw new $(Q.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function ya(e,t){if(!ma(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!ra(sr,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function ba(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>ba(e,t[r],`${n}[${r}]`)):!ma(e)||!ma(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?ba(r,t[e],i):ga(e)?[]:[i]})}function xa(e){if(!aa(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=va(ha(e.requestedSchema),t),r=ra(cr.shape.requestedSchema,n);if(!r.success)throw new $(Q.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${ya(n,r.error.message)}`);let i=ba(n,r.data);if(i.length>0)throw new $(Q.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new $(Q.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function Sa(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw 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}}}function Ca(e,t){let n=e.slice(0,-6);To[n]=t,Eo[n]=e=>t.safeParse(e).success}function wa(e){switch(e){case`initialize`:case`notifications/initialized`:return $i(void 0);case`server/discover`:return $i(co);default:return}}function Ta(e,t){let n=e.params;if(!Oa(n))return{message:e,lifted:{}};let r=n._meta,i=Oa(r)?Do.filter(e=>e in r):[],a=t===`request`?Oo.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&Oa(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function Ea(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function Da(e){return()=>e}function Oa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ka(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Aa(e){let t={},n=[];if(!ka(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!ka(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function ja(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var Ma,X,Z,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,Q,$,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao;function jo(){return(jo=e((()=>{Be(),Ue(),ii(),ye(),_e(),fe(),ce(),Ma=Symbol.for(`mcp.sdk.errorBrands`),class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return oi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oi(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,ai(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},X=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}({}),Z=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return oi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oi(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,ai(this,new.target)}},class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}},Na=`2026-07-28`,Pa=[`task`,`inputRequests`,`requestState`],Ia=new Set([`const`,`enum`,`default`,`examples`]),La=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]),Ra={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},za={"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},Ba={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},Object.keys(Ra),Object.keys(za),Ha={ok:!1,reason:`not-in-era`},Ua={era:`2025-11-25`,hasRequestMethod:gi,hasNotificationMethod:_i,validateRequest:(e,t)=>Ci(bi(e),t),validateResult:(e,t)=>Ci(yi(e),t),validateNotification:(e,t)=>Ci(xi(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Ha,validateInputResponse:()=>Ha,samplingResultVariant:((e,t)=>{let n=di();return Ci(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=ci(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&fi(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(Si(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Ti(e)}}return{kind:`complete`,result:Ti(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>wi(e))?t:{...t,tools:n.map(e=>wi(e)?{...e,outputSchema:mi(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0},Ga=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`],Ka=Symbol(`modelcontextprotocol.resultCacheHintFallback`),Q=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}({}),$=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return oi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oi(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,ai(this,new.target)}static fromError(t,n,r){if(t===Q.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Ja(e.elicitations,n)}if(t===Q.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Ya({supported:e.supported,requested:e.requested},n)}if(t===Q.InvalidParams||t===Q.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===Q.ResourceNotFound||Object.keys(e).length===1))return new qa(e.uri,n)}if(t===Q.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Xa({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},qa=class extends ${static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(Q.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Ja=class extends ${static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Q.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Ya=class extends ${static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Q.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Xa=class extends ${static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(Q.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Za=0,Qa=`private`,$a=[`tools/call`,`prompts/get`,`resources/read`],eo=[`elicitation/create`,`sampling/createMessage`,`roots/list`],no={"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},ro={"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},Object.keys(no),Object.keys(ro),io={ok:!1,reason:`not-in-era`},ao=[qe,Xe],oo={era:`2026-07-28`,hasRequestMethod:Ui,hasNotificationMethod:Wi,hasInputRequestMethod:e=>Vi(e)!==void 0,validateRequest:(e,t)=>Xi(Ki(e),t),validateResult:(e,t)=>Xi(qi(e),t),validateNotification:(e,t)=>Xi(Ji(e),t),validateInputRequest:(e,t)=>Xi(Vi(e),t),validateInputResponse:(e,t)=>Xi(Hi(e),t),samplingResultVariant:()=>io,outboundEnvelope(e){return{[qe]:e.protocolVersion,[Je]:e.clientInfo,[Xe]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of ao)n in e||t.push({key:n,problem:`missing`});let n=Di().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>ci(e),inputRequestSchema:Vi,decodeResult(e,t){if(!Yi(t))return{kind:`invalid`,error:new Z(X.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new Z(X.InvalidResult,`Invalid result for ${e}: missing required resultType — 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 n!=`string`)return{kind:`invalid`,error:new Z(X.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=Yi(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:Di().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new Z(X.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:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new Z(X.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=Qi(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new Z(X.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return Fi(Ni(e,Mi(e,Zi(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,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=Di().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}},co=`2026-07-28`,lo=[Ua,oo],uo=ze({AnnotationsSchema:()=>K,AudioContentSchema:()=>hn,BaseMetadataSchema:()=>V,BaseRequestParamsSchema:()=>P,BlobResourceContentsSchema:()=>G,BooleanSchemaSchema:()=>Xn,CallToolRequestParamsSchema:()=>An,CallToolRequestSchema:()=>jn,CallToolResultSchema:()=>On,CancelTaskRequestSchema:()=>Ir,CancelTaskResultSchema:()=>Lr,CancelledNotificationParamsSchema:()=>pt,CancelledNotificationSchema:()=>mt,ClientCapabilitiesSchema:()=>St,ClientNotificationSchema:()=>zr,ClientRequestSchema:()=>Rr,ClientResultSchema:()=>Br,ClientTasksCapabilitySchema:()=>bt,CompatibilityCallToolResultSchema:()=>kn,CompleteRequestParamsSchema:()=>_r,CompleteRequestSchema:()=>vr,CompleteResultSchema:()=>yr,ContentBlockSchema:()=>yn,CreateMessageRequestParamsSchema:()=>Kn,CreateMessageRequestSchema:()=>qn,CreateMessageResultSchema:()=>Jn,CreateMessageResultWithToolsSchema:()=>Yn,CreateTaskResultSchema:()=>Dr,CursorSchema:()=>tt,DiscoverRequestSchema:()=>Ot,DiscoverResultSchema:()=>kt,ElicitRequestFormParamsSchema:()=>cr,ElicitRequestParamsSchema:()=>ur,ElicitRequestSchema:()=>dr,ElicitRequestURLParamsSchema:()=>lr,ElicitResultSchema:()=>mr,ElicitationCompleteNotificationParamsSchema:()=>fr,ElicitationCompleteNotificationSchema:()=>pr,EmbeddedResourceSchema:()=>_n,EmptyResultSchema:()=>ft,EnumSchemaSchema:()=>or,GetPromptRequestParamsSchema:()=>dn,GetPromptRequestSchema:()=>fn,GetPromptResultSchema:()=>xn,GetTaskPayloadRequestSchema:()=>Mr,GetTaskPayloadResultSchema:()=>Nr,GetTaskRequestSchema:()=>Ar,GetTaskResultSchema:()=>jr,IconSchema:()=>ht,IconsSchema:()=>gt,ImageContentSchema:()=>mn,ImplementationSchema:()=>_t,InitializeRequestParamsSchema:()=>Ct,InitializeRequestSchema:()=>wt,InitializeResultSchema:()=>Et,InitializedNotificationSchema:()=>Dt,JSONArraySchema:()=>$e,JSONObjectSchema:()=>N,JSONRPCErrorResponseSchema:()=>ut,JSONRPCMessageSchema:()=>B,JSONRPCNotificationSchema:()=>ct,JSONRPCRequestSchema:()=>st,JSONRPCResponseSchema:()=>dt,JSONRPCResultResponseSchema:()=>lt,JSONValueSchema:()=>M,LegacyTitledEnumSchemaSchema:()=>tr,ListChangedOptionsBaseSchema:()=>Nn,ListPromptsRequestSchema:()=>ln,ListPromptsResultSchema:()=>un,ListResourceTemplatesRequestSchema:()=>Ht,ListResourceTemplatesResultSchema:()=>Ut,ListResourcesRequestSchema:()=>Bt,ListResourcesResultSchema:()=>Vt,ListRootsRequestSchema:()=>xr,ListRootsResultSchema:()=>Sr,ListTasksRequestSchema:()=>Pr,ListTasksResultSchema:()=>Fr,ListToolsRequestSchema:()=>En,ListToolsResultSchema:()=>Dn,LoggingLevelSchema:()=>Pn,LoggingMessageNotificationParamsSchema:()=>Ln,LoggingMessageNotificationSchema:()=>Rn,ModelHintSchema:()=>zn,ModelPreferencesSchema:()=>Bn,MultiSelectEnumSchemaSchema:()=>ar,NotificationSchema:()=>L,NotificationsParamsSchema:()=>I,NumberSchemaSchema:()=>Qn,PaginatedRequestParamsSchema:()=>Pt,PaginatedRequestSchema:()=>H,PaginatedResultSchema:()=>U,PingRequestSchema:()=>At,PrimitiveSchemaDefinitionSchema:()=>sr,ProgressNotificationParamsSchema:()=>Mt,ProgressNotificationSchema:()=>Nt,ProgressSchema:()=>jt,ProgressTokenSchema:()=>et,PromptArgumentSchema:()=>sn,PromptListChangedNotificationSchema:()=>Sn,PromptMessageSchema:()=>bn,PromptReferenceSchema:()=>gr,PromptSchema:()=>cn,ReadResourceRequestParamsSchema:()=>Gt,ReadResourceRequestSchema:()=>Kt,ReadResourceResultSchema:()=>qt,RelatedTaskMetadataSchema:()=>rt,RequestIdSchema:()=>z,RequestMetaSchema:()=>it,RequestSchema:()=>F,ResourceContentsSchema:()=>Ft,ResourceLinkSchema:()=>vn,ResourceListChangedNotificationSchema:()=>Jt,ResourceRequestParamsSchema:()=>Wt,ResourceSchema:()=>Rt,ResourceTemplateReferenceSchema:()=>hr,ResourceTemplateSchema:()=>zt,ResourceUpdatedNotificationParamsSchema:()=>on,ResourceUpdatedNotificationSchema:()=>J,ResultMetaObjectSchema:()=>ot,ResultSchema:()=>R,RoleSchema:()=>Lt,RootSchema:()=>br,RootsListChangedNotificationSchema:()=>Cr,SamplingContentSchema:()=>Un,SamplingMessageContentBlockSchema:()=>Wn,SamplingMessageSchema:()=>Gn,ServerCapabilitiesSchema:()=>Tt,ServerNotificationSchema:()=>Hr,ServerRequestSchema:()=>Vr,ServerResultSchema:()=>Ur,ServerTasksCapabilitySchema:()=>xt,SetLevelRequestParamsSchema:()=>Fn,SetLevelRequestSchema:()=>In,SingleSelectEnumSchemaSchema:()=>nr,StringSchemaSchema:()=>Zn,SubscribeRequestParamsSchema:()=>Yt,SubscribeRequestSchema:()=>Xt,SubscriptionFilterSchema:()=>$t,SubscriptionsAcknowledgedNotificationParamsSchema:()=>tn,SubscriptionsAcknowledgedNotificationSchema:()=>nn,SubscriptionsListenRequestParamsSchema:()=>q,SubscriptionsListenRequestSchema:()=>en,SubscriptionsListenResultMetaSchema:()=>rn,SubscriptionsListenResultSchema:()=>an,TaskAugmentedRequestParamsSchema:()=>at,TaskCreationParamsSchema:()=>wr,TaskMetadataSchema:()=>nt,TaskSchema:()=>Er,TaskStatusNotificationParamsSchema:()=>Or,TaskStatusNotificationSchema:()=>kr,TaskStatusSchema:()=>Tr,TextContentSchema:()=>pn,TextResourceContentsSchema:()=>It,TitledMultiSelectEnumSchemaSchema:()=>ir,TitledSingleSelectEnumSchemaSchema:()=>er,ToolAnnotationsSchema:()=>Cn,ToolChoiceSchema:()=>Vn,ToolExecutionSchema:()=>wn,ToolListChangedNotificationSchema:()=>Mn,ToolResultContentSchema:()=>Hn,ToolSchema:()=>Tn,ToolUseContentSchema:()=>gn,UnsubscribeRequestParamsSchema:()=>Zt,UnsubscribeRequestSchema:()=>Qt,UntitledMultiSelectEnumSchemaSchema:()=>rr,UntitledSingleSelectEnumSchemaSchema:()=>$n}),fo=e=>st.safeParse(e).success,po=e=>ct.safeParse(e).success,mo=e=>lt.safeParse(e).success,ho=e=>ut.safeParse(e).success,Q.InvalidRequest,Q.UnsupportedProtocolVersion,Q.InvalidParams,Q.MethodNotFound,Q.InvalidParams,Q.MissingRequiredClientCapability,Q.ParseError,Q.InvalidRequest,Q.MethodNotFound,Q.UnsupportedProtocolVersion,Q.MissingRequiredClientCapability,go=!1,_o=`draft-2020-12`,vo=/\\\.\\d\{(\d+)\}/,yo=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]),bo=new Set([`$schema`,...Object.keys(cr.shape.requestedSchema.shape)]),xo={string:ia([Zn,$n,er,tr]),number:ia([Qn]),integer:ia([Qn]),boolean:ia([Xn]),array:ia([rr,ir])},So=new Set(Zn.shape.format.unwrap().options),Object.assign(Sa,{elicit(e){try{return{method:`elicitation/create`,params:xa(e)}}catch(e){throw e instanceof $?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}}),Co=`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`.split(`.`),wo={IdJagTokenExchangeResponseSchema:Yr,OAuthClientInformationFullSchema:ei,OAuthClientInformationSchema:$r,OAuthClientMetadataSchema:Qr,OAuthClientRegistrationErrorSchema:ti,OAuthErrorResponseSchema:Xr,OAuthMetadataSchema:Gr,OAuthProtectedResourceMetadataSchema:Wr,OAuthTokenRevocationRequestSchema:ni,OAuthTokensSchema:Jr,OpenIdProviderDiscoveryMetadataSchema:qr,OpenIdProviderMetadataSchema:Kr},To={},Eo={};for(let e of Co)Ca(e,uo[e]);for(let[e,t]of Object.entries(wo))Ca(e,t);Object.freeze(To),Object.freeze(Eo),Do=[qe,Je,Xe,Qe],Oo=[`inputResponses`,`requestState`],ko=Da(void 0),Ao=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Ge,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new Z(X.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,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Z(X.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});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 n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),mo(e)||ho(e)?this._onresponse(e):fo(e)?this._onrequest(e,t):po(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},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 e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new Z(X.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=Ta(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=ea(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(na(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=Ta(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=ea(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(Q.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(ta(n.method)&&!i.hasRequestMethod(n.method)){o(Q.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Q.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(Q.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:Aa(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?ko:Da(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),aa(t))return u(e,t,n);let i=Ea(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(Q.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:Q.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),mo(e)?n(e):n($.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),aa(t))return this._requestWithSchemaViaCodec(r,e,t,n);let i=Ea(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return $i(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=wa(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(ta(t)&&!e.hasRequestMethod(t))throw new Z(X.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof Z?e:new Z(X.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof Z?e:new Z(X.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(ja(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;la(n,o).then(e=>{e.success?d(e.data):f(new Z(X.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let ee=r?.timeout??6e4;this._setupTimeout(h,ee,r?.maxTotalTimeout,()=>y(new Z(X.RequestTimeout,`Request timed out`,{timeout:ee})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new Z(X.NotConnected,`Not connected`);if(na(t.method)&&!e.hasNotificationMethod(t.method))throw new Z(X.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 r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.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(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!ta(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new $(Q.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await la(t.params,{...r.params});if(!a.success)throw new $(Q.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!na(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new $(Q.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await la(t.params,{...r.params});if(!i.success)throw new $(Q.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}},Re((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))()})))()}function Mo(e){return e.test.bind(e)}function No(e,t){let n=t.match(Po);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo;function Go(){return(Go=e((()=>{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`),Po=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Fo=/^(?=.{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,Io=/^(?:[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,Lo=/^(?:(?:[^\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,Ro=/^(?:(?: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,zo=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Bo=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Vo=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Ho=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Uo=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Wo=/^((([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,No.bind(void 0,!1),Mo(Io),Mo(Lo),Mo(Ro),Mo(Fo),Mo(Uo),Mo(Wo),Mo(zo),Mo(Bo),Mo(Vo),Mo(Ho)})))()}function Ko(){return(Ko=e((()=>{Go()})))()}function qo(){return(qo=e((()=>{globalThis.crypto})))()}var Jo;function Yo(){return(Yo=e((()=>{jo(),Ko(),qo(),Jo=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthClientFlowError`})}static[Symbol.hasInstance](e){return oi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oi(this,e)}constructor(e){super(e),this.name=new.target.name,ai(this,new.target)}},class extends Jo{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.IssuerMismatchError`})}kind;expected;received;constructor(e,t,n){super(`Issuer mismatch in ${e===`metadata`?`authorization server metadata (RFC 8414 §3.3)`:`authorization response (RFC 9207)`}: expected ${JSON.stringify(t)}, received ${JSON.stringify(n)}`),this.kind=e,this.expected=t,this.received=n}},class extends Jo{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}},class extends Jo{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}},class extends Jo{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}},class extends Jo{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}},class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnauthorizedError`})}static[Symbol.hasInstance](e){return oi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oi(this,e)}constructor(e){super(e??`Unauthorized`),this.name=`UnauthorizedError`,ai(this,new.target)}},class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SseError`})}static[Symbol.hasInstance](e){return oi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oi(this,e)}constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n,ai(this,new.target)}}})))()}function Xo(){return(Xo=e((()=>{ri()})))()}function Zo(e,t){let[n,r]=t,i=n?.shape;if(typeof i?.method?.value!=`string`)return;let a=i.method.value,o=e===`request`?`setRequestHandler`:`setNotificationHandler`;ns.has(o)||(ns.add(o),console.warn(`[ext-apps] ${o}(Schema, handler) is deprecated; use ${o}("${a}", { params: Schema.shape.params }, handler).`));let s=r;return[a,{params:i.params},e===`request`?(e,t)=>s({method:a,params:e},Qo(t)):e=>s({method:a,params:e})]}function Qo(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}function $o(e,t){return JSON.stringify(e)===JSON.stringify(t)}var es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs;function Is(){return(Is=e((()=>{Yo(),Xo(),ye(),es=class{_eventSlots=new Map;setHandler(e,t){let n=this._ensureEventSlot(e);n.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),n.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let n=this._eventSlots.get(e);if(!n)return;let r=n.listeners.indexOf(t);r!==-1&&n.listeners.splice(r,1)}dispatch(e,t){let n=this._eventSlots.get(e);if(n){n.onHandler?.(t);for(let e of[...n.listeners])e(t)}}_ensureEventSlot(e){let t=this._eventSlots.get(e);return t||(t={listeners:[]},this._eventSlots.set(e,t)),t}},ts=class{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}},ns=new Set,rs=`2026-01-26`,is=b([j(`light`),j(`dark`)]).describe(`Color theme preference for the host environment.`),as=b([j(`inline`),j(`fullscreen`),j(`pip`)]).describe(`Display mode for UI presentation.`),os=b([j(`--color-background-primary`),j(`--color-background-secondary`),j(`--color-background-tertiary`),j(`--color-background-inverse`),j(`--color-background-ghost`),j(`--color-background-info`),j(`--color-background-danger`),j(`--color-background-success`),j(`--color-background-warning`),j(`--color-background-disabled`),j(`--color-text-primary`),j(`--color-text-secondary`),j(`--color-text-tertiary`),j(`--color-text-inverse`),j(`--color-text-ghost`),j(`--color-text-info`),j(`--color-text-danger`),j(`--color-text-success`),j(`--color-text-warning`),j(`--color-text-disabled`),j(`--color-border-primary`),j(`--color-border-secondary`),j(`--color-border-tertiary`),j(`--color-border-inverse`),j(`--color-border-ghost`),j(`--color-border-info`),j(`--color-border-danger`),j(`--color-border-success`),j(`--color-border-warning`),j(`--color-border-disabled`),j(`--color-ring-primary`),j(`--color-ring-secondary`),j(`--color-ring-inverse`),j(`--color-ring-info`),j(`--color-ring-danger`),j(`--color-ring-success`),j(`--color-ring-warning`),j(`--font-sans`),j(`--font-mono`),j(`--font-weight-normal`),j(`--font-weight-medium`),j(`--font-weight-semibold`),j(`--font-weight-bold`),j(`--font-text-xs-size`),j(`--font-text-sm-size`),j(`--font-text-md-size`),j(`--font-text-lg-size`),j(`--font-heading-xs-size`),j(`--font-heading-sm-size`),j(`--font-heading-md-size`),j(`--font-heading-lg-size`),j(`--font-heading-xl-size`),j(`--font-heading-2xl-size`),j(`--font-heading-3xl-size`),j(`--font-text-xs-line-height`),j(`--font-text-sm-line-height`),j(`--font-text-md-line-height`),j(`--font-text-lg-line-height`),j(`--font-heading-xs-line-height`),j(`--font-heading-sm-line-height`),j(`--font-heading-md-line-height`),j(`--font-heading-lg-line-height`),j(`--font-heading-xl-line-height`),j(`--font-heading-2xl-line-height`),j(`--font-heading-3xl-line-height`),j(`--border-radius-xs`),j(`--border-radius-sm`),j(`--border-radius-md`),j(`--border-radius-lg`),j(`--border-radius-xl`),j(`--border-radius-full`),j(`--border-width-regular`),j(`--shadow-hairline`),j(`--shadow-sm`),j(`--shadow-md`),j(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`),ss=S(os.describe(`Style variables for theming MCP apps.
Individual style keys are optional - hosts may provide any subset of these values.
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),b([C(),ke()]).describe(`Style variables for theming MCP apps.
Individual style keys are optional - hosts may provide any subset of these values.
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
Individual style keys are optional - hosts may provide any subset of these values.
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),cs=x({method:j(`ui/open-link`),params:x({url:C().describe(`URL to open in the host's browser`)})}),ls=x({isError:k().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),us=x({isError:k().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),ds=x({isError:k().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough(),fs=x({method:j(`ui/notifications/sandbox-proxy-ready`),params:x({})}),ps=x({connectDomains:D(C()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
- Maps to CSP \`connect-src\` directive
- Empty or omitted → no network connections (secure default)`),resourceDomains:D(C()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:D(C()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:D(C()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),ms=x({camera:x({}).optional().describe(`Request camera access.
Maps to Permission Policy \`camera\` feature.`),microphone:x({}).optional().describe(`Request microphone access.
Maps to Permission Policy \`microphone\` feature.`),geolocation:x({}).optional().describe(`Request geolocation access.
Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:x({}).optional().describe(`Request clipboard write access.
Maps to Permission Policy \`clipboard-write\` feature.`)}),hs=x({method:j(`ui/notifications/size-changed`),params:x({width:w().optional().describe(`New width in pixels.`),height:w().optional().describe(`New height in pixels.`)})}),x({method:j(`ui/notifications/tool-input`),params:x({arguments:S(C(),O().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),x({method:j(`ui/notifications/tool-input-partial`),params:x({arguments:S(C(),O().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),x({method:j(`ui/notifications/tool-cancelled`),params:x({reason:C().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})}),gs=x({fonts:C().optional()}),_s=x({variables:ss.optional().describe(`CSS variables for theming the app.`),css:gs.optional().describe(`CSS blocks that apps can inject.`)}),x({method:j(`ui/resource-teardown`),params:x({})}),vs=S(C(),O()),ys=x({text:x({}).optional().describe(`Host supports text content blocks.`),image:x({}).optional().describe(`Host supports image content blocks.`),audio:x({}).optional().describe(`Host supports audio content blocks.`),resource:x({}).optional().describe(`Host supports resource content blocks.`),resourceLink:x({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:x({}).optional().describe(`Host supports structured content.`)}),bs=x({method:j(`ui/notifications/request-teardown`),params:x({}).optional()}),xs=x({experimental:S(C(),S(C(),ve()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),openLinks:x({}).optional().describe(`Host supports opening external URLs.`),downloadFile:x({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:x({listChanged:k().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:x({listChanged:k().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:x({}).optional().describe(`Host accepts log messages.`),sandbox:x({permissions:ms.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:ps.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:ys.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:ys.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:x({tools:x({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),Ss=x({experimental:S(C(),S(C(),ve()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),tools:x({listChanged:k().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:D(as).optional().describe(`Display modes the app supports.`)}),Cs=x({method:j(`ui/notifications/initialized`),params:x({}).optional()}),x({csp:ps.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:ms.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:C().optional().describe(`Dedicated origin for view sandbox.
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:k().optional().describe(`Visual boundary preference - true if view prefers a visible border.
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
- \`true\`: request visible border + background
- \`false\`: request no visible border + background
- omitted: host decides border`)}),ws=x({method:j(`ui/request-display-mode`),params:x({mode:as.describe(`The display mode being requested.`)})}),Ts=x({mode:as.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),Es=b([j(`model`),j(`app`)]).describe(`Tool visibility scope - who can access the tool.`),x({resourceUri:C().optional(),visibility:D(Es).optional().describe(`Who can access this tool. Default: ["model", "app"]
- "model": Tool visible to and callable by the agent
- "app": Tool callable by the app from this server only`),csp:je().optional(),permissions:je().optional()}),x({mimeTypes:D(C()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Ds=x({method:j(`ui/download-file`),params:x({contents:D(b([_n,vn])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),Os=x({method:j(`ui/message`),params:x({role:j(`user`).describe(`Message role, currently only "user" is supported.`),content:D(yn).describe(`Message content blocks (text, image, etc.).`)})}),x({method:j(`ui/notifications/sandbox-resource-ready`),params:x({html:C().describe(`HTML content to load into the inner iframe.`),sandbox:C().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:ps.optional().describe(`CSP configuration from resource metadata.`),permissions:ms.optional().describe(`Sandbox permissions from resource metadata.`)})}),x({method:j(`ui/notifications/tool-result`),params:On.describe(`Standard MCP tool execution result.`)}),ks=x({toolInfo:x({id:z.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Tn.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:is.optional().describe(`Current color theme preference.`),styles:_s.optional().describe(`Style configuration for theming the app.`),displayMode:as.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:D(as).optional().describe(`Display modes the host supports.`),containerDimensions:b([x({height:w().describe(`Fixed container height in pixels.`)}),x({maxHeight:b([w(),ke()]).optional().describe(`Maximum container height in pixels.`)})]).and(b([x({width:w().describe(`Fixed container width in pixels.`)}),x({maxWidth:b([w(),ke()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:C().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:C().optional().describe(`User's timezone in IANA format.`),userAgent:C().optional().describe(`Host application identifier.`),platform:b([j(`web`),j(`desktop`),j(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:x({touch:k().optional().describe(`Whether the device supports touch input.`),hover:k().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:x({top:w().describe(`Top safe area inset in pixels.`),right:w().describe(`Right safe area inset in pixels.`),bottom:w().describe(`Bottom safe area inset in pixels.`),left:w().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),x({method:j(`ui/notifications/host-context-changed`),params:ks.describe(`Partial context update containing only changed fields.`)}),As=x({method:j(`ui/update-model-context`),params:x({content:D(yn).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:S(C(),O().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),js=x({method:j(`ui/initialize`),params:x({appInfo:_t.describe(`App identification (name and version).`),appCapabilities:Ss.describe(`Features and capabilities this app provides.`),protocolVersion:C().describe(`Protocol version this app supports.`)})}),Ms=x({protocolVersion:C().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:_t.describe(`Host application identification and version.`),hostCapabilities:xs.describe(`Features and capabilities provided by the host.`),hostContext:ks.describe(`Rich context about the host environment.`)}).passthrough(),Ns=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=B.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},Ps=[rs],Fs=class extends Ao{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new es;_methods=new ts;setRequestHandler=(...e)=>{let[t,...n]=Zo(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=Zo(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_wrapHandler(e,t){let n=super._wrapHandler(e,t);return e===`ui/initialize`||e===`ping`?n:async(t,r)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(t,r))}eventSchemas={sizechange:hs,sandboxready:fs,initialized:Cs,requestteardown:bs,loggingmessage:Rn};setEventHandler(e,t){this._ensureEventSlot(e),this._events.setHandler(e,t)}getEventHandler(e){return this._events.getHandler(e)}addEventListener(e,t){this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);let n=t=>{e===`initialized`&&(this._initializedReceived=!0),this._events.dispatch(e,t)};e===`loggingmessage`?this.setNotificationHandler(`notifications/message`,e=>{n(e.params)}):this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},e=>n(e)),this._registeredEvents.add(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._hostCapabilities=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),this._ensureEventSlot(`initialized`),this._hostContext=r?.hostContext||{},this.replaceRequestHandler(`ui/initialize`,{params:js.shape.params,result:Ms},e=>this._onAppsInitialize(e)),this.replaceRequestHandler(`ping`,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(`ui/request-display-mode`,{params:ws.shape.params,result:Ts},()=>({mode:this._hostContext.displayMode??`inline`}))}buildContext(e){return e}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.replaceRequestHandler(`ui/message`,{params:Os.shape.params,result:ds},async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler(`ui/open-link`,{params:cs.shape.params,result:ls},async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler(`ui/download-file`,{params:Ds.shape.params,result:us},async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler(`ui/request-display-mode`,{params:ws.shape.params,result:Ts},async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler(`ui/update-model-context`,{params:As.shape.params,result:ft},async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(e){this.warnIfRequestHandlerReplaced(`oncreatesamplingmessage`,this._oncreatesamplingmessage,e),this._oncreatesamplingmessage=e,this.replaceRequestHandler(`sampling/createMessage`,async(e,t)=>{if(!this._oncreatesamplingmessage)throw Error(`No oncreatesamplingmessage handler set`);return this._oncreatesamplingmessage(e.params,t)})}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler(`resources/list`,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler(`resources/templates/list`,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler(`resources/read`,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler(`prompts/list`,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(e){let t=e.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.appCapabilities,this._appInfo=e.appInfo,{protocolVersion:Ps.includes(t)?t:rs,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];$o(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},vs,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},t)}listTools(e,t){return this.request({method:`tools/list`,params:e},t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},{signal:t.mcpReq.signal}),e.tools.listChanged&&this._client.setNotificationHandler(`notifications/tools/list_changed`,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},{signal:t.mcpReq.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},{signal:t.mcpReq.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},{signal:t.mcpReq.signal}),e.resources.listChanged&&this._client.setNotificationHandler(`notifications/resources/list_changed`,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},{signal:t.mcpReq.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(`notifications/prompts/list_changed`,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}}})))()}function Ls(e=document.documentElement){if(!e)return;let t=getComputedStyle(e),n={...zs};for(let[e,r]of Object.entries(Rs)){let i=t.getPropertyValue(r).trim();i&&(n[e]=i)}return n}var Rs,zs;function Bs(){return(Bs=e((()=>{Rs={"--color-background-primary":`--card`,"--color-background-secondary":`--bg`,"--color-background-tertiary":`--bg-elevated`,"--color-background-inverse":`--text`,"--color-background-disabled":`--bg-muted`,"--color-background-success":`--ok-subtle`,"--color-background-warning":`--warn-subtle`,"--color-background-danger":`--danger-subtle`,"--color-text-primary":`--text`,"--color-text-secondary":`--muted-strong`,"--color-text-tertiary":`--muted`,"--color-text-inverse":`--bg`,"--color-text-success":`--ok`,"--color-text-warning":`--warn`,"--color-text-danger":`--danger`,"--color-text-info":`--info`,"--color-border-primary":`--border`,"--color-border-secondary":`--border-strong`,"--color-border-inverse":`--bg`,"--color-ring-primary":`--ring`,"--font-text-xs-size":`--control-ui-text-xs`,"--font-text-sm-size":`--control-ui-text-sm`,"--font-text-md-size":`--control-ui-text-md`,"--font-text-lg-size":`--control-ui-text-lg`,"--border-radius-xs":`--radius-sm`,"--border-radius-sm":`--radius-sm`,"--border-radius-md":`--radius`,"--border-radius-lg":`--radius-lg`,"--border-radius-xl":`--radius-xl`,"--border-radius-full":`--radius-full`,"--shadow-sm":`--shadow-sm`,"--shadow-md":`--shadow-md`,"--shadow-lg":`--shadow-lg`},zs={"--border-width-regular":`1px`,"--font-weight-normal":`400`,"--font-weight-medium":`500`,"--font-weight-semibold":`600`,"--font-weight-bold":`700`,"--font-sans":`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"`,"--font-mono":`ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace`}})))()}async function Vs(){await Promise.race([new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})}),new Promise(e=>{window.setTimeout(e,1e3)})])}function Hs(e,t,n){let r=e?.getBoundingClientRect(),i=navigator.maxTouchPoints>0||window.matchMedia?.(`(pointer: coarse)`).matches,a=document.documentElement.dataset.themeMode;return ks.parse({theme:a===`light`||a===`dark`?a:window.matchMedia?.(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,displayMode:`inline`,availableDisplayModes:[`inline`],containerDimensions:{width:Math.max(1,Math.round(r?.width||window.innerWidth)),height:n?Math.max(0,Math.round(r?.height??0)):t},locale:navigator.language||void 0,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,platform:i&&window.innerWidth<768?`mobile`:`web`,deviceCapabilities:{touch:i,hover:window.matchMedia?.(`(hover: hover)`).matches},safeAreaInsets:{top:0,right:0,bottom:0,left:0},styles:{variables:Ls()}})}var Us,Ws,Gs;function Ks(){return(Ks=e((()=>{n(),ae(),Is(),t(),te(),re(),v(),h(),p(),f(),c(),Ie(),Bs(),Us=250,Ws=class extends Fs{setMessageHandler(e){Reflect.set(this,`onmessage`,e)}setUpdateModelContextHandler(e){Reflect.set(this,`onupdatemodelcontext`,e)}setListToolsHandler(e){this.replaceRequestHandler(`tools/list`,t=>e(t.params))}},Gs=class extends r{constructor(...e){super(...e),this.sessionKey=``,this.viewId=``,this.height=600,this.fillContainer=!1,this.title=``,this.i18nController=new l(this),this.mount=y(),this.resources=null,this.teardownPromise=null,this.setupTask=new oe(this,{autoRun:`afterUpdate`,args:()=>[this.context?.gateway.snapshot.client??null,this.sessionKey,this.viewId],task:async([e,t,n],{signal:r})=>{if(await this.teardownResources(this.resources),!t||!n)return null;if(!e)throw Error(u(`mcpApp.errors.gatewayUnavailable`));return this.setupResources({client:e,sessionKey:t,viewId:n},r)}})}static{this.styles=ne`
:host {
display: block;
width: 100%;
}
.mount {
width: 100%;
min-height: 160px;
}
.mount:empty {
min-height: 0;
}
:host([fill-container]),
:host([fill-container]) .mount {
height: 100%;
min-height: 0;
}
iframe {
display: block;
width: 100%;
border: 0;
background: var(--board-surface, transparent);
}
.error {
padding: 14px;
color: var(--danger, #dc2626);
font-size: 13px;
}
`}disconnectedCallback(){this.teardown(),super.disconnectedCallback()}updated(e){this.resources&&(this.resources.iframe.title=this.title||u(`mcpApp.title`),(e.has(`height`)||e.has(`fillContainer`))&&(this.resources.frameHeight=this.height,this.resources.iframe.style.height=this.fillContainer?`100%`:`${this.height}px`,this.resources.bridge?.setHostContext(Hs(this.mount.value,this.height,this.fillContainer))))}async request(e,t,n,r){try{let i={sessionKey:e.sessionKey,viewId:e.viewId,...n};return await(r?e.client.request(t,i,{signal:r}):e.client.request(t,i))}catch(e){throw i(e)&&this.dispatchEvent(new CustomEvent(Me,{bubbles:!0,composed:!0})),e}}addResourceCleanup(e,t){return e.cleanups.add(t),()=>{e.cleanups.delete(t)&&t()}}async teardownResources(e){if(!e||e.disposed){await this.teardownPromise;return}e.disposed=!0,this.resources===e&&(this.resources=null);for(let t of e.cleanups)e.cleanups.delete(t),t();let t=(async()=>{if(e.bridge){let t;try{await Promise.race([e.bridge.teardownResource({}).catch(()=>void 0),new Promise(e=>{t=window.setTimeout(e,Us)})])}finally{t!==void 0&&window.clearTimeout(t)}}await e.transport?.close().catch(()=>void 0),e.iframe.remove()})();this.teardownPromise=t;try{await t}finally{this.teardownPromise===t&&(this.teardownPromise=null)}}async teardown(){this.setupTask.abort(),await this.teardownResources(this.resources)}restartAfterTeardown(){!this.isConnected||this.resources||this.teardownPromise||this.setupTask.run()}async setupResources(e,t){let{sessionKey:n,viewId:r}=e,i=null;try{let a=await this.request(e,`mcp.app.view`,{},t),o=this.mount.value;if(t.throwIfAborted(),!o)throw Error(u(`mcpApp.errors.mountUnavailable`));let s=document.createElement(`iframe`);s.title=this.title||u(`mcpApp.title`),s.referrerPolicy=`origin`,s.style.height=this.fillContainer?`100%`:`${this.height}px`,s.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-forms`),o.appendChild(s);let c={bridge:null,cleanups:new Set,frameHeight:this.height,iframe:s,transport:null,disposed:!1};i=c,this.resources=c,t.addEventListener(`abort`,()=>void this.teardownResources(c),{once:!0});let l=new Promise((e,t)=>{let n=window.setTimeout(()=>{i(),t(Error(u(`mcpApp.errors.sandboxTimedOut`)))},15e3),r=t=>{t.source===s.contentWindow&&t.data?.method===`ui/notifications/sandbox-proxy-ready`&&(i(),e())},i=this.addResourceCleanup(c,()=>{window.clearTimeout(n),window.removeEventListener(`message`,r)});window.addEventListener(`message`,r)});if(s.src=Fe(a.sandboxUrl,a.sandboxPort,a.sandboxOrigin,this.context?.gateway.connection.gatewayUrl??``,window.location.origin),await l,t.throwIfAborted(),!s.contentWindow)throw Error(u(`mcpApp.errors.sandboxUnavailable`));let f=new Ws(null,{name:`OpenClaw`,version:`1.0.0`},Ne(a.csp,a.messageSupported===!0,a.updateModelContextSupported===!0,a.messageSupported===!0),{hostContext:Hs(o,this.height,this.fillContainer)});c.bridge=f;let p=(t,n)=>this.request(e,t,n),m=()=>{this.teardown()};if(f.onrequestteardown=m,this.addResourceCleanup(c,()=>{f.onrequestteardown===m&&(f.onrequestteardown=void 0)}),a.messageSupported===!0){let e=`${n}\0${r}`;f.setMessageHandler(async({content:t})=>{let n=t.length===1?t[0]:void 0,r=n?.type===`text`?n.text:null;return Pe(s,r,e,e=>window.confirm(`${u(`common.confirm`)}:\n\n${e}`))?{}:{isError:!0}})}a.updateModelContextSupported===!0&&f.setUpdateModelContextHandler(async e=>(await p(`mcp.app.updateModelContext`,{...e}),{})),f.oncalltool=async e=>await p(`mcp.app.callTool`,{toolName:e.name,arguments:e.arguments}),f.setListToolsHandler(async e=>await p(`mcp.app.listTools`,e?.cursor?{cursor:e.cursor}:{})),f.onlistresources=async e=>await p(`mcp.app.listResources`,e?.cursor?{cursor:e.cursor}:{}),f.onlistresourcetemplates=async e=>await p(`mcp.app.listResourceTemplates`,e?.cursor?{cursor:e.cursor}:{}),f.onreadresource=async e=>await p(`mcp.app.readResource`,{uri:e.uri}),f.onopenlink=async({url:e})=>d(e)?{}:{isError:!0},f.onsizechange=({height:e})=>{if(e!==void 0&&!this.fillContainer){let t=Math.min(1200,Math.max(160,Math.round(e)));c.frameHeight=t,s.style.height=`${t}px`,f.setHostContext(Hs(o,t,this.fillContainer))}};let h=new Promise(e=>{f.oninitialized=()=>e()}),g=new Ns(s.contentWindow,s.contentWindow);c.transport=g,await f.connect(g),t.throwIfAborted(),await f.sendSandboxResourceReady({html:a.html,csp:a.csp});let _,v=this.addResourceCleanup(c,()=>{_!==void 0&&window.clearTimeout(_)});try{await Promise.race([h,new Promise((e,t)=>{_=window.setTimeout(()=>t(Error(u(`mcpApp.errors.initializationTimedOut`))),15e3)})])}finally{v()}t.throwIfAborted();let y=()=>f.setHostContext(Hs(o,c.frameHeight,this.fillContainer)),ee=this.context?.theme.subscribe(y);if(ee&&this.addResourceCleanup(c,ee),typeof ResizeObserver<`u`){let e=new ResizeObserver(y);e.observe(o),this.addResourceCleanup(c,()=>e.disconnect())}return await Vs(),t.throwIfAborted(),await f.sendToolInput({arguments:a.toolInput&&typeof a.toolInput==`object`&&!Array.isArray(a.toolInput)?a.toolInput:{}}),await f.sendToolResult(a.toolResult),t.throwIfAborted(),c}catch(e){throw await this.teardownResources(i),e}}render(){let e=this.setupTask.status===se.ERROR?this.setupTask.error:null,t=e?u(`mcpApp.unavailable`,{error:s(e,u(`mcpApp.errors.requestFailed`))}):null;return g`<div ${_(this.mount)} class="mount"></div>
${t?g`<div class="error">${t}</div>`:ee}`}},a([o({context:m,subscribe:!0})],Gs.prototype,`context`,void 0),a([ie({attribute:!1})],Gs.prototype,`sessionKey`,void 0),a([ie({attribute:!1})],Gs.prototype,`viewId`,void 0),a([ie({type:Number})],Gs.prototype,`height`,void 0),a([ie({type:Boolean,attribute:`fill-container`,reflect:!0})],Gs.prototype,`fillContainer`,void 0),a([ie()],Gs.prototype,`title`,void 0)})))()}function qs(){customElements.get(`mcp-app-view`)||customElements.define(`mcp-app-view`,Gs)}function Js(){return(Js=e((()=>{Ks(),qs()})))()}Js();export{qs as registerMcpAppView};