@yukino.js/yukino 0.0.3 → 0.0.4

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{a as Ot,b as Dt}from"./chunk-YBUSZS75.js";import"./chunk-6GCU7CRK.js";import"./chunk-HLE7243Q.js";import{p as kt,q as vt,s as Nt,t as At,u as It,v as Mt,w as jt}from"./chunk-OAFPGTZY.js";import{a as Ct}from"./chunk-QG22QNQJ.js";import"./chunk-JFKC4VCA.js";import"./chunk-SAJCBGHL.js";import"./chunk-OFC2GD5K.js";import{v as Rt,w as yt,x as Tt}from"./chunk-7DLUKIPE.js";import"./chunk-RCXKUD3Y.js";import"./chunk-XO7ITAWR.js";import{k as Be,s as $e}from"./chunk-UPNNYP7M.js";import{D as K,g as s,h as xt,i as x,j as A,k as v,n as c,o as T,p as r,r as b,t as B,u as d,w as l}from"./chunk-GYBJR2RB.js";import{b as Et}from"./chunk-L2BWSPCF.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import{d as Se}from"./chunk-7MKA3SHV.js";var Os={};Se(Os,{runAcpStdio:()=>zt});import{Readable as Ha,Writable as Pa}from"stream";var h={initialize:"initialize",authenticate:"authenticate",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_load:"session/load",session_set_mode:"session/set_mode",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",logout:"logout",nes_start:"nes/start",nes_suggest:"nes/suggest",nes_accept:"nes/accept",nes_reject:"nes/reject",nes_close:"nes/close",document_did_open:"document/didOpen",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_save:"document/didSave",document_did_focus:"document/didFocus"},_={session_request_permission:"session/request_permission",session_update:"session/update",fs_write_text_file:"fs/write_text_file",fs_read_text_file:"fs/read_text_file",terminal_create:"terminal/create",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit",terminal_kill:"terminal/kill",mcp_connect:"mcp/connect",mcp_message:"mcp/message",mcp_disconnect:"mcp/disconnect",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},Je={cancel_request:"$/cancel_request"},Ve=1;var qt=Symbol("skippedItem");function o(t,e){return t.catch(e)}function O(t,e){let n=t.catch(e);return K.unknown().transform((i,a)=>i!==void 0?n.parse(i):(a.addIssue({code:"custom",message:"Required value is missing"}),K.NEVER))}function Ht(t,e){if(t===null||typeof t!="object"||Array.isArray(t))return;let n=t[e];return typeof n=="string"?n:void 0}function ae(t,e,n){return t.superRefine((i,a)=>{let u=Ht(i,e);u!==void 0&&n.includes(u)&&a.addIssue({code:"custom",path:[e],message:`${e} ${JSON.stringify(u)} is reserved by a known variant, but the value does not match that variant's schema`})})}function ce(t,e,n){return K.unknown().transform((i,a)=>{let u=t.safeParse(i);if(!u.success){for(let f of u.error.issues)a.addIssue({...f,input:i});return K.NEVER}let p=u.data,z=Ht(i,e);if(z!==void 0&&!n.includes(z)){let f=i;for(let[g,m]of Object.entries(f))g!=="__proto__"&&(Object.hasOwn(p,g)||(p[g]=m))}return p})}function S(t){return K.array(t.catch(qt)).transform(e=>e.filter(n=>n!==qt))}var $=b([x(),s()]).nullable(),E=s(),Ye=r({sessionId:E,path:s(),content:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Qe=r({sessionId:E,path:s(),line:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),limit:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ze=s(),Pt=b([l("read"),l("edit"),l("delete"),l("move"),l("search"),l("execute"),l("think"),l("fetch"),l("switch_mode"),l("other")]),Lt=b([l("pending"),l("in_progress"),l("completed"),l("failed")]),si=b([l("assistant"),l("user")]),de=r({audience:o(S(si).nullish(),()=>{}),lastModified:o(s().nullish(),()=>{}),priority:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ii=r({annotations:o(de.nullish(),()=>{}),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),oi=r({annotations:o(de.nullish(),()=>{}),data:s(),mimeType:s(),uri:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ri=r({annotations:o(de.nullish(),()=>{}),data:s(),mimeType:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ai=r({annotations:o(de.nullish(),()=>{}),description:o(s().nullish(),()=>{}),mimeType:o(s().nullish(),()=>{}),name:s(),size:o(x().nullish(),()=>{}),title:o(s().nullish(),()=>{}),uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ci=r({mimeType:o(s().nullish(),()=>{}),text:s(),uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),di=r({blob:s(),mimeType:o(s().nullish(),()=>{}),uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ui=b([ci,di]),li=r({annotations:o(de.nullish(),()=>{}),resource:ui,_meta:o(d(s(),c()).nullish(),()=>{})}),ue=b([ii.and(r({type:l("text")})),oi.and(r({type:l("image")})),ri.and(r({type:l("audio")})),ai.and(r({type:l("resource_link")})),li.and(r({type:l("resource")}))]),hi=r({content:ue,_meta:o(d(s(),c()).nullish(),()=>{})}),pi=r({path:s(),oldText:o(s().nullish(),()=>{}),newText:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),X=s(),fi=r({terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),Gt=b([hi.and(r({type:l("content")})),pi.and(r({type:l("diff")})),fi.and(r({type:l("terminal")}))]),Ut=r({path:s(),line:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ft=r({toolCallId:Ze,kind:o(Pt.nullish(),()=>{}),status:o(Lt.nullish(),()=>{}),title:o(s().nullish(),()=>{}),name:o(s().nullish(),()=>{}),content:o(S(Gt).nullish(),()=>{}),locations:o(S(Ut).nullish(),()=>{}),rawInput:o(c().optional(),()=>{}),rawOutput:o(c().optional(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Wt=s(),zi=b([l("allow_once"),l("allow_always"),l("reject_once"),l("reject_always")]),mi=r({optionId:Wt,name:s(),kind:zi,_meta:o(d(s(),c()).nullish(),()=>{})}),Xe=r({sessionId:E,toolCall:Ft,options:T(mi),_meta:o(d(s(),c()).nullish(),()=>{})}),Bt=r({name:s(),value:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),en=r({sessionId:E,command:s(),args:o(S(s()).optional(),()=>[]),env:o(S(Bt).optional(),()=>[]),cwd:o(s().nullish(),()=>{}),outputByteLimit:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),nn=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),tn=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),sn=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),on=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),le=r({sessionId:E,toolCallId:o(Ze.nullish(),()=>{})}),he=r({requestId:$}),gi=l("object"),bi=b([l("email"),l("uri"),l("date"),l("date-time")]),$t=r({const:s(),title:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),rn=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minLength:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:s().nullish(),format:bi.nullish(),default:o(s().nullish(),()=>{}),enum:T(s()).nullish(),oneOf:T($t).nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),an=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:x().nullish(),maximum:x().nullish(),default:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),cn=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:x().nullish(),maximum:x().nullish(),default:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),dn=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),default:o(v().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),un=r({enum:T(s()),_meta:o(d(s(),c()).nullish(),()=>{})}),Jt=r({anyOf:T($t),_meta:o(d(s(),c()).nullish(),()=>{})}),_i=ce(b([un.and(r({type:l("string")})),ae(r({type:s()}),"type",["string"]),Jt]),"type",["string"]),ln=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minItems:x().nullish(),maxItems:x().nullish(),items:_i,default:o(S(s()).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),wi=ce(b([rn.and(r({type:l("string")})),an.and(r({type:l("number")})),cn.and(r({type:l("integer")})),dn.and(r({type:l("boolean")})),ln.and(r({type:l("array")})),ae(r({type:s()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),Si=r({type:o(gi.optional().default("object"),()=>"object"),title:o(s().nullish(),()=>{}),properties:d(s(),wi).optional().default({}),required:T(s()).nullish(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),hn=B(b([le,he]),r({requestedSchema:Si})),Vt=s(),pn=B(b([le,he]),r({elicitationId:Vt,url:xt()})),fn=ce(B(b([hn.and(r({mode:l("form")})),pn.and(r({mode:l("url")})),ae(B(b([le,he]),r({mode:s()})),"mode",["form","url"])]),r({message:s(),_meta:o(d(s(),c()).nullish(),()=>{})})),"mode",["form","url"]),Kt=s(),Ei=r({serverId:Kt,_meta:o(d(s(),c()).nullish(),()=>{})}),Ee=s(),Yt=r({connectionId:Ee,method:s(),params:d(s(),c()).nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),xi=r({connectionId:Ee,_meta:o(d(s(),c()).nullish(),()=>{})}),Qt=c(),_c=r({id:$,method:s(),params:b([Ye,Qe,Xe,en,nn,tn,sn,on,fn,Ei,Yt,xi,Qt]).nullish()}),Zt=A().gte(0).lte(65535),Ri=r({image:o(v().optional().default(!1),()=>!1),audio:o(v().optional().default(!1),()=>!1),embeddedContext:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),yi=r({http:o(v().optional().default(!1),()=>!1),sse:o(v().optional().default(!1),()=>!1),acp:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),Ti=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ci=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ki=r({_meta:o(d(s(),c()).nullish(),()=>{})}),vi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ni=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ai=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ii=r({list:o(Ti.nullish(),()=>{}),delete:o(Ci.nullish(),()=>{}),additionalDirectories:o(ki.nullish(),()=>{}),fork:o(vi.nullish(),()=>{}),resume:o(Ni.nullish(),()=>{}),close:o(Ai.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Mi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ji=r({logout:o(Mi.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Oi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Di=r({_meta:o(d(s(),c()).nullish(),()=>{})}),qi=b([l("full"),l("incremental")]),Hi=r({syncKind:qi,_meta:o(d(s(),c()).nullish(),()=>{})}),Pi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Li=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Gi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ui=r({didOpen:o(Di.nullish(),()=>{}),didChange:o(Hi.nullish(),()=>{}),didClose:o(Pi.nullish(),()=>{}),didSave:o(Li.nullish(),()=>{}),didFocus:o(Gi.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Fi=r({document:o(Ui.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Wi=r({maxCount:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Bi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),$i=r({maxCount:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ji=r({maxCount:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Vi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ki=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Yi=r({recentFiles:o(Wi.nullish(),()=>{}),relatedSnippets:o(Bi.nullish(),()=>{}),editHistory:o($i.nullish(),()=>{}),userActions:o(Ji.nullish(),()=>{}),openFiles:o(Vi.nullish(),()=>{}),diagnostics:o(Ki.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Qi=r({events:o(Fi.nullish(),()=>{}),context:o(Yi.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Xt=b([l("utf-16"),l("utf-32"),l("utf-8")]),Zi=r({loadSession:o(v().optional().default(!1),()=>!1),promptCapabilities:o(Ri.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:o(yi.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:o(Ii.optional().default({}),()=>({})),auth:o(ji.optional().default({}),()=>({})),providers:o(Oi.nullish(),()=>{}),nes:o(Qi.nullish(),()=>{}),positionEncoding:o(Xt.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),zn=s(),Xi=r({id:zn,name:s(),description:o(s().nullish(),()=>{}),args:o(S(s()).optional(),()=>[]),env:o(d(s(),s()).optional(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),eo=r({id:zn,name:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),no=b([Xi.and(r({type:l("terminal")})),eo]),es=r({name:s(),title:o(s().nullish(),()=>{}),version:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),to=r({protocolVersion:Zt,agentCapabilities:o(Zi.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:o(S(no).optional().default([]),()=>[]),agentInfo:o(es.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),so=r({_meta:o(d(s(),c()).nullish(),()=>{})}),mn=s(),gn=b([l("anthropic"),l("openai"),l("azure"),l("vertex"),l("bedrock"),s()]),io=r({apiType:gn,baseUrl:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),oo=r({providerId:mn,supported:O(S(gn),()=>[]),required:v(),current:io.nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),ro=r({providers:T(oo),_meta:o(d(s(),c()).nullish(),()=>{})}),ao=r({_meta:o(d(s(),c()).nullish(),()=>{})}),co=r({_meta:o(d(s(),c()).nullish(),()=>{})}),uo=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xe=s(),lo=r({id:xe,name:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Re=r({currentModeId:xe,availableModes:O(S(lo),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ns=s(),ho=b([l("mode"),l("model"),l("model_config"),l("thought_level"),s()]),bn=s(),ts=r({value:bn,name:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),po=s(),fo=r({group:po,name:s(),options:O(S(ts),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),zo=b([T(ts),T(fo)]),mo=r({currentValue:bn,options:zo}),go=r({currentValue:v()}),ee=B(b([mo.and(r({type:l("select")})),go.and(r({type:l("boolean")}))]),r({id:ns,name:s(),description:o(s().nullish(),()=>{}),category:o(ho.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})})),bo=r({sessionId:E,modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),_o=r({modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),wo=r({sessionId:E,cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),So=r({sessions:O(S(wo),()=>[]),nextCursor:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Eo=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xo=r({sessionId:E,modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ro=r({modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),yo=r({_meta:o(d(s(),c()).nullish(),()=>{})}),To=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Co=r({configOptions:O(S(ee),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ko=b([l("end_turn"),l("max_tokens"),l("max_turn_requests"),l("refusal"),l("cancelled")]),vo=r({totalTokens:x(),inputTokens:x(),outputTokens:x(),thoughtTokens:o(x().nullish(),()=>{}),cachedReadTokens:o(x().nullish(),()=>{}),cachedWriteTokens:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),No=r({stopReason:ko,usage:o(vo.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ao=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),ne=s(),J=r({line:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),character:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),_meta:o(d(s(),c()).nullish(),()=>{})}),te=r({start:J,end:J,_meta:o(d(s(),c()).nullish(),()=>{})}),Io=r({range:te,newText:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Mo=r({id:ne,uri:s(),edits:T(Io),cursorPosition:o(J.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),jo=r({id:ne,uri:s(),position:J,_meta:o(d(s(),c()).nullish(),()=>{})}),Oo=r({id:ne,uri:s(),position:J,newName:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Do=r({id:ne,uri:s(),search:s(),replace:s(),isRegex:v().nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),qo=b([Mo.and(r({kind:l("edit")})),jo.and(r({kind:l("jump")})),Oo.and(r({kind:l("rename")})),Do.and(r({kind:l("searchAndReplace")}))]),Ho=r({suggestions:T(qo),_meta:o(d(s(),c()).nullish(),()=>{})}),Po=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ss=c(),is=c(),Lo=b([l(-32700),l(-32600),l(-32601),l(-32602),l(-32603),l(-32800),l(-32e3),l(-32002),A().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),os=r({code:Lo,message:s(),data:o(c().optional(),()=>{})}),wc=b([r({id:$,result:b([to,so,ro,ao,co,uo,bo,_o,So,Eo,xo,Ro,yo,To,Co,No,Ao,Ho,Po,ss,is])}),r({id:$,error:os})]),Go=s(),Ke=r({content:ue,messageId:o(Go.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Uo=r({toolCallId:Ze,title:s(),name:o(s().nullish(),()=>{}),kind:o(Pt.optional(),()=>{}),status:o(Lt.optional(),()=>{}),content:o(S(Gt).optional(),()=>[]),locations:o(S(Ut).optional(),()=>[]),rawInput:o(c().optional(),()=>{}),rawOutput:o(c().optional(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Fo=b([l("high"),l("medium"),l("low")]),Wo=b([l("pending"),l("in_progress"),l("completed")]),rs=r({content:s(),priority:Fo,status:Wo,_meta:o(d(s(),c()).nullish(),()=>{})}),Bo=r({entries:O(S(rs),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ye=s(),$o=r({planId:ye,entries:O(S(rs),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),Jo=r({planId:ye,uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Vo=r({planId:ye,content:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Ko=b([$o.and(r({type:l("items")})),Jo.and(r({type:l("file")})),Vo.and(r({type:l("markdown")}))]),Yo=r({plan:Ko,_meta:o(d(s(),c()).nullish(),()=>{})}),Qo=r({planId:ye,_meta:o(d(s(),c()).nullish(),()=>{})}),Zo=r({hint:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Xo=Zo,er=r({name:s(),description:s(),input:o(Xo.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),nr=r({availableCommands:O(S(er),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),tr=r({currentModeId:xe,_meta:o(d(s(),c()).nullish(),()=>{})}),sr=r({configOptions:O(S(ee),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ir=r({title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),or=r({amount:x(),currency:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),rr=r({used:x(),size:x(),cost:o(or.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ar=b([l("info"),l("warning"),l("error"),s()]),cr=r({severity:ar,title:s().min(1),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),as=s(),dr=b([l("in_progress"),l("completed"),l("failed"),l("cancelled"),s()]),ur=r({compactionId:as,status:dr,summary:o(S(ue).nullish(),()=>{}),error:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),lr=r({compactionId:as,content:ue,_meta:o(d(s(),c()).nullish(),()=>{})}),hr=b([Ke.and(r({sessionUpdate:l("user_message_chunk")})),Ke.and(r({sessionUpdate:l("agent_message_chunk")})),Ke.and(r({sessionUpdate:l("agent_thought_chunk")})),Uo.and(r({sessionUpdate:l("tool_call")})),Ft.and(r({sessionUpdate:l("tool_call_update")})),Bo.and(r({sessionUpdate:l("plan")})),Yo.and(r({sessionUpdate:l("plan_update")})),Qo.and(r({sessionUpdate:l("plan_removed")})),nr.and(r({sessionUpdate:l("available_commands_update")})),tr.and(r({sessionUpdate:l("current_mode_update")})),sr.and(r({sessionUpdate:l("config_option_update")})),ir.and(r({sessionUpdate:l("session_info_update")})),rr.and(r({sessionUpdate:l("usage_update")})),cr.and(r({sessionUpdate:l("notice")})),ur.and(r({sessionUpdate:l("compaction_update")})),lr.and(r({sessionUpdate:l("compaction_summary_chunk")}))]),Te=r({sessionId:E,update:hr,_meta:o(d(s(),c()).nullish(),()=>{})}),_n=r({elicitationId:Vt,_meta:o(d(s(),c()).nullish(),()=>{})}),cs=r({connectionId:Ee,method:s(),params:o(d(s(),c()).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ds=c(),Sc=r({method:s(),params:b([Te,_n,cs,ds]).nullish()}),pr=r({readTextFile:o(v().optional().default(!1),()=>!1),writeTextFile:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),fr=d(s(),c()),zr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),mr=r({boolean:o(zr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),gr=d(s(),c()),br=r({compaction:o(fr.nullish(),()=>{}),configOptions:o(mr.nullish(),()=>{}),notices:o(gr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),_r=r({_meta:o(d(s(),c()).nullish(),()=>{})}),wr=r({terminal:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),Sr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Er=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xr=r({form:o(Sr.nullish(),()=>{}),url:o(Er.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Rr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),yr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Tr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Cr=r({jump:o(Rr.nullish(),()=>{}),rename:o(yr.nullish(),()=>{}),searchAndReplace:o(Tr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),kr=r({fs:o(pr.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:o(v().optional().default(!1),()=>!1),session:o(br.nullish(),()=>{}),plan:o(_r.nullish(),()=>{}),auth:o(wr.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:o(xr.nullish(),()=>{}),nes:o(Cr.nullish(),()=>{}),positionEncodings:o(S(Xt).optional(),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),wn=r({protocolVersion:Zt,clientCapabilities:o(kr.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:o(es.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Sn=r({methodId:zn,_meta:o(d(s(),c()).nullish(),()=>{})}),En=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xn=r({providerId:mn,apiType:gn,baseUrl:s(),headers:d(s(),s()).optional(),_meta:o(d(s(),c()).nullish(),()=>{})}),Rn=r({providerId:mn,_meta:o(d(s(),c()).nullish(),()=>{})}),yn=r({_meta:o(d(s(),c()).nullish(),()=>{})}),us=r({name:s(),value:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),vr=r({name:s(),url:s(),headers:T(us),_meta:o(d(s(),c()).nullish(),()=>{})}),Nr=r({name:s(),url:s(),headers:T(us),_meta:o(d(s(),c()).nullish(),()=>{})}),Ar=r({name:s(),serverId:Kt,_meta:o(d(s(),c()).nullish(),()=>{})}),Ir=r({name:s(),command:s(),args:T(s()),env:T(Bt),_meta:o(d(s(),c()).nullish(),()=>{})}),Ce=b([vr.and(r({type:l("http")})),Nr.and(r({type:l("sse")})),Ar.and(r({type:l("acp")})),Ir]),Tn=r({cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),mcpServers:O(S(Ce),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),Cn=r({mcpServers:O(S(Ce),()=>[]),cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),kn=r({cwd:s().nullish(),cursor:s().nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),vn=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Nn=r({sessionId:E,cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),mcpServers:o(S(Ce).optional(),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),An=r({sessionId:E,cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),mcpServers:o(S(Ce).optional(),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),In=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Mn=r({sessionId:E,modeId:xe,_meta:o(d(s(),c()).nullish(),()=>{})}),jn=B(b([r({value:v(),type:l("boolean")}),r({value:bn})]),r({sessionId:E,configId:ns,_meta:o(d(s(),c()).nullish(),()=>{})})),On=r({sessionId:E,prompt:T(ue),_meta:o(d(s(),c()).nullish(),()=>{})}),Mr=r({uri:s(),name:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),jr=r({name:s(),owner:s(),remoteUrl:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Dn=r({workspaceUri:o(s().nullish(),()=>{}),workspaceFolders:T(Mr).nullish(),repository:o(jr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Or=b([l("automatic"),l("diagnostic"),l("manual")]),Dr=r({uri:s(),languageId:s(),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),qr=r({startLine:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),endLine:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Hr=r({uri:s(),excerpts:T(qr),_meta:o(d(s(),c()).nullish(),()=>{})}),Pr=r({uri:s(),diff:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Lr=r({action:s(),uri:s(),position:J,timestampMs:x(),_meta:o(d(s(),c()).nullish(),()=>{})}),Gr=r({uri:s(),languageId:s(),visibleRange:o(te.nullish(),()=>{}),lastFocusedMs:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ur=b([l("error"),l("warning"),l("information"),l("hint")]),Fr=r({uri:s(),range:te,severity:Ur,message:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Wr=r({recentFiles:T(Dr).nullish(),relatedSnippets:T(Hr).nullish(),editHistory:T(Pr).nullish(),userActions:T(Lr).nullish(),openFiles:T(Gr).nullish(),diagnostics:T(Fr).nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),qn=r({sessionId:E,uri:s(),version:x(),position:J,selection:te.nullish(),triggerKind:Or,context:Wr.nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),Hn=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Ec=r({id:$,method:s(),params:b([wn,Sn,En,xn,Rn,yn,Tn,Cn,kn,vn,Nn,An,In,Mn,jn,On,Dn,qn,Hn,Yt,Qt]).nullish()}),Br=r({_meta:o(d(s(),c()).nullish(),()=>{})}),$r=r({content:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Jr=r({optionId:Wt,_meta:o(d(s(),c()).nullish(),()=>{})}),Vr=b([r({outcome:l("cancelled")}),Jr.and(r({outcome:l("selected")}))]),Kr=r({outcome:Vr,_meta:o(d(s(),c()).nullish(),()=>{})}),Yr=r({terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),Qr=r({exitCode:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Zr=r({output:s(),truncated:v(),exitStatus:o(Qr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Xr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ea=r({exitCode:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),na=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ta=b([s(),x(),x(),v(),T(s())]),Pn=r({content:d(s(),ta).nullish()}),sa=ce(B(b([Pn.and(r({action:l("accept")})),r({action:l("decline")}),r({action:l("cancel")}),ae(r({action:s()}),"action",["accept","cancel","decline"])]),r({_meta:o(d(s(),c()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),ia=r({connectionId:Ee,_meta:o(d(s(),c()).nullish(),()=>{})}),oa=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xc=b([r({id:$,result:b([Br,$r,Kr,Yr,Zr,Xr,ea,na,sa,ia,oa,is,ss])}),r({id:$,error:os})]),Ln=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Gn=r({sessionId:E,uri:s(),languageId:s(),version:x(),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ra=r({range:te.nullish(),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Un=r({sessionId:E,uri:s(),version:x(),contentChanges:O(S(ra),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),Fn=r({sessionId:E,uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Wn=r({sessionId:E,uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Bn=r({sessionId:E,uri:s(),version:x(),position:J,visibleRange:te,_meta:o(d(s(),c()).nullish(),()=>{})}),$n=r({sessionId:E,id:ne,_meta:o(d(s(),c()).nullish(),()=>{})}),aa=b([l("rejected"),l("ignored"),l("replaced"),l("cancelled")]),Jn=r({sessionId:E,id:ne,reason:o(aa.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Rc=r({method:s(),params:b([Ln,Gn,Un,Fn,Wn,Bn,$n,Jn,cs,ds]).nullish()}),yc=r({requestId:$,_meta:o(d(s(),c()).nullish(),()=>{})});var hs="$/cancel_request";function P(t){return Qn(t)&&"id"in t&&typeof t.method=="string"&&Zn(t.id)}function V(t){if(!Qn(t)||"method"in t||!("id"in t)||!Zn(t.id))return!1;let e=Object.hasOwn(t,"result"),n=Object.hasOwn(t,"error");return e===n?!1:!n||ua(t.error)}function F(t){return Qn(t)&&!("id"in t)&&typeof t.method=="string"}function I(t){return typeof t=="object"&&t!==null}function Qn(t){return I(t)&&t.jsonrpc==="2.0"}function Zn(t){return t===null||typeof t=="string"||typeof t=="number"&&Number.isFinite(t)}function pe(t){return I(t)&&!("method"in t)&&("id"in t||"result"in t||"error"in t)}function ca(t){let e=!1,n=!1,i=!1,a=!1;for(let u of t)e||=P(u)||F(u),n||=V(u),I(u)&&(i||="method"in u,a||="result"in u||"error"in u);return e?!1:n?!0:a&&!i}function da(t){if(!(!I(t)||!Zn(t.requestId)))return t.requestId}function ua(t){return I(t)&&typeof t.code=="number"&&Number.isInteger(t.code)&&typeof t.message=="string"}var D={yes(){return{handled:!0}},no(t,e=!1){return{handled:!1,message:t,retry:e}}};function Y(t){let e=Promise.reject(t);return e.catch(()=>{}),e}function la(t){if(t instanceof Error||typeof t=="object"&&t!=null&&"message"in t&&typeof t.message=="string")return t.message}function ha(t){return typeof t=="object"&&t!==null&&"name"in t&&t.name==="ZodError"&&"issues"in t&&Array.isArray(t.issues)&&"format"in t&&typeof t.format=="function"}function ps(t){if(t instanceof w)return t.toResult();if(ha(t))return w.invalidParams(t.format()).toResult();let e=la(t);try{return w.internalError(e?JSON.parse(e):{}).toResult()}catch{return w.internalError({details:e}).toResult()}}function pa(t){return t instanceof w&&t.code===-32800?t:w.requestCancelled(t)}function fa(t,e){let n=za(t,e);return n?n.toResult():ps(t)}function za(t,e){if(!(!e.aborted||!ma(t)))return pa(e.reason)}function ma(t){if(typeof t!="object"||t===null)return!1;let e=t;return e.name==="AbortError"||e.code==="ABORT_ERR"}var Vn=class{id;sendResult;signal;finishRequest;didRespond=!1;constructor(e,n,i=new AbortController().signal,a){this.id=e,this.sendResult=n,this.signal=i,this.finishRequest=a}get responded(){return this.didRespond}respond(e){return this.respondWithResult({result:e??null})}respondWithError(e){let n=e instanceof w?e.toErrorResponse():e;return this.respondWithResult({error:n})}respondWithResult(e){return this.didRespond?Y(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(e).finally(()=>{this.finishRequest?.()}))}},ga=new WeakMap;var se=class{disposeHandler;active=!0;constructor(e){this.disposeHandler=e}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},Kn=class{connection;constructor(e){this.connection=e}sendRequest(e,n,i,a){return this.connection.sendRequest(e,n,i,a)}sendNotification(e,n){return this.connection.sendNotification(e,n)}sendBatch(e){return this.connection.sendBatch(e)}sendCancelRequest(e){return this.connection.sendCancelRequest(e)}addDynamicHandler(e){return this.connection.addDynamicHandler(e)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},ie=class{pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new Kn(this);receiveReader;allowBatches=!0;constructor(e,n,i,a){if(typeof e=="function"){let f=e,g=n,m=i;this.initialize(m,[...a?.handlers??[],this.legacyHandler(f,g)],a);return}let u=e,p=n,z=i;this.initialize(u,[...z?.handlers??[],...p],z)}static builder(){return new Yn}runUntil(e){let n=!1,i=Promise.resolve().then(()=>e(this.context)).finally(()=>{n=!0}),a=this.closed.then(()=>{if(n)return new Promise(()=>{});throw this.closedReason()});return Promise.race([i,a]).finally(()=>{n=!0,this.close()})}addDynamicHandler(e){if(this.dynamicHandlers.add(e),this.retryQueue.length>0)for(let n of this.retryQueue.splice(0))this.processIncomingMessage(n).catch(i=>this.close(i));return new se(()=>{this.dynamicHandlers.delete(e)})}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}getContext(){return this.context}sendRequest(e,n,i,a={}){if(this.abortController.signal.aborted)return Y(this.closedReason());let u=this.prepareRequest(e,n,i,a);return this.sendWireMessage(u.message).catch(()=>{}),a.cancellationSignal?.aborted&&u.cancel(),u.response}sendBatch(e){if(this.abortController.signal.aborted)return Y(this.closedReason());if(!this.allowBatches)return Y(new TypeError("JSON-RPC batches are not supported on this connection"));if(e.length===0)return Y(new TypeError("JSON-RPC batch must contain at least one entry"));let n=[],i=[],a=[];for(let f of e){if(f.kind==="notification"){n.push({jsonrpc:"2.0",method:f.method,params:f.params}),a.push(Promise.resolve(void 0));continue}let g=this.prepareRequest(f.method,f.params,f.mapResponse,f.options);n.push(g.message),a.push(g.response),i.push({signal:f.options?.cancellationSignal,cancel:g.cancel})}let u=n,p=this.sendWireMessage(u);for(let f of i)f.signal?.aborted&&f.cancel();let z=Promise.all([p,...a]).then(([,...f])=>f);return z.catch(()=>{}),z}sendCancelRequest(e){return this.sendNotification(hs,{requestId:e})}sendNotification(e,n){return this.abortController.signal.aborted?Y(this.closedReason()):this.sendWireMessage({jsonrpc:"2.0",method:e,params:n})}prepareRequest(e,n,i,a={}){let u=this.nextRequestId++,p=()=>{},z=new Promise((f,g)=>{let m={resolve:y=>{try{f(i?i(y):y)}catch(C){g(C)}},reject:g};p=()=>{m.cancellationSent||(m.cancellationSent=!0,m.cleanup?.(),this.sendCancelRequest(u).catch(()=>{}))},a.cancellationSignal?.addEventListener("abort",p,{once:!0}),m.cleanup=()=>{a.cancellationSignal?.removeEventListener("abort",p)},this.pendingResponses.set(u,m)});return z.catch(()=>{}),{message:{jsonrpc:"2.0",id:u,method:e,params:n},response:z,cancel:()=>p()}}close(e){if(this.abortController.signal.aborted)return;let n=e??new Error("ACP connection closed");this.abortController.abort(n);for(let i of this.pendingResponses.values())i.cleanup?.(),i.reject(n);this.pendingResponses.clear();for(let i of this.incomingRequests.values())i.abort(n);this.incomingRequests.clear(),this.receiveReader?.cancel(n).catch(()=>{})}initialize(e,n,i){this.stream=e,this.staticHandlers=n,this.allowBatches=i?.allowBatches??!0,this.closedPromise=new Promise(a=>{this.abortController.signal.addEventListener("abort",()=>a())}),this.receive()}legacyHandler(e,n){return{handleMessage:async(i,a)=>{if(i.kind==="request"){let u=await e(i.method,i.params,a);await i.responder.respond(u)}else await n(i.method,i.params,a);return D.yes()}}}async receive(){let e;try{let n=this.stream.readable.getReader();this.receiveReader=n;try{for(;!this.abortController.signal.aborted;){let{value:i,done:a}=await n.read();if(this.abortController.signal.aborted||a)break;this.receiveWireMessage(i)}}finally{this.receiveReader===n&&(this.receiveReader=void 0),n.releaseLock()}}catch(n){e=n}finally{this.close(e)}}receiveWireMessage(e){if(Array.isArray(e)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(e);return}if(!P(e)&&!F(e)&&!pe(e)){this.sendWireMessage(L(w.invalidRequest(e))).catch(()=>{});return}this.receiveMessage(e)}receiveBatch(e){if(e.length===0){this.sendWireMessage(L(w.invalidRequest(e))).catch(()=>{});return}let n=ca(e),a=n?0:e.reduce((m,y)=>m+(F(y)?0:1),0),u=e.reduce((m,y)=>m+(F(y)?1:0),0),p=!1,z=[],f=async()=>{p||a!==0||u!==0||z.length===0||(p=!0,await this.sendWireMessage(z))},g=async m=>{z.push(m),a-=1,await f()};for(let m of e){if(n){pe(m)&&this.receiveMessage(m);continue}if(!P(m)&&!F(m)){g(L(w.invalidRequest(m))).catch(()=>{});continue}let y=this.receiveMessage(m,P(m)?g:void 0,e.length);F(m)&&y.finally(()=>{u-=1,f().catch(C=>this.close(C))})}}receiveMessage(e,n,i){return this.abortController.signal.aborted?Promise.resolve():I(e)?"method"in e?("id"in e||this.handleProtocolNotification(e),this.processIncomingMessage(this.toIncomingMessage(e,n,i)).catch(a=>this.close(a))):("id"in e?this.handleResponse(e):console.error("Invalid message",{message:e}),Promise.resolve()):(console.error("Invalid message",{message:e}),Promise.resolve())}async processIncomingMessage(e){if(this.abortController.signal.aborted)return;let n=e,i=!1;try{for(let a of[...this.staticHandlers,...this.dynamicHandlers.values()]){if(this.abortController.signal.aborted)return;let u=await a.handleMessage(n,this.context)??{handled:!0};if(u.handled)return;n=u.message??n,i=i||!!u.retry}i?this.retryQueue.push(n):n.kind==="request"&&await n.responder.respondWithError(w.methodNotFound(n.method))}catch(a){if(this.abortController.signal.aborted)return;if(n.kind==="request"&&!n.responder.responded)await n.responder.respondWithResult(fa(a,n.responder.signal));else{let u=ps(a);"error"in u&&console.error("Error handling notification",e.raw,u.error)}}}toIncomingMessage(e,n,i){if("id"in e){let a=new AbortController;this.incomingRequests.set(e.id,a);let u=()=>{this.incomingRequests.get(e.id)===a&&this.incomingRequests.delete(e.id)},p=new Vn(e.id,z=>{let f={jsonrpc:"2.0",id:e.id,...z};return n?n(f):this.sendWireMessage(f)},a.signal,u);return i!==void 0&&ga.set(p,i),{kind:"request",method:e.method,params:e.params,raw:e,signal:a.signal,responder:p}}return{kind:"notification",method:e.method,params:e.params,raw:e}}handleResponse(e){let n=this.pendingResponses.get(e.id);if(n)if(this.pendingResponses.delete(e.id),n.cleanup?.(),!V(e))n.reject(w.invalidRequest(e));else if("result"in e)n.resolve(e.result);else{let{code:i,message:a,data:u}=e.error;n.reject(new w(i,a,u))}else console.error("Got response to unknown request",e.id)}handleProtocolNotification(e){if(e.method!==hs)return;let n=da(e.params);if(n===void 0)return;let i=this.incomingRequests.get(n);!i||i.signal.aborted||i.abort(w.requestCancelled({requestId:n}))}closedReason(){return this.abortController.signal.reason??new Error("ACP connection closed")}async sendWireMessage(e){return this.abortController.signal.aborted?Y(this.closedReason()):(this.writeQueue=this.writeQueue.then(async()=>{if(this.abortController.signal.aborted)throw this.closedReason();let n=this.stream.writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{throw this.close(n),n}),this.writeQueue)}},Yn=class{handlers=[];connectionName;name(e){return this.connectionName=e,this}withHandler(e){return this.handlers.push(e),this}onReceiveMessage(e){return this.withHandler({handleMessage:async(n,i)=>await e(n,i)??D.no(n),describe:()=>this.connectionName??"onReceiveMessage"})}onReceiveRequest(e,n,i){return this.withHandler({handleMessage:async(a,u)=>{if(a.kind!=="request"||a.method!==e)return D.no(a);let p=n(a.params);return await i(p,a.responder,u)??D.yes()},describe:()=>`${this.connectionName??"request"}:${e}`})}onReceiveNotification(e,n,i){return this.withHandler({handleMessage:async(a,u)=>{if(a.kind!=="notification"||a.method!==e)return D.no(a);let p=n(a.params);return await i(p,u)??D.yes()},describe:()=>`${this.connectionName??"notification"}:${e}`})}connect(e,n){return new ie(e,this.handlers,n)}connectWith(e,n,i){return this.connect(e,i).runUntil(n)}},w=class t extends Error{code;data;constructor(e,n,i){super(n),this.code=e,this.name="RequestError",this.data=i}static parseError(e,n){return new t(-32700,`Parse error${n?`: ${n}`:""}`,e)}static invalidRequest(e,n){return new t(-32600,`Invalid request${n?`: ${n}`:""}`,e)}static methodNotFound(e){return new t(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,n){return new t(-32602,`Invalid params${n?`: ${n}`:""}`,e)}static internalError(e,n){return new t(-32603,`Internal error${n?`: ${n}`:""}`,e)}static requestCancelled(e,n){return new t(-32800,`Request cancelled${n?`: ${n}`:""}`,e)}static authRequired(e,n){return new t(-32e3,`Authentication required${n?`: ${n}`:""}`,e)}static resourceNotFound(e){return new t(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};function L(t){return{jsonrpc:"2.0",id:null,error:t.toErrorResponse()}}var fe=class{#e=[];push(e){let n=[],i=0,a=e.indexOf(10,i);for(;a!==-1;)n.push(this.#n(e.subarray(i,a))),i=a+1,a=e.indexOf(10,i);return i<e.byteLength&&this.#e.push(i===0?e:new Uint8Array(e.subarray(i))),n}flush(){if(this.#e.length!==0)return this.#n(new Uint8Array(0))}#n(e){if(this.#e.length===0)return e;let n=e.byteLength;for(let u of this.#e)n+=u.byteLength;let i=new Uint8Array(n),a=0;for(let u of this.#e)i.set(u,a),a+=u.byteLength;return i.set(e,a),this.#e=[],i}};function fs(t,e){let n=new TextEncoder,i=new TextDecoder,a=!1,u,p=Promise.resolve(),z=m=>{let y=JSON.stringify(m)+`
4
+ import{a as Ot,b as Dt}from"./chunk-U2CS2E2F.js";import"./chunk-6DXHDARX.js";import"./chunk-HLE7243Q.js";import{p as kt,q as vt,s as Nt,t as At,u as It,v as Mt,w as jt}from"./chunk-ZETIYALB.js";import{a as Ct}from"./chunk-JNCMSXQZ.js";import"./chunk-JFKC4VCA.js";import"./chunk-SAJCBGHL.js";import"./chunk-OFC2GD5K.js";import{v as Rt,w as yt,x as Tt}from"./chunk-7DLUKIPE.js";import"./chunk-RCXKUD3Y.js";import"./chunk-XO7ITAWR.js";import{k as Be,s as $e}from"./chunk-UPNNYP7M.js";import{D as K,g as s,h as xt,i as x,j as A,k as v,n as c,o as T,p as r,r as b,t as B,u as d,w as l}from"./chunk-GYBJR2RB.js";import{b as Et}from"./chunk-L2BWSPCF.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import{d as Se}from"./chunk-7MKA3SHV.js";var Os={};Se(Os,{runAcpStdio:()=>zt});import{Readable as Ha,Writable as Pa}from"stream";var h={initialize:"initialize",authenticate:"authenticate",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_load:"session/load",session_set_mode:"session/set_mode",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",logout:"logout",nes_start:"nes/start",nes_suggest:"nes/suggest",nes_accept:"nes/accept",nes_reject:"nes/reject",nes_close:"nes/close",document_did_open:"document/didOpen",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_save:"document/didSave",document_did_focus:"document/didFocus"},_={session_request_permission:"session/request_permission",session_update:"session/update",fs_write_text_file:"fs/write_text_file",fs_read_text_file:"fs/read_text_file",terminal_create:"terminal/create",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit",terminal_kill:"terminal/kill",mcp_connect:"mcp/connect",mcp_message:"mcp/message",mcp_disconnect:"mcp/disconnect",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},Je={cancel_request:"$/cancel_request"},Ve=1;var qt=Symbol("skippedItem");function o(t,e){return t.catch(e)}function O(t,e){let n=t.catch(e);return K.unknown().transform((i,a)=>i!==void 0?n.parse(i):(a.addIssue({code:"custom",message:"Required value is missing"}),K.NEVER))}function Ht(t,e){if(t===null||typeof t!="object"||Array.isArray(t))return;let n=t[e];return typeof n=="string"?n:void 0}function ae(t,e,n){return t.superRefine((i,a)=>{let u=Ht(i,e);u!==void 0&&n.includes(u)&&a.addIssue({code:"custom",path:[e],message:`${e} ${JSON.stringify(u)} is reserved by a known variant, but the value does not match that variant's schema`})})}function ce(t,e,n){return K.unknown().transform((i,a)=>{let u=t.safeParse(i);if(!u.success){for(let f of u.error.issues)a.addIssue({...f,input:i});return K.NEVER}let p=u.data,z=Ht(i,e);if(z!==void 0&&!n.includes(z)){let f=i;for(let[g,m]of Object.entries(f))g!=="__proto__"&&(Object.hasOwn(p,g)||(p[g]=m))}return p})}function S(t){return K.array(t.catch(qt)).transform(e=>e.filter(n=>n!==qt))}var $=b([x(),s()]).nullable(),E=s(),Ye=r({sessionId:E,path:s(),content:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Qe=r({sessionId:E,path:s(),line:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),limit:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ze=s(),Pt=b([l("read"),l("edit"),l("delete"),l("move"),l("search"),l("execute"),l("think"),l("fetch"),l("switch_mode"),l("other")]),Lt=b([l("pending"),l("in_progress"),l("completed"),l("failed")]),si=b([l("assistant"),l("user")]),de=r({audience:o(S(si).nullish(),()=>{}),lastModified:o(s().nullish(),()=>{}),priority:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ii=r({annotations:o(de.nullish(),()=>{}),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),oi=r({annotations:o(de.nullish(),()=>{}),data:s(),mimeType:s(),uri:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ri=r({annotations:o(de.nullish(),()=>{}),data:s(),mimeType:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ai=r({annotations:o(de.nullish(),()=>{}),description:o(s().nullish(),()=>{}),mimeType:o(s().nullish(),()=>{}),name:s(),size:o(x().nullish(),()=>{}),title:o(s().nullish(),()=>{}),uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ci=r({mimeType:o(s().nullish(),()=>{}),text:s(),uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),di=r({blob:s(),mimeType:o(s().nullish(),()=>{}),uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ui=b([ci,di]),li=r({annotations:o(de.nullish(),()=>{}),resource:ui,_meta:o(d(s(),c()).nullish(),()=>{})}),ue=b([ii.and(r({type:l("text")})),oi.and(r({type:l("image")})),ri.and(r({type:l("audio")})),ai.and(r({type:l("resource_link")})),li.and(r({type:l("resource")}))]),hi=r({content:ue,_meta:o(d(s(),c()).nullish(),()=>{})}),pi=r({path:s(),oldText:o(s().nullish(),()=>{}),newText:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),X=s(),fi=r({terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),Gt=b([hi.and(r({type:l("content")})),pi.and(r({type:l("diff")})),fi.and(r({type:l("terminal")}))]),Ut=r({path:s(),line:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ft=r({toolCallId:Ze,kind:o(Pt.nullish(),()=>{}),status:o(Lt.nullish(),()=>{}),title:o(s().nullish(),()=>{}),name:o(s().nullish(),()=>{}),content:o(S(Gt).nullish(),()=>{}),locations:o(S(Ut).nullish(),()=>{}),rawInput:o(c().optional(),()=>{}),rawOutput:o(c().optional(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Wt=s(),zi=b([l("allow_once"),l("allow_always"),l("reject_once"),l("reject_always")]),mi=r({optionId:Wt,name:s(),kind:zi,_meta:o(d(s(),c()).nullish(),()=>{})}),Xe=r({sessionId:E,toolCall:Ft,options:T(mi),_meta:o(d(s(),c()).nullish(),()=>{})}),Bt=r({name:s(),value:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),en=r({sessionId:E,command:s(),args:o(S(s()).optional(),()=>[]),env:o(S(Bt).optional(),()=>[]),cwd:o(s().nullish(),()=>{}),outputByteLimit:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),nn=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),tn=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),sn=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),on=r({sessionId:E,terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),le=r({sessionId:E,toolCallId:o(Ze.nullish(),()=>{})}),he=r({requestId:$}),gi=l("object"),bi=b([l("email"),l("uri"),l("date"),l("date-time")]),$t=r({const:s(),title:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),rn=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minLength:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:s().nullish(),format:bi.nullish(),default:o(s().nullish(),()=>{}),enum:T(s()).nullish(),oneOf:T($t).nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),an=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:x().nullish(),maximum:x().nullish(),default:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),cn=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:x().nullish(),maximum:x().nullish(),default:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),dn=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),default:o(v().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),un=r({enum:T(s()),_meta:o(d(s(),c()).nullish(),()=>{})}),Jt=r({anyOf:T($t),_meta:o(d(s(),c()).nullish(),()=>{})}),_i=ce(b([un.and(r({type:l("string")})),ae(r({type:s()}),"type",["string"]),Jt]),"type",["string"]),ln=r({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minItems:x().nullish(),maxItems:x().nullish(),items:_i,default:o(S(s()).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),wi=ce(b([rn.and(r({type:l("string")})),an.and(r({type:l("number")})),cn.and(r({type:l("integer")})),dn.and(r({type:l("boolean")})),ln.and(r({type:l("array")})),ae(r({type:s()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),Si=r({type:o(gi.optional().default("object"),()=>"object"),title:o(s().nullish(),()=>{}),properties:d(s(),wi).optional().default({}),required:T(s()).nullish(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),hn=B(b([le,he]),r({requestedSchema:Si})),Vt=s(),pn=B(b([le,he]),r({elicitationId:Vt,url:xt()})),fn=ce(B(b([hn.and(r({mode:l("form")})),pn.and(r({mode:l("url")})),ae(B(b([le,he]),r({mode:s()})),"mode",["form","url"])]),r({message:s(),_meta:o(d(s(),c()).nullish(),()=>{})})),"mode",["form","url"]),Kt=s(),Ei=r({serverId:Kt,_meta:o(d(s(),c()).nullish(),()=>{})}),Ee=s(),Yt=r({connectionId:Ee,method:s(),params:d(s(),c()).nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),xi=r({connectionId:Ee,_meta:o(d(s(),c()).nullish(),()=>{})}),Qt=c(),_c=r({id:$,method:s(),params:b([Ye,Qe,Xe,en,nn,tn,sn,on,fn,Ei,Yt,xi,Qt]).nullish()}),Zt=A().gte(0).lte(65535),Ri=r({image:o(v().optional().default(!1),()=>!1),audio:o(v().optional().default(!1),()=>!1),embeddedContext:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),yi=r({http:o(v().optional().default(!1),()=>!1),sse:o(v().optional().default(!1),()=>!1),acp:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),Ti=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ci=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ki=r({_meta:o(d(s(),c()).nullish(),()=>{})}),vi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ni=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ai=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ii=r({list:o(Ti.nullish(),()=>{}),delete:o(Ci.nullish(),()=>{}),additionalDirectories:o(ki.nullish(),()=>{}),fork:o(vi.nullish(),()=>{}),resume:o(Ni.nullish(),()=>{}),close:o(Ai.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Mi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ji=r({logout:o(Mi.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Oi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Di=r({_meta:o(d(s(),c()).nullish(),()=>{})}),qi=b([l("full"),l("incremental")]),Hi=r({syncKind:qi,_meta:o(d(s(),c()).nullish(),()=>{})}),Pi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Li=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Gi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ui=r({didOpen:o(Di.nullish(),()=>{}),didChange:o(Hi.nullish(),()=>{}),didClose:o(Pi.nullish(),()=>{}),didSave:o(Li.nullish(),()=>{}),didFocus:o(Gi.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Fi=r({document:o(Ui.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Wi=r({maxCount:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Bi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),$i=r({maxCount:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ji=r({maxCount:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Vi=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Ki=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Yi=r({recentFiles:o(Wi.nullish(),()=>{}),relatedSnippets:o(Bi.nullish(),()=>{}),editHistory:o($i.nullish(),()=>{}),userActions:o(Ji.nullish(),()=>{}),openFiles:o(Vi.nullish(),()=>{}),diagnostics:o(Ki.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Qi=r({events:o(Fi.nullish(),()=>{}),context:o(Yi.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Xt=b([l("utf-16"),l("utf-32"),l("utf-8")]),Zi=r({loadSession:o(v().optional().default(!1),()=>!1),promptCapabilities:o(Ri.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:o(yi.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:o(Ii.optional().default({}),()=>({})),auth:o(ji.optional().default({}),()=>({})),providers:o(Oi.nullish(),()=>{}),nes:o(Qi.nullish(),()=>{}),positionEncoding:o(Xt.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),zn=s(),Xi=r({id:zn,name:s(),description:o(s().nullish(),()=>{}),args:o(S(s()).optional(),()=>[]),env:o(d(s(),s()).optional(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),eo=r({id:zn,name:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),no=b([Xi.and(r({type:l("terminal")})),eo]),es=r({name:s(),title:o(s().nullish(),()=>{}),version:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),to=r({protocolVersion:Zt,agentCapabilities:o(Zi.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:o(S(no).optional().default([]),()=>[]),agentInfo:o(es.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),so=r({_meta:o(d(s(),c()).nullish(),()=>{})}),mn=s(),gn=b([l("anthropic"),l("openai"),l("azure"),l("vertex"),l("bedrock"),s()]),io=r({apiType:gn,baseUrl:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),oo=r({providerId:mn,supported:O(S(gn),()=>[]),required:v(),current:io.nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),ro=r({providers:T(oo),_meta:o(d(s(),c()).nullish(),()=>{})}),ao=r({_meta:o(d(s(),c()).nullish(),()=>{})}),co=r({_meta:o(d(s(),c()).nullish(),()=>{})}),uo=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xe=s(),lo=r({id:xe,name:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Re=r({currentModeId:xe,availableModes:O(S(lo),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ns=s(),ho=b([l("mode"),l("model"),l("model_config"),l("thought_level"),s()]),bn=s(),ts=r({value:bn,name:s(),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),po=s(),fo=r({group:po,name:s(),options:O(S(ts),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),zo=b([T(ts),T(fo)]),mo=r({currentValue:bn,options:zo}),go=r({currentValue:v()}),ee=B(b([mo.and(r({type:l("select")})),go.and(r({type:l("boolean")}))]),r({id:ns,name:s(),description:o(s().nullish(),()=>{}),category:o(ho.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})})),bo=r({sessionId:E,modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),_o=r({modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),wo=r({sessionId:E,cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),So=r({sessions:O(S(wo),()=>[]),nextCursor:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Eo=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xo=r({sessionId:E,modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ro=r({modes:o(Re.nullish(),()=>{}),configOptions:o(S(ee).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),yo=r({_meta:o(d(s(),c()).nullish(),()=>{})}),To=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Co=r({configOptions:O(S(ee),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ko=b([l("end_turn"),l("max_tokens"),l("max_turn_requests"),l("refusal"),l("cancelled")]),vo=r({totalTokens:x(),inputTokens:x(),outputTokens:x(),thoughtTokens:o(x().nullish(),()=>{}),cachedReadTokens:o(x().nullish(),()=>{}),cachedWriteTokens:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),No=r({stopReason:ko,usage:o(vo.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ao=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),ne=s(),J=r({line:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),character:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),_meta:o(d(s(),c()).nullish(),()=>{})}),te=r({start:J,end:J,_meta:o(d(s(),c()).nullish(),()=>{})}),Io=r({range:te,newText:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Mo=r({id:ne,uri:s(),edits:T(Io),cursorPosition:o(J.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),jo=r({id:ne,uri:s(),position:J,_meta:o(d(s(),c()).nullish(),()=>{})}),Oo=r({id:ne,uri:s(),position:J,newName:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Do=r({id:ne,uri:s(),search:s(),replace:s(),isRegex:v().nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),qo=b([Mo.and(r({kind:l("edit")})),jo.and(r({kind:l("jump")})),Oo.and(r({kind:l("rename")})),Do.and(r({kind:l("searchAndReplace")}))]),Ho=r({suggestions:T(qo),_meta:o(d(s(),c()).nullish(),()=>{})}),Po=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ss=c(),is=c(),Lo=b([l(-32700),l(-32600),l(-32601),l(-32602),l(-32603),l(-32800),l(-32e3),l(-32002),A().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),os=r({code:Lo,message:s(),data:o(c().optional(),()=>{})}),wc=b([r({id:$,result:b([to,so,ro,ao,co,uo,bo,_o,So,Eo,xo,Ro,yo,To,Co,No,Ao,Ho,Po,ss,is])}),r({id:$,error:os})]),Go=s(),Ke=r({content:ue,messageId:o(Go.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Uo=r({toolCallId:Ze,title:s(),name:o(s().nullish(),()=>{}),kind:o(Pt.optional(),()=>{}),status:o(Lt.optional(),()=>{}),content:o(S(Gt).optional(),()=>[]),locations:o(S(Ut).optional(),()=>[]),rawInput:o(c().optional(),()=>{}),rawOutput:o(c().optional(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Fo=b([l("high"),l("medium"),l("low")]),Wo=b([l("pending"),l("in_progress"),l("completed")]),rs=r({content:s(),priority:Fo,status:Wo,_meta:o(d(s(),c()).nullish(),()=>{})}),Bo=r({entries:O(S(rs),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ye=s(),$o=r({planId:ye,entries:O(S(rs),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),Jo=r({planId:ye,uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Vo=r({planId:ye,content:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Ko=b([$o.and(r({type:l("items")})),Jo.and(r({type:l("file")})),Vo.and(r({type:l("markdown")}))]),Yo=r({plan:Ko,_meta:o(d(s(),c()).nullish(),()=>{})}),Qo=r({planId:ye,_meta:o(d(s(),c()).nullish(),()=>{})}),Zo=r({hint:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Xo=Zo,er=r({name:s(),description:s(),input:o(Xo.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),nr=r({availableCommands:O(S(er),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),tr=r({currentModeId:xe,_meta:o(d(s(),c()).nullish(),()=>{})}),sr=r({configOptions:O(S(ee),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),ir=r({title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),or=r({amount:x(),currency:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),rr=r({used:x(),size:x(),cost:o(or.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ar=b([l("info"),l("warning"),l("error"),s()]),cr=r({severity:ar,title:s().min(1),description:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),as=s(),dr=b([l("in_progress"),l("completed"),l("failed"),l("cancelled"),s()]),ur=r({compactionId:as,status:dr,summary:o(S(ue).nullish(),()=>{}),error:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),lr=r({compactionId:as,content:ue,_meta:o(d(s(),c()).nullish(),()=>{})}),hr=b([Ke.and(r({sessionUpdate:l("user_message_chunk")})),Ke.and(r({sessionUpdate:l("agent_message_chunk")})),Ke.and(r({sessionUpdate:l("agent_thought_chunk")})),Uo.and(r({sessionUpdate:l("tool_call")})),Ft.and(r({sessionUpdate:l("tool_call_update")})),Bo.and(r({sessionUpdate:l("plan")})),Yo.and(r({sessionUpdate:l("plan_update")})),Qo.and(r({sessionUpdate:l("plan_removed")})),nr.and(r({sessionUpdate:l("available_commands_update")})),tr.and(r({sessionUpdate:l("current_mode_update")})),sr.and(r({sessionUpdate:l("config_option_update")})),ir.and(r({sessionUpdate:l("session_info_update")})),rr.and(r({sessionUpdate:l("usage_update")})),cr.and(r({sessionUpdate:l("notice")})),ur.and(r({sessionUpdate:l("compaction_update")})),lr.and(r({sessionUpdate:l("compaction_summary_chunk")}))]),Te=r({sessionId:E,update:hr,_meta:o(d(s(),c()).nullish(),()=>{})}),_n=r({elicitationId:Vt,_meta:o(d(s(),c()).nullish(),()=>{})}),cs=r({connectionId:Ee,method:s(),params:o(d(s(),c()).nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),ds=c(),Sc=r({method:s(),params:b([Te,_n,cs,ds]).nullish()}),pr=r({readTextFile:o(v().optional().default(!1),()=>!1),writeTextFile:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),fr=d(s(),c()),zr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),mr=r({boolean:o(zr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),gr=d(s(),c()),br=r({compaction:o(fr.nullish(),()=>{}),configOptions:o(mr.nullish(),()=>{}),notices:o(gr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),_r=r({_meta:o(d(s(),c()).nullish(),()=>{})}),wr=r({terminal:o(v().optional().default(!1),()=>!1),_meta:o(d(s(),c()).nullish(),()=>{})}),Sr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Er=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xr=r({form:o(Sr.nullish(),()=>{}),url:o(Er.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Rr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),yr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Tr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),Cr=r({jump:o(Rr.nullish(),()=>{}),rename:o(yr.nullish(),()=>{}),searchAndReplace:o(Tr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),kr=r({fs:o(pr.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:o(v().optional().default(!1),()=>!1),session:o(br.nullish(),()=>{}),plan:o(_r.nullish(),()=>{}),auth:o(wr.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:o(xr.nullish(),()=>{}),nes:o(Cr.nullish(),()=>{}),positionEncodings:o(S(Xt).optional(),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),wn=r({protocolVersion:Zt,clientCapabilities:o(kr.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:o(es.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Sn=r({methodId:zn,_meta:o(d(s(),c()).nullish(),()=>{})}),En=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xn=r({providerId:mn,apiType:gn,baseUrl:s(),headers:d(s(),s()).optional(),_meta:o(d(s(),c()).nullish(),()=>{})}),Rn=r({providerId:mn,_meta:o(d(s(),c()).nullish(),()=>{})}),yn=r({_meta:o(d(s(),c()).nullish(),()=>{})}),us=r({name:s(),value:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),vr=r({name:s(),url:s(),headers:T(us),_meta:o(d(s(),c()).nullish(),()=>{})}),Nr=r({name:s(),url:s(),headers:T(us),_meta:o(d(s(),c()).nullish(),()=>{})}),Ar=r({name:s(),serverId:Kt,_meta:o(d(s(),c()).nullish(),()=>{})}),Ir=r({name:s(),command:s(),args:T(s()),env:T(Bt),_meta:o(d(s(),c()).nullish(),()=>{})}),Ce=b([vr.and(r({type:l("http")})),Nr.and(r({type:l("sse")})),Ar.and(r({type:l("acp")})),Ir]),Tn=r({cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),mcpServers:O(S(Ce),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),Cn=r({mcpServers:O(S(Ce),()=>[]),cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),kn=r({cwd:s().nullish(),cursor:s().nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),vn=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Nn=r({sessionId:E,cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),mcpServers:o(S(Ce).optional(),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),An=r({sessionId:E,cwd:s(),additionalDirectories:o(S(s()).optional(),()=>[]),mcpServers:o(S(Ce).optional(),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),In=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Mn=r({sessionId:E,modeId:xe,_meta:o(d(s(),c()).nullish(),()=>{})}),jn=B(b([r({value:v(),type:l("boolean")}),r({value:bn})]),r({sessionId:E,configId:ns,_meta:o(d(s(),c()).nullish(),()=>{})})),On=r({sessionId:E,prompt:T(ue),_meta:o(d(s(),c()).nullish(),()=>{})}),Mr=r({uri:s(),name:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),jr=r({name:s(),owner:s(),remoteUrl:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Dn=r({workspaceUri:o(s().nullish(),()=>{}),workspaceFolders:T(Mr).nullish(),repository:o(jr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Or=b([l("automatic"),l("diagnostic"),l("manual")]),Dr=r({uri:s(),languageId:s(),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),qr=r({startLine:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),endLine:A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Hr=r({uri:s(),excerpts:T(qr),_meta:o(d(s(),c()).nullish(),()=>{})}),Pr=r({uri:s(),diff:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Lr=r({action:s(),uri:s(),position:J,timestampMs:x(),_meta:o(d(s(),c()).nullish(),()=>{})}),Gr=r({uri:s(),languageId:s(),visibleRange:o(te.nullish(),()=>{}),lastFocusedMs:o(x().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Ur=b([l("error"),l("warning"),l("information"),l("hint")]),Fr=r({uri:s(),range:te,severity:Ur,message:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Wr=r({recentFiles:T(Dr).nullish(),relatedSnippets:T(Hr).nullish(),editHistory:T(Pr).nullish(),userActions:T(Lr).nullish(),openFiles:T(Gr).nullish(),diagnostics:T(Fr).nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),qn=r({sessionId:E,uri:s(),version:x(),position:J,selection:te.nullish(),triggerKind:Or,context:Wr.nullish(),_meta:o(d(s(),c()).nullish(),()=>{})}),Hn=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Ec=r({id:$,method:s(),params:b([wn,Sn,En,xn,Rn,yn,Tn,Cn,kn,vn,Nn,An,In,Mn,jn,On,Dn,qn,Hn,Yt,Qt]).nullish()}),Br=r({_meta:o(d(s(),c()).nullish(),()=>{})}),$r=r({content:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Jr=r({optionId:Wt,_meta:o(d(s(),c()).nullish(),()=>{})}),Vr=b([r({outcome:l("cancelled")}),Jr.and(r({outcome:l("selected")}))]),Kr=r({outcome:Vr,_meta:o(d(s(),c()).nullish(),()=>{})}),Yr=r({terminalId:X,_meta:o(d(s(),c()).nullish(),()=>{})}),Qr=r({exitCode:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Zr=r({output:s(),truncated:v(),exitStatus:o(Qr.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Xr=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ea=r({exitCode:o(A().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),na=r({_meta:o(d(s(),c()).nullish(),()=>{})}),ta=b([s(),x(),x(),v(),T(s())]),Pn=r({content:d(s(),ta).nullish()}),sa=ce(B(b([Pn.and(r({action:l("accept")})),r({action:l("decline")}),r({action:l("cancel")}),ae(r({action:s()}),"action",["accept","cancel","decline"])]),r({_meta:o(d(s(),c()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),ia=r({connectionId:Ee,_meta:o(d(s(),c()).nullish(),()=>{})}),oa=r({_meta:o(d(s(),c()).nullish(),()=>{})}),xc=b([r({id:$,result:b([Br,$r,Kr,Yr,Zr,Xr,ea,na,sa,ia,oa,is,ss])}),r({id:$,error:os})]),Ln=r({sessionId:E,_meta:o(d(s(),c()).nullish(),()=>{})}),Gn=r({sessionId:E,uri:s(),languageId:s(),version:x(),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),ra=r({range:te.nullish(),text:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Un=r({sessionId:E,uri:s(),version:x(),contentChanges:O(S(ra),()=>[]),_meta:o(d(s(),c()).nullish(),()=>{})}),Fn=r({sessionId:E,uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Wn=r({sessionId:E,uri:s(),_meta:o(d(s(),c()).nullish(),()=>{})}),Bn=r({sessionId:E,uri:s(),version:x(),position:J,visibleRange:te,_meta:o(d(s(),c()).nullish(),()=>{})}),$n=r({sessionId:E,id:ne,_meta:o(d(s(),c()).nullish(),()=>{})}),aa=b([l("rejected"),l("ignored"),l("replaced"),l("cancelled")]),Jn=r({sessionId:E,id:ne,reason:o(aa.nullish(),()=>{}),_meta:o(d(s(),c()).nullish(),()=>{})}),Rc=r({method:s(),params:b([Ln,Gn,Un,Fn,Wn,Bn,$n,Jn,cs,ds]).nullish()}),yc=r({requestId:$,_meta:o(d(s(),c()).nullish(),()=>{})});var hs="$/cancel_request";function P(t){return Qn(t)&&"id"in t&&typeof t.method=="string"&&Zn(t.id)}function V(t){if(!Qn(t)||"method"in t||!("id"in t)||!Zn(t.id))return!1;let e=Object.hasOwn(t,"result"),n=Object.hasOwn(t,"error");return e===n?!1:!n||ua(t.error)}function F(t){return Qn(t)&&!("id"in t)&&typeof t.method=="string"}function I(t){return typeof t=="object"&&t!==null}function Qn(t){return I(t)&&t.jsonrpc==="2.0"}function Zn(t){return t===null||typeof t=="string"||typeof t=="number"&&Number.isFinite(t)}function pe(t){return I(t)&&!("method"in t)&&("id"in t||"result"in t||"error"in t)}function ca(t){let e=!1,n=!1,i=!1,a=!1;for(let u of t)e||=P(u)||F(u),n||=V(u),I(u)&&(i||="method"in u,a||="result"in u||"error"in u);return e?!1:n?!0:a&&!i}function da(t){if(!(!I(t)||!Zn(t.requestId)))return t.requestId}function ua(t){return I(t)&&typeof t.code=="number"&&Number.isInteger(t.code)&&typeof t.message=="string"}var D={yes(){return{handled:!0}},no(t,e=!1){return{handled:!1,message:t,retry:e}}};function Y(t){let e=Promise.reject(t);return e.catch(()=>{}),e}function la(t){if(t instanceof Error||typeof t=="object"&&t!=null&&"message"in t&&typeof t.message=="string")return t.message}function ha(t){return typeof t=="object"&&t!==null&&"name"in t&&t.name==="ZodError"&&"issues"in t&&Array.isArray(t.issues)&&"format"in t&&typeof t.format=="function"}function ps(t){if(t instanceof w)return t.toResult();if(ha(t))return w.invalidParams(t.format()).toResult();let e=la(t);try{return w.internalError(e?JSON.parse(e):{}).toResult()}catch{return w.internalError({details:e}).toResult()}}function pa(t){return t instanceof w&&t.code===-32800?t:w.requestCancelled(t)}function fa(t,e){let n=za(t,e);return n?n.toResult():ps(t)}function za(t,e){if(!(!e.aborted||!ma(t)))return pa(e.reason)}function ma(t){if(typeof t!="object"||t===null)return!1;let e=t;return e.name==="AbortError"||e.code==="ABORT_ERR"}var Vn=class{id;sendResult;signal;finishRequest;didRespond=!1;constructor(e,n,i=new AbortController().signal,a){this.id=e,this.sendResult=n,this.signal=i,this.finishRequest=a}get responded(){return this.didRespond}respond(e){return this.respondWithResult({result:e??null})}respondWithError(e){let n=e instanceof w?e.toErrorResponse():e;return this.respondWithResult({error:n})}respondWithResult(e){return this.didRespond?Y(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(e).finally(()=>{this.finishRequest?.()}))}},ga=new WeakMap;var se=class{disposeHandler;active=!0;constructor(e){this.disposeHandler=e}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},Kn=class{connection;constructor(e){this.connection=e}sendRequest(e,n,i,a){return this.connection.sendRequest(e,n,i,a)}sendNotification(e,n){return this.connection.sendNotification(e,n)}sendBatch(e){return this.connection.sendBatch(e)}sendCancelRequest(e){return this.connection.sendCancelRequest(e)}addDynamicHandler(e){return this.connection.addDynamicHandler(e)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},ie=class{pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new Kn(this);receiveReader;allowBatches=!0;constructor(e,n,i,a){if(typeof e=="function"){let f=e,g=n,m=i;this.initialize(m,[...a?.handlers??[],this.legacyHandler(f,g)],a);return}let u=e,p=n,z=i;this.initialize(u,[...z?.handlers??[],...p],z)}static builder(){return new Yn}runUntil(e){let n=!1,i=Promise.resolve().then(()=>e(this.context)).finally(()=>{n=!0}),a=this.closed.then(()=>{if(n)return new Promise(()=>{});throw this.closedReason()});return Promise.race([i,a]).finally(()=>{n=!0,this.close()})}addDynamicHandler(e){if(this.dynamicHandlers.add(e),this.retryQueue.length>0)for(let n of this.retryQueue.splice(0))this.processIncomingMessage(n).catch(i=>this.close(i));return new se(()=>{this.dynamicHandlers.delete(e)})}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}getContext(){return this.context}sendRequest(e,n,i,a={}){if(this.abortController.signal.aborted)return Y(this.closedReason());let u=this.prepareRequest(e,n,i,a);return this.sendWireMessage(u.message).catch(()=>{}),a.cancellationSignal?.aborted&&u.cancel(),u.response}sendBatch(e){if(this.abortController.signal.aborted)return Y(this.closedReason());if(!this.allowBatches)return Y(new TypeError("JSON-RPC batches are not supported on this connection"));if(e.length===0)return Y(new TypeError("JSON-RPC batch must contain at least one entry"));let n=[],i=[],a=[];for(let f of e){if(f.kind==="notification"){n.push({jsonrpc:"2.0",method:f.method,params:f.params}),a.push(Promise.resolve(void 0));continue}let g=this.prepareRequest(f.method,f.params,f.mapResponse,f.options);n.push(g.message),a.push(g.response),i.push({signal:f.options?.cancellationSignal,cancel:g.cancel})}let u=n,p=this.sendWireMessage(u);for(let f of i)f.signal?.aborted&&f.cancel();let z=Promise.all([p,...a]).then(([,...f])=>f);return z.catch(()=>{}),z}sendCancelRequest(e){return this.sendNotification(hs,{requestId:e})}sendNotification(e,n){return this.abortController.signal.aborted?Y(this.closedReason()):this.sendWireMessage({jsonrpc:"2.0",method:e,params:n})}prepareRequest(e,n,i,a={}){let u=this.nextRequestId++,p=()=>{},z=new Promise((f,g)=>{let m={resolve:y=>{try{f(i?i(y):y)}catch(C){g(C)}},reject:g};p=()=>{m.cancellationSent||(m.cancellationSent=!0,m.cleanup?.(),this.sendCancelRequest(u).catch(()=>{}))},a.cancellationSignal?.addEventListener("abort",p,{once:!0}),m.cleanup=()=>{a.cancellationSignal?.removeEventListener("abort",p)},this.pendingResponses.set(u,m)});return z.catch(()=>{}),{message:{jsonrpc:"2.0",id:u,method:e,params:n},response:z,cancel:()=>p()}}close(e){if(this.abortController.signal.aborted)return;let n=e??new Error("ACP connection closed");this.abortController.abort(n);for(let i of this.pendingResponses.values())i.cleanup?.(),i.reject(n);this.pendingResponses.clear();for(let i of this.incomingRequests.values())i.abort(n);this.incomingRequests.clear(),this.receiveReader?.cancel(n).catch(()=>{})}initialize(e,n,i){this.stream=e,this.staticHandlers=n,this.allowBatches=i?.allowBatches??!0,this.closedPromise=new Promise(a=>{this.abortController.signal.addEventListener("abort",()=>a())}),this.receive()}legacyHandler(e,n){return{handleMessage:async(i,a)=>{if(i.kind==="request"){let u=await e(i.method,i.params,a);await i.responder.respond(u)}else await n(i.method,i.params,a);return D.yes()}}}async receive(){let e;try{let n=this.stream.readable.getReader();this.receiveReader=n;try{for(;!this.abortController.signal.aborted;){let{value:i,done:a}=await n.read();if(this.abortController.signal.aborted||a)break;this.receiveWireMessage(i)}}finally{this.receiveReader===n&&(this.receiveReader=void 0),n.releaseLock()}}catch(n){e=n}finally{this.close(e)}}receiveWireMessage(e){if(Array.isArray(e)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(e);return}if(!P(e)&&!F(e)&&!pe(e)){this.sendWireMessage(L(w.invalidRequest(e))).catch(()=>{});return}this.receiveMessage(e)}receiveBatch(e){if(e.length===0){this.sendWireMessage(L(w.invalidRequest(e))).catch(()=>{});return}let n=ca(e),a=n?0:e.reduce((m,y)=>m+(F(y)?0:1),0),u=e.reduce((m,y)=>m+(F(y)?1:0),0),p=!1,z=[],f=async()=>{p||a!==0||u!==0||z.length===0||(p=!0,await this.sendWireMessage(z))},g=async m=>{z.push(m),a-=1,await f()};for(let m of e){if(n){pe(m)&&this.receiveMessage(m);continue}if(!P(m)&&!F(m)){g(L(w.invalidRequest(m))).catch(()=>{});continue}let y=this.receiveMessage(m,P(m)?g:void 0,e.length);F(m)&&y.finally(()=>{u-=1,f().catch(C=>this.close(C))})}}receiveMessage(e,n,i){return this.abortController.signal.aborted?Promise.resolve():I(e)?"method"in e?("id"in e||this.handleProtocolNotification(e),this.processIncomingMessage(this.toIncomingMessage(e,n,i)).catch(a=>this.close(a))):("id"in e?this.handleResponse(e):console.error("Invalid message",{message:e}),Promise.resolve()):(console.error("Invalid message",{message:e}),Promise.resolve())}async processIncomingMessage(e){if(this.abortController.signal.aborted)return;let n=e,i=!1;try{for(let a of[...this.staticHandlers,...this.dynamicHandlers.values()]){if(this.abortController.signal.aborted)return;let u=await a.handleMessage(n,this.context)??{handled:!0};if(u.handled)return;n=u.message??n,i=i||!!u.retry}i?this.retryQueue.push(n):n.kind==="request"&&await n.responder.respondWithError(w.methodNotFound(n.method))}catch(a){if(this.abortController.signal.aborted)return;if(n.kind==="request"&&!n.responder.responded)await n.responder.respondWithResult(fa(a,n.responder.signal));else{let u=ps(a);"error"in u&&console.error("Error handling notification",e.raw,u.error)}}}toIncomingMessage(e,n,i){if("id"in e){let a=new AbortController;this.incomingRequests.set(e.id,a);let u=()=>{this.incomingRequests.get(e.id)===a&&this.incomingRequests.delete(e.id)},p=new Vn(e.id,z=>{let f={jsonrpc:"2.0",id:e.id,...z};return n?n(f):this.sendWireMessage(f)},a.signal,u);return i!==void 0&&ga.set(p,i),{kind:"request",method:e.method,params:e.params,raw:e,signal:a.signal,responder:p}}return{kind:"notification",method:e.method,params:e.params,raw:e}}handleResponse(e){let n=this.pendingResponses.get(e.id);if(n)if(this.pendingResponses.delete(e.id),n.cleanup?.(),!V(e))n.reject(w.invalidRequest(e));else if("result"in e)n.resolve(e.result);else{let{code:i,message:a,data:u}=e.error;n.reject(new w(i,a,u))}else console.error("Got response to unknown request",e.id)}handleProtocolNotification(e){if(e.method!==hs)return;let n=da(e.params);if(n===void 0)return;let i=this.incomingRequests.get(n);!i||i.signal.aborted||i.abort(w.requestCancelled({requestId:n}))}closedReason(){return this.abortController.signal.reason??new Error("ACP connection closed")}async sendWireMessage(e){return this.abortController.signal.aborted?Y(this.closedReason()):(this.writeQueue=this.writeQueue.then(async()=>{if(this.abortController.signal.aborted)throw this.closedReason();let n=this.stream.writable.getWriter();try{await n.write(e)}finally{n.releaseLock()}}).catch(n=>{throw this.close(n),n}),this.writeQueue)}},Yn=class{handlers=[];connectionName;name(e){return this.connectionName=e,this}withHandler(e){return this.handlers.push(e),this}onReceiveMessage(e){return this.withHandler({handleMessage:async(n,i)=>await e(n,i)??D.no(n),describe:()=>this.connectionName??"onReceiveMessage"})}onReceiveRequest(e,n,i){return this.withHandler({handleMessage:async(a,u)=>{if(a.kind!=="request"||a.method!==e)return D.no(a);let p=n(a.params);return await i(p,a.responder,u)??D.yes()},describe:()=>`${this.connectionName??"request"}:${e}`})}onReceiveNotification(e,n,i){return this.withHandler({handleMessage:async(a,u)=>{if(a.kind!=="notification"||a.method!==e)return D.no(a);let p=n(a.params);return await i(p,u)??D.yes()},describe:()=>`${this.connectionName??"notification"}:${e}`})}connect(e,n){return new ie(e,this.handlers,n)}connectWith(e,n,i){return this.connect(e,i).runUntil(n)}},w=class t extends Error{code;data;constructor(e,n,i){super(n),this.code=e,this.name="RequestError",this.data=i}static parseError(e,n){return new t(-32700,`Parse error${n?`: ${n}`:""}`,e)}static invalidRequest(e,n){return new t(-32600,`Invalid request${n?`: ${n}`:""}`,e)}static methodNotFound(e){return new t(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,n){return new t(-32602,`Invalid params${n?`: ${n}`:""}`,e)}static internalError(e,n){return new t(-32603,`Internal error${n?`: ${n}`:""}`,e)}static requestCancelled(e,n){return new t(-32800,`Request cancelled${n?`: ${n}`:""}`,e)}static authRequired(e,n){return new t(-32e3,`Authentication required${n?`: ${n}`:""}`,e)}static resourceNotFound(e){return new t(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};function L(t){return{jsonrpc:"2.0",id:null,error:t.toErrorResponse()}}var fe=class{#e=[];push(e){let n=[],i=0,a=e.indexOf(10,i);for(;a!==-1;)n.push(this.#n(e.subarray(i,a))),i=a+1,a=e.indexOf(10,i);return i<e.byteLength&&this.#e.push(i===0?e:new Uint8Array(e.subarray(i))),n}flush(){if(this.#e.length!==0)return this.#n(new Uint8Array(0))}#n(e){if(this.#e.length===0)return e;let n=e.byteLength;for(let u of this.#e)n+=u.byteLength;let i=new Uint8Array(n),a=0;for(let u of this.#e)i.set(u,a),a+=u.byteLength;return i.set(e,a),this.#e=[],i}};function fs(t,e){let n=new TextEncoder,i=new TextDecoder,a=!1,u,p=Promise.resolve(),z=m=>{let y=JSON.stringify(m)+`
5
5
  `,C=p.then(async()=>{let k=t.getWriter();try{await k.write(n.encode(y))}finally{k.releaseLock()}});return p=C.catch(()=>{}),C},f=new ReadableStream({async start(m){let y=new fe,C=async M=>{let U=i.decode(M).trim();if(!U)return;let H;try{H=JSON.parse(U)}catch{await z(L(w.parseError()));return}I(H)||Array.isArray(H)?m.enqueue(H):await z(L(w.invalidRequest(H)))},k=e.getReader();u=k;try{for(;;){let{value:U,done:H}=await k.read();if(a)return;if(H)break;if(U){for(let We of y.push(U))if(await C(We),a)return}}if(a)return;let M=y.flush();M&&await C(M)}catch(M){if(a)return;m.error(M);return}finally{u===k&&(u=void 0),k.releaseLock()}a||m.close()},cancel(m){return a=!0,u?.cancel(m)}}),g=new WritableStream({write(m){return z(m)}});return{readable:f,writable:g}}var Ac=hn.and(r({mode:l("form")})).and(r({message:s()})),Ic=pn.and(r({mode:l("url")})).and(r({message:s()})),Mc=b([le,he]).and(r({message:s()})),jc=rn.and(r({type:l("string")})),Oc=an.and(r({type:l("number")})),Dc=cn.and(r({type:l("integer")})),qc=dn.and(r({type:l("boolean")})),Hc=ln.and(r({type:l("array")})),Pc=un.and(r({type:l("string")}));var Lc=Pn.and(r({action:l("accept")})),Gc=r({action:l("decline")}),Uc=r({action:l("cancel")});function bs(t,e){return fs(t,e)}function j(t){return t??{}}function _s(t){return typeof t=="object"&&t!==null&&"readable"in t&&"writable"in t}function ws(){let t=new TransformStream,e=new TransformStream;return[{readable:e.readable,writable:t.writable},{readable:t.readable,writable:e.writable}]}var q={agent:{initialize:h.initialize,authenticate:h.authenticate,logout:h.logout,providers:{list:h.providers_list,set:h.providers_set,disable:h.providers_disable},session:{new:h.session_new,load:h.session_load,list:h.session_list,delete:h.session_delete,fork:h.session_fork,resume:h.session_resume,close:h.session_close,setMode:h.session_set_mode,setConfigOption:h.session_set_config_option,prompt:h.session_prompt,cancel:h.session_cancel},nes:{start:h.nes_start,suggest:h.nes_suggest,accept:h.nes_accept,reject:h.nes_reject,close:h.nes_close},document:{didOpen:h.document_did_open,didChange:h.document_did_change,didClose:h.document_did_close,didSave:h.document_did_save,didFocus:h.document_did_focus}},client:{session:{requestPermission:_.session_request_permission,update:_.session_update},fs:{writeTextFile:_.fs_write_text_file,readTextFile:_.fs_read_text_file},terminal:{create:_.terminal_create,output:_.terminal_output,release:_.terminal_release,waitForExit:_.terminal_wait_for_exit,kill:_.terminal_kill},elicitation:{create:_.elicitation_create,complete:_.elicitation_complete}},protocol:{cancelRequest:Je.cancel_request}},Ss=Symbol("startActiveSession"),Ne=class{cx;currentRequestId;constructor(e,n){this.cx=e,this.currentRequestId=n}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(e,n,i,a){return this.cx.sendRequest(e,n,i,a)}sendNotification(e,n){return this.cx.sendNotification(e,n)}addDynamicHandler(e){return this.cx.addDynamicHandler(e)}},ze=class t extends Ne{constructor(e,n){super(e,n)}static create(e,n){return new t(e,n)}request(e,n,i){let a=rt[e];return this.sendRequest(e,n,a?.mapResponse,i)}notify(e,n){return this.sendNotification(e,n)}},me=class t extends Ne{constructor(e,n){super(e,n)}static create(e,n){return new t(e,n)}[Ss](e,n){return this.sendRequest(h.session_new,e,i=>this.attachSession(i),n)}buildSession(e){return typeof e=="string"?Ie.create(this,{cwd:e,mcpServers:[]}):Ie.create(this,e)}attachSession(e){let n=new nt,i=this.connectionContext.signal,a=()=>{n.fail(i.reason??new Error("ACP connection closed"))};i.aborted?a():i.addEventListener("abort",a);let u=ks(this.connectionContext).attach(e,n),p=new se(()=>{i.removeEventListener("abort",a)});return tt.create(this,e,n,[u,p])}request(e,n,i){let a=Cs[e];return this.sendRequest(e,n,a?.mapResponse,i)}notify(e,n){return this.sendNotification(e,n)}},Ae=class{connection;constructor(e){this.connection=e}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(e){this.connection.close(e)}},Xn=class extends Ae{connectHandlers;client;didStartConnectHandlers=!1;constructor(e,n=[]){super(e),this.connectHandlers=n,this.client=ze.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,Oe(this,this.connectHandlers))}},et=class extends Ae{connectHandlers;agent;didStartConnectHandlers=!1;constructor(e,n=[]){super(e),this.connectHandlers=n,this.agent=me.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,Oe(this,this.connectHandlers))}};function Es(t,e=[]){return new Xn(t,e)}function xs(t,e=[]){return new et(t,e)}var nt=class{values=[];waiters=[];failed=!1;failure;enqueue(e){if(this.failed)return;let n=this.waiters.shift();n?n.resolve(e):this.values.push({kind:"value",value:e})}reject(e){if(!this.failed){if(this.waiters.length>0){for(let n of this.waiters.splice(0))n.reject(e);return}this.values.push({kind:"error",error:e})}}clearErrors(){this.values=this.values.filter(e=>e.kind==="value")}fail(e){if(!this.failed){this.failed=!0,this.failure=e;for(let n of this.waiters.splice(0))n.reject(e)}}next(){if(this.values.length>0){let e=this.values.shift();return e.kind==="error"?Promise.reject(e.error):Promise.resolve(e.value)}return this.failed?Promise.reject(this.failure):new Promise((e,n)=>{this.waiters.push({resolve:e,reject:n})})}};function zs(t){return{...t,additionalDirectories:t.additionalDirectories?[...t.additionalDirectories]:void 0,mcpServers:[...t.mcpServers]}}var Ie=class t{cx;request;constructor(e,n){this.cx=e,this.request=zs(n)}static create(e,n){return new t(e,n)}toRequest(){return zs(this.request)}withAdditionalDirectories(e){return this.request={...this.request,additionalDirectories:[...e]},this}withMcpServer(e){return this.request={...this.request,mcpServers:[...this.request.mcpServers,e]},this}async start(e){return this.cx[Ss](this.toRequest(),e)}async withSession(e){let n=await this.start();try{return await e(n)}finally{n.dispose()}}},tt=class t{cx;sessionResponse;updates;registrations;constructor(e,n,i,a){this.cx=e,this.sessionResponse=n,this.updates=i,this.registrations=a}static create(e,n,i,a){return new t(e,n,i,a)}get sessionId(){return this.sessionResponse.sessionId}get modes(){return this.sessionResponse.modes}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(e,n){this.updates.clearErrors();let i=this.cx.request(h.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(e)},n);return i.then(a=>{this.updates.enqueue({kind:"stop",response:a,stopReason:a.stopReason})},a=>{this.updates.reject(a)}),i}nextUpdate(){return this.updates.next()}async readText(){let e="";for(;;){let n=await this.nextUpdate();if(n.kind==="stop")return e;let{update:i}=n;i.sessionUpdate==="agent_message_chunk"&&i.content.type==="text"&&(e+=i.content.text)}}dispose(){for(let e of this.registrations.splice(0))e.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e:[e]}};function Rs(t,e){return t?typeof t=="function"?t(e):t.parse(e):e}function R(t,e,n){return{method:t,params:e,mapResponse:n}}function G(t,e){return{method:t,params:e}}function ys(t,e,n,i){t.onReceiveRequest(e.method,a=>Rs(e.params,a),async(a,u,p)=>{let z=await i(n(a,p,u.signal,u.id));await u.respond(e.mapResponse?e.mapResponse(z):z)})}function Ts(t,e,n,i){t.onReceiveNotification(e.method,a=>Rs(e.params,a),(a,u)=>i(n(a,u,u.signal)))}function je(t){let e={};for(let n of Object.values(t))e[n.method]=n;return e}var ba={initialize:R(h.initialize,wn),newSession:R(h.session_new,Tn),loadSession:R(h.session_load,Cn,j),unstable_forkSession:R(h.session_fork,Nn),listSessions:R(h.session_list,kn),deleteSession:R(h.session_delete,vn,j),resumeSession:R(h.session_resume,An),closeSession:R(h.session_close,In,j),setSessionMode:R(h.session_set_mode,Mn,j),setSessionConfigOption:R(h.session_set_config_option,jn),authenticate:R(h.authenticate,Sn,j),unstable_listProviders:R(h.providers_list,En),unstable_setProvider:R(h.providers_set,xn,j),unstable_disableProvider:R(h.providers_disable,Rn,j),logout:R(h.logout,yn,j),prompt:R(h.session_prompt,On),unstable_startNes:R(h.nes_start,Dn),unstable_suggestNes:R(h.nes_suggest,qn),unstable_closeNes:R(h.nes_close,Hn,j)},_a={cancel:G(h.session_cancel,Ln),unstable_didOpenDocument:G(h.document_did_open,Gn),unstable_didChangeDocument:G(h.document_did_change,Un),unstable_didCloseDocument:G(h.document_did_close,Fn),unstable_didSaveDocument:G(h.document_did_save,Wn),unstable_didFocusDocument:G(h.document_did_focus,Bn),unstable_acceptNes:G(h.nes_accept,$n),unstable_rejectNes:G(h.nes_reject,Jn)},wa={requestPermission:R(_.session_request_permission,Xe),writeTextFile:R(_.fs_write_text_file,Ye,j),readTextFile:R(_.fs_read_text_file,Qe),createTerminal:R(_.terminal_create,en),terminalOutput:R(_.terminal_output,nn),releaseTerminal:R(_.terminal_release,tn,j),waitForTerminalExit:R(_.terminal_wait_for_exit,sn),killTerminal:R(_.terminal_kill,on,j),createElicitation:R(_.elicitation_create,fn)},Sa={sessionUpdate:G(_.session_update,Te),completeElicitation:G(_.elicitation_complete,_n)},Cs=je(ba),Ea=je(_a),rt=je(wa),xa=je(Sa);function Ra(t,e,n,i){return{params:t,requestId:i,signal:n,client:e}}function ya(t,e,n){return{params:t,signal:n,client:e}}function Ta(t,e,n,i){return{params:t,requestId:i,signal:n,agent:e}}function Ca(t,e,n){return{params:t,signal:n,agent:e}}var st=class{activeSessions=new Map;handleMessage(e){if(e.kind!=="notification"||e.method!==_.session_update)return D.no(e);let n=Te.parse(e.params),i={kind:"session_update",notification:n,update:n.update},a=this.activeSessions.get(n.sessionId);if(a&&a.size>0)for(let u of a)u.enqueue(i);return D.no(e)}attach(e,n){let i=this.activeSessions.get(e.sessionId)??new Set;return i.add(n),this.activeSessions.set(e.sessionId,i),new se(()=>{i.delete(n),i.size===0&&this.activeSessions.delete(e.sessionId)})}},ms=new WeakMap;function ks(t){let e=ms.get(t);return e||(e=new st,ms.set(t,e)),e}function Oe(t,e){for(let n of e){let i;try{i=n(t)}catch(a){throw t.close(a),a}Promise.resolve(i).catch(a=>{t.close(a)})}}var Q=Symbol("appBuilder"),ke=Symbol("runAgentConnectHandlers"),ve=Symbol("runClientConnectHandlers"),ge={allowBatches:!1};function at(t){return new it(t)}var it=class{builder=ie.builder();connectHandlers=[];constructor(e={}){e.name&&this.builder.name(e.name)}[Q](){return this.builder}[ke](e){Oe(e,this.connectHandlers)}connect(e,n={}){return this.connectConnection(e,n).connection}connectWith(e,n){let{rawConnection:i,connection:a}=this.connectConnection(e);return i.runUntil(()=>n(a.client))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,n,i){if(i)return this.request({method:e,params:n},i);let a=Cs[e];if(!a)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(a,n)}onNotification(e,n,i){if(i)return this.notification({method:e,params:n},i);let a=Ea[e];if(!a)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(a,n)}request(e,n){return ys(this.builder,e,(i,a,u,p)=>Ra(i,ze.create(a,p),u,p),n),this}notification(e,n){return Ts(this.builder,e,(i,a,u)=>ya(i,ze.create(a),u),n),this}connectConnection(e,n={}){if(_s(e)){let f=this.openStreamConnection(e);return n.deferConnectHandlers||this[ke](f.connection),f}let[i,a]=ws(),u=e[Q]().connect(a,ge),p=xs(u),z=this.openStreamConnection(i);z.rawConnection.closed.then(()=>p.close()),u.closed.then(()=>z.connection.close());try{e[ve](p),this[ke](z.connection)}catch(f){throw p.close(f),z.connection.close(f),f}return z}openStreamConnection(e){let n=this.builder.connect(e,ge);return{rawConnection:n,connection:Es(n,this.connectHandlers)}}};var gs=class{builder=ie.builder();connectHandlers=[];constructor(e={}){e.name&&this.builder.name(e.name),this.builder.withHandler({handleMessage:(n,i)=>ks(i).handleMessage(n),describe:()=>"client-session-update-router"})}[Q](){return this.builder}[ve](e){Oe(e,this.connectHandlers)}connect(e){return this.connectConnection(e).connection}connectWith(e,n){let{rawConnection:i,connection:a}=this.connectConnection(e);return i.runUntil(()=>n(a.agent))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,n,i){if(i)return this.request({method:e,params:n},i);let a=rt[e];if(!a)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(a,n)}onNotification(e,n,i){if(i)return this.notification({method:e,params:n},i);let a=xa[e];if(!a)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(a,n)}request(e,n){return ys(this.builder,e,(i,a,u,p)=>Ta(i,me.create(a,p),u,p),n),this}notification(e,n){return Ts(this.builder,e,(i,a,u)=>Ca(i,me.create(a),u),n),this}connectConnection(e){if(_s(e)){let z=this.openStreamConnection(e);return this[ve](z.connection),z}let[n,i]=ws(),a=e[Q]().connect(i,ge),u=Es(a),p=this.openStreamConnection(n);p.rawConnection.closed.then(()=>u.close()),a.closed.then(()=>p.connection.close());try{e[ke](u),this[ve](p.connection)}catch(z){throw u.close(z),p.connection.close(z),z}return p}openStreamConnection(e){let n=this.builder.connect(e,ge);return{rawConnection:n,connection:xs(n,this.connectHandlers)}}},ka=new Set([h.initialize,h.authenticate,h.providers_list,h.providers_set,h.providers_disable,h.session_new,h.session_load,h.session_set_mode,h.session_set_config_option,h.session_prompt,h.session_list,h.session_delete,h.session_fork,h.session_resume,h.session_close,h.logout,h.nes_start,h.nes_suggest,h.nes_close]),va=new Set([h.session_cancel,h.nes_accept,h.nes_reject,h.document_did_open,h.document_did_change,h.document_did_close,h.document_did_save,h.document_did_focus]),Yc=new Set([_.session_request_permission,_.fs_write_text_file,_.fs_read_text_file,_.terminal_create,_.terminal_output,_.terminal_release,_.terminal_wait_for_exit,_.terminal_kill,_.elicitation_create]),Qc=new Set([_.session_update,_.elicitation_complete]);function Na(t){let e=at().onRequest(h.initialize,n=>t.initialize(n.params)).onRequest(h.session_new,n=>t.newSession(n.params)).onRequest(h.authenticate,async n=>await t.authenticate(n.params)??{}).onRequest(h.session_prompt,n=>t.prompt(n.params)).onNotification(h.session_cancel,n=>t.cancel(n.params));return t.loadSession&&e.onRequest(h.session_load,n=>t.loadSession(n.params)),t.listSessions&&e.onRequest(h.session_list,n=>t.listSessions(n.params)),t.deleteSession&&e.onRequest(h.session_delete,async n=>await t.deleteSession(n.params)??{}),t.unstable_forkSession&&e.onRequest(h.session_fork,n=>t.unstable_forkSession(n.params)),t.resumeSession&&e.onRequest(h.session_resume,n=>t.resumeSession(n.params)),t.closeSession&&e.onRequest(h.session_close,async n=>await t.closeSession(n.params)??{}),t.setSessionMode&&e.onRequest(h.session_set_mode,async n=>await t.setSessionMode(n.params)??{}),t.setSessionConfigOption&&e.onRequest(h.session_set_config_option,n=>t.setSessionConfigOption(n.params)),t.unstable_listProviders&&e.onRequest(h.providers_list,n=>t.unstable_listProviders(n.params)),t.unstable_setProvider&&e.onRequest(h.providers_set,async n=>await t.unstable_setProvider(n.params)??{}),t.unstable_disableProvider&&e.onRequest(h.providers_disable,async n=>await t.unstable_disableProvider(n.params)??{}),t.logout&&e.onRequest(h.logout,async n=>await t.logout(n.params)??{}),t.unstable_startNes&&e.onRequest(h.nes_start,n=>t.unstable_startNes(n.params)),t.unstable_suggestNes&&e.onRequest(h.nes_suggest,n=>t.unstable_suggestNes(n.params)),t.unstable_closeNes&&e.onRequest(h.nes_close,async n=>await t.unstable_closeNes(n.params)??{}),t.unstable_didOpenDocument&&e.onNotification(h.document_did_open,n=>t.unstable_didOpenDocument(n.params)),t.unstable_didChangeDocument&&e.onNotification(h.document_did_change,n=>t.unstable_didChangeDocument(n.params)),t.unstable_didCloseDocument&&e.onNotification(h.document_did_close,n=>t.unstable_didCloseDocument(n.params)),t.unstable_didSaveDocument&&e.onNotification(h.document_did_save,n=>t.unstable_didSaveDocument(n.params)),t.unstable_didFocusDocument&&e.onNotification(h.document_did_focus,n=>t.unstable_didFocusDocument(n.params)),t.unstable_acceptNes&&e.onNotification(h.nes_accept,n=>t.unstable_acceptNes(n.params)),t.unstable_rejectNes&&e.onNotification(h.nes_reject,n=>t.unstable_rejectNes(n.params)),t.extMethod&&e[Q]().withHandler({handleMessage:async n=>n.kind!=="request"||ka.has(n.method)?D.no(n):(await n.responder.respond(await t.extMethod(n.method,n.params)),D.yes()),describe:()=>"legacy-agent-extension-request"}),t.extNotification&&e[Q]().withHandler({handleMessage:async n=>n.kind!=="notification"||va.has(n.method)?D.no(n):(await t.extNotification(n.method,n.params),D.yes()),describe:()=>"legacy-agent-extension-notification"}),e}var Me=class{connection;constructor(e,n){this.connection=Na(e(this))[Q]().connect(n,ge)}sessionUpdate(e){return this.connection.sendNotification(_.session_update,e)}requestPermission(e){return this.connection.sendRequest(_.session_request_permission,e)}readTextFile(e){return this.connection.sendRequest(_.fs_read_text_file,e)}writeTextFile(e){return this.connection.sendRequest(_.fs_write_text_file,e,j)}createTerminal(e){return this.connection.sendRequest(_.terminal_create,e,n=>ot.create(n.terminalId,e.sessionId,this.connection))}createElicitation(e){return this.connection.sendRequest(_.elicitation_create,e)}completeElicitation(e){return this.connection.sendNotification(_.elicitation_complete,e)}request(e,n,i){let a=rt[e];return this.connection.sendRequest(e,n,a?.mapResponse,i)}notify(e,n){return this.connection.sendNotification(e,n)}extMethod(e,n){return this.request(e,n)}extNotification(e,n){return this.notify(e,n)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},ot=class t{id;sessionId;connection;constructor(e,n,i){this.id=e,this.sessionId=n,this.connection=i}static create(e,n,i){return new t(e,n,i)}currentOutput(){return this.connection.sendRequest(_.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}waitForExit(){return this.connection.sendRequest(_.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}kill(){return this.connection.sendRequest(_.terminal_kill,{sessionId:this.sessionId,terminalId:this.id},j)}release(){return this.connection.sendRequest(_.terminal_release,{sessionId:this.sessionId,terminalId:this.id},j)}async[Symbol.asyncDispose](){await this.release()}};var js={};Se(js,{YukinoAcpAgent:()=>He,createYukinoAcpApp:()=>be});import{existsSync as ja}from"fs";import{isAbsolute as Oa}from"path";var As={};Se(As,{addUsage:()=>ut,agentEventToUpdate:()=>dt,emptyUsage:()=>lt,historyNotifications:()=>pt,promptToText:()=>ct,stopReason:()=>ht,toolKind:()=>De,toolLocations:()=>qe});import{isAbsolute as Ia,resolve as Ma}from"path";function ct(t){let e=[];for(let i of t)switch(i.type){case"text":i.text.trim()&&e.push(i.text);break;case"resource_link":e.push(`Resource: ${i.name} (${i.uri})`);break;case"resource":if("text"in i.resource){e.push(`Resource: ${i.resource.uri}
6
6
  ${i.resource.text}`);break}throw w.invalidParams(void 0,"Binary resources are not supported.");case"image":throw w.invalidParams(void 0,"Image prompts are not supported.");case"audio":throw w.invalidParams(void 0,"Audio prompts are not supported.")}let n=e.join(`
7
7
 
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{I as b,J as c,g as a}from"./chunk-OAFPGTZY.js";import"./chunk-QG22QNQJ.js";import"./chunk-JFKC4VCA.js";import"./chunk-OFC2GD5K.js";import"./chunk-7DLUKIPE.js";import"./chunk-XO7ITAWR.js";import"./chunk-UPNNYP7M.js";import"./chunk-GYBJR2RB.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import"./chunk-7MKA3SHV.js";export{c as Agent,b as Events,a as StreamingExecutor};
4
+ import{I as b,J as c,g as a}from"./chunk-ZETIYALB.js";import"./chunk-JNCMSXQZ.js";import"./chunk-JFKC4VCA.js";import"./chunk-OFC2GD5K.js";import"./chunk-7DLUKIPE.js";import"./chunk-XO7ITAWR.js";import"./chunk-UPNNYP7M.js";import"./chunk-GYBJR2RB.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import"./chunk-7MKA3SHV.js";export{c as Agent,b as Events,a as StreamingExecutor};
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{a as No,c as Ah,d as Oh,g as Ih}from"./chunk-HLE7243Q.js";import{A as $h,E as Ph,F as Ch,H as Rh,J as zo,f as Mo,j as xh,k as Th,l as Eh,m as Oo,o as Kr}from"./chunk-OAFPGTZY.js";import{a as _h}from"./chunk-QG22QNQJ.js";import{b as Io}from"./chunk-OFC2GD5K.js";import{a as ft,b as ih,c as Eo,d as $o,e as Co,f as Ro,g as Ja,i as mh,j as gh,l as yh,m as wh,s as bh,t as vh}from"./chunk-7DLUKIPE.js";import{e as Mh,f as Zr}from"./chunk-RCXKUD3Y.js";import{a as ec}from"./chunk-XO7ITAWR.js";import{a as Ye,f as z,g as Ao,h as Xa,j as Qa,k as Sh,l as kh,m as Hs,o as A,q as It,r as Gs,s as $,t as Yt}from"./chunk-UPNNYP7M.js";import{A as hh,B as ph,C as fh,D as y,a as oh,d as tt,e as Po,f as ah,g as b,h as ch,i as V,k as Y,l as lh,m as uh,n as ce,o as E,p as P,q as he,r as se,s as Ka,t as Za,u as ee,v as Je,w as R,x as ae,y as dh,z as Ya}from"./chunk-GYBJR2RB.js";import{a as Zt,c as T,e as To}from"./chunk-7MKA3SHV.js";var nn=T(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.regexpCode=K.getEsmExportName=K.getProperty=K.safeStringify=K.stringify=K.strConcat=K.addCodeArg=K.str=K._=K.nil=K._Code=K.Name=K.IDENTIFIER=K._CodeOrName=void 0;var rn=class{};K._CodeOrName=rn;K.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Sr=class extends rn{constructor(e){if(super(),!K.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};K.Name=Sr;var nt=class extends rn{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(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,s)=>`${r}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,s)=>(s instanceof Sr&&(r[s.str]=(r[s.str]||0)+1),r),{})}};K._Code=nt;K.nil=new nt("");function rp(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Mc(r,e[s]),r.push(t[++s]);return new nt(r)}K._=rp;var Rc=new nt("+");function sp(t,...e){let r=[sn(t[0])],s=0;for(;s<e.length;)r.push(Rc),Mc(r,e[s]),r.push(Rc,sn(t[++s]));return aS(r),new nt(r)}K.str=sp;function Mc(t,e){e instanceof nt?t.push(...e._items):e instanceof Sr?t.push(e):t.push(uS(e))}K.addCodeArg=Mc;function aS(t){let e=1;for(;e<t.length-1;){if(t[e]===Rc){let r=cS(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function cS(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Sr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Sr))return`"${t}${e.slice(1)}`}function lS(t,e){return e.emptyStr()?t:t.emptyStr()?e:sp`${t}${e}`}K.strConcat=lS;function uS(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:sn(Array.isArray(t)?t.join(","):t)}function dS(t){return new nt(sn(t))}K.stringify=dS;function sn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}K.safeStringify=sn;function hS(t){return typeof t=="string"&&K.IDENTIFIER.test(t)?new nt(`.${t}`):rp`[${t}]`}K.getProperty=hS;function pS(t){if(typeof t=="string"&&K.IDENTIFIER.test(t))return new nt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}K.getEsmExportName=pS;function fS(t){return new nt(t.toString())}K.regexpCode=fS});var Ic=T(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.ValueScope=Be.ValueScopeName=Be.Scope=Be.varKinds=Be.UsedValueState=void 0;var Ue=nn(),Ac=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Yo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Yo||(Be.UsedValueState=Yo={}));Be.varKinds={const:new Ue.Name("const"),let:new Ue.Name("let"),var:new Ue.Name("var")};var Jo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ue.Name?e:this.name(e)}name(e){return new Ue.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,s;if(!((s=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Be.Scope=Jo;var Xo=class extends Ue.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,Ue._)`.${new Ue.Name(r)}[${s}]`}};Be.ValueScopeName=Xo;var mS=(0,Ue._)`\n`,Oc=class extends Jo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?mS:Ue.nil}}get(){return this._scope}name(e){return new Xo(e,this._newName(e))}value(e,r){var s;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(e),{prefix:o}=n,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[o];if(a){let u=a.get(i);if(u)return u}else a=this._values[o]=new Map;a.set(i,n);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,n.setValue(r,{property:o,itemIndex:l}),n}getValue(e,r){let s=this._values[e];if(s)return s.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,Ue._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,s)}_reduceValues(e,r,s={},n){let o=Ue.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,Yo.Started);let u=r(l);if(u){let d=this.opts.es5?Be.varKinds.var:Be.varKinds.const;o=(0,Ue._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=n?.(l))o=(0,Ue._)`${o}${u}${this.opts._n}`;else throw new Ac(l);c.set(l,Yo.Completed)})}return o}};Be.ValueScope=Oc});var L=T(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.or=F.and=F.not=F.CodeGen=F.operators=F.varKinds=F.ValueScopeName=F.ValueScope=F.Scope=F.Name=F.regexpCode=F.stringify=F.getProperty=F.nil=F.strConcat=F.str=F._=void 0;var W=nn(),mt=Ic(),er=nn();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return er._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return er.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return er.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return er.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return er.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return er.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return er.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return er.Name}});var ri=Ic();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return ri.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return ri.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return ri.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return ri.varKinds}});F.operators={GT:new W._Code(">"),GTE:new W._Code(">="),LT:new W._Code("<"),LTE:new W._Code("<="),EQ:new W._Code("==="),NEQ:new W._Code("!=="),NOT:new W._Code("!"),OR:new W._Code("||"),AND:new W._Code("&&"),ADD:new W._Code("+")};var Nt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},zc=class extends Nt{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?mt.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ts(this.rhs,e,r)),this}get names(){return this.rhs instanceof W._CodeOrName?this.rhs.names:{}}},Qo=class extends Nt{constructor(e,r,s){super(),this.lhs=e,this.rhs=r,this.sideEffects=s}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof W.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ts(this.rhs,e,r),this}get names(){let e=this.lhs instanceof W.Name?{}:{...this.lhs.names};return ti(e,this.rhs)}},Nc=class extends Qo{constructor(e,r,s,n){super(e,s,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},jc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Dc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},qc=class extends Nt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Lc=class extends Nt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=ts(this.code,e,r),this}get names(){return this.code instanceof W._CodeOrName?this.code.names:{}}},on=class extends Nt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,s)=>r+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let s=e[r].optimizeNodes();Array.isArray(s)?e.splice(r,1,...s):s?e[r]=s:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:s}=this,n=s.length;for(;n--;){let o=s[n];o.optimizeNames(e,r)||(gS(e,o.names),s.splice(n,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Tr(e,r.names),{})}},jt=class extends on{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Fc=class extends on{},es=class extends jt{};es.kind="else";var kr=class t extends jt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let s=r.optimizeNodes();r=this.else=Array.isArray(s)?new es(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(np(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=ts(this.condition,e,r),this}get names(){let e=super.names;return ti(e,this.condition),this.else&&Tr(e,this.else.names),e}};kr.kind="if";var xr=class extends jt{};xr.kind="for";var Uc=class extends xr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=ts(this.iteration,e,r),this}get names(){return Tr(super.names,this.iteration.names)}},Bc=class extends xr{constructor(e,r,s,n){super(),this.varKind=e,this.name=r,this.from=s,this.to=n}render(e){let r=e.es5?mt.varKinds.var:this.varKind,{name:s,from:n,to:o}=this;return`for(${r} ${s}=${n}; ${s}<${o}; ${s}++)`+super.render(e)}get names(){let e=ti(super.names,this.from);return ti(e,this.to)}},ei=class extends xr{constructor(e,r,s,n){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=ts(this.iterable,e,r),this}get names(){return Tr(super.names,this.iterable.names)}},an=class extends jt{constructor(e,r,s){super(),this.name=e,this.args=r,this.async=s}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};an.kind="func";var cn=class extends on{render(e){return"return "+super.render(e)}};cn.kind="return";var Wc=class extends jt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var s,n;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Tr(e,this.catch.names),this.finally&&Tr(e,this.finally.names),e}},ln=class extends jt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ln.kind="catch";var un=class extends jt{render(e){return"finally"+super.render(e)}};un.kind="finally";var Hc=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
4
+ import{a as No,c as Ah,d as Oh,g as Ih}from"./chunk-HLE7243Q.js";import{A as $h,E as Ph,F as Ch,H as Rh,J as zo,f as Mo,j as xh,k as Th,l as Eh,m as Oo,o as Kr}from"./chunk-ZETIYALB.js";import{a as _h}from"./chunk-JNCMSXQZ.js";import{b as Io}from"./chunk-OFC2GD5K.js";import{a as ft,b as ih,c as Eo,d as $o,e as Co,f as Ro,g as Ja,i as mh,j as gh,l as yh,m as wh,s as bh,t as vh}from"./chunk-7DLUKIPE.js";import{e as Mh,f as Zr}from"./chunk-RCXKUD3Y.js";import{a as ec}from"./chunk-XO7ITAWR.js";import{a as Ye,f as z,g as Ao,h as Xa,j as Qa,k as Sh,l as kh,m as Hs,o as A,q as It,r as Gs,s as $,t as Yt}from"./chunk-UPNNYP7M.js";import{A as hh,B as ph,C as fh,D as y,a as oh,d as tt,e as Po,f as ah,g as b,h as ch,i as V,k as Y,l as lh,m as uh,n as ce,o as E,p as P,q as he,r as se,s as Ka,t as Za,u as ee,v as Je,w as R,x as ae,y as dh,z as Ya}from"./chunk-GYBJR2RB.js";import{a as Zt,c as T,e as To}from"./chunk-7MKA3SHV.js";var nn=T(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.regexpCode=K.getEsmExportName=K.getProperty=K.safeStringify=K.stringify=K.strConcat=K.addCodeArg=K.str=K._=K.nil=K._Code=K.Name=K.IDENTIFIER=K._CodeOrName=void 0;var rn=class{};K._CodeOrName=rn;K.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Sr=class extends rn{constructor(e){if(super(),!K.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};K.Name=Sr;var nt=class extends rn{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(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,s)=>`${r}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,s)=>(s instanceof Sr&&(r[s.str]=(r[s.str]||0)+1),r),{})}};K._Code=nt;K.nil=new nt("");function rp(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Mc(r,e[s]),r.push(t[++s]);return new nt(r)}K._=rp;var Rc=new nt("+");function sp(t,...e){let r=[sn(t[0])],s=0;for(;s<e.length;)r.push(Rc),Mc(r,e[s]),r.push(Rc,sn(t[++s]));return aS(r),new nt(r)}K.str=sp;function Mc(t,e){e instanceof nt?t.push(...e._items):e instanceof Sr?t.push(e):t.push(uS(e))}K.addCodeArg=Mc;function aS(t){let e=1;for(;e<t.length-1;){if(t[e]===Rc){let r=cS(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function cS(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Sr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Sr))return`"${t}${e.slice(1)}`}function lS(t,e){return e.emptyStr()?t:t.emptyStr()?e:sp`${t}${e}`}K.strConcat=lS;function uS(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:sn(Array.isArray(t)?t.join(","):t)}function dS(t){return new nt(sn(t))}K.stringify=dS;function sn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}K.safeStringify=sn;function hS(t){return typeof t=="string"&&K.IDENTIFIER.test(t)?new nt(`.${t}`):rp`[${t}]`}K.getProperty=hS;function pS(t){if(typeof t=="string"&&K.IDENTIFIER.test(t))return new nt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}K.getEsmExportName=pS;function fS(t){return new nt(t.toString())}K.regexpCode=fS});var Ic=T(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.ValueScope=Be.ValueScopeName=Be.Scope=Be.varKinds=Be.UsedValueState=void 0;var Ue=nn(),Ac=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Yo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Yo||(Be.UsedValueState=Yo={}));Be.varKinds={const:new Ue.Name("const"),let:new Ue.Name("let"),var:new Ue.Name("var")};var Jo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ue.Name?e:this.name(e)}name(e){return new Ue.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,s;if(!((s=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Be.Scope=Jo;var Xo=class extends Ue.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,Ue._)`.${new Ue.Name(r)}[${s}]`}};Be.ValueScopeName=Xo;var mS=(0,Ue._)`\n`,Oc=class extends Jo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?mS:Ue.nil}}get(){return this._scope}name(e){return new Xo(e,this._newName(e))}value(e,r){var s;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(e),{prefix:o}=n,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[o];if(a){let u=a.get(i);if(u)return u}else a=this._values[o]=new Map;a.set(i,n);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,n.setValue(r,{property:o,itemIndex:l}),n}getValue(e,r){let s=this._values[e];if(s)return s.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,Ue._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,s)}_reduceValues(e,r,s={},n){let o=Ue.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,Yo.Started);let u=r(l);if(u){let d=this.opts.es5?Be.varKinds.var:Be.varKinds.const;o=(0,Ue._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=n?.(l))o=(0,Ue._)`${o}${u}${this.opts._n}`;else throw new Ac(l);c.set(l,Yo.Completed)})}return o}};Be.ValueScope=Oc});var L=T(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.or=F.and=F.not=F.CodeGen=F.operators=F.varKinds=F.ValueScopeName=F.ValueScope=F.Scope=F.Name=F.regexpCode=F.stringify=F.getProperty=F.nil=F.strConcat=F.str=F._=void 0;var W=nn(),mt=Ic(),er=nn();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return er._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return er.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return er.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return er.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return er.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return er.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return er.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return er.Name}});var ri=Ic();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return ri.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return ri.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return ri.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return ri.varKinds}});F.operators={GT:new W._Code(">"),GTE:new W._Code(">="),LT:new W._Code("<"),LTE:new W._Code("<="),EQ:new W._Code("==="),NEQ:new W._Code("!=="),NOT:new W._Code("!"),OR:new W._Code("||"),AND:new W._Code("&&"),ADD:new W._Code("+")};var Nt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},zc=class extends Nt{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?mt.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ts(this.rhs,e,r)),this}get names(){return this.rhs instanceof W._CodeOrName?this.rhs.names:{}}},Qo=class extends Nt{constructor(e,r,s){super(),this.lhs=e,this.rhs=r,this.sideEffects=s}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof W.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ts(this.rhs,e,r),this}get names(){let e=this.lhs instanceof W.Name?{}:{...this.lhs.names};return ti(e,this.rhs)}},Nc=class extends Qo{constructor(e,r,s,n){super(e,s,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},jc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Dc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},qc=class extends Nt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Lc=class extends Nt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=ts(this.code,e,r),this}get names(){return this.code instanceof W._CodeOrName?this.code.names:{}}},on=class extends Nt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,s)=>r+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let s=e[r].optimizeNodes();Array.isArray(s)?e.splice(r,1,...s):s?e[r]=s:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:s}=this,n=s.length;for(;n--;){let o=s[n];o.optimizeNames(e,r)||(gS(e,o.names),s.splice(n,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Tr(e,r.names),{})}},jt=class extends on{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Fc=class extends on{},es=class extends jt{};es.kind="else";var kr=class t extends jt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let s=r.optimizeNodes();r=this.else=Array.isArray(s)?new es(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(np(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=ts(this.condition,e,r),this}get names(){let e=super.names;return ti(e,this.condition),this.else&&Tr(e,this.else.names),e}};kr.kind="if";var xr=class extends jt{};xr.kind="for";var Uc=class extends xr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=ts(this.iteration,e,r),this}get names(){return Tr(super.names,this.iteration.names)}},Bc=class extends xr{constructor(e,r,s,n){super(),this.varKind=e,this.name=r,this.from=s,this.to=n}render(e){let r=e.es5?mt.varKinds.var:this.varKind,{name:s,from:n,to:o}=this;return`for(${r} ${s}=${n}; ${s}<${o}; ${s}++)`+super.render(e)}get names(){let e=ti(super.names,this.from);return ti(e,this.to)}},ei=class extends xr{constructor(e,r,s,n){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=ts(this.iterable,e,r),this}get names(){return Tr(super.names,this.iterable.names)}},an=class extends jt{constructor(e,r,s){super(),this.name=e,this.args=r,this.async=s}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};an.kind="func";var cn=class extends on{render(e){return"return "+super.render(e)}};cn.kind="return";var Wc=class extends jt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var s,n;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Tr(e,this.catch.names),this.finally&&Tr(e,this.finally.names),e}},ln=class extends jt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ln.kind="catch";var un=class extends jt{render(e){return"finally"+super.render(e)}};un.kind="finally";var Hc=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
5
  `:""},this._extScope=e,this._scope=new mt.Scope({parent:e}),this._nodes=[new Fc]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let s=this._extScope.value(e,r);return(this._values[s.prefix]||(this._values[s.prefix]=new Set)).add(s),s}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,s,n){let o=this._scope.toName(r);return s!==void 0&&n&&(this._constants[o.str]=s),this._leafNode(new zc(e,o,s)),o}const(e,r,s){return this._def(mt.varKinds.const,e,r,s)}let(e,r,s){return this._def(mt.varKinds.let,e,r,s)}var(e,r,s){return this._def(mt.varKinds.var,e,r,s)}assign(e,r,s){return this._leafNode(new Qo(e,r,s))}add(e,r){return this._leafNode(new Nc(e,F.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==W.nil&&this._leafNode(new Lc(e)),this}object(...e){let r=["{"];for(let[s,n]of e)r.length>1&&r.push(","),r.push(s),(s!==n||this.opts.es5)&&(r.push(":"),(0,W.addCodeArg)(r,n));return r.push("}"),new W._Code(r)}if(e,r,s){if(this._blockNode(new kr(e)),r&&s)this.code(r).else().code(s).endIf();else if(r)this.code(r).endIf();else if(s)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new kr(e))}else(){return this._elseNode(new es)}endIf(){return this._endBlockNode(kr,es)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Uc(e),r)}forRange(e,r,s,n,o=this.opts.es5?mt.varKinds.var:mt.varKinds.let){let i=this._scope.toName(e);return this._for(new Bc(o,i,r,s),()=>n(i))}forOf(e,r,s,n=mt.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof W.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,W._)`${i}.length`,a=>{this.var(o,(0,W._)`${i}[${a}]`),s(o)})}return this._for(new ei("of",n,o,r),()=>s(o))}forIn(e,r,s,n=this.opts.es5?mt.varKinds.var:mt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,W._)`Object.keys(${r})`,s);let o=this._scope.toName(e);return this._for(new ei("in",n,o,r),()=>s(o))}endFor(){return this._endBlockNode(xr)}label(e){return this._leafNode(new jc(e))}break(e){return this._leafNode(new Dc(e))}return(e){let r=new cn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(cn)}try(e,r,s){if(!r&&!s)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new Wc;if(this._blockNode(n),this.code(e),r){let o=this.name("e");this._currNode=n.catch=new ln(o),r(o)}return s&&(this._currNode=n.finally=new un,this.code(s)),this._endBlockNode(ln,un)}throw(e){return this._leafNode(new qc(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let s=this._nodes.length-r;if(s<0||e!==void 0&&s!==e)throw new Error(`CodeGen: wrong number of nodes: ${s} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=W.nil,s,n){return this._blockNode(new an(e,r,s)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(an)}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,r){let s=this._currNode;if(s instanceof e||r&&s instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof kr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};F.CodeGen=Hc;function Tr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function ti(t,e){return e instanceof W._CodeOrName?Tr(t,e.names):t}function ts(t,e,r){if(t instanceof W.Name)return s(t);if(!n(t))return t;return new W._Code(t._items.reduce((o,i)=>(i instanceof W.Name&&(i=s(i)),i instanceof W._Code?o.push(...i._items):o.push(i),o),[]));function s(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function n(o){return o instanceof W._Code&&o._items.some(i=>i instanceof W.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function gS(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function np(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,W._)`!${Gc(t)}`}F.not=np;var yS=op(F.operators.AND);function wS(...t){return t.reduce(yS)}F.and=wS;var bS=op(F.operators.OR);function vS(...t){return t.reduce(bS)}F.or=vS;function op(t){return(e,r)=>e===W.nil?r:r===W.nil?e:(0,W._)`${Gc(e)} ${t} ${Gc(r)}`}function Gc(t){return t instanceof W.Name?t:(0,W._)`(${t})`}});var H=T(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.checkStrictMode=U.getErrorPath=U.Type=U.useFunc=U.setEvaluated=U.evaluatedPropsToName=U.mergeEvaluated=U.eachItem=U.unescapeJsonPointer=U.escapeJsonPointer=U.escapeFragment=U.unescapeFragment=U.schemaRefOrVal=U.schemaHasRulesButRef=U.schemaHasRules=U.checkUnknownRules=U.alwaysValidSchema=U.toHash=void 0;var J=L(),_S=nn();function SS(t){let e={};for(let r of t)e[r]=!0;return e}U.toHash=SS;function kS(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(cp(t,e),!lp(e,t.self.RULES.all))}U.alwaysValidSchema=kS;function cp(t,e=t.schema){let{opts:r,self:s}=t;if(!r.strictSchema||typeof e=="boolean")return;let n=s.RULES.keywords;for(let o in e)n[o]||hp(t,`unknown keyword: "${o}"`)}U.checkUnknownRules=cp;function lp(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}U.schemaHasRules=lp;function xS(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}U.schemaHasRulesButRef=xS;function TS({topSchemaRef:t,schemaPath:e},r,s,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,J._)`${r}`}return(0,J._)`${t}${e}${(0,J.getProperty)(s)}`}U.schemaRefOrVal=TS;function ES(t){return up(decodeURIComponent(t))}U.unescapeFragment=ES;function $S(t){return encodeURIComponent(Kc(t))}U.escapeFragment=$S;function Kc(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}U.escapeJsonPointer=Kc;function up(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}U.unescapeJsonPointer=up;function PS(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}U.eachItem=PS;function ip({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:s}){return(n,o,i,a)=>{let c=i===void 0?o:i instanceof J.Name?(o instanceof J.Name?t(n,o,i):e(n,o,i),i):o instanceof J.Name?(e(n,i,o),o):r(o,i);return a===J.Name&&!(c instanceof J.Name)?s(n,c):c}}U.mergeEvaluated={props:ip({mergeNames:(t,e,r)=>t.if((0,J._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,J._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,J._)`${r} || {}`).code((0,J._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,J._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,J._)`${r} || {}`),Zc(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:dp}),items:ip({mergeNames:(t,e,r)=>t.if((0,J._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,J._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,J._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,J._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function dp(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,J._)`{}`);return e!==void 0&&Zc(t,r,e),r}U.evaluatedPropsToName=dp;function Zc(t,e,r){Object.keys(r).forEach(s=>t.assign((0,J._)`${e}${(0,J.getProperty)(s)}`,!0))}U.setEvaluated=Zc;var ap={};function CS(t,e){return t.scopeValue("func",{ref:e,code:ap[e.code]||(ap[e.code]=new _S._Code(e.code))})}U.useFunc=CS;var Vc;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Vc||(U.Type=Vc={}));function RS(t,e,r){if(t instanceof J.Name){let s=e===Vc.Num;return r?s?(0,J._)`"[" + ${t} + "]"`:(0,J._)`"['" + ${t} + "']"`:s?(0,J._)`"/" + ${t}`:(0,J._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,J.getProperty)(t).toString():"/"+Kc(t)}U.getErrorPath=RS;function hp(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}U.checkStrictMode=hp});var Dt=T(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});var Ee=L(),MS={data:new Ee.Name("data"),valCxt:new Ee.Name("valCxt"),instancePath:new Ee.Name("instancePath"),parentData:new Ee.Name("parentData"),parentDataProperty:new Ee.Name("parentDataProperty"),rootData:new Ee.Name("rootData"),dynamicAnchors:new Ee.Name("dynamicAnchors"),vErrors:new Ee.Name("vErrors"),errors:new Ee.Name("errors"),this:new Ee.Name("this"),self:new Ee.Name("self"),scope:new Ee.Name("scope"),json:new Ee.Name("json"),jsonPos:new Ee.Name("jsonPos"),jsonLen:new Ee.Name("jsonLen"),jsonPart:new Ee.Name("jsonPart")};Yc.default=MS});var dn=T($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.extendErrors=$e.resetErrorsCount=$e.reportExtraError=$e.reportError=$e.keyword$DataError=$e.keywordError=void 0;var G=L(),si=H(),Ie=Dt();$e.keywordError={message:({keyword:t})=>(0,G.str)`must pass "${t}" keyword validation`};$e.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,G.str)`"${t}" keyword must be ${e} ($data)`:(0,G.str)`"${t}" keyword is invalid ($data)`};function AS(t,e=$e.keywordError,r,s){let{it:n}=t,{gen:o,compositeRule:i,allErrors:a}=n,c=mp(t,e,r);s??(i||a)?pp(o,c):fp(n,(0,G._)`[${c}]`)}$e.reportError=AS;function OS(t,e=$e.keywordError,r){let{it:s}=t,{gen:n,compositeRule:o,allErrors:i}=s,a=mp(t,e,r);pp(n,a),o||i||fp(s,Ie.default.vErrors)}$e.reportExtraError=OS;function IS(t,e){t.assign(Ie.default.errors,e),t.if((0,G._)`${Ie.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,G._)`${Ie.default.vErrors}.length`,e),()=>t.assign(Ie.default.vErrors,null)))}$e.resetErrorsCount=IS;function zS({gen:t,keyword:e,schemaValue:r,data:s,errsCount:n,it:o}){if(n===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",n,Ie.default.errors,a=>{t.const(i,(0,G._)`${Ie.default.vErrors}[${a}]`),t.if((0,G._)`${i}.instancePath === undefined`,()=>t.assign((0,G._)`${i}.instancePath`,(0,G.strConcat)(Ie.default.instancePath,o.errorPath))),t.assign((0,G._)`${i}.schemaPath`,(0,G.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,G._)`${i}.schema`,r),t.assign((0,G._)`${i}.data`,s))})}$e.extendErrors=zS;function pp(t,e){let r=t.const("err",e);t.if((0,G._)`${Ie.default.vErrors} === null`,()=>t.assign(Ie.default.vErrors,(0,G._)`[${r}]`),(0,G._)`${Ie.default.vErrors}.push(${r})`),t.code((0,G._)`${Ie.default.errors}++`)}function fp(t,e){let{gen:r,validateName:s,schemaEnv:n}=t;n.$async?r.throw((0,G._)`new ${t.ValidationError}(${e})`):(r.assign((0,G._)`${s}.errors`,e),r.return(!1))}var Er={keyword:new G.Name("keyword"),schemaPath:new G.Name("schemaPath"),params:new G.Name("params"),propertyName:new G.Name("propertyName"),message:new G.Name("message"),schema:new G.Name("schema"),parentSchema:new G.Name("parentSchema")};function mp(t,e,r){let{createErrors:s}=t.it;return s===!1?(0,G._)`{}`:NS(t,e,r)}function NS(t,e,r={}){let{gen:s,it:n}=t,o=[jS(n,r),DS(t,r)];return qS(t,e,o),s.object(...o)}function jS({errorPath:t},{instancePath:e}){let r=e?(0,G.str)`${t}${(0,si.getErrorPath)(e,si.Type.Str)}`:t;return[Ie.default.instancePath,(0,G.strConcat)(Ie.default.instancePath,r)]}function DS({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:s}){let n=s?e:(0,G.str)`${e}/${t}`;return r&&(n=(0,G.str)`${n}${(0,si.getErrorPath)(r,si.Type.Str)}`),[Er.schemaPath,n]}function qS(t,{params:e,message:r},s){let{keyword:n,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;s.push([Er.keyword,n],[Er.params,typeof e=="function"?e(t):e||(0,G._)`{}`]),c.messages&&s.push([Er.message,typeof r=="function"?r(t):r]),c.verbose&&s.push([Er.schema,i],[Er.parentSchema,(0,G._)`${u}${d}`],[Ie.default.data,o]),l&&s.push([Er.propertyName,l])}});var yp=T(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.boolOrEmptySchema=rs.topBoolOrEmptySchema=void 0;var LS=dn(),FS=L(),US=Dt(),BS={message:"boolean schema is false"};function WS(t){let{gen:e,schema:r,validateName:s}=t;r===!1?gp(t,!1):typeof r=="object"&&r.$async===!0?e.return(US.default.data):(e.assign((0,FS._)`${s}.errors`,null),e.return(!0))}rs.topBoolOrEmptySchema=WS;function HS(t,e){let{gen:r,schema:s}=t;s===!1?(r.var(e,!1),gp(t)):r.var(e,!0)}rs.boolOrEmptySchema=HS;function gp(t,e){let{gen:r,data:s}=t,n={gen:r,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,LS.reportError)(n,BS,void 0,e)}});var Jc=T(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.getRules=ss.isJSONType=void 0;var GS=["string","number","integer","boolean","null","object","array"],VS=new Set(GS);function KS(t){return typeof t=="string"&&VS.has(t)}ss.isJSONType=KS;function ZS(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}ss.getRules=ZS});var Xc=T(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.shouldUseRule=tr.shouldUseGroup=tr.schemaHasRulesForType=void 0;function YS({schema:t,self:e},r){let s=e.RULES.types[r];return s&&s!==!0&&wp(t,s)}tr.schemaHasRulesForType=YS;function wp(t,e){return e.rules.some(r=>bp(t,r))}tr.shouldUseGroup=wp;function bp(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(s=>t[s]!==void 0))}tr.shouldUseRule=bp});var hn=T(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.reportTypeError=Pe.checkDataTypes=Pe.checkDataType=Pe.coerceAndCheckDataType=Pe.getJSONTypes=Pe.getSchemaTypes=Pe.DataType=void 0;var JS=Jc(),XS=Xc(),QS=dn(),q=L(),vp=H(),ns;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(ns||(Pe.DataType=ns={}));function ek(t){let e=_p(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Pe.getSchemaTypes=ek;function _p(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(JS.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Pe.getJSONTypes=_p;function tk(t,e){let{gen:r,data:s,opts:n}=t,o=rk(e,n.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,XS.schemaHasRulesForType)(t,e[0]));if(i){let a=el(e,s,n.strictNumbers,ns.Wrong);r.if(a,()=>{o.length?sk(t,e,o):tl(t)})}return i}Pe.coerceAndCheckDataType=tk;var Sp=new Set(["string","number","integer","boolean","null"]);function rk(t,e){return e?t.filter(r=>Sp.has(r)||e==="array"&&r==="array"):[]}function sk(t,e,r){let{gen:s,data:n,opts:o}=t,i=s.let("dataType",(0,q._)`typeof ${n}`),a=s.let("coerced",(0,q._)`undefined`);o.coerceTypes==="array"&&s.if((0,q._)`${i} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>s.assign(n,(0,q._)`${n}[0]`).assign(i,(0,q._)`typeof ${n}`).if(el(e,n,o.strictNumbers),()=>s.assign(a,n))),s.if((0,q._)`${a} !== undefined`);for(let l of r)(Sp.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);s.else(),tl(t),s.endIf(),s.if((0,q._)`${a} !== undefined`,()=>{s.assign(n,a),nk(t,a)});function c(l){switch(l){case"string":s.elseIf((0,q._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,q._)`"" + ${n}`).elseIf((0,q._)`${n} === null`).assign(a,(0,q._)`""`);return;case"number":s.elseIf((0,q._)`${i} == "boolean" || ${n} === null
6
6
  || (${i} == "string" && ${n} && ${n} == +${n})`).assign(a,(0,q._)`+${n}`);return;case"integer":s.elseIf((0,q._)`${i} === "boolean" || ${n} === null
7
7
  || (${i} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(a,(0,q._)`+${n}`);return;case"boolean":s.elseIf((0,q._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(a,!1).elseIf((0,q._)`${n} === "true" || ${n} === 1`).assign(a,!0);return;case"null":s.elseIf((0,q._)`${n} === "" || ${n} === 0 || ${n} === false`),s.assign(a,null);return;case"array":s.elseIf((0,q._)`${i} === "string" || ${i} === "number"