UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

59 lines • 154 kB
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Fu as t,Pu as n,dn as r,un as i,xu as a,yu as o,zu as s}from"./control-ui-core-CBJ5efDh.js";import{Ai as c,ki as l}from"./control-ui-core-DtLivg_r.js";import{D as u,E as d,G as f,J as p,W as m,Z as h,at as g,k as _,rt as v}from"./lit-runtime-IOnANfcZ.js";import{An as y,_a as ee,ba as te,kn as ne}from"./control-ui-boot-shared-UG5ko-VG.js";import{Gi as re,It as ie,Lt as ae,Ui as oe,Ur as se,Wr as ce,Zr as b,da as le,xa as ue}from"./ui-CmSP4d14.js";import{F as de,M as fe,j as pe}from"./control-ui-boot-shared-VLPz5vN2.js";import{C as x,D as S,E as me,F as he,I as ge,L as _e,M as C,N as ve,P as ye,R as be,S as xe,T as w,_ as T,a as Se,b as E,c as D,d as Ce,f as O,g as we,h as Te,i as Ee,j as k,k as A,l as De,n as Oe,o as ke,p as j,r as Ae,s as je,t as Me,u as Ne,v as Pe,w as M,x as N,y as Fe,z as Ie}from"./config-runtime-BecGLziM.js";import{ei as Le,ti as Re}from"./control-ui-boot-shared-XreXSF7h.js";import{r as ze,t as Be}from"./mcp-app-routing-DFzELUUu.js";import{_t as Ve,bt as He,gt as Ue,pt as We,ut as Ge,xt as Ke,yt as qe}from"./control-ui-boot-chat-CmENwCKi.js";import{i as Je,n as Ye,r as Xe,t as Ze}from"./mcp-app-confirm-BOrRV_eo.js";import{r as Qe}from"./sandbox-host-Dm6XHU23.js";var $e,et,tt;function nt(){return(nt=e((()=>{$e=Object.defineProperty,et=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),tt=(e,t)=>{let n={};for(var r in e)$e(n,r,{get:e[r],enumerable:!0});return t&&$e(n,Symbol.toStringTag,{value:`Module`}),n}})))()}function rt(e){return typeof e==`string`&&it.has(e.replace(/#$/,``))}var it;function at(){return(at=e((()=>{it=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`])})))()}var ot,st,ct,lt,ut,dt,ft,pt,mt,ht,P,F,gt,_t,vt,yt,bt,I,xt,L,R,z,St,B,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,V,It,Lt,Rt,H,U,zt,W,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,G,Zt,Qt,$t,en,K,tn,nn,rn,an,on,sn,q,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,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,J,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi;function Si(){return(Si=e((()=>{T(),Se(),je(),Ie(),Me(),ot=`2025-11-25`,st=[ot,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],ct=`io.modelcontextprotocol/related-task`,lt=`io.modelcontextprotocol/protocolVersion`,ut=`io.modelcontextprotocol/clientInfo`,dt=`io.modelcontextprotocol/serverInfo`,ft=`io.modelcontextprotocol/clientCapabilities`,pt=`io.modelcontextprotocol/subscriptionId`,mt=`io.modelcontextprotocol/logLevel`,ht=Fe(()=>k([A(),x(),j(),De(),S(A(),ht),O(ht)])),P=S(A(),ht),F=O(ht),gt=k([A(),x().int()]),_t=A(),vt=M({ttl:x().optional()}),yt=M({taskId:A()}),bt=N({progressToken:gt.optional(),[ct]:yt.optional()}),I=M({_meta:bt.optional()}),xt=I.extend({task:vt.optional()}),L=M({method:A(),params:I.loose().optional()}),R=M({_meta:bt.optional()}),z=M({method:A(),params:R.loose().optional()}),St=N({get[dt](){return V.optional().catch(void 0)}}),B=N({_meta:St.optional()}),Ct=k([A(),x().int()]),wt=M({jsonrpc:E(`2.0`),id:Ct,...L.shape}).strict(),Tt=M({jsonrpc:E(`2.0`),...z.shape}).strict(),Et=M({jsonrpc:E(`2.0`),id:Ct,result:B}).strict(),Dt=M({jsonrpc:E(`2.0`),id:Ct.optional(),error:M({code:x().int(),message:A(),data:C().optional()})}).strict(),Ot=k([wt,Tt,Et,Dt]),kt=k([Et,Dt]),At=B.strict(),jt=R.extend({requestId:Ct.optional(),reason:A().optional()}),Mt=z.extend({method:E(`notifications/cancelled`),params:jt}),Nt=M({src:A(),mimeType:A().optional(),sizes:O(A()).optional(),theme:D([`light`,`dark`]).optional()}),Pt=M({icons:O(Nt).optional()}),Ft=M({name:A(),title:A().optional()}),V=Ft.extend({...Ft.shape,...Pt.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),It=Pe(M({applyDefaults:j().optional()}),P),Lt=me(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Pe(M({form:It.optional(),url:P.optional()}),P.optional())),Rt=N({list:P.optional(),cancel:P.optional(),requests:N({sampling:N({createMessage:P.optional()}).optional(),elicitation:N({create:P.optional()}).optional()}).optional()}),H=N({list:P.optional(),cancel:P.optional(),requests:N({tools:N({call:P.optional()}).optional()}).optional()}),U=M({experimental:S(A(),P).optional(),sampling:M({context:P.optional(),tools:P.optional()}).optional(),elicitation:Lt.optional(),roots:M({listChanged:j().optional()}).optional(),tasks:Rt.optional(),extensions:S(A(),P).optional()}),zt=I.extend({protocolVersion:A(),capabilities:U,clientInfo:V}),W=L.extend({method:E(`initialize`),params:zt}),Bt=M({experimental:S(A(),P).optional(),logging:P.optional(),completions:P.optional(),prompts:M({listChanged:j().optional()}).optional(),resources:M({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:M({listChanged:j().optional()}).optional(),tasks:H.optional(),extensions:S(A(),P).optional()}),Vt=B.extend({protocolVersion:A(),capabilities:Bt,serverInfo:V,instructions:A().optional()}),Ht=z.extend({method:E(`notifications/initialized`),params:R.optional()}),Ut=L.extend({method:E(`server/discover`),params:I.optional()}),Wt=B.extend({supportedVersions:O(A()),capabilities:Bt,instructions:A().optional()}),Gt=L.extend({method:E(`ping`),params:I.optional()}),Kt=M({progress:x(),total:w(x()),message:w(A())}),qt=M({...R.shape,...Kt.shape,progressToken:gt}),Jt=z.extend({method:E(`notifications/progress`),params:qt}),Yt=I.extend({cursor:_t.optional()}),Xt=L.extend({params:Yt.optional()}),G=B.extend({nextCursor:_t.optional()}),Zt=M({uri:A(),mimeType:w(A()),_meta:S(A(),C()).optional()}),Qt=Zt.extend({text:A()}),$t=A().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),en=Zt.extend({blob:$t}),K=D([`user`,`assistant`]),tn=M({audience:O(K).optional(),priority:x().min(0).max(1).optional(),lastModified:Ee({offset:!0}).optional()}),nn=M({...Ft.shape,...Pt.shape,uri:A(),description:w(A()),mimeType:w(A()),size:w(x()),annotations:tn.optional(),_meta:w(N({}))}),rn=M({...Ft.shape,...Pt.shape,uriTemplate:A(),description:w(A()),mimeType:w(A()),annotations:tn.optional(),_meta:w(N({}))}),an=Xt.extend({method:E(`resources/list`)}),on=G.extend({resources:O(nn)}),sn=Xt.extend({method:E(`resources/templates/list`)}),q=G.extend({resourceTemplates:O(rn)}),cn=I.extend({uri:A()}),ln=cn,un=L.extend({method:E(`resources/read`),params:ln}),dn=B.extend({contents:O(k([Qt,en]))}),fn=z.extend({method:E(`notifications/resources/list_changed`),params:R.optional()}),pn=cn,mn=L.extend({method:E(`resources/subscribe`),params:pn}),hn=cn,gn=L.extend({method:E(`resources/unsubscribe`),params:hn}),_n=M({toolsListChanged:j().optional(),promptsListChanged:j().optional(),resourcesListChanged:j().optional(),resourceSubscriptions:O(A()).optional()}),vn=I.extend({notifications:_n}),yn=L.extend({method:E(`subscriptions/listen`),params:vn}),bn=R.extend({notifications:_n}),xn=z.extend({method:E(`notifications/subscriptions/acknowledged`),params:bn}),Sn=St.extend({[pt]:Ct}),Cn=B.extend({_meta:Sn}),wn=R.extend({uri:A()}),Tn=z.extend({method:E(`notifications/resources/updated`),params:wn}),En=M({name:A(),description:w(A()),required:w(j())}),Dn=M({...Ft.shape,...Pt.shape,description:w(A()),arguments:w(O(En)),_meta:w(N({}))}),On=Xt.extend({method:E(`prompts/list`)}),kn=G.extend({prompts:O(Dn)}),An=I.extend({name:A(),arguments:S(A(),A()).optional()}),jn=L.extend({method:E(`prompts/get`),params:An}),Mn=M({type:E(`text`),text:A(),annotations:tn.optional(),_meta:S(A(),C()).optional()}),Nn=M({type:E(`image`),data:$t,mimeType:A(),annotations:tn.optional(),_meta:S(A(),C()).optional()}),Pn=M({type:E(`audio`),data:$t,mimeType:A(),annotations:tn.optional(),_meta:S(A(),C()).optional()}),Fn=M({type:E(`tool_use`),name:A(),id:A(),input:S(A(),C()),_meta:S(A(),C()).optional()}),In=M({type:E(`resource`),resource:k([Qt,en]),annotations:tn.optional(),_meta:S(A(),C()).optional()}),Ln=nn.extend({type:E(`resource_link`)}),Rn=k([Mn,Nn,Pn,Ln,In]),zn=M({role:K,content:Rn}),Bn=B.extend({description:A().optional(),messages:O(zn)}),Vn=z.extend({method:E(`notifications/prompts/list_changed`),params:R.optional()}),Hn=M({title:A().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),Un=M({taskSupport:D([`required`,`optional`,`forbidden`]).optional()}),Wn=M({...Ft.shape,...Pt.shape,description:A().optional(),inputSchema:M({type:E(`object`),properties:S(A(),ht).optional(),required:O(A()).optional()}).catchall(C()),outputSchema:N({$schema:A().optional()}).optional(),annotations:Hn.optional(),execution:Un.optional(),_meta:S(A(),C()).optional()}),Gn=Xt.extend({method:E(`tools/list`)}),Kn=G.extend({tools:O(Wn)}),qn=B.extend({content:O(Rn).default([]),structuredContent:C().optional(),isError:j().optional()}),Jn=qn.or(B.extend({toolResult:C()})),Yn=xt.extend({name:A(),arguments:S(A(),C()).optional()}),Xn=L.extend({method:E(`tools/call`),params:Yn}),Zn=z.extend({method:E(`notifications/tools/list_changed`),params:R.optional()}),Qn=M({autoRefresh:j().default(!0),debounceMs:x().int().nonnegative().default(300)}),$n=D([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),er=I.extend({level:$n}),tr=L.extend({method:E(`logging/setLevel`),params:er}),nr=R.extend({level:$n,logger:A().optional(),data:C()}),rr=z.extend({method:E(`notifications/message`),params:nr}),ir=M({name:A().optional()}),ar=M({hints:O(ir).optional(),costPriority:x().min(0).max(1).optional(),speedPriority:x().min(0).max(1).optional(),intelligencePriority:x().min(0).max(1).optional()}),or=M({mode:D([`auto`,`required`,`none`]).optional()}),sr=M({type:E(`tool_result`),toolUseId:A().describe(`The unique identifier for the corresponding tool call.`),content:O(Rn),structuredContent:C().optional(),isError:j().optional(),_meta:S(A(),C()).optional()}),cr=Te(`type`,[Mn,Nn,Pn]),lr=Te(`type`,[Mn,Nn,Pn,Fn,sr]),ur=M({role:K,content:k([lr,O(lr)]),_meta:S(A(),C()).optional()}),dr=xt.extend({messages:O(ur),modelPreferences:ar.optional(),systemPrompt:A().optional(),includeContext:D([`none`,`thisServer`,`allServers`]).optional(),temperature:x().optional(),maxTokens:x().int(),stopSequences:O(A()).optional(),metadata:P.optional(),tools:O(Wn).optional(),toolChoice:or.optional()}),fr=L.extend({method:E(`sampling/createMessage`),params:dr}),pr=B.extend({model:A(),stopReason:w(D([`endTurn`,`stopSequence`,`maxTokens`]).or(A())),role:K,content:cr}),mr=B.extend({model:A(),stopReason:w(D([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(A())),role:K,content:k([lr,O(lr)])}),hr=M({type:E(`boolean`),title:A().optional(),description:A().optional(),default:j().optional()}),gr=M({type:E(`string`),title:A().optional(),description:A().optional(),minLength:x().optional(),maxLength:x().optional(),format:D([`email`,`uri`,`date`,`date-time`]).optional(),default:A().optional()}),_r=M({type:D([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:x().optional(),maximum:x().optional(),default:x().optional()}),vr=M({type:E(`string`),title:A().optional(),description:A().optional(),enum:O(A()),default:A().optional()}),yr=M({type:E(`string`),title:A().optional(),description:A().optional(),oneOf:O(M({const:A(),title:A()})),default:A().optional()}),br=M({type:E(`string`),title:A().optional(),description:A().optional(),enum:O(A()),enumNames:O(A()).optional(),default:A().optional()}),xr=k([vr,yr]),Sr=M({type:E(`array`),title:A().optional(),description:A().optional(),minItems:x().optional(),maxItems:x().optional(),items:M({type:E(`string`),enum:O(A())}),default:O(A()).optional()}),Cr=M({type:E(`array`),title:A().optional(),description:A().optional(),minItems:x().optional(),maxItems:x().optional(),items:M({anyOf:O(M({const:A(),title:A()}))}),default:O(A()).optional()}),wr=k([Sr,Cr]),Tr=k([br,xr,wr]),Er=k([Tr,hr,gr,_r]),Dr=xt.extend({mode:E(`form`).optional(),message:A(),requestedSchema:M({type:E(`object`),properties:S(A(),Er),required:O(A()).optional()}).catchall(C())}),Or=xt.extend({mode:E(`url`),message:A(),elicitationId:A(),url:A().url()}),kr=k([Dr,Or]),Ar=L.extend({method:E(`elicitation/create`),params:kr}),jr=R.extend({elicitationId:A()}),Mr=z.extend({method:E(`notifications/elicitation/complete`),params:jr}),Nr=B.extend({action:D([`accept`,`decline`,`cancel`]),content:me(e=>e===null?void 0:e,S(A(),k([A(),x(),j(),O(A())])).optional())}),Pr=M({type:E(`ref/resource`),uri:A()}),Fr=M({type:E(`ref/prompt`),name:A()}),Ir=I.extend({ref:k([Fr,Pr]),argument:M({name:A(),value:A()}),context:M({arguments:S(A(),A()).optional()}).optional()}),Lr=L.extend({method:E(`completion/complete`),params:Ir}),Rr=B.extend({completion:N({values:O(A()).max(100),total:w(x().int()),hasMore:w(j())})}),zr=M({uri:A().startsWith(`file://`),name:A().optional(),_meta:S(A(),C()).optional()}),Br=L.extend({method:E(`roots/list`),params:I.optional()}),Vr=B.extend({roots:O(zr)}),Hr=z.extend({method:E(`notifications/roots/list_changed`),params:R.optional()}),Ur=N({ttl:x().optional(),pollInterval:x().optional()}),Wr=D([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Gr=M({taskId:A(),status:Wr,ttl:k([x(),De()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:w(x()),statusMessage:w(A())}),Kr=B.extend({task:Gr}),qr=R.merge(Gr),Jr=z.extend({method:E(`notifications/tasks/status`),params:qr}),Yr=L.extend({method:E(`tasks/get`),params:I.extend({taskId:A()})}),Xr=B.merge(Gr),Zr=L.extend({method:E(`tasks/result`),params:I.extend({taskId:A()})}),Qr=B.loose(),$r=Xt.extend({method:E(`tasks/list`)}),ei=G.extend({tasks:O(Gr)}),ti=L.extend({method:E(`tasks/cancel`),params:I.extend({taskId:A()})}),ni=B.merge(Gr),ri=k([Gt,W,Ut,Lr,tr,jn,On,an,sn,un,mn,gn,yn,Xn,Gn]),ii=k([Mt,Jt,Ht,Hr]),ai=k([At,pr,mr,Nr,Vr]),oi=k([Gt,fr,Ar,Br]),si=k([Mt,Jt,rr,Tn,fn,Zn,Vn,xn,Mr]),ci=k([At,Vt,Wt,Rr,Bn,kn,on,q,dn,qn,Kn,Cn]),J=ve().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ke.custom,message:`URL must be parseable`,fatal:!0}),be}).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`}),li=N({resource:A().url(),authorization_servers:O(J).optional(),jwks_uri:A().url().optional(),scopes_supported:O(A()).optional(),bearer_methods_supported:O(A()).optional(),resource_signing_alg_values_supported:O(A()).optional(),resource_name:A().optional(),resource_documentation:A().optional(),resource_policy_uri:A().url().optional(),resource_tos_uri:A().url().optional(),tls_client_certificate_bound_access_tokens:j().optional(),authorization_details_types_supported:O(A()).optional(),dpop_signing_alg_values_supported:O(A()).optional(),dpop_bound_access_tokens_required:j().optional()}),ui=N({issuer:A(),authorization_endpoint:J,token_endpoint:J,registration_endpoint:J.optional(),scopes_supported:O(A()).optional(),response_types_supported:O(A()),response_modes_supported:O(A()).optional(),grant_types_supported:O(A()).optional(),token_endpoint_auth_methods_supported:O(A()).optional(),token_endpoint_auth_signing_alg_values_supported:O(A()).optional(),service_documentation:J.optional(),revocation_endpoint:J.optional(),revocation_endpoint_auth_methods_supported:O(A()).optional(),revocation_endpoint_auth_signing_alg_values_supported:O(A()).optional(),introspection_endpoint:A().optional(),introspection_endpoint_auth_methods_supported:O(A()).optional(),introspection_endpoint_auth_signing_alg_values_supported:O(A()).optional(),code_challenge_methods_supported:O(A()).optional(),client_id_metadata_document_supported:j().optional(),authorization_response_iss_parameter_supported:j().optional().catch(void 0),dpop_signing_alg_values_supported:O(A()).optional()}),di=N({issuer:A(),authorization_endpoint:J,token_endpoint:J,userinfo_endpoint:J.optional(),jwks_uri:J,registration_endpoint:J.optional(),scopes_supported:O(A()).optional(),response_types_supported:O(A()),response_modes_supported:O(A()).optional(),grant_types_supported:O(A()).optional(),acr_values_supported:O(A()).optional(),subject_types_supported:O(A()),id_token_signing_alg_values_supported:O(A()),id_token_encryption_alg_values_supported:O(A()).optional(),id_token_encryption_enc_values_supported:O(A()).optional(),userinfo_signing_alg_values_supported:O(A()).optional(),userinfo_encryption_alg_values_supported:O(A()).optional(),userinfo_encryption_enc_values_supported:O(A()).optional(),request_object_signing_alg_values_supported:O(A()).optional(),request_object_encryption_alg_values_supported:O(A()).optional(),request_object_encryption_enc_values_supported:O(A()).optional(),token_endpoint_auth_methods_supported:O(A()).optional(),token_endpoint_auth_signing_alg_values_supported:O(A()).optional(),display_values_supported:O(A()).optional(),claim_types_supported:O(A()).optional(),claims_supported:O(A()).optional(),service_documentation:A().optional(),claims_locales_supported:O(A()).optional(),ui_locales_supported:O(A()).optional(),claims_parameter_supported:j().optional(),request_parameter_supported:j().optional(),request_uri_parameter_supported:j().optional(),require_request_uri_registration:j().optional(),op_policy_uri:J.optional(),op_tos_uri:J.optional(),client_id_metadata_document_supported:j().optional(),authorization_response_iss_parameter_supported:j().optional().catch(void 0)}),fi=M({...di.shape,...ui.pick({code_challenge_methods_supported:!0}).shape}),pi=M({access_token:A(),id_token:A().optional(),token_type:A(),expires_in:Oe().optional(),scope:A().optional(),refresh_token:A().optional(),issuer:A().optional().catch(void 0)}).strip(),mi=M({issued_token_type:E(`urn:ietf:params:oauth:token-type:id-jag`),access_token:A(),token_type:A().optional(),expires_in:x().optional(),scope:A().optional()}).strip(),hi=M({error:A(),error_description:A().optional(),error_uri:A().optional()}),gi=J.optional().or(E(``).transform(()=>void 0)),_i=M({redirect_uris:O(J),token_endpoint_auth_method:A().optional(),grant_types:O(A()).optional(),response_types:O(A()).optional(),application_type:A().optional(),client_name:A().optional(),client_uri:J.optional(),logo_uri:gi,scope:A().optional(),contacts:O(A()).optional(),tos_uri:gi,policy_uri:A().optional(),jwks_uri:J.optional(),jwks:Ce().optional(),software_id:A().optional(),software_version:A().optional(),software_statement:A().optional()}).strip(),vi=M({client_id:A(),client_secret:A().optional(),client_id_issued_at:x().optional(),client_secret_expires_at:x().optional(),issuer:A().optional().catch(void 0)}).strip(),yi=_i.merge(vi),bi=M({error:A(),error_description:A().optional()}).strip(),xi=M({token:A(),token_type_hint:A().optional()}).strip()})))()}function Ci(){return(Ci=e((()=>{Si()})))()}function wi(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,Qa,{value:n,enumerable:!1,configurable:!0})}function Ti(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Qa)){let n=t[Qa];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}function Ei(e){return e>=$a}function Di(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 Oi(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||eo.some(t=>t in e)?e:{...e,content:[]}}function ki(){let e=Fe(()=>k([A(),x(),j(),De(),S(A(),e),O(e)])),t=S(A(),e),n=k([A(),x().int()]),r=A(),i=M({ttl:x().optional()}),a=M({taskId:A()}),o=N({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=M({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=M({method:A(),params:s.loose().optional()}),u=M({_meta:o.optional()}),d=M({method:A(),params:u.loose().optional()}),f=N({_meta:o.optional()}),p=k([A(),x().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:A().optional()}),g=d.extend({method:E(`notifications/cancelled`),params:h}),_=M({src:A(),mimeType:A().optional(),sizes:O(A()).optional(),theme:D([`light`,`dark`]).optional()}),v=M({icons:O(_).optional()}),y=M({name:A(),title:A().optional()}),ee=y.extend({...y.shape,...v.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),te=Pe(M({applyDefaults:j().optional()}),t),ne=me(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Pe(M({form:te.optional(),url:t.optional()}),t.optional())),re=N({list:t.optional(),cancel:t.optional(),requests:N({sampling:N({createMessage:t.optional()}).optional(),elicitation:N({create:t.optional()}).optional()}).optional()}),ie=N({list:t.optional(),cancel:t.optional(),requests:N({tools:N({call:t.optional()}).optional()}).optional()}),ae=M({experimental:S(A(),t).optional(),sampling:M({context:t.optional(),tools:t.optional()}).optional(),elicitation:ne.optional(),roots:M({listChanged:j().optional()}).optional(),tasks:re.optional(),extensions:S(A(),t).optional()}),oe=s.extend({protocolVersion:A(),capabilities:ae,clientInfo:ee}),se=l.extend({method:E(`initialize`),params:oe}),ce=M({experimental:S(A(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:M({listChanged:j().optional()}).optional(),resources:M({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:M({listChanged:j().optional()}).optional(),tasks:ie.optional(),extensions:S(A(),t).optional()}),b=f.extend({protocolVersion:A(),capabilities:ce,serverInfo:ee,instructions:A().optional()}),le=d.extend({method:E(`notifications/initialized`),params:u.optional()}),ue=l.extend({method:E(`ping`),params:s.optional()}),de=M({progress:x(),total:w(x()),message:w(A())}),fe=M({...u.shape,...de.shape,progressToken:n}),pe=d.extend({method:E(`notifications/progress`),params:fe}),he=s.extend({cursor:r.optional()}),ge=l.extend({params:he.optional()}),_e=f.extend({nextCursor:r.optional()}),ve=M({uri:A(),mimeType:w(A()),_meta:S(A(),C()).optional()}),ye=ve.extend({text:A()}),be=A().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),xe=ve.extend({blob:be}),T=D([`user`,`assistant`]),Se=M({audience:O(T).optional(),priority:x().min(0).max(1).optional(),lastModified:Ee({offset:!0}).optional()}),Ce=M({...y.shape,...v.shape,uri:A(),description:w(A()),mimeType:w(A()),size:w(x()),annotations:Se.optional(),_meta:w(N({}))}),we=M({...y.shape,...v.shape,uriTemplate:A(),description:w(A()),mimeType:w(A()),annotations:Se.optional(),_meta:w(N({}))}),Oe=ge.extend({method:E(`resources/list`)}),ke=_e.extend({resources:O(Ce)}),Ae=ge.extend({method:E(`resources/templates/list`)}),je=_e.extend({resourceTemplates:O(we)}),Me=s.extend({uri:A()}),Ne=Me,Ie=l.extend({method:E(`resources/read`),params:Ne}),Le=f.extend({contents:O(k([ye,xe]))}),Re=d.extend({method:E(`notifications/resources/list_changed`),params:u.optional()}),ze=Me,Be=l.extend({method:E(`resources/subscribe`),params:ze}),Ve=Me,He=l.extend({method:E(`resources/unsubscribe`),params:Ve}),Ue=u.extend({uri:A()}),We=d.extend({method:E(`notifications/resources/updated`),params:Ue}),Ge=M({name:A(),description:w(A()),required:w(j())}),Ke=M({...y.shape,...v.shape,description:w(A()),arguments:w(O(Ge)),_meta:w(N({}))}),qe=ge.extend({method:E(`prompts/list`)}),Je=_e.extend({prompts:O(Ke)}),Ye=s.extend({name:A(),arguments:S(A(),A()).optional()}),Xe=l.extend({method:E(`prompts/get`),params:Ye}),Ze=M({type:E(`text`),text:A(),annotations:Se.optional(),_meta:S(A(),C()).optional()}),Qe=M({type:E(`image`),data:be,mimeType:A(),annotations:Se.optional(),_meta:S(A(),C()).optional()}),$e=M({type:E(`audio`),data:be,mimeType:A(),annotations:Se.optional(),_meta:S(A(),C()).optional()}),et=M({type:E(`tool_use`),name:A(),id:A(),input:S(A(),C()),_meta:S(A(),C()).optional()}),tt=M({type:E(`resource`),resource:k([ye,xe]),annotations:Se.optional(),_meta:S(A(),C()).optional()}),nt=Ce.extend({type:E(`resource_link`)}),rt=k([Ze,Qe,$e,nt,tt]),it=M({role:T,content:rt}),at=f.extend({description:A().optional(),messages:O(it)}),ot=d.extend({method:E(`notifications/prompts/list_changed`),params:u.optional()}),st=M({title:A().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),ct=M({taskSupport:D([`required`,`optional`,`forbidden`]).optional()}),lt=M({...y.shape,...v.shape,description:A().optional(),inputSchema:M({type:E(`object`),properties:S(A(),e).optional(),required:O(A()).optional()}).catchall(C()),outputSchema:M({type:E(`object`),properties:S(A(),e).optional(),required:O(A()).optional()}).catchall(C()).optional(),annotations:st.optional(),execution:ct.optional(),_meta:S(A(),C()).optional()}),ut=ge.extend({method:E(`tools/list`)}),dt=_e.extend({tools:O(lt)}),ft=f.extend({content:O(rt),structuredContent:S(A(),C()).optional(),isError:j().optional()}),pt=c.extend({name:A(),arguments:S(A(),C()).optional()}),mt=l.extend({method:E(`tools/call`),params:pt}),ht=d.extend({method:E(`notifications/tools/list_changed`),params:u.optional()}),P=D([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),F=s.extend({level:P}),gt=l.extend({method:E(`logging/setLevel`),params:F}),_t=u.extend({level:P,logger:A().optional(),data:C()}),vt=d.extend({method:E(`notifications/message`),params:_t}),yt=M({name:A().optional()}),bt=M({hints:O(yt).optional(),costPriority:x().min(0).max(1).optional(),speedPriority:x().min(0).max(1).optional(),intelligencePriority:x().min(0).max(1).optional()}),I=M({mode:D([`auto`,`required`,`none`]).optional()}),xt=M({type:E(`tool_result`),toolUseId:A().describe(`The unique identifier for the corresponding tool call.`),content:O(rt),structuredContent:M({}).loose().optional(),isError:j().optional(),_meta:S(A(),C()).optional()}),L=Te(`type`,[Ze,Qe,$e]),R=Te(`type`,[Ze,Qe,$e,et,xt]),z=M({role:T,content:k([R,O(R)]),_meta:S(A(),C()).optional()}),St=c.extend({messages:O(z),modelPreferences:bt.optional(),systemPrompt:A().optional(),includeContext:D([`none`,`thisServer`,`allServers`]).optional(),temperature:x().optional(),maxTokens:x().int(),stopSequences:O(A()).optional(),metadata:t.optional(),tools:O(lt).optional(),toolChoice:I.optional()}),B=l.extend({method:E(`sampling/createMessage`),params:St}),Ct=f.extend({model:A(),stopReason:w(D([`endTurn`,`stopSequence`,`maxTokens`]).or(A())),role:T,content:L}),wt=f.extend({model:A(),stopReason:w(D([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(A())),role:T,content:k([R,O(R)])}),Tt=M({type:E(`boolean`),title:A().optional(),description:A().optional(),default:j().optional()}),Et=M({type:E(`string`),title:A().optional(),description:A().optional(),minLength:x().optional(),maxLength:x().optional(),format:D([`email`,`uri`,`date`,`date-time`]).optional(),default:A().optional()}),Dt=M({type:D([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:x().optional(),maximum:x().optional(),default:x().optional()}),Ot=M({type:E(`string`),title:A().optional(),description:A().optional(),enum:O(A()),default:A().optional()}),kt=M({type:E(`string`),title:A().optional(),description:A().optional(),oneOf:O(M({const:A(),title:A()})),default:A().optional()}),At=M({type:E(`string`),title:A().optional(),description:A().optional(),enum:O(A()),enumNames:O(A()).optional(),default:A().optional()}),jt=k([Ot,kt]),Mt=M({type:E(`array`),title:A().optional(),description:A().optional(),minItems:x().optional(),maxItems:x().optional(),items:M({type:E(`string`),enum:O(A())}),default:O(A()).optional()}),Nt=M({type:E(`array`),title:A().optional(),description:A().optional(),minItems:x().optional(),maxItems:x().optional(),items:M({anyOf:O(M({const:A(),title:A()}))}),default:O(A()).optional()}),Pt=k([Mt,Nt]),Ft=k([At,jt,Pt]),V=k([Ft,Tt,Et,Dt]),It=c.extend({mode:E(`form`).optional(),message:A(),requestedSchema:M({type:E(`object`),properties:S(A(),V),required:O(A()).optional()}).catchall(C())}),Lt=c.extend({mode:E(`url`),message:A(),elicitationId:A(),url:A().url()}),Rt=k([It,Lt]),H=l.extend({method:E(`elicitation/create`),params:Rt}),U=u.extend({elicitationId:A()}),zt=d.extend({method:E(`notifications/elicitation/complete`),params:U}),W=f.extend({action:D([`accept`,`decline`,`cancel`]),content:me(e=>e===null?void 0:e,S(A(),k([A(),x(),j(),O(A())])).optional())}),Bt=M({type:E(`ref/resource`),uri:A()}),Vt=M({type:E(`ref/prompt`),name:A()}),Ht=s.extend({ref:k([Vt,Bt]),argument:M({name:A(),value:A()}),context:M({arguments:S(A(),A()).optional()}).optional()}),Ut=l.extend({method:E(`completion/complete`),params:Ht}),Wt=f.extend({completion:N({values:O(A()).max(100),total:w(x().int()),hasMore:w(j())})}),Gt=M({uri:A().startsWith(`file://`),name:A().optional(),_meta:S(A(),C()).optional()}),Kt=l.extend({method:E(`roots/list`),params:s.optional()}),qt=f.extend({roots:O(Gt)}),Jt=d.extend({method:E(`notifications/roots/list_changed`),params:u.optional()}),Yt=N({ttl:x().optional(),pollInterval:x().optional()}),Xt=D([`working`,`input_required`,`completed`,`failed`,`cancelled`]),G=M({taskId:A(),status:Xt,ttl:k([x(),De()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:w(x()),statusMessage:w(A())}),Zt=f.extend({task:G}),Qt=u.merge(G),$t=d.extend({method:E(`notifications/tasks/status`),params:Qt}),en=l.extend({method:E(`tasks/get`),params:s.extend({taskId:A()})}),K=f.merge(G),tn=l.extend({method:E(`tasks/result`),params:s.extend({taskId:A()})}),nn=f.loose(),rn=ge.extend({method:E(`tasks/list`)}),an=_e.extend({tasks:O(G)}),on=l.extend({method:E(`tasks/cancel`),params:s.extend({taskId:A()})});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:b,InitializedNotificationSchema:le,PingRequestSchema:ue,ProgressSchema:de,ProgressNotificationParamsSchema:fe,ProgressNotificationSchema:pe,PaginatedRequestParamsSchema:he,PaginatedRequestSchema:ge,PaginatedResultSchema:_e,ResourceContentsSchema:ve,TextResourceContentsSchema:ye,BlobResourceContentsSchema:xe,RoleSchema:T,AnnotationsSchema:Se,ResourceSchema:Ce,ResourceTemplateSchema:we,ListResourcesRequestSchema:Oe,ListResourcesResultSchema:ke,ListResourceTemplatesRequestSchema:Ae,ListResourceTemplatesResultSchema:je,ResourceRequestParamsSchema:Me,ReadResourceRequestParamsSchema:Ne,ReadResourceRequestSchema:Ie,ReadResourceResultSchema:Le,ResourceListChangedNotificationSchema:Re,SubscribeRequestParamsSchema:ze,SubscribeRequestSchema:Be,UnsubscribeRequestParamsSchema:Ve,UnsubscribeRequestSchema:He,ResourceUpdatedNotificationParamsSchema:Ue,ResourceUpdatedNotificationSchema:We,PromptArgumentSchema:Ge,PromptSchema:Ke,ListPromptsRequestSchema:qe,ListPromptsResultSchema:Je,GetPromptRequestParamsSchema:Ye,GetPromptRequestSchema:Xe,TextContentSchema:Ze,ImageContentSchema:Qe,AudioContentSchema:$e,ToolUseContentSchema:et,EmbeddedResourceSchema:tt,ResourceLinkSchema:nt,ContentBlockSchema:rt,PromptMessageSchema:it,GetPromptResultSchema:at,PromptListChangedNotificationSchema:ot,ToolAnnotationsSchema:st,ToolExecutionSchema:ct,ToolSchema:lt,ListToolsRequestSchema:ut,ListToolsResultSchema:dt,CallToolResultSchema:ft,CallToolRequestParamsSchema:pt,CallToolRequestSchema:mt,ToolListChangedNotificationSchema:ht,LoggingLevelSchema:P,SetLevelRequestParamsSchema:F,SetLevelRequestSchema:gt,LoggingMessageNotificationParamsSchema:_t,LoggingMessageNotificationSchema:vt,ModelHintSchema:yt,ModelPreferencesSchema:bt,ToolChoiceSchema:I,ToolResultContentSchema:xt,SamplingContentSchema:L,SamplingMessageContentBlockSchema:R,SamplingMessageSchema:z,CreateMessageRequestParamsSchema:St,CreateMessageRequestSchema:B,CreateMessageResultSchema:Ct,CreateMessageResultWithToolsSchema:wt,BooleanSchemaSchema:Tt,StringSchemaSchema:Et,NumberSchemaSchema:Dt,UntitledSingleSelectEnumSchemaSchema:Ot,TitledSingleSelectEnumSchemaSchema:kt,LegacyTitledEnumSchemaSchema:At,SingleSelectEnumSchemaSchema:jt,UntitledMultiSelectEnumSchemaSchema:Mt,TitledMultiSelectEnumSchemaSchema:Nt,MultiSelectEnumSchemaSchema:Pt,EnumSchemaSchema:Ft,PrimitiveSchemaDefinitionSchema:V,ElicitRequestFormParamsSchema:It,ElicitRequestURLParamsSchema:Lt,ElicitRequestParamsSchema:Rt,ElicitRequestSchema:H,ElicitationCompleteNotificationParamsSchema:U,ElicitationCompleteNotificationSchema:zt,ElicitResultSchema:W,ResourceTemplateReferenceSchema:Bt,PromptReferenceSchema:Vt,CompleteRequestParamsSchema:Ht,CompleteRequestSchema:Ut,CompleteResultSchema:Wt,RootSchema:Gt,ListRootsRequestSchema:Kt,ListRootsResultSchema:qt,RootsListChangedNotificationSchema:Jt,TaskCreationParamsSchema:Yt,TaskStatusSchema:Xt,TaskSchema:G,CreateTaskResultSchema:Zt,TaskStatusNotificationParamsSchema:Qt,TaskStatusNotificationSchema:$t,GetTaskRequestSchema:en,GetTaskResultSchema:K,GetTaskPayloadRequestSchema:tn,GetTaskPayloadResultSchema:nn,ListTasksRequestSchema:rn,ListTasksResultSchema:an,CancelTaskRequestSchema:on,CancelTaskResultSchema:f.merge(G),ClientRequestSchema:k([ue,se,Ut,gt,Xe,qe,Oe,Ae,Ie,Be,He,mt,ut,en,tn,rn,on]),ClientNotificationSchema:k([g,pe,le,Jt,$t]),ClientResultSchema:k([m,Ct,wt,W,qt,K,an,Zt]),ServerRequestSchema:k([ue,B,H,Kt,en,tn,rn,on]),ServerNotificationSchema:k([g,pe,vt,We,Re,ht,ot,$t,zt]),ServerResultSchema:k([m,b,Wt,at,Je,ke,je,Le,ft,dt,K,an,Zt]),CallToolResultWireSchema:C().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of eo)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(Oi).pipe(ft)}}function Ai(){return to??=ki()}function ji(e){return e.type!==`object`}function Mi(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function Ni(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(Mi(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=rt(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&&Mi(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]=no.has(o)?s:ro.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 Pi(){if(so)return so;let e=Ai();return so={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}},so}function Fi(e){return Object.prototype.hasOwnProperty.call(io,e)}function Ii(e){return Object.prototype.hasOwnProperty.call(ao,e)}function Li(e){return Object.prototype.hasOwnProperty.call(oo,e)}function Ri(e){return Li(e)?Pi().resultSchemas[e]:void 0}function zi(e){return Fi(e)?Pi().requestSchemas[e]:void 0}function Bi(e){return Ii(e)?Pi().notificationSchemas[e]:void 0}function Vi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hi(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 Ui(e){return Vi(e)&&Vi(e.outputSchema)&&ji(e.outputSchema)}function Wi(e){return e}function Gi(){let e=Fe(()=>k([A(),x(),j(),De(),S(A(),e),O(e)])),t=S(A(),e),n=k([A(),x().int()]),r=A(),i=k([A(),x().int()]),a=D([`user`,`assistant`]),o=D([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=A().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=M({ttl:x().optional()}),l=M({taskId:A()}),u=N({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=M({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=M({_meta:u.optional()}),m=M({method:A(),params:p.loose().optional()}),h=M({src:A(),mimeType:A().optional(),sizes:O(A()).optional(),theme:D([`light`,`dark`]).optional()}),g=M({icons:O(h).optional()}),_=M({name:A(),title:A().optional()}),v=_.extend({..._.shape,...g.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),y=Pe(M({applyDefaults:j().optional()}),t),ee=me(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Pe(M({form:y.optional(),url:t.optional()}),t.optional())),te=N({list:t.optional(),cancel:t.optional(),requests:N({sampling:N({createMessage:t.optional()}).optional(),elicitation:N({create:t.optional()}).optional()}).optional()}),ne=N({list:t.optional(),cancel:t.optional(),requests:N({tools:N({call:t.optional()}).optional()}).optional()}),re=M({experimental:S(A(),t).optional(),sampling:M({context:t.optional(),tools:t.optional()}).optional(),elicitation:ee.optional(),roots:M({listChanged:j().optional()}).optional(),tasks:te.optional(),extensions:S(A(),t).optional()}),ie=M({experimental:S(A(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:M({listChanged:j().optional()}).optional(),resources:M({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:M({listChanged:j().optional()}).optional(),tasks:ne.optional(),extensions:S(A(),t).optional()}),ae=M({progress:x(),total:w(x()),message:w(A())}),oe=M({...p.shape,...ae.shape,progressToken:n}),se=m.extend({method:E(`notifications/progress`),params:oe}),ce=p.extend({level:o,logger:A().optional(),data:C()}),b=m.extend({method:E(`notifications/message`),params:ce}),le=M({uri:A(),mimeType:w(A()),_meta:S(A(),C()).optional()}),ue=le.extend({text:A()}),de=le.extend({blob:s}),fe=M({audience:O(a).optional(),priority:x().min(0).max(1).optional(),lastModified:Ee({offset:!0}).optional()}),pe=M({..._.shape,...g.shape,uri:A(),description:w(A()),mimeType:w(A()),size:w(x()),annotations:fe.optional(),_meta:w(N({}))}),he=M({..._.shape,...g.shape,uriTemplate:A(),description:w(A()),mimeType:w(A()),annotations:fe.optional(),_meta:w(N({}))}),ge=m.extend({method:E(`notifications/resources/list_changed`),params:p.optional()}),_e=p.extend({uri:A()}),ve=m.extend({method:E(`notifications/resources/updated`),params:_e}),ye=M({name:A(),description:w(A()),required:w(j())}),be=M({..._.shape,...g.shape,description:w(A()),arguments:w(O(ye)),_meta:w(N({}))}),xe=m.extend({method:E(`notifications/prompts/list_changed`),params:p.optional()}),T=M({type:E(`text`),text:A(),annotations:fe.optional(),_meta:S(A(),C()).optional()}),Se=M({type:E(`image`),data:s,mimeType:A(),annotations:fe.optional(),_meta:S(A(),C()).optional()}),Ce=M({type:E(`audio`),data:s,mimeType:A(),annotations:fe.optional(),_meta:S(A(),C()).optional()}),we=M({type:E(`tool_use`),name:A(),id:A(),input:S(A(),C()),_meta:S(A(),C()).optional()}),Te=M({type:E(`resource`),resource:k([ue,de]),annotations:fe.optional(),_meta:S(A(),C()).optional()}),Oe=pe.extend({type:E(`resource_link`)}),ke=k([T,Se,Ce,Oe,Te]),Ae=M({role:a,content:ke}),je=M({title:A().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),Me=m.extend({method:E(`notifications/tools/list_changed`),params:p.optional()}),Ne=M({name:A().optional()}),Ie=M({hints:O(Ne).optional(),costPriority:x().min(0).max(1).optional(),speedPriority:x().min(0).max(1).optional(),intelligencePriority:x().min(0).max(1).optional()}),Le=M({mode:D([`auto`,`required`,`none`]).optional()}),Re=M({type:E(`boolean`),title:A().optional(),description:A().optional(),default:j().optional()}),ze=M({type:E(`string`),title:A().optional(),description:A().optional(),minLength:x().optional(),maxLength:x().optional(),format:D([`email`,`uri`,`date`,`date-time`]).optional(),default:A().optional()}),Be=M({type:D([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:x().optional(),maximum:x().optional(),default:x().optional()}),Ve=M({type:E(`string`),title:A().optional(),description:A().optional(),enum:O(A()),default:A().optional()}),He=M({type:E(`string`),title:A().optional(),description:A().optional(),oneOf:O(M({const:A(),title:A()})),default:A().optional()}),Ue=M({type:E(`string`),title:A().optional(),description:A().optional(),enum:O(A()),enumNames:O(A()).optional(),default:A().optional()}),We=k([Ve,He]),Ge=M({type:E(`array`),title:A().optional(),description:A().optional(),minItems:x().optional(),maxItems:x().optional(),items:M({type:E(`string`),enum:O(A())}),default:O(A()).optional()}),Ke=M({type:E(`array`),title:A().optional(),description:A().optional(),minItems:x().optional(),maxItems:x().optional(),items:M({anyOf:O(M({const:A(),title:A()}))}),default:O(A()).optional()}),qe=k([Ge,Ke]),Je=k([Ue,We,qe]),Ye=k([Je,Re,ze,Be]),Xe=f.extend({mode:E(`form`).optional(),message:A(),requestedSchema:M({type:E(`object`),properties:S(A(),Ye),required:O(A()).optional()}).catchall(C())}),Ze=M({type:E(`ref/resource`),uri:A()}),Qe=M({type:E(`ref/prompt`),name:A()}),$e=M({uri:A().startsWith(`file://`),name:A().optional(),_meta:S(A(),C()).optional()}),et=re.shape,tt=M({experimental:et.experimental,sampling:et.sampling,elicitation:et.elicitation,roots:et.roots,extensions:et.extensions}),nt=ie.shape,rt=M({experimental:nt.experimental,logging:nt.logging,completions:nt.completions,prompts:nt.prompts,resources:nt.resources,tools:nt.tools,extensions:nt.extensions}),it=N({progressToken:n.optional(),[lt]:A(),[ut]:v.optional(),[ft]:tt,[mt]:o.optional()}),at=M({..._.shape,...g.shape,description:A().optional(),inputSchema:N({$schema:A().optional(),type:E(`object`)}),outputSchema:N({$schema:A().optional()}).optional(),annotations:je.optional(),_meta:S(A(),C()).optional()}),ot=M({type:E(`tool_result`),toolUseId:A(),content:O(ke),structuredContent:C().optional(),isError:j().optional(),_meta:S(A(),C()).optional()}),st=k([T,Se,Ce,we,ot]),ct=M({role:a,content:k([st,O(st)]),_meta:S(A(),C()).optional()}),pt=A(),ht=N({[dt]:v.optional().catch(void 0)}),P=ht.optional();function F(e){return N({_meta:P,resultType:pt.default(`complete`),...e})}let gt=F({}),_t=F({nextCursor:r.optional()}),vt=F({content:O(ke),structuredContent:C().optional(),isError:j().optional()}),yt=F({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),tools:O(at),nextCursor:r.optional()}),bt=F({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),prompts:O(be),nextCursor:r.optional()}),I=F({description:A().optional(),messages:O(Ae)}),xt=F({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),resources:O(pe),nextCursor:r.optional()}),L=F({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),resourceTemplates:O(he),nextCursor:r.optional()}),R=F({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),contents:O(k([ue,de]))}),z=F({completion:M({values:O(A()).max(100),total:x().int().optional(),hasMore:j().optional()}).loose()}),St=F({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`])}),B=F({ttlMs:x().int().min(0).catch(0),cacheScope:D([`public`,`private`]).catch(`private`),supportedVersions:O(A()),capabilities:rt,instructions:A().optional()}),Ct=M({messages:O(ct),modelPreferences:Ie.optional(),systemPrompt:A().optional(),includeContext:D([`none`,`thisServer`,`allServers`]).optional(),temperature:x().optional(),maxTokens:x().int(),stopSequences:O(A()).optional(),metadata:t.optional(),tools:O(at).optional(),toolChoice:Le.optional()}),wt=M({method:E(`sampling/createMessage`),params:Ct}),Tt=M({method:E(`roots/list`),params:M({_meta:S(A(),C()).optional()}).optional()}),Et=M({...ct.shape,model:A(),stopReason:A().optional()}),Dt=M({roots:O($e)}),Ot=M({action:D([`accept`,`decline`,`cancel`]),content:S(A(),k([A(),x(),j(),O(A())])).optional()}),kt=M({mode:E(`url`),message:A(),url:A().url()}),At=k([Xe,kt]),jt=M({method:E(`elicitation/create`),params:At}),Mt=k([wt,Tt,jt]),Nt=k([Et,Dt,Ot]),Pt=S(A(),Mt),Ft=S(A(),Nt),V=F({inputRequests:Pt.optional(),requestState:A().optional()}),It={inputResponses:Ft.optional(),requestState:A().optional()},Lt=M({_meta:it,...It}),Rt=N({progressToken:n.optional()});function H(e,t){return M({method:E(e),params:M({_meta:it,...t})})}function U(e,t){return M({method:E(e),params:M({_meta:Rt.optional(),...t}).optional()})}let zt={name:A(),arguments:S(A(),C()).optional(),...It},W={cursor:r.optional()},Bt=H(`tools/call`,zt),Vt=H(`tools/list`,W),Ht=H(`prompts/list`,W),Ut=H(`prompts/get`,{name:A(),arguments:S(A(),A()).optional(),...It}),Wt=H(`resources/list`,W),Gt=H(`resources/templates/list`,W),Kt=H(`resources/read`,{uri:A(),...It}),qt={ref:k([Qe,Ze]),argument:M({name:A(),value:A()}),context:M({arguments:S(A(),A()).optional()}).optional()},Jt=H(`completion/complete`,qt),Yt=H(`server/discover`,{}),Xt=M({toolsListChanged:j().optional(),promptsListChanged:j().optional(),resourcesListChanged:j().optional(),resourceSubscriptions:O(A()).optional()}),G={notifications:Xt},Zt=H(`subscriptions/listen`,G),Qt=ht.extend({"io.modelcontextprotocol/subscriptionId":i}),$t=N({_meta:Qt,resultType:pt.default(`complete`)}),en={"tools/call":U(`tools/call`,zt),"tools/list":U(`tools/list`,W),"prompts/get":U(`prompts/get`,{name:A(),arguments:S(A(),A()).optional()}),"prompts/list":U(`prompts/list`,W),"resources/list":U(`resources/list`,W),"resources/templates/list":U(`resources/templates/list`,W),"resources/read":U(`resources/read`,{uri:A()}),"completion/complete":U(`completion/complete`,qt),"server/discover":U(`server/discover`,{}),"subscriptions/listen":U(`subscriptions/listen`,G)};function K(e){return N({_meta:P,...e})}let tn={"tools/call":K({content:O(ke),structuredContent:C().optional(),isError:j().optional()}),"tools/list":K({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),tools:O(at),nextCursor:r.optional()}),"prompts/get":K({description:A().optional(),messages:O(Ae)}),"prompts/list":K({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),prompts:O(be),nextCursor:r.optional()}),"resources/list":K({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),resources:O(pe),nextCursor:r.optional()}),"resources/templates/list":K({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),resourceTemplates:O(he),nextCursor:r.optional()}),"resources/read":K({ttlMs:x().int().min(0),cacheScope:D([`public`,`private`]),contents:O(k([ue,de]))}),"completion/complete":K({completion:M({values:O(A()).max(100),total:x().int().optional(),hasMore:j().optional()}).loose()}),"server/discover":K({ttlMs:x().int().min(0).catch(0),cacheScope:D([`public`,`private`]).catch(`private`),supportedVersions:O(A()),capabilities:rt,instructions:A().optional()}),"subscriptions/listen":K({})},nn=N({"io.modelcontextprotocol/subscriptionId":i.optional()}),rn=M({method:E(`notifications/subscriptions/acknowledged`),params:M({_meta:nn.optional(),notifications:Xt})}),an=M({_meta:nn.optional(),requestId:i,reason:A().optional()}),on=M({method:E(`notifications/cancelled`),params:an}),sn={"notifications/cancelled":on,"notifications/progress":se,"notifications/message":b,"notifications/resources/updated":ve,"notifications/resources/list_changed":ge,"notifications/tools/list_changed":Me,"notifications/prompts/list_changed":xe,"notifications/subscriptions/acknowledged":rn},q=e=>M({jsonrpc:E(`2.0`),id:k([A(),x().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:b,ResourceContentsSchema:le,TextResourceContentsSchema:ue,BlobResourceContentsSchema:de,AnnotationsSchema:fe,ResourceSchema:pe,ResourceTemplateSchema:he,ResourceListChangedNotificationSchema:ge,ResourceUpdatedNotificationParamsSchema:_e,ResourceUpdatedNotificationSchema:ve,PromptArgumentSchema:ye,PromptSchema:be,PromptListChangedNotificationSchema:xe,TextContentSchema:T,ImageContentSchema:Se,AudioContentSchema:Ce,ToolUseContentSchema:we,EmbeddedResourceSchema:Te,ResourceLinkSchema:Oe,ContentBlockSchema:ke,PromptMessageSchema:Ae,ToolAnnotationsSchema:je,ToolListChangedNotificationSchema:Me,ModelHintSchema:Ne,ModelPreferencesSchema:Ie,ToolChoiceSchema:Le,BooleanSchemaSchema:Re,StringSchemaSchema:ze,NumberSchemaSchema:Be,UntitledSingleSelectEnumSchemaSchema:Ve,TitledSingleSelectEnumSchemaSchema:He,LegacyTitledEnumSchemaSchema:Ue,SingleSelectEnumSchemaSchema:We,UntitledMultiSelectEnumSchemaSchema:Ge,TitledMultiSelectEnumSchemaSchema:Ke,MultiSelectEnumSchemaSchema:qe,EnumSchemaSchema:Je,PrimitiveSchemaDefinitionSchema:Ye,ElicitRequestFormParamsSchema:Xe,ResourceTemplateReferenceSchema:Ze,PromptReferenceSchema:Qe,RootSchema:$e,ClientCapabilities2026Schema:tt,ServerCapabilities2026Schema:rt,RequestMetaEnvelopeSchema:it,ToolSchema:at,ToolResultContentSchema:ot,SamplingMessageContentBlockSchema:st,SamplingMessageSchema:ct,ResultTypeSchema:pt,ResultMetaSchema:ht,ResultSchema:gt,PaginatedResultSchema:_t,CallToolResultSchema:vt,ListToolsResultSchema:yt,ListPromptsResultSchema:bt,GetPromptResultSchema:I,ListResourcesResultSchema:xt,ListResourceTemplatesResultSchema:L,ReadResourceResultSchema:R,CompleteResultSchema:z,CacheableResultSchema:St,DiscoverResultSchema:B,CreateMessageRequestParamsSchema:Ct,CreateMessageRequestSchema:wt,ListRootsRequestSchema:Tt,CreateMessageResultSchema:Et,ListRootsResultSchema:Dt,ElicitResultSchema:Ot,ElicitRequestURLParamsSchema:kt,ElicitRequestParamsSchema:At,ElicitRequestSchema:jt,InputRequestSchema:Mt,InputResponseSchema:Nt,InputRequestsSchema:Pt,InputResponsesSchema:Ft,InputRequiredResultSchema:V,InputResponseRequestParamsSchema:Lt,CallToolRequestSchema:Bt,ListToolsRequestSchema:Vt,ListPromptsRequestSchema:Ht,GetPromptRequestSchema:Ut,ListResourcesRequestSchema:Wt,ListResourceTemplatesRequestSchema:Gt,ReadResourceRequestSchema:Kt,CompleteRequestSchema:Jt,DiscoverRequestSchema:Yt,SubscriptionFilterSchema:Xt,SubscriptionsListenRequestSchema:Zt,SubscriptionsListenResultMetaSchema:Qt,SubscriptionsListenResultSchema:$t,dispatchRequestSchemas:en,dispatchResultSchemas:tn,NotificationMetaSchema:nn,SubscriptionsAcknowledgedNotificationSchema:rn,CancelledNotificationParamsSchema:an,CancelledNotificationSchema:on,notificationSchemas2026:sn,JSONRPCResultResponseSchema:q(gt),CallToolResultResponseSchema:q(k([vt,V])),ListToolsResultResponseSchema:q(yt),ListPromptsResultResponseSchema:q(bt),GetPromptResultResponseSchema:q(k([I,V])),ListResourcesResultResponseSchema:q(xt),ListResourceTemplatesResultResponseSchema:q(L),ReadResourceResultResponseSchema:q(k([R,V])),CompleteResultResponseSchema:q(z),DiscoverResultResponseSchema:q(B),SubscriptionsListenResultResponseSchema:q($t)}}function Ki(){return uo??=Gi()}function qi(e){return fo.includes(e)}function Ji(e){return e[po]}function Yi(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Xi(e){return e===`public`||e===`private`}function Zi(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||bo.includes(e))return t;throw new Q(Z.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Qi(e,t){let n=Ji(t);if(t.resultType!==`complete`||!qi(e))return n===void 0?t:ra(t);let r=t,i=Yi(r.ttlMs)?r.ttlMs:ta(n),a=Xi(r.cacheScope)?r.cacheScope:na(n),o={...r,ttlMs:i,cacheScope:a};return delete o[po],o}function $i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ea(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[dt]:t}}:!$i(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[dt]:t}}}function ta(e){return e!==void 0&&Yi(e.ttlMs)?e.ttlMs:vo}function na(e){return e!==void 0&&Xi(e.cacheScope)?e.cacheScope:yo}function ra(e){let t={...e};return delete t[po],t}function ia(){if(So)return So;let e=Ki();return So={request:{"elicitation/create":M({method:E(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":M({method:E(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":M({method:E(`roots/list`),params:N({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},So}function aa(e){return xo.includes(e)}function oa(e){return aa(e)?ia().request[e]:void 0}function sa(e){return aa(e)?ia().response[e]:void 0}function ca(e){return Object.prototype.hasOwnProperty.call(Co,e)}function la(e){return Object.prototype.hasOwnProperty.call(wo,e)}function ua(e){return Object.prototype.hasOwnProperty.call(Co,e)}function da(e){return ca(e)?Ki().dispatchRequestSchemas[e]:void 0}function fa(e){return ua(e)?Ki().dispatchResultSchemas[e]:void 0}function pa(e){return la(e)?Ki().notificationSchemas2026[e]:void 0}function ma(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ha(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 ga(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=>ma(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!ma(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(ma(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}function _a(){if(Oo)return Oo;let e=Ki();return Oo={"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},Oo}function va(e){return e!==void 0&&Ei(e)?Do:lo}function ya(e){return e.revision===void 0?e.era===`modern`?Do.era:lo.era:va(e.revision).era}function ba(e){return Ao.some(t=>t.hasRequestMethod(e))}function xa(e){return Ao.some(t=>t.hasNotificationMethod(e))}function Sa(e){return e===`tasks/get`||e===`tasks/cancel`}function Ca(e,t){return he(e,t)}function wa(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function Ta(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 Ea(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:Lo});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().`);Io||(Io=!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=_e(e,{target:Lo,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&&Da(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 Da(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`||Da(e)))}return!1}function Oa(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function ka(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>Oa(e)).join(`, `)}:{success:!0,data:n.value}}function Aa(e){let t=_e(e,{target:Lo,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}function ja(e){let t=Ro.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=>Ee({local:e,offset:t,precision:n}))))}function Ma(e,t){let n;switch(e){case`email`:n=[we()];break;case`uri`:n=[ve()];break;case`date`:n=[Ae()];break;case`date-time`:n=ja(t)}return new Set(n.map(e=>Aa(e)).filter(e=>e!==void 0))}function Na(e,t,n){return n!==`zod`||Ma(e,t).has(t)}function Pa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fa(e){try{return Ea(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Q(Z.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}function Ia(e){return zo.has(e)||e.startsWith(`x-`)}function La(e,t,n,r){if(!Pa(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(Vo,e.type)?Vo[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||Ia(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?Ho.has(e.format)?(typeof s!=`string`||!Na(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function Ra(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&Pa(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,La(n,`properties.${e}`,t,r)])):Bo.has(i)?n[i]=a:Ia(i)||r.push(i);if(r.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function za(e,t){if(!Pa(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!Ca(Er,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}]`)):!Pa(e)||!Pa(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):Ia(e)?[]:[i]})}function Va(e){if(!Ta(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=Ra(Fa(e.requestedSchema),t),r=Ca(Dr.shape.requestedSchema,n);if(!r.success)throw new Q(Z.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${za(n,r.error.message)}`);let i=Ba(n,r.data);if(i.length>0)throw new Q(Z.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(Z.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function Ha(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 Ua(e,t){let n=e.slice(0,-6);Go[n]=t,Ko[n]=e=>t.safeParse(e).success}function Wa(e){switch(e){case`initialize`:case`notifications/initialized`:return va(void 0);case`server/discover`:return va(ko);default:return}}function Ga(e,t){let n=e.params;if(!Ja(n))return{message:e,lifted:{}};let r=n._meta,i=Ja(r)?Jo.filter(e=>e in r):[],a=t===`request`?Yo.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&Ja(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 Ka(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 qa(e){return()=>e}function Ja(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ya(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xa(e){let t={},n=[];if(!Ya(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!Ya(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function Za(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var Qa,Y,X,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,Z,Q,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo;function Qo(){return(Qo=e((()=>{nt(),at(),Ci(),T(),Se(),ye(),ge(),Qa=Symbol.for(`mcp.sdk.errorBrands`),class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return Ti(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 Ti(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,wi(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)}},Y=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}({}),X=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Ti(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 Ti(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,wi(this,new.target)}},class extends X{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}},$a=`2026-07-28`,eo=[`task`,`inputRequests`,`requestState`],no=new Set([`const`,`enum`,`default`,`examples`]),ro=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]),io={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},ao={"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},oo={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(io),Object.keys(ao),co={ok:!1,reason:`not-in-era`},lo={era:`2025-11-25`,hasRequestMethod:Fi,hasNotificationMethod:Ii,validateRequest:(e,t)=>Hi(zi(e),t),validateResult:(e,t)=>Hi(Ri(e),t),validateNotification:(e,t)=>Hi(Bi(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>co,validateInputResponse:()=>co,samplingResultVariant:((e,t)=>{let n=Ai();return Hi(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=Di(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&ji(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(Vi(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Wi(e)}}return{kind:`complete`,result:Wi(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>Ui(e))?t:{...t,tools:n.map(e=>Ui(e)?{...e,outputSchema:Ni(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0},fo=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`],po=Symbol(`modelcontextprotocol.resultCacheHintFallback`),Z=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}({}),Q=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Ti(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 Ti(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,wi(this,new.target)}static fromError(t,n,r){if(t===Z.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new ho(e.elicitations,n)}if(t===Z.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new go({supported:e.supported,requested:e.requested},n)}if(t===Z.InvalidParams||t===Z.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===Z.ResourceNotFound||Object.keys(e).length===1))return new mo(e.uri,n)}if(t===Z.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new _o({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},mo=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(Z.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},ho=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Z.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},go=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Z.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},_o=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(Z.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},vo=0,yo=`private`,bo=[`tools/call`,`prompts/get`,`resources/read`],xo=[`elicitation/create`,`sampling/createMessage`,`roots/list`],Co={"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},wo={"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(Co),Object.keys(wo),To={ok:!1,reason:`not-in-era`},Eo=[lt,ft],Do={era:`2026-07-28`,hasRequestMethod:ca,hasNotificationMethod:la,hasInputRequestMethod:e=>oa(e)!==void 0,validateRequest:(e,t)=>ha(da(e),t),validateResult:(e,t)=>ha(fa(e),t),validateNotification:(e,t)=>ha(pa(e),t),validateInputRequest:(e,t)=>ha(oa(e),t),validateInputResponse:(e,t)=>ha(sa(e),t),samplingResultVariant:()=>To,outboundEnvelope(e){return{[lt]:e.protocolVersion,[ut]:e.clientInfo,[ft]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of Eo)n in e||t.push({key:n,problem:`missing`});let n=Ki().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=>Di(e),inputRequestSchema:oa,decodeResult(e,t){if(!ma(t))return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new X(Y.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 X(Y.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=ma(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:Ki().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new X(Y.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 X(Y.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=_a(),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 X(Y.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 ea(Qi(e,Zi(e,ga(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=Ki().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(`; `)}`}},ko=`2026-07-28`,Ao=[lo,Do],jo=tt({AnnotationsSchema:()=>tn,AudioContentSchema:()=>Pn,BaseMetadataSchema:()=>Ft,BaseRequestParamsSchema:()=>I,BlobResourceContentsSchema:()=>en,BooleanSchemaSchema:()=>hr,CallToolRequestParamsSchema:()=>Yn,CallToolRequestSchema:()=>Xn,CallToolResultSchema:()=>qn,CancelTaskRequestSchema:()=>ti,CancelTaskResultSchema:()=>ni,CancelledNotificationParamsSchema:()=>jt,CancelledNotificationSchema:()=>Mt,ClientCapabilitiesSchema:()=>U,ClientNotificationSchema:()=>ii,ClientRequestSchema:()=>ri,ClientResultSchema:()=>ai,ClientTasksCapabilitySchema:()=>Rt,CompatibilityCallToolResultSchema:()=>Jn,CompleteRequestParamsSchema:()=>Ir,CompleteRequestSchema:()=>Lr,CompleteResultSchema:()=>Rr,ContentBlockSchema:()=>Rn,CreateMessageRequestParamsSchema:()=>dr,CreateMessageRequestSchema:()=>fr,CreateMessageResultSchema:()=>pr,CreateMessageResultWithToolsSchema:()=>mr,CreateTaskResultSchema:()=>Kr,CursorSchema:()=>_t,DiscoverRequestSchema:()=>Ut,DiscoverResultSchema:()=>Wt,ElicitRequestFormParamsSchema:()=>Dr,ElicitRequestParamsSchema:()=>kr,ElicitRequestSchema:()=>Ar,ElicitRequestURLParamsSchema:()=>Or,ElicitResultSchema:()=>Nr,ElicitationCompleteNotificationParamsSchema:()=>jr,ElicitationCompleteNotificationSchema:()=>Mr,EmbeddedResourceSchema:()=>In,EmptyResultSchema:()=>At,EnumSchemaSchema:()=>Tr,GetPromptRequestParamsSchema:()=>An,GetPromptRequestSchema:()=>jn,GetPromptResultSchema:()=>Bn,GetTaskPayloadRequestSchema:()=>Zr,GetTaskPayloadResultSchema:()=>Qr,GetTaskRequestSchema:()=>Yr,GetTaskResultSchema:()=>Xr,IconSchema:()=>Nt,IconsSchema:()=>Pt,ImageContentSchema:()=>Nn,ImplementationSchema:()=>V,InitializeRequestParamsSchema:()=>zt,InitializeRequestSchema:()=>W,InitializeResultSchema:()=>Vt,InitializedNotificationSchema:()=>Ht,JSONArraySchema:()=>F,JSONObjectSchema:()=>P,JSONRPCErrorResponseSchema:()=>Dt,JSONRPCMessageSchema:()=>Ot,JSONRPCNotificationSchema:()=>Tt,JSONRPCRequestSchema:()=>wt,JSONRPCResponseSchema:()=>kt,JSONRPCResultResponseSchema:()=>Et,JSONValueSchema:()=>ht,LegacyTitledEnumSchemaSchema:()=>br,ListChangedOptionsBaseSchema:()=>Qn,ListPromptsRequestSchema:()=>On,ListPromptsResultSchema:()=>kn,ListResourceTemplatesRequestSchema:()=>sn,ListResourceTemplatesResultSchema:()=>q,ListResourcesRequestSchema:()=>an,ListResourcesResultSchema:()=>on,ListRootsRequestSchema:()=>Br,ListRootsResultSchema:()=>Vr,ListTasksRequestSchema:()=>$r,ListTasksResultSchema:()=>ei,ListToolsRequestSchema:()=>Gn,ListToolsResultSchema:()=>Kn,LoggingLevelSchema:()=>$n,LoggingMessageNotificationParamsSchema:()=>nr,LoggingMessageNotificationSchema:()=>rr,ModelHintSchema:()=>ir,ModelPreferencesSchema:()=>ar,MultiSelectEnumSchemaSchema:()=>wr,NotificationSchema:()=>z,NotificationsParamsSchema:()=>R,NumberSchemaSchema:()=>_r,PaginatedRequestParamsSchema:()=>Yt,PaginatedRequestSchema:()=>Xt,PaginatedResultSchema:()=>G,PingRequestSchema:()=>Gt,PrimitiveSchemaDefinitionSchema:()=>Er,ProgressNotificationParamsSchema:()=>qt,ProgressNotificationSchema:()=>Jt,ProgressSchema:()=>Kt,ProgressTokenSchema:()=>gt,PromptArgumentSchema:()=>En,PromptListChangedNotificationSchema:()=>Vn,PromptMessageSchema:()=>zn,PromptReferenceSchema:()=>Fr,PromptSchema:()=>Dn,ReadResourceRequestParamsSchema:()=>ln,ReadResourceRequestSchema:()=>un,ReadResourceResultSchema:()=>dn,RelatedTaskMetadataSchema:()=>yt,RequestIdSchema:()=>Ct,RequestMetaSchema:()=>bt,RequestSchema:()=>L,ResourceContentsSchema:()=>Zt,ResourceLinkSchema:()=>Ln,ResourceListChangedNotificationSchema:()=>fn,ResourceRequestParamsSchema:()=>cn,ResourceSchema:()=>nn,ResourceTemplateReferenceSchema:()=>Pr,ResourceTemplateSchema:()=>rn,ResourceUpdatedNotificationParamsSchema:()=>wn,ResourceUpdatedNotificationSchema:()=>Tn,ResultMetaObjectSchema:()=>St,ResultSchema:()=>B,RoleSchema:()=>K,RootSchema:()=>zr,RootsListChangedNotificationSchema:()=>Hr,SamplingContentSchema:()=>cr,SamplingMessageContentBlockSchema:()=>lr,SamplingMessageSchema:()=>ur,ServerCapabilitiesSchema:()=>Bt,ServerNotificationSchema:()=>si,ServerRequestSchema:()=>oi,ServerResultSchema:()=>ci,ServerTasksCapabilitySchema:()=>H,SetLevelRequestParamsSchema:()=>er,SetLevelRequestSchema:()=>tr,SingleSelectEnumSchemaSchema:()=>xr,StringSchemaSchema:()=>gr,SubscribeRequestParamsSchema:()=>pn,SubscribeRequestSchema:()=>mn,SubscriptionFilterSchema:()=>_n,SubscriptionsAcknowledgedNotificationParamsSchema:()=>bn,SubscriptionsAcknowledgedNotificationSchema:()=>xn,SubscriptionsListenRequestParamsSchema:()=>vn,SubscriptionsListenRequestSchema:()=>yn,SubscriptionsListenResultMetaSchema:()=>Sn,SubscriptionsListenResultSchema:()=>Cn,TaskAugmentedRequestParamsSchema:()=>xt,TaskCreationParamsSchema:()=>Ur,TaskMetadataSchema:()=>vt,TaskSchema:()=>Gr,TaskStatusNotificationParamsSchema:()=>qr,TaskStatusNotificationSchema:()=>Jr,TaskStatusSchema:()=>Wr,TextContentSchema:()=>Mn,TextResourceContentsSchema:()=>Qt,TitledMultiSelectEnumSchemaSchema:()=>Cr,TitledSingleSelectEnumSchemaSchema:()=>yr,ToolAnnotationsSchema:()=>Hn,ToolChoiceSchema:()=>or,ToolExecutionSchema:()=>Un,ToolListChangedNotificationSchema:()=>Zn,ToolResultContentSchema:()=>sr,ToolSchema:()=>Wn,ToolUseContentSchema:()=>Fn,UnsubscribeRequestParamsSchema:()=>hn,UnsubscribeRequestSchema:()=>gn,UntitledMultiSelectEnumSchemaSchema:()=>Sr,UntitledSingleSelectEnumSchemaSchema:()=>vr}),Mo=e=>wt.safeParse(e).success,No=e=>Tt.safeParse(e).success,Po=e=>Et.safeParse(e).success,Fo=e=>Dt.safeParse(e).success,Z.InvalidRequest,Z.UnsupportedProtocolVersion,Z.InvalidParams,Z.MethodNotFound,Z.InvalidParams,Z.MissingRequiredClientCapability,Z.ParseError,Z.InvalidRequest,Z.MethodNotFound,Z.UnsupportedProtocolVersion,Z.MissingRequiredClientCapability,Io=!1,Lo=`draft-2020-12`,Ro=/\\\.\\d\{(\d+)\}/,zo=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]),Bo=new Set([`$schema`,...Object.keys(Dr.shape.requestedSchema.shape)]),Vo={string:wa([gr,vr,yr,br]),number:wa([_r]),integer:wa([_r]),boolean:wa([hr]),array:wa([Sr,Cr])},Ho=new Set(gr.shape.format.unwrap().options),Object.assign(Ha,{elicit(e){try{return{method:`elicitation/create`,params:Va(e)}}catch(e){throw e instanceof Q?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`}}}),Uo=`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:mi,OAuthClientInformationFullSchema:yi,OAuthClientInformationSchema:vi,OAuthClientMetadataSchema:_i,OAuthClientRegistrationErrorSchema:bi,OAuthErrorResponseSchema:hi,OAuthMetadataSchema:ui,OAuthProtectedResourceMetadataSchema:li,OAuthTokenRevocationRequestSchema:xi,OAuthTokensSchema:pi,OpenIdProviderDiscoveryMetadataSchema:fi,OpenIdProviderMetadataSchema:di},Go={},Ko={};for(let e of Uo)Ua(e,jo[e]);for(let[e,t]of Object.entries(Wo))Ua(e,t);qo=Object.freeze(Go),Object.freeze(Ko),Jo=[lt,ut,ft,mt],Yo=[`inputResponses`,`requestState`],Xo=qa(void 0),Zo=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??st,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 X(Y.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 X(Y.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),Po(e)||Fo(e)?this._onresponse(e):Mo(e)?this._onrequest(e,t):No(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 X(Y.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}=Ga(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=ya(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(xa(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}=Ga(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=ya(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(Z.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(ba(n.method)&&!i.hasRequestMethod(n.method)&&!(Sa(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(Z.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Z.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(Z.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:Xa(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?Xo:qa(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Ta(t))return u(e,t,n);let i=Ka(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(Z.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:Z.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),Po(e)?n(e):n(Q.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(Ta(t))return Sa(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=Ka(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 va(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(ba(t)&&!e.hasRequestMethod(t))throw new X(Y.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 X?e:new X(Y.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 X?e:new X(Y.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(Za(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;ka(n,o).then(e=>{e.success?d(e.data):f(new X(Y.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 X(Y.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 X(Y.NotConnected,`Not connected`);if(xa(t.method)&&!e.hasNotificationMethod(t.method))throw new X(Y.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(!ba(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(Z.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 ka(t.params,{...r.params});if(!a.success)throw new Q(Z.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.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(!xa(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(Z.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 ka(t.params,{...r.params});if(!i.success)throw new Q(Z.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}},et((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 $o(e){return e.test.bind(e)}function es(e,t){let n=t.match(ts);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 ts,ns,rs,is,as,os,ss,cs,ls,us,ds;function fs(){return(fs=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`),ts=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,ns=/^(?=.{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,rs=/^(?:[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,is=/^(?:(?:[^\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,as=/^(?:(?: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,os=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,ss=/^(?:\/(?:[^~/]|~0|~1)*)*$/,cs=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,ls=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,us=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ds=/^((([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,es.bind(void 0,!1),$o(rs),$o(is),$o(as),$o(ns),$o(us),$o(ds),$o(os),$o(ss),$o(cs),$o(ls)})))()}function ps(){return(ps=e((()=>{fs()})))()}function ms(){return(ms=e((()=>{globalThis.crypto})))()}var hs;function gs(){return(gs=e((()=>{Qo(),ps(),ms(),hs=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthClientFlowError`})}static[Symbol.hasInstance](e){return Ti(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 Ti(this,e)}constructor(e){super(e),this.name=new.target.name,wi(this,new.target)}},class extends hs{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 hs{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 hs{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 hs{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 hs{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 Ti(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 Ti(this,e)}constructor(e){super(e??`Unauthorized`),this.name=`UnauthorizedError`,wi(this,new.target)}},class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SseError`})}static[Symbol.hasInstance](e){return Ti(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 Ti(this,e)}constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n,wi(this,new.target)}}})))()}function _s(){return(_s=e((()=>{Si()})))()}function vs(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`;Cs.has(o)||(Cs.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},ys(t)):e=>s({method:a,params:e})]}function ys(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 bs(e,t){return JSON.stringify(e)===JSON.stringify(t)}var xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc,nc;function rc(){return(rc=e((()=>{gs(),_s(),T(),xs=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}},Ss=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)}},Cs=new Set,ws=`2026-01-26`,Ts=k([E(`light`),E(`dark`)]).describe(`Color theme preference for the host environment.`),Es=k([E(`inline`),E(`fullscreen`),E(`pip`)]).describe(`Display mode for UI presentation.`),Ds=k([E(`--color-background-primary`),E(`--color-background-secondary`),E(`--color-background-tertiary`),E(`--color-background-inverse`),E(`--color-background-ghost`),E(`--color-background-info`),E(`--color-background-danger`),E(`--color-background-success`),E(`--color-background-warning`),E(`--color-background-disabled`),E(`--color-text-primary`),E(`--color-text-secondary`),E(`--color-text-tertiary`),E(`--color-text-inverse`),E(`--color-text-ghost`),E(`--color-text-info`),E(`--color-text-danger`),E(`--color-text-success`),E(`--color-text-warning`),E(`--color-text-disabled`),E(`--color-border-primary`),E(`--color-border-secondary`),E(`--color-border-tertiary`),E(`--color-border-inverse`),E(`--color-border-ghost`),E(`--color-border-info`),E(`--color-border-danger`),E(`--color-border-success`),E(`--color-border-warning`),E(`--color-border-disabled`),E(`--color-ring-primary`),E(`--color-ring-secondary`),E(`--color-ring-inverse`),E(`--color-ring-info`),E(`--color-ring-danger`),E(`--color-ring-success`),E(`--color-ring-warning`),E(`--font-sans`),E(`--font-mono`),E(`--font-weight-normal`),E(`--font-weight-medium`),E(`--font-weight-semibold`),E(`--font-weight-bold`),E(`--font-text-xs-size`),E(`--font-text-sm-size`),E(`--font-text-md-size`),E(`--font-text-lg-size`),E(`--font-heading-xs-size`),E(`--font-heading-sm-size`),E(`--font-heading-md-size`),E(`--font-heading-lg-size`),E(`--font-heading-xl-size`),E(`--font-heading-2xl-size`),E(`--font-heading-3xl-size`),E(`--font-text-xs-line-height`),E(`--font-text-sm-line-height`),E(`--font-text-md-line-height`),E(`--font-text-lg-line-height`),E(`--font-heading-xs-line-height`),E(`--font-heading-sm-line-height`),E(`--font-heading-md-line-height`),E(`--font-heading-lg-line-height`),E(`--font-heading-xl-line-height`),E(`--font-heading-2xl-line-height`),E(`--font-heading-3xl-line-height`),E(`--border-radius-xs`),E(`--border-radius-sm`),E(`--border-radius-md`),E(`--border-radius-lg`),E(`--border-radius-xl`),E(`--border-radius-full`),E(`--border-width-regular`),E(`--shadow-hairline`),E(`--shadow-sm`),E(`--shadow-md`),E(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`),Os=S(Ds.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.`),k([A(),Ne()]).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.`),ks=M({method:E(`ui/open-link`),params:M({url:A().describe(`URL to open in the host's browser`)})}),As=M({isError:j().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),js=M({isError:j().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),Ms=M({isError:j().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough(),Ns=M({method:E(`ui/notifications/sandbox-proxy-ready`),params:M({})}),Ps=M({connectDomains:O(A()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).

- Maps to CSP \`connect-src\` directive
- Empty or omitted → no network connections (secure default)`),resourceDomains:O(A()).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:O(A()).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:O(A()).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'`)")}),Fs=M({camera:M({}).optional().describe(`Request camera access.

Maps to Permission Policy \`camera\` feature.`),microphone:M({}).optional().describe(`Request microphone access.

Maps to Permission Policy \`microphone\` feature.`),geolocation:M({}).optional().describe(`Request geolocation access.

Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:M({}).optional().describe(`Request clipboard write access.

Maps to Permission Policy \`clipboard-write\` feature.`)}),Is=M({method:E(`ui/notifications/size-changed`),params:M({width:x().optional().describe(`New width in pixels.`),height:x().optional().describe(`New height in pixels.`)})}),M({method:E(`ui/notifications/tool-input`),params:M({arguments:S(A(),C().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),M({method:E(`ui/notifications/tool-input-partial`),params:M({arguments:S(A(),C().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),M({method:E(`ui/notifications/tool-cancelled`),params:M({reason:A().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})}),Ls=M({fonts:A().optional()}),Rs=M({variables:Os.optional().describe(`CSS variables for theming the app.`),css:Ls.optional().describe(`CSS blocks that apps can inject.`)}),M({method:E(`ui/resource-teardown`),params:M({})}),zs=S(A(),C()),Bs=M({text:M({}).optional().describe(`Host supports text content blocks.`),image:M({}).optional().describe(`Host supports image content blocks.`),audio:M({}).optional().describe(`Host supports audio content blocks.`),resource:M({}).optional().describe(`Host supports resource content blocks.`),resourceLink:M({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:M({}).optional().describe(`Host supports structured content.`)}),Vs=M({method:E(`ui/notifications/request-teardown`),params:M({}).optional()}),Hs=M({experimental:S(A(),S(A(),Ce()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),openLinks:M({}).optional().describe(`Host supports opening external URLs.`),downloadFile:M({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:M({listChanged:j().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:M({listChanged:j().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:M({}).optional().describe(`Host accepts log messages.`),sandbox:M({permissions:Fs.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:Bs.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:Bs.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:M({tools:M({}).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.")}),Us=M({experimental:S(A(),S(A(),Ce()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),tools:M({listChanged:j().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:O(Es).optional().describe(`Display modes the app supports.`)}),Ws=M({method:E(`ui/notifications/initialized`),params:M({}).optional()}),M({csp:Ps.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:Fs.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:A().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:j().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`)}),Gs=M({method:E(`ui/request-display-mode`),params:M({mode:Es.describe(`The display mode being requested.`)})}),Ks=M({mode:Es.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),qs=k([E(`model`),E(`app`)]).describe(`Tool visibility scope - who can access the tool.`),M({resourceUri:A().optional(),visibility:O(qs).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:xe().optional(),permissions:xe().optional()}),M({mimeTypes:O(A()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Js=M({method:E(`ui/download-file`),params:M({contents:O(k([In,Ln])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),Ys=M({method:E(`ui/message`),params:M({role:E(`user`).describe(`Message role, currently only "user" is supported.`),content:O(Rn).describe(`Message content blocks (text, image, etc.).`)})}),M({method:E(`ui/notifications/sandbox-resource-ready`),params:M({html:A().describe(`HTML content to load into the inner iframe.`),sandbox:A().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:Ps.optional().describe(`CSP configuration from resource metadata.`),permissions:Fs.optional().describe(`Sandbox permissions from resource metadata.`)})}),M({method:E(`ui/notifications/tool-result`),params:qn.describe(`Standard MCP tool execution result.`)}),Xs=M({toolInfo:M({id:Ct.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Wn.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Ts.optional().describe(`Current color theme preference.`),styles:Rs.optional().describe(`Style configuration for theming the app.`),displayMode:Es.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:O(Es).optional().describe(`Display modes the host supports.`),containerDimensions:k([M({height:x().describe(`Fixed container height in pixels.`)}),M({maxHeight:k([x(),Ne()]).optional().describe(`Maximum container height in pixels.`)})]).and(k([M({width:x().describe(`Fixed container width in pixels.`)}),M({maxWidth:k([x(),Ne()]).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:A().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:A().optional().describe(`User's timezone in IANA format.`),userAgent:A().optional().describe(`Host application identifier.`),platform:k([E(`web`),E(`desktop`),E(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:M({touch:j().optional().describe(`Whether the device supports touch input.`),hover:j().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:M({top:x().describe(`Top safe area inset in pixels.`),right:x().describe(`Right safe area inset in pixels.`),bottom:x().describe(`Bottom safe area inset in pixels.`),left:x().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),M({method:E(`ui/notifications/host-context-changed`),params:Xs.describe(`Partial context update containing only changed fields.`)}),Zs=M({method:E(`ui/update-model-context`),params:M({content:O(Rn).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:S(A(),C().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),Qs=M({method:E(`ui/initialize`),params:M({appInfo:V.describe(`App identification (name and version).`),appCapabilities:Us.describe(`Features and capabilities this app provides.`),protocolVersion:A().describe(`Protocol version this app supports.`)})}),$s=M({protocolVersion:A().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:V.describe(`Host application identification and version.`),hostCapabilities:Hs.describe(`Features and capabilities provided by the host.`),hostContext:Xs.describe(`Rich context about the host environment.`)}).passthrough(),ec=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=Ot.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},tc=[ws],nc=class extends Zo{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new xs;_methods=new Ss;setRequestHandler=(...e)=>{let[t,...n]=vs(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=vs(`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:Is,sandboxready:Ns,initialized:Ws,requestteardown:Vs,loggingmessage:rr};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:Qs.shape.params,result:$s},e=>this._onAppsInitialize(e)),this.replaceRequestHandler(`ping`,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(`ui/request-display-mode`,{params:Gs.shape.params,result:Ks},()=>({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:Ys.shape.params,result:Ms},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:ks.shape.params,result:As},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:Js.shape.params,result:js},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:Gs.shape.params,result:Ks},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:Zs.shape.params,result:At},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:tc.includes(t)?t:ws,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];bs(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},zs,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 ic(e,t){let n=e[`~standard`].validate(t);if(n.issues)throw Error(`Invalid Gateway MCP result`);return n.value}function ac(e){let{bridge:t,request:n,sessionKey:r,viewId:i,iframe:a}=e;t.oncalltool=async e=>ic(qo.CallToolResult,await n(`mcp.app.callTool`,{toolName:e.name,arguments:e.arguments}));let o=(e,t)=>async r=>ic(t,await n(e,r?.cursor===void 0?{}:{cursor:r.cursor}));t.setListToolsHandler(o(`mcp.app.listTools`,qo.ListToolsResult)),t.onlistresources=o(`mcp.app.listResources`,qo.ListResourcesResult),t.onlistresourcetemplates=o(`mcp.app.listResourceTemplates`,qo.ListResourceTemplatesResult),t.onreadresource=async(e,t)=>ic(qo.ReadResourceResult,await n(`mcp.app.readResource`,{uri:e.uri,_meta:t.mcpReq._meta??e._meta}));let s=new Set;return e.fileResourcesSupported&&(t.setHostRequestHandler(`openai/resources/write`,async e=>oc.parse(await n(`mcp.app.writeResource`,e))),t.setHostRequestHandler(`resources/subscribe`,async t=>{let r=oc.parse(await n(`mcp.app.subscribeResource`,t));return typeof t.uri==`string`&&(e.isDisposed()?await n(`mcp.app.unsubscribeResource`,{uri:t.uri}):s.add(t.uri)),r}),t.setHostRequestHandler(`resources/unsubscribe`,async e=>{let t=oc.parse(await n(`mcp.app.unsubscribeResource`,e));return typeof e.uri==`string`&&s.delete(e.uri),t}),e.addCleanup(()=>{for(let e of s)n(`mcp.app.unsubscribeResource`,{uri:e}).catch(()=>void 0);s.clear()})),e.openFilesSupported&&t.setHostRequestHandler(`openai/files/open`,async t=>{if(e.isDisposed()||!He(a)||typeof t.path!=`string`||!await e.confirmOpenFile(t.path)||e.isDisposed()||!He(a))return{isError:!0};let o=sc.parse(await n(`mcp.app.openFile`,t));return e.isDisposed()?{isError:!0}:new Promise(t=>{e.dispatchEvent(new CustomEvent(`openclaw-mcp-app-file-open`,{bubbles:!0,composed:!0,cancelable:!0,detail:{sessionKey:r,viewId:i,...o,respond:e=>t(e?{}:{isError:!0})}}))&&t({isError:!0})})}),()=>{let n=e.subscribeEvents(n=>{if(e.isDisposed())return;let a=ue(n.payload),o=n.event===`question.requested`&&a?.status===`pending`?a:n.event===`plugin.approval.requested`?ue(a?.request):void 0;o?.sessionKey===r&&(!e.agentId||!o.agentId||o.agentId===e.agentId)&&e.onConversationInputRequested(),a?.viewId===i&&(n.event===`mcp.app.hostContextChanged`&&e.onModelContextChanged(a.modelContext===null&&typeof a.updateId==`string`?a.updateId:void 0),n.event===`mcp.app.resourceUpdated`&&typeof a.uri==`string`&&s.has(a.uri)&&t.notification({method:`notifications/resources/updated`,params:{uri:a.uri}}))});n&&e.addCleanup(n)}}var oc,sc,cc;function lc(){return(lc=e((()=>{gs(),rc(),T(),qe(),oc=S(A(),C()),sc=M({path:A(),name:A()}),cc=class extends nc{setMessageHandler(e){Reflect.set(this,`onmessage`,(t,n)=>e({...t,_meta:n?.mcpReq?._meta},n))}setUpdateModelContextHandler(e){Reflect.set(this,`onupdatemodelcontext`,e)}setHostRequestHandler(e,t){this.replaceRequestHandler(e,{params:oc,result:oc},t)}setListToolsHandler(e){this.replaceRequestHandler(`tools/list`,t=>e(t.params))}}})))()}function uc(e=document.documentElement){if(!e)return;let t=getComputedStyle(e),n={...fc};for(let[e,r]of Object.entries(dc)){let i=t.getPropertyValue(r).trim();i&&(n[e]=i)}return n}var dc,fc;function pc(){return(pc=e((()=>{dc={"--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`},fc={"--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 mc(){await Promise.race([new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})}),new Promise(e=>{window.setTimeout(e,1e3)})])}function hc(e,t,n,r,i){let a=e?.getBoundingClientRect(),o=navigator.maxTouchPoints>0||window.matchMedia?.(`(pointer: coarse)`).matches,s=document.documentElement.dataset.themeMode;return Xs.parse({theme:s===`light`||s===`dark`?s:window.matchMedia?.(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,displayMode:r,availableDisplayModes:i,containerDimensions:{width:Math.max(1,Math.round(a?.width||window.innerWidth)),height:n?Math.max(0,Math.round(a?.height??0)):t},locale:navigator.language||void 0,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,platform:o&&window.innerWidth<768?`mobile`:`web`,deviceCapabilities:{touch:o,hover:window.matchMedia?.(`(hover: hover)`).matches},safeAreaInsets:{top:0,right:0,bottom:0,left:0},styles:{variables:uc()}})}var gc,$;function _c(){return(_c=e((()=>{ce(),pe(),rc(),ie(),oe(),m(),h(),d(),c(),Be(),n(),ne(),a(),ee(),i(),lc(),Ye(),qe(),pc(),Xe(),Le(),y(),gc=250,$=class extends le{constructor(...e){super(...e),this.sessionKey=``,this.agentId=``,this.viewId=``,this.height=600,this.fillContainer=!1,this.surface=`conversation`,this.title=``,this.relaunching=!1,this.inactive=null,this.displayMode=`inline`,this.i18nController=new t(this),this.mount=u(),this.confirmation=new Ze(()=>this.requestUpdate()),this.resources=null,this.teardownPromise=null,this.setupTask=new fe(this,{autoRun:`afterUpdate`,args:()=>[this.context?.gateway.snapshot.client??null,this.sessionKey,this.viewId,this.agentId,this.context?.gateway.connectionRevision,this.context?.gateway.snapshot.hello],task:async([e,t,n,r,i,a],{signal:o})=>{if(await this.teardownResources(this.resources),this.inactive=null,!t||!n)return null;if(!e)throw Error(s(`mcpApp.errors.gatewayUnavailable`));return this.setupResources({client:e,sessionKey:t,viewId:n,agentId:r||void 0,connectionRevision:i,hello:a},o)}})}static{this.styles=Je}disconnectedCallback(){this.teardown(),super.disconnectedCallback()}updated(e){this.confirmation.update(),e.has(`displayMode`)&&(this.displayMode===`fullscreen`?Re(this):this.removeAttribute(`popover`)),this.resources&&(this.resources.iframe.title=this.title||s(`mcpApp.title`),(e.has(`height`)||e.has(`fillContainer`)||e.has(`displayMode`)||e.has(`deepLink`))&&(this.resources.frameHeight=this.height,this.resources.iframe.style.height=this.fillContainer||this.displayMode===`fullscreen`?`100%`:`${this.height}px`,this.resources.updateHostContext?.()))}async request(e,t,n,r){try{let{agentId:i,...a}=n,o={...a,sessionKey:e.sessionKey,viewId:e.viewId,...e.agentId?{agentId:e.agentId}:{}};return await(r?e.client.request(t,o,{signal:r}):e.client.request(t,o))}catch(t){throw ae(t)&&this.viewId===e.viewId&&this.sessionKey===e.sessionKey&&this.context?.gateway.snapshot.client===e.client&&(this.inactive=`ended`,this.confirmation.cancel(),this.dispatchEvent(new CustomEvent(We,{bubbles:!0,composed:!0}))),t}}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()=>{e.bridge&&await re(e.bridge.teardownResource({}).catch(()=>void 0),gc,()=>void 0),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()}isCurrentBinding(e,t,n){let r=this.context?.gateway;return!n.aborted&&!t.disposed&&this.resources===t&&this.isConnected&&this.inactive!==`ended`&&this.sessionKey===e.sessionKey&&this.viewId===e.viewId&&(this.agentId||void 0)===e.agentId&&r?.snapshot.phase===`connected`&&r.snapshot.client===e.client&&r.connectionRevision===e.connectionRevision&&r.snapshot.hello===e.hello}bindOpenLinkHandler(e,t,n,i){e.onopenlink=async({url:e})=>{if(!te(e))return r(e)?{}:{isError:!0};let a=this.context;return!a||!this.isCurrentBinding(t,n,i)||!He(n.iframe)?{isError:!0}:ze(a,e)?{}:{isError:!0}}}async setupResources(e,t){let{sessionKey:n,viewId:r,agentId:i}=e,a=null;try{let o=await this.request(e,`mcp.app.view`,{},t),c=this.mount.value;if(t.throwIfAborted(),this.inactive=o.messageSupported===!1?`reconstructed`:null,!c)throw Error(s(`mcpApp.errors.mountUnavailable`));let l=document.createElement(`iframe`);l.title=this.title||s(`mcpApp.title`),l.referrerPolicy=`origin`,l.style.height=this.fillContainer?`100%`:`${this.height}px`,l.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-forms`),c.appendChild(l);let u={bridge:null,cleanups:new Set,frameHeight:this.height,iframe:l,transport:null,disposed:!1};a=u,this.resources=u,this.addResourceCleanup(u,()=>this.confirmation.cancel()),t.addEventListener(`abort`,()=>void this.teardownResources(u),{once:!0});let d=new Promise((e,t)=>{let n=window.setTimeout(()=>{i(),t(Error(s(`mcpApp.errors.sandboxTimedOut`)))},15e3),r=t=>{t.source===l.contentWindow&&t.data?.method===`ui/notifications/sandbox-proxy-ready`&&(i(),e())},i=this.addResourceCleanup(u,()=>{window.clearTimeout(n),window.removeEventListener(`message`,r)});window.addEventListener(`message`,r)});if(l.src=Qe(o.sandboxUrl,o.sandboxPort,o.sandboxOrigin,this.context?.gateway.connection.gatewayUrl??``,window.location.origin,s(`mcpApp.errors.invalidSandboxUrl`)),await d,t.throwIfAborted(),!l.contentWindow)throw Error(s(`mcpApp.errors.sandboxUnavailable`));let f=Ke(o.displayModes);this.displayMode=o.displayMode&&f.available.includes(o.displayMode)?o.displayMode:f.initial;let p=o.hostContext?.[`openai/modelContext`]??null,m=0,h=()=>{let e=this.deepLink?{url:this.deepLink}:o.hostContext?.[`openai/deepLink`];if(e&&(!e.url.startsWith(`/`)||e.url.startsWith(`//`)||e.url.includes(`#`)))throw Error(`Invalid App deep link`);return{...hc(c,u.frameHeight,this.fillContainer||this.displayMode===`fullscreen`,this.displayMode,f.available),"openai/modelContext":p,...e?{"openai/deepLink":e}:{}}},g=()=>this.dispatchEvent(new CustomEvent(Ge,{bubbles:!0,composed:!0,detail:{sessionKey:n,viewId:r,state:p}})),_=new cc(null,{name:`OpenClaw`,version:`1.0.0`},Ue(o.csp,o.messageSupported===!0,o.updateModelContextSupported===!0,{richModelContext:o.richModelContextSupported===!0,fileResources:o.fileResourcesSupported===!0,openFiles:o.openFilesSupported===!0}),{hostContext:h()});u.bridge=_;let v=(t,n)=>this.request(e,t,n),y=()=>this.isCurrentBinding(e,u,t),ee=(e,t)=>this.confirmation.request({frame:l,title:this.title||s(`mcpApp.title`),text:e,kind:t,isCurrent:y}),te=e=>{if(e&&p&&p.updateId!==e)return;let t=++m,n=e=>{u.disposed||t!==m||(p=e,_.setHostContext(h()),g())};if(e){n(null);return}return v(`mcp.app.modelContext`,{}).then(e=>e.state).catch(()=>null).then(n)},ne=()=>{this.teardown()};_.onrequestteardown=ne,this.addResourceCleanup(u,()=>{_.onrequestteardown===ne&&(_.onrequestteardown=void 0)}),o.messageSupported===!0&&_.setMessageHandler(async e=>await Ve(l,{sessionKey:n,viewId:r},e,e=>ee(e,`message`),y)?{}:{isError:!0}),o.updateModelContextSupported===!0&&_.setUpdateModelContextHandler(async e=>{let t=await v(`mcp.app.updateModelContext`,{...e});return await te(),t});let re=ac({bridge:_,request:v,sessionKey:n,viewId:r,iframe:l,agentId:i,fileResourcesSupported:o.fileResourcesSupported,openFilesSupported:o.openFilesSupported,confirmOpenFile:e=>ee(e,`file`),isDisposed:()=>!y(),addCleanup:e=>{this.addResourceCleanup(u,e)},dispatchEvent:e=>this.dispatchEvent(e),onModelContextChanged:e=>{te(e)?.catch(()=>void 0)},onConversationInputRequested:()=>{this.displayMode=`inline`},subscribeEvents:e=>this.context?.gateway.subscribeEvents?.(e)});_.onrequestdisplaymode=async({mode:e})=>e!==`inline`&&e!==`fullscreen`||!f.available.includes(e)?{mode:this.displayMode}:(this.displayMode=e,l.style.height=e===`fullscreen`||this.fillContainer?`100%`:`${u.frameHeight}px`,_.setHostContext(h()),{mode:e}),this.bindOpenLinkHandler(_,e,u,t),_.onsizechange=({height:e})=>{if(e!==void 0&&!this.fillContainer&&this.displayMode!==`fullscreen`){let t=Math.min(1200,Math.max(160,Math.round(e)));u.frameHeight=t,l.style.height=`${t}px`,_.setHostContext(h())}};let ie=new Promise(e=>{_.oninitialized=()=>{f=Ke(o.displayModes,_.getAppCapabilities()?.availableDisplayModes),this.displayMode=o.displayMode&&f.available.includes(o.displayMode)?o.displayMode:f.initial,e()}}),ae=new ec(l.contentWindow,l.contentWindow);u.transport=ae,await _.connect(ae),t.throwIfAborted(),await _.sendSandboxResourceReady({html:o.html,csp:o.csp});let oe,se=this.addResourceCleanup(u,()=>{oe!==void 0&&window.clearTimeout(oe)});try{await Promise.race([ie,new Promise((e,t)=>{oe=window.setTimeout(()=>t(Error(s(`mcpApp.errors.initializationTimedOut`))),15e3)})])}finally{se()}t.throwIfAborted();let ce=()=>_.setHostContext(h());u.updateHostContext=ce,ce(),g(),re();let b=this.context?.theme.subscribe(ce);if(b&&this.addResourceCleanup(u,b),typeof ResizeObserver<`u`){let e=new ResizeObserver(ce);e.observe(c),this.addResourceCleanup(u,()=>e.disconnect())}return await mc(),t.throwIfAborted(),await _.sendToolInput({arguments:o.toolInput&&typeof o.toolInput==`object`&&!Array.isArray(o.toolInput)?o.toolInput:{}}),await _.sendToolResult(o.toolResult),t.throwIfAborted(),u}catch(e){throw await this.teardownResources(a),e}}render(){let e=this.inactive!==`ended`&&this.setupTask.status===de.ERROR?this.setupTask.error:null,t=this.inactive===`ended`&&this.onRelaunch;return p`${this.displayMode===`fullscreen`?p`<button
              class="exit-fullscreen"
              @click=${()=>{this.displayMode=`inline`}}
            >
              ${s(`common.close`)}
            </button>`:f}
      ${this.inactive&&this.surface===`conversation`?p`<div class="inactive" role="status">
              <span>${s(t?`mcpApp.sessionEnded`:`mcpApp.reconstructed`)}</span>
              ${t?p`<button type="button" ?disabled=${this.relaunching} @click=${t}>${s(`mcpApp.relaunch`)}</button>`:f}
            </div>`:f}
      ${this.confirmation.render()}
      <div ${_(this.mount)} class="mount"></div>
      ${e?p`<div class="error">${s(`mcpApp.unavailable`,{error:o(e,s(`mcpApp.errors.requestFailed`))})}</div>`:f}`}},b([se({context:l,subscribe:!0})],$.prototype,`context`,void 0),b([g({attribute:!1})],$.prototype,`sessionKey`,void 0),b([g({attribute:!1})],$.prototype,`agentId`,void 0),b([g({attribute:!1})],$.prototype,`viewId`,void 0),b([g({type:Number})],$.prototype,`height`,void 0),b([g({type:Boolean,attribute:`fill-container`,reflect:!0})],$.prototype,`fillContainer`,void 0),b([g({attribute:!1})],$.prototype,`surface`,void 0),b([g()],$.prototype,`title`,void 0),b([g({attribute:!1})],$.prototype,`deepLink`,void 0),b([g({attribute:!1})],$.prototype,`onRelaunch`,void 0),b([g({type:Boolean})],$.prototype,`relaunching`,void 0),b([v()],$.prototype,`inactive`,void 0),b([g({attribute:`display-mode`,reflect:!0})],$.prototype,`displayMode`,void 0)})))()}function vc(){customElements.get(`mcp-app-view`)||customElements.define(`mcp-app-view`,$)}function yc(){return(yc=e((()=>{_c(),vc()})))()}yc();export{vc as registerMcpAppView};