UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

48 lines • 222 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Bl as t,Gu as n,K as r,Rl as i,U as a,Wo as o,al as s,li as c,oi as l,ol as u,si as d}from"./_4____________________________.js";import{AN as f,Dw as p,EN as m,FN as h,GN as g,JN as _,MN as v,PN as y,Ut as b,Wt as ee,ak as te,gl as ne,hF as re,hl as ie,iT as ae,jN as oe,kw as se,mF as x,nw as ce,ok as le,sT as ue,tw as S}from"./_2_____________________________.js";import{En as de,Fn as fe,In as pe,Li as C,Ln as me,Mn as he,Nn as ge,Qr as _e,Ri as w,Vn as ve,Zr as ye,kn as be}from"./deferred-ui-support-DZEPWjAk.js";import{O as xe,U as Se,d as T,f as Ce,g as we,gt as Te,ht as Ee,j as De,l as Oe,m as ke,s as E,u as Ae,x as je}from"./_6____________________.js";import{i as Me,t as Ne}from"./mcp-app-route-Cg1SB1yj.js";import{r as Pe,t as Fe}from"./mcp-app-routing-BhAH7-5E.js";import{A as D,C as O,E as k,F as Ie,I as Le,L as Re,M as ze,N as Be,O as A,P as Ve,S as j,T as He,_ as Ue,a as We,b as M,c as N,d as Ge,f as P,g as Ke,h as qe,i as Je,j as Ye,k as F,l as Xe,m as Ze,n as Qe,o as $e,p as I,r as et,s as tt,t as nt,u as rt,v as it,w as L,x as at,y as R}from"./config-runtime-ECF4aWQv.js";import{r as ot}from"./widget-sandbox-runtime-DfYFz8qf.js";import{i as z,n as st,r as ct,t as lt}from"./mcp-app-confirm-D_g91E60.js";function ut(e,t){let n=`--mcp-app-`+s(),r={inset:`auto`,top:`anchor(top, -10000px)`,left:`anchor(left, -10000px)`,width:`anchor-size(width, 0px)`,height:`anchor-size(height, 0px)`,"min-height":`0`,padding:`0`},i=Object.keys(r).map(t=>[t,e.style.getPropertyValue(t)]);t.style.setProperty(`anchor-name`,n),e.style.setProperty(`position-anchor`,n);for(let[t,n]of Object.entries(r))e.style.setProperty(t,n);e.style.removeProperty(`visibility`),e.setAttribute(`data-sidebar-ready`,``),e.displayMode=`fullscreen`;let a=se([t],t=>{t.some(e=>e.contentRect.width===0||e.contentRect.height===0)&&(e.displayMode=`inline`)});return()=>{if(a(),t.style.removeProperty(`anchor-name`),e.style.getPropertyValue(`position-anchor`)===n){e.style.removeProperty(`position-anchor`);for(let[t,n]of i)e.style.setProperty(t,n);e.style.removeProperty(`visibility`),e.removeAttribute(`data-sidebar-ready`),e.displayMode=`inline`}}}function dt(e,t){let n=e.displayMode;e.sidebar=e.surface===`conversation`&&!e.dispatchEvent(new CustomEvent(`openclaw-mcp-app-open`,{bubbles:!0,composed:!0,cancelable:!0,detail:{sessionKey:e.sessionKey,present:({state:r,openAppPanel:i})=>{n===`fullscreen`?(r.handleOpenSidebar({kind:`mcp-app-preview`,title:t?.label??(e.title||c(`mcpApp.title`)),view:e,appIdentity:t}),i?.()):r.sidebarContent?.kind===`mcp-app-preview`&&r.sidebarContent.view===e&&r.handleCloseSidebar(`detail`)}}}))&&e.displayMode===`fullscreen`,e.style.visibility=e.sidebar&&!e.hasAttribute(`data-sidebar-ready`)?`hidden`:``}function ft(){return(ft=e((()=>{l(),p(),u(),ve()})))()}var pt,mt,ht;function gt(){return(gt=e((()=>{pt=Object.defineProperty,mt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ht=(e,t)=>{let n={};for(var r in e)pt(n,r,{get:e[r],enumerable:!0});return t&&pt(n,Symbol.toStringTag,{value:`Module`}),n}})))()}function _t(e){return typeof e==`string`&&bt.has(e.replace(/#$/,``))}function vt(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(yt.has(n))return`2020-12`;if(bt.has(n))return`2019-09`;if(xt.has(n)||St.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var yt,bt,xt,St;function Ct(){return(Ct=e((()=>{yt=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),bt=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),xt=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),St=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`])})))()}var wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,B,Pt,Ft,It,Lt,Rt,zt,V,H,U,W,G,Bt,K,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,q,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,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi;function Ni(){return(Ni=e((()=>{Ke(),We(),wt=`2025-11-25`,Tt=[wt,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Et=`io.modelcontextprotocol/related-task`,Dt=`io.modelcontextprotocol/protocolVersion`,Ot=`io.modelcontextprotocol/clientInfo`,kt=`io.modelcontextprotocol/serverInfo`,At=`io.modelcontextprotocol/clientCapabilities`,jt=`io.modelcontextprotocol/subscriptionId`,Mt=`io.modelcontextprotocol/logLevel`,Nt=it(()=>F([A(),j(),I(),Xe(),k(A(),Nt),P(Nt)])),B=k(A(),Nt),Pt=P(Nt),Ft=F([A(),j().int()]),It=A(),Lt=O({ttl:j().optional()}),Rt=O({taskId:A()}),zt=M({progressToken:Ft.optional(),[Et]:Rt.optional()}),V=O({_meta:zt.optional()}),H=V.extend({task:Lt.optional()}),U=O({method:A(),params:V.loose().optional()}),W=O({_meta:zt.optional()}),G=O({method:A(),params:W.loose().optional()}),Bt=M({get[kt](){return q.optional().catch(void 0)}}),K=M({_meta:Bt.optional()}),Vt=F([A(),j().int()]),Ht=O({jsonrpc:R(`2.0`),id:Vt,...U.shape}).strict(),Ut=O({jsonrpc:R(`2.0`),...G.shape}).strict(),Wt=O({jsonrpc:R(`2.0`),id:Vt,result:K}).strict(),Gt=O({jsonrpc:R(`2.0`),id:Vt.optional(),error:O({code:j().int(),message:A(),data:D().optional()})}).strict(),Kt=F([Ht,Ut,Wt,Gt]),qt=F([Wt,Gt]),Jt=K.strict(),Yt=W.extend({requestId:Vt.optional(),reason:A().optional()}),Xt=G.extend({method:R(`notifications/cancelled`),params:Yt}),Zt=O({src:A(),mimeType:A().optional(),sizes:P(A()).optional(),theme:N([`light`,`dark`]).optional()}),Qt=O({icons:P(Zt).optional()}),$t=O({name:A(),title:A().optional()}),q=$t.extend({...$t.shape,...Qt.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),en=Ue(O({applyDefaults:I().optional()}),B),tn=He(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ue(O({form:en.optional(),url:B.optional()}),B.optional())),nn=M({list:B.optional(),cancel:B.optional(),requests:M({sampling:M({createMessage:B.optional()}).optional(),elicitation:M({create:B.optional()}).optional()}).optional()}),rn=M({list:B.optional(),cancel:B.optional(),requests:M({tools:M({call:B.optional()}).optional()}).optional()}),an=O({experimental:k(A(),B).optional(),sampling:O({context:B.optional(),tools:B.optional()}).optional(),elicitation:tn.optional(),roots:O({listChanged:I().optional()}).optional(),tasks:nn.optional(),extensions:k(A(),B).optional()}),on=V.extend({protocolVersion:A(),capabilities:an,clientInfo:q}),sn=U.extend({method:R(`initialize`),params:on}),cn=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:rn.optional(),extensions:k(A(),B).optional()}),ln=K.extend({protocolVersion:A(),capabilities:cn,serverInfo:q,instructions:A().optional()}),un=G.extend({method:R(`notifications/initialized`),params:W.optional()}),dn=U.extend({method:R(`server/discover`),params:V.optional()}),fn=K.extend({supportedVersions:P(A()),capabilities:cn,instructions:A().optional()}),pn=U.extend({method:R(`ping`),params:V.optional()}),mn=O({progress:j(),total:L(j()),message:L(A())}),hn=O({...W.shape,...mn.shape,progressToken:Ft}),gn=G.extend({method:R(`notifications/progress`),params:hn}),_n=V.extend({cursor:It.optional()}),vn=U.extend({params:_n.optional()}),yn=K.extend({nextCursor:It.optional()}),bn=O({uri:A(),mimeType:L(A()),_meta:k(A(),D()).optional()}),xn=bn.extend({text:A()}),Sn=A().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Cn=bn.extend({blob:Sn}),wn=N([`user`,`assistant`]),Tn=O({audience:P(wn).optional(),priority:j().min(0).max(1).optional(),lastModified:Je({offset:!0}).optional()}),En=O({...$t.shape,...Qt.shape,uri:A(),description:L(A()),mimeType:L(A()),size:L(j()),annotations:Tn.optional(),_meta:L(M({}))}),Dn=O({...$t.shape,...Qt.shape,uriTemplate:A(),description:L(A()),mimeType:L(A()),annotations:Tn.optional(),_meta:L(M({}))}),On=vn.extend({method:R(`resources/list`)}),kn=yn.extend({resources:P(En)}),An=vn.extend({method:R(`resources/templates/list`)}),jn=yn.extend({resourceTemplates:P(Dn)}),Mn=V.extend({uri:A()}),Nn=Mn,Pn=U.extend({method:R(`resources/read`),params:Nn}),Fn=K.extend({contents:P(F([xn,Cn]))}),In=G.extend({method:R(`notifications/resources/list_changed`),params:W.optional()}),Ln=Mn,Rn=U.extend({method:R(`resources/subscribe`),params:Ln}),zn=Mn,Bn=U.extend({method:R(`resources/unsubscribe`),params:zn}),Vn=O({toolsListChanged:I().optional(),promptsListChanged:I().optional(),resourcesListChanged:I().optional(),resourceSubscriptions:P(A()).optional()}),Hn=V.extend({notifications:Vn}),Un=U.extend({method:R(`subscriptions/listen`),params:Hn}),Wn=W.extend({notifications:Vn}),Gn=G.extend({method:R(`notifications/subscriptions/acknowledged`),params:Wn}),Kn=Bt.extend({[jt]:Vt}),qn=K.extend({_meta:Kn}),Jn=W.extend({uri:A()}),Yn=G.extend({method:R(`notifications/resources/updated`),params:Jn}),Xn=O({name:A(),description:L(A()),required:L(I())}),Zn=O({...$t.shape,...Qt.shape,description:L(A()),arguments:L(P(Xn)),_meta:L(M({}))}),Qn=vn.extend({method:R(`prompts/list`)}),$n=yn.extend({prompts:P(Zn)}),er=V.extend({name:A(),arguments:k(A(),A()).optional()}),tr=U.extend({method:R(`prompts/get`),params:er}),nr=O({type:R(`text`),text:A(),annotations:Tn.optional(),_meta:k(A(),D()).optional()}),rr=O({type:R(`image`),data:Sn,mimeType:A(),annotations:Tn.optional(),_meta:k(A(),D()).optional()}),ir=O({type:R(`audio`),data:Sn,mimeType:A(),annotations:Tn.optional(),_meta:k(A(),D()).optional()}),ar=O({type:R(`tool_use`),name:A(),id:A(),input:k(A(),D()),_meta:k(A(),D()).optional()}),or=O({type:R(`resource`),resource:F([xn,Cn]),annotations:Tn.optional(),_meta:k(A(),D()).optional()}),sr=En.extend({type:R(`resource_link`)}),cr=F([nr,rr,ir,sr,or]),lr=O({role:wn,content:cr}),ur=K.extend({description:A().optional(),messages:P(lr)}),dr=G.extend({method:R(`notifications/prompts/list_changed`),params:W.optional()}),fr=O({title:A().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),pr=O({taskSupport:N([`required`,`optional`,`forbidden`]).optional()}),mr=O({...$t.shape,...Qt.shape,description:A().optional(),inputSchema:O({type:R(`object`),properties:k(A(),Nt).optional(),required:P(A()).optional()}).catchall(D()),outputSchema:M({$schema:A().optional()}).optional(),annotations:fr.optional(),execution:pr.optional(),_meta:k(A(),D()).optional()}),hr=vn.extend({method:R(`tools/list`)}),gr=yn.extend({tools:P(mr)}),_r=K.extend({content:P(cr).default([]),structuredContent:D().optional(),isError:I().optional()}),vr=_r.or(K.extend({toolResult:D()})),yr=H.extend({name:A(),arguments:k(A(),D()).optional()}),br=U.extend({method:R(`tools/call`),params:yr}),xr=G.extend({method:R(`notifications/tools/list_changed`),params:W.optional()}),Sr=O({autoRefresh:I().default(!0),debounceMs:j().int().nonnegative().default(300)}),Cr=N([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),wr=V.extend({level:Cr}),Tr=U.extend({method:R(`logging/setLevel`),params:wr}),Er=W.extend({level:Cr,logger:A().optional(),data:D()}),Dr=G.extend({method:R(`notifications/message`),params:Er}),Or=O({name:A().optional()}),kr=O({hints:P(Or).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),Ar=O({mode:N([`auto`,`required`,`none`]).optional()}),jr=O({type:R(`tool_result`),toolUseId:A().describe(`The unique identifier for the corresponding tool call.`),content:P(cr),structuredContent:D().optional(),isError:I().optional(),_meta:k(A(),D()).optional()}),Mr=Ze(`type`,[nr,rr,ir]),Nr=Ze(`type`,[nr,rr,ir,ar,jr]),Pr=O({role:wn,content:F([Nr,P(Nr)]),_meta:k(A(),D()).optional()}),Fr=H.extend({messages:P(Pr),modelPreferences:kr.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(mr).optional(),toolChoice:Ar.optional()}),Ir=U.extend({method:R(`sampling/createMessage`),params:Fr}),Lr=K.extend({model:A(),stopReason:L(N([`endTurn`,`stopSequence`,`maxTokens`]).or(A())),role:wn,content:Mr}),Rr=K.extend({model:A(),stopReason:L(N([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(A())),role:wn,content:F([Nr,P(Nr)])}),zr=O({type:R(`boolean`),title:A().optional(),description:A().optional(),default:I().optional()}),Br=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()}),Vr=O({type:N([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),Hr=O({type:R(`string`),title:A().optional(),description:A().optional(),enum:P(A()),default:A().optional()}),Ur=O({type:R(`string`),title:A().optional(),description:A().optional(),oneOf:P(O({const:A(),title:A()})),default:A().optional()}),Wr=O({type:R(`string`),title:A().optional(),description:A().optional(),enum:P(A()),enumNames:P(A()).optional(),default:A().optional()}),Gr=F([Hr,Ur]),Kr=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()}),qr=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()}),Jr=F([Kr,qr]),Yr=F([Wr,Gr,Jr]),Xr=F([Yr,zr,Br,Vr]),Zr=H.extend({mode:R(`form`).optional(),message:A(),requestedSchema:O({type:R(`object`),properties:k(A(),Xr),required:P(A()).optional()}).catchall(D())}),Qr=H.extend({mode:R(`url`),message:A(),elicitationId:A(),url:A().url()}),$r=F([Zr,Qr]),ei=U.extend({method:R(`elicitation/create`),params:$r}),ti=W.extend({elicitationId:A()}),ni=G.extend({method:R(`notifications/elicitation/complete`),params:ti}),ri=K.extend({action:N([`accept`,`decline`,`cancel`]),content:He(e=>e===null?void 0:e,k(A(),F([A(),j(),I(),P(A())])).optional())}),ii=O({type:R(`ref/resource`),uri:A()}),ai=O({type:R(`ref/prompt`),name:A()}),oi=V.extend({ref:F([ai,ii]),argument:O({name:A(),value:A()}),context:O({arguments:k(A(),A()).optional()}).optional()}),si=U.extend({method:R(`completion/complete`),params:oi}),ci=K.extend({completion:M({values:P(A()).max(100),total:L(j().int()),hasMore:L(I())})}),li=O({uri:A().startsWith(`file://`),name:A().optional(),_meta:k(A(),D()).optional()}),ui=U.extend({method:R(`roots/list`),params:V.optional()}),di=K.extend({roots:P(li)}),fi=G.extend({method:R(`notifications/roots/list_changed`),params:W.optional()}),pi=M({ttl:j().optional(),pollInterval:j().optional()}),mi=N([`working`,`input_required`,`completed`,`failed`,`cancelled`]),hi=O({taskId:A(),status:mi,ttl:F([j(),Xe()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:L(j()),statusMessage:L(A())}),gi=K.extend({task:hi}),_i=W.merge(hi),vi=G.extend({method:R(`notifications/tasks/status`),params:_i}),yi=U.extend({method:R(`tasks/get`),params:V.extend({taskId:A()})}),bi=K.merge(hi),xi=U.extend({method:R(`tasks/result`),params:V.extend({taskId:A()})}),Si=K.loose(),Ci=vn.extend({method:R(`tasks/list`)}),wi=yn.extend({tasks:P(hi)}),Ti=U.extend({method:R(`tasks/cancel`),params:V.extend({taskId:A()})}),Ei=K.merge(hi),Di=F([pn,sn,dn,si,Tr,tr,Qn,On,An,Pn,Rn,Bn,Un,br,hr]),Oi=F([Xt,gn,un,fi]),ki=F([Jt,Lr,Rr,ri,di]),Ai=F([pn,Ir,ei,ui]),ji=F([Xt,gn,Dr,Yn,In,xr,dr,Gn,ni]),Mi=F([Jt,ln,fn,ci,ur,$n,kn,jn,Fn,_r,gr,qn])})))()}var J,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki;function qi(){return(qi=e((()=>{Ke(),tt(),Re(),nt(),J=Ye().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:$e.custom,message:`URL must be parseable`,fatal:!0}),Le}).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`}),Pi=M({resource:A().url(),authorization_servers:P(J).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()}),Fi=M({issuer:A(),authorization_endpoint:J,token_endpoint:J,registration_endpoint:J.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:J.optional(),revocation_endpoint:J.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()}),Ii=M({issuer:A(),authorization_endpoint:J,token_endpoint:J,userinfo_endpoint:J.optional(),jwks_uri:J,registration_endpoint:J.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:J.optional(),op_tos_uri:J.optional(),client_id_metadata_document_supported:I().optional(),authorization_response_iss_parameter_supported:I().optional().catch(void 0)}),Li=O({...Ii.shape,...Fi.pick({code_challenge_methods_supported:!0}).shape}),Ri=O({access_token:A(),id_token:A().optional(),token_type:A(),expires_in:Qe().optional(),scope:A().optional(),refresh_token:A().optional(),issuer:A().optional().catch(void 0)}).strip(),zi=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(),Bi=O({error:A(),error_description:A().optional(),error_uri:A().optional()}),Vi=J.optional().or(R(``).transform(()=>void 0)),Hi=O({redirect_uris:P(J),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:J.optional(),logo_uri:Vi,scope:A().optional(),contacts:P(A()).optional(),tos_uri:Vi,policy_uri:A().optional(),jwks_uri:J.optional(),jwks:Ge().optional(),software_id:A().optional(),software_version:A().optional(),software_statement:A().optional()}).strip(),Ui=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(),Wi=Hi.merge(Ui),Gi=O({error:A(),error_description:A().optional()}).strip(),Ki=O({token:A(),token_type_hint:A().optional()}).strip()})))()}function Ji(){return(Ji=e((()=>{Ni(),qi()})))()}function Yi(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,Ko,{value:n,enumerable:!1,configurable:!0})}function Xi(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Ko)){let n=t[Ko];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>=Jo}function Qi(e){return e.filter(e=>!Zi(e))}function $i(e){return e.filter(e=>Zi(e))}function ea(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 ta(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||Xo.some(t=>t in e)?e:{...e,content:[]}}function na(){let e=it(()=>F([A(),j(),I(),Xe(),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(),h=u.extend({requestId:p.optional(),reason:A().optional()}),g=d.extend({method:R(`notifications/cancelled`),params:h}),_=O({src:A(),mimeType:A().optional(),sizes:P(A()).optional(),theme:N([`light`,`dark`]).optional()}),v=O({icons:P(_).optional()}),y=O({name:A(),title:A().optional()}),b=y.extend({...y.shape,...v.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),ee=Ue(O({applyDefaults:I().optional()}),t),te=He(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ue(O({form:ee.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()}),ie=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()}),ae=s.extend({protocolVersion:A(),capabilities:ie,clientInfo:b}),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:re.optional(),extensions:k(A(),t).optional()}),x=f.extend({protocolVersion:A(),capabilities:se,serverInfo:b,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}),de=d.extend({method:R(`notifications/progress`),params:S}),fe=s.extend({cursor:r.optional()}),pe=l.extend({params:fe.optional()}),C=f.extend({nextCursor:r.optional()}),me=O({uri:A(),mimeType:L(A()),_meta:k(A(),D()).optional()}),he=me.extend({text:A()}),ge=A().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),_e=me.extend({blob:ge}),w=N([`user`,`assistant`]),ve=O({audience:P(w).optional(),priority:j().min(0).max(1).optional(),lastModified:Je({offset:!0}).optional()}),ye=O({...y.shape,...v.shape,uri:A(),description:L(A()),mimeType:L(A()),size:L(j()),annotations:ve.optional(),_meta:L(M({}))}),be=O({...y.shape,...v.shape,uriTemplate:A(),description:L(A()),mimeType:L(A()),annotations:ve.optional(),_meta:L(M({}))}),xe=pe.extend({method:R(`resources/list`)}),Se=C.extend({resources:P(ye)}),T=pe.extend({method:R(`resources/templates/list`)}),Ce=C.extend({resourceTemplates:P(be)}),we=s.extend({uri:A()}),Te=we,Ee=l.extend({method:R(`resources/read`),params:Te}),De=f.extend({contents:P(F([he,_e]))}),Oe=d.extend({method:R(`notifications/resources/list_changed`),params:u.optional()}),ke=we,E=l.extend({method:R(`resources/subscribe`),params:ke}),Ae=we,je=l.extend({method:R(`resources/unsubscribe`),params:Ae}),Me=u.extend({uri:A()}),Ne=d.extend({method:R(`notifications/resources/updated`),params:Me}),Pe=O({name:A(),description:L(A()),required:L(I())}),Fe=O({...y.shape,...v.shape,description:L(A()),arguments:L(P(Pe)),_meta:L(M({}))}),Ie=pe.extend({method:R(`prompts/list`)}),Le=C.extend({prompts:P(Fe)}),Re=s.extend({name:A(),arguments:k(A(),A()).optional()}),ze=l.extend({method:R(`prompts/get`),params:Re}),Be=O({type:R(`text`),text:A(),annotations:ve.optional(),_meta:k(A(),D()).optional()}),Ve=O({type:R(`image`),data:ge,mimeType:A(),annotations:ve.optional(),_meta:k(A(),D()).optional()}),We=O({type:R(`audio`),data:ge,mimeType:A(),annotations:ve.optional(),_meta:k(A(),D()).optional()}),Ge=O({type:R(`tool_use`),name:A(),id:A(),input:k(A(),D()),_meta:k(A(),D()).optional()}),Ke=O({type:R(`resource`),resource:F([he,_e]),annotations:ve.optional(),_meta:k(A(),D()).optional()}),qe=ye.extend({type:R(`resource_link`)}),Ye=F([Be,Ve,We,qe,Ke]),Qe=O({role:w,content:Ye}),$e=f.extend({description:A().optional(),messages:P(Qe)}),et=d.extend({method:R(`notifications/prompts/list_changed`),params:u.optional()}),tt=O({title:A().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),nt=O({taskSupport:N([`required`,`optional`,`forbidden`]).optional()}),rt=O({...y.shape,...v.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:tt.optional(),execution:nt.optional(),_meta:k(A(),D()).optional()}),at=pe.extend({method:R(`tools/list`)}),ot=C.extend({tools:P(rt)}),z=f.extend({content:P(Ye),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(Ye),structuredContent:O({}).loose().optional(),isError:I().optional(),_meta:k(A(),D()).optional()}),yt=Ze(`type`,[Be,Ve,We]),bt=Ze(`type`,[Be,Ve,We,Ge,vt]),xt=O({role:w,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(rt).optional(),toolChoice:_t.optional()}),Ct=l.extend({method:R(`sampling/createMessage`),params:St}),wt=f.extend({model:A(),stopReason:L(N([`endTurn`,`stopSequence`,`maxTokens`]).or(A())),role:w,content:yt}),Tt=f.extend({model:A(),stopReason:L(N([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(A())),role:w,content:F([bt,P(bt)])}),Et=O({type:R(`boolean`),title:A().optional(),description:A().optional(),default:I().optional()}),Dt=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()}),Ot=O({type:N([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),kt=O({type:R(`string`),title:A().optional(),description:A().optional(),enum:P(A()),default:A().optional()}),At=O({type:R(`string`),title:A().optional(),description:A().optional(),oneOf:P(O({const:A(),title:A()})),default:A().optional()}),jt=O({type:R(`string`),title:A().optional(),description:A().optional(),enum:P(A()),enumNames:P(A()).optional(),default:A().optional()}),Mt=F([kt,At]),Nt=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()}),B=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()}),Pt=F([Nt,B]),Ft=F([jt,Mt,Pt]),It=F([Ft,Et,Dt,Ot]),Lt=c.extend({mode:R(`form`).optional(),message:A(),requestedSchema:O({type:R(`object`),properties:k(A(),It),required:P(A()).optional()}).catchall(D())}),Rt=c.extend({mode:R(`url`),message:A(),elicitationId:A(),url:A().url()}),zt=F([Lt,Rt]),V=l.extend({method:R(`elicitation/create`),params:zt}),H=u.extend({elicitationId:A()}),U=d.extend({method:R(`notifications/elicitation/complete`),params:H}),W=f.extend({action:N([`accept`,`decline`,`cancel`]),content:He(e=>e===null?void 0:e,k(A(),F([A(),j(),I(),P(A())])).optional())}),G=O({type:R(`ref/resource`),uri:A()}),Bt=O({type:R(`ref/prompt`),name:A()}),K=s.extend({ref:F([Bt,G]),argument:O({name:A(),value:A()}),context:O({arguments:k(A(),A()).optional()}).optional()}),Vt=l.extend({method:R(`completion/complete`),params:K}),Ht=f.extend({completion:M({values:P(A()).max(100),total:L(j().int()),hasMore:L(I())})}),Ut=O({uri:A().startsWith(`file://`),name:A().optional(),_meta:k(A(),D()).optional()}),Wt=l.extend({method:R(`roots/list`),params:s.optional()}),Gt=f.extend({roots:P(Ut)}),Kt=d.extend({method:R(`notifications/roots/list_changed`),params:u.optional()}),qt=M({ttl:j().optional(),pollInterval:j().optional()}),Jt=N([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Yt=O({taskId:A(),status:Jt,ttl:F([j(),Xe()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:L(j()),statusMessage:L(A())}),Xt=f.extend({task:Yt}),Zt=u.merge(Yt),Qt=d.extend({method:R(`notifications/tasks/status`),params:Zt}),$t=l.extend({method:R(`tasks/get`),params:s.extend({taskId:A()})}),q=f.merge(Yt),en=l.extend({method:R(`tasks/result`),params:s.extend({taskId:A()})}),tn=f.loose(),nn=pe.extend({method:R(`tasks/list`)}),rn=C.extend({tasks:P(Yt)}),an=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:h,CancelledNotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:b,ClientTasksCapabilitySchema:ne,ServerTasksCapabilitySchema:re,ClientCapabilitiesSchema:ie,InitializeRequestParamsSchema:ae,InitializeRequestSchema:oe,ServerCapabilitiesSchema:se,InitializeResultSchema:x,InitializedNotificationSchema:ce,PingRequestSchema:le,ProgressSchema:ue,ProgressNotificationParamsSchema:S,ProgressNotificationSchema:de,PaginatedRequestParamsSchema:fe,PaginatedRequestSchema:pe,PaginatedResultSchema:C,ResourceContentsSchema:me,TextResourceContentsSchema:he,BlobResourceContentsSchema:_e,RoleSchema:w,AnnotationsSchema:ve,ResourceSchema:ye,ResourceTemplateSchema:be,ListResourcesRequestSchema:xe,ListResourcesResultSchema:Se,ListResourceTemplatesRequestSchema:T,ListResourceTemplatesResultSchema:Ce,ResourceRequestParamsSchema:we,ReadResourceRequestParamsSchema:Te,ReadResourceRequestSchema:Ee,ReadResourceResultSchema:De,ResourceListChangedNotificationSchema:Oe,SubscribeRequestParamsSchema:ke,SubscribeRequestSchema:E,UnsubscribeRequestParamsSchema:Ae,UnsubscribeRequestSchema:je,ResourceUpdatedNotificationParamsSchema:Me,ResourceUpdatedNotificationSchema:Ne,PromptArgumentSchema:Pe,PromptSchema:Fe,ListPromptsRequestSchema:Ie,ListPromptsResultSchema:Le,GetPromptRequestParamsSchema:Re,GetPromptRequestSchema:ze,TextContentSchema:Be,ImageContentSchema:Ve,AudioContentSchema:We,ToolUseContentSchema:Ge,EmbeddedResourceSchema:Ke,ResourceLinkSchema:qe,ContentBlockSchema:Ye,PromptMessageSchema:Qe,GetPromptResultSchema:$e,PromptListChangedNotificationSchema:et,ToolAnnotationsSchema:tt,ToolExecutionSchema:nt,ToolSchema:rt,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:wt,CreateMessageResultWithToolsSchema:Tt,BooleanSchemaSchema:Et,StringSchemaSchema:Dt,NumberSchemaSchema:Ot,UntitledSingleSelectEnumSchemaSchema:kt,TitledSingleSelectEnumSchemaSchema:At,LegacyTitledEnumSchemaSchema:jt,SingleSelectEnumSchemaSchema:Mt,UntitledMultiSelectEnumSchemaSchema:Nt,TitledMultiSelectEnumSchemaSchema:B,MultiSelectEnumSchemaSchema:Pt,EnumSchemaSchema:Ft,PrimitiveSchemaDefinitionSchema:It,ElicitRequestFormParamsSchema:Lt,ElicitRequestURLParamsSchema:Rt,ElicitRequestParamsSchema:zt,ElicitRequestSchema:V,ElicitationCompleteNotificationParamsSchema:H,ElicitationCompleteNotificationSchema:U,ElicitResultSchema:W,ResourceTemplateReferenceSchema:G,PromptReferenceSchema:Bt,CompleteRequestParamsSchema:K,CompleteRequestSchema:Vt,CompleteResultSchema:Ht,RootSchema:Ut,ListRootsRequestSchema:Wt,ListRootsResultSchema:Gt,RootsListChangedNotificationSchema:Kt,TaskCreationParamsSchema:qt,TaskStatusSchema:Jt,TaskSchema:Yt,CreateTaskResultSchema:Xt,TaskStatusNotificationParamsSchema:Zt,TaskStatusNotificationSchema:Qt,GetTaskRequestSchema:$t,GetTaskResultSchema:q,GetTaskPayloadRequestSchema:en,GetTaskPayloadResultSchema:tn,ListTasksRequestSchema:nn,ListTasksResultSchema:rn,CancelTaskRequestSchema:an,CancelTaskResultSchema:f.merge(Yt),ClientRequestSchema:F([le,oe,Vt,ft,ze,Ie,xe,T,Ee,E,je,ct,at,$t,en,nn,an]),ClientNotificationSchema:F([g,de,ce,Kt,Qt]),ClientResultSchema:F([m,wt,Tt,W,Gt,q,rn,Xt]),ServerRequestSchema:F([le,Ct,V,Wt,$t,en,nn,an]),ServerNotificationSchema:F([g,de,mt,Ne,Oe,lt,et,Qt,U]),ServerResultSchema:F([m,x,Ht,$e,Le,Se,Ce,De,z,ot,q,rn,Xt]),CallToolResultWireSchema:D().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of Xo)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(ta).pipe(z)}}function ra(){return Zo??=na()}function ia(e){return e.type!==`object`}function aa(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function oa(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(aa(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=_t(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&&aa(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]=Qo.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 sa(){if(rs)return rs;let e=ra();return rs={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}},rs}function ca(e){return Object.prototype.hasOwnProperty.call(es,e)}function la(e){return Object.prototype.hasOwnProperty.call(ts,e)}function ua(e){return Object.prototype.hasOwnProperty.call(ns,e)}function da(e){return ua(e)?sa().resultSchemas[e]:void 0}function fa(e){return ca(e)?sa().requestSchemas[e]:void 0}function pa(e){return la(e)?sa().notificationSchemas[e]:void 0}function ma(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ha(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}function ga(e){return ma(e)&&ma(e.outputSchema)&&ia(e.outputSchema)}function _a(e){return e}function va(){let e=it(()=>F([A(),j(),I(),Xe(),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()}),h=O({src:A(),mimeType:A().optional(),sizes:P(A()).optional(),theme:N([`light`,`dark`]).optional()}),g=O({icons:P(h).optional()}),_=O({name:A(),title:A().optional()}),v=_.extend({..._.shape,...g.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),y=Ue(O({applyDefaults:I().optional()}),t),b=He(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ue(O({form:y.optional(),url:t.optional()}),t.optional())),ee=M({list:t.optional(),cancel:t.optional(),requests:M({sampling:M({createMessage:t.optional()}).optional(),elicitation:M({create:t.optional()}).optional()}).optional()}),te=M({list:t.optional(),cancel:t.optional(),requests:M({tools:M({call:t.optional()}).optional()}).optional()}),ne=O({experimental:k(A(),t).optional(),sampling:O({context:t.optional(),tools:t.optional()}).optional(),elicitation:b.optional(),roots:O({listChanged:I().optional()}).optional(),tasks:ee.optional(),extensions:k(A(),t).optional()}),re=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:te.optional(),extensions:k(A(),t).optional()}),ie=O({progress:j(),total:L(j()),message:L(A())}),ae=O({...p.shape,...ie.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:Je({offset:!0}).optional()}),de=O({..._.shape,...g.shape,uri:A(),description:L(A()),mimeType:L(A()),size:L(j()),annotations:S.optional(),_meta:L(M({}))}),fe=O({..._.shape,...g.shape,uriTemplate:A(),description:L(A()),mimeType:L(A()),annotations:S.optional(),_meta:L(M({}))}),pe=m.extend({method:R(`notifications/resources/list_changed`),params:p.optional()}),C=p.extend({uri:A()}),me=m.extend({method:R(`notifications/resources/updated`),params:C}),he=O({name:A(),description:L(A()),required:L(I())}),ge=O({..._.shape,...g.shape,description:L(A()),arguments:L(P(he)),_meta:L(M({}))}),_e=m.extend({method:R(`notifications/prompts/list_changed`),params:p.optional()}),w=O({type:R(`text`),text:A(),annotations:S.optional(),_meta:k(A(),D()).optional()}),ve=O({type:R(`image`),data:s,mimeType:A(),annotations:S.optional(),_meta:k(A(),D()).optional()}),ye=O({type:R(`audio`),data:s,mimeType:A(),annotations:S.optional(),_meta:k(A(),D()).optional()}),be=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([le,ue]),annotations:S.optional(),_meta:k(A(),D()).optional()}),Se=de.extend({type:R(`resource_link`)}),T=F([w,ve,ye,Se,xe]),Ce=O({role:a,content:T}),we=O({title:A().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),Te=m.extend({method:R(`notifications/tools/list_changed`),params:p.optional()}),Ee=O({name:A().optional()}),De=O({hints:P(Ee).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),Oe=O({mode:N([`auto`,`required`,`none`]).optional()}),ke=O({type:R(`boolean`),title:A().optional(),description:A().optional(),default:I().optional()}),E=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()}),Ae=O({type:N([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),je=O({type:R(`string`),title:A().optional(),description:A().optional(),enum:P(A()),default:A().optional()}),Me=O({type:R(`string`),title:A().optional(),description:A().optional(),oneOf:P(O({const:A(),title:A()})),default:A().optional()}),Ne=O({type:R(`string`),title:A().optional(),description:A().optional(),enum:P(A()),enumNames:P(A()).optional(),default:A().optional()}),Pe=F([je,Me]),Fe=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()}),Ie=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()}),Le=F([Fe,Ie]),Re=F([Ne,Pe,Le]),ze=F([Re,ke,E,Ae]),Be=f.extend({mode:R(`form`).optional(),message:A(),requestedSchema:O({type:R(`object`),properties:k(A(),ze),required:P(A()).optional()}).catchall(D())}),Ve=O({type:R(`ref/resource`),uri:A()}),We=O({type:R(`ref/prompt`),name:A()}),Ge=O({uri:A().startsWith(`file://`),name:A().optional(),_meta:k(A(),D()).optional()}),Ke=ne.shape,qe=O({experimental:Ke.experimental,sampling:Ke.sampling,elicitation:Ke.elicitation,roots:Ke.roots,extensions:Ke.extensions}),Ye=re.shape,Ze=O({experimental:Ye.experimental,logging:Ye.logging,completions:Ye.completions,prompts:Ye.prompts,resources:Ye.resources,tools:Ye.tools,extensions:Ye.extensions}),Qe=M({progressToken:n.optional(),[Dt]:A(),[Ot]:v.optional(),[At]:qe,[Mt]:o.optional()}),$e=O({..._.shape,...g.shape,description:A().optional(),inputSchema:M({$schema:A().optional(),type:R(`object`)}),outputSchema:M({$schema:A().optional()}).optional(),annotations:we.optional(),_meta:k(A(),D()).optional()}),et=O({type:R(`tool_result`),toolUseId:A(),content:P(T),structuredContent:D().optional(),isError:I().optional(),_meta:k(A(),D()).optional()}),tt=F([w,ve,ye,be,et]),nt=O({role:a,content:F([tt,P(tt)]),_meta:k(A(),D()).optional()}),rt=A(),at=M({[kt]:v.optional().catch(void 0)}),ot=at.optional();function z(e){return M({_meta:ot,resultType:rt.default(`complete`),...e})}let st=z({}),ct=z({nextCursor:r.optional()}),lt=z({content:P(T),structuredContent:D().optional(),isError:I().optional()}),ut=z({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),tools:P($e),nextCursor:r.optional()}),dt=z({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),prompts:P(ge),nextCursor:r.optional()}),ft=z({description:A().optional(),messages:P(Ce)}),pt=z({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),resources:P(de),nextCursor:r.optional()}),mt=z({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),resourceTemplates:P(fe),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()}),_t=z({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`])}),vt=z({ttlMs:j().int().min(0).catch(0),cacheScope:N([`public`,`private`]).catch(`private`),supportedVersions:P(A()),capabilities:Ze,instructions:A().optional()}),yt=O({messages:P(nt),modelPreferences:De.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($e).optional(),toolChoice:Oe.optional()}),bt=O({method:R(`sampling/createMessage`),params:yt}),xt=O({method:R(`roots/list`),params:O({_meta:k(A(),D()).optional()}).optional()}),St=O({...nt.shape,model:A(),stopReason:A().optional()}),Ct=O({roots:P(Ge)}),wt=O({action:N([`accept`,`decline`,`cancel`]),content:k(A(),F([A(),j(),I(),P(A())])).optional()}),Tt=O({mode:R(`url`),message:A(),url:A().url()}),Et=F([Be,Tt]),jt=O({method:R(`elicitation/create`),params:Et}),Nt=F([bt,xt,jt]),B=F([St,Ct,wt]),Pt=k(A(),Nt),Ft=k(A(),B),It=z({inputRequests:Pt.optional(),requestState:A().optional()}),Lt={inputResponses:Ft.optional(),requestState:A().optional()},Rt=O({_meta:Qe,...Lt}),zt=M({progressToken:n.optional()});function V(e,t){return O({method:R(e),params:O({_meta:Qe,...t})})}function H(e,t){return O({method:R(e),params:O({_meta:zt.optional(),...t}).optional()})}let U={name:A(),arguments:k(A(),D()).optional(),...Lt},W={cursor:r.optional()},G=V(`tools/call`,U),Bt=V(`tools/list`,W),K=V(`prompts/list`,W),Vt=V(`prompts/get`,{name:A(),arguments:k(A(),A()).optional(),...Lt}),Ht=V(`resources/list`,W),Ut=V(`resources/templates/list`,W),Wt=V(`resources/read`,{uri:A(),...Lt}),Gt={ref:F([We,Ve]),argument:O({name:A(),value:A()}),context:O({arguments:k(A(),A()).optional()}).optional()},Kt=V(`completion/complete`,Gt),qt=V(`server/discover`,{}),Jt=O({toolsListChanged:I().optional(),promptsListChanged:I().optional(),resourcesListChanged:I().optional(),resourceSubscriptions:P(A()).optional()}),Yt={notifications:Jt},Xt=V(`subscriptions/listen`,Yt),Zt=at.extend({"io.modelcontextprotocol/subscriptionId":i}),Qt=M({_meta:Zt,resultType:rt.default(`complete`)}),$t={"tools/call":H(`tools/call`,U),"tools/list":H(`tools/list`,W),"prompts/get":H(`prompts/get`,{name:A(),arguments:k(A(),A()).optional()}),"prompts/list":H(`prompts/list`,W),"resources/list":H(`resources/list`,W),"resources/templates/list":H(`resources/templates/list`,W),"resources/read":H(`resources/read`,{uri:A()}),"completion/complete":H(`completion/complete`,Gt),"server/discover":H(`server/discover`,{}),"subscriptions/listen":H(`subscriptions/listen`,Yt)};function q(e){return M({_meta:ot,...e})}let en={"tools/call":q({content:P(T),structuredContent:D().optional(),isError:I().optional()}),"tools/list":q({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),tools:P($e),nextCursor:r.optional()}),"prompts/get":q({description:A().optional(),messages:P(Ce)}),"prompts/list":q({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),prompts:P(ge),nextCursor:r.optional()}),"resources/list":q({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),resources:P(de),nextCursor:r.optional()}),"resources/templates/list":q({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),resourceTemplates:P(fe),nextCursor:r.optional()}),"resources/read":q({ttlMs:j().int().min(0),cacheScope:N([`public`,`private`]),contents:P(F([le,ue]))}),"completion/complete":q({completion:O({values:P(A()).max(100),total:j().int().optional(),hasMore:I().optional()}).loose()}),"server/discover":q({ttlMs:j().int().min(0).catch(0),cacheScope:N([`public`,`private`]).catch(`private`),supportedVersions:P(A()),capabilities:Ze,instructions:A().optional()}),"subscriptions/listen":q({})},tn=M({"io.modelcontextprotocol/subscriptionId":i.optional()}),nn=O({method:R(`notifications/subscriptions/acknowledged`),params:O({_meta:tn.optional(),notifications:Jt})}),rn=O({_meta:tn.optional(),requestId:i,reason:A().optional()}),an=O({method:R(`notifications/cancelled`),params:rn}),on={"notifications/cancelled":an,"notifications/progress":oe,"notifications/message":x,"notifications/resources/updated":me,"notifications/resources/list_changed":pe,"notifications/tools/list_changed":Te,"notifications/prompts/list_changed":_e,"notifications/subscriptions/acknowledged":nn},sn=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:h,IconsSchema:g,BaseMetadataSchema:_,ImplementationSchema:v,ClientTasksCapabilitySchema:ee,ServerTasksCapabilitySchema:te,ClientCapabilitiesSchema:ne,ServerCapabilitiesSchema:re,ProgressSchema:ie,ProgressNotificationParamsSchema:ae,ProgressNotificationSchema:oe,LoggingMessageNotificationParamsSchema:se,LoggingMessageNotificationSchema:x,ResourceContentsSchema:ce,TextResourceContentsSchema:le,BlobResourceContentsSchema:ue,AnnotationsSchema:S,ResourceSchema:de,ResourceTemplateSchema:fe,ResourceListChangedNotificationSchema:pe,ResourceUpdatedNotificationParamsSchema:C,ResourceUpdatedNotificationSchema:me,PromptArgumentSchema:he,PromptSchema:ge,PromptListChangedNotificationSchema:_e,TextContentSchema:w,ImageContentSchema:ve,AudioContentSchema:ye,ToolUseContentSchema:be,EmbeddedResourceSchema:xe,ResourceLinkSchema:Se,ContentBlockSchema:T,PromptMessageSchema:Ce,ToolAnnotationsSchema:we,ToolListChangedNotificationSchema:Te,ModelHintSchema:Ee,ModelPreferencesSchema:De,ToolChoiceSchema:Oe,BooleanSchemaSchema:ke,StringSchemaSchema:E,NumberSchemaSchema:Ae,UntitledSingleSelectEnumSchemaSchema:je,TitledSingleSelectEnumSchemaSchema:Me,LegacyTitledEnumSchemaSchema:Ne,SingleSelectEnumSchemaSchema:Pe,UntitledMultiSelectEnumSchemaSchema:Fe,TitledMultiSelectEnumSchemaSchema:Ie,MultiSelectEnumSchemaSchema:Le,EnumSchemaSchema:Re,PrimitiveSchemaDefinitionSchema:ze,ElicitRequestFormParamsSchema:Be,ResourceTemplateReferenceSchema:Ve,PromptReferenceSchema:We,RootSchema:Ge,ClientCapabilities2026Schema:qe,ServerCapabilities2026Schema:Ze,RequestMetaEnvelopeSchema:Qe,ToolSchema:$e,ToolResultContentSchema:et,SamplingMessageContentBlockSchema:tt,SamplingMessageSchema:nt,ResultTypeSchema:rt,ResultMetaSchema:at,ResultSchema:st,PaginatedResultSchema:ct,CallToolResultSchema:lt,ListToolsResultSchema:ut,ListPromptsResultSchema:dt,GetPromptResultSchema:ft,ListResourcesResultSchema:pt,ListResourceTemplatesResultSchema:mt,ReadResourceResultSchema:ht,CompleteResultSchema:gt,CacheableResultSchema:_t,DiscoverResultSchema:vt,CreateMessageRequestParamsSchema:yt,CreateMessageRequestSchema:bt,ListRootsRequestSchema:xt,CreateMessageResultSchema:St,ListRootsResultSchema:Ct,ElicitResultSchema:wt,ElicitRequestURLParamsSchema:Tt,ElicitRequestParamsSchema:Et,ElicitRequestSchema:jt,InputRequestSchema:Nt,InputResponseSchema:B,InputRequestsSchema:Pt,InputResponsesSchema:Ft,InputRequiredResultSchema:It,InputResponseRequestParamsSchema:Rt,CallToolRequestSchema:G,ListToolsRequestSchema:Bt,ListPromptsRequestSchema:K,GetPromptRequestSchema:Vt,ListResourcesRequestSchema:Ht,ListResourceTemplatesRequestSchema:Ut,ReadResourceRequestSchema:Wt,CompleteRequestSchema:Kt,DiscoverRequestSchema:qt,SubscriptionFilterSchema:Jt,SubscriptionsListenRequestSchema:Xt,SubscriptionsListenResultMetaSchema:Zt,SubscriptionsListenResultSchema:Qt,dispatchRequestSchemas:$t,dispatchResultSchemas:en,NotificationMetaSchema:tn,SubscriptionsAcknowledgedNotificationSchema:nn,CancelledNotificationParamsSchema:rn,CancelledNotificationSchema:an,notificationSchemas2026:on,JSONRPCResultResponseSchema:sn(st),CallToolResultResponseSchema:sn(F([lt,It])),ListToolsResultResponseSchema:sn(ut),ListPromptsResultResponseSchema:sn(dt),GetPromptResultResponseSchema:sn(F([ft,It])),ListResourcesResultResponseSchema:sn(pt),ListResourceTemplatesResultResponseSchema:sn(mt),ReadResourceResultResponseSchema:sn(F([ht,It])),CompleteResultResponseSchema:sn(gt),DiscoverResultResponseSchema:sn(vt),SubscriptionsListenResultResponseSchema:sn(Qt)}}function ya(){return os??=va()}function ba(e){return ss.includes(e)}function xa(e){return e[cs]}function Sa(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Ca(e){return e===`public`||e===`private`}function wa(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||hs.includes(e))return t;throw new Q(Z.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Ta(e,t){let n=xa(t);if(t.resultType!==`complete`||!ba(e))return n===void 0?t:Aa(t);let r=t,i=Sa(r.ttlMs)?r.ttlMs:Oa(n),a=Ca(r.cacheScope)?r.cacheScope:ka(n),o={...r,ttlMs:i,cacheScope:a};return delete o[cs],o}function Ea(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Da(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[kt]:t}}:!Ea(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[kt]:t}}}function Oa(e){return e!==void 0&&Sa(e.ttlMs)?e.ttlMs:ps}function ka(e){return e!==void 0&&Ca(e.cacheScope)?e.cacheScope:ms}function Aa(e){let t={...e};return delete t[cs],t}function ja(){if(_s)return _s;let e=ya();return _s={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}},_s}function Ma(e){return gs.includes(e)}function Na(e){return Ma(e)?ja().request[e]:void 0}function Pa(e){return Ma(e)?ja().response[e]:void 0}function Fa(e){return Object.prototype.hasOwnProperty.call(vs,e)}function Ia(e){return Object.prototype.hasOwnProperty.call(ys,e)}function La(e){return Object.prototype.hasOwnProperty.call(vs,e)}function Ra(e){return Fa(e)?ya().dispatchRequestSchemas[e]:void 0}function za(e){return La(e)?ya().dispatchResultSchemas[e]:void 0}function Ba(e){return Ia(e)?ya().notificationSchemas2026[e]:void 0}function Va(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ha(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}function Ua(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=>Va(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!Va(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(Va(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}function Wa(){if(Cs)return Cs;let e=ya();return Cs={"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},Cs}function Ga(e){return e!==void 0&&Zi(e)?Ss:as}function Ka(e){return e.revision===void 0?e.era===`modern`?Ss.era:as.era:Ga(e.revision).era}function qa(e){return Ts.some(t=>t.hasRequestMethod(e))}function Ja(e){return Ts.some(t=>t.hasNotificationMethod(e))}function Ya(e){return e===`tasks/get`||e===`tasks/cancel`}function Xa(e){let t=[],n=new Map,r,i=(e,a,o)=>{if(typeof e!=`object`||!e)return;let s=e;if(Ns in s){if(!o||a.length===0)return`${Za(a)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let e=s[Ns];if(typeof e!=`string`||e.length===0)return`${Za(a)}: x-mcp-header MUST be a non-empty string`;if(!Ps.test(e))return`${Za(a)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let i=typeof s.type==`string`?s.type:void 0;if(i===void 0||!Fs.has(i)){let e=`${Za(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${i??`<none>`}`;if(i!==`number`)return e;r??=e}let c=e.toLowerCase(),l=n.get(c);if(l!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${l}')`;n.set(c,e),t.push({path:a,headerName:e,type:i})}let c=s.properties;if(typeof c==`object`&&c)for(let[e,t]of Object.entries(c)){let n=i(t,[...a,e],o);if(n!==void 0)return n}for(let e of Is){let t=s[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Ls.has(e)?Object.values(t):[t];for(let t of n){let n=i(t,[...a,`<${e}>`],!1);if(n!==void 0)return n}}},a=i(e,[],!0);return a===void 0?r===void 0?{valid:!0,declarations:t}:{valid:!1,reason:r,declarations:t}:{valid:!1,reason:r??a}}function Za(e){return e.length===0?`<root>`:e.join(`.`)}function Qa(e){if(typeof e==`string`)return e;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function $a(e){if(e.length===0||e.startsWith(Rs)&&e.endsWith(zs)||e!==e.trim())return!0;for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(!(n===9||n>=32&&n<=126))return!0}return!1}function eo(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCodePoint(e);return btoa(n)}function to(e){return $a(e)?`${Rs}${eo(e)}${zs}`:e}function no(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function ro(e,t){let n={};for(let r of e){let e=no(t,r.path);if(e==null)continue;let i=Qa(e);i!==void 0&&(n[`${Ms}${r.headerName}`]=to(i))}return n}function io(e,t){return Be(e,t)}function ao(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function oo(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 so(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:Vs});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().`);Bs||(Bs=!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=Ie(e,{target:Vs,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&&co(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 co(e,t=e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;let n=typeof e.$ref==`string`&&Hs.exec(e.$ref);if(n&&t[n[1]]?.[n[2]]?.type===`object`)return!0;for(let n of[`oneOf`,`anyOf`,`allOf`]){let r=e[n];if(Array.isArray(r)&&r.length>0)return r.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||co(e,`$id`in e?{}:t)))}return!1}function lo(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function uo(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>lo(e)).join(`, `)}:{success:!0,data:n.value}}function fo(e){let t=Ie(e,{target:Vs,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}function po(e){let t=Us.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=>Je({local:e,offset:t,precision:n}))))}function mo(e,t){let n;switch(e){case`email`:n=[qe()];break;case`uri`:n=[Ye()];break;case`date`:n=[et()];break;case`date-time`:n=po(t)}return new Set(n.map(e=>fo(e)).filter(e=>e!==void 0))}function ho(e,t,n){return n!==`zod`||mo(e,t).has(t)}function go(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _o(e){try{return so(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Q(Z.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}function vo(e){return Ws.has(e)||e.startsWith(`x-`)}function yo(e,t,n,r){if(!go(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(Ks,e.type)?Ks[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||vo(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?qs.has(e.format)?(typeof s!=`string`||!ho(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function bo(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&go(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,yo(n,`properties.${e}`,t,r)])):Gs.has(i)?n[i]=a:vo(i)||r.push(i);if(r.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function xo(e,t){if(!go(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!io(Xr,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function So(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>So(e,t[r],`${n}[${r}]`)):!go(e)||!go(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?So(r,t[e],i):vo(e)?[]:[i]})}function Co(e){if(!oo(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=bo(_o(e.requestedSchema),t),r=io(Zr.shape.requestedSchema,n);if(!r.success)throw new Q(Z.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${xo(n,r.error.message)}`);let i=So(n,r.data);if(i.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function wo(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 To(e){return{autoFulfill:e?.autoFulfill??Js,maxRounds:e?.maxRounds??Ys}}function Eo(e,t,n){let r=t!==void 0&&Object.keys(t).length>0;return!r&&n===void 0?e:{...e,...r&&{inputResponses:t},...n!==void 0&&{requestState:n}}}function Do(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Oo(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof X?t.reason:new X(Y.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof X?t.reason:new X(Y.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function ko(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}async function Ao(e){let{config:t,method:n,originalParams:r,requestOptions:i,hooks:a,signal:o}=e,s=e.flowStartedAt??Date.now(),c=e.firstPayload,l=0;for(;;){if(l+=1,l>t.maxRounds)throw new X(Y.InputRequiredRoundsExceeded,Do(n,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:c.inputRequests,...c.requestState!==void 0&&{requestState:c.requestState}}});i.onprogress?.({progress:l,message:`Fulfilling input required by '${n}' (round ${l})`});let e=Object.entries(c.inputRequests??{}),u;if(e.length>0){let t=ko(o);try{let n=await Promise.all(e.map(async([e,n])=>{try{return[e,await a.dispatchInputRequest(e,n,t.signal)]}catch(e){throw t.abort(e),e}}));u=Object.fromEntries(n)}finally{t.dispose()}}else await Oo(Xs,o);let d={...i.timeout!==void 0&&{timeout:i.timeout}};if(i.maxTotalTimeout!==void 0){let e=Date.now()-s,t=i.maxTotalTimeout-e;if(t<=0)throw new X(Y.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:i.maxTotalTimeout,totalElapsed:e});d.maxTotalTimeout=t}let f=await a.retry(Eo(r,u,c.requestState),d);if(js(f))c={inputRequests:f.inputRequests??{},...f.requestState!==void 0&&{requestState:f.requestState}};else return f}}function jo(e,t){let n=e.slice(0,-6);$s[n]=t,ec[n]=e=>t.safeParse(e).success}function Mo(e){switch(e){case`initialize`:case`notifications/initialized`:return Ga(void 0);case`server/discover`:return Ga(ws);default:return}}function No(e,t){let n=e.params;if(!Io(n))return{message:e,lifted:{}};let r=n._meta,i=Io(r)?rc.filter(e=>e in r):[],a=t===`request`?ic.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&Io(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 Po(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 Fo(e){return()=>e}function Io(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lo(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=Io(a)&&Io(i)?{...a,...i}:i}return n}function Ro(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zo(e){let t={},n=[];if(!Ro(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e))!Ro(i)||`method`in i||`result`in i?n.push(r):t[r]=i;return{accepted:t,droppedKeys:n}}function Bo(e){throw new X(Y.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function Vo(e,t,n,r,i){return{sessionId:i,mcpReq:{id:e,method:t,_meta:n?._meta,requestState:Fo(void 0),signal:r,send:(()=>Bo(`send`)),notify:()=>Bo(`notify`)}}}async function Ho(e,t,n,r,i){if(!Ro(r)||typeof r.method!=`string`)throw new X(Y.InvalidResult,`Invalid input request '${n}': each inputRequests entry must be an embedded request object with a method`,{key:n});let a=r.method;if(!t.hasInputRequestMethod(a))throw new X(Y.InvalidResult,`Invalid input request '${n}': '${a}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:n,method:a});let o=e.getRequestHandler(a);if(o===void 0)throw new X(Y.CapabilityNotSupported,`Cannot fulfil input request '${n}': no handler is registered for '${a}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:n,method:a});let s=Ro(r.params)?r.params:void 0;return await o({jsonrpc:`2.0`,id:n,method:a,...s!==void 0&&{params:s}},e.buildContext(Vo(n,a,s,i,e.sessionId)))}function Uo(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function Wo(e,t,n,r){let{codec:i,request:a,options:o,flowStartedAt:s}=r,c={inputRequests:n.inputRequests,...n.requestState!==void 0&&{requestState:n.requestState}},l={dispatchInputRequest:(t,n,r)=>Ho(e,i,t,n,r),retry:(e,t)=>r.retry(e,Uo(o,t))};return Ao({config:t,method:a.method,originalParams:a.params,firstPayload:c,flowStartedAt:s,signal:o?.signal,requestOptions:{...o?.timeout!==void 0&&{timeout:o.timeout},...o?.maxTotalTimeout!==void 0&&{maxTotalTimeout:o.maxTotalTimeout},...o?.onprogress!==void 0&&{onprogress:o.onprogress}},hooks:l})}function Go(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var Ko,Y,X,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,Z,Q,ls,us,ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,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;function sc(){return(sc=e((()=>{gt(),Ct(),Ji(),Ke(),We(),ze(),Ve(),Ko=Symbol.for(`mcp.sdk.errorBrands`),class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return Xi(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 Xi(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Yi(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},Y=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),X=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Xi(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 Xi(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,Yi(this,new.target)}},qo=class extends X{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}},Jo=`2026-07-28`,Yo=[Jo],Xo=[`task`,`inputRequests`,`requestState`],Qo=new Set([`const`,`enum`,`default`,`examples`]),$o=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]),es={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},ts={"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},ns={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(es),Object.keys(ts),is={ok:!1,reason:`not-in-era`},as={era:`2025-11-25`,hasRequestMethod:ca,hasNotificationMethod:la,validateRequest:(e,t)=>ha(fa(e),t),validateResult:(e,t)=>ha(da(e),t),validateNotification:(e,t)=>ha(pa(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>is,validateInputResponse:()=>is,samplingResultVariant:((e,t)=>{let n=ra();return ha(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=ea(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&ia(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(ma(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:_a(e)}}return{kind:`complete`,result:_a(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>ga(e))?t:{...t,tools:n.map(e=>ga(e)?{...e,outputSchema:oa(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0},ss=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`],cs=Symbol(`modelcontextprotocol.resultCacheHintFallback`),Z=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Q=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Xi(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 Xi(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Yi(this,new.target)}static fromError(t,n,r){if(t===Z.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new us(e.elicitations,n)}if(t===Z.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new ds({supported:e.supported,requested:e.requested},n)}if(t===Z.InvalidParams||t===Z.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===Z.ResourceNotFound||Object.keys(e).length===1))return new ls(e.uri,n)}if(t===Z.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new fs({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},ls=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(Z.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},us=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Z.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},ds=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Z.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},fs=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(Z.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},ps=0,ms=`private`,hs=[`tools/call`,`prompts/get`,`resources/read`],gs=[`elicitation/create`,`sampling/createMessage`,`roots/list`],vs={"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},ys={"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(vs),Object.keys(ys),bs={ok:!1,reason:`not-in-era`},xs=[Dt,At],Ss={era:`2026-07-28`,hasRequestMethod:Fa,hasNotificationMethod:Ia,hasInputRequestMethod:e=>Na(e)!==void 0,validateRequest:(e,t)=>Ha(Ra(e),t),validateResult:(e,t)=>Ha(za(e),t),validateNotification:(e,t)=>Ha(Ba(e),t),validateInputRequest:(e,t)=>Ha(Na(e),t),validateInputResponse:(e,t)=>Ha(Pa(e),t),samplingResultVariant:()=>bs,outboundEnvelope(e){return{[Dt]:e.protocolVersion,[Ot]:e.clientInfo,[At]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of xs)n in e||t.push({key:n,problem:`missing`});let n=ya().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=>ea(e),inputRequestSchema:Na,decodeResult(e,t){if(!Va(t))return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=Va(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:ya().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new X(Y.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=Wa(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return Da(Ta(e,wa(e,Ua(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=ya().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(`; `)}`}},ws=`2026-07-28`,Ts=[as,Ss],Es=ht({AnnotationsSchema:()=>Tn,AudioContentSchema:()=>ir,BaseMetadataSchema:()=>$t,BaseRequestParamsSchema:()=>V,BlobResourceContentsSchema:()=>Cn,BooleanSchemaSchema:()=>zr,CallToolRequestParamsSchema:()=>yr,CallToolRequestSchema:()=>br,CallToolResultSchema:()=>_r,CancelTaskRequestSchema:()=>Ti,CancelTaskResultSchema:()=>Ei,CancelledNotificationParamsSchema:()=>Yt,CancelledNotificationSchema:()=>Xt,ClientCapabilitiesSchema:()=>an,ClientNotificationSchema:()=>Oi,ClientRequestSchema:()=>Di,ClientResultSchema:()=>ki,ClientTasksCapabilitySchema:()=>nn,CompatibilityCallToolResultSchema:()=>vr,CompleteRequestParamsSchema:()=>oi,CompleteRequestSchema:()=>si,CompleteResultSchema:()=>ci,ContentBlockSchema:()=>cr,CreateMessageRequestParamsSchema:()=>Fr,CreateMessageRequestSchema:()=>Ir,CreateMessageResultSchema:()=>Lr,CreateMessageResultWithToolsSchema:()=>Rr,CreateTaskResultSchema:()=>gi,CursorSchema:()=>It,DiscoverRequestSchema:()=>dn,DiscoverResultSchema:()=>fn,ElicitRequestFormParamsSchema:()=>Zr,ElicitRequestParamsSchema:()=>$r,ElicitRequestSchema:()=>ei,ElicitRequestURLParamsSchema:()=>Qr,ElicitResultSchema:()=>ri,ElicitationCompleteNotificationParamsSchema:()=>ti,ElicitationCompleteNotificationSchema:()=>ni,EmbeddedResourceSchema:()=>or,EmptyResultSchema:()=>Jt,EnumSchemaSchema:()=>Yr,GetPromptRequestParamsSchema:()=>er,GetPromptRequestSchema:()=>tr,GetPromptResultSchema:()=>ur,GetTaskPayloadRequestSchema:()=>xi,GetTaskPayloadResultSchema:()=>Si,GetTaskRequestSchema:()=>yi,GetTaskResultSchema:()=>bi,IconSchema:()=>Zt,IconsSchema:()=>Qt,ImageContentSchema:()=>rr,ImplementationSchema:()=>q,InitializeRequestParamsSchema:()=>on,InitializeRequestSchema:()=>sn,InitializeResultSchema:()=>ln,InitializedNotificationSchema:()=>un,JSONArraySchema:()=>Pt,JSONObjectSchema:()=>B,JSONRPCErrorResponseSchema:()=>Gt,JSONRPCMessageSchema:()=>Kt,JSONRPCNotificationSchema:()=>Ut,JSONRPCRequestSchema:()=>Ht,JSONRPCResponseSchema:()=>qt,JSONRPCResultResponseSchema:()=>Wt,JSONValueSchema:()=>Nt,LegacyTitledEnumSchemaSchema:()=>Wr,ListChangedOptionsBaseSchema:()=>Sr,ListPromptsRequestSchema:()=>Qn,ListPromptsResultSchema:()=>$n,ListResourceTemplatesRequestSchema:()=>An,ListResourceTemplatesResultSchema:()=>jn,ListResourcesRequestSchema:()=>On,ListResourcesResultSchema:()=>kn,ListRootsRequestSchema:()=>ui,ListRootsResultSchema:()=>di,ListTasksRequestSchema:()=>Ci,ListTasksResultSchema:()=>wi,ListToolsRequestSchema:()=>hr,ListToolsResultSchema:()=>gr,LoggingLevelSchema:()=>Cr,LoggingMessageNotificationParamsSchema:()=>Er,LoggingMessageNotificationSchema:()=>Dr,ModelHintSchema:()=>Or,ModelPreferencesSchema:()=>kr,MultiSelectEnumSchemaSchema:()=>Jr,NotificationSchema:()=>G,NotificationsParamsSchema:()=>W,NumberSchemaSchema:()=>Vr,PaginatedRequestParamsSchema:()=>_n,PaginatedRequestSchema:()=>vn,PaginatedResultSchema:()=>yn,PingRequestSchema:()=>pn,PrimitiveSchemaDefinitionSchema:()=>Xr,ProgressNotificationParamsSchema:()=>hn,ProgressNotificationSchema:()=>gn,ProgressSchema:()=>mn,ProgressTokenSchema:()=>Ft,PromptArgumentSchema:()=>Xn,PromptListChangedNotificationSchema:()=>dr,PromptMessageSchema:()=>lr,PromptReferenceSchema:()=>ai,PromptSchema:()=>Zn,ReadResourceRequestParamsSchema:()=>Nn,ReadResourceRequestSchema:()=>Pn,ReadResourceResultSchema:()=>Fn,RelatedTaskMetadataSchema:()=>Rt,RequestIdSchema:()=>Vt,RequestMetaSchema:()=>zt,RequestSchema:()=>U,ResourceContentsSchema:()=>bn,ResourceLinkSchema:()=>sr,ResourceListChangedNotificationSchema:()=>In,ResourceRequestParamsSchema:()=>Mn,ResourceSchema:()=>En,ResourceTemplateReferenceSchema:()=>ii,ResourceTemplateSchema:()=>Dn,ResourceUpdatedNotificationParamsSchema:()=>Jn,ResourceUpdatedNotificationSchema:()=>Yn,ResultMetaObjectSchema:()=>Bt,ResultSchema:()=>K,RoleSchema:()=>wn,RootSchema:()=>li,RootsListChangedNotificationSchema:()=>fi,SamplingContentSchema:()=>Mr,SamplingMessageContentBlockSchema:()=>Nr,SamplingMessageSchema:()=>Pr,ServerCapabilitiesSchema:()=>cn,ServerNotificationSchema:()=>ji,ServerRequestSchema:()=>Ai,ServerResultSchema:()=>Mi,ServerTasksCapabilitySchema:()=>rn,SetLevelRequestParamsSchema:()=>wr,SetLevelRequestSchema:()=>Tr,SingleSelectEnumSchemaSchema:()=>Gr,StringSchemaSchema:()=>Br,SubscribeRequestParamsSchema:()=>Ln,SubscribeRequestSchema:()=>Rn,SubscriptionFilterSchema:()=>Vn,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Wn,SubscriptionsAcknowledgedNotificationSchema:()=>Gn,SubscriptionsListenRequestParamsSchema:()=>Hn,SubscriptionsListenRequestSchema:()=>Un,SubscriptionsListenResultMetaSchema:()=>Kn,SubscriptionsListenResultSchema:()=>qn,TaskAugmentedRequestParamsSchema:()=>H,TaskCreationParamsSchema:()=>pi,TaskMetadataSchema:()=>Lt,TaskSchema:()=>hi,TaskStatusNotificationParamsSchema:()=>_i,TaskStatusNotificationSchema:()=>vi,TaskStatusSchema:()=>mi,TextContentSchema:()=>nr,TextResourceContentsSchema:()=>xn,TitledMultiSelectEnumSchemaSchema:()=>qr,TitledSingleSelectEnumSchemaSchema:()=>Ur,ToolAnnotationsSchema:()=>fr,ToolChoiceSchema:()=>Ar,ToolExecutionSchema:()=>pr,ToolListChangedNotificationSchema:()=>xr,ToolResultContentSchema:()=>jr,ToolSchema:()=>mr,ToolUseContentSchema:()=>ar,UnsubscribeRequestParamsSchema:()=>zn,UnsubscribeRequestSchema:()=>Bn,UntitledMultiSelectEnumSchemaSchema:()=>Kr,UntitledSingleSelectEnumSchemaSchema:()=>Hr}),Ds=e=>Ht.safeParse(e).success,Os=e=>Ut.safeParse(e).success,ks=e=>Wt.safeParse(e).success,As=e=>Gt.safeParse(e).success,js=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`,Ms=`Mcp-Param-`,Ns=`x-mcp-header`,Ps=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Fs=new Set([`string`,`integer`,`boolean`]),Is=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Ls=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]),Rs=`=?base64?`,zs=`?=`,Z.InvalidRequest,Z.UnsupportedProtocolVersion,Z.InvalidParams,Z.MethodNotFound,Z.InvalidParams,Z.MissingRequiredClientCapability,Z.ParseError,Z.InvalidRequest,Z.MethodNotFound,Z.UnsupportedProtocolVersion,Z.MissingRequiredClientCapability,Bs=!1,Vs=`draft-2020-12`,Hs=/^#\/(\$defs|definitions)\/([^/~%]+)$/,Us=/\\\.\\d\{(\d+)\}/,Ws=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]),Gs=new Set([`$schema`,...Object.keys(Zr.shape.requestedSchema.shape)]),Ks={string:ao([Br,Hr,Ur,Wr]),number:ao([Vr]),integer:ao([Vr]),boolean:ao([zr]),array:ao([Kr,qr])},qs=new Set(Br.shape.format.unwrap().options),Object.assign(wo,{elicit(e){try{return{method:`elicitation/create`,params:Co(e)}}catch(e){throw e instanceof Q?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}}),Js=!0,Ys=10,Xs=250,Zs=`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(`.`),Qs={IdJagTokenExchangeResponseSchema:zi,OAuthClientInformationFullSchema:Wi,OAuthClientInformationSchema:Ui,OAuthClientMetadataSchema:Hi,OAuthClientRegistrationErrorSchema:Gi,OAuthErrorResponseSchema:Bi,OAuthMetadataSchema:Fi,OAuthProtectedResourceMetadataSchema:Pi,OAuthTokenRevocationRequestSchema:Ki,OAuthTokensSchema:Ri,OpenIdProviderDiscoveryMetadataSchema:Li,OpenIdProviderMetadataSchema:Ii},$s={},ec={};for(let e of Zs)jo(e,Es[e]);for(let[e,t]of Object.entries(Qs))jo(e,t);tc=Object.freeze($s),nc=Object.freeze(ec),rc=[Dt,Ot,At,Mt],ic=[`inputResponses`,`requestState`],ac=Fo(void 0),oc=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??Tt,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new X(Y.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new X(Y.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),ks(e)||As(e)?this._onresponse(e):Ds(e)?this._onrequest(e,t):Os(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new X(Y.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=No(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=Ka(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(Ja(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}=No(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=Ka(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(Z.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(qa(n.method)&&!i.hasRequestMethod(n.method)&&!(Ya(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(Z.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Z.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(Z.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:zo(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?ac:Fo(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),oo(t))return u(e,t,n);let i=Po(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(Z.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:Z.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);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),ks(e)?n(e):n(Q.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(oo(t))return Ya(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=Po(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 Ga(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=Mo(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(qa(t)&&!e.hasRequestMethod(t))throw new X(Y.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof X?e:new X(Y.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof X?e:new X(Y.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(Go(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;uo(n,o).then(e=>{e.success?d(e.data):f(new X(Y.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new X(Y.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new X(Y.NotConnected,`Not connected`);if(Ja(t.method)&&!e.hasNotificationMethod(t.method))throw new X(Y.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))})}else await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!qa(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Q(Z.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await uo(t.params,{...r.params});if(!a.success)throw new Q(Z.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!Ja(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Q(Z.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))})}else{if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await uo(t.params,{...r.params});if(!i.success)throw new Q(Z.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}}removeNotificationHandler(e){this._notificationHandlers.delete(e)}},mt((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 cc(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!cc(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!cc(e[r],t[r]))return!1;return!0}return e===t}function lc(e){return encodeURI(uc(e))}function uc(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function dc(e,t=Object.create(null),n=Cc,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:dc(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(Sc[i])continue;let a=`${r}/${lc(i)}`,o=e[i];if(Array.isArray(o)){if(bc[i]){let e=o.length;for(let r=0;r<e;r++)dc(o[r],t,n,`${a}/${r}`)}}else if(xc[i])for(let e in o)dc(o[e],t,n,`${a}/${lc(e)}`);else dc(o,t,n,a)}return t}function fc(e){return e.test.bind(e)}function pc(e){return e%4==0&&(e%100!=0||e%400==0)}function mc(e){let t=e.match(wc);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&pc(n)?29:Tc[r])}function hc(e,t){let n=t.match(Ec);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)}function gc(e){let t=e.split(Bc);return t.length==2&&mc(t[0])&&hc(!0,t[1])}function _c(e){return Vc.test(e)&&Hc.test(e)}function vc(e){if(Uc.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function yc(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function $(e,t,n=`2019-09`,r=dc(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,u;switch(l){case`boolean`:case`number`:case`string`:u=l;break;case`object`:u=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:g,required:_,not:v,anyOf:y,allOf:b,oneOf:ee,if:te,then:ne,else:re,format:ie,properties:ae,patternProperties:oe,additionalProperties:se,unevaluatedProperties:x,minProperties:ce,maxProperties:le,propertyNames:ue,dependentRequired:S,dependentSchemas:de,dependencies:fe,prefixItems:pe,items:C,additionalItems:me,unevaluatedItems:he,contains:ge,minContains:_e,maxContains:w,minItems:ve,maxItems:ye,uniqueItems:be,minimum:xe,maximum:Se,exclusiveMinimum:T,exclusiveMaximum:Ce,multipleOf:we,minLength:Te,maxLength:Ee,pattern:De,__absolute_ref__:Oe,__absolute_recursive_ref__:ke}=t,E=[];if(p===!0&&a===null&&(a=t),f===`#`){let l=a===null?r[ke]:a,u=`${s}/$recursiveRef`,d=$(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||E.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(d!==void 0){let t=r[Oe||d];if(t===void 0){let e=`Unresolved $ref "${d}".`;throw Oe&&Oe!==d&&(e+=`  Absolute URI "${Oe}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
- `)}`,Error(e)}let l=`${s}/$ref`,u=$(e,t,n,r,i,a,o,l,c);if(u.valid||E.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:E.length===0,errors:E}}if(Array.isArray(m)){let t=m.length,n=!1;for(let r=0;r<t;r++)if(u===m[r]||m[r]===`integer`&&u===`number`&&e%1==0&&e===e){n=!0;break}n||E.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join(`", "`)}".`})}else m===`integer`?(u!==`number`||e%1||e!==e)&&E.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&E.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(h!==void 0&&(u===`object`||u===`array`?cc(e,h)||E.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&E.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),g!==void 0&&(u===`object`||u===`array`?g.some(t=>cc(e,t))||E.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(t=>e===t)||E.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),v!==void 0){let t=`${s}/not`;$(e,v,n,r,i,a,o,t).valid&&E.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let Ae=[];if(y!==void 0){let t=`${s}/anyOf`,l=E.length,u=!1;for(let s=0;s<y.length;s++){let l=y[s],d=Object.create(c),f=$(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);E.push(...f.errors),u||=f.valid,f.valid&&Ae.push(d)}u?E.length=l:E.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(b!==void 0){let t=`${s}/allOf`,l=E.length,u=!0;for(let s=0;s<b.length;s++){let l=b[s],d=Object.create(c),f=$(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);E.push(...f.errors),u&&=f.valid,f.valid&&Ae.push(d)}u?E.length=l:E.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(ee!==void 0){let t=`${s}/oneOf`,l=E.length,u=ee.filter((s,l)=>{let u=Object.create(c),d=$(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return E.push(...d.errors),d.valid&&Ae.push(u),d.valid}).length;u===1?E.length=l:E.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...Ae),te!==void 0){let t=`${s}/if`;if($(e,te,n,r,i,a,o,t,c).valid){if(ne!==void 0){let l=$(e,ne,n,r,i,a,o,`${s}/then`,c);l.valid||E.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(re!==void 0){let l=$(e,re,n,r,i,a,o,`${s}/else`,c);l.valid||E.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(_!==void 0)for(let t of _)t in e||E.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(ce!==void 0&&t.length<ce&&E.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${ce} properties.`}),le!==void 0&&t.length>le&&E.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${le} properties.`}),ue!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${lc(s)}`,c=$(s,ue,n,r,i,a,e,t);c.valid||E.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(S!==void 0){let t=`${s}/dependantRequired`;for(let n in S)if(n in e){let r=S[n];for(let i of r)i in e||E.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(de!==void 0)for(let t in de){let l=`${s}/dependentSchemas`;if(t in e){let s=$(e,de[t],n,r,i,a,o,`${l}/${lc(t)}`,c);s.valid||E.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(fe!==void 0){let t=`${s}/dependencies`;for(let s in fe)if(s in e){let c=fe[s];if(Array.isArray(c))for(let n of c)n in e||E.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=$(e,c,n,r,i,a,o,`${t}/${lc(s)}`);l.valid||E.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(ae!==void 0){let t=`${s}/properties`;for(let s in ae){if(!(s in e))continue;let d=`${o}/${lc(s)}`,f=$(e[s],ae[s],n,r,i,a,d,`${t}/${lc(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,E.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&oe!==void 0){let t=`${s}/patternProperties`;for(let s in oe){let d=new RegExp(s,`u`),f=oe[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${lc(p)}`,h=$(e[p],f,n,r,i,a,m,`${t}/${lc(s)}`);h.valid?c[p]=l[p]=!0:(u=i,E.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...h.errors))}}}if(!u&&se!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${lc(s)}`,f=$(e[s],se,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,E.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&x!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${lc(s)}`,u=$(e[s],x,n,r,i,a,l,t);u.valid?c[s]=!0:E.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){ye!==void 0&&e.length>ye&&E.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${ye}).`}),ve!==void 0&&e.length<ve&&E.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${ve}).`});let t=e.length,l=0,u=!1;if(pe!==void 0){let d=`${s}/prefixItems`,f=Math.min(pe.length,t);for(;l<f;l++){let t=$(e[l],pe[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,E.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}if(C!==void 0){let d=`${s}/items`;if(Array.isArray(C)){let s=Math.min(C.length,t);for(;l<s;l++){let t=$(e[l],C[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,E.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}else for(;l<t;l++){let t=$(e[l],C,n,r,i,a,`${o}/${l}`,d);if(c[l]=!0,!t.valid&&(u=i,E.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}if(!u&&me!==void 0){let d=`${s}/additionalItems`;for(;l<t;l++){let t=$(e[l],me,n,r,i,a,`${o}/${l}`,d);c[l]=!0,t.valid||(u=i,E.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:d,error:`Items did not match additional items schema.`},...t.errors))}}}if(ge!==void 0){if(t===0&&_e===void 0)E.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(_e!==void 0&&t<_e)E.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${_e}).`});else{let l=`${s}/contains`,u=E.length,d=0;for(let s=0;s<t;s++){let t=$(e[s],ge,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):E.push(...t.errors)}d>=(_e||0)&&(E.length=u),_e===void 0&&w===void 0&&d===0?E.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):_e!==void 0&&d<_e?E.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${_e} items matching schema. Only ${d} items were found.`}):w!==void 0&&d>w&&E.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${w} items matching schema. ${d} items were found.`})}}if(!u&&he!==void 0){let u=`${s}/unevaluatedItems`;for(;l<t;l++){if(c[l])continue;let t=$(e[l],he,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||E.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:u,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(be)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&cc(r,t))&&(E.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(u===`number`){if(n===`4`?(xe!==void 0&&(T===!0&&e<=xe||e<xe)&&E.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${T?`or equal to `:``} ${xe}.`}),Se!==void 0&&(Ce===!0&&e>=Se||e>Se)&&E.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Ce?`or equal to `:``} ${Se}.`})):(xe!==void 0&&e<xe&&E.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${xe}.`}),Se!==void 0&&e>Se&&E.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Se}.`}),T!==void 0&&e<=T&&E.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${T}.`}),Ce!==void 0&&e>=Ce&&E.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Ce}.`})),we!==void 0){let t=e%we;Math.abs(0-t)>=1.1920929e-7&&Math.abs(we-t)>=1.1920929e-7&&E.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${we}.`})}}else if(u===`string`){let t=Te===void 0&&Ee===void 0?0:yc(e);Te!==void 0&&t<Te&&E.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${Te}).`}),Ee!==void 0&&t>Ee&&E.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${Ee}).`}),De!==void 0&&!new RegExp(De,`u`).test(e)&&E.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),ie!==void 0&&zc[ie]&&!zc[ie](e)&&E.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${ie}".`})}return{valid:E.length===0,errors:E}}var bc,xc,Sc,Cc,wc,Tc,Ec,Dc,Oc,kc,Ac,jc,Mc,Nc,Pc,Fc,Ic,Lc,Rc,zc,Bc,Vc,Hc,Uc,Wc,Gc;function Kc(){return(Kc=e((()=>{Ct(),bc={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},xc={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},Sc={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},Cc=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`),wc=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Tc=[0,31,28,31,30,31,30,31,31,30,31,30,31],Ec=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Dc=/^(?=.{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,Oc=/^(?:[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,kc=/^(?:(?:[^\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,Ac=/^(?:(?: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,jc=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Mc=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Nc=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Pc=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Fc=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},Ic=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Lc=/^((([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,Rc=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),zc={date:mc,time:hc.bind(void 0,!1),"date-time":gc,duration:Rc,uri:_c,"uri-reference":fc(Oc),"uri-template":fc(kc),url:fc(Ac),email:Fc,hostname:fc(Dc),ipv4:fc(Ic),ipv6:fc(Lc),regex:vc,uuid:fc(jc),"json-pointer":fc(Mc),"json-pointer-uri-fragment":fc(Nc),"relative-json-pointer":fc(Pc)},Bc=/t|\s/i,Vc=/\/|:/,Hc=/^(?:[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,Uc=/[^\\]\\Z/,Wc=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=dc(e)}validate(e){return $(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),dc(e,this.lookup)}},Gc=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=vt(e,`pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.`);return t===`draft-7`?`7`:t}getValidator(e){let t=new Wc(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let n=t.validate(e);return n.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:n.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join(`; `)}}}}})))()}function qc(){return(qc=e((()=>{Kc()})))()}function Jc(){return(Jc=e((()=>{globalThis.crypto})))()}function Yc(e){return`${e.method}\0${JSON.stringify([e.partition??``,e.params??``])}`}function Xc(e,t){return t===void 0?e:`${e}\0${t}`}function Zc(e){let t;try{t=JSON.stringify(e)}catch(e){throw TypeError(`cache value is not JSON-serializable: ${e instanceof Error?e.message:String(e)}`)}if(typeof t!=`string`)throw TypeError(`cache value is not JSON-serializable: it has no JSON representation`);return t}function Qc(e){return(typeof e==`object`&&!!e||typeof e==`function`)&&e[jl]===!0}function $c(e,t){switch(e.kind){case`result`:return el(e.result,t);case`rpc-error`:return tl(e,t);case`http-error`:return nl(e,t);case`network-error`:return rl(e.error,t);case`unusable-reply`:return{kind:`error`,error:new X(Y.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${al(e.error)})`,{cause:e.error},{cause:e.error})};case`auth-required`:return{kind:`error`,error:e.error};case`closed`:return t.transportKind===`stdio`?{kind:`legacy`}:rl(Error(`Connection closed during the version negotiation probe`),t);case`timeout`:return t.transportKind===`stdio`?{kind:`legacy`}:{kind:`error`,error:new X(Y.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function el(e,t){let n=Ga(ws).validateResult(`server/discover`,e);if(!n.ok)return{kind:`legacy`};let r=n.value.supportedVersions,i=t.clientModernVersions.find(e=>r.includes(e));return i===void 0?t.fallbackAvailable?{kind:`legacy`}:{kind:`error`,error:new ds({supported:[...r],requested:t.requestedVersion})}:{kind:`modern`,version:i,discover:n.value}}function tl(e,t){let{code:n,message:r,data:i}=e;if(n===Ml){let e=ol(i);if(e===void 0)return{kind:`legacy`};let n=new ds({supported:e,requested:sl(i)??t.requestedVersion},r),a=$i(e),o=t.clientModernVersions.find(e=>a.includes(e));return o===void 0?a.length>0?{kind:`error`,error:n}:t.fallbackAvailable?{kind:`legacy`}:{kind:`error`,error:n}:{kind:`corrective`,version:o,error:n}}return Nl.has(n),{kind:`legacy`}}function nl(e,t){if(e.status===401||e.status===403){let t=e.status===403;return{kind:`error`,error:new qo(t?Y.ClientHttpForbidden:Y.ClientHttpAuthentication,`Version negotiation failed: ${t?`the server denied access (HTTP 403)`:`the server requires authorization (HTTP 401)`}`,{status:e.status,statusText:e.statusText,text:e.body})}}if(e.status>=500)return{kind:`error`,error:new qo(Y.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let n=cl(e.body);return n===void 0?{kind:`legacy`}:tl(n,t)}function rl(e,t){return t.environment===`browser`&&il(e)?{kind:`legacy`}:{kind:`error`,error:new X(Y.EraNegotiationFailed,`Version negotiation probe failed: ${al(e)}`,{cause:e},{cause:e})}}function il(e){return e instanceof TypeError||e instanceof Error&&e.name===`TypeError`}function al(e){return e instanceof Error?e.message:String(e)}function ol(e){if(typeof e!=`object`||!e)return;let t=e.supported;if(Array.isArray(t)&&t.length!==0&&t.every(e=>typeof e==`string`))return t}function sl(e){if(typeof e!=`object`||!e)return;let t=e.requested;return typeof t==`string`?t:void 0}function cl(e){if(e===void 0||e===``)return;let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t)return;let n=t.error;if(typeof n!=`object`||!n)return;let{code:r,message:i,data:a}=n;if(typeof r==`number`)return{code:r,message:typeof i==`string`?i:``,data:a}}function ll(e,t){let n=e?.mode??Pl;if(n===`legacy`)return{kind:`legacy`};let r=e?.probe??{};if(typeof n==`object`){if(!Zi(n.pin))throw TypeError(`versionNegotiation: { pin: '${n.pin}' } is not a modern protocol revision — pinning is for 2026-07-28 and later; omit versionNegotiation (or use mode: 'legacy') for 2025-era servers.`);return{kind:`pin`,version:n.pin,probe:r}}let i=t?$i(t):[];return{kind:`auto`,modernVersions:i.length>0?i:[...Yo],fallbackAvailable:!t||Qi(t).length>0,probe:r}}function ul(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?`browser`:`node`}function dl(e){return`stderr`in e&&`pid`in e?`stdio`:`http`}function fl(e){let t=Il.get(e);Il.delete(e),t?.()}function pl(e,t,n,r){return{jsonrpc:`2.0`,id:e,method:`server/discover`,params:{_meta:Ga(t).outboundEnvelope({protocolVersion:t,clientInfo:n,clientCapabilities:r})}}}function ml(e){return e instanceof X&&e.code===Y.ClientHttpUnexpectedContent||e instanceof Error&&e.name===`SyntaxError`}function hl(e,t){switch(e.kind){case`response`:return e.error===void 0?{kind:`result`,result:e.result}:{kind:`rpc-error`,...e.error};case`send-error`:{let t=e.error;if(Qc(t)||t instanceof El||t instanceof Error&&t.name===`UnauthorizedError`)return{kind:`auth-required`,error:t};if(t instanceof qo){let e=t.data?.text;return{kind:`http-error`,status:t.data.status,body:typeof e==`string`?e:void 0,statusText:t.data.statusText}}return ml(t)?{kind:`unusable-reply`,error:t}:{kind:`network-error`,error:t}}case`closed`:return{kind:`closed`};case`timeout`:return{kind:`timeout`,timeoutMs:t}}}async function gl(e,t){let n=e.probe.timeoutMs??t.defaultTimeoutMs,r=Math.max(0,e.probe.maxRetries??0),i=e.kind===`pin`?[e.version]:e.modernVersions,a=e.kind===`auto`&&e.fallbackAvailable,o=await Fl.open(t.transport),s=async()=>{let s=i[0],c=!1,l=r;for(;;){let r=await o.exchange(e=>pl(e,s,t.clientInfo,t.capabilities),n);if(r.kind===`timeout`&&l>0){l--;continue}let u=hl(r,n),d=$c(u,{clientModernVersions:i,requestedVersion:s,fallbackAvailable:a,environment:t.environment,transportKind:t.transportKind});switch(d.kind){case`modern`:return{era:`modern`,version:d.version,discover:d.discover};case`corrective`:if(c)throw d.error;c=!0,s=d.version;continue;case`legacy`:{let n=u.kind===`closed`?`the connection closed during the server/discover probe`:void 0;if(e.kind===`pin`)throw new X(Y.EraNegotiationFailed,n===void 0?`Version negotiation failed: the server did not offer pinned protocol version ${e.version} via server/discover (no fallback in pin mode)`:`Version negotiation failed: ${n} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new X(Y.EraNegotiationFailed,n===void 0?`Version negotiation failed: the server gave no modern evidence and this client supports no pre-2026-07-28 protocol version to fall back to`:`Version negotiation failed: ${n} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(n!==void 0&&t.disposableProbe!==!0)throw new X(Y.EraNegotiationFailed,`Version negotiation failed: ${n} (this transport probed in place — the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:`legacy`}}case`error`:throw d.error}}},c;try{c=await s()}catch(e){throw o.detach(),e}return o.release(),c}function _l(e){let t=Object.getPrototypeOf(e);if(t===null||!Object.prototype.hasOwnProperty.call(t,`_dispose`))return;let n=e._serverParams;return typeof n==`object`&&n&&typeof n.command==`string`?n:void 0}async function vl(e,t,n,r){let i=t.constructor,a=new i({...n,stderr:`ignore`}),o=t.close,s=!1,c,l=new Promise((e,t)=>{c=()=>t(yl())});t.close=async function(){return s=!0,c?.(),o.call(t)};let u;try{let t=gl(e,{...r,transport:a,transportKind:`stdio`,disposableProbe:!0});t.catch(()=>{}),u=await Promise.race([t,l])}finally{await bl(a),t.close=o}if(s)throw yl();return u}function yl(){return new X(Y.EraNegotiationFailed,`Version negotiation failed: the transport was closed during the server/discover probe`)}async function bl(e){try{let t=e._dispose;await(typeof t==`function`?t.call(e):e.close())}catch{}}function xl(e){let t=e._meta?.[kt];return nc.Implementation(t)?t:void 0}function Sl(e,t){if(e&&typeof t==`object`&&t){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&Sl(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&Sl(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&Sl(n,t)}}function Cl(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}function wl(e){if(typeof e==`object`&&e&&(e.kind===`legacy`&&!(`supportedVersions`in e)&&!(`discover`in e)||e.kind===`modern`&&fn.safeParse(e.discover).success))return e;throw new X(Y.EraNegotiationFailed,`connect({ prior }): unrecognized prior — expected { kind: 'modern', discover } or { kind: 'legacy' }`)}var Tl,El,Dl,Ol,kl,Al,jl,Ml,Nl,Pl,Fl,Il,Ll,Rl,zl;function Bl(){return(Bl=e((()=>{sc(),qc(),Jc(),Tl=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthClientFlowError`})}static[Symbol.hasInstance](e){return Xi(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 Xi(this,e)}constructor(e){super(e),this.name=new.target.name,Yi(this,new.target)}},class extends Tl{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 Tl{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 Tl{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 Tl{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 Tl{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}},El=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnauthorizedError`})}static[Symbol.hasInstance](e){return Xi(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 Xi(this,e)}constructor(e){super(e??`Unauthorized`),this.name=`UnauthorizedError`,Yi(this,new.target)}},Dl=new Set([`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`server/discover`]),Ol=class{_entries=new Map;_maxEntries;_stamp=0;_cappedSize=0;constructor(e){this._maxEntries=e?.maxEntries??512}get size(){return this._entries.size}get(e){return this._entries.get(Yc(e))}set(e,t){let n=Yc(e),r=Dl.has(e.method),i=!this._entries.has(n);if(!r&&i&&this._maxEntries>0&&this._cappedSize>=this._maxEntries){for(let e of this._entries.keys())if(!Dl.has(e.slice(0,e.indexOf(`\0`)))){this._entries.delete(e),this._cappedSize--;break}}let a=++this._stamp;return this._entries.set(n,{...t,stamp:a}),i&&!r&&this._cappedSize++,a}delete(e){this._entries.delete(Yc(e))&&!Dl.has(e.method)&&this._cappedSize--}evict(e){let t=`${e}\0`,n=Dl.has(e);for(let e of this._entries.keys())e.startsWith(t)&&(this._entries.delete(e),n||this._cappedSize--)}clear(){this._entries.clear(),this._cappedSize=0}},kl=864e5,Al=class{_evictionGeneration=new Map;_toolIndex;_toolOutputValidatorIndex;_serverIdentity=``;constructor(e,t,n=()=>{},r=``,i=Date.now){this._store=e,this._isUserSupplied=t,this._reportError=n,this._cachePartition=r,this._now=i}now(){return this._now()}setServerIdentity(e){this._serverIdentity=e}_partitionFor(e){return JSON.stringify([this._serverIdentity,e===`public`?``:this._cachePartition])}async _probe(e,t){let n={method:e,params:t??``},r=this._partitionFor(`private`),i=await this._store.get({...n,partition:r});if(i!==void 0)return i;let a=this._partitionFor(`public`);if(a===r)return;let o=await this._store.get({...n,partition:a});return o?.scope===`public`?o:void 0}async evict(e){this._evictionGeneration.set(e,(this._evictionGeneration.get(e)??0)+1),await this._deleteBoth(e,``)}async _deleteBoth(e,t){let n=this._partitionFor(`private`),r=this._partitionFor(`public`);try{await this._store.delete({method:e,params:t,partition:n})}catch(e){this._reportError(e)}if(r!==n)try{await this._store.delete({method:e,params:t,partition:r})}catch(e){this._reportError(e)}}async evictKey(e,t){let n=Xc(e,t),r=this._evictionGeneration.get(n);r!==void 0&&this._evictionGeneration.set(n,r+1),await this._deleteBoth(e,t)}captureGeneration(e,t){let n=Xc(e,t),r=this._evictionGeneration.get(n)??0;return this._evictionGeneration.set(n,r),r}async write(e,t,n,r){if((this._evictionGeneration.get(Xc(e,r?.params))??0)!==n)return;let i=r?.params??``,a=this._partitionFor(`private`),o=this._partitionFor(`public`),s=(r?.scope??`private`)===`public`?o:a;try{await this._store.set({method:e,params:i,partition:s},{value:Zc(t),expiresAt:r?.expiresAt,scope:r?.scope})}catch(e){this._reportError(e)}if(o!==a)try{await this._store.delete({method:e,params:i,partition:s===a?o:a})}catch(e){this._reportError(e)}}async read(e,t){let n=await this._probe(e,t);if(n?.expiresAt!==void 0&&n.expiresAt>this.now())try{let e=JSON.parse(n.value);if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`cached document is not an object`);return{value:e}}catch(n){this._reportError(n),await this._deleteBoth(e,t??``);return}}resetForReconnect(){this._isUserSupplied||this._store.clear(),this._evictionGeneration.clear(),this._toolIndex=void 0,this._toolOutputValidatorIndex=void 0,this._serverIdentity=``}async toolDefinition(e){let t=await this._probe(`tools/list`);if(t===void 0)this._toolIndex=void 0;else{if(this._toolIndex?.stamp!==t.stamp){let e=this._decodeListTools(t),n=new Map;if(e!==void 0)for(let t of e.tools)n.set(t.name,t);this._toolIndex={stamp:t.stamp,byName:n}}return this._toolIndex.byName.get(e)}}async outputValidator(e,t){let n=await this._probe(`tools/list`);if(n===void 0)this._toolOutputValidatorIndex=void 0;else{if(this._toolOutputValidatorIndex?.stamp!==n.stamp){let e=this._decodeListTools(n)??{tools:[]},r=new Map;for(let n of e.tools){let e=t(n);e!==void 0&&r.set(n.name,e)}this._toolOutputValidatorIndex={stamp:n.stamp,byName:r}}return this._toolOutputValidatorIndex.byName.get(e)}}_decodeListTools(e){try{let t=JSON.parse(e.value);if(!Array.isArray(t?.tools)||!t.tools.every(e=>typeof e==`object`&&!!e))throw TypeError(`cached tools/list document has a malformed tools array`);return t}catch(e){this._reportError(e);return}}},jl=Symbol.for(`mcp.authSeamEscape`),Ml=-32022,Nl=new Set([-32001,-32020,-32021]),Pl=`legacy`,Fl=class e{_pending;_probeCounter=0;_savedOnMessage;_savedOnError;_savedOnClose;_closeDelivered=!1;constructor(e){this._transport=e,this._savedOnMessage=e.onmessage,this._savedOnError=e.onerror,this._savedOnClose=e.onclose}static async open(t){let n=new e(t);t.onmessage=e=>{let t=n._pending;t!==void 0&&(ks(e)||As(e))&&e.id===t.id&&(n._pending=void 0,ks(e)?t.resolve({kind:`response`,result:e.result}):t.resolve({kind:`response`,error:e.error}))},t.onerror=e=>{n._savedOnError?.(e)},t.onclose=()=>{let e=n._pending;e!==void 0&&(n._pending=void 0,e.resolve({kind:`closed`})),n._closeDelivered=!0,n._savedOnClose?.()};try{await t.start()}catch(e){throw n.detach(),e}return n}async exchange(e,t){let n=`server-discover-probe-${++this._probeCounter}`;return new Promise(r=>{let i=!1,a=e=>{i||(i=!0,clearTimeout(o),this._pending?.id===n&&(this._pending=void 0),r(e))},o=setTimeout(()=>a({kind:`timeout`}),t);this._pending={id:n,resolve:a},this._transport.send(e(n)).catch(e=>a({kind:`send-error`,error:e}))})}detach(){if(this._pending=void 0,this._transport.onmessage=this._savedOnMessage,this._transport.onerror=this._savedOnError,this._closeDelivered&&this._savedOnClose!==void 0){let e=this._savedOnClose,t=this._transport,n=!1,r=()=>{n?e():n=!0};t.onclose=r,Il.set(t,()=>{t.onclose===r&&(t.onclose=e)})}else this._transport.onclose=this._savedOnClose}release(){this.detach();let e=this._transport,t=e.start,n=!0;e.start=async function(){if(n)n=!1,e.start=t;else return t.call(e)}}},Il=new WeakMap,Ll={"notifications/tools/list_changed":[`tools/list`],"notifications/prompts/list_changed":[`prompts/list`],"notifications/resources/list_changed":[`resources/list`,`resources/templates/list`]},Rl=64,zl={},class extends oc{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;static{zl.enforceStrictCapabilities=e=>e._enforceStrictCapabilities,zl.walkPages=(e,t,n,r)=>e._walkPages(t,n,r),zl.readResource=(e,t,n)=>e._readResource(t,n)}_resetConnectionState(){if(this._negotiatedProtocolVersion=void 0,this._serverCapabilities=void 0,this._serverVersion=void 0,this._instructions=void 0,this._discoverResult=void 0,this._autoOpenedSubscription=void 0,this._listenState.size>0){let e=new X(Y.ConnectionClosed,`subscriptions/listen: client reconnected or closed; subscription state from the previous connection was reset`);for(let t of this._listenState.values())t.settle({cause:`remote`,error:e})}this._listenState.clear();for(let e of this._listChangedDebounceTimers.values())clearTimeout(e);this._listChangedDebounceTimers.clear(),this._cache.resetForReconnect()}async close(){try{await super.close()}finally{this._resetConnectionState()}}constructor(e,t){super(t),this._clientInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Gc,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=To(t?.inputRequired),this._cache=new Al(t?.responseCacheStore??new Ol,t?.responseCacheStore!==void 0,e=>this._reportStoreError(e),t?.cachePartition??``),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??Rl,t?.listChanged&&(this._listChangedConfig=t.listChanged)}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&Zi(this._negotiatedProtocolVersion)&&Ds(e))return`drop`}_outboundMetaEnvelope(){let e=this._negotiatedProtocolVersion;if(e!==void 0)return this._wireCodec().outboundEnvelope({protocolVersion:e,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(e,t){return this._inputRequiredDriverConfig.autoFulfill?Wo({getRequestHandler:e=>this._getRequestHandler(e),buildContext:e=>this.buildContext(e,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,e,t):Promise.reject(new X(Y.UnsupportedResultType,`Unsupported result type 'input_required' for ${t.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance — pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:`input_required`,method:t.request.method}))}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,`notifications/tools/list_changed`,e.tools,async()=>(await this.listTools(void 0,{cacheMode:`refresh`})).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,`notifications/prompts/list_changed`,e.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:`refresh`})).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,`notifications/resources/list_changed`,e.resources,async()=>(await this.listResources(void 0,{cacheMode:`refresh`})).resources)}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Lo(this._capabilities,e)}setVersionNegotiation(e){if(this.transport)throw Error(`Cannot configure version negotiation after connecting to transport`);this._versionNegotiation=e}_wrapHandler(e,t){return e===`elicitation/create`?async(e,n)=>{let r=Ga(this._negotiatedProtocolVersion),i=r.validateRequest(`elicitation/create`,e);if(!i.ok&&i.reason===`not-in-era`&&(i=r.validateInputRequest(`elicitation/create`,e)),!i.ok)throw new Q(i.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,i.reason===`not-in-era`?`No wire schema for elicitation/create in the resolved era`:`Invalid elicitation request: ${i.message}`);let{params:a}=i.value;a.mode=a.mode??`form`;let{supportsFormMode:o,supportsUrlMode:s}=Cl(this._capabilities.elicitation);if(a.mode===`form`&&!o)throw new Q(Z.InvalidParams,`Client does not support form-mode elicitation requests`);if(a.mode===`url`&&!s)throw new Q(Z.InvalidParams,`Client does not support URL-mode elicitation requests`);let c=await t(e,n),l=r.validateResult(`elicitation/create`,c);if(!l.ok&&l.reason===`not-in-era`&&(l=r.validateInputResponse(`elicitation/create`,c)),!l.ok)throw new Q(l.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,l.reason===`not-in-era`?`No wire schema for elicitation/create in the resolved era`:`Invalid elicitation result: ${l.message}`);let u=l.value,d=a.mode===`form`?a.requestedSchema:void 0;if(a.mode===`form`&&u.action===`accept`&&u.content&&d&&this._capabilities.elicitation?.form?.applyDefaults)try{Sl(d,u.content)}catch{}return u}:e===`sampling/createMessage`?async(e,n)=>{let r=Ga(this._negotiatedProtocolVersion),i=r.validateRequest(`sampling/createMessage`,e);if(!i.ok&&i.reason===`not-in-era`&&(i=r.validateInputRequest(`sampling/createMessage`,e)),!i.ok)throw new Q(i.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,i.reason===`not-in-era`?`No wire schema for sampling/createMessage in the resolved era`:`Invalid sampling request: ${i.message}`);let{params:a}=i.value,o=await t(e,n),s=!!(a.tools||a.toolChoice),c=r.samplingResultVariant(s,o);if(!c.ok&&c.reason===`not-in-era`&&(c=r.validateInputResponse(`sampling/createMessage`,o)),!c.ok)throw new Q(c.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,c.reason===`not-in-era`?`No result schema for sampling/createMessage in the resolved era`:`Invalid sampling result: ${c.message}`);return c.value}:t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new X(Y.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,wl(t.prior),t);let n=ll(this._versionNegotiation,this._supportedProtocolVersionsOption);return n.kind===`legacy`?this._connectPlainLegacy(e,t):this._connectNegotiated(e,n,t)}async _connectPlainLegacy(e,t){if(await super.connect(e),e.sessionId!==void 0){let t=this._negotiatedProtocolVersion;t!==void 0&&e.setProtocolVersion?.(t)}else this._resetConnectionState(),await this._legacyHandshake(e,t)}async _legacyHandshake(e,t){let n=Qi(this._supportedProtocolVersions);try{let r=n[0];if(r===void 0)throw new X(Y.EraNegotiationFailed,`Cannot run the initialize handshake: supportedProtocolVersions contains no pre-2026-07-28 protocol version`);let i=await this.request({method:`initialize`,params:{protocolVersion:r,capabilities:this._capabilities,clientInfo:this._clientInfo}},t);if(i===void 0)throw Error(`Server sent invalid initialize result: ${i}`);if(!n.includes(i.protocolVersion))throw Error(`Server's protocol version is not supported: ${i.protocolVersion}`);this._serverCapabilities=i.capabilities,this._serverVersion=i.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(e)),e.setProtocolVersion&&e.setProtocolVersion(i.protocolVersion),this._instructions=i.instructions,await this.notification({method:`notifications/initialized`}),this._negotiatedProtocolVersion=i.protocolVersion,this._listChangedConfig&&this._setupListChangedHandlers(this._listChangedConfig)}catch(e){throw this.close(),e}}async _connectNegotiated(e,t,n){if(e.sessionId!==void 0){await super.connect(e);let t=this._negotiatedProtocolVersion;t!==void 0&&e.setProtocolVersion&&e.setProtocolVersion(t);return}this._resetConnectionState();let r;try{let i=dl(e),a={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:ul(),defaultTimeoutMs:n?.timeout??6e4},o=i===`stdio`?_l(e):void 0;r=o===void 0?await gl(t,{...a,transport:e,transportKind:i}):await vl(t,e,o,a)}catch(t){throw await e.close().catch(()=>{}),fl(e),t}if(fl(e),await super.connect(e),r.era===`legacy`)await this._legacyHandshake(e,n);else if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=xl(r.discover),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.discover.instructions,this._discoverResult=r.discover,this._negotiatedProtocolVersion=r.version,e.setProtocolVersion&&e.setProtocolVersion(r.version),this._listChangedConfig){let e=this._listChangedConfig,t=this._serverCapabilities,r={...e.tools&&t?.tools?.listChanged&&{tools:e.tools},...e.prompts&&t?.prompts?.listChanged&&{prompts:e.prompts},...e.resources&&t?.resources?.listChanged&&{resources:e.resources}},i=!0;try{this._setupListChangedHandlers(r)}catch(e){i=!1,this.onerror?.(e instanceof Error?e:Error(String(e)))}let a=i?{...r.tools&&{toolsListChanged:!0},...r.prompts&&{promptsListChanged:!0},...r.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(a).length>0){let e=new AbortController,t=()=>e.abort(n?.signal?.reason);n?.signal?.aborted&&t(),n?.signal?.addEventListener(`abort`,t);try{this._autoOpenedSubscription=await this.listen(a,{timeout:n?.timeout,signal:e.signal})}catch(e){if(n?.signal?.aborted)throw await this.close().catch(()=>{}),e;this.onerror?.(e instanceof Error?e:Error(String(e)))}finally{n?.signal?.removeEventListener(`abort`,t)}}}}async _connectFromPrior(e,t,n){if(t.kind===`legacy`)return this._connectPlainLegacy(e,n);let r=t.discover;this._resetConnectionState();let i=this._supportedProtocolVersionsOption,a=(i&&$i(i).length>0?$i(i):Yo).find(e=>r.supportedVersions.includes(e));if(a===void 0)throw new X(Y.EraNegotiationFailed,`connect({ prior }) with a modern verdict requires a 2026-07-28+ mutual protocol version; the supplied DiscoverResult and this client's supportedProtocolVersions have no modern overlap. For a server known to be legacy, pass prior: { kind: 'legacy' } to skip the probe and initialize directly, or use versionNegotiation: { mode: 'auto' } to re-probe with legacy fallback.`);if(await super.connect(e),this._discoverResult=r,this._serverCapabilities=r.capabilities,this._serverVersion=xl(r),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.instructions,this._negotiatedProtocolVersion=a,e.setProtocolVersion?.(a),this._listChangedConfig)try{this._setupListChangedHandlers(this._listChangedConfig)}catch(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(e){let t=this._serverVersion;return t===void 0?e.sessionId??`anonymous:${Date.now()}-${Math.random().toString(36).slice(2)}`:`${t.name}@${t.version}`}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}getProtocolEra(){let e=this._negotiatedProtocolVersion;if(e!==void 0)return Zi(e)?`modern`:`legacy`}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw new X(Y.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw new X(Y.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw new X(Y.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw new X(Y.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw new X(Y.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw new X(Y.CapabilityNotSupported,`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if(e===`notifications/roots/list_changed`&&!this._capabilities.roots?.listChanged)throw new X(Y.CapabilityNotSupported,`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw new X(Y.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw new X(Y.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw new X(Y.CapabilityNotSupported,`Client does not support roots capability (required for ${e})`)}}async ping(e){return this.request({method:`ping`},e)}async discover(e){let t=await this._requestWithSchema({method:`server/discover`},fn,e);return this._discoverResult=t,t}async complete(e,t){return this.request({method:`completion/complete`,params:e},t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},t)}async listPrompts(e,t){if(!this._serverCapabilities?.prompts&&!this._enforceStrictCapabilities)return console.debug(`Client.listPrompts() called but server does not advertise prompts capability - returning empty list`),{prompts:[]};if(e?.cursor!==void 0)return this.request({method:`prompts/list`,params:e},t);let n=await this._serveFromCache(`prompts/list`,void 0,t);return n===void 0?this._listAllPages(`prompts/list`,e,t,e=>e.prompts):n}async listResources(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug(`Client.listResources() called but server does not advertise resources capability - returning empty list`),{resources:[]};if(e?.cursor!==void 0)return this.request({method:`resources/list`,params:e},t);let n=await this._serveFromCache(`resources/list`,void 0,t);return n===void 0?this._listAllPages(`resources/list`,e,t,e=>e.resources):n}async listResourceTemplates(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug(`Client.listResourceTemplates() called but server does not advertise resources capability - returning empty list`),{resourceTemplates:[]};if(e?.cursor!==void 0)return this.request({method:`resources/templates/list`,params:e},t);let n=await this._serveFromCache(`resources/templates/list`,void 0,t);return n===void 0?this._listAllPages(`resources/templates/list`,e,t,e=>e.resourceTemplates):n}async _listAllPages(e,t,n,r,i){let a=n?.cacheMode===`bypass`,o=this._cache.captureGeneration(e),s=await this._walkPages(e,r=>{let i=r===void 0?t&&{...t}:{...t,cursor:r};return this.request({method:e,...i&&{params:i}},n)},r);return delete s.nextCursor,i?.(s),a||await this._cache.write(e,s,o,this._freshness(s)),s}async _walkPages(e,t,n){let r=await t(void 0),i=r.nextCursor,a=r,o=1;for(;i!==void 0;){if(this._listMaxPages!==0&&o>=this._listMaxPages)throw new X(Y.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let s=await t(i);if(s.nextCursor===i&&JSON.stringify(n(s))===JSON.stringify(n(a)))break;n(r).push(...n(s)),a=s,i=s.nextCursor,o++}return r}_freshness(e,t){let n=e,r=typeof n.ttlMs==`number`?n.ttlMs:this._defaultCacheTtlMs,i=n.cacheScope===`public`?`public`:`private`;return{expiresAt:this._cache.now()+Math.min(Math.max(0,r),kl),scope:i,params:t}}async _serveFromCache(e,t,n){if(n?.cacheMode===`bypass`||n?.cacheMode===`refresh`)return;let r=await this._cache.read(e,t).catch(e=>void this._reportStoreError(e));if(r!==void 0){if(n?.signal?.aborted){let e=n.signal.reason;throw e instanceof X?e:new X(Y.RequestTimeout,String(e))}return r.value}}_reportStoreError(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}_compileOutputValidator(e){if(e.outputSchema)try{return{ok:!0,validator:this._jsonSchemaValidator.getValidator(e.outputSchema)}}catch(e){return{ok:!1,compileError:e}}}async _resolveXMcpHeaderScan(e,t){let n=t??await this._cache.toolDefinition(e);return n===void 0?void 0:Xa(n.inputSchema)}async readResource(e,t){let{result:n}=await this._readResource(e,t);return n}async _readResource(e,t){let n=await this._serveFromCache(`resources/read`,e.uri,t);if(n!==void 0)return{result:n,cached:!0};let r=this._cache.captureGeneration(`resources/read`,e.uri),i=await this.request({method:`resources/read`,params:e},t);if(t?.cacheMode!==`bypass`){let n=this._freshness(i,e.uri);n.expiresAt>this._cache.now()?await this._cache.write(`resources/read`,i,r,n):t?.cacheMode===`refresh`&&await this._cache.evictKey(`resources/read`,e.uri)}return{result:i,cached:!1}}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},t)}async listen(e,t){if(this.transport===void 0)throw new X(Y.NotConnected,`Not connected`);let n=this._negotiatedProtocolVersion;if(n===void 0||!Zi(n))throw new X(Y.MethodNotSupportedByProtocolVersion,`subscriptions/listen requires a 2026-07-28-era connection (negotiated: ${n??`none`}). On a 2025-era connection, change notifications are delivered unsolicited: use ClientOptions.listChanged and resources/subscribe instead.`,{method:`subscriptions/listen`,protocolVersion:n});if(t?.signal?.aborted){let e=t.signal.reason;throw e instanceof X?e:new X(Y.RequestTimeout,String(e))}let r=new AbortController,i=`listen:${this._nextListenId++}`,a=`opening`,o,s,c,l,u=new Promise((e,t)=>{c=e,l=t}),d,f=new Promise(e=>{d=e}),p=e=>{if(a===`closed`)return;let n=a===`opening`;o!==void 0&&(clearTimeout(o),o=void 0),`ack`in e?(a=`open`,c(e.ack)):(a=`closed`,s!==void 0&&t?.signal?.removeEventListener(`abort`,s),this._listenState.delete(i),r.abort(),d(e.cause),n&&l(e.error??new X(Y.ConnectionClosed,`subscriptions/listen closed before the server acknowledged`)))},m=async()=>{r.abort(),await this.notification({method:`notifications/cancelled`,params:{requestId:i}}).catch(()=>{})},h=async()=>{a!==`closed`&&(p({cause:`local`}),await m())};this._listenState.set(i,{settle:p});let g=t?.timeout??6e4;if(o=setTimeout(()=>{p({cause:`remote`,error:new X(Y.RequestTimeout,`subscriptions/listen ack timed out`,{timeout:g})}),m().catch(()=>{})},g),t?.signal){let e=t.signal;s=()=>{if(a===`closed`)return;let t=e.reason;p({cause:`local`,error:t instanceof Error?t:Error(String(t??`Aborted`))}),m().catch(()=>{})},e.addEventListener(`abort`,s,{once:!0})}let _={jsonrpc:`2.0`,id:i,method:`subscriptions/listen`,params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},v=e=>{p({cause:`remote`,error:e instanceof Error?e:Error(String(e))})};try{this.transport.send(_,{requestSignal:r.signal,onRequestStreamEnd:()=>p({cause:`remote`,error:Error(`subscriptions/listen: stream ended`)})}).catch(v)}catch(e){v(e)}return{honoredFilter:await u,close:h,closed:f}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let n=Object.hasOwn(Ll,e.method)?Ll[e.method]:void 0;if(e.method===`notifications/resources/updated`){let t=e.params?.uri;typeof t==`string`&&this._cache.evictKey(`resources/read`,t)}else if(n!==void 0)for(let e of n)this._cache.evict(e);if(e.method===`notifications/subscriptions/acknowledged`){let t=e.params?._meta?.[jt],n=typeof t==`string`?this._listenState.get(t):void 0;if(n!==void 0){let t=this._wireCodec().validateNotification(`notifications/subscriptions/acknowledged`,e);n.settle({ack:t.ok?t.value.params.notifications:{}});return}}if(e.method===`notifications/cancelled`){let t=e.params?.requestId,n=typeof t==`string`?this._listenState.get(t):void 0;if(n!==void 0){n.settle({cause:`remote`,error:Error(`subscriptions/listen: server cancelled the subscription`)});return}}super._onnotification(e,t)}_onresponse(e){let t=e.id,n=typeof t==`string`?this._listenState.get(t):void 0;n===void 0?super._onresponse(e):As(e)?n.settle({cause:`remote`,error:Q.fromError(e.error.code,e.error.message,e.error.data)}):n.settle({cause:`graceful`,error:new X(Y.ConnectionClosed,`subscriptions/listen: server closed the subscription gracefully before acknowledging`)})}_onclose(){if(this._listenState.size>0){let e=new X(Y.ConnectionClosed,`Connection closed`);for(let t of this._listenState.values())t.settle({cause:`remote`,error:e});this._listenState.clear()}super._onclose()}async callTool(e,t){let n=this.getProtocolEra()===`modern`&&ul()!==`browser`,r=async()=>{if(!n)return t;let r;try{r=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(e){this._reportStoreError(e)}if(!r?.valid||r.declarations.length===0)return t;let i=ro(r.declarations,e.arguments);return Object.keys(i).length===0?t:{...t,headers:{...t?.headers,...i}}},i=t?.toolDefinition===void 0?await this._cache.outputValidator(e.name,e=>this._compileOutputValidator(e)).catch(e=>void this._reportStoreError(e)):this._compileOutputValidator(t.toolDefinition),a=()=>{if(i===void 0||i.ok)return;let t=i.compileError,n=(t instanceof Error?t.message:String(t)).slice(0,200);throw new Q(Z.InvalidParams,`Tool '${e.name}' has an invalid outputSchema: ${n}`)};a();let o;try{o=await this.request({method:`tools/call`,params:e},await r())}catch(s){let c=s instanceof Q&&s.code===-32020;if(!n||!c||t?.toolDefinition!==void 0)throw s;let l={signal:t?.signal,timeout:t?.timeout,cacheMode:`refresh`};await this._cache.evict(`tools/list`),await this.listTools(void 0,l).catch(e=>this._reportStoreError(e)),i=await this._cache.outputValidator(e.name,e=>this._compileOutputValidator(e)).catch(e=>void this._reportStoreError(e)),a(),o=await this.request({method:`tools/call`,params:e},await r())}let s=i!==void 0&&i.ok?i.validator:void 0;if(s){if(o.structuredContent===void 0&&!o.isError)throw new Q(Z.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent!==void 0&&!o.isError)try{let e=s(o.structuredContent);if(!e.valid)throw new Q(Z.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof Q?e:new Q(Z.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return o}async listTools(e,t){if(!this._serverCapabilities?.tools&&!this._enforceStrictCapabilities)return console.debug(`Client.listTools() called but server does not advertise tools capability - returning empty list`),{tools:[]};if(e?.cursor!==void 0){let n=await this.request({method:`tools/list`,params:e},t);return this._excludeInvalidXMcpHeaderTools(n),n}let n=await this._serveFromCache(`tools/list`,void 0,t);return n===void 0?this._listAllPages(`tools/list`,e,t,e=>e.tools,e=>this._excludeInvalidXMcpHeaderTools(e)):n}_excludeInvalidXMcpHeaderTools(e){if(this.getProtocolEra()!==`modern`||!this.transport||dl(this.transport)===`stdio`)return;let t=e.tools.filter(e=>{let t=Xa(e.inputSchema);return t.valid?!0:(console.warn(`[mcp-sdk] excluding tool '${e.name}' from tools/list: invalid x-mcp-header declaration — ${t.reason}`),!1)});t.length!==e.tools.length&&(e.tools=t)}_setupListChangedHandler(e,t,n,r){let i=io(Sr,n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw TypeError(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a)s(null,null);else try{s(null,await r())}catch(e){s(e instanceof Error?e:Error(String(e)),null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}}})))()}function Vl(){return(Vl=e((()=>{sc(),Bl(),qc(),class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SseError`})}static[Symbol.hasInstance](e){return Xi(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 Xi(this,e)}constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n,Yi(this,new.target)}}})))()}function Hl(){return(Hl=e((()=>{Ni(),qi()})))()}function Ul(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`;Jl.has(o)||(Jl.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},Wl(t)):e=>s({method:a,params:e})]}function Wl(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 Gl(e,t){return JSON.stringify(e)===JSON.stringify(t)}var Kl,ql,Jl,Yl,Xl,Zl,Ql,$l,eu,tu,nu,ru,iu,au,ou,su,cu,lu,uu,du,fu,pu,mu,hu,gu,_u,vu,yu,bu,xu,Su,Cu,wu,Tu,Eu,Du;function Ou(){return(Ou=e((()=>{Vl(),Hl(),Ke(),Kl=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}},ql=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)}},Jl=new Set,Yl=`2026-01-26`,Xl=F([R(`light`),R(`dark`)]).describe(`Color theme preference for the host environment.`),Zl=F([R(`inline`),R(`fullscreen`),R(`pip`)]).describe(`Display mode for UI presentation.`),Ql=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.`),$l=k(Ql.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(),rt()]).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.`),eu=O({method:R(`ui/open-link`),params:O({url:A().describe(`URL to open in the host's browser`)})}),tu=O({isError:I().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),nu=O({isError:I().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),ru=O({isError:I().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough(),iu=O({method:R(`ui/notifications/sandbox-proxy-ready`),params:O({})}),au=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'`)")}),ou=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.`)}),su=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").`)})}),cu=O({fonts:A().optional()}),lu=O({variables:$l.optional().describe(`CSS variables for theming the app.`),css:cu.optional().describe(`CSS blocks that apps can inject.`)}),O({method:R(`ui/resource-teardown`),params:O({})}),uu=k(A(),D()),du=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.`)}),fu=O({method:R(`ui/notifications/request-teardown`),params:O({}).optional()}),pu=O({experimental:k(A(),k(A(),Ge()).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:ou.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:au.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:du.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:du.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.")}),mu=O({experimental:k(A(),k(A(),Ge()).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(Zl).optional().describe(`Display modes the app supports.`)}),hu=O({method:R(`ui/notifications/initialized`),params:O({}).optional()}),O({csp:au.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:ou.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`)}),gu=O({method:R(`ui/request-display-mode`),params:O({mode:Zl.describe(`The display mode being requested.`)})}),_u=O({mode:Zl.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),vu=F([R(`model`),R(`app`)]).describe(`Tool visibility scope - who can access the tool.`),O({resourceUri:A().optional(),visibility:P(vu).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:at().optional(),permissions:at().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.')}),yu=O({method:R(`ui/download-file`),params:O({contents:P(F([or,sr])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),bu=O({method:R(`ui/message`),params:O({role:R(`user`).describe(`Message role, currently only "user" is supported.`),content:P(cr).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:au.optional().describe(`CSP configuration from resource metadata.`),permissions:ou.optional().describe(`Sandbox permissions from resource metadata.`)})}),O({method:R(`ui/notifications/tool-result`),params:_r.describe(`Standard MCP tool execution result.`)}),xu=O({toolInfo:O({id:Vt.optional().describe(`JSON-RPC id of the tools/call request.`),tool:mr.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Xl.optional().describe(`Current color theme preference.`),styles:lu.optional().describe(`Style configuration for theming the app.`),displayMode:Zl.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:P(Zl).optional().describe(`Display modes the host supports.`),containerDimensions:F([O({height:j().describe(`Fixed container height in pixels.`)}),O({maxHeight:F([j(),rt()]).optional().describe(`Maximum container height in pixels.`)})]).and(F([O({width:j().describe(`Fixed container width in pixels.`)}),O({maxWidth:F([j(),rt()]).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:xu.describe(`Partial context update containing only changed fields.`)}),Su=O({method:R(`ui/update-model-context`),params:O({content:P(cr).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.`)})}),Cu=O({method:R(`ui/initialize`),params:O({appInfo:q.describe(`App identification (name and version).`),appCapabilities:mu.describe(`Features and capabilities this app provides.`),protocolVersion:A().describe(`Protocol version this app supports.`)})}),wu=O({protocolVersion:A().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:q.describe(`Host application identification and version.`),hostCapabilities:pu.describe(`Features and capabilities provided by the host.`),hostContext:xu.describe(`Rich context about the host environment.`)}).passthrough(),Tu=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=Kt.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},Eu=[Yl],Du=class extends oc{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new Kl;_methods=new ql;setRequestHandler=(...e)=>{let[t,...n]=Ul(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=Ul(`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:su,sandboxready:iu,initialized:hu,requestteardown:fu,loggingmessage:Dr};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:Cu.shape.params,result:wu},e=>this._onAppsInitialize(e)),this.replaceRequestHandler(`ping`,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(`ui/request-display-mode`,{params:gu.shape.params,result:_u},()=>({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:bu.shape.params,result:ru},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:eu.shape.params,result:tu},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:yu.shape.params,result:nu},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:gu.shape.params,result:_u},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:Su.shape.params,result:Jt},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:Eu.includes(t)?t:Yl,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];Gl(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},uu,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 ku(e,t){let n=e[`~standard`].validate(t);if(n.issues)throw Error(`Invalid Gateway MCP result`);return n.value}function Au(e){let{bridge:t,request:r,sessionKey:i,viewId:a,iframe:o}=e;t.oncalltool=async e=>ku(tc.CallToolResult,await r(`mcp.app.callTool`,{toolName:e.name,arguments:e.arguments}));let s=(e,t)=>async n=>ku(t,await r(e,n?.cursor===void 0?{}:{cursor:n.cursor}));t.setListToolsHandler(s(`mcp.app.listTools`,tc.ListToolsResult)),t.onlistresources=s(`mcp.app.listResources`,tc.ListResourcesResult),t.onlistresourcetemplates=s(`mcp.app.listResourceTemplates`,tc.ListResourceTemplatesResult),t.onreadresource=async(e,t)=>ku(tc.ReadResourceResult,await r(`mcp.app.readResource`,{uri:e.uri,_meta:t.mcpReq._meta??e._meta}));let c=new Set;return e.fileResourcesSupported&&(t.setHostRequestHandler(`openai/resources/write`,async e=>ju.parse(await r(`mcp.app.writeResource`,e))),t.setHostRequestHandler(`resources/subscribe`,async t=>{let n=ju.parse(await r(`mcp.app.subscribeResource`,t));return typeof t.uri==`string`&&(e.isDisposed()?await e.releaseResourceSubscription(t.uri):c.add(t.uri)),n}),t.setHostRequestHandler(`resources/unsubscribe`,async e=>{let t=ju.parse(await r(`mcp.app.unsubscribeResource`,e));return typeof e.uri==`string`&&c.delete(e.uri),t}),e.addCleanup(()=>{for(let t of c)e.releaseResourceSubscription(t).catch(()=>void 0);c.clear()})),e.openFilesSupported&&t.setHostRequestHandler(`openai/files/open`,async t=>{if(e.isDisposed()||!pe(o)||typeof t.path!=`string`||!await e.confirmOpenFile(t.path)||e.isDisposed()||!pe(o))return{isError:!0};let n=Mu.parse(await r(`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:i,viewId:a,...n,respond:e=>t(e?{}:{isError:!0})}}))&&t({isError:!0})})}),{async reconnect(){for(let e of c)await r(`mcp.app.subscribeResource`,{uri:e})},start(){let r=e.subscribeEvents(r=>{if(e.isDisposed())return;let o=n(r.payload),s=r.event===`question.requested`&&o?.status===`pending`?o:r.event===`plugin.approval.requested`?n(o?.request):void 0;s?.sessionKey===i&&(!e.agentId||!s.agentId||s.agentId===e.agentId)&&e.onConversationInputRequested(),o?.viewId===a&&(r.event===`mcp.app.hostContextChanged`&&e.onModelContextChanged(o.modelContext===null&&typeof o.updateId==`string`?o.updateId:void 0),r.event===`mcp.app.resourceUpdated`&&typeof o.uri==`string`&&c.has(o.uri)&&t.notification({method:`notifications/resources/updated`,params:{uri:o.uri}}))});r&&e.addCleanup(r)}}}var ju,Mu,Nu;function Pu(){return(Pu=e((()=>{Vl(),Ou(),Ke(),fe(),ju=k(A(),D()),Mu=O({path:A(),name:A()}),Nu=class extends Du{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:ju,result:ju},t)}setListToolsHandler(e){this.replaceRequestHandler(`tools/list`,t=>e(t.params))}}})))()}function Fu(){let e=getComputedStyle(document.documentElement),t={...Lu};for(let[n,r]of Object.entries(Iu)){let i=e.getPropertyValue(r).trim();i&&(t[n]=i)}return t}var Iu,Lu;function Ru(){return(Ru=e((()=>{Iu={"--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`},Lu={"--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 zu(e,t,n,r,i){let a=e?.getBoundingClientRect(),o=navigator.maxTouchPoints>0||window.matchMedia?.(`(pointer: coarse)`).matches,s=document.documentElement.dataset.themeMode;return xu.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:Fu()}})}function Bu(e,t,n,r){let i=new URL(t).origin,a=new Promise((t,a)=>{let s=window.setTimeout(()=>{u(),a(Error(c(`mcpApp.errors.sandboxTimedOut`)))},15e3),l=o(window,`message`,n=>{n.source===e.contentWindow&&n.origin===i&&(n.data?.method===`ui/notifications/sandbox-bootstrap-ready`&&n.data?.params?.version===1&&r!==void 0?e.contentWindow?.postMessage({jsonrpc:`2.0`,method:`ui/notifications/sandbox-bootstrap-shell`,params:{html:r}},i):n.data?.method===`ui/notifications/sandbox-proxy-ready`&&(u(),t()))}),u=n(()=>{window.clearTimeout(s),l()})});return e.src=t,a}async function Vu(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(c(`mcpApp.errors.initializationTimedOut`))),15e3)})])}finally{r()}}async function Hu(){await Promise.race([new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})}),new Promise(e=>{window.setTimeout(e,1e3)})])}function Uu(){return(Uu=e((()=>{Ou(),l(),C(),Ru(),w()})))()}function Wu(e,r,i,s){let l=null,u=null,f,p=null,m=null,h,g=new AbortController,_=lt(),v=!1,y=!1,b=!1,ee=!1,ie=!1,ae,oe,x,ce,le,ue,S,fe;function C(){!v||y||ee||(ee=!0,i(ve))}function w(){let t=r.gateway;return[t.snapshot.client,e.sessionKey,e.viewId,e.agentId,t.connectionRevision,te(t).key,t.snapshot.phase===`connected`&&t.snapshot.hello!==null&&!a(t.snapshot.hello.auth??null)]}function ve(){if(ee=!1,y)return;let t=w(),n=!x?.every((e,n)=>e===t[n]);x=t;let r=ie&&!b;ie=!1,(n||r)&&Ce(je(t)),le!==e.title&&(le=e.title,we());let i=[e.height,e.fillContainer,e.displayMode,e.deepLink],a=!ce?.every((e,t)=>e===i[t]);ce=i,a&&Ee(),ue!==e.surface&&!a&&Te(),ue=e.surface}function ye(){v=!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)&&T(),{client:e,phase:t,hello:n}=r,C()}),oe=d.subscribe(we),C()}function xe(){y=!0,ae?.(),oe?.(),E()}function Se(e){l=e,s()}function T(){if(g.abort(),g=new AbortController,_.cancel(),r.gateway.snapshot.phase===`connected`){let e=p;if(!e&&!b)h?.abort(),ie=!0,C();else if(e?.reconnect){let t=g.signal;e.reconnect().then(()=>{!t.aborted&&p===e&&u&&(u=null,s())},n=>{!t.aborted&&p===e&&(u=n,s())})}}}async function Ce(t){if(y)return;b=!1,h?.abort();let n=new AbortController;h=n,u=null,s();try{if(await ke(p),n.signal.throwIfAborted(),Se(null),!e.sessionKey||!e.viewId)return;if(!t)throw Error(c(`mcpApp.errors.gatewayUnavailable`));await Fe(t,n.signal)}catch(t){n.signal.aborted||(u=t,e.onHeightChange?.(null,!0),Te(),s())}}function we(){p&&(p.iframe.title=e.title||c(`mcpApp.title`))}function Te(){f&&(f.style.minHeight=!u&&l!==`ended`&&e.surface===`conversation`&&!e.fillContainer&&e.displayMode===`inline`?`${p?.frameHeight??e.height}px`:``,e.onHeightChange&&(e.style.minHeight=``))}function Ee(){_.update(),S!==e.displayMode&&(S=e.displayMode,dt(e,fe)),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?.()),Te()}async function De(t,n,i,o){let s=o?AbortSignal.any([o,g.signal]):g.signal;try{s.throwIfAborted();let e=r.gateway;if(e.snapshot.phase!==`connected`||e.snapshot.client!==t.client||!a(e.snapshot.hello?.auth??null)||te(e).key!==t.scope)throw Error(c(`mcpApp.errors.gatewayUnavailable`));let{agentId:o,...l}=i,u={...l,sessionKey:t.sessionKey,viewId:t.viewId,...t.agentId?{agentId:t.agentId}:{}},d=await t.client.request(n,u,{signal:s});return s.throwIfAborted(),d}catch(n){throw re(n)&&!s.aborted&&e.viewId===t.viewId&&e.sessionKey===t.sessionKey&&r.gateway.snapshot.client===t.client&&(e.onHeightChange?.(null,!0),Se(`ended`),Te(),_.cancel(),e.dispatchEvent(new CustomEvent(be,{bubbles:!0,composed:!0}))),n}}function Oe(e,t){return e.cleanups.add(t),()=>{e.cleanups.delete(t)&&t()}}async function ke(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),Gu,()=>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 E(){b=!0,x=w(),ie=!1,h?.abort(),await ke(p)}function Ae(){b&&e.isConnected&&!p&&!m&&(g=new AbortController,Ce(je()))}function je(e=w()){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 Ne(t,n,i){let o=r.gateway;return!i.aborted&&!n.disposed&&p===n&&e.isConnected&&l!==`ended`&&e.sessionKey===t.sessionKey&&e.viewId===t.viewId&&(e.agentId||void 0)===t.agentId&&o.snapshot.phase===`connected`&&o.snapshot.client===t.client&&a(o.snapshot.hello?.auth??null)&&o.connectionRevision===t.connectionRevision&&te(o).key===t.scope}async function Fe(t,i){let{sessionKey:a,viewId:s,agentId:l}=t,u=null;try{let d=await De(t,`mcp.app.view`,{},i);fe=d.appIdentity;let m=f;if(i.throwIfAborted(),Se(d.messageSupported===!1?`reconstructed`:null),!m)throw Error(c(`mcpApp.errors.mountUnavailable`));let h=document.createElement(`iframe`);h.title=e.title||c(`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 v={bridge:null,requestAbort:new AbortController,cleanups:new Set,frameHeight:e.height,iframe:h,transport:null,disposed:!1};u=v,p=v,Oe(v,()=>_.cancel()),Oe(v,o(i,`abort`,()=>void ke(v),{once:!0}));let y=e=>Oe(v,e);if(await Bu(h,ot(d.sandboxUrl,d.sandboxPort,d.sandboxOrigin,r.gateway.connection.gatewayUrl,window.location.origin,c(`mcpApp.errors.invalidSandboxUrl`)),y,d.sandboxShellHtml),i.throwIfAborted(),!h.contentWindow)throw Error(c(`mcpApp.errors.sandboxUnavailable`));let b=!1,ee=me(d.displayModes),te=()=>d.displayMode&&ee.available.includes(d.displayMode)?d.displayMode:ee.initial;e.displayMode=te();let re=d.hostContext?.[`openai/modelContext`]??null,ie=0,ae=()=>{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{...zu(m,v.frameHeight,e.fillContainer||e.displayMode===`fullscreen`,e.displayMode,ee.available),"openai/modelContext":re,...t?{"openai/deepLink":t}:{}}},oe=()=>e.dispatchEvent(new CustomEvent(de,{bubbles:!0,composed:!0,detail:{sessionKey:a,viewId:s,state:re}})),x=new Nu(null,{name:`OpenClaw`,version:`1.0.0`},he(d.csp,d.messageSupported===!0,d.updateModelContextSupported===!0,{richModelContext:d.richModelContextSupported===!0,fileResources:d.fileResourcesSupported===!0,openFiles:d.openFilesSupported===!0}),{hostContext:ae()});v.bridge=x;let ce=(e,n)=>De(t,e,n,v.requestAbort.signal),le=()=>Ne(t,v,i),ue=(t,n)=>_.request({frame:h,title:e.title||c(`mcpApp.title`),text:t,kind:n,isCurrent:le}),S=e=>{if(e&&re&&re.updateId!==e)return;let t=++ie,n=g.signal,r=e=>{v.disposed||n.aborted||t!==ie||(re=e,x.setHostContext(ae()),oe())};if(e)r(null);else return ce(`mcp.app.modelContext`,{}).then(e=>r(e.state),()=>void 0)},C=()=>{E()};x.onrequestteardown=C,Oe(v,()=>{x.onrequestteardown===C&&(x.onrequestteardown=void 0)}),d.messageSupported===!0&&x.setMessageHandler(async e=>await ge(h,{sessionKey:a,viewId:s},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 _e=Au({bridge:x,request:ce,releaseResourceSubscription:e=>De(t,`mcp.app.unsubscribeResource`,{uri:e}),sessionKey:a,viewId:s,iframe:h,agentId:l,fileResourcesSupported:d.fileResourcesSupported,openFilesSupported:d.openFilesSupported,confirmOpenFile:e=>ue(e,`file`),isDisposed:()=>!le(),addCleanup:e=>{Oe(v,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`||!ee.available.includes(t)?Promise.resolve({mode:e.displayMode}):(e.displayMode=t,h.style.height=t===`fullscreen`||e.fillContainer?`100%`:`${v.frameHeight}px`,x.setHostContext(ae()),Promise.resolve({mode:t})),x.onopenlink=({url:e})=>!Ne(t,v,i)||!pe(v.iframe)?Promise.resolve({isError:!0}):Me(e)?Promise.resolve(Pe(r,e)?{}:{isError:!0}):Promise.resolve(ne(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,b)??n;v.frameHeight=r,h.style.height=`${r}px`,Te(),x.setHostContext(ae())}};let w=new Promise(t=>{x.oninitialized=()=>{b=!0,ee=me(d.displayModes,x.getAppCapabilities()?.availableDisplayModes),e.displayMode=te(),t()}}),ve=new Tu(h.contentWindow,h.contentWindow);v.transport=ve,await x.connect(ve),i.throwIfAborted(),await x.sendSandboxResourceReady({html:d.html,csp:d.csp}),await Vu(w,y),i.throwIfAborted();let ye=()=>x.setHostContext(ae());v.updateHostContext=ye,ye(),oe(),_e.start(),v.reconnect=async()=>{await _e.reconnect(),d.updateModelContextSupported===!0&&await S()},Oe(v,r.theme.subscribe(ye)),typeof ResizeObserver<`u`&&Oe(v,se([m],ye)),await Hu(),i.throwIfAborted(),await x.sendToolInput({arguments:n(d.toolInput)??{}}),await x.sendToolResult(d.toolResult),i.throwIfAborted()}catch(e){throw await ke(u),e}}return{confirmation:_,start:ye,dispose:xe,inputChanged:C,setup:Ce,currentBinding:je,teardown:E,restartAfterTeardown:Ae,read:()=>({inactive:l,error:u}),setMount:e=>{f=e}}}var Gu;function Ku(){return(Ku=e((()=>{Ou(),x(),i(),le(),Fe(),r(),l(),C(),Ne(),ie(),p(),Pu(),st(),Uu(),fe(),ft(),ye(),w(),Gu=250})))()}var qu,Ju,Yu,Xu,Zu,Qu,$u;function ed(){return(ed=e((()=>{Ae(),Se(),f(),ae(),b(),y(),g(),v(),z(),ft(),S(),Ku(),qu=je(`<button class=exit-fullscreen>`),Ju=je(`<div class=inactive role=status><span>`),Yu=je(`<div class=mount>`),Xu=je(`<button type=button>`),Zu=je(`<div class=error><button type=button>`),Qu=new WeakMap,$u=oe(`mcp-app-view`,(e,t)=>{let n=h(),r=ue(n.gateway),{owner:i,view:a}=ee(e=>Wu(t,n,Te,e),e=>e.read()),o=a.read;Qu.set(t,i);let s=ce(t);Te(()=>i.start()),Ee(()=>{s(),Qu.delete(t),i.dispose()});let c=()=>o().inactive===`ended`?e.onRelaunch:void 0;return[De(xe,{get when(){return Ce(()=>e.displayMode===`fullscreen`)()&&!e.sidebar},get children(){var e=qu();return e._$$click=()=>{t.displayMode=`inline`},T(e,()=>_(`common.close`)),e}}),De(xe,{get when(){return Ce(()=>!!o().inactive)()?e.surface===`conversation`:o().inactive},get children(){var t=Ju(),n=t.firstChild;return T(n,()=>_(c()?`mcpApp.sessionEnded`:`mcpApp.reconstructed`)),T(t,De(xe,{get when(){return c()},children:t=>(()=>{var n=Xu();return n._$$click=()=>t()(),T(n,()=>_(`mcpApp.relaunch`)),Oe(()=>e.relaunching,e=>{we(n,`disabled`,e)}),n})()}),null),t}}),De(ct,{get confirmation(){return i.confirmation}}),(()=>{var e=Yu();return ke(()=>e=>{i.setMount(e)},e),e})(),De(xe,{get when(){return Ce(()=>o().inactive!==`ended`)()&&o().error},children:e=>(()=>{var t=Zu(),n=t.firstChild;return T(t,()=>_(`mcpApp.unavailable`,{error:m(e(),_(`mcpApp.errors.requestFailed`))}),n),n._$$click=()=>void i.setup(i.currentBinding()),T(n,()=>_(`mcpApp.retry`)),Oe(()=>r.read().snapshot.phase!==`connected`,e=>{we(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},sidebar:{default:!1,attribute:!1}},propertyChanged:e=>Qu.get(e)?.inputChanged(),methods:{teardown:e=>Qu.get(e)?.teardown()??Promise.resolve(),restartAfterTeardown:e=>Qu.get(e)?.restartAfterTeardown(),presentInSidebar:(e,t)=>ut(e,t)}}),E([`click`])})))()}ed();export{$u as McpAppView};