UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

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

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

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

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

Maps to Permission Policy \`clipboard-write\` feature.`)}),Ys=O({method:R(`ui/notifications/size-changed`),params:O({width:j().optional().describe(`New width in pixels.`),height:j().optional().describe(`New height in pixels.`)})}),O({method:R(`ui/notifications/tool-input`),params:O({arguments:k(A(),D().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),O({method:R(`ui/notifications/tool-input-partial`),params:O({arguments:k(A(),D().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),O({method:R(`ui/notifications/tool-cancelled`),params:O({reason:A().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})}),Xs=O({fonts:A().optional()}),Zs=O({variables:Vs.optional().describe(`CSS variables for theming the app.`),css:Xs.optional().describe(`CSS blocks that apps can inject.`)}),O({method:R(`ui/resource-teardown`),params:O({})}),Qs=k(A(),D()),$s=O({text:O({}).optional().describe(`Host supports text content blocks.`),image:O({}).optional().describe(`Host supports image content blocks.`),audio:O({}).optional().describe(`Host supports audio content blocks.`),resource:O({}).optional().describe(`Host supports resource content blocks.`),resourceLink:O({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:O({}).optional().describe(`Host supports structured content.`)}),ec=O({method:R(`ui/notifications/request-teardown`),params:O({}).optional()}),tc=O({experimental:k(A(),k(A(),je()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),openLinks:O({}).optional().describe(`Host supports opening external URLs.`),downloadFile:O({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:O({listChanged:I().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:O({listChanged:I().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:O({}).optional().describe(`Host accepts log messages.`),sandbox:O({permissions:Js.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:qs.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:$s.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:$s.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:O({tools:O({}).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.")}),nc=O({experimental:k(A(),k(A(),je()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),tools:O({listChanged:I().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:P(zs).optional().describe(`Display modes the app supports.`)}),rc=O({method:R(`ui/notifications/initialized`),params:O({}).optional()}),O({csp:qs.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:Js.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:I().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`)}),ic=O({method:R(`ui/request-display-mode`),params:O({mode:zs.describe(`The display mode being requested.`)})}),ac=O({mode:zs.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),oc=F([R(`model`),R(`app`)]).describe(`Tool visibility scope - who can access the tool.`),O({resourceUri:A().optional(),visibility:P(oc).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:Ge().optional(),permissions:Ge().optional()}),O({mimeTypes:P(A()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),sc=O({method:R(`ui/download-file`),params:O({contents:P(F([Yn,Xn])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),cc=O({method:R(`ui/message`),params:O({role:R(`user`).describe(`Message role, currently only "user" is supported.`),content:P(Zn).describe(`Message content blocks (text, image, etc.).`)})}),O({method:R(`ui/notifications/sandbox-resource-ready`),params:O({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:qs.optional().describe(`CSP configuration from resource metadata.`),permissions:Js.optional().describe(`Sandbox permissions from resource metadata.`)})}),O({method:R(`ui/notifications/tool-result`),params:or.describe(`Standard MCP tool execution result.`)}),lc=O({toolInfo:O({id:Mt.optional().describe(`JSON-RPC id of the tools/call request.`),tool:rr.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Rs.optional().describe(`Current color theme preference.`),styles:Zs.optional().describe(`Style configuration for theming the app.`),displayMode:zs.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:P(zs).optional().describe(`Display modes the host supports.`),containerDimensions:F([O({height:j().describe(`Fixed container height in pixels.`)}),O({maxHeight:F([j(),Ue()]).optional().describe(`Maximum container height in pixels.`)})]).and(F([O({width:j().describe(`Fixed container width in pixels.`)}),O({maxWidth:F([j(),Ue()]).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:F([R(`web`),R(`desktop`),R(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:O({touch:I().optional().describe(`Whether the device supports touch input.`),hover:I().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:O({top:j().describe(`Top safe area inset in pixels.`),right:j().describe(`Right safe area inset in pixels.`),bottom:j().describe(`Bottom safe area inset in pixels.`),left:j().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),O({method:R(`ui/notifications/host-context-changed`),params:lc.describe(`Partial context update containing only changed fields.`)}),uc=O({method:R(`ui/update-model-context`),params:O({content:P(Zn).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:k(A(),D().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),dc=O({method:R(`ui/initialize`),params:O({appInfo:Ut.describe(`App identification (name and version).`),appCapabilities:nc.describe(`Features and capabilities this app provides.`),protocolVersion:A().describe(`Protocol version this app supports.`)})}),fc=O({protocolVersion:A().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ut.describe(`Host application identification and version.`),hostCapabilities:tc.describe(`Features and capabilities provided by the host.`),hostContext:lc.describe(`Rich context about the host environment.`)}).passthrough(),pc=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=Ft.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},mc=[Ls],hc=class extends us{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new Ps;_methods=new Fs;setRequestHandler=(...e)=>{let[t,...n]=js(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=js(`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:Ys,sandboxready:Ks,initialized:rc,requestteardown:ec,loggingmessage:gr};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:dc.shape.params,result:fc},e=>this._onAppsInitialize(e)),this.replaceRequestHandler(`ping`,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(`ui/request-display-mode`,{params:ic.shape.params,result:ac},()=>({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:cc.shape.params,result:Gs},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:Hs.shape.params,result:Us},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:sc.shape.params,result:Ws},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:ic.shape.params,result:ac},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:uc.shape.params,result:Lt},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:mc.includes(t)?t:Ls,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];Ns(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},Qs,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 _c(e,t){let n=e[`~standard`].validate(t);if(n.issues)throw Error(`Invalid Gateway MCP result`);return n.value}function vc(e){let{bridge:t,request:n,sessionKey:r,viewId:i,iframe:a}=e;t.oncalltool=async e=>_c(os.CallToolResult,await n(`mcp.app.callTool`,{toolName:e.name,arguments:e.arguments}));let o=(e,t)=>async r=>_c(t,await n(e,r?.cursor===void 0?{}:{cursor:r.cursor}));t.setListToolsHandler(o(`mcp.app.listTools`,os.ListToolsResult)),t.onlistresources=o(`mcp.app.listResources`,os.ListResourcesResult),t.onlistresourcetemplates=o(`mcp.app.listResourceTemplates`,os.ListResourceTemplatesResult),t.onreadresource=async(e,t)=>_c(os.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=>yc.parse(await n(`mcp.app.writeResource`,e))),t.setHostRequestHandler(`resources/subscribe`,async t=>{let r=yc.parse(await n(`mcp.app.subscribeResource`,t));return typeof t.uri==`string`&&(e.isDisposed()?await e.releaseResourceSubscription(t.uri):s.add(t.uri)),r}),t.setHostRequestHandler(`resources/unsubscribe`,async e=>{let t=yc.parse(await n(`mcp.app.unsubscribeResource`,e));return typeof e.uri==`string`&&s.delete(e.uri),t}),e.addCleanup(()=>{for(let t of s)e.releaseResourceSubscription(t).catch(()=>void 0);s.clear()})),e.openFilesSupported&&t.setHostRequestHandler(`openai/files/open`,async t=>{if(e.isDisposed()||!Ze(a)||typeof t.path!=`string`||!await e.confirmOpenFile(t.path)||e.isDisposed()||!Ze(a))return{isError:!0};let o=bc.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})})}),{async reconnect(){for(let e of s)await n(`mcp.app.subscribeResource`,{uri:e})},start(){let n=e.subscribeEvents(n=>{if(e.isDisposed())return;let a=c(n.payload),o=n.event===`question.requested`&&a?.status===`pending`?a:n.event===`plugin.approval.requested`?c(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 yc,bc,xc;function Sc(){return(Sc=e((()=>{ks(),gc(),Me(),qe(),yc=k(A(),D()),bc=O({path:A(),name:A()}),xc=class extends hc{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:yc,result:yc},t)}setListToolsHandler(e){this.replaceRequestHandler(`tools/list`,t=>e(t.params))}}})))()}function Cc(){let e=getComputedStyle(document.documentElement),t={...Tc};for(let[n,r]of Object.entries(wc)){let i=e.getPropertyValue(r).trim();i&&(t[n]=i)}return t}var wc,Tc;function Ec(){return(Ec=e((()=>{wc={"--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`},Tc={"--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`}})))()}function Dc(e,t,n,r,i){let a=e?.getBoundingClientRect(),o=navigator.maxTouchPoints>0||window.matchMedia?.(`(pointer: coarse)`).matches,s=document.documentElement.dataset.themeMode;return lc.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:Cc()}})}function Oc(e,t,n){let r=new Promise((t,r)=>{let i=window.setTimeout(()=>{o(),r(Error(l(`mcpApp.errors.sandboxTimedOut`)))},15e3),a=s(window,`message`,n=>{n.source===e.contentWindow&&n.data?.method===`ui/notifications/sandbox-proxy-ready`&&(o(),t())}),o=n(()=>{window.clearTimeout(i),a()})});return e.src=t,r}async function kc(e,t){let n,r=t(()=>{n!==void 0&&window.clearTimeout(n)});try{await Promise.race([e,new Promise((e,t)=>{n=window.setTimeout(()=>t(Error(l(`mcpApp.errors.initializationTimedOut`))),15e3)})])}finally{r()}}async function Ac(){await Promise.race([new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})}),new Promise(e=>{window.setTimeout(e,1e3)})])}function jc(){return(jc=e((()=>{gc(),u(),tt(),Ec(),nt()})))()}function Mc(e,r,a,o){let u=null,d=null,f,p=null,m=null,g,_=new AbortController,v=ot(),te=!1,ne=!1,y=!1,ie=!1,b=!1,ae,se,x,ce,le,ue;function S(){!te||ne||ie||(ie=!0,a(de))}function C(){let t=r.gateway;return[t.snapshot.client,e.sessionKey,e.viewId,e.agentId,t.connectionRevision,oe(t).key,t.snapshot.phase===`connected`&&t.snapshot.hello!==null&&!n(t.snapshot.hello.auth??null)]}function de(){if(ie=!1,ne)return;let t=C(),n=!x?.every((e,n)=>e===t[n]);x=t;let r=b&&!y;b=!1,(n||r)&&he(k(t)),le!==e.title&&(le=e.title,ge());let i=[e.height,e.fillContainer,e.displayMode,e.deepLink],a=!ce?.every((e,t)=>e===i[t]);ce=i,a&&_e(),ue!==e.surface&&!a&&T(),ue=e.surface}function fe(){te=!0;let{client:e,phase:t,hello:n}=r.gateway.snapshot;ae=r.gateway.subscribe(r=>{(r.client!==e||r.phase!==t||r.hello!==n)&&w(),{client:e,phase:t,hello:n}=r,S()}),se=i.subscribe(ge),S()}function pe(){ne=!0,ae?.(),se?.(),D()}function me(e){u=e,o()}function w(){if(_.abort(),_=new AbortController,v.cancel(),r.gateway.snapshot.phase===`connected`){let e=p;if(!e&&!y)g?.abort(),b=!0,S();else if(e?.reconnect){let t=_.signal;e.reconnect().then(()=>{!t.aborted&&p===e&&d&&(d=null,o())},n=>{!t.aborted&&p===e&&(d=n,o())})}}}async function he(t){if(ne)return;y=!1,g?.abort();let n=new AbortController;g=n,d=null,o();try{if(await xe(p),n.signal.throwIfAborted(),me(null),!e.sessionKey||!e.viewId)return;if(!t)throw Error(l(`mcpApp.errors.gatewayUnavailable`));await Ce(t,n.signal)}catch(t){n.signal.aborted||(d=t,e.onHeightChange?.(null,!0),T(),o())}}function ge(){p&&(p.iframe.title=e.title||l(`mcpApp.title`))}function T(){f&&(f.style.minHeight=!d&&u!==`ended`&&e.surface===`conversation`&&!e.fillContainer&&e.displayMode===`inline`?`${p?.frameHeight??e.height}px`:``,e.onHeightChange&&(e.style.minHeight=``))}function _e(){v.update(),e.displayMode===`fullscreen`?$e(e,()=>[e]):e.removeAttribute(`popover`),p&&(p.frameHeight=e.height,p.iframe.style.height=e.fillContainer||e.displayMode===`fullscreen`?`100%`:`${e.height}px`,p.updateHostContext?.()),T()}async function E(t,i,a,o){let s=o?AbortSignal.any([o,_.signal]):_.signal;try{s.throwIfAborted();let e=r.gateway;if(e.snapshot.phase!==`connected`||e.snapshot.client!==t.client||!n(e.snapshot.hello?.auth??null)||oe(e).key!==t.scope)throw Error(l(`mcpApp.errors.gatewayUnavailable`));let{agentId:o,...c}=a,u={...c,sessionKey:t.sessionKey,viewId:t.viewId,...t.agentId?{agentId:t.agentId}:{}},d=await t.client.request(i,u,{signal:s});return s.throwIfAborted(),d}catch(n){throw h(n)&&!s.aborted&&e.viewId===t.viewId&&e.sessionKey===t.sessionKey&&r.gateway.snapshot.client===t.client&&(e.onHeightChange?.(null,!0),me(`ended`),T(),v.cancel(),e.dispatchEvent(new CustomEvent(Ye,{bubbles:!0,composed:!0}))),n}}function ye(e,t){return e.cleanups.add(t),()=>{e.cleanups.delete(t)&&t()}}async function xe(e){if(!e||e.disposed){await m;return}e.disposed=!0,p===e&&(p=null);for(let t of e.cleanups)e.cleanups.delete(t),t();let n=(async()=>{e.bridge&&await t(e.bridge.teardownResource({}).catch(()=>void 0),Nc,()=>void 0),e.requestAbort.abort(),await e.transport?.close().catch(()=>void 0),e.iframe.remove()})();m=n;try{await n}finally{m===n&&(m=null)}}async function D(){y=!0,x=C(),b=!1,g?.abort(),await xe(p)}function O(){y&&e.isConnected&&!p&&!m&&(_=new AbortController,he(k()))}function k(e=C()){let[t,n,r,i,a,o,s]=e;return t&&!s?{client:t,sessionKey:n,viewId:r,agentId:i||void 0,connectionRevision:a,scope:o}:null}function Se(t,i,a){let o=r.gateway;return!a.aborted&&!i.disposed&&p===i&&e.isConnected&&u!==`ended`&&e.sessionKey===t.sessionKey&&e.viewId===t.viewId&&(e.agentId||void 0)===t.agentId&&o.snapshot.phase===`connected`&&o.snapshot.client===t.client&&n(o.snapshot.hello?.auth??null)&&o.connectionRevision===t.connectionRevision&&oe(o).key===t.scope}async function Ce(t,n){let{sessionKey:i,viewId:a,agentId:o}=t,u=null;try{let d=await E(t,`mcp.app.view`,{},n),m=f;if(n.throwIfAborted(),me(d.messageSupported===!1?`reconstructed`:null),!m)throw Error(l(`mcpApp.errors.mountUnavailable`));let h=document.createElement(`iframe`);h.title=e.title||l(`mcpApp.title`),h.referrerPolicy=`origin`,h.style.height=e.fillContainer?`100%`:`${e.height}px`,h.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-forms`),m.appendChild(h);let g={bridge:null,requestAbort:new AbortController,cleanups:new Set,frameHeight:e.height,iframe:h,transport:null,disposed:!1};u=g,p=g,ye(g,()=>v.cancel()),ye(g,s(n,`abort`,()=>void xe(g),{once:!0}));let te=e=>ye(g,e);if(await Oc(h,z(d.sandboxUrl,d.sandboxPort,d.sandboxOrigin,r.gateway.connection.gatewayUrl,window.location.origin,l(`mcpApp.errors.invalidSandboxUrl`)),te),n.throwIfAborted(),!h.contentWindow)throw Error(l(`mcpApp.errors.sandboxUnavailable`));let ne=!1,y=Ke(d.displayModes),ie=()=>d.displayMode&&y.available.includes(d.displayMode)?d.displayMode:y.initial;e.displayMode=ie();let b=d.hostContext?.[`openai/modelContext`]??null,ae=0,oe=()=>{let t=e.deepLink?{url:e.deepLink}:d.hostContext?.[`openai/deepLink`];if(t&&(!t.url.startsWith(`/`)||t.url.startsWith(`//`)||t.url.includes(`#`)))throw Error(`Invalid App deep link`);return{...Dc(m,g.frameHeight,e.fillContainer||e.displayMode===`fullscreen`,e.displayMode,y.available),"openai/modelContext":b,...t?{"openai/deepLink":t}:{}}},se=()=>e.dispatchEvent(new CustomEvent(Qe,{bubbles:!0,composed:!0,detail:{sessionKey:i,viewId:a,state:b}})),x=new xc(null,{name:`OpenClaw`,version:`1.0.0`},Je(d.csp,d.messageSupported===!0,d.updateModelContextSupported===!0,{richModelContext:d.richModelContextSupported===!0,fileResources:d.fileResourcesSupported===!0,openFiles:d.openFilesSupported===!0}),{hostContext:oe()});g.bridge=x;let ce=(e,n)=>E(t,e,n,g.requestAbort.signal),le=()=>Se(t,g,n),ue=(t,n)=>v.request({frame:h,title:e.title||l(`mcpApp.title`),text:t,kind:n,isCurrent:le}),S=e=>{if(e&&b&&b.updateId!==e)return;let t=++ae,n=_.signal,r=e=>{g.disposed||n.aborted||t!==ae||(b=e,x.setHostContext(oe()),se())};if(e)r(null);else return ce(`mcp.app.modelContext`,{}).then(e=>r(e.state),()=>void 0)},C=()=>{D()};x.onrequestteardown=C,ye(g,()=>{x.onrequestteardown===C&&(x.onrequestteardown=void 0)}),d.messageSupported===!0&&x.setMessageHandler(async e=>await Xe(h,{sessionKey:i,viewId:a},e,e=>ue(e,`message`),le)?{}:{isError:!0}),d.updateModelContextSupported===!0&&x.setUpdateModelContextHandler(async e=>{let t=await ce(`mcp.app.updateModelContext`,{...e});return await S(),t});let de=vc({bridge:x,request:ce,releaseResourceSubscription:e=>E(t,`mcp.app.unsubscribeResource`,{uri:e}),sessionKey:i,viewId:a,iframe:h,agentId:o,fileResourcesSupported:d.fileResourcesSupported,openFilesSupported:d.openFilesSupported,confirmOpenFile:e=>ue(e,`file`),isDisposed:()=>!le(),addCleanup:e=>{ye(g,e)},dispatchEvent:t=>e.dispatchEvent(t),onModelContextChanged:e=>{S(e)?.catch(()=>void 0)},onConversationInputRequested:()=>{e.displayMode=`inline`},subscribeEvents:e=>r.gateway.subscribeEvents(e)});x.onrequestdisplaymode=({mode:t})=>t!==`inline`&&t!==`fullscreen`||!y.available.includes(t)?Promise.resolve({mode:e.displayMode}):(e.displayMode=t,h.style.height=t===`fullscreen`||e.fillContainer?`100%`:`${g.frameHeight}px`,x.setHostContext(oe()),Promise.resolve({mode:t})),x.onopenlink=({url:e})=>!Se(t,g,n)||!Ze(g.iframe)?Promise.resolve({isError:!0}):ve(e)?Promise.resolve(be(r,e)?{}:{isError:!0}):Promise.resolve(ee(e)?{}:{isError:!0}),x.onsizechange=({height:t})=>{if(t!==void 0&&Number.isFinite(t)&&le()&&!e.fillContainer&&e.displayMode!==`fullscreen`){let n=Math.min(1200,Math.max(160,Math.round(t))),r=e.onHeightChange?.(n,ne)??n;g.frameHeight=r,h.style.height=`${r}px`,T(),x.setHostContext(oe())}};let fe=new Promise(t=>{x.oninitialized=()=>{ne=!0,y=Ke(d.displayModes,x.getAppCapabilities()?.availableDisplayModes),e.displayMode=ie(),t()}}),pe=new pc(h.contentWindow,h.contentWindow);g.transport=pe,await x.connect(pe),n.throwIfAborted(),await x.sendSandboxResourceReady({html:d.html,csp:d.csp}),await kc(fe,te),n.throwIfAborted();let w=()=>x.setHostContext(oe());g.updateHostContext=w,w(),se(),de.start(),g.reconnect=async()=>{await de.reconnect(),d.updateModelContextSupported===!0&&await S()},ye(g,r.theme.subscribe(w)),typeof ResizeObserver<`u`&&ye(g,re([m],w)),await Ac(),n.throwIfAborted(),await x.sendToolInput({arguments:c(d.toolInput)??{}}),await x.sendToolResult(d.toolResult),n.throwIfAborted()}catch(e){throw await xe(u),e}}return{confirmation:v,start:fe,dispose:pe,inputChanged:S,setup:he,currentBinding:k,teardown:D,restartAfterTeardown:O,read:()=>({inactive:u,error:d}),setMount:e=>{f=e}}}var Nc;function Pc(){return(Pc=e((()=>{gc(),m(),d(),ce(),xe(),o(),u(),tt(),ye(),v(),p(),Sc(),it(),jc(),qe(),et(),nt(),Nc=250})))()}var Fc,Ic,Lc,Rc,zc,Bc,Vc;function Hc(){return(Hc=e((()=>{_e(),S(),r(),f(),_(),b(),ie(),ne(),rt(),ae(),Pc(),Fc=E(`<button class=exit-fullscreen>`),Ic=E(`<div class=inactive role=status><span>`),Lc=E(`<div class=mount>`),Rc=E(`<button type=button>`),zc=E(`<div class=error><button type=button>`),Bc=new WeakMap,Vc=y(`mcp-app-view`,(e,t)=>{let n=le(),r=g(n.gateway),{owner:i,view:o}=te(e=>Mc(t,n,pe,e),e=>e.read()),s=o.read;Bc.set(t,i);let c=x(t);pe(()=>i.start()),me(()=>{c(),Bc.delete(t),i.dispose()});let l=()=>s().inactive===`ended`?e.onRelaunch:void 0;return[w(ue,{get when(){return e.displayMode===`fullscreen`},get children(){var e=Fc();return e._$$click=()=>{t.displayMode=`inline`},C(e,()=>se(`common.close`)),e}}),w(ue,{get when(){return de(()=>!!s().inactive)()?e.surface===`conversation`:s().inactive},get children(){var t=Ic(),n=t.firstChild;return C(n,()=>se(l()?`mcpApp.sessionEnded`:`mcpApp.reconstructed`)),C(t,w(ue,{get when(){return l()},children:t=>(()=>{var n=Rc();return n._$$click=()=>t()(),C(n,()=>se(`mcpApp.relaunch`)),he(()=>e.relaunching,e=>{fe(n,`disabled`,e)}),n})()}),null),t}}),w(at,{get confirmation(){return i.confirmation}}),(()=>{var e=Lc();return ge(()=>e=>{i.setMount(e)},e),e})(),w(ue,{get when(){return de(()=>s().inactive!==`ended`)()&&s().error},children:e=>(()=>{var t=zc(),n=t.firstChild;return C(t,()=>se(`mcpApp.unavailable`,{error:a(e(),se(`mcpApp.errors.requestFailed`))}),n),n._$$click=()=>void i.setup(i.currentBinding()),C(n,()=>se(`mcpApp.retry`)),he(()=>r.read().snapshot.phase!==`connected`,e=>{fe(n,`disabled`,e)}),t})()})]},{properties:{sessionKey:{default:``,attribute:!1},agentId:{default:``,attribute:!1},viewId:{default:``,attribute:!1},height:{default:600},fillContainer:{default:!1,attribute:`fill-container`,reflect:!0},surface:{default:`conversation`,attribute:!1},title:{default:``},deepLink:{default:void 0,attribute:!1},onRelaunch:{default:void 0,attribute:!1},onHeightChange:{default:void 0,attribute:!1},relaunching:{default:!1},displayMode:{default:`inline`,attribute:`display-mode`,reflect:!0}},propertyChanged:e=>Bc.get(e)?.inputChanged(),methods:{teardown:e=>Bc.get(e)?.teardown()??Promise.resolve(),restartAfterTeardown:e=>Bc.get(e)?.restartAfterTeardown()}}),T([`click`])})))()}Hc();export{Vc as McpAppView};