@reddb-io/red-skills 2.13.0 → 2.14.0

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.
@@ -19,7 +19,7 @@ ${n}
19
19
  `)}if(AY(e)){let t=[];return xY(e,0,t),t.join(`
20
20
  `)}return ER(e)}var MM,vx=h(()=>{"use strict";MM=" "});function sye(e){if(e===void 0||e.trim()==="")return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}function cft(e,t){if(t===void 0||t<=0)return;let r=Math.max(0,e),n=r/t;return{tier:n>=1?"HARD_STOP":n>=.9?"CRITICAL":n>=.75?"WARNING":"OK",spentUsd:r,limitUsd:t,percent:n}}function vC(e=process.env,t=()=>""){let r=(n,o)=>{let i=e[n];return i!==void 0&&/^[0-9]+$/.test(i)?Number(i):o};return{target:r("RED_AFK_TARGET",Mr.target),fastDeathThresholdS:r("RED_AFK_FAST_DEATH_S",Mr.fastDeathThresholdS),circuitK:r("RED_AFK_CIRCUIT_K",Mr.circuitK),circuitWindowS:r("RED_AFK_CIRCUIT_WINDOW_S",Mr.circuitWindowS),stallThresholdS:r("RED_AFK_STALL_THRESHOLD_S",Mr.stallThresholdS),stallKillThresholdS:r("RED_AFK_STALL_KILL_THRESHOLD_S",Mr.stallKillThresholdS),runner:e.RED_AFK_RUNNER&&e.RED_AFK_RUNNER.length>0?e.RED_AFK_RUNNER:Mr.runner,pollIntervalS:r("RED_AFK_POLL_S",Mr.pollIntervalS),eventFallbackS:r("RED_AFK_WAKE_FALLBACK_S",Mr.eventFallbackS)||Mr.eventFallbackS,tickTimeoutS:r("RED_AFK_TICK_TIMEOUT_S",Mr.tickTimeoutS)||Mr.tickTimeoutS,supervisorStaleS:r("RED_AFK_SUPERVISOR_STALE_S",Mr.supervisorStaleS)||Mr.supervisorStaleS,progressStaleS:r("RED_AFK_SUPERVISOR_PROGRESS_STALE_S",Mr.progressStaleS)||Mr.progressStaleS,halfOpenBaseS:r("RED_AFK_HALF_OPEN_BASE_S",Mr.halfOpenBaseS),halfOpenCapS:r("RED_AFK_HALF_OPEN_CAP_S",Mr.halfOpenCapS),unblockSweepIntervalS:r("RED_AFK_UNBLOCK_SWEEP_INTERVAL_S",Mr.unblockSweepIntervalS)||Mr.unblockSweepIntervalS,supervisorMaxRestarts:r("RED_AFK_SUPERVISOR_MAX_RESTARTS",Mr.supervisorMaxRestarts)||Mr.supervisorMaxRestarts,supervisorRestartWindowS:r("RED_AFK_SUPERVISOR_RESTART_WINDOW_S",Mr.supervisorRestartWindowS)||Mr.supervisorRestartWindowS,drainBudgetUsd:sye(e.RED_AFK_DRAIN_MAX_COST_USD)??sye(t("afk.drain.max_cost_usd")),reapContestWindowS:r("RED_AFK_REAP_CONTEST_WINDOW_S",Mr.reapContestWindowS)}}function SY(e){if(e.stallKillThresholdS<=e.stallThresholdS)throw new Error(`RED_AFK_STALL_KILL_THRESHOLD_S (${e.stallKillThresholdS}) must be > RED_AFK_STALL_THRESHOLD_S (${e.stallThresholdS})`)}function uft(e){if(e.supervisorStaleS<=e.tickTimeoutS)throw new Error(`RED_AFK_SUPERVISOR_STALE_S (${e.supervisorStaleS}) must be > RED_AFK_TICK_TIMEOUT_S (${e.tickTimeoutS})`)}function lft(e){if(e.progressStaleS<=e.supervisorStaleS)throw new Error(`RED_AFK_SUPERVISOR_PROGRESS_STALE_S (${e.progressStaleS}) must be > RED_AFK_SUPERVISOR_STALE_S (${e.supervisorStaleS})`)}function FM(e,t,r,n){return e.pid===null||!e.pidAlive?"absent":e.lastHeartbeatEpoch===null?"healthy":t-e.lastHeartbeatEpoch>=r||e.lastProgressEpoch!==null&&t-e.lastProgressEpoch>=n&&e.slotsBusy>0?"quiescent":"healthy"}function dft(e,t,r,n){let o=r-t;if(!(t>0&&o<n.fastDeathThresholdS))return{deaths:[...e],count:e.length,fastDeath:!1,trip:!1};let s=[...e,r].filter(c=>r-c<=n.circuitWindowS),a=s.length;return{deaths:s,count:a,fastDeath:!0,trip:a>=n.circuitK}}function fft(){return{pid:null,spawnEpoch:0,deaths:[],parked:!1,tripEpoch:0,swept:!1,stalled:!1,stallSinceEpoch:0,reaped:!1,spawning:!1,idleParked:!1,backoffStep:0,halfOpen:!1,contest:null}}function uye(e){return{slots:Array.from({length:e},()=>fft()),lastProgressEpoch:0,lastUnblockSweepEpoch:0,wakeStats:jAe(),drainBudgetHardStopped:!1}}function pft(e,t,r,n,o){let i=[`slot: ${t}`,`worker IDs: ${r}`,`fast deaths: ${n}`,`supervisor log: ${o}`].join(`
21
21
  `);return CC({status:"discarded",worker:e,duration:`runner-broken, slot parked after ${n} fast deaths`,diff:"discarded",attempt:1,sections:[{name:"summary",body:i}]})}function mft(e){return CC({status:"no-sentinel",worker:e.workerId.length>0?e.workerId:"unknown",duration:`${e.durationS}s \xB7 stall-reaped`,diff:"stall-reaped",attempt:e.attempt,sections:[{name:"notes",body:e.notes.length>0?e.notes:"(no agent notes recorded before stall-reap)"},{name:"log",body:e.logTail,fenced:!0}]})}function hft(e){return CC({status:"no-sentinel",worker:e.workerId.length>0?e.workerId:"unknown",duration:`${e.durationS}s \xB7 orchestrator died mid-attempt`,diff:"crashed",attempt:e.attempt,sections:[{name:"notes",body:e.notes.length>0?e.notes:"(no agent notes recorded before the orchestrator died)"},{name:"log",body:e.logTail,fenced:!0}]})}function gft(e){return e.issue!==null&&e.ghOk&&e.stillRunning}async function aye(e,t){if(e===null||e.issue===null||!t.gh.crashedClaimState)return null;let r;try{r=await t.gh.crashedClaimState(e.issue)}catch{return null}if(!gft({issue:e.issue,ghOk:r.ghOk,stillRunning:r.stillRunning}))return null;r.envelopePosted||await t.gh.comment(e.issue,hft(e));let n=Yd("no-sentinel",e.attempt,t.recoveryEnv??{});return n.decision==="retry"?await t.gh.editLabels(e.issue,n.addLabels,n.removeLabels):(n.typedLabel!==null&&await t.gh.ensureLabel(n.typedLabel),await t.gh.editLabels(e.issue,n.addLabels,[...n.removeLabels,Ye]),n.escalationComment!==null&&await t.gh.comment(e.issue,n.escalationComment)),e.issue}function Aft(e){let t=0,r=0,n=0;for(let o of e.slots)o.parked||o.idleParked?n+=1:o.pid===null?r+=1:t+=1;return{slotsBusy:t,slotsFree:r,slotsTotal:e.slots.length,slotsParked:n}}function yft(e){return new Date(e*1e3).toISOString()}function xft(e,t){let r=[];for(let n=0;n<e.slots.length;n++){let o=e.slots[n];if(o.idleParked)r.push({index:n,status:"idle-parked"});else if(o.parked&&o.halfOpen)r.push({index:n,status:"half-open"});else if(o.parked){let i=o.tripEpoch>0?o.tripEpoch+xR(o.backoffStep,t):void 0;r.push({index:n,status:"open",...i!==void 0?{retryAt:i}:{}})}}return r}async function Eft(e,t,r,n,o){let i=r.queueDepth,s=t.now(),a={ts:yft(s),epoch:s,lastProgressEpoch:e.lastProgressEpoch,runner:n,readyForAgent:i,...Aft(e),spawnsThisTick:r.respawned.length,...r.drainBudget?{drainBudget:r.drainBudget}:{},slotDetails:xft(e,o)};try{await t.emitFleetHeartbeat?.(a)}catch{}return a}async function bft(e,t,r,n){if(t.swept)return;t.swept=!0;let o=r.fs.parkedSlotWork(e,t.pid),i=o.workers.map(c=>c.workerId).join(","),s=t.deaths.length;if(r.dispatchFleetHook)try{await r.dispatchFleetHook("on_circuit_trip",{event:"on_circuit_trip",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{},...i.length>0?{worker_ids:i}:{},death_count:s,supervisor_log:o.supervisorLogPath})}catch{}if(o.workers.length===0)return;o.workers.some(c=>c.pairs.some(u=>u.issue!==null))&&await r.gh.ensureRunnerErrorLabel();for(let c of o.workers)for(let u of c.pairs){if(u.issue!==null){let l=pft(n.runner,e,i,s,o.supervisorLogPath);await r.gh.comment(u.issue,l),await r.gh.editLabels(u.issue,[Ye,eye],[tt,Xe])}await r.fs.removeDir(u.dir)}}async function Sft(e,t,r,n=Mr){if(t.reaped)return;t.reaped=!0;let o=t.pid,i=r.fs.resolveIterDir(e),s=!0;if(o!==null&&r.proc.isAlive(o)&&(s=await r.proc.killTree(o)!==!1),t.pid=null,t.stalled=!1,t.stallSinceEpoch=0,i&&i.issue!==null){await r.gh.comment(i.issue,mft(i));let a=Yd("stalled",i.attempt,r.recoveryEnv??{});a.decision==="retry"?await Cft(e,t,i,r,n.reapContestWindowS)||await r.gh.editLabels(i.issue,a.addLabels,a.removeLabels):(a.typedLabel!==null&&await r.gh.ensureLabel(a.typedLabel),await r.gh.editLabels(i.issue,a.addLabels,[...a.removeLabels,Ye]),a.escalationComment!==null&&await r.gh.comment(i.issue,a.escalationComment))}i&&s&&await r.fs.teardownIterDir(i)}async function lye(e,t){try{return await e.attemptBranchHead?.(t)}catch{return}}function EY(e,t,r){e.log?.(cs({schema_version:"red.afk.reap_contest.v1",event:t,...r}))}async function Cft(e,t,r,n,o){if(r.issue===null||!r.branch||o<=0)return!1;let i=n.now(),s=i+o,a=await lye(n,r.branch);return gg({edge:"contest",fromLabels:[Xe],removeLabels:[],addLabels:[ha]}),await n.gh.editLabels(r.issue,[ha],[]),t.contest={issue:r.issue,branch:r.branch,headAtReap:a,openedEpoch:i,deadlineEpoch:s},EY(n,"opened",{slot:e,issue:r.issue,branch:r.branch,head_at_reap:a,deadline_epoch:s}),!0}async function Ift(e,t,r,n=Mr){let o=t.contest;if(o===null)return null;let i=r.now(),s=await lye(r,o.branch);return i<=o.deadlineEpoch&&o.headAtReap!==void 0&&s!==void 0&&s!==o.headAtReap?(gg({edge:"contest-reclaimed",fromLabels:[Xe,ha],removeLabels:[ha],addLabels:[]}),await r.gh.editLabels(o.issue,[],[ha]),t.contest=null,EY(r,"reclaimed",{slot:e,issue:o.issue,branch:o.branch,head_at_reap:o.headAtReap,head_at_resolution:s}),"reclaimed"):i<o.deadlineEpoch?"pending":(gg({edge:"contest-expired",fromLabels:[Xe,ha],removeLabels:[Xe,ha],addLabels:[Ye]}),await r.gh.editLabels(o.issue,[Ye],[Xe,ha]),t.contest=null,EY(r,"expired",{slot:e,issue:o.issue,branch:o.branch,head_at_reap:o.headAtReap,head_at_resolution:s}),"expired")}async function wft(e,t,r){let n=t.now(),o=[];for(let i=0;i<e.slots.length;i+=1){let s=e.slots[i];if(s.parked||s.idleParked||!(s.spawnEpoch>0)||!(n-s.spawnEpoch>=r.stallThresholdS))continue;let a=t.fs.workerLivenessVerdict(i,r.stallThresholdS*1e3);if(a!==null&&a.status==="stalled"){if(!s.stalled){s.stalled=!0;let l=a.laneAgeMs!==void 0?n-Math.round(a.laneAgeMs/1e3):n;if(s.stallSinceEpoch=l,t.dispatchFleetHook)try{await t.dispatchFleetHook("on_stall_detected",{event:"on_stall_detected",runner:r.runner,slot:i,...s.pid!==null?{pid:s.pid}:{},stall_since:l,idle_seconds:a.laneAgeMs!==void 0?Math.round(a.laneAgeMs/1e3):0})}catch{}}let u=s.stallSinceEpoch;if(u>0&&n-u>=r.stallKillThresholdS&&!s.reaped){let l=s.pid,d=l!==null?vM(t.proc.inspectTree(l)):{activeDescendant:!1,cpuPct:0};if(RM({idleSeconds:n-u,idleThresholdSeconds:r.stallKillThresholdS,activeDescendant:d.activeDescendant,cpuPct:d.cpuPct})==="kill"){let p=!1;if(t.dispatchFleetHook)try{p=(await t.dispatchFleetHook("on_stall_reap",{event:"on_stall_reap",runner:r.runner,slot:i,...l!==null?{pid:l}:{},idle_seconds:n-u,stall_since:u})).vetoed}catch{}p||(await Sft(i,s,t,r),o.push(i))}}}else s.stalled&&(s.stalled=!1,s.stallSinceEpoch=0)}return o}function dye(e,t,r){if(r.drainBudgetUsd===void 0)return;let n=0;try{n=t.fs.fleetCostUsd?.()??0}catch{n=0}let o=cft(n,r.drainBudgetUsd);return o?.tier==="HARD_STOP"&&(e.drainBudgetHardStopped=!0),o}function fye(e,t,r,n){!r||e.lastDrainBudgetTier===r.tier||(e.lastDrainBudgetTier=r.tier,t.log?.(cs({schema_version:"red.afk.drain_budget.v1",tier:r.tier,spent_usd:Number(r.spentUsd.toFixed(4)),limit_usd:Number(r.limitUsd.toFixed(4)),percent:Number((r.percent*100).toFixed(2)),ready_for_agent:n,action:r.tier==="HARD_STOP"?"hard_stop_no_new_spawns_inflight_finish":r.tier==="CRITICAL"?"new_spawns_downgrade_one_model_tier":"observe"})))}function pye(e,t){if(e.drainBudgetHardStopped||t?.tier==="HARD_STOP")return"hard-stop";if(t?.tier==="CRITICAL")return{taskTierDowngrade:!0}}async function bY(e,t,r,n){let o=pye(r,n);return o==="hard-stop"?null:o?t.proc.spawnSlot(e,o):t.proc.spawnSlot(e)}async function kft(e,t,r,n,o=0,i){let s=async()=>i==="hard-stop"?null:i?r.proc.spawnSlot(e,i):r.proc.spawnSlot(e);if(t.parked&&t.halfOpen){let d=r.now(),f=t.spawnEpoch>0?d-t.spawnEpoch:0,p=t.spawnEpoch>0&&f<n.fastDeathThresholdS;if(t.halfOpen=!1,t.pid=null,p)return t.backoffStep++,t.tripEpoch=d,r.log?.(`circuit re-parked: slot ${e} probe fast-death (${f}s), next backoff=${xR(t.backoffStep,n)}s step=${t.backoffStep}`),{parked:!0};t.parked=!1,t.backoffStep=0,t.tripEpoch=0,t.swept=!1,t.deaths=[],r.log?.(`circuit closed: slot ${e} probe succeeded (${f}s), backoff reset`),t.spawning=!0;try{let m=await s();if(m===null)return{parked:!0};t.pid=m.pid,t.spawnEpoch=m.spawnEpoch}finally{t.spawning=!1}if(t.stalled=!1,t.stallSinceEpoch=0,t.reaped=!1,r.dispatchFleetHook)try{await r.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}})}catch{}return{parked:!1}}if((r.proc.lastExitCode?.(e)??null)===0){if(o===0)return t.idleParked=!0,{parked:!0};t.spawning=!0;try{let d=await s();if(d===null)return t.pid=null,{parked:!0};t.pid=d.pid,t.spawnEpoch=d.spawnEpoch}finally{t.spawning=!1}if(t.stalled=!1,t.stallSinceEpoch=0,t.reaped=!1,r.dispatchFleetHook)try{await r.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}}),await r.dispatchFleetHook("on_respawn",{event:"on_respawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}})}catch{}return{parked:!1}}let u=r.now(),l=dft(t.deaths,t.spawnEpoch,u,n);if(t.deaths=l.deaths,l.trip)return t.parked=!0,t.tripEpoch=u,await bft(e,t,r,n),{parked:!0};t.spawning=!0;try{let d=await s();if(d===null)return t.pid=null,{parked:!0};t.pid=d.pid,t.spawnEpoch=d.spawnEpoch}finally{t.spawning=!1}if(t.stalled=!1,t.stallSinceEpoch=0,t.reaped=!1,r.dispatchFleetHook)try{await r.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}}),await r.dispatchFleetHook("on_respawn",{event:"on_respawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}})}catch{}return{parked:!1}}async function vft(e,t){if(!t.proc.spawnReconcileWorker||!t.gh.findReconcileCandidate)return null;let r=e.slots.findIndex(s=>!s.parked&&s.pid===null);if(r<0)return null;let n=null;try{n=await t.gh.findReconcileCandidate()}catch{return null}if(n===null)return null;let o=await t.proc.spawnReconcileWorker(r,n),i=e.slots[r];return i.pid=o.pid,i.spawnEpoch=o.spawnEpoch,i.stalled=!1,i.stallSinceEpoch=0,i.reaped=!1,r}async function Rft(e,t,r,n){let o={respawned:[],deaths:[],parked:[],idleParked:[],halfOpened:[],reaped:[],crashReconciled:[],reconciledSlots:[],unblocked:[],stopped:!1,queueDepth:0,abandoned:!1};if(n())return await Bft(e,t),o.stopped=!0,o;let i=0;try{i=await t.gh.readyQueueDepth?.()??0}catch{i=0}o.queueDepth=i;let s=dye(e,t,r);o.drainBudget=s,fye(e,t,s,i);let a=pye(e,s);for(let u=0;u<e.slots.length;u+=1)await Ift(u,e.slots[u],t,r);for(let u=0;u<e.slots.length;u+=1){let l=e.slots[u];if(!(!l.idleParked||i===0)&&a!=="hard-stop"){l.idleParked=!1,l.spawning=!0;try{let d=await bY(u,t,e,s);if(d===null)continue;l.pid=d.pid,l.spawnEpoch=d.spawnEpoch,l.stalled=!1,l.stallSinceEpoch=0,l.reaped=!1}finally{l.spawning=!1}if(o.respawned.push(u),t.dispatchFleetHook)try{await t.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:r.runner,slot:u,...l.pid!==null?{pid:l.pid}:{}})}catch{}}}{let u=t.now();for(let l=0;l<e.slots.length;l+=1){let d=e.slots[l];if(!(!d.parked||d.halfOpen||d.spawning)&&a!=="hard-stop"&&nye(d.tripEpoch,d.backoffStep,u,r)){t.log?.(`circuit half-open: slot ${l} cooldown expired, spawning probe (backoff=${xR(d.backoffStep,r)}s step=${d.backoffStep})`),d.halfOpen=!0,d.spawning=!0;try{let f=await bY(l,t,e,s);if(f===null)continue;d.pid=f.pid,d.spawnEpoch=f.spawnEpoch,d.stalled=!1,d.stallSinceEpoch=0,d.reaped=!1}finally{d.spawning=!1}if(o.halfOpened.push(l),t.dispatchFleetHook)try{await t.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:r.runner,slot:l,...d.pid!==null?{pid:d.pid}:{}})}catch{}}}}for(let u=0;u<e.slots.length;u+=1){let l=e.slots[u];if(l.parked&&!l.halfOpen||l.idleParked||l.spawning)continue;let d=l.pid;if(d===null||!t.proc.isAlive(d)){if(t.dispatchFleetHook)try{await t.dispatchFleetHook("on_slot_death",{event:"on_slot_death",runner:r.runner,slot:u,...d!==null?{pid:d}:{}})}catch{}let f=t.fs.resolveIterDir(u);if(o.deaths.push(u),a==="hard-stop"){l.pid=null,l.stalled=!1,l.stallSinceEpoch=0,l.reaped=!1;try{let m=await aye(f,t);m!==null&&o.crashReconciled.push(m)}catch{}continue}let{parked:p}=await kft(u,l,t,r,i,a);if(p)l.idleParked?o.idleParked.push(u):o.parked.push(u);else{o.respawned.push(u);try{let m=await aye(f,t);m!==null&&o.crashReconciled.push(m)}catch{}}}}let c=await wft(e,t,r);if(o.reaped=c,a!=="hard-stop"){let u=await vft(e,t);u!==null&&o.reconciledSlots.push(u)}if(t.unblockSweep){let u=t.now();if(e.lastUnblockSweepEpoch===0||u-e.lastUnblockSweepEpoch>=r.unblockSweepIntervalS){e.lastUnblockSweepEpoch=u;try{o.unblocked=await t.unblockSweep()}catch{}}}return o}async function Bft(e,t){for(let r of e.slots){let n=r.pid;n!==null&&t.proc.isAlive(n)&&await t.proc.killTree(n)}}async function mye(e,t,r,n){if(SY(r),uft(r),lft(r),t.bootSweeps)try{await t.bootSweeps()}catch(i){t.log?.(`boot sweeps failed: ${i instanceof Error?i.message:String(i)} \u2014 spawning workers anyway`)}if(t.dispatchFleetHook){let i=!1;try{i=(await t.dispatchFleetHook("pre_fleet",{event:"pre_fleet",runner:r.runner})).aborted}catch(s){t.log?.(`pre_fleet hook threw: ${s instanceof Error?s.message:String(s)} \u2014 spawning workers anyway`)}if(i){t.log?.("pre_fleet hook aborted boot \u2014 fleet will not spawn");return}}let o=dye(e,t,r);fye(e,t,o,0);for(let i=0;i<e.slots.length;i+=1){let s=e.slots[i],a=await bY(i,t,e,o);if(a!==null&&(s.pid=a.pid,s.spawnEpoch=a.spawnEpoch,t.dispatchFleetHook))try{await t.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:r.runner,slot:i,...s.pid!==null?{pid:s.pid}:{}})}catch{}}for(;;){let i=await _ft(()=>Rft(e,t,r,n),r.tickTimeoutS*1e3,t.proc.sleep,t.log);i.abandoned||(e.lastProgressEpoch=t.now());let s=await Eft(e,t,i,r.runner,r);if(t.log?.(`tick: slots=${e.slots.length} respawned=${i.respawned.length} deaths=${i.deaths.length} parked=${i.parked.length} idle-parked=${i.idleParked.length} half-opened=${i.halfOpened.length} reaped=${i.reaped.length} unblocked=${i.unblocked.length} crash-reconciled=${i.crashReconciled.length} ready=${s.readyForAgent} busy=${s.slotsBusy} free=${s.slotsFree}`),i.stopped){if(t.dispatchFleetHook)try{await t.dispatchFleetHook("post_fleet",{event:"post_fleet",runner:r.runner})}catch(u){t.log?.(`post_fleet hook threw: ${u instanceof Error?u.message:String(u)}`)}return}let a=t.wake?r.eventFallbackS:r.pollIntervalS,c=await WAe({fallbackMs:a*1e3,sleep:t.proc.sleep,wake:t.wake});qAe(e.wakeStats,c),c==="event"&&t.log?.(`wake: event-driven (idle wakes reduced \u2014 ${e.wakeStats.event}/${e.wakeStats.total} wakes event-driven)`)}}function cye(){return{respawned:[],deaths:[],parked:[],idleParked:[],halfOpened:[],reaped:[],crashReconciled:[],reconciledSlots:[],unblocked:[],stopped:!1,queueDepth:0,abandoned:!0}}async function _ft(e,t,r,n){let o=Symbol("tick-timeout");try{let i=await Promise.race([e(),r(t).then(()=>o)]);return i===o?(n?.(`tick exceeded ${Math.round(t/1e3)}s \u2014 abandoning this pass, loop continues`),cye()):i}catch(i){return n?.(`tick threw: ${i instanceof Error?i.message:String(i)} \u2014 loop continues`),cye()}}var Mr,RC=h(()=>{"use strict";iY();GAe();sY();DM();sn();NM();oye();vx();Mr={target:2,fastDeathThresholdS:30,circuitK:5,circuitWindowS:90,stallThresholdS:600,stallKillThresholdS:1800,runner:"claude",pollIntervalS:15,eventFallbackS:60,tickTimeoutS:120,supervisorStaleS:300,progressStaleS:900,halfOpenBaseS:hY.halfOpenBaseS,halfOpenCapS:hY.halfOpenCapS,unblockSweepIntervalS:60,supervisorMaxRestarts:5,supervisorRestartWindowS:300,reapContestWindowS:30}});var er,IY,Te,Jd,bR=h(()=>{(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function r(o){throw new Error}e.assertNever=r,e.arrayToEnum=o=>{let i={};for(let s of o)i[s]=s;return i},e.getValidEnumValues=o=>{let i=e.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),s={};for(let a of i)s[a]=o[a];return e.objectValues(s)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let s in o)Object.prototype.hasOwnProperty.call(o,s)&&i.push(s);return i},e.find=(o,i)=>{for(let s of o)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(er||(er={}));(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(IY||(IY={}));Te=er.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Jd=e=>{switch(typeof e){case"undefined":return Te.undefined;case"string":return Te.string;case"number":return Number.isNaN(e)?Te.nan:Te.number;case"boolean":return Te.boolean;case"function":return Te.function;case"bigint":return Te.bigint;case"symbol":return Te.symbol;case"object":return Array.isArray(e)?Te.array:e===null?Te.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Te.promise:typeof Map<"u"&&e instanceof Map?Te.map:typeof Set<"u"&&e instanceof Set?Te.set:typeof Date<"u"&&e instanceof Date?Te.date:Te.object;default:return Te.unknown}}});var pe,Qft,ga,PM=h(()=>{bR();pe=er.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"]),Qft=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ga=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(i){return i.message},n={_errors:[]},o=i=>{for(let s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(o);else if(s.code==="invalid_return_type")o(s.returnTypeError);else if(s.code==="invalid_arguments")o(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,c=0;for(;c<s.path.length;){let u=s.path[c];c===s.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(s))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,er.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let i=o.path[0];r[i]=r[i]||[],r[i].push(t(o))}else n.push(t(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};ga.create=e=>new ga(e)});var Oft,qp,wY=h(()=>{PM();bR();Oft=(e,t)=>{let r;switch(e.code){case pe.invalid_type:e.received===Te.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case pe.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,er.jsonStringifyReplacer)}`;break;case pe.unrecognized_keys:r=`Unrecognized key(s) in object: ${er.joinValues(e.keys,", ")}`;break;case pe.invalid_union:r="Invalid input";break;case pe.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${er.joinValues(e.options)}`;break;case pe.invalid_enum_value:r=`Invalid enum value. Expected ${er.joinValues(e.options)}, received '${e.received}'`;break;case pe.invalid_arguments:r="Invalid function arguments";break;case pe.invalid_return_type:r="Invalid function return type";break;case pe.invalid_date:r="Invalid date";break;case pe.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:er.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case pe.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case pe.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case pe.custom:r="Invalid input";break;case pe.invalid_intersection_types:r="Intersection results could not be merged";break;case pe.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case pe.not_finite:r="Number must be finite";break;default:r=t.defaultError,er.assertNever(e)}return{message:r}},qp=Oft});function Nft(e){gye=e}function BC(){return gye}var gye,LM=h(()=>{wY();gye=qp});function ke(e,t){let r=BC(),n=SR({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===qp?void 0:qp].filter(o=>!!o)});e.common.issues.push(n)}var SR,Mft,Mi,dt,Rx,us,UM,$M,Ag,_C,kY=h(()=>{LM();wY();SR=e=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,i=[...r,...o.path||[]],s={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(s,{data:t,defaultError:a}).message;return{...o,path:i,message:a}},Mft=[];Mi=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let o of r){if(o.status==="aborted")return dt;o.status==="dirty"&&t.dirty(),n.push(o.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let o of r){let i=await o.key,s=await o.value;n.push({key:i,value:s})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let o of r){let{key:i,value:s}=o;if(i.status==="aborted"||s.status==="aborted")return dt;i.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||o.alwaysSet)&&(n[i.value]=s.value)}return{status:t.value,value:n}}},dt=Object.freeze({status:"aborted"}),Rx=e=>({status:"dirty",value:e}),us=e=>({status:"valid",value:e}),UM=e=>e.status==="aborted",$M=e=>e.status==="dirty",Ag=e=>e.status==="valid",_C=e=>typeof Promise<"u"&&e instanceof Promise});var Aye=h(()=>{});var je,yye=h(()=>{(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(je||(je={}))});function Tt(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(s,a)=>{let{message:c}=e;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}function Sye(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Xft(e){return new RegExp(`^${Sye(e)}$`)}function Cye(e){let t=`${bye}T${Sye(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function ept(e,t){return!!((t==="v4"||!t)&&Gft.test(e)||(t==="v6"||!t)&&Vft.test(e))}function tpt(e,t){if(!Hft.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function rpt(e,t){return!!((t==="v4"||!t)&&zft.test(e)||(t==="v6"||!t)&&Yft.test(e))}function npt(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,i=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return i%s/10**o}function TC(e){if(e instanceof Aa){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=tu.create(TC(n))}return new Aa({...e._def,shape:()=>t})}else return e instanceof Vp?new Vp({...e._def,type:TC(e.element)}):e instanceof tu?tu.create(TC(e.unwrap())):e instanceof Zd?Zd.create(TC(e.unwrap())):e instanceof Kd?Kd.create(e.items.map(t=>TC(t))):e}function RY(e,t){let r=Jd(e),n=Jd(t);if(e===t)return{valid:!0,data:e};if(r===Te.object&&n===Te.object){let o=er.objectKeys(t),i=er.objectKeys(e).filter(a=>o.indexOf(a)!==-1),s={...e,...t};for(let a of i){let c=RY(e[a],t[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===Te.array&&n===Te.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let i=0;i<e.length;i++){let s=e[i],a=t[i],c=RY(s,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===Te.date&&n===Te.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}function Iye(e,t){return new Lx({values:e,typeName:ht.ZodEnum,...Tt(t)})}function Eye(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function wye(e,t={},r){return e?xg.create().superRefine((n,o)=>{let i=e(n);if(i instanceof Promise)return i.then(s=>{if(!s){let a=Eye(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!i){let s=Eye(t,n),a=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:a})}}):xg.create()}var ru,xye,Ht,Fft,Pft,Lft,Uft,$ft,Hft,Wft,jft,qft,vY,Gft,zft,Vft,Yft,Jft,Kft,bye,Zft,yg,Bx,_x,Tx,Dx,DC,Qx,Ox,xg,zp,kl,QC,Vp,Aa,Nx,Gp,HM,Mx,Kd,WM,OC,NC,jM,Fx,Px,Lx,Ux,Eg,nu,tu,Zd,$x,Hx,MC,opt,CR,IR,Wx,ipt,ht,spt,kye,vye,apt,cpt,Rye,upt,lpt,dpt,fpt,ppt,mpt,hpt,gpt,Apt,ypt,xpt,Ept,bpt,Spt,Cpt,Ipt,wpt,kpt,vpt,Rpt,Bpt,_pt,Tpt,Dpt,Qpt,Opt,Npt,Mpt,Fpt,Ppt,Lpt,Upt,$pt,Hpt,Bye=h(()=>{PM();LM();yye();kY();bR();ru=class{constructor(t,r,n,o){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=o}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}},xye=(e,t)=>{if(Ag(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new ga(e.common.issues);return this._error=r,this._error}}};Ht=class{get description(){return this._def.description}_getType(t){return Jd(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Jd(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Mi,ctx:{common:t.parent.common,data:t.data,parsedType:Jd(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(_C(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Jd(t)},o=this._parseSync({data:t,path:n.path,parent:n});return xye(n,o)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Jd(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return Ag(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>Ag(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Jd(t)},o=this._parse({data:t,path:n.path,parent:n}),i=await(_C(o)?o:Promise.resolve(o));return xye(n,i)}refine(t,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,i)=>{let s=t(o),a=()=>i.addIssue({code:pe.custom,...n(o)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,o)=>t(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(t){return new nu({schema:this,typeName:ht.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:r=>this["~validate"](r)}}optional(){return tu.create(this,this._def)}nullable(){return Zd.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Vp.create(this)}promise(){return Eg.create(this,this._def)}or(t){return Nx.create([this,t],this._def)}and(t){return Mx.create(this,t,this._def)}transform(t){return new nu({...Tt(this._def),schema:this,typeName:ht.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new $x({...Tt(this._def),innerType:this,defaultValue:r,typeName:ht.ZodDefault})}brand(){return new CR({typeName:ht.ZodBranded,type:this,...Tt(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Hx({...Tt(this._def),innerType:this,catchValue:r,typeName:ht.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return IR.create(this,t)}readonly(){return Wx.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Fft=/^c[^\s-]{8,}$/i,Pft=/^[0-9a-z]+$/,Lft=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Uft=/^[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,$ft=/^[a-z0-9_-]{21}$/i,Hft=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Wft=/^[-+]?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)?)??$/,jft=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qft="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Gft=/^(?:(?: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])$/,zft=/^(?:(?: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])$/,Vft=/^(([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]))$/,Yft=/^(([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])$/,Jft=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Kft=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bye="((\\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])))",Zft=new RegExp(`^${bye}$`);yg=class e extends Ht{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Te.string){let i=this._getOrReturnCtx(t);return ke(i,{code:pe.invalid_type,expected:Te.string,received:i.parsedType}),dt}let n=new Mi,o;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let s=t.data.length>i.value,a=t.data.length<i.value;(s||a)&&(o=this._getOrReturnCtx(t,o),s?ke(o,{code:pe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ke(o,{code:pe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")jft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"email",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")vY||(vY=new RegExp(qft,"u")),vY.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"emoji",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Uft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"uuid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")$ft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"nanoid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Fft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"cuid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Pft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"cuid2",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Lft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"ulid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),ke(o,{validation:"url",code:pe.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"regex",code:pe.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Cye(i).test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Zft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Xft(i).test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Wft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"duration",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?ept(t.data,i.version)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"ip",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?tpt(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"jwt",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?rpt(t.data,i.version)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"cidr",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Jft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"base64",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Kft.test(t.data)||(o=this._getOrReturnCtx(t,o),ke(o,{validation:"base64url",code:pe.invalid_string,message:i.message}),n.dirty()):er.assertNever(i);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(o=>t.test(o),{validation:r,code:pe.invalid_string,...je.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...je.errToObj(t)})}url(t){return this._addCheck({kind:"url",...je.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...je.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...je.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...je.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...je.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...je.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...je.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...je.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...je.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...je.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...je.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...je.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...je.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...je.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...je.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...je.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...je.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...je.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...je.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...je.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...je.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...je.errToObj(r)})}nonempty(t){return this.min(1,je.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};yg.create=e=>new yg({checks:[],typeName:ht.ZodString,coerce:e?.coerce??!1,...Tt(e)});Bx=class e extends Ht{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Te.number){let i=this._getOrReturnCtx(t);return ke(i,{code:pe.invalid_type,expected:Te.number,received:i.parsedType}),dt}let n,o=new Mi;for(let i of this._def.checks)i.kind==="int"?er.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?npt(t.data,i.value)!==0&&(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.not_finite,message:i.message}),o.dirty()):er.assertNever(i);return{status:o.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,je.toString(r))}gt(t,r){return this.setLimit("min",t,!1,je.toString(r))}lte(t,r){return this.setLimit("max",t,!0,je.toString(r))}lt(t,r){return this.setLimit("max",t,!1,je.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:je.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:je.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:je.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:je.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:je.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:je.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:je.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:je.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:je.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:je.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&er.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Bx.create=e=>new Bx({checks:[],typeName:ht.ZodNumber,coerce:e?.coerce||!1,...Tt(e)});_x=class e extends Ht{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Te.bigint)return this._getInvalidInput(t);let n,o=new Mi;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),ke(n,{code:pe.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):er.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return ke(r,{code:pe.invalid_type,expected:Te.bigint,received:r.parsedType}),dt}gte(t,r){return this.setLimit("min",t,!0,je.toString(r))}gt(t,r){return this.setLimit("min",t,!1,je.toString(r))}lte(t,r){return this.setLimit("max",t,!0,je.toString(r))}lt(t,r){return this.setLimit("max",t,!1,je.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:je.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:je.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:je.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:je.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:je.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:je.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};_x.create=e=>new _x({checks:[],typeName:ht.ZodBigInt,coerce:e?.coerce??!1,...Tt(e)});Tx=class extends Ht{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Te.boolean){let n=this._getOrReturnCtx(t);return ke(n,{code:pe.invalid_type,expected:Te.boolean,received:n.parsedType}),dt}return us(t.data)}};Tx.create=e=>new Tx({typeName:ht.ZodBoolean,coerce:e?.coerce||!1,...Tt(e)});Dx=class e extends Ht{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Te.date){let i=this._getOrReturnCtx(t);return ke(i,{code:pe.invalid_type,expected:Te.date,received:i.parsedType}),dt}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return ke(i,{code:pe.invalid_date}),dt}let n=new Mi,o;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),ke(o,{code:pe.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):er.assertNever(i);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:je.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:je.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Dx.create=e=>new Dx({checks:[],coerce:e?.coerce||!1,typeName:ht.ZodDate,...Tt(e)});DC=class extends Ht{_parse(t){if(this._getType(t)!==Te.symbol){let n=this._getOrReturnCtx(t);return ke(n,{code:pe.invalid_type,expected:Te.symbol,received:n.parsedType}),dt}return us(t.data)}};DC.create=e=>new DC({typeName:ht.ZodSymbol,...Tt(e)});Qx=class extends Ht{_parse(t){if(this._getType(t)!==Te.undefined){let n=this._getOrReturnCtx(t);return ke(n,{code:pe.invalid_type,expected:Te.undefined,received:n.parsedType}),dt}return us(t.data)}};Qx.create=e=>new Qx({typeName:ht.ZodUndefined,...Tt(e)});Ox=class extends Ht{_parse(t){if(this._getType(t)!==Te.null){let n=this._getOrReturnCtx(t);return ke(n,{code:pe.invalid_type,expected:Te.null,received:n.parsedType}),dt}return us(t.data)}};Ox.create=e=>new Ox({typeName:ht.ZodNull,...Tt(e)});xg=class extends Ht{constructor(){super(...arguments),this._any=!0}_parse(t){return us(t.data)}};xg.create=e=>new xg({typeName:ht.ZodAny,...Tt(e)});zp=class extends Ht{constructor(){super(...arguments),this._unknown=!0}_parse(t){return us(t.data)}};zp.create=e=>new zp({typeName:ht.ZodUnknown,...Tt(e)});kl=class extends Ht{_parse(t){let r=this._getOrReturnCtx(t);return ke(r,{code:pe.invalid_type,expected:Te.never,received:r.parsedType}),dt}};kl.create=e=>new kl({typeName:ht.ZodNever,...Tt(e)});QC=class extends Ht{_parse(t){if(this._getType(t)!==Te.undefined){let n=this._getOrReturnCtx(t);return ke(n,{code:pe.invalid_type,expected:Te.void,received:n.parsedType}),dt}return us(t.data)}};QC.create=e=>new QC({typeName:ht.ZodVoid,...Tt(e)});Vp=class e extends Ht{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),o=this._def;if(r.parsedType!==Te.array)return ke(r,{code:pe.invalid_type,expected:Te.array,received:r.parsedType}),dt;if(o.exactLength!==null){let s=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(s||a)&&(ke(r,{code:s?pe.too_big:pe.too_small,minimum:a?o.exactLength.value:void 0,maximum:s?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(ke(r,{code:pe.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(ke(r,{code:pe.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>o.type._parseAsync(new ru(r,s,r.path,a)))).then(s=>Mi.mergeArray(n,s));let i=[...r.data].map((s,a)=>o.type._parseSync(new ru(r,s,r.path,a)));return Mi.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:je.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:je.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:je.toString(r)}})}nonempty(t){return this.min(1,t)}};Vp.create=(e,t)=>new Vp({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ht.ZodArray,...Tt(t)});Aa=class e extends Ht{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=er.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Te.object){let u=this._getOrReturnCtx(t);return ke(u,{code:pe.invalid_type,expected:Te.object,received:u.parsedType}),dt}let{status:n,ctx:o}=this._processInputParams(t),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof kl&&this._def.unknownKeys==="strip"))for(let u in o.data)s.includes(u)||a.push(u);let c=[];for(let u of s){let l=i[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ru(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof kl){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(ke(o,{code:pe.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ru(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>Mi.mergeObjectSync(n,u)):Mi.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return je.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:je.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ht.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of er.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of er.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return TC(this)}partial(t){let r={};for(let n of er.objectKeys(this.shape)){let o=this.shape[n];t&&!t[n]?r[n]=o:r[n]=o.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of er.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof tu;)i=i._def.innerType;r[n]=i}return new e({...this._def,shape:()=>r})}keyof(){return Iye(er.objectKeys(this.shape))}};Aa.create=(e,t)=>new Aa({shape:()=>e,unknownKeys:"strip",catchall:kl.create(),typeName:ht.ZodObject,...Tt(t)});Aa.strictCreate=(e,t)=>new Aa({shape:()=>e,unknownKeys:"strict",catchall:kl.create(),typeName:ht.ZodObject,...Tt(t)});Aa.lazycreate=(e,t)=>new Aa({shape:e,unknownKeys:"strip",catchall:kl.create(),typeName:ht.ZodObject,...Tt(t)});Nx=class extends Ht{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function o(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(a=>new ga(a.ctx.common.issues));return ke(r,{code:pe.invalid_union,unionErrors:s}),dt}if(r.common.async)return Promise.all(n.map(async i=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(o);{let i,s=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&s.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(c=>new ga(c));return ke(r,{code:pe.invalid_union,unionErrors:a}),dt}}get options(){return this._def.options}};Nx.create=(e,t)=>new Nx({options:e,typeName:ht.ZodUnion,...Tt(t)});Gp=e=>e instanceof Fx?Gp(e.schema):e instanceof nu?Gp(e.innerType()):e instanceof Px?[e.value]:e instanceof Lx?e.options:e instanceof Ux?er.objectValues(e.enum):e instanceof $x?Gp(e._def.innerType):e instanceof Qx?[void 0]:e instanceof Ox?[null]:e instanceof tu?[void 0,...Gp(e.unwrap())]:e instanceof Zd?[null,...Gp(e.unwrap())]:e instanceof CR||e instanceof Wx?Gp(e.unwrap()):e instanceof Hx?Gp(e._def.innerType):[],HM=class e extends Ht{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Te.object)return ke(r,{code:pe.invalid_type,expected:Te.object,received:r.parsedType}),dt;let n=this.discriminator,o=r.data[n],i=this.optionsMap.get(o);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(ke(r,{code:pe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),dt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let o=new Map;for(let i of r){let s=Gp(i.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of s){if(o.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);o.set(a,i)}}return new e({typeName:ht.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:o,...Tt(n)})}};Mx=class extends Ht{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=(i,s)=>{if(UM(i)||UM(s))return dt;let a=RY(i.value,s.value);return a.valid?(($M(i)||$M(s))&&r.dirty(),{status:r.value,value:a.data}):(ke(n,{code:pe.invalid_intersection_types}),dt)};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,s])=>o(i,s)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Mx.create=(e,t,r)=>new Mx({left:e,right:t,typeName:ht.ZodIntersection,...Tt(r)});Kd=class e extends Ht{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Te.array)return ke(n,{code:pe.invalid_type,expected:Te.array,received:n.parsedType}),dt;if(n.data.length<this._def.items.length)return ke(n,{code:pe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),dt;!this._def.rest&&n.data.length>this._def.items.length&&(ke(n,{code:pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((s,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new ru(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>Mi.mergeArray(r,s)):Mi.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Kd.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Kd({items:e,typeName:ht.ZodTuple,rest:null,...Tt(t)})};WM=class e extends Ht{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Te.object)return ke(n,{code:pe.invalid_type,expected:Te.object,received:n.parsedType}),dt;let o=[],i=this._def.keyType,s=this._def.valueType;for(let a in n.data)o.push({key:i._parse(new ru(n,a,n.path,a)),value:s._parse(new ru(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Mi.mergeObjectAsync(r,o):Mi.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Ht?new e({keyType:t,valueType:r,typeName:ht.ZodRecord,...Tt(n)}):new e({keyType:yg.create(),valueType:t,typeName:ht.ZodRecord,...Tt(r)})}},OC=class extends Ht{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Te.map)return ke(n,{code:pe.invalid_type,expected:Te.map,received:n.parsedType}),dt;let o=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new ru(n,a,n.path,[u,"key"])),value:i._parse(new ru(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of s){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return dt;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of s){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return dt;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};OC.create=(e,t,r)=>new OC({valueType:t,keyType:e,typeName:ht.ZodMap,...Tt(r)});NC=class e extends Ht{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Te.set)return ke(n,{code:pe.invalid_type,expected:Te.set,received:n.parsedType}),dt;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(ke(n,{code:pe.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(ke(n,{code:pe.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let i=this._def.valueType;function s(c){let u=new Set;for(let l of c){if(l.status==="aborted")return dt;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>i._parse(new ru(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>s(c)):s(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:je.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:je.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};NC.create=(e,t)=>new NC({valueType:e,minSize:null,maxSize:null,typeName:ht.ZodSet,...Tt(t)});jM=class e extends Ht{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Te.function)return ke(r,{code:pe.invalid_type,expected:Te.function,received:r.parsedType}),dt;function n(a,c){return SR({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,BC(),qp].filter(u=>!!u),issueData:{code:pe.invalid_arguments,argumentsError:c}})}function o(a,c){return SR({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,BC(),qp].filter(u=>!!u),issueData:{code:pe.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Eg){let a=this;return us(async function(...c){let u=new ga([]),l=await a._def.args.parseAsync(c,i).catch(p=>{throw u.addIssue(n(c,p)),u}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,i).catch(p=>{throw u.addIssue(o(d,p)),u})})}else{let a=this;return us(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new ga([n(c,u.error)]);let l=Reflect.apply(s,this,u.data),d=a._def.returns.safeParse(l,i);if(!d.success)throw new ga([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Kd.create(t).rest(zp.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Kd.create([]).rest(zp.create()),returns:r||zp.create(),typeName:ht.ZodFunction,...Tt(n)})}},Fx=class extends Ht{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Fx.create=(e,t)=>new Fx({getter:e,typeName:ht.ZodLazy,...Tt(t)});Px=class extends Ht{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return ke(r,{received:r.data,code:pe.invalid_literal,expected:this._def.value}),dt}return{status:"valid",value:t.data}}get value(){return this._def.value}};Px.create=(e,t)=>new Px({value:e,typeName:ht.ZodLiteral,...Tt(t)});Lx=class e extends Ht{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return ke(r,{expected:er.joinValues(n),received:r.parsedType,code:pe.invalid_type}),dt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return ke(r,{received:r.data,code:pe.invalid_enum_value,options:n}),dt}return us(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Lx.create=Iye;Ux=class extends Ht{_parse(t){let r=er.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Te.string&&n.parsedType!==Te.number){let o=er.objectValues(r);return ke(n,{expected:er.joinValues(o),received:n.parsedType,code:pe.invalid_type}),dt}if(this._cache||(this._cache=new Set(er.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=er.objectValues(r);return ke(n,{received:n.data,code:pe.invalid_enum_value,options:o}),dt}return us(t.data)}get enum(){return this._def.values}};Ux.create=(e,t)=>new Ux({values:e,typeName:ht.ZodNativeEnum,...Tt(t)});Eg=class extends Ht{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Te.promise&&r.common.async===!1)return ke(r,{code:pe.invalid_type,expected:Te.promise,received:r.parsedType}),dt;let n=r.parsedType===Te.promise?r.data:Promise.resolve(r.data);return us(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Eg.create=(e,t)=>new Eg({type:e,typeName:ht.ZodPromise,...Tt(t)});nu=class extends Ht{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ht.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:s=>{ke(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let s=o.transform(n.data,i);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return dt;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?dt:c.status==="dirty"?Rx(c.value):r.value==="dirty"?Rx(c.value):c});{if(r.value==="aborted")return dt;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?dt:a.status==="dirty"?Rx(a.value):r.value==="dirty"?Rx(a.value):a}}if(o.type==="refinement"){let s=a=>{let c=o.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?dt:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?dt:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ag(s))return dt;let a=o.transform(s.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>Ag(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:r.value,value:a})):dt);er.assertNever(o)}};nu.create=(e,t,r)=>new nu({schema:e,typeName:ht.ZodEffects,effect:t,...Tt(r)});nu.createWithPreprocess=(e,t,r)=>new nu({schema:t,effect:{type:"preprocess",transform:e},typeName:ht.ZodEffects,...Tt(r)});tu=class extends Ht{_parse(t){return this._getType(t)===Te.undefined?us(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};tu.create=(e,t)=>new tu({innerType:e,typeName:ht.ZodOptional,...Tt(t)});Zd=class extends Ht{_parse(t){return this._getType(t)===Te.null?us(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Zd.create=(e,t)=>new Zd({innerType:e,typeName:ht.ZodNullable,...Tt(t)});$x=class extends Ht{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===Te.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};$x.create=(e,t)=>new $x({innerType:e,typeName:ht.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Tt(t)});Hx=class extends Ht{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return _C(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ga(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ga(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Hx.create=(e,t)=>new Hx({innerType:e,typeName:ht.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Tt(t)});MC=class extends Ht{_parse(t){if(this._getType(t)!==Te.nan){let n=this._getOrReturnCtx(t);return ke(n,{code:pe.invalid_type,expected:Te.nan,received:n.parsedType}),dt}return{status:"valid",value:t.data}}};MC.create=e=>new MC({typeName:ht.ZodNaN,...Tt(e)});opt=Symbol("zod_brand"),CR=class extends Ht{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},IR=class e extends Ht{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);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"?dt:i.status==="dirty"?(r.dirty(),Rx(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?dt:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:ht.ZodPipeline})}},Wx=class extends Ht{_parse(t){let r=this._def.innerType._parse(t),n=o=>(Ag(o)&&(o.value=Object.freeze(o.value)),o);return _C(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Wx.create=(e,t)=>new Wx({innerType:e,typeName:ht.ZodReadonly,...Tt(t)});ipt={object:Aa.lazycreate};(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(ht||(ht={}));spt=(e,t={message:`Input not instance of ${e.name}`})=>wye(r=>r instanceof e,t),kye=yg.create,vye=Bx.create,apt=MC.create,cpt=_x.create,Rye=Tx.create,upt=Dx.create,lpt=DC.create,dpt=Qx.create,fpt=Ox.create,ppt=xg.create,mpt=zp.create,hpt=kl.create,gpt=QC.create,Apt=Vp.create,ypt=Aa.create,xpt=Aa.strictCreate,Ept=Nx.create,bpt=HM.create,Spt=Mx.create,Cpt=Kd.create,Ipt=WM.create,wpt=OC.create,kpt=NC.create,vpt=jM.create,Rpt=Fx.create,Bpt=Px.create,_pt=Lx.create,Tpt=Ux.create,Dpt=Eg.create,Qpt=nu.create,Opt=tu.create,Npt=Zd.create,Mpt=nu.createWithPreprocess,Fpt=IR.create,Ppt=()=>kye().optional(),Lpt=()=>vye().optional(),Upt=()=>Rye().optional(),$pt={string:e=>yg.create({...e,coerce:!0}),number:e=>Bx.create({...e,coerce:!0}),boolean:e=>Tx.create({...e,coerce:!0}),bigint:e=>_x.create({...e,coerce:!0}),date:e=>Dx.create({...e,coerce:!0})},Hpt=dt});var Ce={};Xt(Ce,{BRAND:()=>opt,DIRTY:()=>Rx,EMPTY_PATH:()=>Mft,INVALID:()=>dt,NEVER:()=>Hpt,OK:()=>us,ParseStatus:()=>Mi,Schema:()=>Ht,ZodAny:()=>xg,ZodArray:()=>Vp,ZodBigInt:()=>_x,ZodBoolean:()=>Tx,ZodBranded:()=>CR,ZodCatch:()=>Hx,ZodDate:()=>Dx,ZodDefault:()=>$x,ZodDiscriminatedUnion:()=>HM,ZodEffects:()=>nu,ZodEnum:()=>Lx,ZodError:()=>ga,ZodFirstPartyTypeKind:()=>ht,ZodFunction:()=>jM,ZodIntersection:()=>Mx,ZodIssueCode:()=>pe,ZodLazy:()=>Fx,ZodLiteral:()=>Px,ZodMap:()=>OC,ZodNaN:()=>MC,ZodNativeEnum:()=>Ux,ZodNever:()=>kl,ZodNull:()=>Ox,ZodNullable:()=>Zd,ZodNumber:()=>Bx,ZodObject:()=>Aa,ZodOptional:()=>tu,ZodParsedType:()=>Te,ZodPipeline:()=>IR,ZodPromise:()=>Eg,ZodReadonly:()=>Wx,ZodRecord:()=>WM,ZodSchema:()=>Ht,ZodSet:()=>NC,ZodString:()=>yg,ZodSymbol:()=>DC,ZodTransformer:()=>nu,ZodTuple:()=>Kd,ZodType:()=>Ht,ZodUndefined:()=>Qx,ZodUnion:()=>Nx,ZodUnknown:()=>zp,ZodVoid:()=>QC,addIssueToContext:()=>ke,any:()=>ppt,array:()=>Apt,bigint:()=>cpt,boolean:()=>Rye,coerce:()=>$pt,custom:()=>wye,date:()=>upt,datetimeRegex:()=>Cye,defaultErrorMap:()=>qp,discriminatedUnion:()=>bpt,effect:()=>Qpt,enum:()=>_pt,function:()=>vpt,getErrorMap:()=>BC,getParsedType:()=>Jd,instanceof:()=>spt,intersection:()=>Spt,isAborted:()=>UM,isAsync:()=>_C,isDirty:()=>$M,isValid:()=>Ag,late:()=>ipt,lazy:()=>Rpt,literal:()=>Bpt,makeIssue:()=>SR,map:()=>wpt,nan:()=>apt,nativeEnum:()=>Tpt,never:()=>hpt,null:()=>fpt,nullable:()=>Npt,number:()=>vye,object:()=>ypt,objectUtil:()=>IY,oboolean:()=>Upt,onumber:()=>Lpt,optional:()=>Opt,ostring:()=>Ppt,pipeline:()=>Fpt,preprocess:()=>Mpt,promise:()=>Dpt,quotelessJson:()=>Qft,record:()=>Ipt,set:()=>kpt,setErrorMap:()=>Nft,strictObject:()=>xpt,string:()=>kye,symbol:()=>lpt,transformer:()=>Qpt,tuple:()=>Cpt,undefined:()=>dpt,union:()=>Ept,unknown:()=>mpt,util:()=>er,void:()=>gpt});var BY=h(()=>{LM();kY();Aye();bR();Bye();PM()});var qM=h(()=>{BY();BY()});function Tye(e){let t=e[Wpt];if(typeof t=="string"&&t.length>0)return{ANTHROPIC_API_KEY:t,ANTHROPIC_BASE_URL:jpt,CLAUDE_CODE_SIMPLE:qpt}}var Wpt,jpt,_ye,qpt,Dye=h(()=>{"use strict";Wpt="MINIMAX_API_KEY",jpt="https://api.minimax.io/anthropic",_ye="MiniMax-M3",qpt="1"});function Qye(e){for(let t of Gpt){let r=e[t];if(typeof r=="string"&&r.length>0)return{envVar:t,keyValue:r}}}function Oye(e){return e?{[e.envVar]:e.keyValue}:void 0}var Gpt,Nye=h(()=>{"use strict";Gpt=["OPENAI_API_KEY","MINIMAX_API_KEY","OPENROUTER_API_KEY"]});function FC(e){return e==="codex"||e==="opencode"||e==="claude-minimax"?e:"claude"}function wR(e){return zM[e].structuredOutput===!0}var _Y,GM,TY,zM,kR=h(()=>{"use strict";Dye();Nye();_Y=["low","medium","high","xhigh"],GM=["low","medium","high","xhigh","max"],TY=["low"],zM={claude:{efforts:GM,channel:"effort",factory:"claudeCode",structuredOutput:!0},codex:{efforts:_Y,channel:"effort",factory:"codex"},opencode:{efforts:GM,channel:"variant",factory:"opencode",resolveAuthEnv:e=>Oye(Qye(e))},"claude-minimax":{efforts:TY,channel:"effort",factory:"claudeCode",forcedModel:_ye,defaultEffort:"low",resolveAuthEnv:Tye}}});import{readFileSync as zpt}from"node:fs";function Vpt(e){let t=Mye.indexOf(e);return t<=0?"validate":Mye[t-1]}function Fye(){return{...VM}}function Jpt(e){let t={},r=[],n=[],o={};for(let i of e.split(`
22
- `)){i=i.replace(/\r$/,"");let s=i;if(!/".*"/.test(s)&&!/'.*'/.test(s)){let m=s.indexOf("#");m>=0&&(s=s.slice(0,m))}if(s.replace(/\s/g,"")==="")continue;let c=(s.match(/^\s*/)?.[0]??"").length;if(c%2!==0)throw new Xd;let u=s.slice(c).replace(/\s+$/,"");if(/^-(\s|$)/.test(u)){for(;n.length>0&&n[n.length-1]>=c;)r.pop(),n.pop();if(r.length===0)throw new Xd;let m=u.slice(1).replace(/^\s+/,"");if(m==="")throw new Xd;if(m[0]==='"'||m[0]==="'"){let E=m[0],y=m.indexOf(E,1);if(y>0){let b=m.slice(y+1).trimStart();(b===""||b.startsWith("#"))&&(m=m.slice(0,y+1))}}if(m.startsWith('"')){if(!m.endsWith('"')||m.length<2)throw new Xd;m=m.slice(1,-1)}else if(m.startsWith("'")){if(!m.endsWith("'")||m.length<2)throw new Xd;m=m.slice(1,-1)}let g=r.join("."),A=o[g]??0;o[g]=A+1,t[`${g}.${A}`]=m;continue}if(!/^[a-zA-Z_][a-zA-Z0-9_-]*:/.test(u))throw new Xd;let l=u.indexOf(":"),d=u.slice(0,l),f=u.slice(l+1).replace(/^\s+/,"");if(f[0]==='"'||f[0]==="'"){let m=f[0],g=f.indexOf(m,1);if(g>0){let A=f.slice(g+1).trimStart();(A===""||A.startsWith("#"))&&(f=f.slice(0,g+1))}}if(f.startsWith('"')){if(!f.endsWith('"')||f.length<2)throw new Xd;f=f.slice(1,-1)}else if(f.startsWith("'")){if(!f.endsWith("'")||f.length<2)throw new Xd;f=f.slice(1,-1)}for(;n.length>0&&n[n.length-1]>=c;)r.pop(),n.pop();let p=r.length>0?`${r.join(".")}.${d}`:d;f===""?(r.push(d),n.push(c)):t[p]=f}return t}function br(e,t={}){let r=t.read??Kpt,n=t.warn??Zpt,o=Fye(),i=r(e);if(i===void 0)return o;let s;try{s=Jpt(i)}catch{return n(`[afk:config] warn: malformed YAML in ${e} \u2014 using defaults`),Fye()}let a=new Set;for(let[c,u]of Object.entries(s))o[c]=u,a.add(c);for(let[c,u]of Object.entries(s)){let l=/^plugins\.dev\.(.+)$/.exec(c);if(!l)continue;let d=l[1],f=d==="afk"||d.startsWith("afk.")?d:`dev.${d}`;o[f]=u,a.add(f)}return a.size>0&&(o["\0explicit"]=Array.from(a).join("")),o}function rt(e,t){return e[t]??""}function Pye(e,t,r){let n=`afk.models.${e}.${t}.${r}`;return Object.prototype.hasOwnProperty.call(VM,n)?n:void 0}function Lye(e,t){return Ypt.includes(e)?e:t}function ya(e,t,r="think",n={}){let o=FC(t),i=YM.includes(r)?r:"think",s=n.RED_AFK_TASK_TIER_DOWNGRADE==="1"?Vpt(i):i,a=Pye(o,s,"model"),c=Pye(o,s,"effort"),u=VM[a],l=VM[c],d=rt(e,a),f=rt(e,`afk.models.${o}.base.model`),p=rt(e,`afk.models.${o}.base.effort`),m=rt(e,`afk.models.${o}`),g=rt(e,"afk.model"),A=rt(e,c),E=new Set((e["\0explicit"]??"").split("").filter(Boolean)),y=(n.RED_AFK_MODEL??"").trim(),b=(n.RED_AFK_EFFORT??"").trim(),I=d&&(d!==u||E.has(a))?d:f||m||g||u,w=A&&(A!==l||E.has(c))?A:p||l;return{model:y.length>0?y:I,effort:b.length>0?Lye(b,l):Lye(w,l)}}function JM(e){let t=[];for(let n=0;;n++){let o=e[`afk.backpressure.${n}`];if(o===void 0)break;o.trim()!==""&&t.push(o)}if(t.length>0)return t;let r=e["afk.backpressure"];return r&&r.trim()!==""?[r]:[]}function Uye(e){let t=[];for(let n=0;;n++){let o=e[`afk.post_attempt_format.${n}`];if(o===void 0)break;o.trim()!==""&&t.push(o)}if(t.length>0)return t;let r=e["afk.post_attempt_format"];return r&&r.trim()!==""?[r]:[]}function $ye(e=process.env){let t=(e.RED_AFK_MERGE_CI_TIMEOUT_S??"").trim(),r=Number.parseInt(t,10);return Number.isInteger(r)&&r>0?r:Xpt}var VM,YM,Mye,Ypt,MAr,Xd,Kpt,Zpt,Xpt,Qo=h(()=>{"use strict";qM();kR();VM={"afk.default_runner":"claude","afk.fleet.target":"2","afk.models.claude.validate.model":"claude-haiku-4-5","afk.models.claude.validate.effort":"low","afk.models.claude.simple.model":"claude-sonnet-4-6","afk.models.claude.simple.effort":"high","afk.models.claude.complex.model":"claude-opus-4-8","afk.models.claude.complex.effort":"medium","afk.models.claude.think.model":"claude-opus-4-8","afk.models.claude.think.effort":"high","afk.models.codex.validate.model":"gpt-5.5","afk.models.codex.validate.effort":"low","afk.models.codex.simple.model":"gpt-5.5","afk.models.codex.simple.effort":"high","afk.models.codex.complex.model":"gpt-5.5","afk.models.codex.complex.effort":"medium","afk.models.codex.think.model":"gpt-5.5","afk.models.codex.think.effort":"high","afk.models.opencode.validate.model":"openrouter/anthropic/claude-3.5-haiku","afk.models.opencode.validate.effort":"low","afk.models.opencode.simple.model":"openrouter/anthropic/claude-sonnet-4","afk.models.opencode.simple.effort":"high","afk.models.opencode.complex.model":"openrouter/anthropic/claude-opus-4","afk.models.opencode.complex.effort":"medium","afk.models.opencode.think.model":"openrouter/anthropic/claude-opus-4","afk.models.opencode.think.effort":"high","afk.models.claude-minimax.validate.model":"MiniMax-M3","afk.models.claude-minimax.validate.effort":"low","afk.models.claude-minimax.simple.model":"MiniMax-M3","afk.models.claude-minimax.simple.effort":"low","afk.models.claude-minimax.complex.model":"MiniMax-M3","afk.models.claude-minimax.complex.effort":"low","afk.models.claude-minimax.think.model":"MiniMax-M3","afk.models.claude-minimax.think.effort":"low","afk.hooks.defaults.cargo":"true","afk.hooks.defaults.gradle":"true","afk.feedback.rebase_on_base":"false","afk.merge.wait_for_review":"false","afk.merge.review_check":"CodeRabbit","afk.merge.ci_aware":"false","afk.worktree_launches_pull_request":"true","afk.review_gate.enabled":"false","afk.review_gate.threshold":"complex","afk.release.channel":"stable","afk.claim_reaper.refresh_s":"300","afk.claim_reaper.stale_tolerance":"3","afk.claim_reaper.grace_s":"300","afk.claim_reaper.recent_commit_s":"2700","afk.worktree_pool.enabled":"false","afk.worktree_pool.max_size":"4","afk.worktree_pool.lease_ttl_s":"3600","afk.worktree_pool.min_idle_s":"1800","afk.companion.iteration_churn":"8","afk.companion.waiting_windows":"20","afk.companion.diff_drift_loc":"4000","afk.companion.min_progress_loc":"5","afk.notes_loop.enabled":"false","afk.notes_loop.max_iterations":"4","afk.notes_loop.inner_max_iterations":"0","afk.notes_loop.token_budget":"0","afk.notes_loop.wall_clock_s":"0","afk.landing.cascade_rebase":"true","dev.lock.primary-branch":"false","dev.trunk":"main"},YM=["validate","simple","complex","think"],Mye=YM;Ypt=["low","medium","high","xhigh","max"],MAr=Ce.record(Ce.string()),Xd=class extends Error{constructor(t="malformed YAML"){super(t),this.name="MalformedConfigError"}};Kpt=e=>{try{return zpt(e,"utf8")}catch{return}},Zpt=e=>{process.stderr.write(`${e}
22
+ `)){i=i.replace(/\r$/,"");let s=i;if(!/".*"/.test(s)&&!/'.*'/.test(s)){let m=s.indexOf("#");m>=0&&(s=s.slice(0,m))}if(s.replace(/\s/g,"")==="")continue;let c=(s.match(/^\s*/)?.[0]??"").length;if(c%2!==0)throw new Xd;let u=s.slice(c).replace(/\s+$/,"");if(/^-(\s|$)/.test(u)){for(;n.length>0&&n[n.length-1]>=c;)r.pop(),n.pop();if(r.length===0)throw new Xd;let m=u.slice(1).replace(/^\s+/,"");if(m==="")throw new Xd;if(m[0]==='"'||m[0]==="'"){let E=m[0],y=m.indexOf(E,1);if(y>0){let b=m.slice(y+1).trimStart();(b===""||b.startsWith("#"))&&(m=m.slice(0,y+1))}}if(m.startsWith('"')){if(!m.endsWith('"')||m.length<2)throw new Xd;m=m.slice(1,-1)}else if(m.startsWith("'")){if(!m.endsWith("'")||m.length<2)throw new Xd;m=m.slice(1,-1)}let g=r.join("."),A=o[g]??0;o[g]=A+1,t[`${g}.${A}`]=m;continue}if(!/^[a-zA-Z_][a-zA-Z0-9_-]*:/.test(u))throw new Xd;let l=u.indexOf(":"),d=u.slice(0,l),f=u.slice(l+1).replace(/^\s+/,"");if(f[0]==='"'||f[0]==="'"){let m=f[0],g=f.indexOf(m,1);if(g>0){let A=f.slice(g+1).trimStart();(A===""||A.startsWith("#"))&&(f=f.slice(0,g+1))}}if(f.startsWith('"')){if(!f.endsWith('"')||f.length<2)throw new Xd;f=f.slice(1,-1)}else if(f.startsWith("'")){if(!f.endsWith("'")||f.length<2)throw new Xd;f=f.slice(1,-1)}for(;n.length>0&&n[n.length-1]>=c;)r.pop(),n.pop();let p=r.length>0?`${r.join(".")}.${d}`:d;f===""?(r.push(d),n.push(c)):t[p]=f}return t}function br(e,t={}){let r=t.read??Kpt,n=t.warn??Zpt,o=Fye(),i=r(e);if(i===void 0)return o;let s;try{s=Jpt(i)}catch{return n(`[afk:config] warn: malformed YAML in ${e} \u2014 using defaults`),Fye()}let a=new Set;for(let[c,u]of Object.entries(s))o[c]=u,a.add(c);for(let[c,u]of Object.entries(s)){let l=/^plugins\.dev\.(.+)$/.exec(c);if(!l)continue;let d=l[1],f=d==="afk"||d.startsWith("afk.")?d:`dev.${d}`;o[f]=u,a.add(f)}return a.size>0&&(o["\0explicit"]=Array.from(a).join("")),o}function rt(e,t){return e[t]??""}function Pye(e,t,r){let n=`afk.models.${e}.${t}.${r}`;return Object.prototype.hasOwnProperty.call(VM,n)?n:void 0}function Lye(e,t){return Ypt.includes(e)?e:t}function ya(e,t,r="think",n={}){let o=FC(t),i=YM.includes(r)?r:"think",s=n.RED_AFK_TASK_TIER_DOWNGRADE==="1"?Vpt(i):i,a=Pye(o,s,"model"),c=Pye(o,s,"effort"),u=VM[a],l=VM[c],d=rt(e,a),f=rt(e,`afk.models.${o}.base.model`),p=rt(e,`afk.models.${o}.base.effort`),m=rt(e,`afk.models.${o}`),g=rt(e,"afk.model"),A=rt(e,c),E=new Set((e["\0explicit"]??"").split("").filter(Boolean)),y=(n.RED_AFK_MODEL??"").trim(),b=(n.RED_AFK_EFFORT??"").trim(),I=d&&(d!==u||E.has(a))?d:f||m||g||u,w=A&&(A!==l||E.has(c))?A:p||l;return{model:y.length>0?y:I,effort:b.length>0?Lye(b,l):Lye(w,l)}}function JM(e){let t=[];for(let n=0;;n++){let o=e[`afk.backpressure.${n}`];if(o===void 0)break;o.trim()!==""&&t.push(o)}if(t.length>0)return t;let r=e["afk.backpressure"];return r&&r.trim()!==""?[r]:[]}function Uye(e){let t=[];for(let n=0;;n++){let o=e[`afk.post_attempt_format.${n}`];if(o===void 0)break;o.trim()!==""&&t.push(o)}if(t.length>0)return t;let r=e["afk.post_attempt_format"];return r&&r.trim()!==""?[r]:[]}function $ye(e=process.env){let t=(e.RED_AFK_MERGE_CI_TIMEOUT_S??"").trim(),r=Number.parseInt(t,10);return Number.isInteger(r)&&r>0?r:Xpt}var VM,YM,Mye,Ypt,MAr,Xd,Kpt,Zpt,Xpt,Qo=h(()=>{"use strict";qM();kR();VM={"afk.default_runner":"claude","afk.fleet.target":"2","afk.models.claude.validate.model":"claude-haiku-4-5","afk.models.claude.validate.effort":"low","afk.models.claude.simple.model":"claude-sonnet-4-6","afk.models.claude.simple.effort":"high","afk.models.claude.complex.model":"claude-opus-4-8","afk.models.claude.complex.effort":"medium","afk.models.claude.think.model":"claude-opus-4-8","afk.models.claude.think.effort":"high","afk.models.codex.validate.model":"gpt-5.5","afk.models.codex.validate.effort":"low","afk.models.codex.simple.model":"gpt-5.5","afk.models.codex.simple.effort":"high","afk.models.codex.complex.model":"gpt-5.5","afk.models.codex.complex.effort":"medium","afk.models.codex.think.model":"gpt-5.5","afk.models.codex.think.effort":"high","afk.models.opencode.validate.model":"openrouter/anthropic/claude-3.5-haiku","afk.models.opencode.validate.effort":"low","afk.models.opencode.simple.model":"openrouter/anthropic/claude-sonnet-4","afk.models.opencode.simple.effort":"high","afk.models.opencode.complex.model":"openrouter/anthropic/claude-opus-4","afk.models.opencode.complex.effort":"medium","afk.models.opencode.think.model":"openrouter/anthropic/claude-opus-4","afk.models.opencode.think.effort":"high","afk.models.claude-minimax.validate.model":"MiniMax-M3","afk.models.claude-minimax.validate.effort":"low","afk.models.claude-minimax.simple.model":"MiniMax-M3","afk.models.claude-minimax.simple.effort":"low","afk.models.claude-minimax.complex.model":"MiniMax-M3","afk.models.claude-minimax.complex.effort":"low","afk.models.claude-minimax.think.model":"MiniMax-M3","afk.models.claude-minimax.think.effort":"low","afk.hooks.defaults.cargo":"true","afk.hooks.defaults.gradle":"true","afk.feedback.rebase_on_base":"false","afk.merge.wait_for_review":"false","afk.merge.review_check":"CodeRabbit","afk.merge.ci_aware":"false","afk.worktree_launches_pull_request":"true","afk.review_gate.enabled":"false","afk.review_gate.threshold":"complex","afk.release.channel":"stable","afk.claim_reaper.refresh_s":"300","afk.claim_reaper.stale_tolerance":"3","afk.claim_reaper.grace_s":"300","afk.claim_reaper.recent_commit_s":"2700","afk.worktree_pool.enabled":"false","afk.worktree_pool.max_size":"4","afk.worktree_pool.lease_ttl_s":"3600","afk.worktree_pool.min_idle_s":"1800","afk.companion.iteration_churn":"8","afk.companion.waiting_windows":"20","afk.companion.diff_drift_loc":"4000","afk.companion.min_progress_loc":"5","afk.notes_loop.enabled":"false","afk.notes_loop.max_iterations":"4","afk.notes_loop.inner_max_iterations":"0","afk.notes_loop.token_budget":"0","afk.notes_loop.wall_clock_s":"0","afk.landing.cascade_rebase":"true","dev.lock.primary-branch":"false","dev.triage.external_pr_surface.enabled":"false","dev.trunk":"main"},YM=["validate","simple","complex","think"],Mye=YM;Ypt=["low","medium","high","xhigh","max"],MAr=Ce.record(Ce.string()),Xd=class extends Error{constructor(t="malformed YAML"){super(t),this.name="MalformedConfigError"}};Kpt=e=>{try{return zpt(e,"utf8")}catch{return}},Zpt=e=>{process.stderr.write(`${e}
23
23
  `)};Xpt=1800});function C(e,t,r,n,o,i,s,a,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return r(t(e));case 4:return n(r(t(e)));case 5:return o(n(r(t(e))));case 6:return i(o(n(r(t(e)))));case 7:return s(i(o(n(r(t(e))))));case 8:return a(s(i(o(n(r(t(e)))))));case 9:return c(a(s(i(o(n(r(t(e))))))));default:{let u=arguments[0];for(let l=1;l<arguments.length;l++)u=arguments[l](u);return u}}}var KM,x,be,Yp,xa,Fi,DY,PC,di,oe=h(()=>{KM=e=>typeof e=="function",x=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):r=>t(r,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(r,n){return arguments.length>=2?t(r,n):function(o){return t(o,r)}};case 3:return function(r,n,o){return arguments.length>=3?t(r,n,o):function(i){return t(i,r,n)}};case 4:return function(r,n,o,i){return arguments.length>=4?t(r,n,o,i):function(s){return t(s,r,n,o)}};case 5:return function(r,n,o,i,s){return arguments.length>=5?t(r,n,o,i,s):function(a){return t(a,r,n,o,i)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}},be=e=>e,Yp=e=>()=>e,xa=Yp(!0),Fi=Yp(!1),DY=Yp(null),PC=Yp(void 0),di=PC});var vl,emt,tmt,QY,OY,Hye,ZM,Kp=h(()=>{oe();vl=e=>(t,r)=>t===r||e(t,r),emt=(e,t)=>e===t,tmt=()=>emt,QY=tmt(),OY=x(2,(e,t)=>vl((r,n)=>e(t(r),t(n)))),Hye=OY(QY,e=>e.getTime()),ZM=e=>vl((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})});var XM,eF,tF,NY=h(()=>{oe();XM=e=>x(3,(t,r,n)=>e(t,o=>({...o,[r]:n(o)}))),eF=e=>x(2,(t,r)=>e(t,n=>({[r]:n}))),tF=(e,t)=>x(3,(r,n,o)=>t(r,i=>e(o(i),s=>({...i,[n]:s}))))});var jye,vR,De,gn=h(()=>{jye="effect/GlobalValue",De=(e,t)=>(vR||(globalThis[jye]??=new Map,vR=globalThis[jye]),vR.has(e)||vR.set(e,t()),vR.get(e))});var Oo,Ts,Zp,Sg,jx,Xp,qye,Gye,RR,fi,ie,ef,qx,zye,rF,ou,MY,FY,at=h(()=>{oe();Oo=e=>typeof e=="string",Ts=e=>typeof e=="number",Zp=e=>typeof e=="boolean",Sg=e=>typeof e=="bigint",jx=e=>typeof e=="symbol",Xp=KM,qye=e=>e===void 0,Gye=e=>!1,RR=e=>typeof e=="object"&&e!==null,fi=e=>RR(e)||Xp(e),ie=x(2,(e,t)=>fi(e)&&t in e),ef=x(2,(e,t)=>ie(e,"_tag")&&e._tag===t),qx=e=>e==null,zye=e=>e!=null,rF=e=>e instanceof Date,ou=e=>typeof e=="string"||ie(e,Symbol.iterator),MY=e=>RR(e)&&!Array.isArray(e),FY=e=>ie(e,"then")&&Xp(e.then)});var Rl,LC=h(()=>{Rl=e=>`BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`});function umt(e,t,r,n,o){let i=(r>>>16)*(o&65535)>>>0,s=(r&65535)*(o>>>16)>>>0,a=(r&65535)*(o&65535)>>>0,c=(r>>>16)*(o>>>16)+((s>>>16)+(i>>>16))>>>0;s=s<<16>>>0,a=a+s>>>0,a>>>0<s>>>0&&(c=c+1>>>0),i=i<<16>>>0,a=a+i>>>0,a>>>0<i>>>0&&(c=c+1>>>0),c=c+Math.imul(r,n)>>>0,c=c+Math.imul(t,o)>>>0,e[0]=c,e[1]=a}function Vye(e,t,r,n,o){let i=t+n>>>0,s=r+o>>>0;s>>>0<r>>>0&&(i=i+1|0),e[0]=i,e[1]=s}function BR(e){if(typeof e=="object"&&e!==null&&UY in e)return e[UY]();throw new Error(Rl("yieldWrapGet"))}var PY,Yye,LY,Gx,Jye,nmt,omt,imt,smt,amt,cmt,nF,UY,tf,Ea,Kye,lmt,dmt,Wn,fmt,Zye,su=h(()=>{oe();gn();LC();at();PY=Symbol.for("effect/Gen/GenKind"),Yye=e=>fi(e)&&PY in e,LY=class{value;constructor(t){this.value=t}get _F(){return be}get _R(){return t=>t}get _O(){return t=>t}get _E(){return t=>t}[PY]=PY;[Symbol.iterator](){return new Gx(this)}},Gx=class e{self;called=!1;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(t){return{value:t,done:!0}}throw(t){throw t}[Symbol.iterator](){return new e(this.self)}},Jye=()=>function(){let e=arguments[0];for(let t=1;t<arguments.length;t++)e=arguments[t](e);return new LY(e)},nmt=335903614,omt=4150755663,imt=1481765933,smt=1284865837,amt=9007199254740992,cmt=134217728,nF=class{_state;constructor(t,r,n,o){return qx(r)&&qx(t)?(r=Math.random()*4294967295>>>0,t=0):qx(r)&&(r=t,t=0),qx(o)&&qx(n)?(o=this._state?this._state[3]:omt,n=this._state?this._state[2]:nmt):qx(o)&&(o=n,n=0),this._state=new Int32Array([0,0,n>>>0,((o||0)|1)>>>0]),this._next(),Vye(this._state,this._state[0],this._state[1],t>>>0,r>>>0),this._next(),this}getState(){return[this._state[0],this._state[1],this._state[2],this._state[3]]}setState(t){this._state[0]=t[0],this._state[1]=t[1],this._state[2]=t[2],this._state[3]=t[3]|1}integer(t){return Math.round(this.number()*Number.MAX_SAFE_INTEGER)%t}number(){let t=(this._next()&67108863)*1,r=(this._next()&134217727)*1;return(t*cmt+r)/amt}_next(){let t=this._state[0]>>>0,r=this._state[1]>>>0;umt(this._state,t,r,imt,smt),Vye(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let n=t>>>18,o=(r>>>18|t<<14)>>>0;n=(n^t)>>>0,o=(o^r)>>>0;let i=(o>>>27|n<<5)>>>0,s=t>>>27,a=(-s>>>0&31)>>>0;return(i>>>s|i<<a)>>>0}};UY=Symbol.for("effect/Utils/YieldWrap"),tf=class{#e;constructor(t){this.#e=t}[UY](){return this.#e}};Ea=De("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0})),Kye={effect_internal_function:e=>e()},lmt={effect_internal_function:e=>{try{return e()}finally{}}},dmt=Kye.effect_internal_function(()=>new Error().stack)?.includes("effect_internal_function")===!0,Wn=dmt?Kye.effect_internal_function:lmt.effect_internal_function,fmt=function*(){}.constructor,Zye=e=>fi(e)&&e.constructor===fmt});var HY,he,se,UC,we,oF,pmt,au,Mt,mmt,iF,xo,$e,or=h(()=>{oe();gn();at();su();HY=De(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),he=Symbol.for("effect/Hash"),se=e=>{if(Ea.enabled===!0)return 0;switch(typeof e){case"number":return au(e);case"bigint":return Mt(e.toString(10));case"boolean":return Mt(String(e));case"symbol":return Mt(String(e));case"string":return Mt(e);case"undefined":return Mt("undefined");case"function":case"object":return e===null?Mt("null"):e instanceof Date?Number.isNaN(e.getTime())?Mt("Invalid Date"):se(e.toISOString()):e instanceof URL?se(e.href):pmt(e)?e[he]():UC(e);default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},UC=e=>(HY.has(e)||HY.set(e,au(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),HY.get(e)),we=e=>t=>t*53^e,oF=e=>e&3221225471|e>>>1&1073741824,pmt=e=>ie(e,he),au=e=>{if(e!==e||e===1/0)return 0;let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return oF(t)},Mt=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return oF(t)},mmt=(e,t)=>{let r=12289;for(let n=0;n<t.length;n++)r^=C(Mt(t[n]),we(se(e[t[n]])));return oF(r)},iF=e=>mmt(e,Object.keys(e)),xo=e=>{let t=6151;for(let r=0;r<e.length;r++)t=C(t,we(se(e[r])));return oF(t)},$e=function(){if(arguments.length===1){let r=arguments[0];return function(n){return Object.defineProperty(r,he,{value(){return n},enumerable:!1}),n}}let e=arguments[0],t=arguments[1];return Object.defineProperty(e,he,{value(){return t},enumerable:!1}),t}});function ae(){return arguments.length===1?e=>sF(e,arguments[0]):sF(arguments[0],arguments[1])}function sF(e,t){if(e===t)return!0;let r=typeof e;if(r!==typeof t)return!1;if(r==="object"||r==="function"){if(e!==null&&t!==null){if($C(e)&&$C(t))return se(e)===se(t)&&e[me](t)?!0:Ea.enabled&&Ea.tester?Ea.tester(e,t):!1;if(e instanceof Date&&t instanceof Date){let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof URL&&t instanceof URL)return e.href===t.href}if(Ea.enabled){if(e===null||t===null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,o)=>sF(n,t[o]));if(Object.getPrototypeOf(e)===Object.prototype&&Object.getPrototypeOf(t)===Object.prototype){let n=Object.keys(e),o=Object.keys(t);if(n.length===o.length){for(let i of n)if(!(i in t&&sF(e[i],t[i])))return Ea.tester?Ea.tester(e,t):!1;return!0}}return Ea.tester?Ea.tester(e,t):!1}}return Ea.enabled&&Ea.tester?Ea.tester(e,t):!1}var me,$C,_R,pt=h(()=>{or();at();su();me=Symbol.for("effect/Equal");$C=e=>ie(e,me),_R=()=>ae});function Xye(e){try{return e.toISOString()}catch{return"Invalid Date"}}function hmt(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function Cg(e){return Oo(e)?JSON.stringify(e):String(e)}function rc(e,t){let r=t?.space??0,n=new WeakSet,o=r?Ts(r)?" ".repeat(r):r:"",i=u=>o.repeat(u),s=(u,l)=>{let d=u?.constructor;return d&&d!==Object.prototype.constructor&&d.name?`${d.name}(${l})`:l},a=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,l=0){if(Array.isArray(u)){if(n.has(u))return WY;if(n.add(u),!o||u.length<=1)return`[${u.map(f=>c(f,l)).join(",")}]`;let d=u.map(f=>c(f,l+1)).join(`,
24
24
  `+i(l+1));return`[
25
25
  ${i(l+1)}${d}
@@ -810,7 +810,7 @@ requeued to ready-for-agent${e.activeBlocker?` (cleared active blocker: ${e.acti
810
810
  `);let n;try{let i=await $t("git",["branch","--show-current"],{cwd:t});n=i.code===0&&i.stdout.trim()||void 0}catch{}let o=ihr(e)??(n?W4(n):void 0);return!o||!n?(process.stderr.write(`[afk] /ship alias: could not infer issue or branch.
811
811
  Run manually: red-skills-dev requeue #ISSUE --adopt-branch BRANCH --guidance 'reason'
812
812
  `),1):(process.stderr.write(`[afk] /ship alias: routing to requeue #${o} --adopt-branch ${n}
813
- `),H4([String(o),"--adopt-branch",n,"--guidance","Adopted via deprecated /ship alias (ADR 0081). Update guidance if needed."],t,r))}import{existsSync as Fhr,statSync as Phr}from"node:fs";import{join as cdt,basename as Lhr}from"node:path";function V4(e){let t={app:e,version:shr(lR("__RED_BUILD_VERSION__",()=>"2.13.0")??"0.0.0-dev"),gitSha:lR("__RED_BUILD_GIT_SHA__",()=>"ad0bea1325733c1d80ffcea50e9be670fb95e8d2")??"unknown",buildTime:lR("__RED_BUILD_TIME__",()=>"2026-07-08T21:20:18-03:00")??"unknown",bundleAsset:lR("__RED_BUNDLE_ASSET__",()=>"dev.bundle.min.mjs")??"unknown"},r=lR("__REDDB_SDK_VERSION__",()=>""),n=lR("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function shr(e){return e.startsWith("v")?e.slice(1):e}function Jlt(e){return`${e.app} ${e.version} ${e.gitSha}`}function lR(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}function Y4(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.floor(e/1e3)}k`:String(e)}function Klt(e){let t=(r,n)=>{let o=(Math.round(r*10)/10).toFixed(1);return`${o.endsWith(".0")?o.slice(0,-2):o}${n}`};return e>=1e9?t(e/1e9,"B"):e>=1e6?t(e/1e6,"M"):e>=1e3?t(e/1e3,"k"):String(e>0?e:0)}function Zlt(e){let t=e.toLowerCase();for(let r of["opus","sonnet","haiku","fable"])if(t.includes(r))return r;return e}function ahr(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let r=Math.floor(t/60);if(r<60)return`${r}m${t%60}s`;let n=Math.floor(r/60);return n<24?`${n}h${r%60}m`:`${Math.floor(n/24)}d${n%24}h`}function J4(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}h${n}m`:`${r}h`}function chr(e){let t=e.basename;if(e.branch){let r=e.branch;return r.length>28&&(r=`${r.slice(0,27)}\u2026`),`${t} (${r})`}return e.detachedSha?`${t} (detached ${e.detachedSha})`:t}function uhr(e){return!e||!e.model?null:e.effort?`${e.model}\xB7${e.effort}`:e.model}function lhr(e){if(!e)return null;let t=e.contextTokens;if(t===void 0||t===0)return null;let r=Y4(t);return e.contextPercent===void 0?r:`${r} ${Math.round(e.contextPercent)}%`}function dhr(e){if(!e||e.workers<=0)return[];let t=[],r=(i,s)=>{t.push({label:i,value:s,suffix:""})};if(e.workers>0&&r("wrk=",String(e.workers)),e.sourceCounts&&e.sourceCounts.length>0)for(let{origin:i,count:s}of e.sourceCounts)r(`${i}=`,String(s));let n=e.cacheAgeS!==void 0?` (${J4(e.cacheAgeS)})`:"";if(e.queue>0&&t.push({label:"rdy=",value:String(e.queue),suffix:n}),e.human>0){let i=n&&e.queue===0?n:"";t.push({label:"hmn=",value:String(e.human),suffix:i})}e.blocked>0&&r("blk=",String(e.blocked));let o=[];return e.added>0&&o.push(`+${e.added}`),e.removed>0&&o.push(`-${e.removed}`),o.length&&r("loc=",e.locIsPeak?`~${o.join(" ")}`:o.join(" ")),e.waiting!==void 0&&e.waiting>0&&r("wai=",String(e.waiting)),e.tokens!==void 0&&e.tokens>0&&r("tok=",Y4(e.tokens)),e.costUsd!==void 0&&e.costUsd>0&&r("usd=",e.costUsd.toFixed(2)),e.issues.forEach((i,s)=>{let a=e.stages?.[s],c=e.aliveMs?.[s],u=a?`\xB7${a}`:"";c!==void 0&&c>0&&(u+=`\xB7${ahr(c)}`),t.push({label:"#",value:String(i),suffix:u})}),t}function fhr(e){if(!e)return null;let t=[];return e.usage5h!==void 0&&t.push(`5h=${Math.round(e.usage5h)}%`),e.usage7d!==void 0&&t.push(`7d=${Math.round(e.usage7d)}%`),t.length?t.join(" "):null}function phr(e){if(!e)return null;let t=[],r=e.cacheAgeS!==void 0?` (${J4(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(`prs=${e.openPrs}${r}`),e.openIssues&&e.openIssues>0){let o=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(`iss=${e.openIssues}${o}`)}let n=[];return e.localAdded&&e.localAdded>0&&n.push(`+${e.localAdded}`),e.localRemoved&&e.localRemoved>0&&n.push(`-${e.localRemoved}`),n.length&&t.push(`loc=${n.join(" ")}`),t.length?t.join(" "):null}function mhr(e){let t=dhr(e);return t.length===0?null:t.map(r=>`${r.label}${r.value}${r.suffix}`).join(" ")}function Xlt(e){let t=[chr(e.project)],r=uhr(e.claude);r!==null&&t.push(r);let n=lhr(e.claude);n!==null&&t.push(n);let o=fhr(e.claude);o!==null&&t.push(o);let i=phr(e.repo);i!==null&&t.push(i);let s=mhr(e.afk);return s!==null&&t.push(s),t.join(" \xB7 ")}var hhr="\x1B[48;2;114;47;55m",ghr="\x1B[48;2;88;36;42m",edt="\x1B[49m",xC="\x1B[38;2;255;255;255m",tdt="\x1B[38;2;255;214;214m",rdt="\x1B[39m",Z4="\x1B[38;2;224;138;148m",K4="\x1B[38;2;201;150;158m",Ahr="\x1B[38;2;240;200;120m",ndt="\x1B[1m",odt="\x1B[22m",idt="\x1B[0m",yhr=28,xhr=" ",IAe=["workerId","run","org","iss","stage","elapsed","loc","tks","tls","rsn","txt"],Ehr=new Set(["requeue"]),bhr=e=>e.replace(/\x1b\[[0-9;]*m/g,"");function sdt(e){return bhr(e).length}function Shr(e,t){return e+" ".repeat(Math.max(0,t-sdt(e)))}var dR=(e,t)=>`${tdt}${e}=${rdt}${t}${Z4}`;function Chr(e,t){let r=[];return e&&e>0&&r.push(`+${e}`),t&&t>0&&r.push(`-${t}`),r.length?r.join(" "):null}function Ihr(e){let t="";if(e.branch){let n=e.branch.length>yhr?`${e.branch.slice(0,27)}\u2026`:e.branch;t=` ${K4}(${n})${xC}`}else e.detachedSha&&(t=` ${K4}(detached ${e.detachedSha})${xC}`);let r=e.version?` ${K4}v${e.version}${xC}`:"";return`${Ahr}\xBB${xC} ${ndt}${e.basename}${odt}${t}${r}`}function whr(e){return!e||!e.model?null:e.effort?`${e.model}${K4}\xB7${xC}${e.effort}`:e.model}function khr(e){if(!e||!e.contextTokens)return null;let t=Y4(e.contextTokens),r=e.contextPercent===void 0?t:`${t} ${Math.round(e.contextPercent)}%`;return dR("ctx",r)}function vhr(e){if(!e)return[];let t=[];return e.usage5h!==void 0&&t.push(dR("5h",`${Math.round(e.usage5h)}%`)),e.usage7d!==void 0&&t.push(dR("7d",`${Math.round(e.usage7d)}%`)),t}function Rhr(e){if(!e)return[];let t=[],r=e.cacheAgeS!==void 0?` (${J4(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(dR("prs",String(e.openPrs))+r),e.openIssues&&e.openIssues>0){let n=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(dR("iss",String(e.openIssues))+n)}return t}function Bhr(e){if(!e)return[];let t=Chr(e.localAdded,e.localRemoved);return t?[dR("loc",t)]:[]}function _hr(e,t,r){let n=`${ghr}${xC} ${Ihr(e)} `,o=whr(t);o!==null&&(n+=`${hhr}${xC} ${o} `),n+=`${edt}${Z4}`;let i=[khr(t),...vhr(t),...Rhr(r),...Bhr(r)].filter(s=>s!==null);return i.length&&(n+=` ${i.join(" ")}`),`${n}${idt}`}function Thr(e,t){let r=ilt(e,t),n=[r.runner,r.model?Zlt(r.model):void 0,r.effort].filter(i=>!!i).join(" "),o=r.origin!==void 0&&Ehr.has(r.origin);return{workerId:r.workerId,run:`run=${n}`,org:`org=${r.origin||"afk"}`,iss:r.issue===null?"":`iss=${String(r.issue)}`,stage:r.issue===null?"":r.stage,elapsed:r.elapsed,loc:o?"":`loc=${L4(r.added,r.removed)}`,tks:o?"":`tks=${Klt(r.tokens)}`,tls:o?"":`tls=${String(r.tools)}`,rsn:o?"":`rsn=${String(r.reasoning)}`,txt:o?"":`txt=${String(r.text)}`}}function Dhr(e){let t=Object.fromEntries(IAe.map(r=>[r,0]));for(let r of e)for(let n of IAe)t[n]=Math.max(t[n],sdt(r[n]));return t}function Qhr(e,t){if(e==="workerId")return`${ndt}${t}${odt}`;let r=t.indexOf("=");return r>0?`${tdt}${t.slice(0,r+1)}${rdt}${t.slice(r+1)}${Z4}`:t}function Ohr(e,t){let r=IAe.map(n=>Qhr(n,Shr(e[n],t[n])));return`${edt}${Z4}${r.join(xhr)}${idt}`}function Nhr(e,t){let r=e.map(o=>Thr(o,t)),n=Dhr(r);return r.map(o=>Ohr(o,n))}function Mhr(e,t={}){let r=[_hr(e.project,e.claude,e.repo)],n=t.now??0;return r.push(...Nhr(t.workers??[],n)),r.join(`
813
+ `),H4([String(o),"--adopt-branch",n,"--guidance","Adopted via deprecated /ship alias (ADR 0081). Update guidance if needed."],t,r))}import{existsSync as Fhr,statSync as Phr}from"node:fs";import{join as cdt,basename as Lhr}from"node:path";function V4(e){let t={app:e,version:shr(lR("__RED_BUILD_VERSION__",()=>"2.14.0")??"0.0.0-dev"),gitSha:lR("__RED_BUILD_GIT_SHA__",()=>"f0fb96ef790664a52a2e9dc9824113bec1b8d5ee")??"unknown",buildTime:lR("__RED_BUILD_TIME__",()=>"2026-07-08T21:57:43-03:00")??"unknown",bundleAsset:lR("__RED_BUNDLE_ASSET__",()=>"dev.bundle.min.mjs")??"unknown"},r=lR("__REDDB_SDK_VERSION__",()=>""),n=lR("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function shr(e){return e.startsWith("v")?e.slice(1):e}function Jlt(e){return`${e.app} ${e.version} ${e.gitSha}`}function lR(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}function Y4(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.floor(e/1e3)}k`:String(e)}function Klt(e){let t=(r,n)=>{let o=(Math.round(r*10)/10).toFixed(1);return`${o.endsWith(".0")?o.slice(0,-2):o}${n}`};return e>=1e9?t(e/1e9,"B"):e>=1e6?t(e/1e6,"M"):e>=1e3?t(e/1e3,"k"):String(e>0?e:0)}function Zlt(e){let t=e.toLowerCase();for(let r of["opus","sonnet","haiku","fable"])if(t.includes(r))return r;return e}function ahr(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let r=Math.floor(t/60);if(r<60)return`${r}m${t%60}s`;let n=Math.floor(r/60);return n<24?`${n}h${r%60}m`:`${Math.floor(n/24)}d${n%24}h`}function J4(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}h${n}m`:`${r}h`}function chr(e){let t=e.basename;if(e.branch){let r=e.branch;return r.length>28&&(r=`${r.slice(0,27)}\u2026`),`${t} (${r})`}return e.detachedSha?`${t} (detached ${e.detachedSha})`:t}function uhr(e){return!e||!e.model?null:e.effort?`${e.model}\xB7${e.effort}`:e.model}function lhr(e){if(!e)return null;let t=e.contextTokens;if(t===void 0||t===0)return null;let r=Y4(t);return e.contextPercent===void 0?r:`${r} ${Math.round(e.contextPercent)}%`}function dhr(e){if(!e||e.workers<=0)return[];let t=[],r=(i,s)=>{t.push({label:i,value:s,suffix:""})};if(e.workers>0&&r("wrk=",String(e.workers)),e.sourceCounts&&e.sourceCounts.length>0)for(let{origin:i,count:s}of e.sourceCounts)r(`${i}=`,String(s));let n=e.cacheAgeS!==void 0?` (${J4(e.cacheAgeS)})`:"";if(e.queue>0&&t.push({label:"rdy=",value:String(e.queue),suffix:n}),e.human>0){let i=n&&e.queue===0?n:"";t.push({label:"hmn=",value:String(e.human),suffix:i})}e.blocked>0&&r("blk=",String(e.blocked));let o=[];return e.added>0&&o.push(`+${e.added}`),e.removed>0&&o.push(`-${e.removed}`),o.length&&r("loc=",e.locIsPeak?`~${o.join(" ")}`:o.join(" ")),e.waiting!==void 0&&e.waiting>0&&r("wai=",String(e.waiting)),e.tokens!==void 0&&e.tokens>0&&r("tok=",Y4(e.tokens)),e.costUsd!==void 0&&e.costUsd>0&&r("usd=",e.costUsd.toFixed(2)),e.issues.forEach((i,s)=>{let a=e.stages?.[s],c=e.aliveMs?.[s],u=a?`\xB7${a}`:"";c!==void 0&&c>0&&(u+=`\xB7${ahr(c)}`),t.push({label:"#",value:String(i),suffix:u})}),t}function fhr(e){if(!e)return null;let t=[];return e.usage5h!==void 0&&t.push(`5h=${Math.round(e.usage5h)}%`),e.usage7d!==void 0&&t.push(`7d=${Math.round(e.usage7d)}%`),t.length?t.join(" "):null}function phr(e){if(!e)return null;let t=[],r=e.cacheAgeS!==void 0?` (${J4(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(`prs=${e.openPrs}${r}`),e.openIssues&&e.openIssues>0){let o=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(`iss=${e.openIssues}${o}`)}let n=[];return e.localAdded&&e.localAdded>0&&n.push(`+${e.localAdded}`),e.localRemoved&&e.localRemoved>0&&n.push(`-${e.localRemoved}`),n.length&&t.push(`loc=${n.join(" ")}`),t.length?t.join(" "):null}function mhr(e){let t=dhr(e);return t.length===0?null:t.map(r=>`${r.label}${r.value}${r.suffix}`).join(" ")}function Xlt(e){let t=[chr(e.project)],r=uhr(e.claude);r!==null&&t.push(r);let n=lhr(e.claude);n!==null&&t.push(n);let o=fhr(e.claude);o!==null&&t.push(o);let i=phr(e.repo);i!==null&&t.push(i);let s=mhr(e.afk);return s!==null&&t.push(s),t.join(" \xB7 ")}var hhr="\x1B[48;2;114;47;55m",ghr="\x1B[48;2;88;36;42m",edt="\x1B[49m",xC="\x1B[38;2;255;255;255m",tdt="\x1B[38;2;255;214;214m",rdt="\x1B[39m",Z4="\x1B[38;2;224;138;148m",K4="\x1B[38;2;201;150;158m",Ahr="\x1B[38;2;240;200;120m",ndt="\x1B[1m",odt="\x1B[22m",idt="\x1B[0m",yhr=28,xhr=" ",IAe=["workerId","run","org","iss","stage","elapsed","loc","tks","tls","rsn","txt"],Ehr=new Set(["requeue"]),bhr=e=>e.replace(/\x1b\[[0-9;]*m/g,"");function sdt(e){return bhr(e).length}function Shr(e,t){return e+" ".repeat(Math.max(0,t-sdt(e)))}var dR=(e,t)=>`${tdt}${e}=${rdt}${t}${Z4}`;function Chr(e,t){let r=[];return e&&e>0&&r.push(`+${e}`),t&&t>0&&r.push(`-${t}`),r.length?r.join(" "):null}function Ihr(e){let t="";if(e.branch){let n=e.branch.length>yhr?`${e.branch.slice(0,27)}\u2026`:e.branch;t=` ${K4}(${n})${xC}`}else e.detachedSha&&(t=` ${K4}(detached ${e.detachedSha})${xC}`);let r=e.version?` ${K4}v${e.version}${xC}`:"";return`${Ahr}\xBB${xC} ${ndt}${e.basename}${odt}${t}${r}`}function whr(e){return!e||!e.model?null:e.effort?`${e.model}${K4}\xB7${xC}${e.effort}`:e.model}function khr(e){if(!e||!e.contextTokens)return null;let t=Y4(e.contextTokens),r=e.contextPercent===void 0?t:`${t} ${Math.round(e.contextPercent)}%`;return dR("ctx",r)}function vhr(e){if(!e)return[];let t=[];return e.usage5h!==void 0&&t.push(dR("5h",`${Math.round(e.usage5h)}%`)),e.usage7d!==void 0&&t.push(dR("7d",`${Math.round(e.usage7d)}%`)),t}function Rhr(e){if(!e)return[];let t=[],r=e.cacheAgeS!==void 0?` (${J4(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(dR("prs",String(e.openPrs))+r),e.openIssues&&e.openIssues>0){let n=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(dR("iss",String(e.openIssues))+n)}return t}function Bhr(e){if(!e)return[];let t=Chr(e.localAdded,e.localRemoved);return t?[dR("loc",t)]:[]}function _hr(e,t,r){let n=`${ghr}${xC} ${Ihr(e)} `,o=whr(t);o!==null&&(n+=`${hhr}${xC} ${o} `),n+=`${edt}${Z4}`;let i=[khr(t),...vhr(t),...Rhr(r),...Bhr(r)].filter(s=>s!==null);return i.length&&(n+=` ${i.join(" ")}`),`${n}${idt}`}function Thr(e,t){let r=ilt(e,t),n=[r.runner,r.model?Zlt(r.model):void 0,r.effort].filter(i=>!!i).join(" "),o=r.origin!==void 0&&Ehr.has(r.origin);return{workerId:r.workerId,run:`run=${n}`,org:`org=${r.origin||"afk"}`,iss:r.issue===null?"":`iss=${String(r.issue)}`,stage:r.issue===null?"":r.stage,elapsed:r.elapsed,loc:o?"":`loc=${L4(r.added,r.removed)}`,tks:o?"":`tks=${Klt(r.tokens)}`,tls:o?"":`tls=${String(r.tools)}`,rsn:o?"":`rsn=${String(r.reasoning)}`,txt:o?"":`txt=${String(r.text)}`}}function Dhr(e){let t=Object.fromEntries(IAe.map(r=>[r,0]));for(let r of e)for(let n of IAe)t[n]=Math.max(t[n],sdt(r[n]));return t}function Qhr(e,t){if(e==="workerId")return`${ndt}${t}${odt}`;let r=t.indexOf("=");return r>0?`${tdt}${t.slice(0,r+1)}${rdt}${t.slice(r+1)}${Z4}`:t}function Ohr(e,t){let r=IAe.map(n=>Qhr(n,Shr(e[n],t[n])));return`${edt}${Z4}${r.join(xhr)}${idt}`}function Nhr(e,t){let r=e.map(o=>Thr(o,t)),n=Dhr(r);return r.map(o=>Ohr(o,n))}function Mhr(e,t={}){let r=[_hr(e.project,e.claude,e.repo)],n=t.now??0;return r.push(...Nhr(t.workers??[],n)),r.join(`
814
814
  `)}function adt(e,t,r={}){return t?Mhr(e,r):Xlt(e)}Qo();function Uhr(e){return new Promise(t=>{if(e.isTTY){t("");return}let r="",n=!1,o=()=>{n||(n=!0,t(r))};e.setEncoding("utf8"),e.on("data",i=>{r+=i}),e.on("end",o),e.on("error",o),e.on("close",o)})}function $hr(e){if(!e.trim())return{};try{let t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{}}catch{return{}}}function Hhr(e){try{return Phr(e).isDirectory()}catch{return!1}}function Whr(e,t,r){if(e&&Hhr(e))return e;let n=t.workspace?.project_dir||t.workspace?.current_dir||t.cwd;return n||r}function jhr(e){let t=cdt(e,".red","config.yaml");if(!Fhr(t))return!0;let r=br(t,{warn:()=>{}});return!(rt(r,"statusline")==="false"||rt(r,"afk.statusline")==="false")}async function qhr(e){let t={cwd:e},r=V4("dev").version,n={basename:Lhr(e),version:r},o=await HN(t);if(o)return{...n,branch:o};let i=await eg(t);return i?{...n,detachedSha:i}:n}function Ghr(e){let t=e.model?.display_name,r=e.effort?.level,n=e.context_window?.total_input_tokens,o=e.context_window?.used_percentage,i=e.rate_limits?.five_hour?.used_percentage,s=e.rate_limits?.seven_day?.used_percentage;if(!(t===void 0&&n===void 0&&i===void 0&&s===void 0))return{model:t||void 0,effort:r||void 0,contextTokens:n,contextPercent:o,usage5h:i,usage7d:s}}async function udt(e,t=process.cwd(),r=process.stdout,n=process.stdin){if(e.includes("--legend"))return r.write(`${U4()}
815
815
  `),0;let o=e[0],i=await Uhr(n),s=$hr(i),a=Whr(o,s,t);if(!jhr(a))return 0;let c=await qhr(a),u=Ghr(s),l={root:a,repo:qv(a),remote:"origin"},d=br(cdt(a,".red","config.yaml"),{warn:()=>{}}),f=YV(process.env,I=>rt(d,I)),[p,m,g]=await Promise.all([pst(l,f),dst(l,f).then(I=>I??void 0),fst(l)]),A=!process.env.NO_COLOR,E=Number.parseInt(process.env.COLUMNS??"",10),y=Math.floor(Date.now()/1e3),b=adt({project:c,claude:u,repo:p,afk:m},A,{columns:Number.isFinite(E)&&E>0?E:void 0,workers:g,now:y});return r.write(`${b}
816
816
  `),0}async function ldt(e,t=process.cwd()){let r=e[0]??t,n="",o="";for(let i=1;i<e.length;i+=1){let s=e[i];s==="--repo"?n=e[++i]??"":s==="--lock"&&(o=e[++i]??"")}return await lst(r,n||qv(r),o||void 0),0}RC();import{spawn as wdt}from"node:child_process";import{existsSync as kAe,openSync as vdt,closeSync as tgr,writeFileSync as Rdt,writeSync as rgr,rmSync as vAe,renameSync as ngr}from"node:fs";import{join as EC}from"node:path";import{existsSync as zhr,readdirSync as IM,readFileSync as X4,statSync as mdt}from"node:fs";import{join as is}from"node:path";$d();function Vhr(e,t){return is(e,`afk-supervisor-slot-${t}.log`)}function Yhr(e){let t;try{t=X4(e,"utf8")}catch{return[]}let r=[],n=new Set;for(let o of t.split(`
@@ -6515,7 +6515,7 @@ Usage:
6515
6515
  ${r} archive --candidate <json> [--root <dir>] [--archive-dir <rel>]
6516
6516
  ${r} restore <name> [--root <dir>] [--archive-dir <rel>]`}function nL(r){return ygr(typeof r.root=="string"?r.root:process.cwd())}function Dct(r){return typeof r["archive-dir"]=="string"?r["archive-dir"]:void 0}async function YW(r){let s=await Mu(r);return s?s.mode!=="graph"?{ok:!1,message:`curate: skill telemetry needs graph mode (this project is "${s.mode}") \u2014 run \`${_De}\``}:uh(s)?{ok:!0}:{ok:!1,message:`curate: skill telemetry is not enabled here \u2014 run \`${_De}\``}:{ok:!1,message:`curate: memory is not initialized here \u2014 run \`${_De}\``}}function bgr(){let r=hgr(vgr(import.meta.url));return r.includes("dist/curate-skill")||r.endsWith("dist/curate-skill")?Ect(r,"..","cli.js"):Ect(r,"..","cli.ts")}async function Sgr(r,s){let l=["curate","skills","--json"];s!==void 0&&l.push("--stale-days",String(s));let f=bgr(),v=f.endsWith(".ts")?Cct(process.execPath,["--import","tsx",f,...l,"--root",r],{encoding:"utf8"}):Cct(process.execPath,[f,...l,"--root",r],{encoding:"utf8"}),T=v.status??1;if(T!==0)throw new Error(`memory curate skills exited ${T}`);return kct(v.stdout??"")}function xgr(r){return typeof r.flags["stale-days"]=="string"?Number(r.flags["stale-days"]):void 0}async function Act(r,s){return(s.loadCuratorReport??Sgr)(nL(r.flags),xgr(r))}async function kgr(r){let s=nL(r.flags),l=await YW(s);return l.ok?(console.log("curate: skill telemetry is enabled \u2014 ready to curate"),0):(console.error(l.message),2)}async function wgr(r,s){let l=nL(r.flags),f=await YW(l);if(!f.ok)return console.error(f.message),2;let _;try{_=await Act(r,s)}catch(B){return console.error(`curate: ${B.message}`),1}let{candidates:v,byCategory:T,filtered:N}=fDe(_);return console.log(JSON.stringify({candidates:v,byCategory:T,filtered:N,totals:{totalSkills:_.totalSkills,curatableSkills:_.curatableSkills,readOnlySkills:_.readOnlySkills}},null,2)),0}async function Tgr(r,s){let l=nL(r.flags),f=await YW(l);if(!f.ok)return console.error(f.message),2;let _;try{_=await Act(r,s)}catch(B){return console.error(`curate: ${B.message}`),1}let{byCategory:v}=fDe(_);if(pDe(v)===0)return console.error("curate: no candidates \u2014 no issue filed"),0;let T=typeof r.flags.label=="string"?r.flags.label:void 0,N=await Tct({byCategory:v,totals:{totalSkills:_.totalSkills,curatableSkills:_.curatableSkills,readOnlySkills:_.readOnlySkills},generatedAt:_.generatedAt},{cwd:l,label:T});return console.log(`curate: filed background issue \u2014 ${N.output||N.title}`),0}async function Cgr(r){let s=nL(r.flags),l=await YW(s);if(!l.ok)return console.error(l.message),2;let f=r.flags.candidate;if(typeof f!="string")return console.error("curate archive: --candidate <json> is required"),2;let _;try{_=JSON.parse(f)}catch(T){return console.error(`curate archive: invalid --candidate JSON: ${T.message}`),2}let v=await Sct(_,{rootDir:s,archiveDir:Dct(r.flags)});return v.ok?(console.log(`curate: archived "${v.receipt.name}" \u2192 ${v.receipt.archiveRoot} (${v.receipt.files.length} file(s), manifest at ${v.receipt.manifestPath})`),0):(console.error(`curate archive: refused \u2014 ${v.rejection.reason}: ${v.rejection.detail}`),3)}async function Egr(r){let s=nL(r.flags),l=await YW(s);if(!l.ok)return console.error(l.message),2;let f=r.positional[0];if(!f)return console.error("curate restore: skill name is required"),2;let _=await xct(f,{rootDir:s,archiveDir:Dct(r.flags)});return console.log(`curate: restored "${_.name}" \u2192 ${_.restoredRoot} (${_.files.length} file(s) hash-verified)`),0}async function Nct(r,s={}){switch(r.command){case"check":return kgr(r);case"list":return wgr(r,s);case"background":return Tgr(r,s);case"archive":return Cgr(r);case"restore":return Egr(r);case void 0:case"--help":case"-h":return console.log(Pct(s.usageCommand)),0;default:return console.error(`unknown curate subcommand: ${r.command}
6517
6517
 
6518
- ${Pct(s.usageCommand)}`),2}}function Ict(r){let s={app:r,version:Pgr(iL("__RED_BUILD_VERSION__",()=>"2.13.0")??"0.0.0-dev"),gitSha:iL("__RED_BUILD_GIT_SHA__",()=>"ad0bea1325733c1d80ffcea50e9be670fb95e8d2")??"unknown",buildTime:iL("__RED_BUILD_TIME__",()=>"2026-07-08T21:20:18-03:00")??"unknown",bundleAsset:iL("__RED_BUNDLE_ASSET__",()=>"memory.bundle.min.mjs")??"unknown"},l=iL("__REDDB_SDK_VERSION__",()=>"1.7.0"),f=iL("__REDDB_BINARY_TAG__",()=>"v1.7.0");return l&&(s.reddbSdkVersion=l),f&&(s.reddbBinaryTag=f),s}function Pgr(r){return r.startsWith("v")?r.slice(1):r}function Rct(r){return`${r.app} ${r.version} ${r.gitSha}`}function iL(r,s){try{let l=s();return typeof l=="string"&&l.length>0?l:void 0}catch{return process.env[r.replace(/^__|__$/g,"")]}}var Oct=`memory \u2014 governed operational memory for code agents
6518
+ ${Pct(s.usageCommand)}`),2}}function Ict(r){let s={app:r,version:Pgr(iL("__RED_BUILD_VERSION__",()=>"2.14.0")??"0.0.0-dev"),gitSha:iL("__RED_BUILD_GIT_SHA__",()=>"f0fb96ef790664a52a2e9dc9824113bec1b8d5ee")??"unknown",buildTime:iL("__RED_BUILD_TIME__",()=>"2026-07-08T21:57:43-03:00")??"unknown",bundleAsset:iL("__RED_BUNDLE_ASSET__",()=>"memory.bundle.min.mjs")??"unknown"},l=iL("__REDDB_SDK_VERSION__",()=>"1.7.0"),f=iL("__REDDB_BINARY_TAG__",()=>"v1.7.0");return l&&(s.reddbSdkVersion=l),f&&(s.reddbBinaryTag=f),s}function Pgr(r){return r.startsWith("v")?r.slice(1):r}function Rct(r){return`${r.app} ${r.version} ${r.gitSha}`}function iL(r,s){try{let l=s();return typeof l=="string"&&l.length>0?l:void 0}catch{return process.env[r.replace(/^__|__$/g,"")]}}var Oct=`memory \u2014 governed operational memory for code agents
6519
6519
 
6520
6520
  Common workflows:
6521
6521
  remember one fact memory store "Decision: ..."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reddb-io/red-skills",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "RedSkills plugin runtime bundles (dev, memory, brain) distributed over npm — the v2 client transport (ADR 0091). Carries the platform-independent JS bundles inside the tarball plus thin bin shims; no postinstall download.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",