@abacus-ai/cli 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -73118,7 +73118,7 @@ const Ch={216:`O`,223:`s`,248:`o`,273:`d`,295:`h`,305:`i`,320:`l`,322:`l`,359:`t
|
|
|
73118
73118
|
`);for(let t=0;t<=r.length-i.length;t++){let n=r.slice(t,t+i.length),o=n.join(`
|
|
73119
73119
|
`);if(Fg(o)===e){f=r.slice(0,t).join(`
|
|
73120
73120
|
`).length+(t>0?1:0),p=o.length;let e=n.map(e=>{let t=e.match(/^(\s*)/);return t?t[1]:``});m=a.map((t,n)=>n<e.length?e[n]+t.trimStart():t).join(`
|
|
73121
|
-
`);break}}}}if(f===-1){let e=t.substring(0,200);throw Error(`Exact match not found for string: "${e}${t.length>200?`...`:``}"`)}let h=s.substring(0,l+f),g=0;if(n.length>0){let e=0;for(;(e=h.indexOf(n,e))!==-1;)g++,e+=n.length}let _=l+f,v=s.substring(0,_)+m+s.substring(_+p);return await R.writeFile(o,v,`utf-8`),{filePath:o,type:`str_replace`,oldStr:t,newStr:n,previousNewStrings:g}}async grep(e){let{query:t,folderExcludes:n=[],folderIncludes:r=[],offset:i=0,isCaseSensitive:a=!1,path:o,outputMode:s=`files_with_matches`,contextBefore:c,contextAfter:l,contextLines:u,showLineNumbers:d,fileType:p,headLimit:m,multiline:h=!1}=e,g=this.workspacePath,_=o?T.resolve(this.workspacePath,o):`.`,v=[`--hidden`,`--max-columns`,`2000`,`--max-columns-preview`,`--path-separator`,`/`];for(let e of Mg)v.push(`--glob`,`!${e}`);if(h&&v.push(`-U`,`--multiline-dotall`),a||v.push(`-i`),s===`files_with_matches`?v.push(`--files-with-matches`):s===`count`&&v.push(`--count`),s===`content`){try{let e=await R.stat(_);(!o||e.isDirectory())&&v.push(`-H`)}catch{v.push(`-H`)}d!==!1&&v.push(`-n`),u===void 0?(c!==void 0&&v.push(`-B`,String(c)),l!==void 0&&v.push(`-A`,String(l))):v.push(`-C`,String(u))}p&&v.push(`--type`,p);for(let e of r)v.push(`-g`,e);for(let e of n)v.push(`-g`,`!${e}`);return v.push(`--`,t,_),new Promise(e=>{let t=f(ce,v,{cwd:g,stdio:[`ignore`,`pipe`,`pipe`]}),n=ee({input:t.stdout}),r=[];n.on(`line`,e=>{r.push(e)}),t.on(`close`,async()=>{try{let t=r.length;if(s===`files_with_matches`){let n=[];for(let e=0;e<r.length;e+=64){let t=r.slice(e,e+64),i=await Promise.all(t.map(async e=>{let t=T.isAbsolute(e)?e:T.resolve(g,e);try{return{filePath:e,mtimeMs:(await R.stat(t)).mtimeMs}}catch{return{filePath:e,mtimeMs:0}}}));n.push(...i)}n.sort((e,t)=>{let n=t.mtimeMs-e.mtimeMs;return n===0?e.filePath.localeCompare(t.filePath):n});let a=n.map(e=>ql(e.filePath,g));if(a=a.slice(i),m){let n=a.length>m;a=a.slice(0,m),e({matches:a,metadata:{offset:i,limit:m,totalMatches:t,hasMore:n}})}else e({matches:a,metadata:{offset:i,limit:a.length,totalMatches:t,hasMore:!1}})}else{let n=r.map(e=>{if(e===`--`)return e;let t=Ng.exec(e);return t?ql(t[1],g)+e.substring(t[1].length):e});if(n=n.slice(i),m){let r=n.length>m;n=n.slice(0,m),e({matches:n,metadata:{offset:i,limit:m,totalMatches:t,hasMore:r}})}else e({matches:n,metadata:{offset:i,limit:n.length,totalMatches:t,hasMore:!1}})}}catch{e({matches:[],metadata:{offset:i,limit:0,totalMatches:0,hasMore:!1}})}}),t.on(`error`,()=>{e({matches:[],metadata:{offset:i,limit:0,totalMatches:0,hasMore:!1}})})})}async grepFile(e){let{query:t,maxResults:n=100}=e;return(await Dg(t,{root:this.workspacePath,maxResults:n,includeHidden:!1})).paths.slice(0,n).map(e=>ql(e,this.workspacePath))}async grepTextFile(e){let{query:t,maxResults:n=100}=e,r=await Dg(t,{root:this.workspacePath,maxResults:n,includeHidden:!1}),i=[];for(let e of r.paths.slice(0,n))try{await Sh(e)||i.push(ql(e,this.workspacePath))}catch{}return i}async glob(e){let t=this.workspacePath,n=e.path?T.resolve(t,e.path):t,r=await this.globViaGit(n,e.pattern,t);return r===null?this.globViaRipgrep(n,e.pattern,t):r}async globViaGit(e,t,n){try{if(!await this.runGitCmd([`rev-parse`,`--show-toplevel`],e))return null;let[r,i]=await Promise.all([this.runGitLines([`ls-files`],e),this.runGitLines([`ls-files`,`--others`,`--exclude-standard`],e)]),a=(0,Og.default)(t,{dot:!0}),o=[];for(let t of[...r,...i]){if(!t)continue;let r=T.resolve(e,t),i=T.relative(n,r).replace(/\\/g,`/`);(a(t)||a(i)||a(T.basename(t)))&&o.push(r)}return this.sortAndBuildResult(o,n)}catch{return null}}globViaRipgrep(e,t,n){let r=[`--files`,`--hidden`,`--path-separator`,`/`,`-g`,t];for(let e of Mg)r.push(`--glob`,`!${e}`);return r.push(e),new Promise(e=>{let t=f(ce,r,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]}),i=ee({input:t.stdout}),a=[];i.on(`line`,e=>{a.push(e)}),t.on(`close`,async()=>{try{e(await this.sortAndBuildResult(a,n))}catch{e({files:[],metadata:{totalFiles:0}})}}),t.on(`error`,()=>{e({files:[],metadata:{totalFiles:0}})})})}async sortAndBuildResult(e,t){let n=[];for(let r=0;r<e.length;r+=64){let i=e.slice(r,r+64),a=await Promise.all(i.map(async e=>{let n=T.isAbsolute(e)?e:T.resolve(t,e);try{return{filePath:e,mtimeMs:(await R.stat(n)).mtimeMs}}catch{return{filePath:e,mtimeMs:0}}}));n.push(...a)}n.sort((e,t)=>{let n=t.mtimeMs-e.mtimeMs;return n===0?e.filePath.localeCompare(t.filePath):n});let r=n.map(e=>ql(e.filePath,t));return{files:r,metadata:{totalFiles:r.length}}}runGitCmd(e,t){return new Promise((n,r)=>{let i=f(`git`,e,{cwd:t,stdio:[`ignore`,`pipe`,`pipe`]}),a=``;i.stdout.on(`data`,e=>a+=e.toString()),i.on(`close`,e=>e===0?n(a.trim()):r()),i.on(`error`,r)})}runGitLines(e,t){return new Promise(n=>{let r=[],i=f(`git`,e,{cwd:t,stdio:[`ignore`,`pipe`,`pipe`]});ee({input:i.stdout}).on(`line`,e=>r.push(e.trim())),i.on(`close`,()=>n(r)),i.on(`error`,()=>n(r))})}};let Lg;Lg=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function Rg(e){return(await Lg).getRandomValues(new Uint8Array(e))}async function zg(e){let t=``;for(;t.length<e;){let n=await Rg(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Bg(e){return await zg(e)}async function Vg(e){let t=await(await Lg).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Hg(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Bg(e);return{code_verifier:t,code_challenge:await Vg(t)}}const Ug=`2025-11-25`,Wg=[Ug,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Gg=`io.modelcontextprotocol/related-task`,Kg=Wc(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),qg=uc([K(),Ws().int()]),Jg=K();cc({ttl:uc([Ws(),Zs()]).optional(),pollInterval:Ws().optional()});const Yg=sc({ttl:Ws().optional()}),Xg=sc({taskId:K()}),Zg=cc({progressToken:qg.optional(),[Gg]:Xg.optional()}),Qg=sc({_meta:Zg.optional()}),$g=Qg.extend({task:Yg.optional()}),e_=e=>$g.safeParse(e).success,t_=sc({method:K(),params:Qg.loose().optional()}),n_=sc({_meta:Zg.optional()}),r_=sc({method:K(),params:n_.loose().optional()}),i_=cc({_meta:Zg.optional()}),a_=uc([K(),Ws().int()]),o_=sc({jsonrpc:Sc(`2.0`),id:a_,...t_.shape}).strict(),s_=e=>o_.safeParse(e).success,c_=sc({jsonrpc:Sc(`2.0`),...r_.shape}).strict(),l_=e=>c_.safeParse(e).success,u_=sc({jsonrpc:Sc(`2.0`),id:a_,result:i_}).strict(),d_=e=>u_.safeParse(e).success;var f_;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,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.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(f_||={});const p_=sc({jsonrpc:Sc(`2.0`),id:a_.optional(),error:sc({code:Ws().int(),message:K(),data:tc().optional()})}).strict(),m_=e=>p_.safeParse(e).success,h_=uc([o_,c_,u_,p_]);uc([u_,p_]);const g_=i_.strict(),__=n_.extend({requestId:a_.optional(),reason:K().optional()}),v_=r_.extend({method:Sc(`notifications/cancelled`),params:__}),y_=sc({icons:ac(sc({src:K(),mimeType:K().optional(),sizes:ac(K()).optional(),theme:bc([`light`,`dark`]).optional()})).optional()}),b_=sc({name:K(),title:K().optional()}),x_=b_.extend({...b_.shape,...y_.shape,version:K(),websiteUrl:K().optional(),description:K().optional()}),S_=qc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,mc(sc({form:mc(sc({applyDefaults:Js().optional()}),vc(K(),tc())).optional(),url:Kg.optional()}),vc(K(),tc()).optional())),C_=cc({list:Kg.optional(),cancel:Kg.optional(),requests:cc({sampling:cc({createMessage:Kg.optional()}).optional(),elicitation:cc({create:Kg.optional()}).optional()}).optional()}),w_=cc({list:Kg.optional(),cancel:Kg.optional(),requests:cc({tools:cc({call:Kg.optional()}).optional()}).optional()}),T_=sc({experimental:vc(K(),Kg).optional(),sampling:sc({context:Kg.optional(),tools:Kg.optional()}).optional(),elicitation:S_.optional(),roots:sc({listChanged:Js().optional()}).optional(),tasks:C_.optional()}),E_=Qg.extend({protocolVersion:K(),capabilities:T_,clientInfo:x_}),D_=t_.extend({method:Sc(`initialize`),params:E_}),O_=sc({experimental:vc(K(),Kg).optional(),logging:Kg.optional(),completions:Kg.optional(),prompts:sc({listChanged:Js().optional()}).optional(),resources:sc({subscribe:Js().optional(),listChanged:Js().optional()}).optional(),tools:sc({listChanged:Js().optional()}).optional(),tasks:w_.optional()}),k_=i_.extend({protocolVersion:K(),capabilities:O_,serverInfo:x_,instructions:K().optional()}),A_=r_.extend({method:Sc(`notifications/initialized`),params:n_.optional()}),j_=e=>A_.safeParse(e).success,M_=t_.extend({method:Sc(`ping`),params:Qg.optional()}),N_=sc({progress:Ws(),total:Ec(Ws()),message:Ec(K())}),P_=sc({...n_.shape,...N_.shape,progressToken:qg}),F_=r_.extend({method:Sc(`notifications/progress`),params:P_}),I_=Qg.extend({cursor:Jg.optional()}),L_=t_.extend({params:I_.optional()}),R_=i_.extend({nextCursor:Jg.optional()}),z_=bc([`working`,`input_required`,`completed`,`failed`,`cancelled`]),B_=sc({taskId:K(),status:z_,ttl:uc([Ws(),Zs()]),createdAt:K(),lastUpdatedAt:K(),pollInterval:Ec(Ws()),statusMessage:Ec(K())}),V_=i_.extend({task:B_}),H_=n_.merge(B_),U_=r_.extend({method:Sc(`notifications/tasks/status`),params:H_}),W_=t_.extend({method:Sc(`tasks/get`),params:Qg.extend({taskId:K()})}),G_=i_.merge(B_),K_=t_.extend({method:Sc(`tasks/result`),params:Qg.extend({taskId:K()})});i_.loose();const q_=L_.extend({method:Sc(`tasks/list`)}),J_=R_.extend({tasks:ac(B_)}),Y_=t_.extend({method:Sc(`tasks/cancel`),params:Qg.extend({taskId:K()})}),X_=i_.merge(B_),Z_=sc({uri:K(),mimeType:Ec(K()),_meta:vc(K(),tc()).optional()}),Q_=Z_.extend({text:K()}),$_=K().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),ev=Z_.extend({blob:$_}),tv=bc([`user`,`assistant`]),nv=sc({audience:ac(tv).optional(),priority:Ws().min(0).max(1).optional(),lastModified:Qo({offset:!0}).optional()}),rv=sc({...b_.shape,...y_.shape,uri:K(),description:Ec(K()),mimeType:Ec(K()),annotations:nv.optional(),_meta:Ec(cc({}))}),iv=sc({...b_.shape,...y_.shape,uriTemplate:K(),description:Ec(K()),mimeType:Ec(K()),annotations:nv.optional(),_meta:Ec(cc({}))}),av=L_.extend({method:Sc(`resources/list`)}),ov=R_.extend({resources:ac(rv)}),sv=L_.extend({method:Sc(`resources/templates/list`)}),cv=R_.extend({resourceTemplates:ac(iv)}),lv=Qg.extend({uri:K()}),uv=lv,dv=t_.extend({method:Sc(`resources/read`),params:uv}),fv=i_.extend({contents:ac(uc([Q_,ev]))}),pv=r_.extend({method:Sc(`notifications/resources/list_changed`),params:n_.optional()}),mv=lv,hv=t_.extend({method:Sc(`resources/subscribe`),params:mv}),gv=lv,_v=t_.extend({method:Sc(`resources/unsubscribe`),params:gv}),vv=n_.extend({uri:K()}),yv=r_.extend({method:Sc(`notifications/resources/updated`),params:vv}),bv=sc({name:K(),description:Ec(K()),required:Ec(Js())}),xv=sc({...b_.shape,...y_.shape,description:Ec(K()),arguments:Ec(ac(bv)),_meta:Ec(cc({}))}),Sv=L_.extend({method:Sc(`prompts/list`)}),Cv=R_.extend({prompts:ac(xv)}),wv=Qg.extend({name:K(),arguments:vc(K(),K()).optional()}),Tv=t_.extend({method:Sc(`prompts/get`),params:wv}),Ev=sc({type:Sc(`text`),text:K(),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),Dv=sc({type:Sc(`image`),data:$_,mimeType:K(),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),Ov=sc({type:Sc(`audio`),data:$_,mimeType:K(),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),kv=sc({type:Sc(`tool_use`),name:K(),id:K(),input:vc(K(),tc()),_meta:vc(K(),tc()).optional()}),Av=sc({type:Sc(`resource`),resource:uc([Q_,ev]),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),jv=uc([Ev,Dv,Ov,rv.extend({type:Sc(`resource_link`)}),Av]),Mv=sc({role:tv,content:jv}),Nv=i_.extend({description:K().optional(),messages:ac(Mv)}),Pv=r_.extend({method:Sc(`notifications/prompts/list_changed`),params:n_.optional()}),Fv=sc({title:K().optional(),readOnlyHint:Js().optional(),destructiveHint:Js().optional(),idempotentHint:Js().optional(),openWorldHint:Js().optional()}),Iv=sc({taskSupport:bc([`required`,`optional`,`forbidden`]).optional()}),Lv=sc({...b_.shape,...y_.shape,description:K().optional(),inputSchema:sc({type:Sc(`object`),properties:vc(K(),Kg).optional(),required:ac(K()).optional()}).catchall(tc()),outputSchema:sc({type:Sc(`object`),properties:vc(K(),Kg).optional(),required:ac(K()).optional()}).catchall(tc()).optional(),annotations:Fv.optional(),execution:Iv.optional(),_meta:vc(K(),tc()).optional()}),Rv=L_.extend({method:Sc(`tools/list`)}),zv=R_.extend({tools:ac(Lv)}),Bv=i_.extend({content:ac(jv).default([]),structuredContent:vc(K(),tc()).optional(),isError:Js().optional()});Bv.or(i_.extend({toolResult:tc()}));const Vv=$g.extend({name:K(),arguments:vc(K(),tc()).optional()}),Hv=t_.extend({method:Sc(`tools/call`),params:Vv}),Uv=r_.extend({method:Sc(`notifications/tools/list_changed`),params:n_.optional()}),Wv=sc({autoRefresh:Js().default(!0),debounceMs:Ws().int().nonnegative().default(300)}),Gv=bc([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Kv=Qg.extend({level:Gv}),qv=t_.extend({method:Sc(`logging/setLevel`),params:Kv}),Jv=n_.extend({level:Gv,logger:K().optional(),data:tc()}),Yv=r_.extend({method:Sc(`notifications/message`),params:Jv}),Xv=sc({hints:ac(sc({name:K().optional()})).optional(),costPriority:Ws().min(0).max(1).optional(),speedPriority:Ws().min(0).max(1).optional(),intelligencePriority:Ws().min(0).max(1).optional()}),Zv=sc({mode:bc([`auto`,`required`,`none`]).optional()}),Qv=sc({type:Sc(`tool_result`),toolUseId:K().describe(`The unique identifier for the corresponding tool call.`),content:ac(jv).default([]),structuredContent:sc({}).loose().optional(),isError:Js().optional(),_meta:vc(K(),tc()).optional()}),$v=fc(`type`,[Ev,Dv,Ov]),ey=fc(`type`,[Ev,Dv,Ov,kv,Qv]),ty=sc({role:tv,content:uc([ey,ac(ey)]),_meta:vc(K(),tc()).optional()}),ny=$g.extend({messages:ac(ty),modelPreferences:Xv.optional(),systemPrompt:K().optional(),includeContext:bc([`none`,`thisServer`,`allServers`]).optional(),temperature:Ws().optional(),maxTokens:Ws().int(),stopSequences:ac(K()).optional(),metadata:Kg.optional(),tools:ac(Lv).optional(),toolChoice:Zv.optional()}),ry=t_.extend({method:Sc(`sampling/createMessage`),params:ny}),iy=i_.extend({model:K(),stopReason:Ec(bc([`endTurn`,`stopSequence`,`maxTokens`]).or(K())),role:tv,content:$v}),ay=i_.extend({model:K(),stopReason:Ec(bc([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(K())),role:tv,content:uc([ey,ac(ey)])}),oy=sc({type:Sc(`boolean`),title:K().optional(),description:K().optional(),default:Js().optional()}),sy=sc({type:Sc(`string`),title:K().optional(),description:K().optional(),minLength:Ws().optional(),maxLength:Ws().optional(),format:bc([`email`,`uri`,`date`,`date-time`]).optional(),default:K().optional()}),cy=sc({type:bc([`number`,`integer`]),title:K().optional(),description:K().optional(),minimum:Ws().optional(),maximum:Ws().optional(),default:Ws().optional()}),ly=sc({type:Sc(`string`),title:K().optional(),description:K().optional(),enum:ac(K()),default:K().optional()}),uy=sc({type:Sc(`string`),title:K().optional(),description:K().optional(),oneOf:ac(sc({const:K(),title:K()})),default:K().optional()}),dy=uc([uc([sc({type:Sc(`string`),title:K().optional(),description:K().optional(),enum:ac(K()),enumNames:ac(K()).optional(),default:K().optional()}),uc([ly,uy]),uc([sc({type:Sc(`array`),title:K().optional(),description:K().optional(),minItems:Ws().optional(),maxItems:Ws().optional(),items:sc({type:Sc(`string`),enum:ac(K())}),default:ac(K()).optional()}),sc({type:Sc(`array`),title:K().optional(),description:K().optional(),minItems:Ws().optional(),maxItems:Ws().optional(),items:sc({anyOf:ac(sc({const:K(),title:K()}))}),default:ac(K()).optional()})])]),oy,sy,cy]),fy=uc([$g.extend({mode:Sc(`form`).optional(),message:K(),requestedSchema:sc({type:Sc(`object`),properties:vc(K(),dy),required:ac(K()).optional()})}),$g.extend({mode:Sc(`url`),message:K(),elicitationId:K(),url:K().url()})]),py=t_.extend({method:Sc(`elicitation/create`),params:fy}),my=n_.extend({elicitationId:K()}),hy=r_.extend({method:Sc(`notifications/elicitation/complete`),params:my}),gy=i_.extend({action:bc([`accept`,`decline`,`cancel`]),content:qc(e=>e===null?void 0:e,vc(K(),uc([K(),Ws(),Js(),ac(K())])).optional())}),_y=sc({type:Sc(`ref/resource`),uri:K()}),vy=sc({type:Sc(`ref/prompt`),name:K()}),yy=Qg.extend({ref:uc([vy,_y]),argument:sc({name:K(),value:K()}),context:sc({arguments:vc(K(),K()).optional()}).optional()}),by=t_.extend({method:Sc(`completion/complete`),params:yy}),xy=i_.extend({completion:cc({values:ac(K()).max(100),total:Ec(Ws().int()),hasMore:Ec(Js())})}),Sy=sc({uri:K().startsWith(`file://`),name:K().optional(),_meta:vc(K(),tc()).optional()}),Cy=t_.extend({method:Sc(`roots/list`),params:Qg.optional()}),wy=i_.extend({roots:ac(Sy)}),Ty=r_.extend({method:Sc(`notifications/roots/list_changed`),params:n_.optional()});uc([M_,D_,by,qv,Tv,Sv,av,sv,dv,hv,_v,Hv,Rv,W_,K_,q_,Y_]),uc([v_,F_,A_,Ty,U_]),uc([g_,iy,ay,gy,wy,G_,J_,V_]),uc([M_,ry,py,Cy,W_,K_,q_,Y_]),uc([v_,F_,Yv,yv,pv,Uv,Pv,U_,hy]),uc([g_,k_,xy,Nv,Cv,ov,cv,fv,Bv,zv,G_,J_,V_]);var Ey=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===f_.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Dy(e.elicitations,n)}return new e(t,n,r)}},Dy=class extends Ey{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(f_.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};const Oy=Ds().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Jc.custom,message:`URL must be parseable`,fatal:!0}),ze}).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`}),ky=cc({resource:K().url(),authorization_servers:ac(Oy).optional(),jwks_uri:K().url().optional(),scopes_supported:ac(K()).optional(),bearer_methods_supported:ac(K()).optional(),resource_signing_alg_values_supported:ac(K()).optional(),resource_name:K().optional(),resource_documentation:K().optional(),resource_policy_uri:K().url().optional(),resource_tos_uri:K().url().optional(),tls_client_certificate_bound_access_tokens:Js().optional(),authorization_details_types_supported:ac(K()).optional(),dpop_signing_alg_values_supported:ac(K()).optional(),dpop_bound_access_tokens_required:Js().optional()}),Ay=cc({issuer:K(),authorization_endpoint:Oy,token_endpoint:Oy,registration_endpoint:Oy.optional(),scopes_supported:ac(K()).optional(),response_types_supported:ac(K()),response_modes_supported:ac(K()).optional(),grant_types_supported:ac(K()).optional(),token_endpoint_auth_methods_supported:ac(K()).optional(),token_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),service_documentation:Oy.optional(),revocation_endpoint:Oy.optional(),revocation_endpoint_auth_methods_supported:ac(K()).optional(),revocation_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),introspection_endpoint:K().optional(),introspection_endpoint_auth_methods_supported:ac(K()).optional(),introspection_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),code_challenge_methods_supported:ac(K()).optional(),client_id_metadata_document_supported:Js().optional()}),jy=sc({...cc({issuer:K(),authorization_endpoint:Oy,token_endpoint:Oy,userinfo_endpoint:Oy.optional(),jwks_uri:Oy,registration_endpoint:Oy.optional(),scopes_supported:ac(K()).optional(),response_types_supported:ac(K()),response_modes_supported:ac(K()).optional(),grant_types_supported:ac(K()).optional(),acr_values_supported:ac(K()).optional(),subject_types_supported:ac(K()),id_token_signing_alg_values_supported:ac(K()),id_token_encryption_alg_values_supported:ac(K()).optional(),id_token_encryption_enc_values_supported:ac(K()).optional(),userinfo_signing_alg_values_supported:ac(K()).optional(),userinfo_encryption_alg_values_supported:ac(K()).optional(),userinfo_encryption_enc_values_supported:ac(K()).optional(),request_object_signing_alg_values_supported:ac(K()).optional(),request_object_encryption_alg_values_supported:ac(K()).optional(),request_object_encryption_enc_values_supported:ac(K()).optional(),token_endpoint_auth_methods_supported:ac(K()).optional(),token_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),display_values_supported:ac(K()).optional(),claim_types_supported:ac(K()).optional(),claims_supported:ac(K()).optional(),service_documentation:K().optional(),claims_locales_supported:ac(K()).optional(),ui_locales_supported:ac(K()).optional(),claims_parameter_supported:Js().optional(),request_parameter_supported:Js().optional(),request_uri_parameter_supported:Js().optional(),require_request_uri_registration:Js().optional(),op_policy_uri:Oy.optional(),op_tos_uri:Oy.optional(),client_id_metadata_document_supported:Js().optional()}).shape,...Ay.pick({code_challenge_methods_supported:!0}).shape}),My=sc({access_token:K(),id_token:K().optional(),token_type:K(),expires_in:Zc().optional(),scope:K().optional(),refresh_token:K().optional()}).strip(),Ny=sc({error:K(),error_description:K().optional(),error_uri:K().optional()}),Py=Oy.optional().or(Sc(``).transform(()=>void 0)),Fy=sc({redirect_uris:ac(Oy),token_endpoint_auth_method:K().optional(),grant_types:ac(K()).optional(),response_types:ac(K()).optional(),client_name:K().optional(),client_uri:Oy.optional(),logo_uri:Py,scope:K().optional(),contacts:ac(K()).optional(),tos_uri:Py,policy_uri:K().optional(),jwks_uri:Oy.optional(),jwks:$s().optional(),software_id:K().optional(),software_version:K().optional(),software_statement:K().optional()}).strip(),Iy=sc({client_id:K(),client_secret:K().optional(),client_id_issued_at:Ws().optional(),client_secret_expires_at:Ws().optional()}).strip(),Ly=Fy.merge(Iy);sc({error:K(),error_description:K().optional()}).strip(),sc({token:K(),token_type_hint:K().optional()}).strip();function Ry(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function zy({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var By=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Vy=class extends By{};Vy.errorCode=`invalid_request`;var Hy=class extends By{};Hy.errorCode=`invalid_client`;var Uy=class extends By{};Uy.errorCode=`invalid_grant`;var Wy=class extends By{};Wy.errorCode=`unauthorized_client`;var Gy=class extends By{};Gy.errorCode=`unsupported_grant_type`;var Ky=class extends By{};Ky.errorCode=`invalid_scope`;var qy=class extends By{};qy.errorCode=`access_denied`;var Jy=class extends By{};Jy.errorCode=`server_error`;var Yy=class extends By{};Yy.errorCode=`temporarily_unavailable`;var Xy=class extends By{};Xy.errorCode=`unsupported_response_type`;var Zy=class extends By{};Zy.errorCode=`unsupported_token_type`;var Qy=class extends By{};Qy.errorCode=`invalid_token`;var $y=class extends By{};$y.errorCode=`method_not_allowed`;var eb=class extends By{};eb.errorCode=`too_many_requests`;var tb=class extends By{};tb.errorCode=`invalid_client_metadata`;var nb=class extends By{};nb.errorCode=`insufficient_scope`;var rb=class extends By{};rb.errorCode=`invalid_target`;const ib={[Vy.errorCode]:Vy,[Hy.errorCode]:Hy,[Uy.errorCode]:Uy,[Wy.errorCode]:Wy,[Gy.errorCode]:Gy,[Ky.errorCode]:Ky,[qy.errorCode]:qy,[Jy.errorCode]:Jy,[Yy.errorCode]:Yy,[Xy.errorCode]:Xy,[Zy.errorCode]:Zy,[Qy.errorCode]:Qy,[$y.errorCode]:$y,[eb.errorCode]:eb,[tb.errorCode]:tb,[nb.errorCode]:nb,[rb.errorCode]:rb};var ab=class extends Error{constructor(e){super(e??`Unauthorized`)}};function ob(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}const sb=`code`,cb=`S256`;function lb(e,t){let n=e.client_secret!==void 0;return t.length===0?n?`client_secret_post`:`none`:`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&ob(e.token_endpoint_auth_method)&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function ub(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:db(i,a,n);return;case`client_secret_post`:fb(i,a,r);return;case`none`:pb(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function db(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function fb(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function pb(e,t){t.set(`client_id`,e)}async function mb(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=Ny.parse(JSON.parse(n));return new(ib[e]||Jy)(t||``,r)}catch(e){return new Jy(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function hb(e,t){try{return await gb(e,t)}catch(n){if(n instanceof Hy||n instanceof Wy)return await e.invalidateCredentials?.(`all`),await gb(e,t);if(n instanceof Uy)return await e.invalidateCredentials?.(`tokens`),await gb(e,t);throw n}}async function gb(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await Ob(c,{fetchFn:a}),!s)try{s=await xb(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await kb(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await vb(t,e,s),f=await Promise.resolve(e.clientInformation());if(!f){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!_b(r))throw new tb(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)f={client_id:r},await e.saveClientInformation?.(f);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await Fb(c,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:a});await e.saveClientInformation(t),f=t}}let p=!e.redirectUrl;if(n!==void 0||p){let t=await Pb(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let m=await e.tokens();if(m?.refresh_token)try{let t=await Nb(c,{metadata:l,clientInformation:f,refreshToken:m.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof By)||e instanceof Jy))throw e}let h=e.state?await e.state():void 0,{authorizationUrl:g,codeVerifier:_}=await Ab(c,{metadata:l,clientInformation:f,state:h,redirectUrl:e.redirectUrl,scope:r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,resource:d});return await e.saveCodeVerifier(_),await e.redirectToAuthorization(g),`REDIRECT`}function _b(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function vb(e,t,n){let r=Ry(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!zy({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function yb(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=bb(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=bb(e,`scope`)||void 0,s=bb(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function bb(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function xb(e,t,n=fetch){let r=await Eb(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return ky.parse(await r.json())}async function Sb(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Sb(e,void 0,n):void 0;throw r}}function Cb(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function wb(e,t,n=fetch){return await Sb(e,{"MCP-Protocol-Version":t},n)}function Tb(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function Eb(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Cb(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await wb(o,a,n);return!r?.metadataUrl&&Tb(s,i.pathname)&&(s=await wb(new URL(`/.well-known/${t}`,i),a,n)),s}function Db(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function Ob(e,{fetchFn:t=fetch,protocolVersion:n=Ug}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=Db(e);for(let{url:e,type:n}of i){let i=await Sb(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?Ay.parse(await i.json()):jy.parse(await i.json())}}}async function kb(e,t){let n,r;try{n=await xb(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await Ob(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function Ab(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(sb))throw Error(`Incompatible auth server: does not support response type ${sb}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(cb))throw Error(`Incompatible auth server: does not support code challenge method ${cb}`)}else s=new URL(`/authorize`,e);let c=await Hg(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,sb),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,cb),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function jb(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function Mb(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&ub(lb(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await mb(l);return My.parse(await l.json())}async function Nb(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await Mb(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function Pb(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=jb(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return Mb(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function Fb(e,{metadata:t,clientMetadata:n,fetchFn:r}){let i;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);i=new URL(t.registration_endpoint)}else i=new URL(`/register`,e);let a=await(r??fetch)(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw await mb(a);return Ly.parse(await a.json())}function Ib(e){return!!e._zod}function Lb(e,t){return Ib(e)?zt(e,t):e.safeParse(t)}function Rb(e){if(!e)return;let t;if(t=Ib(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function zb(e){if(Ib(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function Bb(e){return e===`completed`||e===`failed`||e===`cancelled`}function Vb(e){let t=Rb(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=zb(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Hb(e,t){let n=Lb(e,t);if(!n.success)throw n.error;return n.data}var Ub=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(v_,e=>{this._oncancel(e)}),this.setNotificationHandler(F_,e=>{this._onprogress(e)}),this.setRequestHandler(M_,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(W_,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new Ey(f_.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(K_,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new Ey(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new Ey(f_.InvalidParams,`Task not found: ${r}`);if(!Bb(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(Bb(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[Gg]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(q_,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new Ey(f_.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Y_,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new Ey(f_.InvalidParams,`Task not found: ${e.params.taskId}`);if(Bb(n.status))throw new Ey(f_.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Ey(f_.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof Ey?e:new Ey(f_.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&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),Ey.fromError(f_.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){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),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),d_(e)||m_(e)?this._onresponse(e):s_(e)?this._onrequest(e,t):l_(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=Ey.fromError(f_.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[Gg]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:f_.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=e_(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new Ey(f_.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:f_.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.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._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),d_(e)?n(e):n(new Ey(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(d_(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),d_(e)?r(e):r(Ey.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof Ey?e:new Ey(f_.InternalError,String(e))}}return}let i;try{let r=await this.request(e,V_,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new Ey(f_.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Bb(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new Ey(f_.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new Ey(f_.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof Ey?e:new Ey(f_.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Gg]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof Ey?e:new Ey(f_.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Lb(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(Ey.fromError(f_.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},G_,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},J_,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},X_,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[Gg]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[Gg]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[Gg]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Vb(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Hb(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Vb(e);this._notificationHandlers.set(n,n=>{let r=Hb(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&s_(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new Ey(f_.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new Ey(f_.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new Ey(f_.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new Ey(f_.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=U_.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Bb(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new Ey(f_.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Bb(a.status))throw new Ey(f_.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=U_.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Bb(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function Wb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gb(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];Wb(a)&&Wb(i)?n[r]={...a,...i}:n[r]=i}return n}var Kb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),qb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Kb();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Jb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=Kb(),n=qb();var r=Kb();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=qb();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
73121
|
+
`);break}}}}if(f===-1){let e=t.substring(0,200);throw Error(`Exact match not found for string: "${e}${t.length>200?`...`:``}"`)}let h=s.substring(0,l+f),g=0;if(n.length>0){let e=0;for(;(e=h.indexOf(n,e))!==-1;)g++,e+=n.length}let _=l+f,v=s.substring(0,_)+m+s.substring(_+p);return await R.writeFile(o,v,`utf-8`),{filePath:o,type:`str_replace`,oldStr:t,newStr:n,previousNewStrings:g}}async grep(e){let{query:t,folderExcludes:n=[],folderIncludes:r=[],offset:i=0,isCaseSensitive:a=!1,path:o,outputMode:s=`files_with_matches`,contextBefore:c,contextAfter:l,contextLines:u,showLineNumbers:d,fileType:p,headLimit:m,multiline:h=!1}=e,g=this.workspacePath,_=o?T.resolve(this.workspacePath,o):`.`,v=[`--hidden`,`-L`,`--max-columns`,`2000`,`--max-columns-preview`,`--path-separator`,`/`];for(let e of Mg)v.push(`--glob`,`!${e}`);if(h&&v.push(`-U`,`--multiline-dotall`),a||v.push(`-i`),s===`files_with_matches`?v.push(`--files-with-matches`):s===`count`&&v.push(`--count`),s===`content`){try{let e=await R.stat(_);(!o||e.isDirectory())&&v.push(`-H`)}catch{v.push(`-H`)}d!==!1&&v.push(`-n`),u===void 0?(c!==void 0&&v.push(`-B`,String(c)),l!==void 0&&v.push(`-A`,String(l))):v.push(`-C`,String(u))}p&&v.push(`--type`,p);for(let e of r)v.push(`-g`,e);for(let e of n)v.push(`-g`,`!${e}`);return v.push(`--`,t,_),new Promise(e=>{let t=f(ce,v,{cwd:g,stdio:[`ignore`,`pipe`,`pipe`]}),n=ee({input:t.stdout}),r=[],a=[];n.on(`line`,e=>{r.push(e)}),t.stderr.on(`data`,e=>{a.push(e)}),t.on(`close`,async t=>{try{if(t===2){e({matches:[`Error: ${Buffer.concat(a).toString().trim()||`ripgrep exited with error code 2`}`],metadata:{offset:i,limit:0,totalMatches:0,hasMore:!1}});return}let n=r.length;if(s===`files_with_matches`){let t=[];for(let e=0;e<r.length;e+=64){let n=r.slice(e,e+64),i=await Promise.all(n.map(async e=>{let t=T.isAbsolute(e)?e:T.resolve(g,e);try{return{filePath:e,mtimeMs:(await R.stat(t)).mtimeMs}}catch{return{filePath:e,mtimeMs:0}}}));t.push(...i)}t.sort((e,t)=>{let n=t.mtimeMs-e.mtimeMs;return n===0?e.filePath.localeCompare(t.filePath):n});let a=t.map(e=>ql(e.filePath,g));if(a=a.slice(i),m){let t=a.length>m;a=a.slice(0,m),e({matches:a,metadata:{offset:i,limit:m,totalMatches:n,hasMore:t}})}else e({matches:a,metadata:{offset:i,limit:a.length,totalMatches:n,hasMore:!1}})}else{let t=r.map(e=>{if(e===`--`)return e;let t=Ng.exec(e);return t?ql(t[1],g)+e.substring(t[1].length):e});if(t=t.slice(i),m){let r=t.length>m;t=t.slice(0,m),e({matches:t,metadata:{offset:i,limit:m,totalMatches:n,hasMore:r}})}else e({matches:t,metadata:{offset:i,limit:t.length,totalMatches:n,hasMore:!1}})}}catch{e({matches:[],metadata:{offset:i,limit:0,totalMatches:0,hasMore:!1}})}}),t.on(`error`,t=>{e({matches:[`Error: ${t.message}`],metadata:{offset:i,limit:0,totalMatches:0,hasMore:!1}})})})}async grepFile(e){let{query:t,maxResults:n=100}=e;return(await Dg(t,{root:this.workspacePath,maxResults:n,includeHidden:!1})).paths.slice(0,n).map(e=>ql(e,this.workspacePath))}async grepTextFile(e){let{query:t,maxResults:n=100}=e,r=await Dg(t,{root:this.workspacePath,maxResults:n,includeHidden:!1}),i=[];for(let e of r.paths.slice(0,n))try{await Sh(e)||i.push(ql(e,this.workspacePath))}catch{}return i}async glob(e){let t=this.workspacePath,n=e.path?T.resolve(t,e.path):t,r=await this.globViaGit(n,e.pattern,t);return r===null?this.globViaRipgrep(n,e.pattern,t):r}async globViaGit(e,t,n){try{if(!await this.runGitCmd([`rev-parse`,`--show-toplevel`],e))return null;let[r,i]=await Promise.all([this.runGitLines([`ls-files`],e),this.runGitLines([`ls-files`,`--others`,`--exclude-standard`],e)]),a=(0,Og.default)(t,{dot:!0}),o=[];for(let t of[...r,...i]){if(!t)continue;let r=T.resolve(e,t),i=T.relative(n,r).replace(/\\/g,`/`);(a(t)||a(i)||a(T.basename(t)))&&o.push(r)}return this.sortAndBuildResult(o,n)}catch{return null}}globViaRipgrep(e,t,n){let r=[`--files`,`--hidden`,`-L`,`--path-separator`,`/`,`-g`,t];for(let e of Mg)r.push(`--glob`,`!${e}`);return r.push(e),new Promise(e=>{let t=f(ce,r,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]}),i=ee({input:t.stdout}),a=[];i.on(`line`,e=>{a.push(e)}),t.on(`close`,async()=>{try{e(await this.sortAndBuildResult(a,n))}catch{e({files:[],metadata:{totalFiles:0}})}}),t.on(`error`,()=>{e({files:[],metadata:{totalFiles:0}})})})}async sortAndBuildResult(e,t){let n=[];for(let r=0;r<e.length;r+=64){let i=e.slice(r,r+64),a=await Promise.all(i.map(async e=>{let n=T.isAbsolute(e)?e:T.resolve(t,e);try{return{filePath:e,mtimeMs:(await R.stat(n)).mtimeMs}}catch{return{filePath:e,mtimeMs:0}}}));n.push(...a)}n.sort((e,t)=>{let n=t.mtimeMs-e.mtimeMs;return n===0?e.filePath.localeCompare(t.filePath):n});let r=n.map(e=>ql(e.filePath,t));return{files:r,metadata:{totalFiles:r.length}}}runGitCmd(e,t){return new Promise((n,r)=>{let i=f(`git`,e,{cwd:t,stdio:[`ignore`,`pipe`,`pipe`]}),a=``;i.stdout.on(`data`,e=>a+=e.toString()),i.on(`close`,e=>e===0?n(a.trim()):r()),i.on(`error`,r)})}runGitLines(e,t){return new Promise(n=>{let r=[],i=f(`git`,e,{cwd:t,stdio:[`ignore`,`pipe`,`pipe`]});ee({input:i.stdout}).on(`line`,e=>r.push(e.trim())),i.on(`close`,()=>n(r)),i.on(`error`,()=>n(r))})}};let Lg;Lg=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function Rg(e){return(await Lg).getRandomValues(new Uint8Array(e))}async function zg(e){let t=``;for(;t.length<e;){let n=await Rg(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Bg(e){return await zg(e)}async function Vg(e){let t=await(await Lg).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Hg(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Bg(e);return{code_verifier:t,code_challenge:await Vg(t)}}const Ug=`2025-11-25`,Wg=[Ug,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Gg=`io.modelcontextprotocol/related-task`,Kg=Wc(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),qg=uc([K(),Ws().int()]),Jg=K();cc({ttl:uc([Ws(),Zs()]).optional(),pollInterval:Ws().optional()});const Yg=sc({ttl:Ws().optional()}),Xg=sc({taskId:K()}),Zg=cc({progressToken:qg.optional(),[Gg]:Xg.optional()}),Qg=sc({_meta:Zg.optional()}),$g=Qg.extend({task:Yg.optional()}),e_=e=>$g.safeParse(e).success,t_=sc({method:K(),params:Qg.loose().optional()}),n_=sc({_meta:Zg.optional()}),r_=sc({method:K(),params:n_.loose().optional()}),i_=cc({_meta:Zg.optional()}),a_=uc([K(),Ws().int()]),o_=sc({jsonrpc:Sc(`2.0`),id:a_,...t_.shape}).strict(),s_=e=>o_.safeParse(e).success,c_=sc({jsonrpc:Sc(`2.0`),...r_.shape}).strict(),l_=e=>c_.safeParse(e).success,u_=sc({jsonrpc:Sc(`2.0`),id:a_,result:i_}).strict(),d_=e=>u_.safeParse(e).success;var f_;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,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.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(f_||={});const p_=sc({jsonrpc:Sc(`2.0`),id:a_.optional(),error:sc({code:Ws().int(),message:K(),data:tc().optional()})}).strict(),m_=e=>p_.safeParse(e).success,h_=uc([o_,c_,u_,p_]);uc([u_,p_]);const g_=i_.strict(),__=n_.extend({requestId:a_.optional(),reason:K().optional()}),v_=r_.extend({method:Sc(`notifications/cancelled`),params:__}),y_=sc({icons:ac(sc({src:K(),mimeType:K().optional(),sizes:ac(K()).optional(),theme:bc([`light`,`dark`]).optional()})).optional()}),b_=sc({name:K(),title:K().optional()}),x_=b_.extend({...b_.shape,...y_.shape,version:K(),websiteUrl:K().optional(),description:K().optional()}),S_=qc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,mc(sc({form:mc(sc({applyDefaults:Js().optional()}),vc(K(),tc())).optional(),url:Kg.optional()}),vc(K(),tc()).optional())),C_=cc({list:Kg.optional(),cancel:Kg.optional(),requests:cc({sampling:cc({createMessage:Kg.optional()}).optional(),elicitation:cc({create:Kg.optional()}).optional()}).optional()}),w_=cc({list:Kg.optional(),cancel:Kg.optional(),requests:cc({tools:cc({call:Kg.optional()}).optional()}).optional()}),T_=sc({experimental:vc(K(),Kg).optional(),sampling:sc({context:Kg.optional(),tools:Kg.optional()}).optional(),elicitation:S_.optional(),roots:sc({listChanged:Js().optional()}).optional(),tasks:C_.optional()}),E_=Qg.extend({protocolVersion:K(),capabilities:T_,clientInfo:x_}),D_=t_.extend({method:Sc(`initialize`),params:E_}),O_=sc({experimental:vc(K(),Kg).optional(),logging:Kg.optional(),completions:Kg.optional(),prompts:sc({listChanged:Js().optional()}).optional(),resources:sc({subscribe:Js().optional(),listChanged:Js().optional()}).optional(),tools:sc({listChanged:Js().optional()}).optional(),tasks:w_.optional()}),k_=i_.extend({protocolVersion:K(),capabilities:O_,serverInfo:x_,instructions:K().optional()}),A_=r_.extend({method:Sc(`notifications/initialized`),params:n_.optional()}),j_=e=>A_.safeParse(e).success,M_=t_.extend({method:Sc(`ping`),params:Qg.optional()}),N_=sc({progress:Ws(),total:Ec(Ws()),message:Ec(K())}),P_=sc({...n_.shape,...N_.shape,progressToken:qg}),F_=r_.extend({method:Sc(`notifications/progress`),params:P_}),I_=Qg.extend({cursor:Jg.optional()}),L_=t_.extend({params:I_.optional()}),R_=i_.extend({nextCursor:Jg.optional()}),z_=bc([`working`,`input_required`,`completed`,`failed`,`cancelled`]),B_=sc({taskId:K(),status:z_,ttl:uc([Ws(),Zs()]),createdAt:K(),lastUpdatedAt:K(),pollInterval:Ec(Ws()),statusMessage:Ec(K())}),V_=i_.extend({task:B_}),H_=n_.merge(B_),U_=r_.extend({method:Sc(`notifications/tasks/status`),params:H_}),W_=t_.extend({method:Sc(`tasks/get`),params:Qg.extend({taskId:K()})}),G_=i_.merge(B_),K_=t_.extend({method:Sc(`tasks/result`),params:Qg.extend({taskId:K()})});i_.loose();const q_=L_.extend({method:Sc(`tasks/list`)}),J_=R_.extend({tasks:ac(B_)}),Y_=t_.extend({method:Sc(`tasks/cancel`),params:Qg.extend({taskId:K()})}),X_=i_.merge(B_),Z_=sc({uri:K(),mimeType:Ec(K()),_meta:vc(K(),tc()).optional()}),Q_=Z_.extend({text:K()}),$_=K().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),ev=Z_.extend({blob:$_}),tv=bc([`user`,`assistant`]),nv=sc({audience:ac(tv).optional(),priority:Ws().min(0).max(1).optional(),lastModified:Qo({offset:!0}).optional()}),rv=sc({...b_.shape,...y_.shape,uri:K(),description:Ec(K()),mimeType:Ec(K()),annotations:nv.optional(),_meta:Ec(cc({}))}),iv=sc({...b_.shape,...y_.shape,uriTemplate:K(),description:Ec(K()),mimeType:Ec(K()),annotations:nv.optional(),_meta:Ec(cc({}))}),av=L_.extend({method:Sc(`resources/list`)}),ov=R_.extend({resources:ac(rv)}),sv=L_.extend({method:Sc(`resources/templates/list`)}),cv=R_.extend({resourceTemplates:ac(iv)}),lv=Qg.extend({uri:K()}),uv=lv,dv=t_.extend({method:Sc(`resources/read`),params:uv}),fv=i_.extend({contents:ac(uc([Q_,ev]))}),pv=r_.extend({method:Sc(`notifications/resources/list_changed`),params:n_.optional()}),mv=lv,hv=t_.extend({method:Sc(`resources/subscribe`),params:mv}),gv=lv,_v=t_.extend({method:Sc(`resources/unsubscribe`),params:gv}),vv=n_.extend({uri:K()}),yv=r_.extend({method:Sc(`notifications/resources/updated`),params:vv}),bv=sc({name:K(),description:Ec(K()),required:Ec(Js())}),xv=sc({...b_.shape,...y_.shape,description:Ec(K()),arguments:Ec(ac(bv)),_meta:Ec(cc({}))}),Sv=L_.extend({method:Sc(`prompts/list`)}),Cv=R_.extend({prompts:ac(xv)}),wv=Qg.extend({name:K(),arguments:vc(K(),K()).optional()}),Tv=t_.extend({method:Sc(`prompts/get`),params:wv}),Ev=sc({type:Sc(`text`),text:K(),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),Dv=sc({type:Sc(`image`),data:$_,mimeType:K(),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),Ov=sc({type:Sc(`audio`),data:$_,mimeType:K(),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),kv=sc({type:Sc(`tool_use`),name:K(),id:K(),input:vc(K(),tc()),_meta:vc(K(),tc()).optional()}),Av=sc({type:Sc(`resource`),resource:uc([Q_,ev]),annotations:nv.optional(),_meta:vc(K(),tc()).optional()}),jv=uc([Ev,Dv,Ov,rv.extend({type:Sc(`resource_link`)}),Av]),Mv=sc({role:tv,content:jv}),Nv=i_.extend({description:K().optional(),messages:ac(Mv)}),Pv=r_.extend({method:Sc(`notifications/prompts/list_changed`),params:n_.optional()}),Fv=sc({title:K().optional(),readOnlyHint:Js().optional(),destructiveHint:Js().optional(),idempotentHint:Js().optional(),openWorldHint:Js().optional()}),Iv=sc({taskSupport:bc([`required`,`optional`,`forbidden`]).optional()}),Lv=sc({...b_.shape,...y_.shape,description:K().optional(),inputSchema:sc({type:Sc(`object`),properties:vc(K(),Kg).optional(),required:ac(K()).optional()}).catchall(tc()),outputSchema:sc({type:Sc(`object`),properties:vc(K(),Kg).optional(),required:ac(K()).optional()}).catchall(tc()).optional(),annotations:Fv.optional(),execution:Iv.optional(),_meta:vc(K(),tc()).optional()}),Rv=L_.extend({method:Sc(`tools/list`)}),zv=R_.extend({tools:ac(Lv)}),Bv=i_.extend({content:ac(jv).default([]),structuredContent:vc(K(),tc()).optional(),isError:Js().optional()});Bv.or(i_.extend({toolResult:tc()}));const Vv=$g.extend({name:K(),arguments:vc(K(),tc()).optional()}),Hv=t_.extend({method:Sc(`tools/call`),params:Vv}),Uv=r_.extend({method:Sc(`notifications/tools/list_changed`),params:n_.optional()}),Wv=sc({autoRefresh:Js().default(!0),debounceMs:Ws().int().nonnegative().default(300)}),Gv=bc([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Kv=Qg.extend({level:Gv}),qv=t_.extend({method:Sc(`logging/setLevel`),params:Kv}),Jv=n_.extend({level:Gv,logger:K().optional(),data:tc()}),Yv=r_.extend({method:Sc(`notifications/message`),params:Jv}),Xv=sc({hints:ac(sc({name:K().optional()})).optional(),costPriority:Ws().min(0).max(1).optional(),speedPriority:Ws().min(0).max(1).optional(),intelligencePriority:Ws().min(0).max(1).optional()}),Zv=sc({mode:bc([`auto`,`required`,`none`]).optional()}),Qv=sc({type:Sc(`tool_result`),toolUseId:K().describe(`The unique identifier for the corresponding tool call.`),content:ac(jv).default([]),structuredContent:sc({}).loose().optional(),isError:Js().optional(),_meta:vc(K(),tc()).optional()}),$v=fc(`type`,[Ev,Dv,Ov]),ey=fc(`type`,[Ev,Dv,Ov,kv,Qv]),ty=sc({role:tv,content:uc([ey,ac(ey)]),_meta:vc(K(),tc()).optional()}),ny=$g.extend({messages:ac(ty),modelPreferences:Xv.optional(),systemPrompt:K().optional(),includeContext:bc([`none`,`thisServer`,`allServers`]).optional(),temperature:Ws().optional(),maxTokens:Ws().int(),stopSequences:ac(K()).optional(),metadata:Kg.optional(),tools:ac(Lv).optional(),toolChoice:Zv.optional()}),ry=t_.extend({method:Sc(`sampling/createMessage`),params:ny}),iy=i_.extend({model:K(),stopReason:Ec(bc([`endTurn`,`stopSequence`,`maxTokens`]).or(K())),role:tv,content:$v}),ay=i_.extend({model:K(),stopReason:Ec(bc([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(K())),role:tv,content:uc([ey,ac(ey)])}),oy=sc({type:Sc(`boolean`),title:K().optional(),description:K().optional(),default:Js().optional()}),sy=sc({type:Sc(`string`),title:K().optional(),description:K().optional(),minLength:Ws().optional(),maxLength:Ws().optional(),format:bc([`email`,`uri`,`date`,`date-time`]).optional(),default:K().optional()}),cy=sc({type:bc([`number`,`integer`]),title:K().optional(),description:K().optional(),minimum:Ws().optional(),maximum:Ws().optional(),default:Ws().optional()}),ly=sc({type:Sc(`string`),title:K().optional(),description:K().optional(),enum:ac(K()),default:K().optional()}),uy=sc({type:Sc(`string`),title:K().optional(),description:K().optional(),oneOf:ac(sc({const:K(),title:K()})),default:K().optional()}),dy=uc([uc([sc({type:Sc(`string`),title:K().optional(),description:K().optional(),enum:ac(K()),enumNames:ac(K()).optional(),default:K().optional()}),uc([ly,uy]),uc([sc({type:Sc(`array`),title:K().optional(),description:K().optional(),minItems:Ws().optional(),maxItems:Ws().optional(),items:sc({type:Sc(`string`),enum:ac(K())}),default:ac(K()).optional()}),sc({type:Sc(`array`),title:K().optional(),description:K().optional(),minItems:Ws().optional(),maxItems:Ws().optional(),items:sc({anyOf:ac(sc({const:K(),title:K()}))}),default:ac(K()).optional()})])]),oy,sy,cy]),fy=uc([$g.extend({mode:Sc(`form`).optional(),message:K(),requestedSchema:sc({type:Sc(`object`),properties:vc(K(),dy),required:ac(K()).optional()})}),$g.extend({mode:Sc(`url`),message:K(),elicitationId:K(),url:K().url()})]),py=t_.extend({method:Sc(`elicitation/create`),params:fy}),my=n_.extend({elicitationId:K()}),hy=r_.extend({method:Sc(`notifications/elicitation/complete`),params:my}),gy=i_.extend({action:bc([`accept`,`decline`,`cancel`]),content:qc(e=>e===null?void 0:e,vc(K(),uc([K(),Ws(),Js(),ac(K())])).optional())}),_y=sc({type:Sc(`ref/resource`),uri:K()}),vy=sc({type:Sc(`ref/prompt`),name:K()}),yy=Qg.extend({ref:uc([vy,_y]),argument:sc({name:K(),value:K()}),context:sc({arguments:vc(K(),K()).optional()}).optional()}),by=t_.extend({method:Sc(`completion/complete`),params:yy}),xy=i_.extend({completion:cc({values:ac(K()).max(100),total:Ec(Ws().int()),hasMore:Ec(Js())})}),Sy=sc({uri:K().startsWith(`file://`),name:K().optional(),_meta:vc(K(),tc()).optional()}),Cy=t_.extend({method:Sc(`roots/list`),params:Qg.optional()}),wy=i_.extend({roots:ac(Sy)}),Ty=r_.extend({method:Sc(`notifications/roots/list_changed`),params:n_.optional()});uc([M_,D_,by,qv,Tv,Sv,av,sv,dv,hv,_v,Hv,Rv,W_,K_,q_,Y_]),uc([v_,F_,A_,Ty,U_]),uc([g_,iy,ay,gy,wy,G_,J_,V_]),uc([M_,ry,py,Cy,W_,K_,q_,Y_]),uc([v_,F_,Yv,yv,pv,Uv,Pv,U_,hy]),uc([g_,k_,xy,Nv,Cv,ov,cv,fv,Bv,zv,G_,J_,V_]);var Ey=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===f_.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Dy(e.elicitations,n)}return new e(t,n,r)}},Dy=class extends Ey{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(f_.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};const Oy=Ds().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Jc.custom,message:`URL must be parseable`,fatal:!0}),ze}).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`}),ky=cc({resource:K().url(),authorization_servers:ac(Oy).optional(),jwks_uri:K().url().optional(),scopes_supported:ac(K()).optional(),bearer_methods_supported:ac(K()).optional(),resource_signing_alg_values_supported:ac(K()).optional(),resource_name:K().optional(),resource_documentation:K().optional(),resource_policy_uri:K().url().optional(),resource_tos_uri:K().url().optional(),tls_client_certificate_bound_access_tokens:Js().optional(),authorization_details_types_supported:ac(K()).optional(),dpop_signing_alg_values_supported:ac(K()).optional(),dpop_bound_access_tokens_required:Js().optional()}),Ay=cc({issuer:K(),authorization_endpoint:Oy,token_endpoint:Oy,registration_endpoint:Oy.optional(),scopes_supported:ac(K()).optional(),response_types_supported:ac(K()),response_modes_supported:ac(K()).optional(),grant_types_supported:ac(K()).optional(),token_endpoint_auth_methods_supported:ac(K()).optional(),token_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),service_documentation:Oy.optional(),revocation_endpoint:Oy.optional(),revocation_endpoint_auth_methods_supported:ac(K()).optional(),revocation_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),introspection_endpoint:K().optional(),introspection_endpoint_auth_methods_supported:ac(K()).optional(),introspection_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),code_challenge_methods_supported:ac(K()).optional(),client_id_metadata_document_supported:Js().optional()}),jy=sc({...cc({issuer:K(),authorization_endpoint:Oy,token_endpoint:Oy,userinfo_endpoint:Oy.optional(),jwks_uri:Oy,registration_endpoint:Oy.optional(),scopes_supported:ac(K()).optional(),response_types_supported:ac(K()),response_modes_supported:ac(K()).optional(),grant_types_supported:ac(K()).optional(),acr_values_supported:ac(K()).optional(),subject_types_supported:ac(K()),id_token_signing_alg_values_supported:ac(K()),id_token_encryption_alg_values_supported:ac(K()).optional(),id_token_encryption_enc_values_supported:ac(K()).optional(),userinfo_signing_alg_values_supported:ac(K()).optional(),userinfo_encryption_alg_values_supported:ac(K()).optional(),userinfo_encryption_enc_values_supported:ac(K()).optional(),request_object_signing_alg_values_supported:ac(K()).optional(),request_object_encryption_alg_values_supported:ac(K()).optional(),request_object_encryption_enc_values_supported:ac(K()).optional(),token_endpoint_auth_methods_supported:ac(K()).optional(),token_endpoint_auth_signing_alg_values_supported:ac(K()).optional(),display_values_supported:ac(K()).optional(),claim_types_supported:ac(K()).optional(),claims_supported:ac(K()).optional(),service_documentation:K().optional(),claims_locales_supported:ac(K()).optional(),ui_locales_supported:ac(K()).optional(),claims_parameter_supported:Js().optional(),request_parameter_supported:Js().optional(),request_uri_parameter_supported:Js().optional(),require_request_uri_registration:Js().optional(),op_policy_uri:Oy.optional(),op_tos_uri:Oy.optional(),client_id_metadata_document_supported:Js().optional()}).shape,...Ay.pick({code_challenge_methods_supported:!0}).shape}),My=sc({access_token:K(),id_token:K().optional(),token_type:K(),expires_in:Zc().optional(),scope:K().optional(),refresh_token:K().optional()}).strip(),Ny=sc({error:K(),error_description:K().optional(),error_uri:K().optional()}),Py=Oy.optional().or(Sc(``).transform(()=>void 0)),Fy=sc({redirect_uris:ac(Oy),token_endpoint_auth_method:K().optional(),grant_types:ac(K()).optional(),response_types:ac(K()).optional(),client_name:K().optional(),client_uri:Oy.optional(),logo_uri:Py,scope:K().optional(),contacts:ac(K()).optional(),tos_uri:Py,policy_uri:K().optional(),jwks_uri:Oy.optional(),jwks:$s().optional(),software_id:K().optional(),software_version:K().optional(),software_statement:K().optional()}).strip(),Iy=sc({client_id:K(),client_secret:K().optional(),client_id_issued_at:Ws().optional(),client_secret_expires_at:Ws().optional()}).strip(),Ly=Fy.merge(Iy);sc({error:K(),error_description:K().optional()}).strip(),sc({token:K(),token_type_hint:K().optional()}).strip();function Ry(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function zy({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var By=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Vy=class extends By{};Vy.errorCode=`invalid_request`;var Hy=class extends By{};Hy.errorCode=`invalid_client`;var Uy=class extends By{};Uy.errorCode=`invalid_grant`;var Wy=class extends By{};Wy.errorCode=`unauthorized_client`;var Gy=class extends By{};Gy.errorCode=`unsupported_grant_type`;var Ky=class extends By{};Ky.errorCode=`invalid_scope`;var qy=class extends By{};qy.errorCode=`access_denied`;var Jy=class extends By{};Jy.errorCode=`server_error`;var Yy=class extends By{};Yy.errorCode=`temporarily_unavailable`;var Xy=class extends By{};Xy.errorCode=`unsupported_response_type`;var Zy=class extends By{};Zy.errorCode=`unsupported_token_type`;var Qy=class extends By{};Qy.errorCode=`invalid_token`;var $y=class extends By{};$y.errorCode=`method_not_allowed`;var eb=class extends By{};eb.errorCode=`too_many_requests`;var tb=class extends By{};tb.errorCode=`invalid_client_metadata`;var nb=class extends By{};nb.errorCode=`insufficient_scope`;var rb=class extends By{};rb.errorCode=`invalid_target`;const ib={[Vy.errorCode]:Vy,[Hy.errorCode]:Hy,[Uy.errorCode]:Uy,[Wy.errorCode]:Wy,[Gy.errorCode]:Gy,[Ky.errorCode]:Ky,[qy.errorCode]:qy,[Jy.errorCode]:Jy,[Yy.errorCode]:Yy,[Xy.errorCode]:Xy,[Zy.errorCode]:Zy,[Qy.errorCode]:Qy,[$y.errorCode]:$y,[eb.errorCode]:eb,[tb.errorCode]:tb,[nb.errorCode]:nb,[rb.errorCode]:rb};var ab=class extends Error{constructor(e){super(e??`Unauthorized`)}};function ob(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}const sb=`code`,cb=`S256`;function lb(e,t){let n=e.client_secret!==void 0;return t.length===0?n?`client_secret_post`:`none`:`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&ob(e.token_endpoint_auth_method)&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function ub(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:db(i,a,n);return;case`client_secret_post`:fb(i,a,r);return;case`none`:pb(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function db(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function fb(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function pb(e,t){t.set(`client_id`,e)}async function mb(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=Ny.parse(JSON.parse(n));return new(ib[e]||Jy)(t||``,r)}catch(e){return new Jy(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function hb(e,t){try{return await gb(e,t)}catch(n){if(n instanceof Hy||n instanceof Wy)return await e.invalidateCredentials?.(`all`),await gb(e,t);if(n instanceof Uy)return await e.invalidateCredentials?.(`tokens`),await gb(e,t);throw n}}async function gb(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await Ob(c,{fetchFn:a}),!s)try{s=await xb(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await kb(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await vb(t,e,s),f=await Promise.resolve(e.clientInformation());if(!f){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!_b(r))throw new tb(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)f={client_id:r},await e.saveClientInformation?.(f);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await Fb(c,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:a});await e.saveClientInformation(t),f=t}}let p=!e.redirectUrl;if(n!==void 0||p){let t=await Pb(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let m=await e.tokens();if(m?.refresh_token)try{let t=await Nb(c,{metadata:l,clientInformation:f,refreshToken:m.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof By)||e instanceof Jy))throw e}let h=e.state?await e.state():void 0,{authorizationUrl:g,codeVerifier:_}=await Ab(c,{metadata:l,clientInformation:f,state:h,redirectUrl:e.redirectUrl,scope:r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,resource:d});return await e.saveCodeVerifier(_),await e.redirectToAuthorization(g),`REDIRECT`}function _b(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function vb(e,t,n){let r=Ry(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!zy({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function yb(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=bb(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=bb(e,`scope`)||void 0,s=bb(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function bb(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function xb(e,t,n=fetch){let r=await Eb(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return ky.parse(await r.json())}async function Sb(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Sb(e,void 0,n):void 0;throw r}}function Cb(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function wb(e,t,n=fetch){return await Sb(e,{"MCP-Protocol-Version":t},n)}function Tb(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function Eb(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Cb(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await wb(o,a,n);return!r?.metadataUrl&&Tb(s,i.pathname)&&(s=await wb(new URL(`/.well-known/${t}`,i),a,n)),s}function Db(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function Ob(e,{fetchFn:t=fetch,protocolVersion:n=Ug}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=Db(e);for(let{url:e,type:n}of i){let i=await Sb(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?Ay.parse(await i.json()):jy.parse(await i.json())}}}async function kb(e,t){let n,r;try{n=await xb(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await Ob(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function Ab(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(sb))throw Error(`Incompatible auth server: does not support response type ${sb}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(cb))throw Error(`Incompatible auth server: does not support code challenge method ${cb}`)}else s=new URL(`/authorize`,e);let c=await Hg(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,sb),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,cb),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function jb(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function Mb(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&ub(lb(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await mb(l);return My.parse(await l.json())}async function Nb(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await Mb(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function Pb(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=jb(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return Mb(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function Fb(e,{metadata:t,clientMetadata:n,fetchFn:r}){let i;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);i=new URL(t.registration_endpoint)}else i=new URL(`/register`,e);let a=await(r??fetch)(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw await mb(a);return Ly.parse(await a.json())}function Ib(e){return!!e._zod}function Lb(e,t){return Ib(e)?zt(e,t):e.safeParse(t)}function Rb(e){if(!e)return;let t;if(t=Ib(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function zb(e){if(Ib(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function Bb(e){return e===`completed`||e===`failed`||e===`cancelled`}function Vb(e){let t=Rb(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=zb(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Hb(e,t){let n=Lb(e,t);if(!n.success)throw n.error;return n.data}var Ub=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(v_,e=>{this._oncancel(e)}),this.setNotificationHandler(F_,e=>{this._onprogress(e)}),this.setRequestHandler(M_,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(W_,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new Ey(f_.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(K_,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new Ey(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new Ey(f_.InvalidParams,`Task not found: ${r}`);if(!Bb(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(Bb(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[Gg]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(q_,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new Ey(f_.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Y_,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new Ey(f_.InvalidParams,`Task not found: ${e.params.taskId}`);if(Bb(n.status))throw new Ey(f_.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Ey(f_.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof Ey?e:new Ey(f_.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&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),Ey.fromError(f_.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){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),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),d_(e)||m_(e)?this._onresponse(e):s_(e)?this._onrequest(e,t):l_(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=Ey.fromError(f_.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[Gg]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:f_.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=e_(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new Ey(f_.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:f_.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.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._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),d_(e)?n(e):n(new Ey(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(d_(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),d_(e)?r(e):r(Ey.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof Ey?e:new Ey(f_.InternalError,String(e))}}return}let i;try{let r=await this.request(e,V_,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new Ey(f_.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Bb(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new Ey(f_.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new Ey(f_.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof Ey?e:new Ey(f_.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Gg]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof Ey?e:new Ey(f_.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Lb(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(Ey.fromError(f_.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},G_,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},J_,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},X_,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[Gg]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[Gg]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[Gg]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Vb(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Hb(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Vb(e);this._notificationHandlers.set(n,n=>{let r=Hb(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&s_(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new Ey(f_.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new Ey(f_.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new Ey(f_.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new Ey(f_.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=U_.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Bb(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new Ey(f_.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Bb(a.status))throw new Ey(f_.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=U_.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Bb(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function Wb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gb(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];Wb(a)&&Wb(i)?n[r]={...a,...i}:n[r]=i}return n}var Kb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),qb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Kb();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Jb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=Kb(),n=qb();var r=Kb();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=qb();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
73122
73122
|
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${te(e)}`}e.not=j;let M=F(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;let P=F(e.operators.OR);function ee(...e){return e.reduce(P)}e.or=ee;function F(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${te(n)} ${e} ${te(r)}`}function te(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Yb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=Jb(),n=Kb();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),Xb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Jb();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),Zb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=Jb(),n=Yb(),r=Xb();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Qb=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Zb(),n=Jb(),r=Xb(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),$b=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),ex=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),tx=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=$b(),n=ex(),r=Zb(),i=Jb(),a=Yb();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
73123
73123
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
73124
73124
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
@@ -73260,7 +73260,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
73260
73260
|
`:`
|
|
73261
73261
|
`)+n,i=r+1,r=e.indexOf(`
|
|
73262
73262
|
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:KO,stderr:qO}=UO,JO=Symbol(`GENERATOR`),YO=Symbol(`STYLER`),XO=Symbol(`IS_EMPTY`),ZO=[`ansi`,`ansi`,`ansi256`,`ansi16m`],QO=Object.create(null),$O=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=KO?KO.level:0;e.level=t.level===void 0?n:t.level},ek=e=>{let t=(...e)=>e.join(` `);return $O(t,e),Object.setPrototypeOf(t,tk.prototype),t};function tk(e){return ek(e)}Object.setPrototypeOf(tk.prototype,Function.prototype);for(let[e,t]of Object.entries(FO))QO[e]={get(){let n=ak(this,ik(t.open,t.close,this[YO]),this[XO]);return Object.defineProperty(this,e,{value:n}),n}};QO.visible={get(){let e=ak(this,this[YO],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const nk=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?FO[n].ansi16m(...r):t===`ansi256`?FO[n].ansi256(FO.rgbToAnsi256(...r)):FO[n].ansi(FO.rgbToAnsi(...r)):e===`hex`?nk(`rgb`,t,n,...FO.hexToRgb(...r)):FO[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){QO[e]={get(){let{level:t}=this;return function(...n){let r=ik(nk(e,ZO[t],`color`,...n),FO.color.close,this[YO]);return ak(this,r,this[XO])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);QO[t]={get(){let{level:t}=this;return function(...n){let r=ik(nk(e,ZO[t],`bgColor`,...n),FO.bgColor.close,this[YO]);return ak(this,r,this[XO])}}}}const rk=Object.defineProperties(()=>{},{...QO,level:{enumerable:!0,get(){return this[JO].level},set(e){this[JO].level=e}}}),ik=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},ak=(e,t,n)=>{let r=(...e)=>ok(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,rk),r[JO]=e,r[YO]=t,r[XO]=n,r},ok=(e,t)=>{if(e.level<=0||!t)return e[XO]?``:t;let n=e[YO];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=WO(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
73263
|
-
`);return a!==-1&&(t=GO(t,i,r,a)),r+t+i};Object.defineProperties(tk.prototype,QO);const sk=tk();tk({level:qO?qO.level:0});var ck=U(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.3.
|
|
73263
|
+
`);return a!==-1&&(t=GO(t,i,r,a)),r+t+i};Object.defineProperties(tk.prototype,QO);const sk=tk();tk({level:qO?qO.level:0});var ck=U(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.3.2`,private:!0,bin:{abacusai:`dist/index.mjs`},files:[`dist`,`LICENSE.txt`],type:`module`,scripts:{"prepare-publish":`bun ./scripts/prepare-publish.ts`,build:`tsdown`,"check-types":`tsgo -b --noEmit`,test:`FORCE_COLOR=1 vitest run`,"test:watch":`FORCE_COLOR=1 vitest`,"test:ui":`FORCE_COLOR=1 vitest --ui`,"test:coverage":`FORCE_COLOR=1 vitest run --coverage`},dependencies:{"@clack/prompts":`^0.11.0`,"@codellm/agent":`workspace:*`,"@codellm/api":`workspace:*`,"@codellm/auth":`workspace:*`,"@codellm/comms":`workspace:*`,"@codellm/jar":`workspace:*`,"@codellm/product":`workspace:*`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`^10.42.0`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`^5.90.19`,"@vscode/ripgrep":`^1.17.0`,"ansi-styles":`^6.2.3`,"beautiful-mermaid":`^1.1.3`,chalk:`^5.6.2`,"cli-boxes":`^4.0.1`,"cli-highlight":`^2.1.11`,conf:`^15.0.2`,diff:`^8.0.3`,fzf:`^0.5.2`,"gradient-string":`^3.0.0`,immer:`^11.1.4`,"isomorphic-git":`^1.36.1`,marked:`^17.0.4`,"patchright-core":`^1.58.2`,react:`^19.2.3`,"react-compiler-runtime":`^1.0.0`,remend:`^1.2.2`,semver:`^7.7.4`,"shell-history":`^2.0.1`,"string-width":`^8.1.0`,"strip-ansi":`^7.2.0`,trash:`^9.0.0`,zod:`catalog:`},devDependencies:{"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`^19.2.9`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:`,"@vitejs/plugin-react":`^5.1.2`,"@vitest/coverage-v8":`^4.0.18`,"@vitest/ui":`^4.0.18`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`^1.0.0`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"node-pty":`^1.1.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`^0.21.0`,vite:`catalog:`,vitest:`^4.0.18`},engines:{node:`>=18`}}})),lk=Ee(ck(),1);let uk=null;function dk(e){let t=(0,cO.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function fk(){let e=process.env.npm_command;if(e===`exec`||e===`dlx`)return!0;let t=process.argv[1]??``;return!!/_npx[/\\]|[/\\]dlx[/\\]|\.cache[/\\]/.test(t)}function pk(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function mk(){let e=`${Le.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let n=process.argv[1]??``;try{n=x(n)}catch{}if(/[/\\]\.abacusai[/\\]bin[/\\]/.test(n))return!1;let r=/[/\\]node_modules[/\\]/.test(n)||/[/\\]\.npm[/\\]/.test(n)||/[/\\]\.bun[/\\]/.test(n),i=!!process.env.npm_config_user_agent;return!r&&!i}function hk(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function gk(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}let t=process.argv[1]??``;return t.includes(`yarn`)?`yarn`:t.includes(`pnpm`)?`pnpm`:t.includes(`bun`)?`bun`:`npm`}async function _k(e){let t=Date.now();if(uk&&t-uk.timestamp<6e4)return uk.tags;let n=await fetch(`https://registry.npmjs.org/${e}`,{signal:AbortSignal.timeout(1e4),headers:{accept:`application/json`}});if(!n.ok)throw Error(`Registry returned ${n.status}`);let r=(await n.json())[`dist-tags`]??{};return uk={tags:r,timestamp:t},r}async function vk(e,t,n,r){let i=t??dk(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json();return{currentVersion:e,latestVersion:c.result.version,tag:c.result.channel,packageManager:gk(),isEphemeral:fk(),downloadUrl:c.result.url}}async function yk(e){let t=dk(e),n=gk(),r=fk(),i=(await _k(Re.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function bk(e,t,n){if(pk())try{return await vk(e,t,hk(),n)}catch{return null}return await yk(e)}function xk(){return`${Le.binName} upgrade`}function Sk(e){let t=`${Re.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function Ck(e){try{return d(Sk(e),{stdio:`pipe`}),!0}catch{return!1}}function wk(e){try{return{ok:!0,output:d(Sk(e),{stdio:`pipe`,encoding:`utf-8`}).trim()}}catch(e){return{ok:!1,output:e instanceof Error&&`stderr`in e?String(e.stderr).trim():e instanceof Error?e.message:`Unknown error`}}}async function Tk(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let n=w.join(t.tmpdir(),`abacusai-update-${Date.now()}`),r=w.join(t.homedir(),`.${Le.configDirName}`,`bin`),i=process.platform===`win32`,a=i?`${Le.binName}.exe`:Le.binName;try{await L.mkdir(n,{recursive:!0});let t=w.join(n,i?`update.zip`:`update.tar.gz`),o=await fetch(e.downloadUrl);if(!o.ok)throw Error(`Download failed: ${o.status}`);let s=Buffer.from(await o.arrayBuffer());await L.writeFile(t,s),d(i?`powershell -Command "Expand-Archive -Path '${t}' -DestinationPath '${n}' -Force"`:`tar -xzf "${t}" -C "${n}"`,{stdio:`pipe`});let c=w.join(n,a),l=w.join(r,a);return await L.copyFile(c,l),i||await L.chmod(l,493),{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await L.rm(n,{recursive:!0,force:!0}).catch(()=>{})}}function Ek(e,t){let n=e=>{let n=e.toLowerCase();if(n===t)return 1e3;if(n.startsWith(t))return 900;let r=0,i=-1;for(let e of t){let t=n.indexOf(e,i+1);if(t===-1)return 0;r+=100-(t-i),i=t}return r+=Math.max(0,50-n.length),r},r=null,i=0;for(let t of e){let e=Math.max(n(t.name??``),n(t.llmName));e>i&&(i=e,r=t.llmName)}return i>=100?r:null}async function Dk(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
73264
73264
|
`),process.exit(1)),t?Ek(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const Ok=T.join(i(),Le.configDirName,Le.logsDirName),kk=T.join(Ok,`cli.log`);let Ak=!1;function jk(){if(!Ak)try{v(Ok)||y(Ok,{recursive:!0}),Ak=!0}catch{}}function Mk(e){return e.length===0?``:` `+e.map(e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function Nk(e,t,n){jk();let r=`[${new Date().toISOString()}] [${e}] ${t instanceof Error?`${t.message}${t.stack?`
|
|
73265
73265
|
`+t.stack:``}`:String(t)}${Mk(n)}\n`;try{g(kk,r)}catch{}}const Pk={error(e,...t){Nk(`ERROR`,e,t)},warn(e,...t){Nk(`WARN`,e,t)},info(e,...t){Nk(`INFO`,e,t)},debug(...e){Nk(`DEBUG`,e[0]??``,e.slice(1))},trace(e,...t){Nk(`TRACE`,e,t)}},Fk=new Set,Ik=new Set,Lk=new Set;let Rk=!1,zk=!1,Bk=null,Vk;async function Hk(e){let t=e.map(e=>new Promise(t=>{let n=`writableLength`in e?e.writableLength:0;if((`bufferSize`in e?e.bufferSize:n)===0){t();return}let r=e.write.bind(e),i=!1,a=()=>{let n=`writableLength`in e?e.writableLength:0;(`bufferSize`in e?e.bufferSize:n)===0&&!i&&(i=!0,e.write=r,t())};e.once(`drain`,a),e.write(``,`utf-8`,()=>{a()}),e.write=function(){return!1}}));await Promise.all(t)}async function Uk(e,t,n,r){if(Rk)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:Fk.size,syncCallbacks:Ik.size}),Rk=!0,Fk.size>0&&t&&console.error([`SYNCHRONOUS TERMINATION NOTICE:`,`When explicitly exiting the process via process.exit or via a parent process,`,`asynchronous tasks in your exitHooks will not run. Either remove these tasks,`,`use gracefulExit() instead of process.exit(), or ensure your parent process`,`sends a SIGINT to the process running this code.`].join(` `));let i=0;n>0?i=128+n:Vk===void 0?(typeof B.exitCode==`number`||typeof B.exitCode==`string`)&&(i=Number(B.exitCode)):i=Vk;let a=(t=!1)=>{(t||e)&&(Bk?Bk.call(B,i):B.exit(i))};for(let e of Ik)try{e(i)}catch(e){console.error(`Error in synchronous exit hook:`,e)}if(t){a();return}let o=[],s=0;for(let[e,t]of Fk)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{console.error(`Error in asynchronous exit hook:`,e)}));let c=Array.from(Lk);c.length>0&&o.push(Hk(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),console.error(`Error during exit cleanup:`,e),a(!0)}}function Wk(){zk||(zk=!0,B.once(`beforeExit`,()=>{Uk(!0,!1,-128)}),B.once(`SIGINT`,()=>{Uk(!0,!1,2)}),B.once(`SIGTERM`,()=>{Uk(!0,!1,15)}),B.once(`exit`,()=>{Uk(!1,!0,0)}),B.on(`message`,e=>{e===`shutdown`&&Uk(!0,!0,-128)}),Bk||(Bk=B.exit.bind(B),B.exit=function(e){if(Vk===void 0&&(Vk=e??0),Fk.size===0&&Lk.size===0){if(Bk){Bk(e??0);return}B.exit(e??0)}Uk(!0,!1,-128).catch(e=>{console.error(`Error during exit:`,e),Bk?Bk(1):B.exit(1)})}))}function Gk(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(Rk)throw Error(`Cannot install exit hook while exit handlers are running`);t?.logger?.debug?.(`Registering exit hook`,{wait:t?.wait,hasStreams:t?.streams!==void 0}),Wk();let n=t?.wait??0,r=t?.streams??[B.stdout,B.stderr];if(n>0){let t=[e,n];Fk.add(t);for(let e of r)Lk.add(e);return()=>{Fk.delete(t);for(let e of r)Lk.delete(e)}}return Ik.add(e),()=>{Ik.delete(e)}}function Kk(e){e!==void 0&&(B.exitCode=e),Uk(!0,!1,-128)}function qk(e){process.stdout.write(JSON.stringify(e)+`
|
|
73266
73266
|
`)}function Jk(e){try{return JSON.parse(e)}catch{return null}}async function Yk({agentArgs:e}){let t=await EO.create(),n=new Ie(t,{error:(e,...t)=>Pk.error(e,...t),debug:(...e)=>Pk.debug(...e),warn:(e,...t)=>Pk.warn(e,...t)});if(!t.isAuthenticated())try{(await n.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|