@github/copilot 0.0.343-11 → 0.0.343-13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +5 -12
- package/package.json +2 -2
- package/sdk/index.js +5 -12
- package/sdk/index.js.map +2 -2
package/index.js
CHANGED
|
@@ -802,7 +802,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
|
|
|
802
802
|
`;if(this.options.debug){r&&(this.fullStaticOutput+=n),this.options.stdout.write(this.fullStaticOutput+e);return}if(b3){r&&this.options.stdout.write(n),this.lastOutput=e,this.lastOutputHeight=l;return}if(this.isScreenReaderEnabled){if(r){let s=this.lastOutputHeight>0?jG.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+n),this.lastOutputHeight=0}if(e===this.lastOutput&&!r)return;let I=this.options.stdout.columns||80,a=aX(e,I,{trim:!1,hard:!0});if(r)this.options.stdout.write(a);else{let s=this.lastOutputHeight>0?jG.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+a)}this.lastOutput=e,this.lastOutputHeight=a===""?0:a.split(`
|
|
803
803
|
`).length;return}if(r&&(this.fullStaticOutput+=n),this.lastOutputHeight>=this.options.stdout.rows){this.options.stdout.write(jG.clearTerminal+this.fullStaticOutput+e),this.lastOutput=e,this.lastOutputHeight=l,this.log.sync(e);return}r&&(this.log.clear(),this.options.stdout.write(n),this.log(e)),!r&&e!==this.lastOutput&&this.throttledLog(e),this.lastOutput=e,this.lastOutputHeight=l};render(e){let l=IXe.default.createElement(GF.Provider,{value:{isScreenReaderEnabled:this.isScreenReaderEnabled}},IXe.default.createElement(D$,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},e));bF.updateContainerSync(l,this.container,null,Vit),bF.flushSyncWork()}writeToStdout(e){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(e+this.fullStaticOutput+this.lastOutput);return}if(b3){this.options.stdout.write(e);return}this.log.clear(),this.options.stdout.write(e),this.log(this.lastOutput)}}writeToStderr(e){if(!this.isUnmounted){if(this.options.debug){this.options.stderr.write(e),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(b3){this.options.stderr.write(e);return}this.log.clear(),this.options.stderr.write(e),this.log(this.lastOutput)}}unmount(e){this.isUnmounted||(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),b3?this.options.stdout.write(this.lastOutput+`
|
|
804
804
|
`):this.options.debug||this.log.done(),this.isUnmounted=!0,bF.updateContainerSync(null,this.container,null,Vit),bF.flushSyncWork(),EM.delete(this.options.stdout),e instanceof Error?this.rejectExitPromise(e):this.resolveExitPromise())}async waitUntilExit(){return this.exitPromise||=new Promise((e,l)=>{this.resolveExitPromise=e,this.rejectExitPromise=l}),this.exitPromise}clear(){!b3&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=UGe((e,l)=>{e==="stdout"&&this.writeToStdout(l),e==="stderr"&&(l.startsWith("The above error occurred")||this.writeToStderr(l))}))}};var SEl=(t,e)=>{let l={stdout:Vpe.stdout,stdin:Vpe.stdin,stderr:Vpe.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,...BEl(e)},n=OEl(l.stdout,()=>new z$(l));return n.render(t),{rerender:n.render,unmount(){n.unmount()},waitUntilExit:n.waitUntilExit,cleanup:()=>EM.delete(l.stdout),clear:n.clear}},P$=SEl,BEl=(t={})=>t instanceof xEl?{stdout:t,stdin:Vpe.stdin}:t,OEl=(t,e)=>{let l=EM.get(t);return l||(l=e(),EM.set(t,l)),l};c();var hF=lt($t(),1);function Qpe(t){let{items:e,children:l,style:n}=t,[r,I]=(0,hF.useState)(0),a=(0,hF.useMemo)(()=>e.slice(r),[e,r]);(0,hF.useLayoutEffect)(()=>{I(e.length)},[e.length]);let s=a.map((d,u)=>l(d,r+u)),o=(0,hF.useMemo)(()=>({position:"absolute",flexDirection:"column",...n}),[n]);return hF.default.createElement("ink-box",{internal_static:!0,style:o},s)}c();var Fit=lt($t(),1);c();var TEl=lt($t(),1);c();var UEl=lt($t(),1);c();var aXe=lt($t(),1);c();import{Buffer as MEl}from"node:buffer";var _El=/^(?:\x1b)([a-zA-Z0-9])$/,DEl=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Cit={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},vit=[...Object.values(Cit),"backspace"],zEl=t=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t),PEl=t=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t),jEl=(t="")=>{let e;MEl.isBuffer(t)?t[0]>127&&t[1]===void 0?(t[0]-=128,t="\x1B"+String(t)):t=String(t):t!==void 0&&typeof t!="string"?t=String(t):t||(t="");let l={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:t,raw:t};if(l.sequence=l.sequence||t||l.name,t==="\r")l.raw=void 0,l.name="return";else if(t===`
|
|
805
|
-
`)l.name="enter";else if(t===" ")l.name="tab";else if(t==="\b"||t==="\x1B\b")l.name="backspace",l.meta=t.charAt(0)==="\x1B";else if(t==="\x7F"||t==="\x1B\x7F")l.name="delete",l.meta=t.charAt(0)==="\x1B";else if(t==="\x1B"||t==="\x1B\x1B")l.name="escape",l.meta=t.length===2;else if(t===" "||t==="\x1B ")l.name="space",l.meta=t.length===2;else if(t.length===1&&t<="")l.name=String.fromCharCode(t.charCodeAt(0)+97-1),l.ctrl=!0;else if(t.length===1&&t>="0"&&t<="9")l.name="number";else if(t.length===1&&t>="a"&&t<="z")l.name=t;else if(t.length===1&&t>="A"&&t<="Z")l.name=t.toLowerCase(),l.shift=!0;else if(e=_El.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=DEl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let r=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),I=(e[3]||e[5]||1)-1;l.ctrl=!!(I&4),l.meta=!!(I&10),l.shift=!!(I&1),l.code=r,l.name=Cit[r],l.shift=zEl(r)||l.shift,l.ctrl=PEl(r)||l.ctrl}return l},fit=jEl;c();var Hit=lt($t(),1);var KEl=()=>(0,Hit.useContext)(Wpe),RM=KEl;var qEl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:I}=RM();(0,aXe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,aXe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=fit(s),d={upArrow:o.name==="up",downArrow:o.name==="down",leftArrow:o.name==="left",rightArrow:o.name==="right",pageDown:o.name==="pagedown",pageUp:o.name==="pageup",return:o.name==="return",escape:o.name==="escape",ctrl:o.ctrl,shift:o.shift,tab:o.name==="tab",backspace:o.name==="backspace",delete:o.name==="delete",meta:o.meta||o.name==="escape"||o.option},u=o.ctrl?o.name:o.sequence;vit.includes(o.name)&&(u=""),u.startsWith("\x1B")&&(u=u.slice(1)),u.length===1&&typeof u[0]=="string"&&/[A-Z]/.test(u[0])&&(d.shift=!0),(!(u==="c"&&d.ctrl)||!r)&&bF.batchedUpdates(()=>{t(u,d)})};return I?.on("input",a),()=>{I?.removeListener("input",a)}},[e.isActive,l,r,t])},$Y=qEl;c();var $El=lt($t(),1);c();var Xit=lt($t(),1);var e0l=()=>(0,Xit.useContext)(ype),PN=e0l;c();var t0l=lt($t(),1);c();var sXe=lt($t(),1);c();var l0l=lt($t(),1);c();var kit=lt($t(),1);var n0l=()=>{let{isScreenReaderEnabled:t}=(0,kit.useContext)(GF);return t},Z3=n0l;c();var r0l=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),wpe=r0l;var sIt=lt($t(),1);import{join as aIt}from"path";import{text as frr}from"stream/consumers";c();c();var Oht=lt(Z_(),1);c();c();c();c();var tp=[];for(let t=0;t<256;++t)tp.push((t+256).toString(16).slice(1));function bht(t,e=0){return(tp[t[e+0]]+tp[t[e+1]]+tp[t[e+2]]+tp[t[e+3]]+"-"+tp[t[e+4]]+tp[t[e+5]]+"-"+tp[t[e+6]]+tp[t[e+7]]+"-"+tp[t[e+8]]+tp[t[e+9]]+"-"+tp[t[e+10]]+tp[t[e+11]]+tp[t[e+12]]+tp[t[e+13]]+tp[t[e+14]]+tp[t[e+15]]).toLowerCase()}c();import{randomFillSync as _Hl}from"node:crypto";var FAe=new Uint8Array(256),wAe=FAe.length;function Xke(){return wAe>FAe.length-16&&(_Hl(FAe),wAe=0),FAe.slice(wAe,wAe+=16)}c();c();import{randomUUID as DHl}from"node:crypto";var kke={randomUUID:DHl};function zHl(t,e,l){t=t||{};let n=t.random??t.rng?.()??Xke();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(l=l||0,l<0||l+16>e.length)throw new RangeError(`UUID byte range ${l}:${l+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[l+r]=n[r];return e}return bht(n)}function PHl(t,e,l){return kke.randomUUID&&!e&&!t?kke.randomUUID():zHl(t,e,l)}var Bu=PHl;var B3=class{settings={};mergePartial(e,l){return{...e,...l}}setBlackbirdMode(e){return e!==void 0&&(e=="tool"||e=="initial-search")&&(this.settings.blackbird=this.mergePartial(this.settings.blackbird,{mode:e})),this}setSwebenchBaseCommit(e){return e!==void 0&&(this.settings.swebench_base_commit=e),this}setGithubUserName(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,name:e}})}return this}setGithubUserEmail(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,email:e}})}return this}setGithubToken(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{token:e})),this}setGithubServerUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{serverUrl:e??"https://github.com"}),(!this.settings.github.host||!this.settings.github.hostProtocol)&&(this.settings.github=this.mergePartial(this.settings.github,new URL(e)))),this}setGithubHost(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{host:e})),this}setGithubHostProtocol(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{hostProtocol:e})),this}setGithubActorId(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorId:e}})}return this}setGithubActorLogin(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorLogin:e}})}return this}setAgentRuntimeVersion(e){return e!==void 0?this.settings.version=e:this.settings.version="latest",this}setGithubRepoName(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,name:e}})}return this}setGithubRepoId(e){if(e!==void 0){let l=this.settings.github?.repo||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,id:n}}))}return this}setGithubRepoOwnerName(e){if(e!==void 0){let l=this.settings.github?.owner||{};this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,name:e}})}return this}setGithubRepoOwnerId(e){if(e!==void 0){let l=this.settings.github?.owner||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,id:n}}))}return this}setGithubRepoBranch(e){if(e){let l=e.replace(/^refs\/heads\//,"");if(l.length===0)return this;let n=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...n,branch:l}})}return this}setGithubRepoCommit(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,commit:e}})}return this}setGithubRepoReadWrite(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,readWrite:e}})}return this}setProblemStatement(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{statement:e})),this}setProblemContentFilterMode(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{contentFilterMode:e})),this}setProblemAction(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{action:e})),this}setCustomAgentName(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{customAgentName:e})),this}setGithubIssueNumber(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{issue:{number:e}})),this}setGithubPRCommitCount(e){if(e!==void 0){let l=this.settings.github?.pr||{};this.settings.github=this.mergePartial(this.settings.github,{pr:{...l,commitCount:e}})}return this}setInstanceId(e){return this.settings.service=this.mergePartial(this.settings.service,{instance:{id:e??Bu()}}),this}setAgentModel(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,model:e}})}return this}setRequestHeaders(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,requestHeaders:e}})}return this}setRetryPolicy(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,retryPolicy:e}})}return this}setCallbackUrl(e){return e!==void 0&&(this.settings.service=this.mergePartial(this.settings.service,{callback:{url:e}})),this}setGitHubUploadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{uploadsUrl:e})),this}setGitHubDownloadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{downloadsUrl:e})),this}setAipSweAgentToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{aipSweAgent:{token:e}})),this}setAnthropicApiKey(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{anthropic:{key:e}})),this}setOpenAiApiKey(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,apiKey:e}})}return this}setOpenAiBaseUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,baseUrl:e}})}return this}setAzureOpenAiUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,url:e}}})}return this}setAzureOpenAiApiVersion(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,apiVersion:e}}})}return this}setAzureOpenAiKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureKeyVaultUri:e}})}return this}setAzureOpenAiSecretName(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureSecretName:e}})}return this}setCopilotUrl(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,url:e}})}return this}setCopilotIntegrationId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,integrationId:e}})}return this}setCopilotHmacKey(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,hmacKey:e}})}return this}setCopilotToken(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,token:e}})}return this}setCopilotAzureKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,azureKeyVaultUri:e}})}return this}setCopilotSessionId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,sessionId:e}})}return this}setCopilotPreviousSessionIds(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,previousSessionIds:e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}})}return this}setCopilotUseSessions(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,useSessions:e}})}return this}setCopilotJobNonce(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{nonce:e})),this}setTrajectoryOutputFile(e){return e!==void 0&&(this.settings.trajectory=this.mergePartial(this.settings.trajectory,{outputFile:e})),this}setEventsLogDirectory(e){return e!==void 0&&(this.settings.logs=this.mergePartial(this.settings.logs,{eventsLogDir:e})),this}setDisableOnlineEvaluation(e){return e==!0&&this.settings.onlineEvaluation?.disableOnlineEvaluation!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{disableOnlineEvaluation:e})),this}setEnableOnlineEvaluationOutputFile(e){return e==!0&&this.settings.onlineEvaluation?.enableOnlineEvaluationOutputFile!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{enableOnlineEvaluationOutputFile:e})),this}setGitHubMCPServerToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{github:{mcpServerToken:e}})),this}setFeatureFlagEnabled(e){return this.settings.featureFlags=this.mergePartial(this.settings.featureFlags,{[e]:!0}),this}setExperiment(e,l){return this.settings.experiments=this.mergePartial(this.settings.experiments,{[e]:l}),this}setTimeoutMs(e){return e!==void 0&&(this.settings.timeoutMs=e),this}setStartTimeMs(e){return e!==void 0&&(this.settings.startTimeMs=e),this}build(){return this.settings}};var CAe=["GITHUB_TOKEN","GITHUB_COPILOT_API_TOKEN","CAPI_HMAC_KEY","CAPI_HMAC_KEY_OVERRIDE","ANTHROPIC_API_KEY","AIP_SWE_AGENT_TOKEN","CAPI_AZURE_KEY_VAULT_URI","COPILOT_JOB_NONCE","GITHUB_MCP_SERVER_TOKEN","OPENAI_BASE_URL","OPENAI_API_KEY","COPILOT_AGENT_REQUEST_HEADERS","AZURE_OPENAI_API_KEY","AZURE_OPENAI_API_ENDPOINT","AZURE_OPENAI_KEY_VAULT_URI","AZURE_OPENAI_KEY_VAULT_SECRET_NAME","BLACKBIRD_AUTH_METIS_API_KEY","BLACKBIRD_AUTH_MODEL_BASED_RETRIEVAL_TOKEN"],Ght=["COPILOT_CALLBACK_URL","COPILOT_AGENT_MODEL","COPILOT_AGENT_JOB_ID","COPILOT_AGENT_PROMPT","COPILOT_AGENT_PUSH","COPILOT_FIREWALL_ENABLED","COPILOT_FIREWALL_ALLOW_LIST","GITHUB_COPILOT_INTEGRATION_ID","COPILOT_INTEGRATION_ID_OVERRIDE","COPILOT_AGENT_SESSION_ID","COPILOT_AGENT_PREVIOUS_SESSION_IDS","COPILOT_AGENT_EVENT_URL","COPILOT_AGENT_EVENT_TYPE","COPILOT_AGENT_ACTOR","COPILOT_AGENT_ACTOR_ID",...CAe];async function pht(){let t=new B3;t.setGithubServerUrl(process.env.GITHUB_SERVER_URL).setGithubHost(process.env.GITHUB_HOST).setGithubHostProtocol(process.env.GITHUB_HOST_PROTOCOL).setGithubToken(process.env.GITHUB_TOKEN).setGithubUserName(process.env.COPILOT_AGENT_COMMIT_LOGIN).setGithubUserEmail(process.env.COPILOT_AGENT_COMMIT_EMAIL).setGithubRepoOwnerId(process.env.GITHUB_REPOSITORY_OWNER_ID).setGithubRepoOwnerName(process.env.GITHUB_REPOSITORY_OWNER).setGithubRepoId(process.env.GITHUB_REPOSITORY_ID).setGithubRepoName(process.env.GITHUB_REPOSITORY).setGithubRepoBranch(process.env.COPILOT_AGENT_BRANCH_NAME).setGithubRepoCommit(process.env.COPILOT_AGENT_BASE_COMMIT).setAgentRuntimeVersion(process.env.COPILOT_AGENT_RUNTIME_VERSION),process.env.COPILOT_AGENT_PUSH!==void 0&&t.setGithubRepoReadWrite(process.env.COPILOT_AGENT_PUSH==="true");let e=process.env.COPILOT_AGENT_ISSUE_NUMBER?parseInt(process.env.COPILOT_AGENT_ISSUE_NUMBER,10):void 0;isNaN(e)||t.setGithubIssueNumber(e),t.setGithubPRCommitCount(process.env.COPILOT_AGENT_PR_COMMIT_COUNT?parseInt(process.env.COPILOT_AGENT_PR_COMMIT_COUNT,10):void 0),t.setProblemStatement(process.env.COPILOT_AGENT_PROMPT).setProblemContentFilterMode(process.env.COPILOT_AGENT_CONTENT_FILTER_MODE).setCustomAgentName(process.env.COPILOT_CUSTOM_AGENT);let l=process.env.COPILOT_AGENT_ACTION;if(l&&["fix","fix-pr-comment"].includes(l)&&t.setProblemAction(l),process.env.COPILOT_AGENT_ACTOR_ID&&t.setGithubActorId(parseInt(process.env.COPILOT_AGENT_ACTOR_ID,10)),process.env.COPILOT_AGENT_ACTOR&&t.setGithubActorLogin(process.env.COPILOT_AGENT_ACTOR),t.setInstanceId(process.env.COPILOT_AGENT_JOB_ID).setCopilotJobNonce(process.env.COPILOT_JOB_NONCE).setAgentModel(process.env.COPILOT_AGENT_MODEL).setCallbackUrl(process.env.COPILOT_AGENT_CALLBACK_URL).setGitHubUploadsUrl(process.env.GITHUB_UPLOADS_URL).setGitHubDownloadsUrl(process.env.GITHUB_DOWNLOADS_URL),t.setAipSweAgentToken(process.env.AIP_SWE_AGENT_TOKEN).setAnthropicApiKey(process.env.ANTHROPIC_API_KEY).setCopilotUrl(process.env.COPILOT_API_URL).setCopilotIntegrationId(process.env.GITHUB_COPILOT_INTEGRATION_ID).setCopilotHmacKey(process.env.CAPI_HMAC_KEY).setCopilotToken(process.env.GITHUB_COPILOT_API_TOKEN).setCopilotAzureKeyVaultUri(process.env.CAPI_AZURE_KEY_VAULT_URI).setBlackbirdMode(process.env.BLACKBIRD_MODE||"initial-search").setCopilotSessionId(process.env.COPILOT_AGENT_SESSION_ID).setCopilotPreviousSessionIds(process.env.COPILOT_AGENT_PREVIOUS_SESSION_IDS).setSwebenchBaseCommit(process.env.SWEBENCH_BASE_COMMIT).setGitHubMCPServerToken(process.env.GITHUB_MCP_SERVER_TOKEN).setAzureOpenAiKeyVaultUri(process.env.AZURE_OPENAI_KEY_VAULT_URI).setAzureOpenAiSecretName(process.env.AZURE_OPENAI_KEY_VAULT_SECRET_NAME).setOpenAiBaseUrl(process.env.OPENAI_BASE_URL).setOpenAiApiKey(process.env.AZURE_OPENAI_API_KEY||process.env.OPENAI_API_KEY).setAzureOpenAiUrl(process.env.AZURE_OPENAI_API_ENDPOINT).setAzureOpenAiApiVersion(process.env.AZURE_OPENAI_API_VERSION),process.env.COPILOT_USE_SESSIONS!==void 0&&t.setCopilotUseSessions(process.env.COPILOT_USE_SESSIONS==="true"),t.setTrajectoryOutputFile(process.env.CPD_SAVE_TRAJECTORY_OUTPUT),t.setEventsLogDirectory(process.env.COPILOT_EVENTS_LOG_DIRECTORY),process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED!==void 0&&t.setDisableOnlineEvaluation(process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED==="true"),process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE!==void 0&&t.setEnableOnlineEvaluationOutputFile(process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE==="true"),process.env.COPILOT_FEATURE_FLAGS&&process.env.COPILOT_FEATURE_FLAGS.split(",").map(I=>I.trim()).filter(I=>I.length>0).forEach(I=>t.setFeatureFlagEnabled(I)),process.env.COPILOT_EXPERIMENTS&&process.env.COPILOT_EXPERIMENTS.split(",").map(I=>{let[a,s]=I.split(":");t.setExperiment(a,s)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let I=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(a=>parseInt(a.trim(),10));t.setRetryPolicy({errorCodesToRetry:I})}if(process.env.COPILOT_AGENT_REQUEST_HEADERS)try{let I=JSON.parse(process.env.COPILOT_AGENT_REQUEST_HEADERS);t.setRequestHeaders(I)}catch{}let n=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;n!==void 0&&!Number.isNaN(n)&&t.setTimeoutMs(n*60*1e3);let r=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return r!==void 0&&!Number.isNaN(r)&&t.setStartTimeMs(r*1e3),t.build()}c();c();var Rht=lt(Aht(),1);import{exec as Eht,execFile as $Hl}from"child_process";c();c();c();var Lee=null;function W_(){return!!Lee}function Lke(){if(!Lee)throw new Error("Settings have not been initialized");return Lee}function Zht(t){return Lee=t,t}function y_(){Lee=null}c();function Lo(t,e){return t?.featureFlags?.[e]??!1}function ght(t,e){return t?.experiments?.[e]}function Jke(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var KHl=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function xke(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":xke(n,e);break;case"undefined":break;default:if(KHl.includes(l)){let r=n.toString().trim();r!=""&&e.push(r)}break}return e}function Nht(t,e){if(isNaN(e)||!isFinite(e)||e<=0)return{isWithin:!1,withinMs:e};if(e>1)return{isWithin:!1,withinMs:e};if(!t.timeoutMs)return{isWithin:!1,withinMs:e};let l=t.timeoutMs*e;return t.startTimeMs?{isWithin:Date.now()-t.startTimeMs>=t.timeoutMs-l,withinMs:l}:{isWithin:!1,withinMs:l}}c();import*as Wht from"process";function Ske(t){let e=Wht.env[t];if(e&&e.trim()!=="")return e}var qHl=[/\b(?:eyJ0eXAiOi|eyJhbGciOi|eyJ4NXQiOi|eyJraWQiOi)[^\s'";]+/g,/\bBearer\s+[^\s'";]+/g,/\b(?:Password|Pwd)=(?:[^\s'";]+|"[^"]+")/gi,/\s+-(?:Password|Pwd)\s+(?:[^\s'";]+|"[^"]+")/gi,/\bv1\.[0-9A-Fa-f]{40}\b/g,/\bgh[pousr]{1}_[A-Za-z0-9]{36}\b/g,/\bgithub_pat_[0-9][A-Za-z0-9]{21}_[A-Za-z0-9]{59}\b/g,/(?:[a-zA-Z][a-zA-Z\d+-.]*):\/\/([a-zA-Z\d\-._~!$&'()*+,;=%]+):([a-zA-Z\d\-._~!$&'()*+,;=:%]*)@/g,/\b[0-9A-Za-z-_~.]{3}7Q~[0-9A-Za-z-_~.]{31}\b|\b[0-9A-Za-z-_~.]{3}8Q~[0-9A-Za-z-_~.]{34}\b/g,/\b[0-9A-Za-z+/]{76}(APIM|ACDb|\+(ABa|AMC|ASt))[0-9A-Za-z+/]{5}[AQgw]==/g,/\b[0-9A-Za-z+/]{33}(AIoT|\+(ASb|AEh|ARm))[A-P][0-9A-Za-z+/]{5}=/g,/\b[0-9A-Za-z_-]{44}AzFu[0-9A-Za-z\-_]{5}[AQgw]==/g,/\b[0-9A-Za-z]{42}AzSe[A-D][0-9A-Za-z]{5}\b/g,/\b[0-9A-Za-z+/]{42}\+ACR[A-D][0-9A-Za-z+/]{5}\b/g,/\b[0-9A-Za-z]{33}AzCa[A-P][0-9A-Za-z]{5}=/g,/\boy2[a-p][0-9a-z]{15}[aq][0-9a-z]{11}[eu][bdfhjlnprtvxz357][a-p][0-9a-z]{11}[aeimquy4]\b/g,/\bnpm_[0-9A-Za-z]{36}\b/g,/\bx-ghcr-signature=[^&]+/g],yht="******",b1=class t{static singleton;static getInstance(){return t.singleton||(t.singleton=new t),t.singleton}secretValuesToFilter;runner;logger;constructor(){}setRunner(e){this.runner=e,this.logger=e.logger,this.secretValuesToFilter=void 0}filterSecrets(e){let l=typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"message"),n=l?e.message??e.toString():e,r=this.getSecretValues();for(let I of r)n=n.replaceAll(I,yht);for(let I of qHl)n=n.replaceAll(I,yht);return l?(e.message=n,e):n}filterSecretsFromJsonString(e){try{let l=JSON.parse(e),n=this.filterSecretsFromObj(l);return JSON.stringify(n)}catch{return this.filterSecrets(e)}}filterSecretsFromObj(e){if(e==null)return e;if(typeof e=="string")return this.filterSecrets(e);if(typeof e=="number"){let l=this.filterSecrets(e.toString()),n=Number(l);return isNaN(n)?l:n}if(Array.isArray(e))return e.map(l=>this.filterSecretsFromObj(l));if(typeof e=="object"){let l={};for(let[n,r]of Object.entries(e))l[n]=this.filterSecretsFromObj(r);return l}return e}getSecretValues(){if(this.secretValuesToFilter)return this.secretValuesToFilter;let e={secretEnvVars:!1,runner:!1,settings:!1},l=new Set;for(let n of CAe){let r=Ske(n);r&&Bke(l,r)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let r=Ske(n);r&&Bke(l,r)}e.runner=!0}if(W_()){let n=xke(Lke());for(let r of n)Bke(l,r);e.settings=!0}return Object.values(e).every(n=>n)&&(this.secretValuesToFilter=l,this.logger?.debug("Caching secret values to filter from all sources.")),l}};function Bke(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function Jee(...t){let e=new Set(["DEBUG","COPILOT_AGENT_DEBUG",...t]);for(let l of e)if(process.env[l]==="1"||process.env[l]?.toLocaleLowerCase()==="true")return!0;return!1}var vF=class{logLevel;debugEnvironmentVariables;secretFilter=b1.getInstance();constructor(e,l){e===void 0?Jee(...l??[])?this.logLevel=15:this.logLevel=7:this.logLevel=e,this.debugEnvironmentVariables=l}filterSecrets(e){return typeof e=="string"?this.secretFilter.filterSecrets(e):this.secretFilter.filterSecrets(e)}shouldLog(e){return this.logLevel===void 0||(this.logLevel&e)===e}isDebug(){return Jee(...this.debugEnvironmentVariables??[])}};var aW=class{logger;constructor(e){this.logger=e}async exec(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),0}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}async execReturn(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),{exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}_exec(e,l,n,r=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let I={cwd:n.cwd,env:n.env,shell:n.shell,timeout:n.timeout,signal:n.abortSignal};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?Eht(e,I):n.shell?Eht(`${e} ${(0,Rht.default)(l)}`,I):$Hl(e,l,I),d="",u="";o.stdout?.on("data",b=>{d+=b}),o.stderr?.on("data",b=>{u+=b}),o.on("close",(b,p)=>{if(b!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,r),g=new Error(`Command failed with exit code ${b}: ${h}`);g.cmd=h,g.code=b,g.stdout=d,g.stderr=u,g.signal=p,s(g)}else a({error:null,stdout:d,stderr:u,exitCode:b})}),o.on("error",b=>{b.stdout=d,b.stderr=u,b.cmd=this.filterCommand(e,l,r),s(b)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let r=l.reduce((I,a)=>(n.includes(a)?I.push("REDACTED"):I.push(a),I),[]);return`${e} ${r.join(" ")}`}};c();import{randomUUID as eXl}from"crypto";import{cpSync as tXl,existsSync as Sht,mkdtempSync as lXl,rmSync as nXl}from"fs";import{homedir as Bht,tmpdir as rXl}from"os";import{join as Oee}from"path";c();var O3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let r=e.code,I=e.message;"stdout"in e&&"stderr"in e&&(I+=`
|
|
805
|
+
`)l.name="enter";else if(t===" ")l.name="tab";else if(t==="\b"||t==="\x1B\b")l.name="backspace",l.meta=t.charAt(0)==="\x1B";else if(t==="\x7F"||t==="\x1B\x7F")l.name="delete",l.meta=t.charAt(0)==="\x1B";else if(t==="\x1B"||t==="\x1B\x1B")l.name="escape",l.meta=t.length===2;else if(t===" "||t==="\x1B ")l.name="space",l.meta=t.length===2;else if(t.length===1&&t<="")l.name=String.fromCharCode(t.charCodeAt(0)+97-1),l.ctrl=!0;else if(t.length===1&&t>="0"&&t<="9")l.name="number";else if(t.length===1&&t>="a"&&t<="z")l.name=t;else if(t.length===1&&t>="A"&&t<="Z")l.name=t.toLowerCase(),l.shift=!0;else if(e=_El.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=DEl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let r=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),I=(e[3]||e[5]||1)-1;l.ctrl=!!(I&4),l.meta=!!(I&10),l.shift=!!(I&1),l.code=r,l.name=Cit[r],l.shift=zEl(r)||l.shift,l.ctrl=PEl(r)||l.ctrl}return l},fit=jEl;c();var Hit=lt($t(),1);var KEl=()=>(0,Hit.useContext)(Wpe),RM=KEl;var qEl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:I}=RM();(0,aXe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,aXe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=fit(s),d={upArrow:o.name==="up",downArrow:o.name==="down",leftArrow:o.name==="left",rightArrow:o.name==="right",pageDown:o.name==="pagedown",pageUp:o.name==="pageup",return:o.name==="return",escape:o.name==="escape",ctrl:o.ctrl,shift:o.shift,tab:o.name==="tab",backspace:o.name==="backspace",delete:o.name==="delete",meta:o.meta||o.name==="escape"||o.option},u=o.ctrl?o.name:o.sequence;vit.includes(o.name)&&(u=""),u.startsWith("\x1B")&&(u=u.slice(1)),u.length===1&&typeof u[0]=="string"&&/[A-Z]/.test(u[0])&&(d.shift=!0),(!(u==="c"&&d.ctrl)||!r)&&bF.batchedUpdates(()=>{t(u,d)})};return I?.on("input",a),()=>{I?.removeListener("input",a)}},[e.isActive,l,r,t])},$Y=qEl;c();var $El=lt($t(),1);c();var Xit=lt($t(),1);var e0l=()=>(0,Xit.useContext)(ype),PN=e0l;c();var t0l=lt($t(),1);c();var sXe=lt($t(),1);c();var l0l=lt($t(),1);c();var kit=lt($t(),1);var n0l=()=>{let{isScreenReaderEnabled:t}=(0,kit.useContext)(GF);return t},Z3=n0l;c();var r0l=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),wpe=r0l;var sIt=lt($t(),1);import{join as aIt}from"path";import{text as frr}from"stream/consumers";c();c();var Oht=lt(Z_(),1);c();c();c();c();var tp=[];for(let t=0;t<256;++t)tp.push((t+256).toString(16).slice(1));function bht(t,e=0){return(tp[t[e+0]]+tp[t[e+1]]+tp[t[e+2]]+tp[t[e+3]]+"-"+tp[t[e+4]]+tp[t[e+5]]+"-"+tp[t[e+6]]+tp[t[e+7]]+"-"+tp[t[e+8]]+tp[t[e+9]]+"-"+tp[t[e+10]]+tp[t[e+11]]+tp[t[e+12]]+tp[t[e+13]]+tp[t[e+14]]+tp[t[e+15]]).toLowerCase()}c();import{randomFillSync as _Hl}from"node:crypto";var FAe=new Uint8Array(256),wAe=FAe.length;function Xke(){return wAe>FAe.length-16&&(_Hl(FAe),wAe=0),FAe.slice(wAe,wAe+=16)}c();c();import{randomUUID as DHl}from"node:crypto";var kke={randomUUID:DHl};function zHl(t,e,l){t=t||{};let n=t.random??t.rng?.()??Xke();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(l=l||0,l<0||l+16>e.length)throw new RangeError(`UUID byte range ${l}:${l+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[l+r]=n[r];return e}return bht(n)}function PHl(t,e,l){return kke.randomUUID&&!e&&!t?kke.randomUUID():zHl(t,e,l)}var Bu=PHl;var B3=class{settings={};mergePartial(e,l){return{...e,...l}}setBlackbirdMode(e){return e!==void 0&&(e=="tool"||e=="initial-search")&&(this.settings.blackbird=this.mergePartial(this.settings.blackbird,{mode:e})),this}setSwebenchBaseCommit(e){return e!==void 0&&(this.settings.swebench_base_commit=e),this}setGithubUserName(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,name:e}})}return this}setGithubUserEmail(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,email:e}})}return this}setGithubToken(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{token:e})),this}setGithubServerUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{serverUrl:e??"https://github.com"}),(!this.settings.github.host||!this.settings.github.hostProtocol)&&(this.settings.github=this.mergePartial(this.settings.github,new URL(e)))),this}setGithubHost(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{host:e})),this}setGithubHostProtocol(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{hostProtocol:e})),this}setGithubActorId(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorId:e}})}return this}setGithubActorLogin(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorLogin:e}})}return this}setAgentRuntimeVersion(e){return e!==void 0?this.settings.version=e:this.settings.version="latest",this}setGithubRepoName(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,name:e}})}return this}setGithubRepoId(e){if(e!==void 0){let l=this.settings.github?.repo||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,id:n}}))}return this}setGithubRepoOwnerName(e){if(e!==void 0){let l=this.settings.github?.owner||{};this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,name:e}})}return this}setGithubRepoOwnerId(e){if(e!==void 0){let l=this.settings.github?.owner||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,id:n}}))}return this}setGithubRepoBranch(e){if(e){let l=e.replace(/^refs\/heads\//,"");if(l.length===0)return this;let n=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...n,branch:l}})}return this}setGithubRepoCommit(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,commit:e}})}return this}setGithubRepoReadWrite(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,readWrite:e}})}return this}setProblemStatement(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{statement:e})),this}setProblemContentFilterMode(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{contentFilterMode:e})),this}setProblemAction(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{action:e})),this}setCustomAgentName(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{customAgentName:e})),this}setGithubPRCommitCount(e){if(e!==void 0){let l=this.settings.github?.pr||{};this.settings.github=this.mergePartial(this.settings.github,{pr:{...l,commitCount:e}})}return this}setInstanceId(e){return this.settings.service=this.mergePartial(this.settings.service,{instance:{id:e??Bu()}}),this}setAgentModel(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,model:e}})}return this}setRequestHeaders(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,requestHeaders:e}})}return this}setRetryPolicy(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,retryPolicy:e}})}return this}setCallbackUrl(e){return e!==void 0&&(this.settings.service=this.mergePartial(this.settings.service,{callback:{url:e}})),this}setGitHubUploadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{uploadsUrl:e})),this}setGitHubDownloadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{downloadsUrl:e})),this}setAipSweAgentToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{aipSweAgent:{token:e}})),this}setAnthropicApiKey(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{anthropic:{key:e}})),this}setOpenAiApiKey(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,apiKey:e}})}return this}setOpenAiBaseUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,baseUrl:e}})}return this}setAzureOpenAiUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,url:e}}})}return this}setAzureOpenAiApiVersion(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,apiVersion:e}}})}return this}setAzureOpenAiKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureKeyVaultUri:e}})}return this}setAzureOpenAiSecretName(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureSecretName:e}})}return this}setCopilotUrl(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,url:e}})}return this}setCopilotIntegrationId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,integrationId:e}})}return this}setCopilotHmacKey(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,hmacKey:e}})}return this}setCopilotToken(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,token:e}})}return this}setCopilotAzureKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,azureKeyVaultUri:e}})}return this}setCopilotSessionId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,sessionId:e}})}return this}setCopilotPreviousSessionIds(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,previousSessionIds:e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}})}return this}setCopilotUseSessions(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,useSessions:e}})}return this}setCopilotJobNonce(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{nonce:e})),this}setTrajectoryOutputFile(e){return e!==void 0&&(this.settings.trajectory=this.mergePartial(this.settings.trajectory,{outputFile:e})),this}setEventsLogDirectory(e){return e!==void 0&&(this.settings.logs=this.mergePartial(this.settings.logs,{eventsLogDir:e})),this}setDisableOnlineEvaluation(e){return e==!0&&this.settings.onlineEvaluation?.disableOnlineEvaluation!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{disableOnlineEvaluation:e})),this}setEnableOnlineEvaluationOutputFile(e){return e==!0&&this.settings.onlineEvaluation?.enableOnlineEvaluationOutputFile!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{enableOnlineEvaluationOutputFile:e})),this}setGitHubMCPServerToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{github:{mcpServerToken:e}})),this}setFeatureFlagEnabled(e){return this.settings.featureFlags=this.mergePartial(this.settings.featureFlags,{[e]:!0}),this}setExperiment(e,l){return this.settings.experiments=this.mergePartial(this.settings.experiments,{[e]:l}),this}setTimeoutMs(e){return e!==void 0&&(this.settings.timeoutMs=e),this}setStartTimeMs(e){return e!==void 0&&(this.settings.startTimeMs=e),this}build(){return this.settings}};var CAe=["GITHUB_TOKEN","GITHUB_COPILOT_API_TOKEN","CAPI_HMAC_KEY","CAPI_HMAC_KEY_OVERRIDE","ANTHROPIC_API_KEY","AIP_SWE_AGENT_TOKEN","CAPI_AZURE_KEY_VAULT_URI","COPILOT_JOB_NONCE","GITHUB_MCP_SERVER_TOKEN","OPENAI_BASE_URL","OPENAI_API_KEY","COPILOT_AGENT_REQUEST_HEADERS","AZURE_OPENAI_API_KEY","AZURE_OPENAI_API_ENDPOINT","AZURE_OPENAI_KEY_VAULT_URI","AZURE_OPENAI_KEY_VAULT_SECRET_NAME","BLACKBIRD_AUTH_METIS_API_KEY","BLACKBIRD_AUTH_MODEL_BASED_RETRIEVAL_TOKEN"],Ght=["COPILOT_CALLBACK_URL","COPILOT_AGENT_MODEL","COPILOT_AGENT_JOB_ID","COPILOT_AGENT_PROMPT","COPILOT_AGENT_PUSH","COPILOT_FIREWALL_ENABLED","COPILOT_FIREWALL_ALLOW_LIST","GITHUB_COPILOT_INTEGRATION_ID","COPILOT_INTEGRATION_ID_OVERRIDE","COPILOT_AGENT_SESSION_ID","COPILOT_AGENT_PREVIOUS_SESSION_IDS","COPILOT_AGENT_EVENT_URL","COPILOT_AGENT_EVENT_TYPE","COPILOT_AGENT_ACTOR","COPILOT_AGENT_ACTOR_ID",...CAe];async function pht(){let t=new B3;t.setGithubServerUrl(process.env.GITHUB_SERVER_URL).setGithubHost(process.env.GITHUB_HOST).setGithubHostProtocol(process.env.GITHUB_HOST_PROTOCOL).setGithubToken(process.env.GITHUB_TOKEN).setGithubUserName(process.env.COPILOT_AGENT_COMMIT_LOGIN).setGithubUserEmail(process.env.COPILOT_AGENT_COMMIT_EMAIL).setGithubRepoOwnerId(process.env.GITHUB_REPOSITORY_OWNER_ID).setGithubRepoOwnerName(process.env.GITHUB_REPOSITORY_OWNER).setGithubRepoId(process.env.GITHUB_REPOSITORY_ID).setGithubRepoName(process.env.GITHUB_REPOSITORY).setGithubRepoBranch(process.env.COPILOT_AGENT_BRANCH_NAME).setGithubRepoCommit(process.env.COPILOT_AGENT_BASE_COMMIT).setAgentRuntimeVersion(process.env.COPILOT_AGENT_RUNTIME_VERSION),process.env.COPILOT_AGENT_PUSH!==void 0&&t.setGithubRepoReadWrite(process.env.COPILOT_AGENT_PUSH==="true"),t.setGithubPRCommitCount(process.env.COPILOT_AGENT_PR_COMMIT_COUNT?parseInt(process.env.COPILOT_AGENT_PR_COMMIT_COUNT,10):void 0),t.setProblemStatement(process.env.COPILOT_AGENT_PROMPT).setProblemContentFilterMode(process.env.COPILOT_AGENT_CONTENT_FILTER_MODE).setCustomAgentName(process.env.COPILOT_CUSTOM_AGENT);let e=process.env.COPILOT_AGENT_ACTION;if(e&&["fix","fix-pr-comment"].includes(e)&&t.setProblemAction(e),process.env.COPILOT_AGENT_ACTOR_ID&&t.setGithubActorId(parseInt(process.env.COPILOT_AGENT_ACTOR_ID,10)),process.env.COPILOT_AGENT_ACTOR&&t.setGithubActorLogin(process.env.COPILOT_AGENT_ACTOR),t.setInstanceId(process.env.COPILOT_AGENT_JOB_ID).setCopilotJobNonce(process.env.COPILOT_JOB_NONCE).setAgentModel(process.env.COPILOT_AGENT_MODEL).setCallbackUrl(process.env.COPILOT_AGENT_CALLBACK_URL).setGitHubUploadsUrl(process.env.GITHUB_UPLOADS_URL).setGitHubDownloadsUrl(process.env.GITHUB_DOWNLOADS_URL),t.setAipSweAgentToken(process.env.AIP_SWE_AGENT_TOKEN).setAnthropicApiKey(process.env.ANTHROPIC_API_KEY).setCopilotUrl(process.env.COPILOT_API_URL).setCopilotIntegrationId(process.env.GITHUB_COPILOT_INTEGRATION_ID).setCopilotHmacKey(process.env.CAPI_HMAC_KEY).setCopilotToken(process.env.GITHUB_COPILOT_API_TOKEN).setCopilotAzureKeyVaultUri(process.env.CAPI_AZURE_KEY_VAULT_URI).setBlackbirdMode(process.env.BLACKBIRD_MODE||"initial-search").setCopilotSessionId(process.env.COPILOT_AGENT_SESSION_ID).setCopilotPreviousSessionIds(process.env.COPILOT_AGENT_PREVIOUS_SESSION_IDS).setSwebenchBaseCommit(process.env.SWEBENCH_BASE_COMMIT).setGitHubMCPServerToken(process.env.GITHUB_MCP_SERVER_TOKEN).setAzureOpenAiKeyVaultUri(process.env.AZURE_OPENAI_KEY_VAULT_URI).setAzureOpenAiSecretName(process.env.AZURE_OPENAI_KEY_VAULT_SECRET_NAME).setOpenAiBaseUrl(process.env.OPENAI_BASE_URL).setOpenAiApiKey(process.env.AZURE_OPENAI_API_KEY||process.env.OPENAI_API_KEY).setAzureOpenAiUrl(process.env.AZURE_OPENAI_API_ENDPOINT).setAzureOpenAiApiVersion(process.env.AZURE_OPENAI_API_VERSION),process.env.COPILOT_USE_SESSIONS!==void 0&&t.setCopilotUseSessions(process.env.COPILOT_USE_SESSIONS==="true"),t.setTrajectoryOutputFile(process.env.CPD_SAVE_TRAJECTORY_OUTPUT),t.setEventsLogDirectory(process.env.COPILOT_EVENTS_LOG_DIRECTORY),process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED!==void 0&&t.setDisableOnlineEvaluation(process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED==="true"),process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE!==void 0&&t.setEnableOnlineEvaluationOutputFile(process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE==="true"),process.env.COPILOT_FEATURE_FLAGS&&process.env.COPILOT_FEATURE_FLAGS.split(",").map(r=>r.trim()).filter(r=>r.length>0).forEach(r=>t.setFeatureFlagEnabled(r)),process.env.COPILOT_EXPERIMENTS&&process.env.COPILOT_EXPERIMENTS.split(",").map(r=>{let[I,a]=r.split(":");t.setExperiment(I,a)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let r=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(I=>parseInt(I.trim(),10));t.setRetryPolicy({errorCodesToRetry:r})}if(process.env.COPILOT_AGENT_REQUEST_HEADERS)try{let r=JSON.parse(process.env.COPILOT_AGENT_REQUEST_HEADERS);t.setRequestHeaders(r)}catch{}let l=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;l!==void 0&&!Number.isNaN(l)&&t.setTimeoutMs(l*60*1e3);let n=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return n!==void 0&&!Number.isNaN(n)&&t.setStartTimeMs(n*1e3),t.build()}c();c();var Rht=lt(Aht(),1);import{exec as Eht,execFile as $Hl}from"child_process";c();c();c();var Lee=null;function W_(){return!!Lee}function Lke(){if(!Lee)throw new Error("Settings have not been initialized");return Lee}function Zht(t){return Lee=t,t}function y_(){Lee=null}c();function Lo(t,e){return t?.featureFlags?.[e]??!1}function ght(t,e){return t?.experiments?.[e]}function Jke(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var KHl=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function xke(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":xke(n,e);break;case"undefined":break;default:if(KHl.includes(l)){let r=n.toString().trim();r!=""&&e.push(r)}break}return e}function Nht(t,e){if(isNaN(e)||!isFinite(e)||e<=0)return{isWithin:!1,withinMs:e};if(e>1)return{isWithin:!1,withinMs:e};if(!t.timeoutMs)return{isWithin:!1,withinMs:e};let l=t.timeoutMs*e;return t.startTimeMs?{isWithin:Date.now()-t.startTimeMs>=t.timeoutMs-l,withinMs:l}:{isWithin:!1,withinMs:l}}c();import*as Wht from"process";function Ske(t){let e=Wht.env[t];if(e&&e.trim()!=="")return e}var qHl=[/\b(?:eyJ0eXAiOi|eyJhbGciOi|eyJ4NXQiOi|eyJraWQiOi)[^\s'";]+/g,/\bBearer\s+[^\s'";]+/g,/\b(?:Password|Pwd)=(?:[^\s'";]+|"[^"]+")/gi,/\s+-(?:Password|Pwd)\s+(?:[^\s'";]+|"[^"]+")/gi,/\bv1\.[0-9A-Fa-f]{40}\b/g,/\bgh[pousr]{1}_[A-Za-z0-9]{36}\b/g,/\bgithub_pat_[0-9][A-Za-z0-9]{21}_[A-Za-z0-9]{59}\b/g,/(?:[a-zA-Z][a-zA-Z\d+-.]*):\/\/([a-zA-Z\d\-._~!$&'()*+,;=%]+):([a-zA-Z\d\-._~!$&'()*+,;=:%]*)@/g,/\b[0-9A-Za-z-_~.]{3}7Q~[0-9A-Za-z-_~.]{31}\b|\b[0-9A-Za-z-_~.]{3}8Q~[0-9A-Za-z-_~.]{34}\b/g,/\b[0-9A-Za-z+/]{76}(APIM|ACDb|\+(ABa|AMC|ASt))[0-9A-Za-z+/]{5}[AQgw]==/g,/\b[0-9A-Za-z+/]{33}(AIoT|\+(ASb|AEh|ARm))[A-P][0-9A-Za-z+/]{5}=/g,/\b[0-9A-Za-z_-]{44}AzFu[0-9A-Za-z\-_]{5}[AQgw]==/g,/\b[0-9A-Za-z]{42}AzSe[A-D][0-9A-Za-z]{5}\b/g,/\b[0-9A-Za-z+/]{42}\+ACR[A-D][0-9A-Za-z+/]{5}\b/g,/\b[0-9A-Za-z]{33}AzCa[A-P][0-9A-Za-z]{5}=/g,/\boy2[a-p][0-9a-z]{15}[aq][0-9a-z]{11}[eu][bdfhjlnprtvxz357][a-p][0-9a-z]{11}[aeimquy4]\b/g,/\bnpm_[0-9A-Za-z]{36}\b/g,/\bx-ghcr-signature=[^&]+/g],yht="******",b1=class t{static singleton;static getInstance(){return t.singleton||(t.singleton=new t),t.singleton}secretValuesToFilter;runner;logger;constructor(){}setRunner(e){this.runner=e,this.logger=e.logger,this.secretValuesToFilter=void 0}filterSecrets(e){let l=typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"message"),n=l?e.message??e.toString():e,r=this.getSecretValues();for(let I of r)n=n.replaceAll(I,yht);for(let I of qHl)n=n.replaceAll(I,yht);return l?(e.message=n,e):n}filterSecretsFromJsonString(e){try{let l=JSON.parse(e),n=this.filterSecretsFromObj(l);return JSON.stringify(n)}catch{return this.filterSecrets(e)}}filterSecretsFromObj(e){if(e==null)return e;if(typeof e=="string")return this.filterSecrets(e);if(typeof e=="number"){let l=this.filterSecrets(e.toString()),n=Number(l);return isNaN(n)?l:n}if(Array.isArray(e))return e.map(l=>this.filterSecretsFromObj(l));if(typeof e=="object"){let l={};for(let[n,r]of Object.entries(e))l[n]=this.filterSecretsFromObj(r);return l}return e}getSecretValues(){if(this.secretValuesToFilter)return this.secretValuesToFilter;let e={secretEnvVars:!1,runner:!1,settings:!1},l=new Set;for(let n of CAe){let r=Ske(n);r&&Bke(l,r)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let r=Ske(n);r&&Bke(l,r)}e.runner=!0}if(W_()){let n=xke(Lke());for(let r of n)Bke(l,r);e.settings=!0}return Object.values(e).every(n=>n)&&(this.secretValuesToFilter=l,this.logger?.debug("Caching secret values to filter from all sources.")),l}};function Bke(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function Jee(...t){let e=new Set(["DEBUG","COPILOT_AGENT_DEBUG",...t]);for(let l of e)if(process.env[l]==="1"||process.env[l]?.toLocaleLowerCase()==="true")return!0;return!1}var vF=class{logLevel;debugEnvironmentVariables;secretFilter=b1.getInstance();constructor(e,l){e===void 0?Jee(...l??[])?this.logLevel=15:this.logLevel=7:this.logLevel=e,this.debugEnvironmentVariables=l}filterSecrets(e){return typeof e=="string"?this.secretFilter.filterSecrets(e):this.secretFilter.filterSecrets(e)}shouldLog(e){return this.logLevel===void 0||(this.logLevel&e)===e}isDebug(){return Jee(...this.debugEnvironmentVariables??[])}};var aW=class{logger;constructor(e){this.logger=e}async exec(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),0}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}async execReturn(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),{exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}_exec(e,l,n,r=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let I={cwd:n.cwd,env:n.env,shell:n.shell,timeout:n.timeout,signal:n.abortSignal};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?Eht(e,I):n.shell?Eht(`${e} ${(0,Rht.default)(l)}`,I):$Hl(e,l,I),d="",u="";o.stdout?.on("data",b=>{d+=b}),o.stderr?.on("data",b=>{u+=b}),o.on("close",(b,p)=>{if(b!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,r),g=new Error(`Command failed with exit code ${b}: ${h}`);g.cmd=h,g.code=b,g.stdout=d,g.stderr=u,g.signal=p,s(g)}else a({error:null,stdout:d,stderr:u,exitCode:b})}),o.on("error",b=>{b.stdout=d,b.stderr=u,b.cmd=this.filterCommand(e,l,r),s(b)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let r=l.reduce((I,a)=>(n.includes(a)?I.push("REDACTED"):I.push(a),I),[]);return`${e} ${r.join(" ")}`}};c();import{randomUUID as eXl}from"crypto";import{cpSync as tXl,existsSync as Sht,mkdtempSync as lXl,rmSync as nXl}from"fs";import{homedir as Bht,tmpdir as rXl}from"os";import{join as Oee}from"path";c();var O3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let r=e.code,I=e.message;"stdout"in e&&"stderr"in e&&(I+=`
|
|
806
806
|
`+e.stderr?.trim()+`
|
|
807
807
|
`+e.stdout?.trim()),I.includes("GH013: Repository rule violations found")||I.includes("unknown revision or path not in the working tree")?(l="protection rule",n=!0):I.includes("You may want to try Git Large File Storage")||I.includes("GH001: Large files detected")?(l="LFS",n=!0):r===1&&(I.includes("hook failed")||I.includes("husky -")||I.includes("hook declined")||I.includes("hook exited")||I.includes("vite ")||I.includes("eslint "))?(l="hook",n=!0):I.includes("use 'git pull' before pushing again")?(l="pull first",n=!0):I.includes("fetch first")?(l="fetch first",n=!0):I.includes("The requested URL returned error: 403")?(l="access denied",n=!1):I.includes("unexpected disconnect")?(l="disconnect",n=!1):(l="unknown",n=!(r==="ENOENT"||r===127||r===128||I.includes("fatal: ")))}super(`${l} git error: ${e.message}`);for(let r of Object.keys(e))this[r]=e[r];this.errorType=l??"unknown",this.skipReport=n,this.cause=e,Object.setPrototypeOf(this,t.prototype),this.name="GitError"}};c();var xee="https://api.githubcopilot.com";function Yht(t){if(!t.github?.user?.name)throw new Error("GitHub user name is required");return t.github.user.name}function Vht(t){if(!t.github?.user?.email)throw new Error("GitHub user email is required");return t.github.user.email}function Qht(t){let e=t.github?.user?.actorLogin,l=t.github?.user?.actorId;if(!(!e||!l))return{login:e,id:l}}function wht(t){if(!t.github?.serverUrl)throw new Error("GitHub server URL is required");return t.github.serverUrl}function Fht(t){if(!t.github?.host)throw new Error("GitHub host is required");return t.github.host}function Cht(t){if(!t.github?.hostProtocol)throw new Error("GitHub host protocol is required");return t.github.hostProtocol}function T3(t){if(!t.github?.token)throw new Error("GitHub token is required");return t.github.token}function vAe(t){if(!t.github?.repo?.name)throw new Error("GitHub repository name is required");return t.github.repo.name}function U3(t){if(!t.service?.instance?.id)throw new Error("Instance ID is required");return t.service.instance.id}function vht(t){if(!t.service?.callback?.url)throw new Error("Callback URL is required");return t.service.callback.url}function fht(t){if(!t.api?.anthropic?.key)throw new Error("Anthropic API key is required");return t.api.anthropic.key}function Hht(t){if(!t.api?.openai?.apiKey)throw new Error("OpenAI API key is required");return t.api.openai.apiKey}function Xht(t){if(!t.api?.openai?.azure?.url)throw new Error("Azure OpenAI deployment URL is required");return t.api.openai.azure.url}function kht(t,e=xee){let l=t.api?.copilot?.url||e;if(!l)throw new Error("Copilot URL is required");return l}function See(t){if(!t.api?.copilot?.integrationId)throw new Error("Copilot integration ID is required");return t.api.copilot.integrationId}function Bee(t){if(!t.api?.copilot?.token)throw new Error("Copilot token is required");return t.api.copilot.token}function Lht(t){if(!t.github?.uploadsUrl)throw new Error("GitHub uploads URL is required");return t.github.uploadsUrl}function Jht(t){if(!t.github?.downloadsUrl)throw new Error("GitHub downloads URL is required");return t.github.downloadsUrl}c();function xht(t){return t.startsWith('"')&&t.endsWith('"')?(t=t.substring(1,t.length-1),t.replace(/\\([abfnrtv\\"]|[0-7]{1,3})/g,(e,l)=>{switch(l[0]){case"a":return"\x07";case"b":return"\b";case"f":return"\f";case"n":return`
|
|
808
808
|
`;case"r":return"\r";case"t":return" ";case"v":return"\v";case"\\":return"\\";case'"':return'"';default:return String.fromCharCode(parseInt(l,8))}})):t}var Oke='!f() { test "$1" = get && echo "password=$GITHUB_TOKEN"; }; f',ag=class{constructor(e,l){this.logger=e;this.exec=l}resolveGitUrl(e,l){let n=null,r="";try{r=wht(e),n=new URL(r)}catch(I){this.logger.warning(`Failed to parse GITHUB_SERVER_URL "${r}". Falling back to GITHUB_HOST and GITHUB_GIT_HOST_PROTOCOL. Error: ${I.message??I}`);let a=Cht(e),s=Fht(e);try{n=URL.parse(`${a}://${s}`)}catch(o){this.logger.warning(`Unable to determine GITHUB_SERVER_URL. Falling back to "https://github.com". Error: ${o.message??o}`),n=URL.parse("https://github.com")}}if(!n)throw new Error("Could not determine the Git URL");return l&&(n.pathname=l),this.logger.info(`Using Git URL: ${n.href}`),n}async cloneRepo(e,l,n,r,I,a){process.env.GITHUB_TOKEN=process.env.GITHUB_TOKEN??T3(e);let o=this.resolveGitUrl(e,l).href;if(I=I??1,I+=1,I<2&&(I=2),Sht(Oee(n,".git"))){let N={cwd:n,silent:!0};if(this.logger.debug(`Repo ${l} already cloned to ${n}`),this.logger.debug(`Configuring git credential helper for ${l}`),await this.setGitConfig(e,N,!1),await this.execGit(["remote","set-url","origin",o],N,[o]),(await this.execGit(["rev-parse","--abbrev-ref","HEAD"],N)).stdout.toString().trim()===r){this.logger.debug(`Already on branch ${r} in repo ${l}`);return}if((await this.execGit(["branch","--list",r],N,[r])).stdout.toString().trim().length>0){this.logger.debug(`Local branch ${r} already exists in repo ${l}`),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout",r],N,[r]);return}if(await this.hasRemoteBranch(r,n)){this.logger.debug(`Remote branch ${r} exists in repo ${l}`);let{stdout:Q}=await this.execGit(["rev-parse","--is-shallow-repository"],N);Q.trim()==="true"?await this.execGit(["fetch","--unshallow","--update-head-ok","origin","+refs/heads/*:refs/heads/*"],N):await this.execGit(["fetch","origin"],N),this.logger.debug(`Pulling branch ${r} with depth ${I}`),await this.execGit(["pull","--depth",I.toString(),"origin",r],N,[I.toString(),r]),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout",r],N,[r]);return}if(a){this.logger.debug(`Base commit ${a} provided for branch ${r} in repo ${l}`),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout","-b",r,a],N,[r,a]);return}throw new Error(`Branch ${r} does not exist in repo ${l} and no base commit was provided.`)}this.logger.debug(`Repo ${l} not cloned to ${n} yet`);let u=process.env.HOME||Bht(),b=lXl(Oee(rXl(),`cpd-${eXl()}`));Sht(Oee(u,".gitconfig"))&&tXl(Oee(u,".gitconfig"),Oee(b,".gitconfig"));let p={...process.env,HOME:b},h={silent:!0,env:p},g={cwd:n,silent:!0,env:p};await this.setGitConfig(e,h,!0);try{this.logger.debug(`Cloning repo ${l} to ${n} with branch ${r} and depth ${I}`),await this.execGit(["clone","-b",r,"--single-branch","--depth",I.toString(),o,n],h,[o,n,r,I.toString()])}catch(N){if(this.logger.debug(`Error cloning repo ${l} to ${n}: ${N}`),a)this.logger.debug(`Base commit ${a} provided. Checking out branch ${r}`),await this.execGit(["clone",o,n],h,[o,n]),await this.execGit(["checkout","-b",r,a],g,[r,a]);else throw new Error(`Branch ${r} does not exist in repo ${l} and no base commit was provided.`)}finally{await this.cleanGitConfig(h,!0,!0)}await this.setGitConfig(e,g,!1)}async commitChanges(e,l,n,r,I=!1,a=!1){process.env.HOME||(process.env.HOME=Bht());let s={cwd:n,silent:!0},o=Qht(e);if(o){let b=`Co-authored-by: ${o.login} <${o.id}+${o.login}@users.noreply.github.com>`;r=r.trim()+`
|
|
@@ -886,16 +886,9 @@ ${n.join(`
|
|
|
886
886
|
`,input_schema:{type:"object",properties:{reply:{type:"string",description:"A short reply to the comment that addresses the user's request, question, or feedback"},comment_id:{type:"number",description:"Id of the comment thread to reply to. Use the <comment_id> of the <comment_new>."}},required:["reply","comment_id"]},callback:async l=>{e.startGroup(`Reply to comment ${l.comment_id}`,8),e.debug(l.reply),e.endGroup(8);let n;try{if(n=typeof l.comment_id=="string"?parseInt(l.comment_id,10):l.comment_id,isNaN(n))return`error: invalid comment_id provided. Expected a valid number but received: ${l.comment_id}`}catch(r){return`error: failed to parse comment_id as a number: ${r}`}return await m9l(n,l.reply,e,t.callback),`Replied to comment_id ${l.comment_id}.`},safeForTelemetry:!0});async function m9l(t,e,l,n){try{await n?.commentReply({comment_id:t,message:e})}catch(r){l.error(`Error replying to comment: ${r}`)}}c();c();import{isAbsolute as p9l,resolve as h9l}from"path";c();import*as PX from"fs";import*as Pge from"path";import{join as b9l}from"path";async function qF(t){try{return(await PX.promises.stat(t)).isDirectory()?"directory":"file"}catch{return!1}}function IE(t){if(!t)return t;if(t.startsWith("@")){let e=t.slice(1);try{let l=Pge.resolve(process.cwd(),e);if(!PX.existsSync(l))throw new Error(`File not found: ${e}`);return PX.readFileSync(l,"utf-8").trim()}catch(l){throw l instanceof Error?new Error(`Failed to read file ${e}: ${l.message}`):l}}return t}function jge(t){try{if(Kge(t)===!0)return"directory";let e=Pge.extname(t);return G9l.has(e)?e:"not-safe"}catch{return"unknown"}}function Kge(t){try{return PX.statSync(t).isDirectory()}catch(e){if(e.code==="ENOENT")return"does-not-exist"}return"unknown"}function qge(...t){let e=b9l(...t);return process.platform==="win32"&&(e=e.replace(/^\.\\/,"").replaceAll("\\","/")),e}var G9l=new Set(["",".ts",".py",".cs",".tsx",".md",".js",".json",".go",".php",".yml",".rb",".html",".java",".dart",".rs",".swift",".css",".csproj",".razor",".kt",".sh",".vue",".yaml",".jsx",".cpp",".txt",".gitignore",".toml",".sql",".scss",".ps1",".cshtml",".tf",".xml",".github",".erb",".svelte",".h",".c",".example",".mjs",".astro",".xaml",".sln",".env",".bicep",".gradle",".ex",".prisma",".kts",".scala",".Tests",".R",".mod",".props",".ejs",".j2",".properties",".lua",".hpp",".cls",".vb",".ipynb",".mqh",".exs",".gs",".ini",".sol",".pas",".aspx",".mdx",".config",".csv",".m",".png",".jpg",".jpeg",".gif",".svg",".ico",".webp",".bmp",".tiff",".mp3",".wav",".ogg",".m4a",".flac",".mp4",".webm",".avi",".mov",".mkv",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".zip",".rar",".7z",".tar",".gz",".exe",".dll",".so",".dylib",".bin"]);var A9l=10*1024;function _yt(t,e,l,n="middle"){let r=l.countTokens(t),I=l.tokenLimit;if(r>I){let a=I/r,s=Math.floor(t.length*a);return Rc(t,e,s,n)}else return t}function Rc(t,e,l=A9l,n="middle"){if(t.length<=l)return t;let r=t.split(`
|
|
887
887
|
`);if(r.length>1){let a=new Set([]),s=0;if(n==="middle"){let b=Math.floor(r.length/2);a.add(b),s+=r[b].length+1;let p=0,h=0;for(;t.length-s>l;){let g;p===h?(p++,g=-p):(h++,g=h);let N=b+g;if(N<=0||N>=r.length-1)break;a.add(N),s+=r[N].length+1}}else if(n==="start"){let b=0;for(;t.length-s>l&&(a.add(b),s+=r[b].length+1,b++,!(b>=r.length-1)););}else{let b=r.length-1;for(;t.length-s>l&&(a.add(b),s+=r[b].length+1,b--,!(b<=0)););}let o="",d=a.size,u=!1;for(let b=0;b<r.length;b++){if(a.has(b)){u||(u=!0,o+=`<${e} too long - dropped ${d} lines from the ${n}>
|
|
888
888
|
`);continue}o+=r[b]+(b<r.length-1?`
|
|
889
|
-
`:"")}return o}else return n==="middle"?t.slice(0,l/2)+`<${e} too long - dropped ${t.length-l} characters from the middle>`+t.slice(t.length-l/2):n==="start"?`<${e} too long - dropped ${t.length-l} characters from the start>`+t.slice(t.length-l):t.slice(0,l)+`<${e} too long - dropped ${t.length-l} characters from the end>`}async function Dyt(t,e,l){try{let n=new TextEncoder().encode(e),r=await t.execReturn("git",["apply","--binary"],{cwd:l,input:Buffer.from(n)});return r.stdout||r.stderr}catch(n){return`Error applying patch: ${n.message}`}}function $ge(){let t={};for(let e in process.env)!Ght.includes(e)&&process.env[e]!==void 0&&(t[e]=process.env[e]);return t}async function zyt(t,e){if(p9l(t))return t;let l=h9l(e,t);return await qF(l)?l:t}var Ile="report_progress",Z9l=
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
* Use markdown checklists to show progress (- [x] for completed items, - [ ] for pending items).
|
|
893
|
-
* Keep the checklist structure as consistent as you can between updates, while still being accurate and useful.${t>0?`
|
|
894
|
-
* Include "Fixes #${t}." as the last line of the body in the PR description.`:""}
|
|
895
|
-
* Don't use headers in the PR description, just the checklist.
|
|
896
|
-
* If there are changes in the repo this tool will run \`git add .\`, \`git commit -m <msg>\`, and \`git push\`.`,Pyt=(t,e,l,n,r)=>({name:Ile,description:Z9l(e),input_schema:{type:"object",properties:{commitMessage:{type:"string",description:"A short single line of text to use as the commit message"},prDescription:{type:"string",description:"A description of work completed and remaining, using markdown checklists"}},required:["commitMessage","prDescription"]},callback:async I=>{let a=new ag(n,r);if(n.startGroup(I.commitMessage,8),n.debug(I.prDescription),n.endGroup(8),!t.branchName)throw new Error("branchName is required for report_progress tool");let{output:s,isError:o}=await g9l(t.location,I.commitMessage,t.branchName,t.push??!1,l,n,a),{isError:d}=await N9l(I.prDescription,t.branchName,n,t.callback),u=[s||"No changes to commit and push.",d?"Error reporting progress.":"Progress reported successfully."].filter(h=>h).join(`
|
|
897
|
-
|
|
898
|
-
`),b=Rc(u,"output"),p=o||d?"failure":"success";return{textResultForLlm:b,error:p==="failure"?b:void 0,resultType:p,sessionLog:b,toolTelemetry:{}}},safeForTelemetry:!0});async function g9l(t,e,l,n,r,I,a){let s="";try{let o=n?a.commitAndPushChanges:a.commitChanges;return s+=await o.bind(a)(r,l,t,e,!1),{output:s,isError:!1}}catch(o){return I.error(`Error committing and pushing changes: ${o}`),s+="Error committing and pushing changes.",{output:s,isError:!0}}}async function N9l(t,e,l,n){try{return await n?.partialResult({branchName:e,message:t}),{isError:!1}}catch(r){return l.error(`Error reporting progress: ${r}`),{isError:!0}}}c();var IEt=lt(Kyt(),1);import{existsSync as C9l}from"fs";import{readdir as v9l,readFile as Qxe,stat as f9l,writeFile as wxe}from"fs/promises";import{dirname as H9l,isAbsolute as X9l}from"path";c();c();import*as qyt from"crypto";function gx(t){let e=qyt.createHash("sha256");return e.update(t),e.digest("hex")}var tNe=class{perPathEditsTracking;constructor(){this.perPathEditsTracking=new Map}reset(){this.perPathEditsTracking.clear()}trackEdit(e,l,n,r){let I=gx(e),a=jge(e);this.perPathEditsTracking.has(I)||this.perPathEditsTracking.set(I,{edits:[],numEditsByCommand:{},numFailedEdits:0,numSuccessfulEdits:0,wasLastEditSuccessful:!1,fileExtension:a});let s=this.perPathEditsTracking.get(I);s.fileExtension=a;let o=s.edits[s.edits.length-1],d=o&&o.result==="failure"?o.lenPriorFailureSequence+1:0;return s.edits.push({id:r||s.edits.length.toString(),command:l,result:n,lenPriorFailureSequence:d}),s.numEditsByCommand[l]?s.numEditsByCommand[l]++:s.numEditsByCommand[l]=1,n==="success"?(s.numSuccessfulEdits++,s.wasLastEditSuccessful=!0):(s.numFailedEdits++,s.wasLastEditSuccessful=!1),I}getTrackedEditsForPath(e){let l=this.perPathEditsTracking.get(e);if(l)return JSON.parse(JSON.stringify(l))}getTrackedEdits(){return JSON.parse(JSON.stringify(Object.fromEntries(this.perPathEditsTracking.entries())))}getTrackedEditsJsonArrString(){return JSON.stringify(Array.from(this.perPathEditsTracking.entries()).map(([e,l])=>({...l,hashedPath:e})))}};c();function V9l(t){if(!t)return t===""?`
|
|
889
|
+
`:"")}return o}else return n==="middle"?t.slice(0,l/2)+`<${e} too long - dropped ${t.length-l} characters from the middle>`+t.slice(t.length-l/2):n==="start"?`<${e} too long - dropped ${t.length-l} characters from the start>`+t.slice(t.length-l):t.slice(0,l)+`<${e} too long - dropped ${t.length-l} characters from the end>`}async function Dyt(t,e,l){try{let n=new TextEncoder().encode(e),r=await t.execReturn("git",["apply","--binary"],{cwd:l,input:Buffer.from(n)});return r.stdout||r.stderr}catch(n){return`Error applying patch: ${n.message}`}}function $ge(){let t={};for(let e in process.env)!Ght.includes(e)&&process.env[e]!==void 0&&(t[e]=process.env[e]);return t}async function zyt(t,e){if(p9l(t))return t;let l=h9l(e,t);return await qF(l)?l:t}var Ile="report_progress",Z9l="Report progress on the task. Call when you complete a meaningful unit of work. Commits and pushes changes that are pending in the repo, then updates the PR description.\n* Use this tool at least once, and as early as possible once you've established a plan. Outline the complete plan as a checklist.\n* Use only when you have meaningful progress to report (you need to update the plan in the checklist, you have code changes to commit, or you have completed a new item in the checklist)\n* Use markdown checklists to show progress (- [x] for completed items, - [ ] for pending items).\n* Keep the checklist structure as consistent as you can between updates, while still being accurate and useful.\n* Don't use headers in the PR description, just the checklist.\n* If there are changes in the repo this tool will run `git add .`, `git commit -m <msg>`, and `git push`.",Pyt=(t,e,l,n)=>({name:Ile,description:Z9l,input_schema:{type:"object",properties:{commitMessage:{type:"string",description:"A short single line of text to use as the commit message"},prDescription:{type:"string",description:"A description of work completed and remaining, using markdown checklists"}},required:["commitMessage","prDescription"]},callback:async r=>{let I=new ag(l,n);if(l.startGroup(r.commitMessage,8),l.debug(r.prDescription),l.endGroup(8),!t.branchName)throw new Error("branchName is required for report_progress tool");let{output:a,isError:s}=await g9l(t.location,r.commitMessage,t.branchName,t.push??!1,e,l,I),{isError:o}=await N9l(r.prDescription,t.branchName,l,t.callback),d=[a||"No changes to commit and push.",o?"Error reporting progress.":"Progress reported successfully."].filter(p=>p).join(`
|
|
890
|
+
|
|
891
|
+
`),u=Rc(d,"output"),b=s||o?"failure":"success";return{textResultForLlm:u,error:b==="failure"?u:void 0,resultType:b,sessionLog:u,toolTelemetry:{}}},safeForTelemetry:!0});async function g9l(t,e,l,n,r,I,a){let s="";try{let o=n?a.commitAndPushChanges:a.commitChanges;return s+=await o.bind(a)(r,l,t,e,!1),{output:s,isError:!1}}catch(o){return I.error(`Error committing and pushing changes: ${o}`),s+="Error committing and pushing changes.",{output:s,isError:!0}}}async function N9l(t,e,l,n){try{return await n?.partialResult({branchName:e,message:t}),{isError:!1}}catch(r){return l.error(`Error reporting progress: ${r}`),{isError:!0}}}c();var IEt=lt(Kyt(),1);import{existsSync as C9l}from"fs";import{readdir as v9l,readFile as Qxe,stat as f9l,writeFile as wxe}from"fs/promises";import{dirname as H9l,isAbsolute as X9l}from"path";c();c();import*as qyt from"crypto";function gx(t){let e=qyt.createHash("sha256");return e.update(t),e.digest("hex")}var tNe=class{perPathEditsTracking;constructor(){this.perPathEditsTracking=new Map}reset(){this.perPathEditsTracking.clear()}trackEdit(e,l,n,r){let I=gx(e),a=jge(e);this.perPathEditsTracking.has(I)||this.perPathEditsTracking.set(I,{edits:[],numEditsByCommand:{},numFailedEdits:0,numSuccessfulEdits:0,wasLastEditSuccessful:!1,fileExtension:a});let s=this.perPathEditsTracking.get(I);s.fileExtension=a;let o=s.edits[s.edits.length-1],d=o&&o.result==="failure"?o.lenPriorFailureSequence+1:0;return s.edits.push({id:r||s.edits.length.toString(),command:l,result:n,lenPriorFailureSequence:d}),s.numEditsByCommand[l]?s.numEditsByCommand[l]++:s.numEditsByCommand[l]=1,n==="success"?(s.numSuccessfulEdits++,s.wasLastEditSuccessful=!0):(s.numFailedEdits++,s.wasLastEditSuccessful=!1),I}getTrackedEditsForPath(e){let l=this.perPathEditsTracking.get(e);if(l)return JSON.parse(JSON.stringify(l))}getTrackedEdits(){return JSON.parse(JSON.stringify(Object.fromEntries(this.perPathEditsTracking.entries())))}getTrackedEditsJsonArrString(){return JSON.stringify(Array.from(this.perPathEditsTracking.entries()).map(([e,l])=>({...l,hashedPath:e})))}};c();function V9l(t){if(!t)return t===""?`
|
|
899
892
|
`:void 0;let e=t.startsWith(`
|
|
900
893
|
`),l=t.endsWith(`
|
|
901
894
|
`);return e||(t=`
|
|
@@ -1956,7 +1949,7 @@ Pay attention to the following when using it:
|
|
|
1956
1949
|
This tool is used to perform a semantic search of the codebase to find relevant information based on the question asked.
|
|
1957
1950
|
* It leverages advanced AI techniques to understand the context and semantics of the codebase.
|
|
1958
1951
|
* Use this tool when you need to find information that is not easily accessible through traditional search methods.
|
|
1959
|
-
`,input_schema:{type:"object",properties:{question:{type:"string",description:"A question about the codebase. It should reference by name any topics, specific file names, and concepts that are relevant to the question and specify the desired output format."}},required:["question"]},callback:async n=>{let r,I=vAe(t),a="",s="",o=I.split("/");if(o.length===2){[a,s]=o,l.info("Searching for repository insights");try{r=await fPe(n.question,a,s,e,l),l.info(`Blackbird results: ${r}`)}catch(d){l.error(`Error occurred while searching for repository insights: ${d}`)}}return{resultType:"success",textResultForLlm:r??"No results found.",toolTelemetry:{}}}}}async function WSt(t,e,l,n,r,I,a){let s=await ySt(t),o=await yhn(t,l,n),d=gSt(l)?[new AYe(n,l,r,I,t,t.location,$ge(),a).getSearch()]:[],u=t.splitEditingTools?Cxe(t,n,l):[nNe(t,n,l)];return[s.shellTool,...s.otherTools??[],...o,...d,...u,Pyt(t,e,l,n,r),Lo(l,nLe)?EAt(t,n,r,l):void 0,t?.requireReasoning?fxe(t):void 0,Lo(l,Oyt)?Tyt:void 0,await Ehn(t,l,n,r)].filter(b=>b!==void 0)}async function kPe(t,e){let l=await ySt(t),n=t.splitEditingTools?Cxe(t,e):[nNe(t,e)];return[l.shellTool,...l.otherTools??[],...n,t?.requireReasoning?fxe(t):void 0].filter(r=>r!==void 0)}async function Whn(t,e,l,n,r,I,a){return[...await WSt(t,e,l,n,r,I,a),Myt(t,n)]}var LPe=t=>({...uQ,supports:{...uQ.supports,reasoning:t?.thinkingMode?!0:uQ.supports?.reasoning}}),uQ={supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!1},createPR:{toolInit:WSt,jitInstructions:UOe},prDetails:{},respondToPRComment:{toolInit:Whn,jitInstructions:UOe}},JPe=t=>({"sweagent-capi":{"claude-3.5-sonnet":{...uQ,supports:{tool_choice:!1,reasoning:!1}},"claude-3.7-sonnet":{...uQ,supports:{tool_choice:!1,reasoning:!1,vision:!0}},"claude-sonnet-4":{...uQ,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},"claude-sonnet-4.5":{...uQ,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},oswe:{...uQ,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"oswe-prime":{...uQ,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"gpt-5":{...uQ,supports:{tool_choice:!0,reasoning:!0,parallel_tool_calls:!0,vision:!0,steering:!0},toolConfigOverrides:{splitEditingTools:!0}}}});async function ySt(t){let e=new sNe(t);return{shellTool:e.getShellTool(),otherTools:[e.getWriteShellTool(),e.getReadShellTool(),e.getStopShellTool()]}}async function yhn(t,e,l){if(qSe(e,"cloud"))return[new Cle(new BNe(e,l,void 0)).getStoreMemory()];if(qSe(e,"local")){let n=new Cle(new SNe(t.location));return[n.getStoreMemory(),n.getReadMemory()]}return[]}async function Ehn(t,e,l,n){if(t.includeCodeQLTool){let r=new ag(l,n),I=e.swebench_base_commit&&e.swebench_base_commit!=="undefined"?e.swebench_base_commit:await r.getCurrentCommitHash(t.location);return new zge(t,r,I,e,l).getCodeQLCheckerTool()}}c();async function ESt(t,e){switch(t.kind){case"image_processing":return e.onImageProcessingEvent(t);case"images_removed":return e.onImageRemovalEvent(t);case"message":return e.onMessage(t);case"model_call_failure":return e.onModelCallFailure(t);case"model_call_success":return await e.onModelCallSuccess(t);case"response":return e.onResponse(t);case"tool_execution":return e.onToolExecution(t);case"history_truncated":return e.onTruncationEvent(t);case"turn_started":case"turn_ended":case"turn_failed":case"turn_retry":return e.onTurnEvent(t);default:{let l=t;throw new Error(`unexpected event kind: ${JSON.stringify(t)}`)}}}c();c();c();import{Writable as U0n}from"stream";c();c();c();c();c();var P={};ob(P,{BRAND:()=>jhn,DIRTY:()=>L9,EMPTY_PATH:()=>Qhn,INVALID:()=>Tr,NEVER:()=>yAn,OK:()=>Ch,ParseStatus:()=>Ep,Schema:()=>Na,ZodAny:()=>Jk,ZodArray:()=>Ov,ZodBigInt:()=>x9,ZodBoolean:()=>S9,ZodBranded:()=>Xce,ZodCatch:()=>K9,ZodDate:()=>B9,ZodDefault:()=>j9,ZodDiscriminatedUnion:()=>NYe,ZodEffects:()=>jE,ZodEnum:()=>z9,ZodError:()=>Fh,ZodFirstPartyTypeKind:()=>jr,ZodFunction:()=>yYe,ZodIntersection:()=>M9,ZodIssueCode:()=>vl,ZodLazy:()=>_9,ZodLiteral:()=>D9,ZodMap:()=>TK,ZodNaN:()=>MK,ZodNativeEnum:()=>P9,ZodNever:()=>k2,ZodNull:()=>T9,ZodNullable:()=>GQ,ZodNumber:()=>J9,ZodObject:()=>_g,ZodOptional:()=>zE,ZodParsedType:()=>fn,ZodPipeline:()=>kce,ZodPromise:()=>xk,ZodReadonly:()=>q9,ZodRecord:()=>WYe,ZodSchema:()=>Na,ZodSet:()=>UK,ZodString:()=>Lk,ZodSymbol:()=>BK,ZodTransformer:()=>jE,ZodTuple:()=>bQ,ZodType:()=>Na,ZodUndefined:()=>O9,ZodUnion:()=>U9,ZodUnknown:()=>Bv,ZodVoid:()=>OK,addIssueToContext:()=>An,any:()=>OPe,array:()=>Bd,bigint:()=>eAn,boolean:()=>ci,coerce:()=>Jce,custom:()=>vSt,date:()=>tAn,datetimeRegex:()=>FSt,defaultErrorMap:()=>xv,discriminatedUnion:()=>Lce,effect:()=>GAn,enum:()=>Dg,function:()=>dAn,getErrorMap:()=>JK,getParsedType:()=>mQ,instanceof:()=>qhn,intersection:()=>oAn,isAborted:()=>ZYe,isAsync:()=>xK,isDirty:()=>gYe,isValid:()=>kk,late:()=>Khn,lazy:()=>uAn,literal:()=>Zr,makeIssue:()=>Hce,map:()=>iAn,nan:()=>$hn,nativeEnum:()=>mAn,never:()=>IAn,null:()=>rAn,nullable:()=>hAn,number:()=>vh,object:()=>$l,objectUtil:()=>xPe,oboolean:()=>WAn,onumber:()=>NAn,optional:()=>pAn,ostring:()=>gAn,pipeline:()=>ZAn,preprocess:()=>AAn,promise:()=>bAn,quotelessJson:()=>Rhn,record:()=>L2,set:()=>cAn,setErrorMap:()=>Vhn,strictObject:()=>sAn,string:()=>Vt,symbol:()=>lAn,transformer:()=>GAn,tuple:()=>TPe,undefined:()=>nAn,union:()=>fh,unknown:()=>pQ,util:()=>os,void:()=>aAn});c();c();c();c();c();var os;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function l(r){throw new Error}t.assertNever=l,t.arrayToEnum=r=>{let I={};for(let a of r)I[a]=a;return I},t.getValidEnumValues=r=>{let I=t.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),a={};for(let s of I)a[s]=r[s];return t.objectValues(a)},t.objectValues=r=>t.objectKeys(r).map(function(I){return r[I]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let I=[];for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&I.push(a);return I},t.find=(r,I)=>{for(let a of r)if(I(a))return a},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function n(r,I=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(I)}t.joinValues=n,t.jsonStringifyReplacer=(r,I)=>typeof I=="bigint"?I.toString():I})(os||(os={}));var xPe;(function(t){t.mergeShapes=(e,l)=>({...e,...l})})(xPe||(xPe={}));var fn=os.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),mQ=t=>{switch(typeof t){case"undefined":return fn.undefined;case"string":return fn.string;case"number":return Number.isNaN(t)?fn.nan:fn.number;case"boolean":return fn.boolean;case"function":return fn.function;case"bigint":return fn.bigint;case"symbol":return fn.symbol;case"object":return Array.isArray(t)?fn.array:t===null?fn.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?fn.promise:typeof Map<"u"&&t instanceof Map?fn.map:typeof Set<"u"&&t instanceof Set?fn.set:typeof Date<"u"&&t instanceof Date?fn.date:fn.object;default:return fn.unknown}};var vl=os.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Rhn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Fh=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let l=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,l):this.__proto__=l,this.name="ZodError",this.issues=e}format(e){let l=e||function(I){return I.message},n={_errors:[]},r=I=>{for(let a of I.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)n._errors.push(l(a));else{let s=n,o=0;for(;o<a.path.length;){let d=a.path[o];o===a.path.length-1?(s[d]=s[d]||{_errors:[]},s[d]._errors.push(l(a))):s[d]=s[d]||{_errors:[]},s=s[d],o++}}};return r(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,os.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=l=>l.message){let l={},n=[];for(let r of this.issues)if(r.path.length>0){let I=r.path[0];l[I]=l[I]||[],l[I].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:l}}get formErrors(){return this.flatten()}};Fh.create=t=>new Fh(t);var Yhn=(t,e)=>{let l;switch(t.code){case vl.invalid_type:t.received===fn.undefined?l="Required":l=`Expected ${t.expected}, received ${t.received}`;break;case vl.invalid_literal:l=`Invalid literal value, expected ${JSON.stringify(t.expected,os.jsonStringifyReplacer)}`;break;case vl.unrecognized_keys:l=`Unrecognized key(s) in object: ${os.joinValues(t.keys,", ")}`;break;case vl.invalid_union:l="Invalid input";break;case vl.invalid_union_discriminator:l=`Invalid discriminator value. Expected ${os.joinValues(t.options)}`;break;case vl.invalid_enum_value:l=`Invalid enum value. Expected ${os.joinValues(t.options)}, received '${t.received}'`;break;case vl.invalid_arguments:l="Invalid function arguments";break;case vl.invalid_return_type:l="Invalid function return type";break;case vl.invalid_date:l="Invalid date";break;case vl.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(l=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(l=`${l} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?l=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?l=`Invalid input: must end with "${t.validation.endsWith}"`:os.assertNever(t.validation):t.validation!=="regex"?l=`Invalid ${t.validation}`:l="Invalid";break;case vl.too_small:t.type==="array"?l=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?l=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?l=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?l=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?l=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:l="Invalid input";break;case vl.too_big:t.type==="array"?l=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?l=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?l=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?l=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?l=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:l="Invalid input";break;case vl.custom:l="Invalid input";break;case vl.invalid_intersection_types:l="Intersection results could not be merged";break;case vl.not_multiple_of:l=`Number must be a multiple of ${t.multipleOf}`;break;case vl.not_finite:l="Number must be finite";break;default:l=e.defaultError,os.assertNever(t)}return{message:l}},xv=Yhn;var RSt=xv;function Vhn(t){RSt=t}function JK(){return RSt}c();var Hce=t=>{let{data:e,path:l,errorMaps:n,issueData:r}=t,I=[...l,...r.path||[]],a={...r,path:I};if(r.message!==void 0)return{...r,path:I,message:r.message};let s="",o=n.filter(d=>!!d).slice().reverse();for(let d of o)s=d(a,{data:e,defaultError:s}).message;return{...r,path:I,message:s}},Qhn=[];function An(t,e){let l=JK(),n=Hce({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l,l===xv?void 0:xv].filter(r=>!!r)});t.common.issues.push(n)}var Ep=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,l){let n=[];for(let r of l){if(r.status==="aborted")return Tr;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,l){let n=[];for(let r of l){let I=await r.key,a=await r.value;n.push({key:I,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,l){let n={};for(let r of l){let{key:I,value:a}=r;if(I.status==="aborted"||a.status==="aborted")return Tr;I.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),I.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(n[I.value]=a.value)}return{status:e.value,value:n}}},Tr=Object.freeze({status:"aborted"}),L9=t=>({status:"dirty",value:t}),Ch=t=>({status:"valid",value:t}),ZYe=t=>t.status==="aborted",gYe=t=>t.status==="dirty",kk=t=>t.status==="valid",xK=t=>typeof Promise<"u"&&t instanceof Promise;c();c();var or;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(or||(or={}));var PE=class{constructor(e,l,n,r){this._cachedPath=[],this.parent=e,this.data=l,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},YSt=(t,e)=>{if(kk(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let l=new Fh(t.common.issues);return this._error=l,this._error}}};function la(t){if(!t)return{};let{errorMap:e,invalid_type_error:l,required_error:n,description:r}=t;if(e&&(l||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,s)=>{let{message:o}=t;return a.code==="invalid_enum_value"?{message:o??s.defaultError}:typeof s.data>"u"?{message:o??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:o??l??s.defaultError}},description:r}}var Na=class{get description(){return this._def.description}_getType(e){return mQ(e.data)}_getOrReturnCtx(e,l){return l||{common:e.parent.common,data:e.data,parsedType:mQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ep,ctx:{common:e.parent.common,data:e.data,parsedType:mQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let l=this._parse(e);if(xK(l))throw new Error("Synchronous parse encountered promise.");return l}_parseAsync(e){let l=this._parse(e);return Promise.resolve(l)}parse(e,l){let n=this.safeParse(e,l);if(n.success)return n.data;throw n.error}safeParse(e,l){let n={common:{issues:[],async:l?.async??!1,contextualErrorMap:l?.errorMap},path:l?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mQ(e)},r=this._parseSync({data:e,path:n.path,parent:n});return YSt(n,r)}"~validate"(e){let l={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mQ(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:l});return kk(n)?{value:n.value}:{issues:l.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),l.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:l}).then(n=>kk(n)?{value:n.value}:{issues:l.common.issues})}async parseAsync(e,l){let n=await this.safeParseAsync(e,l);if(n.success)return n.data;throw n.error}async safeParseAsync(e,l){let n={common:{issues:[],contextualErrorMap:l?.errorMap,async:!0},path:l?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mQ(e)},r=this._parse({data:e,path:n.path,parent:n}),I=await(xK(r)?r:Promise.resolve(r));return YSt(n,I)}refine(e,l){let n=r=>typeof l=="string"||typeof l>"u"?{message:l}:typeof l=="function"?l(r):l;return this._refinement((r,I)=>{let a=e(r),s=()=>I.addIssue({code:vl.custom,...n(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(o=>o?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,l){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof l=="function"?l(n,r):l),!1))}_refinement(e){return new jE({schema:this,typeName:jr.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:l=>this["~validate"](l)}}optional(){return zE.create(this,this._def)}nullable(){return GQ.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ov.create(this)}promise(){return xk.create(this,this._def)}or(e){return U9.create([this,e],this._def)}and(e){return M9.create(this,e,this._def)}transform(e){return new jE({...la(this._def),schema:this,typeName:jr.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let l=typeof e=="function"?e:()=>e;return new j9({...la(this._def),innerType:this,defaultValue:l,typeName:jr.ZodDefault})}brand(){return new Xce({typeName:jr.ZodBranded,type:this,...la(this._def)})}catch(e){let l=typeof e=="function"?e:()=>e;return new K9({...la(this._def),innerType:this,catchValue:l,typeName:jr.ZodCatch})}describe(e){let l=this.constructor;return new l({...this._def,description:e})}pipe(e){return kce.create(this,e)}readonly(){return q9.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},whn=/^c[^\s-]{8,}$/i,Fhn=/^[0-9a-z]+$/,Chn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vhn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,fhn=/^[a-z0-9_-]{21}$/i,Hhn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Xhn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,khn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lhn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",SPe,Jhn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xhn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Shn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Bhn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ohn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Thn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,QSt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Uhn=new RegExp(`^${QSt}$`);function wSt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let l=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${l}`}function Mhn(t){return new RegExp(`^${wSt(t)}$`)}function FSt(t){let e=`${QSt}T${wSt(t)}`,l=[];return l.push(t.local?"Z?":"Z"),t.offset&&l.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${l.join("|")})`,new RegExp(`^${e}$`)}function _hn(t,e){return!!((e==="v4"||!e)&&Jhn.test(t)||(e==="v6"||!e)&&Shn.test(t))}function Dhn(t,e){if(!Hhn.test(t))return!1;try{let[l]=t.split(".");if(!l)return!1;let n=l.replace(/-/g,"+").replace(/_/g,"/").padEnd(l.length+(4-l.length%4)%4,"="),r=JSON.parse(atob(n));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function zhn(t,e){return!!((e==="v4"||!e)&&xhn.test(t)||(e==="v6"||!e)&&Bhn.test(t))}var Lk=class t extends Na{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==fn.string){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_type,expected:fn.string,received:I.parsedType}),Tr}let n=new Ep,r;for(let I of this._def.checks)if(I.kind==="min")e.data.length<I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_small,minimum:I.value,type:"string",inclusive:!0,exact:!1,message:I.message}),n.dirty());else if(I.kind==="max")e.data.length>I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_big,maximum:I.value,type:"string",inclusive:!0,exact:!1,message:I.message}),n.dirty());else if(I.kind==="length"){let a=e.data.length>I.value,s=e.data.length<I.value;(a||s)&&(r=this._getOrReturnCtx(e,r),a?An(r,{code:vl.too_big,maximum:I.value,type:"string",inclusive:!0,exact:!0,message:I.message}):s&&An(r,{code:vl.too_small,minimum:I.value,type:"string",inclusive:!0,exact:!0,message:I.message}),n.dirty())}else if(I.kind==="email")khn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"email",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="emoji")SPe||(SPe=new RegExp(Lhn,"u")),SPe.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"emoji",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="uuid")vhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"uuid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="nanoid")fhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"nanoid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="cuid")whn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"cuid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="cuid2")Fhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"cuid2",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="ulid")Chn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"ulid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),An(r,{validation:"url",code:vl.invalid_string,message:I.message}),n.dirty()}else I.kind==="regex"?(I.regex.lastIndex=0,I.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"regex",code:vl.invalid_string,message:I.message}),n.dirty())):I.kind==="trim"?e.data=e.data.trim():I.kind==="includes"?e.data.includes(I.value,I.position)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:{includes:I.value,position:I.position},message:I.message}),n.dirty()):I.kind==="toLowerCase"?e.data=e.data.toLowerCase():I.kind==="toUpperCase"?e.data=e.data.toUpperCase():I.kind==="startsWith"?e.data.startsWith(I.value)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:{startsWith:I.value},message:I.message}),n.dirty()):I.kind==="endsWith"?e.data.endsWith(I.value)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:{endsWith:I.value},message:I.message}),n.dirty()):I.kind==="datetime"?FSt(I).test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:"datetime",message:I.message}),n.dirty()):I.kind==="date"?Uhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:"date",message:I.message}),n.dirty()):I.kind==="time"?Mhn(I).test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:"time",message:I.message}),n.dirty()):I.kind==="duration"?Xhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"duration",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="ip"?_hn(e.data,I.version)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"ip",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="jwt"?Dhn(e.data,I.alg)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"jwt",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="cidr"?zhn(e.data,I.version)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"cidr",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="base64"?Ohn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"base64",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="base64url"?Thn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"base64url",code:vl.invalid_string,message:I.message}),n.dirty()):os.assertNever(I);return{status:n.value,value:e.data}}_regex(e,l,n){return this.refinement(r=>e.test(r),{validation:l,code:vl.invalid_string,...or.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...or.errToObj(e)})}url(e){return this._addCheck({kind:"url",...or.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...or.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...or.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...or.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...or.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...or.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...or.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...or.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...or.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...or.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...or.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...or.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...or.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...or.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...or.errToObj(e)})}regex(e,l){return this._addCheck({kind:"regex",regex:e,...or.errToObj(l)})}includes(e,l){return this._addCheck({kind:"includes",value:e,position:l?.position,...or.errToObj(l?.message)})}startsWith(e,l){return this._addCheck({kind:"startsWith",value:e,...or.errToObj(l)})}endsWith(e,l){return this._addCheck({kind:"endsWith",value:e,...or.errToObj(l)})}min(e,l){return this._addCheck({kind:"min",value:e,...or.errToObj(l)})}max(e,l){return this._addCheck({kind:"max",value:e,...or.errToObj(l)})}length(e,l){return this._addCheck({kind:"length",value:e,...or.errToObj(l)})}nonempty(e){return this.min(1,or.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e}get maxLength(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e}};Lk.create=t=>new Lk({checks:[],typeName:jr.ZodString,coerce:t?.coerce??!1,...la(t)});function Phn(t,e){let l=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=l>n?l:n,I=Number.parseInt(t.toFixed(r).replace(".","")),a=Number.parseInt(e.toFixed(r).replace(".",""));return I%a/10**r}var J9=class t extends Na{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==fn.number){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_type,expected:fn.number,received:I.parsedType}),Tr}let n,r=new Ep;for(let I of this._def.checks)I.kind==="int"?os.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),An(n,{code:vl.invalid_type,expected:"integer",received:"float",message:I.message}),r.dirty()):I.kind==="min"?(I.inclusive?e.data<I.value:e.data<=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_small,minimum:I.value,type:"number",inclusive:I.inclusive,exact:!1,message:I.message}),r.dirty()):I.kind==="max"?(I.inclusive?e.data>I.value:e.data>=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_big,maximum:I.value,type:"number",inclusive:I.inclusive,exact:!1,message:I.message}),r.dirty()):I.kind==="multipleOf"?Phn(e.data,I.value)!==0&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.not_multiple_of,multipleOf:I.value,message:I.message}),r.dirty()):I.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),An(n,{code:vl.not_finite,message:I.message}),r.dirty()):os.assertNever(I);return{status:r.value,value:e.data}}gte(e,l){return this.setLimit("min",e,!0,or.toString(l))}gt(e,l){return this.setLimit("min",e,!1,or.toString(l))}lte(e,l){return this.setLimit("max",e,!0,or.toString(l))}lt(e,l){return this.setLimit("max",e,!1,or.toString(l))}setLimit(e,l,n,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:l,inclusive:n,message:or.toString(r)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:or.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:or.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:or.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:or.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:or.toString(e)})}multipleOf(e,l){return this._addCheck({kind:"multipleOf",value:e,message:or.toString(l)})}finite(e){return this._addCheck({kind:"finite",message:or.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:or.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:or.toString(e)})}get minValue(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e}get maxValue(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&os.isInteger(e.value))}get isFinite(){let e=null,l=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(l===null||n.value>l)&&(l=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(l)&&Number.isFinite(e)}};J9.create=t=>new J9({checks:[],typeName:jr.ZodNumber,coerce:t?.coerce||!1,...la(t)});var x9=class t extends Na{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==fn.bigint)return this._getInvalidInput(e);let n,r=new Ep;for(let I of this._def.checks)I.kind==="min"?(I.inclusive?e.data<I.value:e.data<=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_small,type:"bigint",minimum:I.value,inclusive:I.inclusive,message:I.message}),r.dirty()):I.kind==="max"?(I.inclusive?e.data>I.value:e.data>=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_big,type:"bigint",maximum:I.value,inclusive:I.inclusive,message:I.message}),r.dirty()):I.kind==="multipleOf"?e.data%I.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.not_multiple_of,multipleOf:I.value,message:I.message}),r.dirty()):os.assertNever(I);return{status:r.value,value:e.data}}_getInvalidInput(e){let l=this._getOrReturnCtx(e);return An(l,{code:vl.invalid_type,expected:fn.bigint,received:l.parsedType}),Tr}gte(e,l){return this.setLimit("min",e,!0,or.toString(l))}gt(e,l){return this.setLimit("min",e,!1,or.toString(l))}lte(e,l){return this.setLimit("max",e,!0,or.toString(l))}lt(e,l){return this.setLimit("max",e,!1,or.toString(l))}setLimit(e,l,n,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:l,inclusive:n,message:or.toString(r)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:or.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:or.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:or.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:or.toString(e)})}multipleOf(e,l){return this._addCheck({kind:"multipleOf",value:e,message:or.toString(l)})}get minValue(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e}get maxValue(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e}};x9.create=t=>new x9({checks:[],typeName:jr.ZodBigInt,coerce:t?.coerce??!1,...la(t)});var S9=class extends Na{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==fn.boolean){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.boolean,received:n.parsedType}),Tr}return Ch(e.data)}};S9.create=t=>new S9({typeName:jr.ZodBoolean,coerce:t?.coerce||!1,...la(t)});var B9=class t extends Na{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==fn.date){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_type,expected:fn.date,received:I.parsedType}),Tr}if(Number.isNaN(e.data.getTime())){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_date}),Tr}let n=new Ep,r;for(let I of this._def.checks)I.kind==="min"?e.data.getTime()<I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_small,message:I.message,inclusive:!0,exact:!1,minimum:I.value,type:"date"}),n.dirty()):I.kind==="max"?e.data.getTime()>I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_big,message:I.message,inclusive:!0,exact:!1,maximum:I.value,type:"date"}),n.dirty()):os.assertNever(I);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,l){return this._addCheck({kind:"min",value:e.getTime(),message:or.toString(l)})}max(e,l){return this._addCheck({kind:"max",value:e.getTime(),message:or.toString(l)})}get minDate(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e!=null?new Date(e):null}};B9.create=t=>new B9({checks:[],coerce:t?.coerce||!1,typeName:jr.ZodDate,...la(t)});var BK=class extends Na{_parse(e){if(this._getType(e)!==fn.symbol){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.symbol,received:n.parsedType}),Tr}return Ch(e.data)}};BK.create=t=>new BK({typeName:jr.ZodSymbol,...la(t)});var O9=class extends Na{_parse(e){if(this._getType(e)!==fn.undefined){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.undefined,received:n.parsedType}),Tr}return Ch(e.data)}};O9.create=t=>new O9({typeName:jr.ZodUndefined,...la(t)});var T9=class extends Na{_parse(e){if(this._getType(e)!==fn.null){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.null,received:n.parsedType}),Tr}return Ch(e.data)}};T9.create=t=>new T9({typeName:jr.ZodNull,...la(t)});var Jk=class extends Na{constructor(){super(...arguments),this._any=!0}_parse(e){return Ch(e.data)}};Jk.create=t=>new Jk({typeName:jr.ZodAny,...la(t)});var Bv=class extends Na{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ch(e.data)}};Bv.create=t=>new Bv({typeName:jr.ZodUnknown,...la(t)});var k2=class extends Na{_parse(e){let l=this._getOrReturnCtx(e);return An(l,{code:vl.invalid_type,expected:fn.never,received:l.parsedType}),Tr}};k2.create=t=>new k2({typeName:jr.ZodNever,...la(t)});var OK=class extends Na{_parse(e){if(this._getType(e)!==fn.undefined){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.void,received:n.parsedType}),Tr}return Ch(e.data)}};OK.create=t=>new OK({typeName:jr.ZodVoid,...la(t)});var Ov=class t extends Na{_parse(e){let{ctx:l,status:n}=this._processInputParams(e),r=this._def;if(l.parsedType!==fn.array)return An(l,{code:vl.invalid_type,expected:fn.array,received:l.parsedType}),Tr;if(r.exactLength!==null){let a=l.data.length>r.exactLength.value,s=l.data.length<r.exactLength.value;(a||s)&&(An(l,{code:a?vl.too_big:vl.too_small,minimum:s?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&l.data.length<r.minLength.value&&(An(l,{code:vl.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&l.data.length>r.maxLength.value&&(An(l,{code:vl.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),l.common.async)return Promise.all([...l.data].map((a,s)=>r.type._parseAsync(new PE(l,a,l.path,s)))).then(a=>Ep.mergeArray(n,a));let I=[...l.data].map((a,s)=>r.type._parseSync(new PE(l,a,l.path,s)));return Ep.mergeArray(n,I)}get element(){return this._def.type}min(e,l){return new t({...this._def,minLength:{value:e,message:or.toString(l)}})}max(e,l){return new t({...this._def,maxLength:{value:e,message:or.toString(l)}})}length(e,l){return new t({...this._def,exactLength:{value:e,message:or.toString(l)}})}nonempty(e){return this.min(1,e)}};Ov.create=(t,e)=>new Ov({type:t,minLength:null,maxLength:null,exactLength:null,typeName:jr.ZodArray,...la(e)});function SK(t){if(t instanceof _g){let e={};for(let l in t.shape){let n=t.shape[l];e[l]=zE.create(SK(n))}return new _g({...t._def,shape:()=>e})}else return t instanceof Ov?new Ov({...t._def,type:SK(t.element)}):t instanceof zE?zE.create(SK(t.unwrap())):t instanceof GQ?GQ.create(SK(t.unwrap())):t instanceof bQ?bQ.create(t.items.map(e=>SK(e))):t}var _g=class t extends Na{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),l=os.objectKeys(e);return this._cached={shape:e,keys:l},this._cached}_parse(e){if(this._getType(e)!==fn.object){let d=this._getOrReturnCtx(e);return An(d,{code:vl.invalid_type,expected:fn.object,received:d.parsedType}),Tr}let{status:n,ctx:r}=this._processInputParams(e),{shape:I,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof k2&&this._def.unknownKeys==="strip"))for(let d in r.data)a.includes(d)||s.push(d);let o=[];for(let d of a){let u=I[d],b=r.data[d];o.push({key:{status:"valid",value:d},value:u._parse(new PE(r,b,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof k2){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")s.length>0&&(An(r,{code:vl.unrecognized_keys,keys:s}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of s){let b=r.data[u];o.push({key:{status:"valid",value:u},value:d._parse(new PE(r,b,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of o){let b=await u.key,p=await u.value;d.push({key:b,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Ep.mergeObjectSync(n,d)):Ep.mergeObjectSync(n,o)}get shape(){return this._def.shape()}strict(e){return or.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(l,n)=>{let r=this._def.errorMap?.(l,n).message??n.defaultError;return l.code==="unrecognized_keys"?{message:or.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:jr.ZodObject})}setKey(e,l){return this.augment({[e]:l})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let l={};for(let n of os.objectKeys(e))e[n]&&this.shape[n]&&(l[n]=this.shape[n]);return new t({...this._def,shape:()=>l})}omit(e){let l={};for(let n of os.objectKeys(this.shape))e[n]||(l[n]=this.shape[n]);return new t({...this._def,shape:()=>l})}deepPartial(){return SK(this)}partial(e){let l={};for(let n of os.objectKeys(this.shape)){let r=this.shape[n];e&&!e[n]?l[n]=r:l[n]=r.optional()}return new t({...this._def,shape:()=>l})}required(e){let l={};for(let n of os.objectKeys(this.shape))if(e&&!e[n])l[n]=this.shape[n];else{let I=this.shape[n];for(;I instanceof zE;)I=I._def.innerType;l[n]=I}return new t({...this._def,shape:()=>l})}keyof(){return CSt(os.objectKeys(this.shape))}};_g.create=(t,e)=>new _g({shape:()=>t,unknownKeys:"strip",catchall:k2.create(),typeName:jr.ZodObject,...la(e)});_g.strictCreate=(t,e)=>new _g({shape:()=>t,unknownKeys:"strict",catchall:k2.create(),typeName:jr.ZodObject,...la(e)});_g.lazycreate=(t,e)=>new _g({shape:t,unknownKeys:"strip",catchall:k2.create(),typeName:jr.ZodObject,...la(e)});var U9=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n=this._def.options;function r(I){for(let s of I)if(s.result.status==="valid")return s.result;for(let s of I)if(s.result.status==="dirty")return l.common.issues.push(...s.ctx.common.issues),s.result;let a=I.map(s=>new Fh(s.ctx.common.issues));return An(l,{code:vl.invalid_union,unionErrors:a}),Tr}if(l.common.async)return Promise.all(n.map(async I=>{let a={...l,common:{...l.common,issues:[]},parent:null};return{result:await I._parseAsync({data:l.data,path:l.path,parent:a}),ctx:a}})).then(r);{let I,a=[];for(let o of n){let d={...l,common:{...l.common,issues:[]},parent:null},u=o._parseSync({data:l.data,path:l.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!I&&(I={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(I)return l.common.issues.push(...I.ctx.common.issues),I.result;let s=a.map(o=>new Fh(o));return An(l,{code:vl.invalid_union,unionErrors:s}),Tr}}get options(){return this._def.options}};U9.create=(t,e)=>new U9({options:t,typeName:jr.ZodUnion,...la(e)});var Sv=t=>t instanceof _9?Sv(t.schema):t instanceof jE?Sv(t.innerType()):t instanceof D9?[t.value]:t instanceof z9?t.options:t instanceof P9?os.objectValues(t.enum):t instanceof j9?Sv(t._def.innerType):t instanceof O9?[void 0]:t instanceof T9?[null]:t instanceof zE?[void 0,...Sv(t.unwrap())]:t instanceof GQ?[null,...Sv(t.unwrap())]:t instanceof Xce||t instanceof q9?Sv(t.unwrap()):t instanceof K9?Sv(t._def.innerType):[],NYe=class t extends Na{_parse(e){let{ctx:l}=this._processInputParams(e);if(l.parsedType!==fn.object)return An(l,{code:vl.invalid_type,expected:fn.object,received:l.parsedType}),Tr;let n=this.discriminator,r=l.data[n],I=this.optionsMap.get(r);return I?l.common.async?I._parseAsync({data:l.data,path:l.path,parent:l}):I._parseSync({data:l.data,path:l.path,parent:l}):(An(l,{code:vl.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Tr)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,l,n){let r=new Map;for(let I of l){let a=Sv(I.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(r.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);r.set(s,I)}}return new t({typeName:jr.ZodDiscriminatedUnion,discriminator:e,options:l,optionsMap:r,...la(n)})}};function BPe(t,e){let l=mQ(t),n=mQ(e);if(t===e)return{valid:!0,data:t};if(l===fn.object&&n===fn.object){let r=os.objectKeys(e),I=os.objectKeys(t).filter(s=>r.indexOf(s)!==-1),a={...t,...e};for(let s of I){let o=BPe(t[s],e[s]);if(!o.valid)return{valid:!1};a[s]=o.data}return{valid:!0,data:a}}else if(l===fn.array&&n===fn.array){if(t.length!==e.length)return{valid:!1};let r=[];for(let I=0;I<t.length;I++){let a=t[I],s=e[I],o=BPe(a,s);if(!o.valid)return{valid:!1};r.push(o.data)}return{valid:!0,data:r}}else return l===fn.date&&n===fn.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var M9=class extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e),r=(I,a)=>{if(ZYe(I)||ZYe(a))return Tr;let s=BPe(I.value,a.value);return s.valid?((gYe(I)||gYe(a))&&l.dirty(),{status:l.value,value:s.data}):(An(n,{code:vl.invalid_intersection_types}),Tr)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([I,a])=>r(I,a)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};M9.create=(t,e,l)=>new M9({left:t,right:e,typeName:jr.ZodIntersection,...la(l)});var bQ=class t extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.array)return An(n,{code:vl.invalid_type,expected:fn.array,received:n.parsedType}),Tr;if(n.data.length<this._def.items.length)return An(n,{code:vl.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Tr;!this._def.rest&&n.data.length>this._def.items.length&&(An(n,{code:vl.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),l.dirty());let I=[...n.data].map((a,s)=>{let o=this._def.items[s]||this._def.rest;return o?o._parse(new PE(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(I).then(a=>Ep.mergeArray(l,a)):Ep.mergeArray(l,I)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};bQ.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bQ({items:t,typeName:jr.ZodTuple,rest:null,...la(e)})};var WYe=class t extends Na{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.object)return An(n,{code:vl.invalid_type,expected:fn.object,received:n.parsedType}),Tr;let r=[],I=this._def.keyType,a=this._def.valueType;for(let s in n.data)r.push({key:I._parse(new PE(n,s,n.path,s)),value:a._parse(new PE(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?Ep.mergeObjectAsync(l,r):Ep.mergeObjectSync(l,r)}get element(){return this._def.valueType}static create(e,l,n){return l instanceof Na?new t({keyType:e,valueType:l,typeName:jr.ZodRecord,...la(n)}):new t({keyType:Lk.create(),valueType:e,typeName:jr.ZodRecord,...la(l)})}},TK=class extends Na{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.map)return An(n,{code:vl.invalid_type,expected:fn.map,received:n.parsedType}),Tr;let r=this._def.keyType,I=this._def.valueType,a=[...n.data.entries()].map(([s,o],d)=>({key:r._parse(new PE(n,s,n.path,[d,"key"])),value:I._parse(new PE(n,o,n.path,[d,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let o of a){let d=await o.key,u=await o.value;if(d.status==="aborted"||u.status==="aborted")return Tr;(d.status==="dirty"||u.status==="dirty")&&l.dirty(),s.set(d.value,u.value)}return{status:l.value,value:s}})}else{let s=new Map;for(let o of a){let d=o.key,u=o.value;if(d.status==="aborted"||u.status==="aborted")return Tr;(d.status==="dirty"||u.status==="dirty")&&l.dirty(),s.set(d.value,u.value)}return{status:l.value,value:s}}}};TK.create=(t,e,l)=>new TK({valueType:e,keyType:t,typeName:jr.ZodMap,...la(l)});var UK=class t extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.set)return An(n,{code:vl.invalid_type,expected:fn.set,received:n.parsedType}),Tr;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(An(n,{code:vl.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),l.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(An(n,{code:vl.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),l.dirty());let I=this._def.valueType;function a(o){let d=new Set;for(let u of o){if(u.status==="aborted")return Tr;u.status==="dirty"&&l.dirty(),d.add(u.value)}return{status:l.value,value:d}}let s=[...n.data.values()].map((o,d)=>I._parse(new PE(n,o,n.path,d)));return n.common.async?Promise.all(s).then(o=>a(o)):a(s)}min(e,l){return new t({...this._def,minSize:{value:e,message:or.toString(l)}})}max(e,l){return new t({...this._def,maxSize:{value:e,message:or.toString(l)}})}size(e,l){return this.min(e,l).max(e,l)}nonempty(e){return this.min(1,e)}};UK.create=(t,e)=>new UK({valueType:t,minSize:null,maxSize:null,typeName:jr.ZodSet,...la(e)});var yYe=class t extends Na{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:l}=this._processInputParams(e);if(l.parsedType!==fn.function)return An(l,{code:vl.invalid_type,expected:fn.function,received:l.parsedType}),Tr;function n(s,o){return Hce({data:s,path:l.path,errorMaps:[l.common.contextualErrorMap,l.schemaErrorMap,JK(),xv].filter(d=>!!d),issueData:{code:vl.invalid_arguments,argumentsError:o}})}function r(s,o){return Hce({data:s,path:l.path,errorMaps:[l.common.contextualErrorMap,l.schemaErrorMap,JK(),xv].filter(d=>!!d),issueData:{code:vl.invalid_return_type,returnTypeError:o}})}let I={errorMap:l.common.contextualErrorMap},a=l.data;if(this._def.returns instanceof xk){let s=this;return Ch(async function(...o){let d=new Fh([]),u=await s._def.args.parseAsync(o,I).catch(h=>{throw d.addIssue(n(o,h)),d}),b=await Reflect.apply(a,this,u);return await s._def.returns._def.type.parseAsync(b,I).catch(h=>{throw d.addIssue(r(b,h)),d})})}else{let s=this;return Ch(function(...o){let d=s._def.args.safeParse(o,I);if(!d.success)throw new Fh([n(o,d.error)]);let u=Reflect.apply(a,this,d.data),b=s._def.returns.safeParse(u,I);if(!b.success)throw new Fh([r(u,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:bQ.create(e).rest(Bv.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,l,n){return new t({args:e||bQ.create([]).rest(Bv.create()),returns:l||Bv.create(),typeName:jr.ZodFunction,...la(n)})}},_9=class extends Na{get schema(){return this._def.getter()}_parse(e){let{ctx:l}=this._processInputParams(e);return this._def.getter()._parse({data:l.data,path:l.path,parent:l})}};_9.create=(t,e)=>new _9({getter:t,typeName:jr.ZodLazy,...la(e)});var D9=class extends Na{_parse(e){if(e.data!==this._def.value){let l=this._getOrReturnCtx(e);return An(l,{received:l.data,code:vl.invalid_literal,expected:this._def.value}),Tr}return{status:"valid",value:e.data}}get value(){return this._def.value}};D9.create=(t,e)=>new D9({value:t,typeName:jr.ZodLiteral,...la(e)});function CSt(t,e){return new z9({values:t,typeName:jr.ZodEnum,...la(e)})}var z9=class t extends Na{_parse(e){if(typeof e.data!="string"){let l=this._getOrReturnCtx(e),n=this._def.values;return An(l,{expected:os.joinValues(n),received:l.parsedType,code:vl.invalid_type}),Tr}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let l=this._getOrReturnCtx(e),n=this._def.values;return An(l,{received:l.data,code:vl.invalid_enum_value,options:n}),Tr}return Ch(e.data)}get options(){return this._def.values}get enum(){let e={};for(let l of this._def.values)e[l]=l;return e}get Values(){let e={};for(let l of this._def.values)e[l]=l;return e}get Enum(){let e={};for(let l of this._def.values)e[l]=l;return e}extract(e,l=this._def){return t.create(e,{...this._def,...l})}exclude(e,l=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...l})}};z9.create=CSt;var P9=class extends Na{_parse(e){let l=os.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==fn.string&&n.parsedType!==fn.number){let r=os.objectValues(l);return An(n,{expected:os.joinValues(r),received:n.parsedType,code:vl.invalid_type}),Tr}if(this._cache||(this._cache=new Set(os.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=os.objectValues(l);return An(n,{received:n.data,code:vl.invalid_enum_value,options:r}),Tr}return Ch(e.data)}get enum(){return this._def.values}};P9.create=(t,e)=>new P9({values:t,typeName:jr.ZodNativeEnum,...la(e)});var xk=class extends Na{unwrap(){return this._def.type}_parse(e){let{ctx:l}=this._processInputParams(e);if(l.parsedType!==fn.promise&&l.common.async===!1)return An(l,{code:vl.invalid_type,expected:fn.promise,received:l.parsedType}),Tr;let n=l.parsedType===fn.promise?l.data:Promise.resolve(l.data);return Ch(n.then(r=>this._def.type.parseAsync(r,{path:l.path,errorMap:l.common.contextualErrorMap})))}};xk.create=(t,e)=>new xk({type:t,typeName:jr.ZodPromise,...la(e)});var jE=class extends Na{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===jr.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:l,ctx:n}=this._processInputParams(e),r=this._def.effect||null,I={addIssue:a=>{An(n,a),a.fatal?l.abort():l.dirty()},get path(){return n.path}};if(I.addIssue=I.addIssue.bind(I),r.type==="preprocess"){let a=r.transform(n.data,I);if(n.common.async)return Promise.resolve(a).then(async s=>{if(l.value==="aborted")return Tr;let o=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return o.status==="aborted"?Tr:o.status==="dirty"?L9(o.value):l.value==="dirty"?L9(o.value):o});{if(l.value==="aborted")return Tr;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?Tr:s.status==="dirty"?L9(s.value):l.value==="dirty"?L9(s.value):s}}if(r.type==="refinement"){let a=s=>{let o=r.refinement(s,I);if(n.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Tr:(s.status==="dirty"&&l.dirty(),a(s.value),{status:l.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?Tr:(s.status==="dirty"&&l.dirty(),a(s.value).then(()=>({status:l.value,value:s.value}))))}if(r.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kk(a))return Tr;let s=r.transform(a.value,I);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:l.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>kk(a)?Promise.resolve(r.transform(a.value,I)).then(s=>({status:l.value,value:s})):Tr);os.assertNever(r)}};jE.create=(t,e,l)=>new jE({schema:t,typeName:jr.ZodEffects,effect:e,...la(l)});jE.createWithPreprocess=(t,e,l)=>new jE({schema:e,effect:{type:"preprocess",transform:t},typeName:jr.ZodEffects,...la(l)});var zE=class extends Na{_parse(e){return this._getType(e)===fn.undefined?Ch(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};zE.create=(t,e)=>new zE({innerType:t,typeName:jr.ZodOptional,...la(e)});var GQ=class extends Na{_parse(e){return this._getType(e)===fn.null?Ch(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};GQ.create=(t,e)=>new GQ({innerType:t,typeName:jr.ZodNullable,...la(e)});var j9=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n=l.data;return l.parsedType===fn.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:l.path,parent:l})}removeDefault(){return this._def.innerType}};j9.create=(t,e)=>new j9({innerType:t,typeName:jr.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...la(e)});var K9=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n={...l,common:{...l.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return xK(r)?r.then(I=>({status:"valid",value:I.status==="valid"?I.value:this._def.catchValue({get error(){return new Fh(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Fh(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};K9.create=(t,e)=>new K9({innerType:t,typeName:jr.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...la(e)});var MK=class extends Na{_parse(e){if(this._getType(e)!==fn.nan){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.nan,received:n.parsedType}),Tr}return{status:"valid",value:e.data}}};MK.create=t=>new MK({typeName:jr.ZodNaN,...la(t)});var jhn=Symbol("zod_brand"),Xce=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n=l.data;return this._def.type._parse({data:n,path:l.path,parent:l})}unwrap(){return this._def.type}},kce=class t extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let I=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return I.status==="aborted"?Tr:I.status==="dirty"?(l.dirty(),L9(I.value)):this._def.out._parseAsync({data:I.value,path:n.path,parent:n})})();{let r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?Tr:r.status==="dirty"?(l.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,l){return new t({in:e,out:l,typeName:jr.ZodPipeline})}},q9=class extends Na{_parse(e){let l=this._def.innerType._parse(e),n=r=>(kk(r)&&(r.value=Object.freeze(r.value)),r);return xK(l)?l.then(r=>n(r)):n(l)}unwrap(){return this._def.innerType}};q9.create=(t,e)=>new q9({innerType:t,typeName:jr.ZodReadonly,...la(e)});function VSt(t,e){let l=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof l=="string"?{message:l}:l}function vSt(t,e={},l){return t?Jk.create().superRefine((n,r)=>{let I=t(n);if(I instanceof Promise)return I.then(a=>{if(!a){let s=VSt(e,n),o=s.fatal??l??!0;r.addIssue({code:"custom",...s,fatal:o})}});if(!I){let a=VSt(e,n),s=a.fatal??l??!0;r.addIssue({code:"custom",...a,fatal:s})}}):Jk.create()}var Khn={object:_g.lazycreate},jr;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(jr||(jr={}));var qhn=(t,e={message:`Input not instance of ${t.name}`})=>vSt(l=>l instanceof t,e),Vt=Lk.create,vh=J9.create,$hn=MK.create,eAn=x9.create,ci=S9.create,tAn=B9.create,lAn=BK.create,nAn=O9.create,rAn=T9.create,OPe=Jk.create,pQ=Bv.create,IAn=k2.create,aAn=OK.create,Bd=Ov.create,$l=_g.create,sAn=_g.strictCreate,fh=U9.create,Lce=NYe.create,oAn=M9.create,TPe=bQ.create,L2=WYe.create,iAn=TK.create,cAn=UK.create,dAn=yYe.create,uAn=_9.create,Zr=D9.create,Dg=z9.create,mAn=P9.create,bAn=xk.create,GAn=jE.create,pAn=zE.create,hAn=GQ.create,AAn=jE.createWithPreprocess,ZAn=kce.create,gAn=()=>Vt().optional(),NAn=()=>vh().optional(),WAn=()=>ci().optional(),Jce={string:t=>Lk.create({...t,coerce:!0}),number:t=>J9.create({...t,coerce:!0}),boolean:t=>S9.create({...t,coerce:!0}),bigint:t=>x9.create({...t,coerce:!0}),date:t=>B9.create({...t,coerce:!0})};var yAn=Tr;var Xa=P;var _K="2025-06-18";var fSt=[_K,"2025-03-26","2024-11-05","2024-10-07"],EYe="2.0",HSt=P.union([P.string(),P.number().int()]),XSt=P.string(),EAn=P.object({progressToken:P.optional(HSt)}).passthrough(),$E=P.object({_meta:P.optional(EAn)}).passthrough(),zg=P.object({method:P.string(),params:P.optional($E)}),xce=P.object({_meta:P.optional(P.object({}).passthrough())}).passthrough(),hQ=P.object({method:P.string(),params:P.optional(xce)}),e0=P.object({_meta:P.optional(P.object({}).passthrough())}).passthrough(),RYe=P.union([P.string(),P.number().int()]),kSt=P.object({jsonrpc:P.literal(EYe),id:RYe}).merge(zg).strict(),YYe=t=>kSt.safeParse(t).success,LSt=P.object({jsonrpc:P.literal(EYe)}).merge(hQ).strict(),JSt=t=>LSt.safeParse(t).success,xSt=P.object({jsonrpc:P.literal(EYe),id:RYe,result:e0}).strict(),Sce=t=>xSt.safeParse(t).success,KE;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError"})(KE||(KE={}));var SSt=P.object({jsonrpc:P.literal(EYe),id:RYe,error:P.object({code:P.number().int(),message:P.string(),data:P.optional(P.unknown())})}).strict(),BSt=t=>SSt.safeParse(t).success,Bk=P.union([kSt,LSt,xSt,SSt]),$9=e0.strict(),VYe=hQ.extend({method:P.literal("notifications/cancelled"),params:xce.extend({requestId:RYe,reason:P.string().optional()})}),QYe=P.object({src:P.string(),mimeType:P.optional(P.string()),sizes:P.optional(P.string())}).passthrough(),Bce=P.object({name:P.string(),title:P.optional(P.string())}).passthrough(),OSt=Bce.extend({version:P.string(),websiteUrl:P.optional(P.string()),icons:P.optional(P.array(QYe))}),RAn=P.object({experimental:P.optional(P.object({}).passthrough()),sampling:P.optional(P.object({}).passthrough()),elicitation:P.optional(P.object({}).passthrough()),roots:P.optional(P.object({listChanged:P.optional(P.boolean())}).passthrough())}).passthrough(),YAn=zg.extend({method:P.literal("initialize"),params:$E.extend({protocolVersion:P.string(),capabilities:RAn,clientInfo:OSt})});var VAn=P.object({experimental:P.optional(P.object({}).passthrough()),logging:P.optional(P.object({}).passthrough()),completions:P.optional(P.object({}).passthrough()),prompts:P.optional(P.object({listChanged:P.optional(P.boolean())}).passthrough()),resources:P.optional(P.object({subscribe:P.optional(P.boolean()),listChanged:P.optional(P.boolean())}).passthrough()),tools:P.optional(P.object({listChanged:P.optional(P.boolean())}).passthrough())}).passthrough(),UPe=e0.extend({protocolVersion:P.string(),capabilities:VAn,serverInfo:OSt,instructions:P.optional(P.string())}),TSt=hQ.extend({method:P.literal("notifications/initialized")}),USt=t=>TSt.safeParse(t).success,wYe=zg.extend({method:P.literal("ping")}),QAn=P.object({progress:P.number(),total:P.optional(P.number()),message:P.optional(P.string())}).passthrough(),FYe=hQ.extend({method:P.literal("notifications/progress"),params:xce.merge(QAn).extend({progressToken:HSt})}),CYe=zg.extend({params:$E.extend({cursor:P.optional(XSt)}).optional()}),vYe=e0.extend({nextCursor:P.optional(XSt)}),MSt=P.object({uri:P.string(),mimeType:P.optional(P.string()),_meta:P.optional(P.object({}).passthrough())}).passthrough(),_St=MSt.extend({text:P.string()}),MPe=P.string().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),DSt=MSt.extend({blob:MPe}),zSt=Bce.extend({uri:P.string(),description:P.optional(P.string()),mimeType:P.optional(P.string()),icons:P.optional(P.array(QYe)),_meta:P.optional(P.object({}).passthrough())}),wAn=Bce.extend({uriTemplate:P.string(),description:P.optional(P.string()),mimeType:P.optional(P.string()),_meta:P.optional(P.object({}).passthrough())}),FAn=CYe.extend({method:P.literal("resources/list")}),_Pe=vYe.extend({resources:P.array(zSt)}),CAn=CYe.extend({method:P.literal("resources/templates/list")}),DPe=vYe.extend({resourceTemplates:P.array(wAn)}),vAn=zg.extend({method:P.literal("resources/read"),params:$E.extend({uri:P.string()})}),zPe=e0.extend({contents:P.array(P.union([_St,DSt]))}),fAn=hQ.extend({method:P.literal("notifications/resources/list_changed")}),HAn=zg.extend({method:P.literal("resources/subscribe"),params:$E.extend({uri:P.string()})}),XAn=zg.extend({method:P.literal("resources/unsubscribe"),params:$E.extend({uri:P.string()})}),kAn=hQ.extend({method:P.literal("notifications/resources/updated"),params:xce.extend({uri:P.string()})}),LAn=P.object({name:P.string(),description:P.optional(P.string()),required:P.optional(P.boolean())}).passthrough(),JAn=Bce.extend({description:P.optional(P.string()),arguments:P.optional(P.array(LAn)),icons:P.optional(P.array(QYe)),_meta:P.optional(P.object({}).passthrough())}),xAn=CYe.extend({method:P.literal("prompts/list")}),PPe=vYe.extend({prompts:P.array(JAn)}),SAn=zg.extend({method:P.literal("prompts/get"),params:$E.extend({name:P.string(),arguments:P.optional(P.record(P.string()))})}),jPe=P.object({type:P.literal("text"),text:P.string(),_meta:P.optional(P.object({}).passthrough())}).passthrough(),KPe=P.object({type:P.literal("image"),data:MPe,mimeType:P.string(),_meta:P.optional(P.object({}).passthrough())}).passthrough(),qPe=P.object({type:P.literal("audio"),data:MPe,mimeType:P.string(),_meta:P.optional(P.object({}).passthrough())}).passthrough(),BAn=P.object({type:P.literal("resource"),resource:P.union([_St,DSt]),_meta:P.optional(P.object({}).passthrough())}).passthrough(),OAn=zSt.extend({type:P.literal("resource_link")}),PSt=P.union([jPe,KPe,qPe,OAn,BAn]),TAn=P.object({role:P.enum(["user","assistant"]),content:PSt}).passthrough(),$Pe=e0.extend({description:P.optional(P.string()),messages:P.array(TAn)}),UAn=hQ.extend({method:P.literal("notifications/prompts/list_changed")}),MAn=P.object({title:P.optional(P.string()),readOnlyHint:P.optional(P.boolean()),destructiveHint:P.optional(P.boolean()),idempotentHint:P.optional(P.boolean()),openWorldHint:P.optional(P.boolean())}).passthrough(),_An=Bce.extend({description:P.optional(P.string()),inputSchema:P.object({type:P.literal("object"),properties:P.optional(P.object({}).passthrough()),required:P.optional(P.array(P.string()))}).passthrough(),outputSchema:P.optional(P.object({type:P.literal("object"),properties:P.optional(P.object({}).passthrough()),required:P.optional(P.array(P.string()))}).passthrough()),annotations:P.optional(MAn),icons:P.optional(P.array(QYe)),_meta:P.optional(P.object({}).passthrough())}),DAn=CYe.extend({method:P.literal("tools/list")}),eje=vYe.extend({tools:P.array(_An)}),fYe=e0.extend({content:P.array(PSt).default([]),structuredContent:P.object({}).passthrough().optional(),isError:P.optional(P.boolean())}),Pba=fYe.or(e0.extend({toolResult:P.unknown()})),zAn=zg.extend({method:P.literal("tools/call"),params:$E.extend({name:P.string(),arguments:P.optional(P.record(P.unknown()))})}),PAn=hQ.extend({method:P.literal("notifications/tools/list_changed")}),jSt=P.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),jAn=zg.extend({method:P.literal("logging/setLevel"),params:$E.extend({level:jSt})}),KAn=hQ.extend({method:P.literal("notifications/message"),params:xce.extend({level:jSt,logger:P.optional(P.string()),data:P.unknown()})}),qAn=P.object({name:P.string().optional()}).passthrough(),$An=P.object({hints:P.optional(P.array(qAn)),costPriority:P.optional(P.number().min(0).max(1)),speedPriority:P.optional(P.number().min(0).max(1)),intelligencePriority:P.optional(P.number().min(0).max(1))}).passthrough(),eZn=P.object({role:P.enum(["user","assistant"]),content:P.union([jPe,KPe,qPe])}).passthrough(),tZn=zg.extend({method:P.literal("sampling/createMessage"),params:$E.extend({messages:P.array(eZn),systemPrompt:P.optional(P.string()),includeContext:P.optional(P.enum(["none","thisServer","allServers"])),temperature:P.optional(P.number()),maxTokens:P.number().int(),stopSequences:P.optional(P.array(P.string())),metadata:P.optional(P.object({}).passthrough()),modelPreferences:P.optional($An)})}),lZn=e0.extend({model:P.string(),stopReason:P.optional(P.enum(["endTurn","stopSequence","maxTokens"]).or(P.string())),role:P.enum(["user","assistant"]),content:P.discriminatedUnion("type",[jPe,KPe,qPe])}),nZn=P.object({type:P.literal("boolean"),title:P.optional(P.string()),description:P.optional(P.string()),default:P.optional(P.boolean())}).passthrough(),rZn=P.object({type:P.literal("string"),title:P.optional(P.string()),description:P.optional(P.string()),minLength:P.optional(P.number()),maxLength:P.optional(P.number()),format:P.optional(P.enum(["email","uri","date","date-time"]))}).passthrough(),IZn=P.object({type:P.enum(["number","integer"]),title:P.optional(P.string()),description:P.optional(P.string()),minimum:P.optional(P.number()),maximum:P.optional(P.number())}).passthrough(),aZn=P.object({type:P.literal("string"),title:P.optional(P.string()),description:P.optional(P.string()),enum:P.array(P.string()),enumNames:P.optional(P.array(P.string()))}).passthrough(),sZn=P.union([nZn,rZn,IZn,aZn]),oZn=zg.extend({method:P.literal("elicitation/create"),params:$E.extend({message:P.string(),requestedSchema:P.object({type:P.literal("object"),properties:P.record(P.string(),sZn),required:P.optional(P.array(P.string()))}).passthrough()})}),iZn=e0.extend({action:P.enum(["accept","decline","cancel"]),content:P.optional(P.record(P.string(),P.unknown()))}),cZn=P.object({type:P.literal("ref/resource"),uri:P.string()}).passthrough();var dZn=P.object({type:P.literal("ref/prompt"),name:P.string()}).passthrough(),uZn=zg.extend({method:P.literal("completion/complete"),params:$E.extend({ref:P.union([dZn,cZn]),argument:P.object({name:P.string(),value:P.string()}).passthrough(),context:P.optional(P.object({arguments:P.optional(P.record(P.string(),P.string()))}))})}),tje=e0.extend({completion:P.object({values:P.array(P.string()).max(100),total:P.optional(P.number().int()),hasMore:P.optional(P.boolean())}).passthrough()}),mZn=P.object({uri:P.string().startsWith("file://"),name:P.optional(P.string()),_meta:P.optional(P.object({}).passthrough())}).passthrough(),bZn=zg.extend({method:P.literal("roots/list")}),GZn=e0.extend({roots:P.array(mZn)}),pZn=hQ.extend({method:P.literal("notifications/roots/list_changed")}),jba=P.union([wYe,YAn,uZn,jAn,SAn,xAn,FAn,CAn,vAn,HAn,XAn,zAn,DAn]),Kba=P.union([VYe,FYe,TSt,pZn]),qba=P.union([$9,lZn,iZn,GZn]),$ba=P.union([wYe,tZn,oZn,bZn]),eGa=P.union([VYe,FYe,KAn,kAn,fAn,PAn,UAn]),tGa=P.union([$9,UPe,tje,$Pe,PPe,_Pe,DPe,zPe,fYe,eje]),qE=class extends Error{constructor(e,l,n){super(`MCP error ${e}: ${l}`),this.code=e,this.data=n,this.name="McpError"}};var hZn=6e4,HYe=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(VYe,l=>{let n=this._requestHandlerAbortControllers.get(l.params.requestId);n?.abort(l.params.reason)}),this.setNotificationHandler(FYe,l=>{this._onprogress(l)}),this.setRequestHandler(wYe,l=>({}))}_setupTimeout(e,l,n,r,I=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,l),startTime:Date.now(),timeout:l,maxTotalTimeout:n,resetTimeoutOnProgress:I,onTimeout:r})}_resetTimeout(e){let l=this._timeoutInfo.get(e);if(!l)return!1;let n=Date.now()-l.startTime;if(l.maxTotalTimeout&&n>=l.maxTotalTimeout)throw this._timeoutInfo.delete(e),new qE(KE.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:l.maxTotalTimeout,totalElapsed:n});return clearTimeout(l.timeoutId),l.timeoutId=setTimeout(l.onTimeout,l.timeout),!0}_cleanupTimeout(e){let l=this._timeoutInfo.get(e);l&&(clearTimeout(l.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var l,n,r;this._transport=e;let I=(l=this.transport)===null||l===void 0?void 0:l.onclose;this._transport.onclose=()=>{I?.(),this._onclose()};let a=(n=this.transport)===null||n===void 0?void 0:n.onerror;this._transport.onerror=o=>{a?.(o),this._onerror(o)};let s=(r=this._transport)===null||r===void 0?void 0:r.onmessage;this._transport.onmessage=(o,d)=>{s?.(o,d),Sce(o)||BSt(o)?this._onresponse(o):YYe(o)?this._onrequest(o,d):JSt(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){var e;let l=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let n=new qE(KE.ConnectionClosed,"Connection closed");for(let r of l.values())r(n)}_onerror(e){var l;(l=this.onerror)===null||l===void 0||l.call(this,e)}_onnotification(e){var l;let n=(l=this._notificationHandlers.get(e.method))!==null&&l!==void 0?l:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(e,l){var n,r;let I=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler,a=this._transport;if(I===void 0){a?.send({jsonrpc:"2.0",id:e.id,error:{code:KE.MethodNotFound,message:"Method not found"}}).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);let o={signal:s.signal,sessionId:a?.sessionId,_meta:(r=e.params)===null||r===void 0?void 0:r._meta,sendNotification:d=>this.notification(d,{relatedRequestId:e.id}),sendRequest:(d,u,b)=>this.request(d,u,{...b,relatedRequestId:e.id}),authInfo:l?.authInfo,requestId:e.id,requestInfo:l?.requestInfo};Promise.resolve().then(()=>I(e,o)).then(d=>{if(!s.signal.aborted)return a?.send({result:d,jsonrpc:"2.0",id:e.id})},d=>{var u;if(!s.signal.aborted)return a?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(d.code)?d.code:KE.InternalError,message:(u=d.message)!==null&&u!==void 0?u:"Internal error"}})}).catch(d=>this._onerror(new Error(`Failed to send response: ${d}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:l,...n}=e.params,r=Number(l),I=this._progressHandlers.get(r);if(!I){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),s=this._timeoutInfo.get(r);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(o){a(o);return}I(n)}_onresponse(e){let l=Number(e.id),n=this._responseHandlers.get(l);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(l),this._progressHandlers.delete(l),this._cleanupTimeout(l),Sce(e))n(e);else{let r=new qE(e.error.code,e.error.message,e.error.data);n(r)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,l,n){let{relatedRequestId:r,resumptionToken:I,onresumptiontoken:a}=n??{};return new Promise((s,o)=>{var d,u,b,p,h,g;if(!this._transport){o(new Error("Not connected"));return}((d=this._options)===null||d===void 0?void 0:d.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(u=n?.signal)===null||u===void 0||u.throwIfAborted();let N=this._requestMessageId++,y={...e,jsonrpc:"2.0",id:N};n?.onprogress&&(this._progressHandlers.set(N,n.onprogress),y.params={...e.params,_meta:{...((b=e.params)===null||b===void 0?void 0:b._meta)||{},progressToken:N}});let Y=J=>{var O;this._responseHandlers.delete(N),this._progressHandlers.delete(N),this._cleanupTimeout(N),(O=this._transport)===null||O===void 0||O.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:N,reason:String(J)}},{relatedRequestId:r,resumptionToken:I,onresumptiontoken:a}).catch(z=>this._onerror(new Error(`Failed to send cancellation: ${z}`))),o(J)};this._responseHandlers.set(N,J=>{var O;if(!(!((O=n?.signal)===null||O===void 0)&&O.aborted)){if(J instanceof Error)return o(J);try{let z=l.parse(J.result);s(z)}catch(z){o(z)}}}),(p=n?.signal)===null||p===void 0||p.addEventListener("abort",()=>{var J;Y((J=n?.signal)===null||J===void 0?void 0:J.reason)});let Q=(h=n?.timeout)!==null&&h!==void 0?h:hZn,X=()=>Y(new qE(KE.RequestTimeout,"Request timed out",{timeout:Q}));this._setupTimeout(N,Q,n?.maxTotalTimeout,X,(g=n?.resetTimeoutOnProgress)!==null&&g!==void 0?g:!1),this._transport.send(y,{relatedRequestId:r,resumptionToken:I,onresumptiontoken:a}).catch(J=>{this._cleanupTimeout(N),o(J)})})}async notification(e,l){var n,r;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((r=(n=this._options)===null||n===void 0?void 0:n.debouncedNotificationMethods)!==null&&r!==void 0?r:[]).includes(e.method)&&!e.params&&!l?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var o;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let d={...e,jsonrpc:"2.0"};(o=this._transport)===null||o===void 0||o.send(d,l).catch(u=>this._onerror(u))});return}let s={...e,jsonrpc:"2.0"};await this._transport.send(s,l)}setRequestHandler(e,l){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(r,I)=>Promise.resolve(l(e.parse(r),I)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,l){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(l(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function KSt(t,e){return Object.entries(e).reduce((l,[n,r])=>(r&&typeof r=="object"?l[n]=l[n]?{...l[n],...r}:r:l[n]=r,l),{...t})}var COt=lt(FOt(),1),G1e=class extends HYe{constructor(e,l){var n;super(l),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(n=l?.capabilities)!==null&&n!==void 0?n:{},this._ajv=new COt.default}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=KSt(this._capabilities,e)}assertCapability(e,l){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[e]))throw new Error(`Server does not support ${e} (required for ${l})`)}async connect(e,l){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:_K,capabilities:this._capabilities,clientInfo:this._clientInfo}},UPe,l);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!fSt.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"})}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var l,n,r,I,a;switch(e){case"logging/setLevel":if(!(!((l=this._serverCapabilities)===null||l===void 0)&&l.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((I=this._serverCapabilities)===null||I===void 0)&&I.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((a=this._serverCapabilities)===null||a===void 0)&&a.completions))throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var l;switch(e){case"notifications/roots/list_changed":if(!(!((l=this._capabilities.roots)===null||l===void 0)&&l.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},$9,e)}async complete(e,l){return this.request({method:"completion/complete",params:e},tje,l)}async setLoggingLevel(e,l){return this.request({method:"logging/setLevel",params:{level:e}},$9,l)}async getPrompt(e,l){return this.request({method:"prompts/get",params:e},$Pe,l)}async listPrompts(e,l){return this.request({method:"prompts/list",params:e},PPe,l)}async listResources(e,l){return this.request({method:"resources/list",params:e},_Pe,l)}async listResourceTemplates(e,l){return this.request({method:"resources/templates/list",params:e},DPe,l)}async readResource(e,l){return this.request({method:"resources/read",params:e},zPe,l)}async subscribeResource(e,l){return this.request({method:"resources/subscribe",params:e},$9,l)}async unsubscribeResource(e,l){return this.request({method:"resources/unsubscribe",params:e},$9,l)}async callTool(e,l=fYe,n){let r=await this.request({method:"tools/call",params:e},l,n),I=this.getToolOutputValidator(e.name);if(I){if(!r.structuredContent&&!r.isError)throw new qE(KE.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{if(!I(r.structuredContent))throw new qE(KE.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(I.errors)}`)}catch(a){throw a instanceof qE?a:new qE(KE.InvalidParams,`Failed to validate structured content: ${a instanceof Error?a.message:String(a)}`)}}return r}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(let l of e)if(l.outputSchema)try{let n=this._ajv.compile(l.outputSchema);this._cachedToolOutputValidators.set(l.name,n)}catch{}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,l){let n=await this.request({method:"tools/list",params:e},eje,l);return this.cacheToolOutputSchemas(n.tools),n}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var p1e=class{createClient(e,l){return new G1e(e,l)}};c();c();c();c();var h1e=class extends Error{constructor(e,l){super(e),this.name="ParseError",this.type=l.type,this.field=l.field,this.value=l.value,this.line=l.line}};function x6e(t){}function A1e(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=x6e,onError:l=x6e,onRetry:n=x6e,onComment:r}=t,I="",a=!0,s,o="",d="";function u(N){let y=a?N.replace(/^\xEF\xBB\xBF/,""):N,[Y,Q]=OEn(`${I}${y}`);for(let X of Y)b(X);I=Q,a=!1}function b(N){if(N===""){h();return}if(N.startsWith(":")){r&&r(N.slice(N.startsWith(": ")?2:1));return}let y=N.indexOf(":");if(y!==-1){let Y=N.slice(0,y),Q=N[y+1]===" "?2:1,X=N.slice(y+Q);p(Y,X,N);return}p(N,"",N)}function p(N,y,Y){switch(N){case"event":d=y;break;case"data":o=`${o}${y}
|
|
1952
|
+
`,input_schema:{type:"object",properties:{question:{type:"string",description:"A question about the codebase. It should reference by name any topics, specific file names, and concepts that are relevant to the question and specify the desired output format."}},required:["question"]},callback:async n=>{let r,I=vAe(t),a="",s="",o=I.split("/");if(o.length===2){[a,s]=o,l.info("Searching for repository insights");try{r=await fPe(n.question,a,s,e,l),l.info(`Blackbird results: ${r}`)}catch(d){l.error(`Error occurred while searching for repository insights: ${d}`)}}return{resultType:"success",textResultForLlm:r??"No results found.",toolTelemetry:{}}}}}async function WSt(t,e,l,n,r,I){let a=await ySt(t),s=await yhn(t,e,l),o=gSt(e)?[new AYe(l,e,n,r,t,t.location,$ge(),I).getSearch()]:[],d=t.splitEditingTools?Cxe(t,l,e):[nNe(t,l,e)];return[a.shellTool,...a.otherTools??[],...s,...o,...d,Pyt(t,e,l,n),Lo(e,nLe)?EAt(t,l,n,e):void 0,t?.requireReasoning?fxe(t):void 0,Lo(e,Oyt)?Tyt:void 0,await Ehn(t,e,l,n)].filter(u=>u!==void 0)}async function kPe(t,e){let l=await ySt(t),n=t.splitEditingTools?Cxe(t,e):[nNe(t,e)];return[l.shellTool,...l.otherTools??[],...n,t?.requireReasoning?fxe(t):void 0].filter(r=>r!==void 0)}async function Whn(t,e,l,n,r,I){return[...await WSt(t,e,l,n,r,I),Myt(t,l)]}var LPe=t=>({...uQ,supports:{...uQ.supports,reasoning:t?.thinkingMode?!0:uQ.supports?.reasoning}}),uQ={supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!1},createPR:{toolInit:WSt,jitInstructions:UOe},prDetails:{},respondToPRComment:{toolInit:Whn,jitInstructions:UOe}},JPe=t=>({"sweagent-capi":{"claude-3.5-sonnet":{...uQ,supports:{tool_choice:!1,reasoning:!1}},"claude-3.7-sonnet":{...uQ,supports:{tool_choice:!1,reasoning:!1,vision:!0}},"claude-sonnet-4":{...uQ,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},"claude-sonnet-4.5":{...uQ,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},oswe:{...uQ,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"oswe-prime":{...uQ,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"gpt-5":{...uQ,supports:{tool_choice:!0,reasoning:!0,parallel_tool_calls:!0,vision:!0,steering:!0},toolConfigOverrides:{splitEditingTools:!0}}}});async function ySt(t){let e=new sNe(t);return{shellTool:e.getShellTool(),otherTools:[e.getWriteShellTool(),e.getReadShellTool(),e.getStopShellTool()]}}async function yhn(t,e,l){if(qSe(e,"cloud"))return[new Cle(new BNe(e,l,void 0)).getStoreMemory()];if(qSe(e,"local")){let n=new Cle(new SNe(t.location));return[n.getStoreMemory(),n.getReadMemory()]}return[]}async function Ehn(t,e,l,n){if(t.includeCodeQLTool){let r=new ag(l,n),I=e.swebench_base_commit&&e.swebench_base_commit!=="undefined"?e.swebench_base_commit:await r.getCurrentCommitHash(t.location);return new zge(t,r,I,e,l).getCodeQLCheckerTool()}}c();async function ESt(t,e){switch(t.kind){case"image_processing":return e.onImageProcessingEvent(t);case"images_removed":return e.onImageRemovalEvent(t);case"message":return e.onMessage(t);case"model_call_failure":return e.onModelCallFailure(t);case"model_call_success":return await e.onModelCallSuccess(t);case"response":return e.onResponse(t);case"tool_execution":return e.onToolExecution(t);case"history_truncated":return e.onTruncationEvent(t);case"turn_started":case"turn_ended":case"turn_failed":case"turn_retry":return e.onTurnEvent(t);default:{let l=t;throw new Error(`unexpected event kind: ${JSON.stringify(t)}`)}}}c();c();c();import{Writable as U0n}from"stream";c();c();c();c();c();var P={};ob(P,{BRAND:()=>jhn,DIRTY:()=>L9,EMPTY_PATH:()=>Qhn,INVALID:()=>Tr,NEVER:()=>yAn,OK:()=>Ch,ParseStatus:()=>Ep,Schema:()=>Na,ZodAny:()=>Jk,ZodArray:()=>Ov,ZodBigInt:()=>x9,ZodBoolean:()=>S9,ZodBranded:()=>Xce,ZodCatch:()=>K9,ZodDate:()=>B9,ZodDefault:()=>j9,ZodDiscriminatedUnion:()=>NYe,ZodEffects:()=>jE,ZodEnum:()=>z9,ZodError:()=>Fh,ZodFirstPartyTypeKind:()=>jr,ZodFunction:()=>yYe,ZodIntersection:()=>M9,ZodIssueCode:()=>vl,ZodLazy:()=>_9,ZodLiteral:()=>D9,ZodMap:()=>TK,ZodNaN:()=>MK,ZodNativeEnum:()=>P9,ZodNever:()=>k2,ZodNull:()=>T9,ZodNullable:()=>GQ,ZodNumber:()=>J9,ZodObject:()=>_g,ZodOptional:()=>zE,ZodParsedType:()=>fn,ZodPipeline:()=>kce,ZodPromise:()=>xk,ZodReadonly:()=>q9,ZodRecord:()=>WYe,ZodSchema:()=>Na,ZodSet:()=>UK,ZodString:()=>Lk,ZodSymbol:()=>BK,ZodTransformer:()=>jE,ZodTuple:()=>bQ,ZodType:()=>Na,ZodUndefined:()=>O9,ZodUnion:()=>U9,ZodUnknown:()=>Bv,ZodVoid:()=>OK,addIssueToContext:()=>An,any:()=>OPe,array:()=>Bd,bigint:()=>eAn,boolean:()=>ci,coerce:()=>Jce,custom:()=>vSt,date:()=>tAn,datetimeRegex:()=>FSt,defaultErrorMap:()=>xv,discriminatedUnion:()=>Lce,effect:()=>GAn,enum:()=>Dg,function:()=>dAn,getErrorMap:()=>JK,getParsedType:()=>mQ,instanceof:()=>qhn,intersection:()=>oAn,isAborted:()=>ZYe,isAsync:()=>xK,isDirty:()=>gYe,isValid:()=>kk,late:()=>Khn,lazy:()=>uAn,literal:()=>Zr,makeIssue:()=>Hce,map:()=>iAn,nan:()=>$hn,nativeEnum:()=>mAn,never:()=>IAn,null:()=>rAn,nullable:()=>hAn,number:()=>vh,object:()=>$l,objectUtil:()=>xPe,oboolean:()=>WAn,onumber:()=>NAn,optional:()=>pAn,ostring:()=>gAn,pipeline:()=>ZAn,preprocess:()=>AAn,promise:()=>bAn,quotelessJson:()=>Rhn,record:()=>L2,set:()=>cAn,setErrorMap:()=>Vhn,strictObject:()=>sAn,string:()=>Vt,symbol:()=>lAn,transformer:()=>GAn,tuple:()=>TPe,undefined:()=>nAn,union:()=>fh,unknown:()=>pQ,util:()=>os,void:()=>aAn});c();c();c();c();c();var os;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function l(r){throw new Error}t.assertNever=l,t.arrayToEnum=r=>{let I={};for(let a of r)I[a]=a;return I},t.getValidEnumValues=r=>{let I=t.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),a={};for(let s of I)a[s]=r[s];return t.objectValues(a)},t.objectValues=r=>t.objectKeys(r).map(function(I){return r[I]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let I=[];for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&I.push(a);return I},t.find=(r,I)=>{for(let a of r)if(I(a))return a},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function n(r,I=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(I)}t.joinValues=n,t.jsonStringifyReplacer=(r,I)=>typeof I=="bigint"?I.toString():I})(os||(os={}));var xPe;(function(t){t.mergeShapes=(e,l)=>({...e,...l})})(xPe||(xPe={}));var fn=os.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),mQ=t=>{switch(typeof t){case"undefined":return fn.undefined;case"string":return fn.string;case"number":return Number.isNaN(t)?fn.nan:fn.number;case"boolean":return fn.boolean;case"function":return fn.function;case"bigint":return fn.bigint;case"symbol":return fn.symbol;case"object":return Array.isArray(t)?fn.array:t===null?fn.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?fn.promise:typeof Map<"u"&&t instanceof Map?fn.map:typeof Set<"u"&&t instanceof Set?fn.set:typeof Date<"u"&&t instanceof Date?fn.date:fn.object;default:return fn.unknown}};var vl=os.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Rhn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Fh=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let l=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,l):this.__proto__=l,this.name="ZodError",this.issues=e}format(e){let l=e||function(I){return I.message},n={_errors:[]},r=I=>{for(let a of I.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)n._errors.push(l(a));else{let s=n,o=0;for(;o<a.path.length;){let d=a.path[o];o===a.path.length-1?(s[d]=s[d]||{_errors:[]},s[d]._errors.push(l(a))):s[d]=s[d]||{_errors:[]},s=s[d],o++}}};return r(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,os.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=l=>l.message){let l={},n=[];for(let r of this.issues)if(r.path.length>0){let I=r.path[0];l[I]=l[I]||[],l[I].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:l}}get formErrors(){return this.flatten()}};Fh.create=t=>new Fh(t);var Yhn=(t,e)=>{let l;switch(t.code){case vl.invalid_type:t.received===fn.undefined?l="Required":l=`Expected ${t.expected}, received ${t.received}`;break;case vl.invalid_literal:l=`Invalid literal value, expected ${JSON.stringify(t.expected,os.jsonStringifyReplacer)}`;break;case vl.unrecognized_keys:l=`Unrecognized key(s) in object: ${os.joinValues(t.keys,", ")}`;break;case vl.invalid_union:l="Invalid input";break;case vl.invalid_union_discriminator:l=`Invalid discriminator value. Expected ${os.joinValues(t.options)}`;break;case vl.invalid_enum_value:l=`Invalid enum value. Expected ${os.joinValues(t.options)}, received '${t.received}'`;break;case vl.invalid_arguments:l="Invalid function arguments";break;case vl.invalid_return_type:l="Invalid function return type";break;case vl.invalid_date:l="Invalid date";break;case vl.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(l=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(l=`${l} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?l=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?l=`Invalid input: must end with "${t.validation.endsWith}"`:os.assertNever(t.validation):t.validation!=="regex"?l=`Invalid ${t.validation}`:l="Invalid";break;case vl.too_small:t.type==="array"?l=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?l=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?l=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?l=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?l=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:l="Invalid input";break;case vl.too_big:t.type==="array"?l=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?l=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?l=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?l=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?l=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:l="Invalid input";break;case vl.custom:l="Invalid input";break;case vl.invalid_intersection_types:l="Intersection results could not be merged";break;case vl.not_multiple_of:l=`Number must be a multiple of ${t.multipleOf}`;break;case vl.not_finite:l="Number must be finite";break;default:l=e.defaultError,os.assertNever(t)}return{message:l}},xv=Yhn;var RSt=xv;function Vhn(t){RSt=t}function JK(){return RSt}c();var Hce=t=>{let{data:e,path:l,errorMaps:n,issueData:r}=t,I=[...l,...r.path||[]],a={...r,path:I};if(r.message!==void 0)return{...r,path:I,message:r.message};let s="",o=n.filter(d=>!!d).slice().reverse();for(let d of o)s=d(a,{data:e,defaultError:s}).message;return{...r,path:I,message:s}},Qhn=[];function An(t,e){let l=JK(),n=Hce({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l,l===xv?void 0:xv].filter(r=>!!r)});t.common.issues.push(n)}var Ep=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,l){let n=[];for(let r of l){if(r.status==="aborted")return Tr;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,l){let n=[];for(let r of l){let I=await r.key,a=await r.value;n.push({key:I,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,l){let n={};for(let r of l){let{key:I,value:a}=r;if(I.status==="aborted"||a.status==="aborted")return Tr;I.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),I.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(n[I.value]=a.value)}return{status:e.value,value:n}}},Tr=Object.freeze({status:"aborted"}),L9=t=>({status:"dirty",value:t}),Ch=t=>({status:"valid",value:t}),ZYe=t=>t.status==="aborted",gYe=t=>t.status==="dirty",kk=t=>t.status==="valid",xK=t=>typeof Promise<"u"&&t instanceof Promise;c();c();var or;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(or||(or={}));var PE=class{constructor(e,l,n,r){this._cachedPath=[],this.parent=e,this.data=l,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},YSt=(t,e)=>{if(kk(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let l=new Fh(t.common.issues);return this._error=l,this._error}}};function la(t){if(!t)return{};let{errorMap:e,invalid_type_error:l,required_error:n,description:r}=t;if(e&&(l||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,s)=>{let{message:o}=t;return a.code==="invalid_enum_value"?{message:o??s.defaultError}:typeof s.data>"u"?{message:o??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:o??l??s.defaultError}},description:r}}var Na=class{get description(){return this._def.description}_getType(e){return mQ(e.data)}_getOrReturnCtx(e,l){return l||{common:e.parent.common,data:e.data,parsedType:mQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ep,ctx:{common:e.parent.common,data:e.data,parsedType:mQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let l=this._parse(e);if(xK(l))throw new Error("Synchronous parse encountered promise.");return l}_parseAsync(e){let l=this._parse(e);return Promise.resolve(l)}parse(e,l){let n=this.safeParse(e,l);if(n.success)return n.data;throw n.error}safeParse(e,l){let n={common:{issues:[],async:l?.async??!1,contextualErrorMap:l?.errorMap},path:l?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mQ(e)},r=this._parseSync({data:e,path:n.path,parent:n});return YSt(n,r)}"~validate"(e){let l={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mQ(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:l});return kk(n)?{value:n.value}:{issues:l.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),l.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:l}).then(n=>kk(n)?{value:n.value}:{issues:l.common.issues})}async parseAsync(e,l){let n=await this.safeParseAsync(e,l);if(n.success)return n.data;throw n.error}async safeParseAsync(e,l){let n={common:{issues:[],contextualErrorMap:l?.errorMap,async:!0},path:l?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mQ(e)},r=this._parse({data:e,path:n.path,parent:n}),I=await(xK(r)?r:Promise.resolve(r));return YSt(n,I)}refine(e,l){let n=r=>typeof l=="string"||typeof l>"u"?{message:l}:typeof l=="function"?l(r):l;return this._refinement((r,I)=>{let a=e(r),s=()=>I.addIssue({code:vl.custom,...n(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(o=>o?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,l){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof l=="function"?l(n,r):l),!1))}_refinement(e){return new jE({schema:this,typeName:jr.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:l=>this["~validate"](l)}}optional(){return zE.create(this,this._def)}nullable(){return GQ.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ov.create(this)}promise(){return xk.create(this,this._def)}or(e){return U9.create([this,e],this._def)}and(e){return M9.create(this,e,this._def)}transform(e){return new jE({...la(this._def),schema:this,typeName:jr.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let l=typeof e=="function"?e:()=>e;return new j9({...la(this._def),innerType:this,defaultValue:l,typeName:jr.ZodDefault})}brand(){return new Xce({typeName:jr.ZodBranded,type:this,...la(this._def)})}catch(e){let l=typeof e=="function"?e:()=>e;return new K9({...la(this._def),innerType:this,catchValue:l,typeName:jr.ZodCatch})}describe(e){let l=this.constructor;return new l({...this._def,description:e})}pipe(e){return kce.create(this,e)}readonly(){return q9.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},whn=/^c[^\s-]{8,}$/i,Fhn=/^[0-9a-z]+$/,Chn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vhn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,fhn=/^[a-z0-9_-]{21}$/i,Hhn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Xhn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,khn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lhn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",SPe,Jhn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xhn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Shn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Bhn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ohn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Thn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,QSt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Uhn=new RegExp(`^${QSt}$`);function wSt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let l=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${l}`}function Mhn(t){return new RegExp(`^${wSt(t)}$`)}function FSt(t){let e=`${QSt}T${wSt(t)}`,l=[];return l.push(t.local?"Z?":"Z"),t.offset&&l.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${l.join("|")})`,new RegExp(`^${e}$`)}function _hn(t,e){return!!((e==="v4"||!e)&&Jhn.test(t)||(e==="v6"||!e)&&Shn.test(t))}function Dhn(t,e){if(!Hhn.test(t))return!1;try{let[l]=t.split(".");if(!l)return!1;let n=l.replace(/-/g,"+").replace(/_/g,"/").padEnd(l.length+(4-l.length%4)%4,"="),r=JSON.parse(atob(n));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function zhn(t,e){return!!((e==="v4"||!e)&&xhn.test(t)||(e==="v6"||!e)&&Bhn.test(t))}var Lk=class t extends Na{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==fn.string){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_type,expected:fn.string,received:I.parsedType}),Tr}let n=new Ep,r;for(let I of this._def.checks)if(I.kind==="min")e.data.length<I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_small,minimum:I.value,type:"string",inclusive:!0,exact:!1,message:I.message}),n.dirty());else if(I.kind==="max")e.data.length>I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_big,maximum:I.value,type:"string",inclusive:!0,exact:!1,message:I.message}),n.dirty());else if(I.kind==="length"){let a=e.data.length>I.value,s=e.data.length<I.value;(a||s)&&(r=this._getOrReturnCtx(e,r),a?An(r,{code:vl.too_big,maximum:I.value,type:"string",inclusive:!0,exact:!0,message:I.message}):s&&An(r,{code:vl.too_small,minimum:I.value,type:"string",inclusive:!0,exact:!0,message:I.message}),n.dirty())}else if(I.kind==="email")khn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"email",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="emoji")SPe||(SPe=new RegExp(Lhn,"u")),SPe.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"emoji",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="uuid")vhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"uuid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="nanoid")fhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"nanoid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="cuid")whn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"cuid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="cuid2")Fhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"cuid2",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="ulid")Chn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"ulid",code:vl.invalid_string,message:I.message}),n.dirty());else if(I.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),An(r,{validation:"url",code:vl.invalid_string,message:I.message}),n.dirty()}else I.kind==="regex"?(I.regex.lastIndex=0,I.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"regex",code:vl.invalid_string,message:I.message}),n.dirty())):I.kind==="trim"?e.data=e.data.trim():I.kind==="includes"?e.data.includes(I.value,I.position)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:{includes:I.value,position:I.position},message:I.message}),n.dirty()):I.kind==="toLowerCase"?e.data=e.data.toLowerCase():I.kind==="toUpperCase"?e.data=e.data.toUpperCase():I.kind==="startsWith"?e.data.startsWith(I.value)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:{startsWith:I.value},message:I.message}),n.dirty()):I.kind==="endsWith"?e.data.endsWith(I.value)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:{endsWith:I.value},message:I.message}),n.dirty()):I.kind==="datetime"?FSt(I).test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:"datetime",message:I.message}),n.dirty()):I.kind==="date"?Uhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:"date",message:I.message}),n.dirty()):I.kind==="time"?Mhn(I).test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{code:vl.invalid_string,validation:"time",message:I.message}),n.dirty()):I.kind==="duration"?Xhn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"duration",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="ip"?_hn(e.data,I.version)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"ip",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="jwt"?Dhn(e.data,I.alg)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"jwt",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="cidr"?zhn(e.data,I.version)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"cidr",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="base64"?Ohn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"base64",code:vl.invalid_string,message:I.message}),n.dirty()):I.kind==="base64url"?Thn.test(e.data)||(r=this._getOrReturnCtx(e,r),An(r,{validation:"base64url",code:vl.invalid_string,message:I.message}),n.dirty()):os.assertNever(I);return{status:n.value,value:e.data}}_regex(e,l,n){return this.refinement(r=>e.test(r),{validation:l,code:vl.invalid_string,...or.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...or.errToObj(e)})}url(e){return this._addCheck({kind:"url",...or.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...or.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...or.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...or.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...or.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...or.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...or.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...or.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...or.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...or.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...or.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...or.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...or.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...or.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...or.errToObj(e)})}regex(e,l){return this._addCheck({kind:"regex",regex:e,...or.errToObj(l)})}includes(e,l){return this._addCheck({kind:"includes",value:e,position:l?.position,...or.errToObj(l?.message)})}startsWith(e,l){return this._addCheck({kind:"startsWith",value:e,...or.errToObj(l)})}endsWith(e,l){return this._addCheck({kind:"endsWith",value:e,...or.errToObj(l)})}min(e,l){return this._addCheck({kind:"min",value:e,...or.errToObj(l)})}max(e,l){return this._addCheck({kind:"max",value:e,...or.errToObj(l)})}length(e,l){return this._addCheck({kind:"length",value:e,...or.errToObj(l)})}nonempty(e){return this.min(1,or.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e}get maxLength(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e}};Lk.create=t=>new Lk({checks:[],typeName:jr.ZodString,coerce:t?.coerce??!1,...la(t)});function Phn(t,e){let l=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=l>n?l:n,I=Number.parseInt(t.toFixed(r).replace(".","")),a=Number.parseInt(e.toFixed(r).replace(".",""));return I%a/10**r}var J9=class t extends Na{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==fn.number){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_type,expected:fn.number,received:I.parsedType}),Tr}let n,r=new Ep;for(let I of this._def.checks)I.kind==="int"?os.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),An(n,{code:vl.invalid_type,expected:"integer",received:"float",message:I.message}),r.dirty()):I.kind==="min"?(I.inclusive?e.data<I.value:e.data<=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_small,minimum:I.value,type:"number",inclusive:I.inclusive,exact:!1,message:I.message}),r.dirty()):I.kind==="max"?(I.inclusive?e.data>I.value:e.data>=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_big,maximum:I.value,type:"number",inclusive:I.inclusive,exact:!1,message:I.message}),r.dirty()):I.kind==="multipleOf"?Phn(e.data,I.value)!==0&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.not_multiple_of,multipleOf:I.value,message:I.message}),r.dirty()):I.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),An(n,{code:vl.not_finite,message:I.message}),r.dirty()):os.assertNever(I);return{status:r.value,value:e.data}}gte(e,l){return this.setLimit("min",e,!0,or.toString(l))}gt(e,l){return this.setLimit("min",e,!1,or.toString(l))}lte(e,l){return this.setLimit("max",e,!0,or.toString(l))}lt(e,l){return this.setLimit("max",e,!1,or.toString(l))}setLimit(e,l,n,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:l,inclusive:n,message:or.toString(r)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:or.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:or.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:or.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:or.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:or.toString(e)})}multipleOf(e,l){return this._addCheck({kind:"multipleOf",value:e,message:or.toString(l)})}finite(e){return this._addCheck({kind:"finite",message:or.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:or.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:or.toString(e)})}get minValue(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e}get maxValue(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&os.isInteger(e.value))}get isFinite(){let e=null,l=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(l===null||n.value>l)&&(l=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(l)&&Number.isFinite(e)}};J9.create=t=>new J9({checks:[],typeName:jr.ZodNumber,coerce:t?.coerce||!1,...la(t)});var x9=class t extends Na{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==fn.bigint)return this._getInvalidInput(e);let n,r=new Ep;for(let I of this._def.checks)I.kind==="min"?(I.inclusive?e.data<I.value:e.data<=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_small,type:"bigint",minimum:I.value,inclusive:I.inclusive,message:I.message}),r.dirty()):I.kind==="max"?(I.inclusive?e.data>I.value:e.data>=I.value)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.too_big,type:"bigint",maximum:I.value,inclusive:I.inclusive,message:I.message}),r.dirty()):I.kind==="multipleOf"?e.data%I.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),An(n,{code:vl.not_multiple_of,multipleOf:I.value,message:I.message}),r.dirty()):os.assertNever(I);return{status:r.value,value:e.data}}_getInvalidInput(e){let l=this._getOrReturnCtx(e);return An(l,{code:vl.invalid_type,expected:fn.bigint,received:l.parsedType}),Tr}gte(e,l){return this.setLimit("min",e,!0,or.toString(l))}gt(e,l){return this.setLimit("min",e,!1,or.toString(l))}lte(e,l){return this.setLimit("max",e,!0,or.toString(l))}lt(e,l){return this.setLimit("max",e,!1,or.toString(l))}setLimit(e,l,n,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:l,inclusive:n,message:or.toString(r)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:or.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:or.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:or.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:or.toString(e)})}multipleOf(e,l){return this._addCheck({kind:"multipleOf",value:e,message:or.toString(l)})}get minValue(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e}get maxValue(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e}};x9.create=t=>new x9({checks:[],typeName:jr.ZodBigInt,coerce:t?.coerce??!1,...la(t)});var S9=class extends Na{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==fn.boolean){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.boolean,received:n.parsedType}),Tr}return Ch(e.data)}};S9.create=t=>new S9({typeName:jr.ZodBoolean,coerce:t?.coerce||!1,...la(t)});var B9=class t extends Na{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==fn.date){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_type,expected:fn.date,received:I.parsedType}),Tr}if(Number.isNaN(e.data.getTime())){let I=this._getOrReturnCtx(e);return An(I,{code:vl.invalid_date}),Tr}let n=new Ep,r;for(let I of this._def.checks)I.kind==="min"?e.data.getTime()<I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_small,message:I.message,inclusive:!0,exact:!1,minimum:I.value,type:"date"}),n.dirty()):I.kind==="max"?e.data.getTime()>I.value&&(r=this._getOrReturnCtx(e,r),An(r,{code:vl.too_big,message:I.message,inclusive:!0,exact:!1,maximum:I.value,type:"date"}),n.dirty()):os.assertNever(I);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,l){return this._addCheck({kind:"min",value:e.getTime(),message:or.toString(l)})}max(e,l){return this._addCheck({kind:"max",value:e.getTime(),message:or.toString(l)})}get minDate(){let e=null;for(let l of this._def.checks)l.kind==="min"&&(e===null||l.value>e)&&(e=l.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let l of this._def.checks)l.kind==="max"&&(e===null||l.value<e)&&(e=l.value);return e!=null?new Date(e):null}};B9.create=t=>new B9({checks:[],coerce:t?.coerce||!1,typeName:jr.ZodDate,...la(t)});var BK=class extends Na{_parse(e){if(this._getType(e)!==fn.symbol){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.symbol,received:n.parsedType}),Tr}return Ch(e.data)}};BK.create=t=>new BK({typeName:jr.ZodSymbol,...la(t)});var O9=class extends Na{_parse(e){if(this._getType(e)!==fn.undefined){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.undefined,received:n.parsedType}),Tr}return Ch(e.data)}};O9.create=t=>new O9({typeName:jr.ZodUndefined,...la(t)});var T9=class extends Na{_parse(e){if(this._getType(e)!==fn.null){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.null,received:n.parsedType}),Tr}return Ch(e.data)}};T9.create=t=>new T9({typeName:jr.ZodNull,...la(t)});var Jk=class extends Na{constructor(){super(...arguments),this._any=!0}_parse(e){return Ch(e.data)}};Jk.create=t=>new Jk({typeName:jr.ZodAny,...la(t)});var Bv=class extends Na{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ch(e.data)}};Bv.create=t=>new Bv({typeName:jr.ZodUnknown,...la(t)});var k2=class extends Na{_parse(e){let l=this._getOrReturnCtx(e);return An(l,{code:vl.invalid_type,expected:fn.never,received:l.parsedType}),Tr}};k2.create=t=>new k2({typeName:jr.ZodNever,...la(t)});var OK=class extends Na{_parse(e){if(this._getType(e)!==fn.undefined){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.void,received:n.parsedType}),Tr}return Ch(e.data)}};OK.create=t=>new OK({typeName:jr.ZodVoid,...la(t)});var Ov=class t extends Na{_parse(e){let{ctx:l,status:n}=this._processInputParams(e),r=this._def;if(l.parsedType!==fn.array)return An(l,{code:vl.invalid_type,expected:fn.array,received:l.parsedType}),Tr;if(r.exactLength!==null){let a=l.data.length>r.exactLength.value,s=l.data.length<r.exactLength.value;(a||s)&&(An(l,{code:a?vl.too_big:vl.too_small,minimum:s?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&l.data.length<r.minLength.value&&(An(l,{code:vl.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&l.data.length>r.maxLength.value&&(An(l,{code:vl.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),l.common.async)return Promise.all([...l.data].map((a,s)=>r.type._parseAsync(new PE(l,a,l.path,s)))).then(a=>Ep.mergeArray(n,a));let I=[...l.data].map((a,s)=>r.type._parseSync(new PE(l,a,l.path,s)));return Ep.mergeArray(n,I)}get element(){return this._def.type}min(e,l){return new t({...this._def,minLength:{value:e,message:or.toString(l)}})}max(e,l){return new t({...this._def,maxLength:{value:e,message:or.toString(l)}})}length(e,l){return new t({...this._def,exactLength:{value:e,message:or.toString(l)}})}nonempty(e){return this.min(1,e)}};Ov.create=(t,e)=>new Ov({type:t,minLength:null,maxLength:null,exactLength:null,typeName:jr.ZodArray,...la(e)});function SK(t){if(t instanceof _g){let e={};for(let l in t.shape){let n=t.shape[l];e[l]=zE.create(SK(n))}return new _g({...t._def,shape:()=>e})}else return t instanceof Ov?new Ov({...t._def,type:SK(t.element)}):t instanceof zE?zE.create(SK(t.unwrap())):t instanceof GQ?GQ.create(SK(t.unwrap())):t instanceof bQ?bQ.create(t.items.map(e=>SK(e))):t}var _g=class t extends Na{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),l=os.objectKeys(e);return this._cached={shape:e,keys:l},this._cached}_parse(e){if(this._getType(e)!==fn.object){let d=this._getOrReturnCtx(e);return An(d,{code:vl.invalid_type,expected:fn.object,received:d.parsedType}),Tr}let{status:n,ctx:r}=this._processInputParams(e),{shape:I,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof k2&&this._def.unknownKeys==="strip"))for(let d in r.data)a.includes(d)||s.push(d);let o=[];for(let d of a){let u=I[d],b=r.data[d];o.push({key:{status:"valid",value:d},value:u._parse(new PE(r,b,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof k2){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")s.length>0&&(An(r,{code:vl.unrecognized_keys,keys:s}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of s){let b=r.data[u];o.push({key:{status:"valid",value:u},value:d._parse(new PE(r,b,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of o){let b=await u.key,p=await u.value;d.push({key:b,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Ep.mergeObjectSync(n,d)):Ep.mergeObjectSync(n,o)}get shape(){return this._def.shape()}strict(e){return or.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(l,n)=>{let r=this._def.errorMap?.(l,n).message??n.defaultError;return l.code==="unrecognized_keys"?{message:or.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:jr.ZodObject})}setKey(e,l){return this.augment({[e]:l})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let l={};for(let n of os.objectKeys(e))e[n]&&this.shape[n]&&(l[n]=this.shape[n]);return new t({...this._def,shape:()=>l})}omit(e){let l={};for(let n of os.objectKeys(this.shape))e[n]||(l[n]=this.shape[n]);return new t({...this._def,shape:()=>l})}deepPartial(){return SK(this)}partial(e){let l={};for(let n of os.objectKeys(this.shape)){let r=this.shape[n];e&&!e[n]?l[n]=r:l[n]=r.optional()}return new t({...this._def,shape:()=>l})}required(e){let l={};for(let n of os.objectKeys(this.shape))if(e&&!e[n])l[n]=this.shape[n];else{let I=this.shape[n];for(;I instanceof zE;)I=I._def.innerType;l[n]=I}return new t({...this._def,shape:()=>l})}keyof(){return CSt(os.objectKeys(this.shape))}};_g.create=(t,e)=>new _g({shape:()=>t,unknownKeys:"strip",catchall:k2.create(),typeName:jr.ZodObject,...la(e)});_g.strictCreate=(t,e)=>new _g({shape:()=>t,unknownKeys:"strict",catchall:k2.create(),typeName:jr.ZodObject,...la(e)});_g.lazycreate=(t,e)=>new _g({shape:t,unknownKeys:"strip",catchall:k2.create(),typeName:jr.ZodObject,...la(e)});var U9=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n=this._def.options;function r(I){for(let s of I)if(s.result.status==="valid")return s.result;for(let s of I)if(s.result.status==="dirty")return l.common.issues.push(...s.ctx.common.issues),s.result;let a=I.map(s=>new Fh(s.ctx.common.issues));return An(l,{code:vl.invalid_union,unionErrors:a}),Tr}if(l.common.async)return Promise.all(n.map(async I=>{let a={...l,common:{...l.common,issues:[]},parent:null};return{result:await I._parseAsync({data:l.data,path:l.path,parent:a}),ctx:a}})).then(r);{let I,a=[];for(let o of n){let d={...l,common:{...l.common,issues:[]},parent:null},u=o._parseSync({data:l.data,path:l.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!I&&(I={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(I)return l.common.issues.push(...I.ctx.common.issues),I.result;let s=a.map(o=>new Fh(o));return An(l,{code:vl.invalid_union,unionErrors:s}),Tr}}get options(){return this._def.options}};U9.create=(t,e)=>new U9({options:t,typeName:jr.ZodUnion,...la(e)});var Sv=t=>t instanceof _9?Sv(t.schema):t instanceof jE?Sv(t.innerType()):t instanceof D9?[t.value]:t instanceof z9?t.options:t instanceof P9?os.objectValues(t.enum):t instanceof j9?Sv(t._def.innerType):t instanceof O9?[void 0]:t instanceof T9?[null]:t instanceof zE?[void 0,...Sv(t.unwrap())]:t instanceof GQ?[null,...Sv(t.unwrap())]:t instanceof Xce||t instanceof q9?Sv(t.unwrap()):t instanceof K9?Sv(t._def.innerType):[],NYe=class t extends Na{_parse(e){let{ctx:l}=this._processInputParams(e);if(l.parsedType!==fn.object)return An(l,{code:vl.invalid_type,expected:fn.object,received:l.parsedType}),Tr;let n=this.discriminator,r=l.data[n],I=this.optionsMap.get(r);return I?l.common.async?I._parseAsync({data:l.data,path:l.path,parent:l}):I._parseSync({data:l.data,path:l.path,parent:l}):(An(l,{code:vl.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Tr)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,l,n){let r=new Map;for(let I of l){let a=Sv(I.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(r.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);r.set(s,I)}}return new t({typeName:jr.ZodDiscriminatedUnion,discriminator:e,options:l,optionsMap:r,...la(n)})}};function BPe(t,e){let l=mQ(t),n=mQ(e);if(t===e)return{valid:!0,data:t};if(l===fn.object&&n===fn.object){let r=os.objectKeys(e),I=os.objectKeys(t).filter(s=>r.indexOf(s)!==-1),a={...t,...e};for(let s of I){let o=BPe(t[s],e[s]);if(!o.valid)return{valid:!1};a[s]=o.data}return{valid:!0,data:a}}else if(l===fn.array&&n===fn.array){if(t.length!==e.length)return{valid:!1};let r=[];for(let I=0;I<t.length;I++){let a=t[I],s=e[I],o=BPe(a,s);if(!o.valid)return{valid:!1};r.push(o.data)}return{valid:!0,data:r}}else return l===fn.date&&n===fn.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var M9=class extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e),r=(I,a)=>{if(ZYe(I)||ZYe(a))return Tr;let s=BPe(I.value,a.value);return s.valid?((gYe(I)||gYe(a))&&l.dirty(),{status:l.value,value:s.data}):(An(n,{code:vl.invalid_intersection_types}),Tr)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([I,a])=>r(I,a)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};M9.create=(t,e,l)=>new M9({left:t,right:e,typeName:jr.ZodIntersection,...la(l)});var bQ=class t extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.array)return An(n,{code:vl.invalid_type,expected:fn.array,received:n.parsedType}),Tr;if(n.data.length<this._def.items.length)return An(n,{code:vl.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Tr;!this._def.rest&&n.data.length>this._def.items.length&&(An(n,{code:vl.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),l.dirty());let I=[...n.data].map((a,s)=>{let o=this._def.items[s]||this._def.rest;return o?o._parse(new PE(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(I).then(a=>Ep.mergeArray(l,a)):Ep.mergeArray(l,I)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};bQ.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bQ({items:t,typeName:jr.ZodTuple,rest:null,...la(e)})};var WYe=class t extends Na{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.object)return An(n,{code:vl.invalid_type,expected:fn.object,received:n.parsedType}),Tr;let r=[],I=this._def.keyType,a=this._def.valueType;for(let s in n.data)r.push({key:I._parse(new PE(n,s,n.path,s)),value:a._parse(new PE(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?Ep.mergeObjectAsync(l,r):Ep.mergeObjectSync(l,r)}get element(){return this._def.valueType}static create(e,l,n){return l instanceof Na?new t({keyType:e,valueType:l,typeName:jr.ZodRecord,...la(n)}):new t({keyType:Lk.create(),valueType:e,typeName:jr.ZodRecord,...la(l)})}},TK=class extends Na{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.map)return An(n,{code:vl.invalid_type,expected:fn.map,received:n.parsedType}),Tr;let r=this._def.keyType,I=this._def.valueType,a=[...n.data.entries()].map(([s,o],d)=>({key:r._parse(new PE(n,s,n.path,[d,"key"])),value:I._parse(new PE(n,o,n.path,[d,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let o of a){let d=await o.key,u=await o.value;if(d.status==="aborted"||u.status==="aborted")return Tr;(d.status==="dirty"||u.status==="dirty")&&l.dirty(),s.set(d.value,u.value)}return{status:l.value,value:s}})}else{let s=new Map;for(let o of a){let d=o.key,u=o.value;if(d.status==="aborted"||u.status==="aborted")return Tr;(d.status==="dirty"||u.status==="dirty")&&l.dirty(),s.set(d.value,u.value)}return{status:l.value,value:s}}}};TK.create=(t,e,l)=>new TK({valueType:e,keyType:t,typeName:jr.ZodMap,...la(l)});var UK=class t extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.parsedType!==fn.set)return An(n,{code:vl.invalid_type,expected:fn.set,received:n.parsedType}),Tr;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(An(n,{code:vl.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),l.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(An(n,{code:vl.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),l.dirty());let I=this._def.valueType;function a(o){let d=new Set;for(let u of o){if(u.status==="aborted")return Tr;u.status==="dirty"&&l.dirty(),d.add(u.value)}return{status:l.value,value:d}}let s=[...n.data.values()].map((o,d)=>I._parse(new PE(n,o,n.path,d)));return n.common.async?Promise.all(s).then(o=>a(o)):a(s)}min(e,l){return new t({...this._def,minSize:{value:e,message:or.toString(l)}})}max(e,l){return new t({...this._def,maxSize:{value:e,message:or.toString(l)}})}size(e,l){return this.min(e,l).max(e,l)}nonempty(e){return this.min(1,e)}};UK.create=(t,e)=>new UK({valueType:t,minSize:null,maxSize:null,typeName:jr.ZodSet,...la(e)});var yYe=class t extends Na{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:l}=this._processInputParams(e);if(l.parsedType!==fn.function)return An(l,{code:vl.invalid_type,expected:fn.function,received:l.parsedType}),Tr;function n(s,o){return Hce({data:s,path:l.path,errorMaps:[l.common.contextualErrorMap,l.schemaErrorMap,JK(),xv].filter(d=>!!d),issueData:{code:vl.invalid_arguments,argumentsError:o}})}function r(s,o){return Hce({data:s,path:l.path,errorMaps:[l.common.contextualErrorMap,l.schemaErrorMap,JK(),xv].filter(d=>!!d),issueData:{code:vl.invalid_return_type,returnTypeError:o}})}let I={errorMap:l.common.contextualErrorMap},a=l.data;if(this._def.returns instanceof xk){let s=this;return Ch(async function(...o){let d=new Fh([]),u=await s._def.args.parseAsync(o,I).catch(h=>{throw d.addIssue(n(o,h)),d}),b=await Reflect.apply(a,this,u);return await s._def.returns._def.type.parseAsync(b,I).catch(h=>{throw d.addIssue(r(b,h)),d})})}else{let s=this;return Ch(function(...o){let d=s._def.args.safeParse(o,I);if(!d.success)throw new Fh([n(o,d.error)]);let u=Reflect.apply(a,this,d.data),b=s._def.returns.safeParse(u,I);if(!b.success)throw new Fh([r(u,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:bQ.create(e).rest(Bv.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,l,n){return new t({args:e||bQ.create([]).rest(Bv.create()),returns:l||Bv.create(),typeName:jr.ZodFunction,...la(n)})}},_9=class extends Na{get schema(){return this._def.getter()}_parse(e){let{ctx:l}=this._processInputParams(e);return this._def.getter()._parse({data:l.data,path:l.path,parent:l})}};_9.create=(t,e)=>new _9({getter:t,typeName:jr.ZodLazy,...la(e)});var D9=class extends Na{_parse(e){if(e.data!==this._def.value){let l=this._getOrReturnCtx(e);return An(l,{received:l.data,code:vl.invalid_literal,expected:this._def.value}),Tr}return{status:"valid",value:e.data}}get value(){return this._def.value}};D9.create=(t,e)=>new D9({value:t,typeName:jr.ZodLiteral,...la(e)});function CSt(t,e){return new z9({values:t,typeName:jr.ZodEnum,...la(e)})}var z9=class t extends Na{_parse(e){if(typeof e.data!="string"){let l=this._getOrReturnCtx(e),n=this._def.values;return An(l,{expected:os.joinValues(n),received:l.parsedType,code:vl.invalid_type}),Tr}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let l=this._getOrReturnCtx(e),n=this._def.values;return An(l,{received:l.data,code:vl.invalid_enum_value,options:n}),Tr}return Ch(e.data)}get options(){return this._def.values}get enum(){let e={};for(let l of this._def.values)e[l]=l;return e}get Values(){let e={};for(let l of this._def.values)e[l]=l;return e}get Enum(){let e={};for(let l of this._def.values)e[l]=l;return e}extract(e,l=this._def){return t.create(e,{...this._def,...l})}exclude(e,l=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...l})}};z9.create=CSt;var P9=class extends Na{_parse(e){let l=os.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==fn.string&&n.parsedType!==fn.number){let r=os.objectValues(l);return An(n,{expected:os.joinValues(r),received:n.parsedType,code:vl.invalid_type}),Tr}if(this._cache||(this._cache=new Set(os.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=os.objectValues(l);return An(n,{received:n.data,code:vl.invalid_enum_value,options:r}),Tr}return Ch(e.data)}get enum(){return this._def.values}};P9.create=(t,e)=>new P9({values:t,typeName:jr.ZodNativeEnum,...la(e)});var xk=class extends Na{unwrap(){return this._def.type}_parse(e){let{ctx:l}=this._processInputParams(e);if(l.parsedType!==fn.promise&&l.common.async===!1)return An(l,{code:vl.invalid_type,expected:fn.promise,received:l.parsedType}),Tr;let n=l.parsedType===fn.promise?l.data:Promise.resolve(l.data);return Ch(n.then(r=>this._def.type.parseAsync(r,{path:l.path,errorMap:l.common.contextualErrorMap})))}};xk.create=(t,e)=>new xk({type:t,typeName:jr.ZodPromise,...la(e)});var jE=class extends Na{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===jr.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:l,ctx:n}=this._processInputParams(e),r=this._def.effect||null,I={addIssue:a=>{An(n,a),a.fatal?l.abort():l.dirty()},get path(){return n.path}};if(I.addIssue=I.addIssue.bind(I),r.type==="preprocess"){let a=r.transform(n.data,I);if(n.common.async)return Promise.resolve(a).then(async s=>{if(l.value==="aborted")return Tr;let o=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return o.status==="aborted"?Tr:o.status==="dirty"?L9(o.value):l.value==="dirty"?L9(o.value):o});{if(l.value==="aborted")return Tr;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?Tr:s.status==="dirty"?L9(s.value):l.value==="dirty"?L9(s.value):s}}if(r.type==="refinement"){let a=s=>{let o=r.refinement(s,I);if(n.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Tr:(s.status==="dirty"&&l.dirty(),a(s.value),{status:l.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?Tr:(s.status==="dirty"&&l.dirty(),a(s.value).then(()=>({status:l.value,value:s.value}))))}if(r.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kk(a))return Tr;let s=r.transform(a.value,I);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:l.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>kk(a)?Promise.resolve(r.transform(a.value,I)).then(s=>({status:l.value,value:s})):Tr);os.assertNever(r)}};jE.create=(t,e,l)=>new jE({schema:t,typeName:jr.ZodEffects,effect:e,...la(l)});jE.createWithPreprocess=(t,e,l)=>new jE({schema:e,effect:{type:"preprocess",transform:t},typeName:jr.ZodEffects,...la(l)});var zE=class extends Na{_parse(e){return this._getType(e)===fn.undefined?Ch(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};zE.create=(t,e)=>new zE({innerType:t,typeName:jr.ZodOptional,...la(e)});var GQ=class extends Na{_parse(e){return this._getType(e)===fn.null?Ch(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};GQ.create=(t,e)=>new GQ({innerType:t,typeName:jr.ZodNullable,...la(e)});var j9=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n=l.data;return l.parsedType===fn.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:l.path,parent:l})}removeDefault(){return this._def.innerType}};j9.create=(t,e)=>new j9({innerType:t,typeName:jr.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...la(e)});var K9=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n={...l,common:{...l.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return xK(r)?r.then(I=>({status:"valid",value:I.status==="valid"?I.value:this._def.catchValue({get error(){return new Fh(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Fh(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};K9.create=(t,e)=>new K9({innerType:t,typeName:jr.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...la(e)});var MK=class extends Na{_parse(e){if(this._getType(e)!==fn.nan){let n=this._getOrReturnCtx(e);return An(n,{code:vl.invalid_type,expected:fn.nan,received:n.parsedType}),Tr}return{status:"valid",value:e.data}}};MK.create=t=>new MK({typeName:jr.ZodNaN,...la(t)});var jhn=Symbol("zod_brand"),Xce=class extends Na{_parse(e){let{ctx:l}=this._processInputParams(e),n=l.data;return this._def.type._parse({data:n,path:l.path,parent:l})}unwrap(){return this._def.type}},kce=class t extends Na{_parse(e){let{status:l,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let I=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return I.status==="aborted"?Tr:I.status==="dirty"?(l.dirty(),L9(I.value)):this._def.out._parseAsync({data:I.value,path:n.path,parent:n})})();{let r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?Tr:r.status==="dirty"?(l.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,l){return new t({in:e,out:l,typeName:jr.ZodPipeline})}},q9=class extends Na{_parse(e){let l=this._def.innerType._parse(e),n=r=>(kk(r)&&(r.value=Object.freeze(r.value)),r);return xK(l)?l.then(r=>n(r)):n(l)}unwrap(){return this._def.innerType}};q9.create=(t,e)=>new q9({innerType:t,typeName:jr.ZodReadonly,...la(e)});function VSt(t,e){let l=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof l=="string"?{message:l}:l}function vSt(t,e={},l){return t?Jk.create().superRefine((n,r)=>{let I=t(n);if(I instanceof Promise)return I.then(a=>{if(!a){let s=VSt(e,n),o=s.fatal??l??!0;r.addIssue({code:"custom",...s,fatal:o})}});if(!I){let a=VSt(e,n),s=a.fatal??l??!0;r.addIssue({code:"custom",...a,fatal:s})}}):Jk.create()}var Khn={object:_g.lazycreate},jr;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(jr||(jr={}));var qhn=(t,e={message:`Input not instance of ${t.name}`})=>vSt(l=>l instanceof t,e),Vt=Lk.create,vh=J9.create,$hn=MK.create,eAn=x9.create,ci=S9.create,tAn=B9.create,lAn=BK.create,nAn=O9.create,rAn=T9.create,OPe=Jk.create,pQ=Bv.create,IAn=k2.create,aAn=OK.create,Bd=Ov.create,$l=_g.create,sAn=_g.strictCreate,fh=U9.create,Lce=NYe.create,oAn=M9.create,TPe=bQ.create,L2=WYe.create,iAn=TK.create,cAn=UK.create,dAn=yYe.create,uAn=_9.create,Zr=D9.create,Dg=z9.create,mAn=P9.create,bAn=xk.create,GAn=jE.create,pAn=zE.create,hAn=GQ.create,AAn=jE.createWithPreprocess,ZAn=kce.create,gAn=()=>Vt().optional(),NAn=()=>vh().optional(),WAn=()=>ci().optional(),Jce={string:t=>Lk.create({...t,coerce:!0}),number:t=>J9.create({...t,coerce:!0}),boolean:t=>S9.create({...t,coerce:!0}),bigint:t=>x9.create({...t,coerce:!0}),date:t=>B9.create({...t,coerce:!0})};var yAn=Tr;var Xa=P;var _K="2025-06-18";var fSt=[_K,"2025-03-26","2024-11-05","2024-10-07"],EYe="2.0",HSt=P.union([P.string(),P.number().int()]),XSt=P.string(),EAn=P.object({progressToken:P.optional(HSt)}).passthrough(),$E=P.object({_meta:P.optional(EAn)}).passthrough(),zg=P.object({method:P.string(),params:P.optional($E)}),xce=P.object({_meta:P.optional(P.object({}).passthrough())}).passthrough(),hQ=P.object({method:P.string(),params:P.optional(xce)}),e0=P.object({_meta:P.optional(P.object({}).passthrough())}).passthrough(),RYe=P.union([P.string(),P.number().int()]),kSt=P.object({jsonrpc:P.literal(EYe),id:RYe}).merge(zg).strict(),YYe=t=>kSt.safeParse(t).success,LSt=P.object({jsonrpc:P.literal(EYe)}).merge(hQ).strict(),JSt=t=>LSt.safeParse(t).success,xSt=P.object({jsonrpc:P.literal(EYe),id:RYe,result:e0}).strict(),Sce=t=>xSt.safeParse(t).success,KE;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError"})(KE||(KE={}));var SSt=P.object({jsonrpc:P.literal(EYe),id:RYe,error:P.object({code:P.number().int(),message:P.string(),data:P.optional(P.unknown())})}).strict(),BSt=t=>SSt.safeParse(t).success,Bk=P.union([kSt,LSt,xSt,SSt]),$9=e0.strict(),VYe=hQ.extend({method:P.literal("notifications/cancelled"),params:xce.extend({requestId:RYe,reason:P.string().optional()})}),QYe=P.object({src:P.string(),mimeType:P.optional(P.string()),sizes:P.optional(P.string())}).passthrough(),Bce=P.object({name:P.string(),title:P.optional(P.string())}).passthrough(),OSt=Bce.extend({version:P.string(),websiteUrl:P.optional(P.string()),icons:P.optional(P.array(QYe))}),RAn=P.object({experimental:P.optional(P.object({}).passthrough()),sampling:P.optional(P.object({}).passthrough()),elicitation:P.optional(P.object({}).passthrough()),roots:P.optional(P.object({listChanged:P.optional(P.boolean())}).passthrough())}).passthrough(),YAn=zg.extend({method:P.literal("initialize"),params:$E.extend({protocolVersion:P.string(),capabilities:RAn,clientInfo:OSt})});var VAn=P.object({experimental:P.optional(P.object({}).passthrough()),logging:P.optional(P.object({}).passthrough()),completions:P.optional(P.object({}).passthrough()),prompts:P.optional(P.object({listChanged:P.optional(P.boolean())}).passthrough()),resources:P.optional(P.object({subscribe:P.optional(P.boolean()),listChanged:P.optional(P.boolean())}).passthrough()),tools:P.optional(P.object({listChanged:P.optional(P.boolean())}).passthrough())}).passthrough(),UPe=e0.extend({protocolVersion:P.string(),capabilities:VAn,serverInfo:OSt,instructions:P.optional(P.string())}),TSt=hQ.extend({method:P.literal("notifications/initialized")}),USt=t=>TSt.safeParse(t).success,wYe=zg.extend({method:P.literal("ping")}),QAn=P.object({progress:P.number(),total:P.optional(P.number()),message:P.optional(P.string())}).passthrough(),FYe=hQ.extend({method:P.literal("notifications/progress"),params:xce.merge(QAn).extend({progressToken:HSt})}),CYe=zg.extend({params:$E.extend({cursor:P.optional(XSt)}).optional()}),vYe=e0.extend({nextCursor:P.optional(XSt)}),MSt=P.object({uri:P.string(),mimeType:P.optional(P.string()),_meta:P.optional(P.object({}).passthrough())}).passthrough(),_St=MSt.extend({text:P.string()}),MPe=P.string().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),DSt=MSt.extend({blob:MPe}),zSt=Bce.extend({uri:P.string(),description:P.optional(P.string()),mimeType:P.optional(P.string()),icons:P.optional(P.array(QYe)),_meta:P.optional(P.object({}).passthrough())}),wAn=Bce.extend({uriTemplate:P.string(),description:P.optional(P.string()),mimeType:P.optional(P.string()),_meta:P.optional(P.object({}).passthrough())}),FAn=CYe.extend({method:P.literal("resources/list")}),_Pe=vYe.extend({resources:P.array(zSt)}),CAn=CYe.extend({method:P.literal("resources/templates/list")}),DPe=vYe.extend({resourceTemplates:P.array(wAn)}),vAn=zg.extend({method:P.literal("resources/read"),params:$E.extend({uri:P.string()})}),zPe=e0.extend({contents:P.array(P.union([_St,DSt]))}),fAn=hQ.extend({method:P.literal("notifications/resources/list_changed")}),HAn=zg.extend({method:P.literal("resources/subscribe"),params:$E.extend({uri:P.string()})}),XAn=zg.extend({method:P.literal("resources/unsubscribe"),params:$E.extend({uri:P.string()})}),kAn=hQ.extend({method:P.literal("notifications/resources/updated"),params:xce.extend({uri:P.string()})}),LAn=P.object({name:P.string(),description:P.optional(P.string()),required:P.optional(P.boolean())}).passthrough(),JAn=Bce.extend({description:P.optional(P.string()),arguments:P.optional(P.array(LAn)),icons:P.optional(P.array(QYe)),_meta:P.optional(P.object({}).passthrough())}),xAn=CYe.extend({method:P.literal("prompts/list")}),PPe=vYe.extend({prompts:P.array(JAn)}),SAn=zg.extend({method:P.literal("prompts/get"),params:$E.extend({name:P.string(),arguments:P.optional(P.record(P.string()))})}),jPe=P.object({type:P.literal("text"),text:P.string(),_meta:P.optional(P.object({}).passthrough())}).passthrough(),KPe=P.object({type:P.literal("image"),data:MPe,mimeType:P.string(),_meta:P.optional(P.object({}).passthrough())}).passthrough(),qPe=P.object({type:P.literal("audio"),data:MPe,mimeType:P.string(),_meta:P.optional(P.object({}).passthrough())}).passthrough(),BAn=P.object({type:P.literal("resource"),resource:P.union([_St,DSt]),_meta:P.optional(P.object({}).passthrough())}).passthrough(),OAn=zSt.extend({type:P.literal("resource_link")}),PSt=P.union([jPe,KPe,qPe,OAn,BAn]),TAn=P.object({role:P.enum(["user","assistant"]),content:PSt}).passthrough(),$Pe=e0.extend({description:P.optional(P.string()),messages:P.array(TAn)}),UAn=hQ.extend({method:P.literal("notifications/prompts/list_changed")}),MAn=P.object({title:P.optional(P.string()),readOnlyHint:P.optional(P.boolean()),destructiveHint:P.optional(P.boolean()),idempotentHint:P.optional(P.boolean()),openWorldHint:P.optional(P.boolean())}).passthrough(),_An=Bce.extend({description:P.optional(P.string()),inputSchema:P.object({type:P.literal("object"),properties:P.optional(P.object({}).passthrough()),required:P.optional(P.array(P.string()))}).passthrough(),outputSchema:P.optional(P.object({type:P.literal("object"),properties:P.optional(P.object({}).passthrough()),required:P.optional(P.array(P.string()))}).passthrough()),annotations:P.optional(MAn),icons:P.optional(P.array(QYe)),_meta:P.optional(P.object({}).passthrough())}),DAn=CYe.extend({method:P.literal("tools/list")}),eje=vYe.extend({tools:P.array(_An)}),fYe=e0.extend({content:P.array(PSt).default([]),structuredContent:P.object({}).passthrough().optional(),isError:P.optional(P.boolean())}),Pba=fYe.or(e0.extend({toolResult:P.unknown()})),zAn=zg.extend({method:P.literal("tools/call"),params:$E.extend({name:P.string(),arguments:P.optional(P.record(P.unknown()))})}),PAn=hQ.extend({method:P.literal("notifications/tools/list_changed")}),jSt=P.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),jAn=zg.extend({method:P.literal("logging/setLevel"),params:$E.extend({level:jSt})}),KAn=hQ.extend({method:P.literal("notifications/message"),params:xce.extend({level:jSt,logger:P.optional(P.string()),data:P.unknown()})}),qAn=P.object({name:P.string().optional()}).passthrough(),$An=P.object({hints:P.optional(P.array(qAn)),costPriority:P.optional(P.number().min(0).max(1)),speedPriority:P.optional(P.number().min(0).max(1)),intelligencePriority:P.optional(P.number().min(0).max(1))}).passthrough(),eZn=P.object({role:P.enum(["user","assistant"]),content:P.union([jPe,KPe,qPe])}).passthrough(),tZn=zg.extend({method:P.literal("sampling/createMessage"),params:$E.extend({messages:P.array(eZn),systemPrompt:P.optional(P.string()),includeContext:P.optional(P.enum(["none","thisServer","allServers"])),temperature:P.optional(P.number()),maxTokens:P.number().int(),stopSequences:P.optional(P.array(P.string())),metadata:P.optional(P.object({}).passthrough()),modelPreferences:P.optional($An)})}),lZn=e0.extend({model:P.string(),stopReason:P.optional(P.enum(["endTurn","stopSequence","maxTokens"]).or(P.string())),role:P.enum(["user","assistant"]),content:P.discriminatedUnion("type",[jPe,KPe,qPe])}),nZn=P.object({type:P.literal("boolean"),title:P.optional(P.string()),description:P.optional(P.string()),default:P.optional(P.boolean())}).passthrough(),rZn=P.object({type:P.literal("string"),title:P.optional(P.string()),description:P.optional(P.string()),minLength:P.optional(P.number()),maxLength:P.optional(P.number()),format:P.optional(P.enum(["email","uri","date","date-time"]))}).passthrough(),IZn=P.object({type:P.enum(["number","integer"]),title:P.optional(P.string()),description:P.optional(P.string()),minimum:P.optional(P.number()),maximum:P.optional(P.number())}).passthrough(),aZn=P.object({type:P.literal("string"),title:P.optional(P.string()),description:P.optional(P.string()),enum:P.array(P.string()),enumNames:P.optional(P.array(P.string()))}).passthrough(),sZn=P.union([nZn,rZn,IZn,aZn]),oZn=zg.extend({method:P.literal("elicitation/create"),params:$E.extend({message:P.string(),requestedSchema:P.object({type:P.literal("object"),properties:P.record(P.string(),sZn),required:P.optional(P.array(P.string()))}).passthrough()})}),iZn=e0.extend({action:P.enum(["accept","decline","cancel"]),content:P.optional(P.record(P.string(),P.unknown()))}),cZn=P.object({type:P.literal("ref/resource"),uri:P.string()}).passthrough();var dZn=P.object({type:P.literal("ref/prompt"),name:P.string()}).passthrough(),uZn=zg.extend({method:P.literal("completion/complete"),params:$E.extend({ref:P.union([dZn,cZn]),argument:P.object({name:P.string(),value:P.string()}).passthrough(),context:P.optional(P.object({arguments:P.optional(P.record(P.string(),P.string()))}))})}),tje=e0.extend({completion:P.object({values:P.array(P.string()).max(100),total:P.optional(P.number().int()),hasMore:P.optional(P.boolean())}).passthrough()}),mZn=P.object({uri:P.string().startsWith("file://"),name:P.optional(P.string()),_meta:P.optional(P.object({}).passthrough())}).passthrough(),bZn=zg.extend({method:P.literal("roots/list")}),GZn=e0.extend({roots:P.array(mZn)}),pZn=hQ.extend({method:P.literal("notifications/roots/list_changed")}),jba=P.union([wYe,YAn,uZn,jAn,SAn,xAn,FAn,CAn,vAn,HAn,XAn,zAn,DAn]),Kba=P.union([VYe,FYe,TSt,pZn]),qba=P.union([$9,lZn,iZn,GZn]),$ba=P.union([wYe,tZn,oZn,bZn]),eGa=P.union([VYe,FYe,KAn,kAn,fAn,PAn,UAn]),tGa=P.union([$9,UPe,tje,$Pe,PPe,_Pe,DPe,zPe,fYe,eje]),qE=class extends Error{constructor(e,l,n){super(`MCP error ${e}: ${l}`),this.code=e,this.data=n,this.name="McpError"}};var hZn=6e4,HYe=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(VYe,l=>{let n=this._requestHandlerAbortControllers.get(l.params.requestId);n?.abort(l.params.reason)}),this.setNotificationHandler(FYe,l=>{this._onprogress(l)}),this.setRequestHandler(wYe,l=>({}))}_setupTimeout(e,l,n,r,I=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,l),startTime:Date.now(),timeout:l,maxTotalTimeout:n,resetTimeoutOnProgress:I,onTimeout:r})}_resetTimeout(e){let l=this._timeoutInfo.get(e);if(!l)return!1;let n=Date.now()-l.startTime;if(l.maxTotalTimeout&&n>=l.maxTotalTimeout)throw this._timeoutInfo.delete(e),new qE(KE.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:l.maxTotalTimeout,totalElapsed:n});return clearTimeout(l.timeoutId),l.timeoutId=setTimeout(l.onTimeout,l.timeout),!0}_cleanupTimeout(e){let l=this._timeoutInfo.get(e);l&&(clearTimeout(l.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var l,n,r;this._transport=e;let I=(l=this.transport)===null||l===void 0?void 0:l.onclose;this._transport.onclose=()=>{I?.(),this._onclose()};let a=(n=this.transport)===null||n===void 0?void 0:n.onerror;this._transport.onerror=o=>{a?.(o),this._onerror(o)};let s=(r=this._transport)===null||r===void 0?void 0:r.onmessage;this._transport.onmessage=(o,d)=>{s?.(o,d),Sce(o)||BSt(o)?this._onresponse(o):YYe(o)?this._onrequest(o,d):JSt(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){var e;let l=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let n=new qE(KE.ConnectionClosed,"Connection closed");for(let r of l.values())r(n)}_onerror(e){var l;(l=this.onerror)===null||l===void 0||l.call(this,e)}_onnotification(e){var l;let n=(l=this._notificationHandlers.get(e.method))!==null&&l!==void 0?l:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(e,l){var n,r;let I=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler,a=this._transport;if(I===void 0){a?.send({jsonrpc:"2.0",id:e.id,error:{code:KE.MethodNotFound,message:"Method not found"}}).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);let o={signal:s.signal,sessionId:a?.sessionId,_meta:(r=e.params)===null||r===void 0?void 0:r._meta,sendNotification:d=>this.notification(d,{relatedRequestId:e.id}),sendRequest:(d,u,b)=>this.request(d,u,{...b,relatedRequestId:e.id}),authInfo:l?.authInfo,requestId:e.id,requestInfo:l?.requestInfo};Promise.resolve().then(()=>I(e,o)).then(d=>{if(!s.signal.aborted)return a?.send({result:d,jsonrpc:"2.0",id:e.id})},d=>{var u;if(!s.signal.aborted)return a?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(d.code)?d.code:KE.InternalError,message:(u=d.message)!==null&&u!==void 0?u:"Internal error"}})}).catch(d=>this._onerror(new Error(`Failed to send response: ${d}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:l,...n}=e.params,r=Number(l),I=this._progressHandlers.get(r);if(!I){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),s=this._timeoutInfo.get(r);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(o){a(o);return}I(n)}_onresponse(e){let l=Number(e.id),n=this._responseHandlers.get(l);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(l),this._progressHandlers.delete(l),this._cleanupTimeout(l),Sce(e))n(e);else{let r=new qE(e.error.code,e.error.message,e.error.data);n(r)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,l,n){let{relatedRequestId:r,resumptionToken:I,onresumptiontoken:a}=n??{};return new Promise((s,o)=>{var d,u,b,p,h,g;if(!this._transport){o(new Error("Not connected"));return}((d=this._options)===null||d===void 0?void 0:d.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(u=n?.signal)===null||u===void 0||u.throwIfAborted();let N=this._requestMessageId++,y={...e,jsonrpc:"2.0",id:N};n?.onprogress&&(this._progressHandlers.set(N,n.onprogress),y.params={...e.params,_meta:{...((b=e.params)===null||b===void 0?void 0:b._meta)||{},progressToken:N}});let Y=J=>{var O;this._responseHandlers.delete(N),this._progressHandlers.delete(N),this._cleanupTimeout(N),(O=this._transport)===null||O===void 0||O.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:N,reason:String(J)}},{relatedRequestId:r,resumptionToken:I,onresumptiontoken:a}).catch(z=>this._onerror(new Error(`Failed to send cancellation: ${z}`))),o(J)};this._responseHandlers.set(N,J=>{var O;if(!(!((O=n?.signal)===null||O===void 0)&&O.aborted)){if(J instanceof Error)return o(J);try{let z=l.parse(J.result);s(z)}catch(z){o(z)}}}),(p=n?.signal)===null||p===void 0||p.addEventListener("abort",()=>{var J;Y((J=n?.signal)===null||J===void 0?void 0:J.reason)});let Q=(h=n?.timeout)!==null&&h!==void 0?h:hZn,X=()=>Y(new qE(KE.RequestTimeout,"Request timed out",{timeout:Q}));this._setupTimeout(N,Q,n?.maxTotalTimeout,X,(g=n?.resetTimeoutOnProgress)!==null&&g!==void 0?g:!1),this._transport.send(y,{relatedRequestId:r,resumptionToken:I,onresumptiontoken:a}).catch(J=>{this._cleanupTimeout(N),o(J)})})}async notification(e,l){var n,r;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((r=(n=this._options)===null||n===void 0?void 0:n.debouncedNotificationMethods)!==null&&r!==void 0?r:[]).includes(e.method)&&!e.params&&!l?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var o;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let d={...e,jsonrpc:"2.0"};(o=this._transport)===null||o===void 0||o.send(d,l).catch(u=>this._onerror(u))});return}let s={...e,jsonrpc:"2.0"};await this._transport.send(s,l)}setRequestHandler(e,l){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(r,I)=>Promise.resolve(l(e.parse(r),I)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,l){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(l(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function KSt(t,e){return Object.entries(e).reduce((l,[n,r])=>(r&&typeof r=="object"?l[n]=l[n]?{...l[n],...r}:r:l[n]=r,l),{...t})}var COt=lt(FOt(),1),G1e=class extends HYe{constructor(e,l){var n;super(l),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(n=l?.capabilities)!==null&&n!==void 0?n:{},this._ajv=new COt.default}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=KSt(this._capabilities,e)}assertCapability(e,l){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[e]))throw new Error(`Server does not support ${e} (required for ${l})`)}async connect(e,l){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:_K,capabilities:this._capabilities,clientInfo:this._clientInfo}},UPe,l);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!fSt.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"})}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var l,n,r,I,a;switch(e){case"logging/setLevel":if(!(!((l=this._serverCapabilities)===null||l===void 0)&&l.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((I=this._serverCapabilities)===null||I===void 0)&&I.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((a=this._serverCapabilities)===null||a===void 0)&&a.completions))throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var l;switch(e){case"notifications/roots/list_changed":if(!(!((l=this._capabilities.roots)===null||l===void 0)&&l.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},$9,e)}async complete(e,l){return this.request({method:"completion/complete",params:e},tje,l)}async setLoggingLevel(e,l){return this.request({method:"logging/setLevel",params:{level:e}},$9,l)}async getPrompt(e,l){return this.request({method:"prompts/get",params:e},$Pe,l)}async listPrompts(e,l){return this.request({method:"prompts/list",params:e},PPe,l)}async listResources(e,l){return this.request({method:"resources/list",params:e},_Pe,l)}async listResourceTemplates(e,l){return this.request({method:"resources/templates/list",params:e},DPe,l)}async readResource(e,l){return this.request({method:"resources/read",params:e},zPe,l)}async subscribeResource(e,l){return this.request({method:"resources/subscribe",params:e},$9,l)}async unsubscribeResource(e,l){return this.request({method:"resources/unsubscribe",params:e},$9,l)}async callTool(e,l=fYe,n){let r=await this.request({method:"tools/call",params:e},l,n),I=this.getToolOutputValidator(e.name);if(I){if(!r.structuredContent&&!r.isError)throw new qE(KE.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{if(!I(r.structuredContent))throw new qE(KE.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(I.errors)}`)}catch(a){throw a instanceof qE?a:new qE(KE.InvalidParams,`Failed to validate structured content: ${a instanceof Error?a.message:String(a)}`)}}return r}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(let l of e)if(l.outputSchema)try{let n=this._ajv.compile(l.outputSchema);this._cachedToolOutputValidators.set(l.name,n)}catch{}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,l){let n=await this.request({method:"tools/list",params:e},eje,l);return this.cacheToolOutputSchemas(n.tools),n}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var p1e=class{createClient(e,l){return new G1e(e,l)}};c();c();c();c();var h1e=class extends Error{constructor(e,l){super(e),this.name="ParseError",this.type=l.type,this.field=l.field,this.value=l.value,this.line=l.line}};function x6e(t){}function A1e(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=x6e,onError:l=x6e,onRetry:n=x6e,onComment:r}=t,I="",a=!0,s,o="",d="";function u(N){let y=a?N.replace(/^\xEF\xBB\xBF/,""):N,[Y,Q]=OEn(`${I}${y}`);for(let X of Y)b(X);I=Q,a=!1}function b(N){if(N===""){h();return}if(N.startsWith(":")){r&&r(N.slice(N.startsWith(": ")?2:1));return}let y=N.indexOf(":");if(y!==-1){let Y=N.slice(0,y),Q=N[y+1]===" "?2:1,X=N.slice(y+Q);p(Y,X,N);return}p(N,"",N)}function p(N,y,Y){switch(N){case"event":d=y;break;case"data":o=`${o}${y}
|
|
1960
1953
|
`;break;case"id":s=y.includes("\0")?void 0:y;break;case"retry":/^\d+$/.test(y)?n(parseInt(y,10)):l(new h1e(`Invalid \`retry\` value: "${y}"`,{type:"invalid-retry",value:y,line:Y}));break;default:l(new h1e(`Unknown field "${N.length>20?`${N.slice(0,20)}\u2026`:N}"`,{type:"unknown-field",field:N,value:y,line:Y}));break}}function h(){o.length>0&&e({id:s,event:d||void 0,data:o.endsWith(`
|
|
1961
1954
|
`)?o.slice(0,-1):o}),s=void 0,o="",d=""}function g(N={}){I&&N.consume&&b(I),a=!0,s=void 0,o="",d="",I=""}return{feed:u,reset:g}}function OEn(t){let e=[],l="",n=0;for(;n<t.length;){let r=t.indexOf("\r",n),I=t.indexOf(`
|
|
1962
1955
|
`,n),a=-1;if(r!==-1&&I!==-1?a=Math.min(r,I):r!==-1?a=r:I!==-1&&(a=I),a===-1){l=t.slice(n);break}else{let s=t.slice(n,a);e.push(s),n=a+1,t[n-1]==="\r"&&t[n]===`
|