agent-afk 3.56.4 → 3.56.5

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +2 -2
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -2065,7 +2065,7 @@ ${u}`}function op(e,t){let n=VS[t.status];e.out.line(` ${n} ${p.bold(t.jobId)}
2065
2065
  return "no"
2066
2066
  end try
2067
2067
  `;return new Promise(r=>{let o=gk("osascript",["-e",n],{stdio:["ignore","pipe","pipe"]}),s="",i="";o.stdout?.on("data",a=>{s+=a.toString("utf8")}),o.stderr?.on("data",a=>{i+=a.toString("utf8")}),o.on("error",()=>r({ok:!1,exitCode:null,stderr:i})),o.on("close",a=>{r({ok:a===0&&s.trim()==="ok",exitCode:a,stderr:i})})})}function XF(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function ZF(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.length>=4&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56?"image/gif":e.length>=12&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":null}var wk=["Stalking","Shadowing","Tailing","Casing","Sleuthing","Investigating","Deducing","Interrogating","Profiling","Canvassing","Prowling","Lurking","Scanning","Probing","Inspecting","Querying","Invoking","Parsing","Validating","Resolving","Compiling","Executing","Hunting","Sweeping","Tracing","Tracking","Triangulating","Decoding","Decrypting","Intercepting","Hacking","Bugging","Wiretapping","Dispatching","Deploying","Patching","Hooking","Unmasking","Cornering","Striking","Surveilling","Scouting"];function fp(){return wk[Math.floor(Math.random()*wk.length)]}K();var QF=[{id:"kbd:ctrl-b",text:"Ctrl+B during a turn detaches it to the background so you can keep typing \u2014 find it later with /tasks.",source:"static"},{id:"kbd:shift-tab",text:"Shift+Tab toggles plan mode (no file writes) without leaving the prompt.",source:"static"},{id:"kbd:ctrl-c",text:"Ctrl+C interrupts the current turn; press it twice in a row to exit the REPL.",source:"static"},{id:"kbd:at-path",text:"Type @ in the prompt to autocomplete a file path and attach its contents to your turn.",source:"static"},{id:"kbd:cmd-v",text:"Paste an image with Cmd+V (macOS) or Ctrl+V \u2014 clipboard images attach automatically.",source:"static"},{id:"env:tips-opt-out",text:"Set AFK_SPINNER_TIPS=0 to silence these loading-screen tips.",source:"static"}];function eN(){let e=[];for(let t of Ze())t.hint&&(t.name.includes(":")||e.push({id:`cmd:${t.name}`,text:`${t.name} \u2014 ${t.hint}`,source:"command"}));return e}function tN(e){let t=[];for(let n of mt()){let r=`cmd:/${n}`;if(e.has(r))continue;let o;try{o=je(n)}catch{continue}o.whenToUse&&t.push({id:`skill:${n}`,text:`/${n} \u2014 ${o.whenToUse}`,source:"skill"})}return t}function vk(){if(v.AFK_SPINNER_TIPS==="0")return[];let e=eN(),t=new Set(e.map(r=>r.id)),n=tN(t);return[...QF,...e,...n]}var Sk=new Set,kk=new Map;function Tk(e,t){if(e.length===0)return null;let n=t.now??Date.now(),r=t.warmupMs??1500;if(n-t.startedAt<r)return null;let o=t.rotateMs??7e3,s=Math.floor((n-t.startedAt)/o),i=`${t.startedAt}:${s}`,a=kk.get(i);if(a)return a;let l=null,c=e.filter(u=>!Sk.has(u.id));if(c.length>0){let u=(s%c.length+c.length)%c.length;l=c[u]??null}else{let u=(s%e.length+e.length)%e.length;l=e[u]??null}return l&&(Sk.add(l.id),kk.set(i,l)),l}var gp=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],nN=5e3;function Ek(e){let t=Date.now()-e;if(t<nN)return"";let n=Math.floor(t/1e3);if(n<60)return p.dim(` ${n}s`);let r=Math.floor(n/60),o=n%60;return p.dim(` ${r}m${o.toString().padStart(2,"0")}s`)}function xk(e,t){let n=" \u{1F4A1} ",r=Math.max(8,t-n.length-1),o=e.length>r?e.slice(0,r-1)+"\u2026":e;return p.dim(n+o)}var wl=class{state=null;interval=null;captureMode;onTick;constructor(t){this.captureMode=t.captureMode,this.onTick=t.onTick}set(t){if(!t.enabled){this.interval&&(clearInterval(this.interval),this.interval=null),this.state&&(this.state=null,this.onTick());return}if(this.captureMode||this.state)return;let n=t.rotateVerbEveryMs??3500,r=Date.now();this.state={frameIndex:0,verb:fp(),nextVerbRotateAt:r+n,startedAt:r,tipPool:vk(),currentTip:null},this.interval=setInterval(()=>this.tick(n),80),this.onTick()}dispose(){this.interval&&(clearInterval(this.interval),this.interval=null),this.state=null}renderSpinnerRow(){return this.state?p.meta(`${gp[this.state.frameIndex]} ${this.state.verb}...`)+Ek(this.state.startedAt):null}renderTipRow(t){return this.state?.currentTip?xk(this.state.currentTip.text,t):null}tick(t){if(!this.state)return;this.state.frameIndex=(this.state.frameIndex+1)%gp.length;let n=Date.now();n>=this.state.nextVerbRotateAt&&(this.state.verb=fp(),this.state.nextVerbRotateAt=n+t),this.state.currentTip=Tk(this.state.tipPool,{startedAt:this.state.startedAt,now:n}),this.onTick()}};var sN=5,iN=1e3,aN=/\[Pasted text #([0-9a-f]+) \+\d+ (?:lines|chars)\]/g;function lN(e,t){let n=t.match(/\n/g),r=n?n.length:0;return r>0?`[Pasted text #${e} +${r+1} lines]`:`[Pasted text #${e} +${t.length} chars]`}var Ro=class e{stdout;stdin;onCancel;onSoftStop;softStopped=!1;onBackground;onShiftTab;promptTextFn;history;autocompleteState;formatInputBuffer;scrollRegion;anchorRow;declaredAnchorRow;onSubmit;attachments=[];pasting=!1;pasteStartBufferLen=0;pasteStartCursor=0;pasteRegistry=new Map;clipboardInFlight=!1;clipboardFailureMsg=null;inputMode="streaming";pickerController=null;pickerSavedMode="streaming";armed=!1;suspended=!1;canceled=!1;backgrounded=!1;wasRaw=!1;logUpdate=null;overlay="";input=j.seed("");queued=!1;handleKeypress=null;resizeUnsub=null;resizeImmediateUnsub=null;spinnerController;committing=!1;hasCommitted=!1;debugCompositor=!!v.AFK_DEBUG_COMPOSITOR;debugLog(t,n={}){if(!this.debugCompositor)return;let r=process.hrtime.bigint(),o=Object.entries(n).map(([s,i])=>{let a=typeof i=="string"?JSON.stringify(i.length>60?i.slice(0,57)+"...":i):String(i);return`${s}=${a}`}).join(" ");process.stderr.write(`[compositor] t=${r} ${t}${o?" "+o:""}
2068
- `)}static MAX_DROPDOWN_ROWS=6;constructor(t){this.stdout=t.stdout,this.stdin=t.stdin,this.onCancel=t.onCancel,this.onSoftStop=t.onSoftStop,this.onBackground=t.onBackground,this.onShiftTab=t.onShiftTab;let n=t.promptText;if(typeof n=="function")this.promptTextFn=n;else if(typeof n=="string")this.promptTextFn=()=>n;else{let r=" "+p.dim("\u23AF")+" ";this.promptTextFn=()=>r}this.history=t.history,this.autocompleteState=t.autocompleteState,this.formatInputBuffer=t.formatInputBuffer,this.scrollRegion=t.scrollRegion,this.spinnerController=new wl({captureMode:t.captureMode??!1,onTick:()=>this.repaint()}),this.onSubmit=t.onSubmit,this.anchorRow=t.anchorRow,this.declaredAnchorRow=t.anchorRow}isArmed(){return this.armed}setAnchorRow(t){this.anchorRow=t,this.declaredAnchorRow=t}suspendInput(){if(!(!this.armed||this.suspended)){if(this.logUpdate)try{this.logUpdate.clear(this.scrollRegion?.getExtraRows()??0),this.logUpdate.done()}catch{}this.handleKeypress&&this.stdin.removeListener("keypress",this.handleKeypress);try{this.stdin.setRawMode(!1)}catch{}this.suspended=!0}}resumeInput(){if(!(!this.armed||!this.suspended)){try{this.stdin.setRawMode(!0)}catch{}this.handleKeypress&&this.stdin.on("keypress",this.handleKeypress),this.suspended=!1,this.repaint()}}setOnSubmit(t){this.onSubmit=t??void 0}setOnCancel(t){this.onCancel=t??void 0}getOnCancel(){return this.onCancel}setOnSoftStop(t){this.onSoftStop=t??void 0}setOnBackground(t){this.onBackground=t??void 0}setOnShiftTab(t){this.onShiftTab=t??void 0}enterPickerMode(t){if(this.pickerController)throw new Error("enterPickerMode: a picker is already active; call exitPickerMode first");this.pickerSavedMode=this.inputMode,this.pickerController=t,this.inputMode="picker",this.autocompleteState?.reset(),this.repaint()}exitPickerMode(){this.pickerController&&(this.pickerController=null,this.inputMode=this.pickerSavedMode,this.repaint())}repaintPicker(){this.pickerController&&this.repaint()}setInputMode(t){let n=this.inputMode;if(this.inputMode=t,n==="idle"&&t==="streaming"){this.canceled=!1,this.backgrounded=!1,this.softStopped=!1,this.autocompleteState?.reset(),this.repaint();return}if(t==="idle"&&this.queued&&this.onSubmit){let r=this.input.buffer,o=this.expandPastePlaceholders(r),s=[...this.attachments],i=this.onSubmit;this.queued=!1,this.input=j.seed(""),this.attachments=[],this.pasteRegistry.clear(),this.repaint(),i(o===r?{text:o,attachments:s}:{text:o,displayText:r,attachments:s});return}n!==t&&this.repaint()}getInputMode(){return this.inputMode}async arm(){if(this.armed)throw new Error("TerminalCompositor: arm() called while already armed");if(!(!this.stdout.isTTY||!this.stdin.isTTY)){this.anchorRow=this.declaredAnchorRow,this.logUpdate||(this.logUpdate=new fl(this.stdout)),this.wasRaw=this.stdin.isRaw??!1;try{this.stdin.setRawMode(!0)}catch{this.logUpdate=null,this.wasRaw=!1;return}try{this.stdout.write("\x1B[?2004h")}catch{}this.stdin.resume(),rN(this.stdin),this.handleKeypress=(t,n)=>this.dispatchKey(t,n),this.stdin.on("keypress",this.handleKeypress),this.armed=!0,this.canceled=!1,this.resizeUnsub=qe.subscribe(()=>{this.armed&&this.repaint()}),this.resizeImmediateUnsub=qe.subscribeImmediate(()=>{this.armed&&this.logUpdate?.resetGeometry?.()}),this.repaint()}}disarm(){if(this.spinnerController.dispose(),!this.armed){this.resetState();return}if(this.handleKeypress&&(this.stdin.removeListener("keypress",this.handleKeypress),this.handleKeypress=null),this.resizeUnsub&&(this.resizeUnsub(),this.resizeUnsub=null),this.resizeImmediateUnsub&&(this.resizeImmediateUnsub(),this.resizeImmediateUnsub=null),this.logUpdate)try{this.logUpdate.clear(this.scrollRegion?.getExtraRows()??0),this.logUpdate.done()}catch{}if(this.stdout.isTTY&&this.stdin.isTTY){try{this.stdout.write("\x1B[?2004l")}catch{}try{this.stdin.setRawMode(this.wasRaw)}catch{}}this.armed=!1,this.resetState()}setOverlay(t){t!==this.overlay&&(this.debugLog("setOverlay",{framesLen:t.length,anchorRow:this.anchorRow??null}),this.overlay=t,this.repaint())}setSpinner(t){this.stdout.isTTY&&this.spinnerController.set(t)}commitAbove(t){this.debugLog("commitAbove:enter",{textLen:t.length,anchorRow:this.anchorRow??null,committing:this.committing,topRow:this.logUpdate?.topRow??null});let n=g=>{this.scrollRegion?this.scrollRegion.withFullScrollRegion(g):g()};if(!this.armed||!this.logUpdate){n(()=>{this.stdout.write(t+`
2068
+ `)}static MAX_DROPDOWN_ROWS=6;constructor(t){this.stdout=t.stdout,this.stdin=t.stdin,this.onCancel=t.onCancel,this.onSoftStop=t.onSoftStop,this.onBackground=t.onBackground,this.onShiftTab=t.onShiftTab;let n=t.promptText;if(typeof n=="function")this.promptTextFn=n;else if(typeof n=="string")this.promptTextFn=()=>n;else{let r=" "+p.dim("\u23AF")+" ";this.promptTextFn=()=>r}this.history=t.history,this.autocompleteState=t.autocompleteState,this.formatInputBuffer=t.formatInputBuffer,this.scrollRegion=t.scrollRegion,this.spinnerController=new wl({captureMode:t.captureMode??!1,onTick:()=>this.repaint()}),this.onSubmit=t.onSubmit,this.anchorRow=t.anchorRow,this.declaredAnchorRow=t.anchorRow}isArmed(){return this.armed}setAnchorRow(t){this.anchorRow=t,this.declaredAnchorRow=t}suspendInput(){if(!(!this.armed||this.suspended)){if(this.logUpdate)try{this.logUpdate.clear(this.scrollRegion?.getExtraRows()??0),this.logUpdate.done()}catch{}this.handleKeypress&&this.stdin.removeListener("keypress",this.handleKeypress);try{this.stdin.setRawMode(!1)}catch{}this.suspended=!0}}resumeInput(){if(!(!this.armed||!this.suspended)){try{this.stdin.setRawMode(!0)}catch{}this.handleKeypress&&this.stdin.on("keypress",this.handleKeypress),this.suspended=!1,this.repaint()}}setOnSubmit(t){this.onSubmit=t??void 0}setOnCancel(t){this.onCancel=t??void 0}getOnCancel(){return this.onCancel}setOnSoftStop(t){this.onSoftStop=t??void 0}setOnBackground(t){this.onBackground=t??void 0}setOnShiftTab(t){this.onShiftTab=t??void 0}enterPickerMode(t){if(this.pickerController)throw new Error("enterPickerMode: a picker is already active; call exitPickerMode first");this.pickerSavedMode=this.inputMode,this.pickerController=t,this.inputMode="picker",this.autocompleteState?.reset(),this.repaint()}exitPickerMode(){this.pickerController&&(this.pickerController=null,this.inputMode=this.pickerSavedMode,this.repaint())}repaintPicker(){this.pickerController&&this.repaint()}setInputMode(t){let n=this.inputMode;if(this.inputMode=t,n==="idle"&&t==="streaming"){this.canceled=!1,this.backgrounded=!1,this.softStopped=!1,this.autocompleteState?.reset(),this.repaint();return}if(t==="idle"&&this.softStopped&&this.queued){this.queued=!1,this.repaint();return}if(t==="idle"&&this.queued&&this.onSubmit){let r=this.input.buffer,o=this.expandPastePlaceholders(r),s=[...this.attachments],i=this.onSubmit;this.queued=!1,this.input=j.seed(""),this.attachments=[],this.pasteRegistry.clear(),this.repaint(),i(o===r?{text:o,attachments:s}:{text:o,displayText:r,attachments:s});return}n!==t&&this.repaint()}getInputMode(){return this.inputMode}async arm(){if(this.armed)throw new Error("TerminalCompositor: arm() called while already armed");if(!(!this.stdout.isTTY||!this.stdin.isTTY)){this.anchorRow=this.declaredAnchorRow,this.logUpdate||(this.logUpdate=new fl(this.stdout)),this.wasRaw=this.stdin.isRaw??!1;try{this.stdin.setRawMode(!0)}catch{this.logUpdate=null,this.wasRaw=!1;return}try{this.stdout.write("\x1B[?2004h")}catch{}this.stdin.resume(),rN(this.stdin),this.handleKeypress=(t,n)=>this.dispatchKey(t,n),this.stdin.on("keypress",this.handleKeypress),this.armed=!0,this.canceled=!1,this.resizeUnsub=qe.subscribe(()=>{this.armed&&this.repaint()}),this.resizeImmediateUnsub=qe.subscribeImmediate(()=>{this.armed&&this.logUpdate?.resetGeometry?.()}),this.repaint()}}disarm(){if(this.spinnerController.dispose(),!this.armed){this.resetState();return}if(this.handleKeypress&&(this.stdin.removeListener("keypress",this.handleKeypress),this.handleKeypress=null),this.resizeUnsub&&(this.resizeUnsub(),this.resizeUnsub=null),this.resizeImmediateUnsub&&(this.resizeImmediateUnsub(),this.resizeImmediateUnsub=null),this.logUpdate)try{this.logUpdate.clear(this.scrollRegion?.getExtraRows()??0),this.logUpdate.done()}catch{}if(this.stdout.isTTY&&this.stdin.isTTY){try{this.stdout.write("\x1B[?2004l")}catch{}try{this.stdin.setRawMode(this.wasRaw)}catch{}}this.armed=!1,this.resetState()}setOverlay(t){t!==this.overlay&&(this.debugLog("setOverlay",{framesLen:t.length,anchorRow:this.anchorRow??null}),this.overlay=t,this.repaint())}setSpinner(t){this.stdout.isTTY&&this.spinnerController.set(t)}commitAbove(t){this.debugLog("commitAbove:enter",{textLen:t.length,anchorRow:this.anchorRow??null,committing:this.committing,topRow:this.logUpdate?.topRow??null});let n=g=>{this.scrollRegion?this.scrollRegion.withFullScrollRegion(g):g()};if(!this.armed||!this.logUpdate){n(()=>{this.stdout.write(t+`
2069
2069
  `)});return}let r=Math.max(1,this.stdout.rows??24),o=t.endsWith(`
2070
2070
  `)?t.slice(0,-1):t,s=o.match(/\n/g)?.length??0,i=Math.max(1,s+1),a=o.split(`
2071
2071
  `),l=this.scrollRegion?.getExtraRows()??0,c=this.logUpdate.topRow??0,u=c>1?c:Math.max(1,r-1-l),d=Math.max(this.anchorRow??1,1),m=c>1&&i<=u-d;this.committing=!0;try{this.logUpdate.clear(l),n(()=>{if(this.debugLog("commitAbove:phase1",{lineCount:i,fitsAboveFrame:m}),m)this.stdout.write(`\x1B[${r};1H${`
@@ -2205,7 +2205,7 @@ _ended: ${new Date().toISOString()}_
2205
2205
  `)}function SB(e){let t=[],n=(r,o)=>{o&&o.trim().length>0&&t.push({label:r,value:o.trim()})};switch(e.kind){case"done":n("done",e.whatWasDone),n("evidence",e.evidence),n("deferred",e.deferred);break;case"blocked":n("blocks",e.whatBlocks),n("unblock",e.unblockCondition),n("progress",e.alreadyDone);break;case"asking":n("question",e.question),n("resolves",e.assumption),n("after",e.followup);break;case"interrupted":n("was doing",e.whatWasInProgress),n("saved at",e.stateLocation),n("resume",e.resumeRequires);break}return t}function zT(e,t,n){let r=[];return n&&n.trim().length>0&&r.push({type:"text",text:n}),e&&r.push({type:"text",text:e}),Ll(r,t),r}async function JT(e,t,n,r,o="summary",s,i,a){let l=fk(e.text,e.attachments);r.setInFlight(!0);let c="",u=!1,d=!1,m=!1,f=!1,g,h=!1,b=!1,y=0,w=15e3,k=[],E=new Map,T=e.text.startsWith("/")?e.text.split(/[\s:]/)[0]?.slice(1):void 0,I=r.getCompositor?r.getCompositor():null,$=()=>new Oo({out:$o(s),thinkingMode:o,...T?{activeSkillName:T}:{},onCancel:()=>{t.interrupt().catch(C=>{Ue()&&console.error(" "+p.error("session.interrupt() failed:"),C)})},...i?{onBackground:()=>{h=!0}}:{},...a?.history?{history:a.history}:{},...a?.autocompleteState?{autocompleteState:a.autocompleteState}:{},...a?.promptText!==void 0?{promptText:a.promptText}:{},...r.scrollRegion?{scrollRegion:r.scrollRegion}:{},...I?{compositor:I}:{}}),x=$(),A=async()=>{if(!m){m=!0;try{await x.dispose()}catch{}}},P=async()=>{await x.arm();let C=x.getCompositor();if(s&&C){let R=C;s.fn=M=>R.commitAbove(M)}r.setActiveCompositor?.(C),r.setInterruptNotifier?.(R=>x.setInterrupting(R)),r.rearmStatus?.()};try{I?I.commitAbove(""):console.log(),r.setSoftStopHandler&&r.setSoftStopHandler(()=>{b=!0}),await P(),i&&r.setBackgroundHandler&&r.setBackgroundHandler(()=>{h=!0});let C=e.attachments.length===0?e.text:zT(e.text,e.attachments),R=t.sendMessageStream(C);if(await Wr((_,F)=>{x.process(_,F)},async()=>{for await(let _ of R){if(b){t.interrupt().catch(F=>{Ue()&&console.error(" "+p.error("soft-stop session.interrupt() failed:"),F)});break}if(h&&i){let F=T??e.text.slice(0,40),U=i.register(F),G=ol(U,i);sl(R,c,l,U,i,G,n,r.onTurnComplete,t.abortSignal),await A(),(s??{fn:console.log}).fn(p.dim(` \u2192 backgrounded as ${U.id}: ${U.label}`)),r.setInFlight(!1),r.rearmStatus?.();return}if(_.type==="chunk"&&_.chunk.type==="content"?(c+=_.chunk.content,u=!0):_.type==="message"&&!u&&(c=_.message.content),_.type==="chunk"&&_.chunk.type==="tool_use_detail"){let F=_.chunk,U={toolName:F.toolName,toolUseId:F.toolUseId,input:F.toolInput};E.set(F.toolUseId,U),k.push(U)}else if(_.type==="chunk"&&_.chunk.type==="tool_result"){let F=_.chunk,U=E.get(F.toolUseId);if(U&&(U.result=F.content,U.isError=F.isError,E.delete(F.toolUseId)),r.onContextProgress){let G=Date.now();if(G-y>=w){y=G;try{let D=r.onContextProgress();D instanceof Promise&&await D}catch(D){Ue()&&console.error(" "+p.error("onContextProgress (status refresh) failed:"),D)}}}}if(_.type==="paused"){await A(),(s??{fn:console.log}).fn(Jf({reason:_.reason,..._.resetsAt!==void 0?{resetsAt:_.resetsAt}:{},..._.accountId!==void 0?{accountId:_.accountId}:{},..._.autoResume!==void 0?{autoResume:_.autoResume}:{}}));continue}if(_.type==="resumed"){let F=_.hotSwapped&&_.accountId?`\u25B6 Resumed on ${_.accountId}`:"\u25B6 Resumed";c="",u=!1,k.length=0,E.clear(),f=!1,g=void 0,d=!1,h=!1,x=$(),m=!1,await P(),(s??{fn:console.log}).fn(p.success(F));continue}if(_.type==="error"){await A(),Ur(Fr(_.error)),d=!0;continue}x.process(_),_.type==="done"&&(f=!0,g=_.metadata)}}),await A(),b){let _=s?s.fn:console.log;_(p.warning("\u23F8 Stopped \u2014 work so far kept.")+p.dim(" Use /resume or --resume to continue.")),_("")}if(f&&!b){ar(n,l,c,g,k),r.onTurnComplete&&await r.onTurnComplete(l,c).catch(()=>{}),Ka(process.stdout);let _=U=>{s?s.fn(U):console.log(U)},F=GT(c);if(F&&(_(qT(F)),_(""),r.onTerminalState))try{r.onTerminalState(F)}catch{}if(kB(g,n,_),r.onAfterTurn){let U=r.onAfterTurn();U instanceof Promise&&await U.catch(()=>{})}}}catch(C){await A(),d||Ur(Fr(C))}finally{await A(),s&&(s.fn=s.idleFn),r.setActiveCompositor?.(null),r.setInterruptNotifier?.(null),r.setBackgroundHandler?.(null),r.setSoftStopHandler?.(null),r.setInFlight(!1),r.rearmStatus?.()}}function kB(e,t,n=console.log){if(!e)return;let r=[];e.durationMs&&r.push(se(e.durationMs)),e.totalCostUsd!==void 0&&r.push(Fe(e.totalCostUsd));let o=Number(e.usage?.input_tokens??0),s=Number(e.usage?.output_tokens??0);o+s>0&&r.push(te(o+s)+" tok"),r.length>0&&n(p.dim(" \u25E6 "+r.join(" \xB7 ")));let i=Jd(t),a=it(t.model);if(i>=1){let l=Math.round((i-1)*a),c=Math.round(a/1e3);console.log(p.error(` context OVER ${c}k tok by ~${te(l)} tok \u2014 model output may be silently truncated`))}else if(i>.5){let l=i>.8?p.error:p.warning;n(l(` context ${Math.round(i*100)}% used of ${te(a)}`))}n("")}function VT(e={}){let t=e.load??tl,n=e.onResize??(i=>qe.subscribe(i)),r="",o,s=n(()=>{r=""});return{renderIfChanged(i){let a=i??"unbound",l=t(a),c=$S(l);return a===o&&c===r?[]:(o=a,r=c,c===""?[]:nl(l))},invalidate(){r=""},dispose(){try{s()}catch{}}}}var fm={done:{glyph:"\u2713",color:p.success,label:"done"},blocked:{glyph:"\u2298",color:p.error,label:"blocked"},asking:{glyph:"?",color:p.warning,label:"asking"},interrupted:{glyph:"\u23F8",color:p.meta,label:"interrupted"}};function YT(e={}){let t=Math.max(2,e.capacity??8),n=[];return{push(r){n.push(r.kind),n.length>t&&(n=n.slice(n.length-t))},reset(){n=[]},entries(){return n},render(){if(n.length===0)return null;let r=p.dim(" ledger "),o=p.dim(" \xB7 "),s=n.map(u=>{let d=fm[u];return d.color(`${d.glyph} ${d.label}`)}),i=p.dim(` (${n.length} turn${n.length===1?"":"s"})`),a=r+s.join(o)+i,l=Math.max(20,Y()-2);if(z(a)<=l)return a;let c=r+n.map(u=>fm[u].color(fm[u].glyph)).join(p.dim(" "))+i;return ce(c,l)}}}var gm=["\u25D0","\u25D1","\u25D2","\u25D3"],mc=class{stream;manager;registry;throttleMs;started=!1;lastRepaint=0;spinnerIndex=0;spinnerInterval=null;resizeUnsub=null;updateHandler=null;registryStartedHandler=null;registrySettledHandler=null;rowCount=0;onRowCountChange;constructor(t,n,r={}){this.manager=t,this.registry=n,this.stream=r.stream??process.stdout,this.throttleMs=r.throttleMs??200}setRowCountChangeHandler(t){this.onRowCountChange=t}start(){this.started||(this.started=!0,this.updateHandler=()=>this.scheduleRepaint(),this.manager.on("update",this.updateHandler),this.manager.on("complete",this.updateHandler),this.registry&&(this.registryStartedHandler=t=>{this.scheduleRepaint()},this.registrySettledHandler=t=>{this.scheduleRepaint()},this.registry.on("started",this.registryStartedHandler),this.registry.on("settled",this.registrySettledHandler)),this.resizeUnsub=qe.subscribe(()=>this.repaint()),this.spinnerInterval=setInterval(()=>{this.spinnerIndex=(this.spinnerIndex+1)%gm.length,this.rowCount>0&&this.repaint()},Math.max(this.throttleMs,50)))}stop(){this.started&&(this.started=!1,this.updateHandler&&(this.manager.removeListener("update",this.updateHandler),this.manager.removeListener("complete",this.updateHandler),this.updateHandler=null),this.registry&&(this.registryStartedHandler&&(this.registry.off("started",this.registryStartedHandler),this.registryStartedHandler=null),this.registrySettledHandler&&(this.registry.off("settled",this.registrySettledHandler),this.registrySettledHandler=null)),this.resizeUnsub&&(this.resizeUnsub(),this.resizeUnsub=null),this.spinnerInterval&&(clearInterval(this.spinnerInterval),this.spinnerInterval=null),this.rowCount>0&&(this.clearRows(),this.rowCount=0,this.onRowCountChange?.(0)))}scheduleRepaint(){Date.now()-this.lastRepaint<this.throttleMs||this.repaint()}repaint(){if(!this.started||!this.stream.isTTY)return;this.lastRepaint=Date.now();let t=[...this.manager.running().map(s=>({kind:"turn",task:s})),...(this.registry?.list()??[]).filter(s=>s.status==="running").map(s=>({kind:"subagent",job:s}))],n=this.stream.rows??24,r=Math.max(0,Math.min(t.length,n-1));if(r!==this.rowCount&&(this.rowCount>0&&this.clearRows(),this.rowCount=r,this.onRowCountChange?.(r)),r===0)return;let o=Math.max(1,n-r);this.stream.write("\x1B[s");for(let s=0;s<r;s++){let i=t[s],a=o+s;this.stream.write(`\x1B[${a};1H`),this.stream.write("\x1B[2K"),this.stream.write(this.formatItemLine(i))}this.stream.write("\x1B[u")}clearRows(){if(!this.stream.isTTY)return;let t=this.stream.rows??24,n=Math.min(this.rowCount,t-1),r=Math.max(1,t-n);this.stream.write("\x1B[s");for(let o=0;o<n;o++)this.stream.write(`\x1B[${r+o};1H`),this.stream.write("\x1B[2K");this.stream.write("\x1B[u")}formatItemLine(t){return t.kind==="turn"?this.formatTaskLine(t.task):this.formatJobLine(t.job)}formatTaskLine(t){let n=Math.max(4,(this.stream.columns??80)-2),r=p.brand(gm[this.spinnerIndex]),o=p.dim(t.id),s=p.bold(t.label),i=[r,o,s];t.progressDescription&&i.push(p.dim(t.progressDescription));let a=[];t.stats.toolUses>0&&a.push(`${t.stats.toolUses} tool${t.stats.toolUses===1?"":"s"}`),t.stats.tokens>0&&a.push(`${te(t.stats.tokens)} tok`);let l=Date.now()-t.startedAt;return a.push(se(l)),a.length>0&&i.push(p.dim(a.join(" \xB7 "))),ce(" "+i.join(" "),n)}formatJobLine(t){let n=Math.max(4,(this.stream.columns??80)-2),r=p.brand(gm[this.spinnerIndex]),o=p.dim(t.jobId),s=p.bold(t.label||t.jobId),i=[r,o,s],a=Date.now()-t.startedAt;return i.push(p.dim(se(a))),ce(" "+i.join(" "),n)}};function fc(e,t){let n=p.brand("afk")+p.dim(` (${e})`),r=t?p.warning(" \u25CF plan"):"";return n+r+p.dim(" \u203A ")}async function XT(e,t,n,r){let o=null,s=[];e.session.current.waitForInitialization().then(async m=>{Ue()&&(o=Xa(m)),await Bl(e.session.current),Ue()&&(s=Vv())}).catch(()=>{});let i=await NT(),a=new pc({rl:e.rl,history:i,statusLine:e.statusLine}),l,c,u,d;try{await a.armCompositor({promptFn:()=>fc(e.stats.model,e.stats.planMode),onCancel:r,onShiftTab:()=>{let y=e.slashCtx;y.stats.planMode&&y.stats.pendingPlanExit?(y.stats.pendingPlanExit=!1,Rt(y,!1,{closureSummarySkipped:!0}).catch(()=>{})):Rt(y).catch(()=>{}),e.statusLine.rearm()},scrollRegion:e.statusLine,...e.preArmAnchorRow!==void 0?{anchorRow:e.preArmAnchorRow}:{}});let m=a.getCompositor();Ft.install(qa({readLine:y=>a.readLine({promptFn:()=>y}).then(w=>w.text),writer:{line:(y="")=>{let w=a.getCompositor();w?w.commitAbove(y):process.stdout.write(y+`
2206
2206
  `)}},pendingCount:()=>Ft.pendingCount(),...m?{pickFromList:y=>HT(m,y),readTextOverlay:y=>KT(m,y)}:{}})),e.replRenderer.setCompositor(a.getCompositor()),e.slashCtx.getCompositor=()=>a.getCompositor();let f=a.getCompositor();if(f){let y=w=>f.commitAbove(w);e.completionWriter.fn=y,e.completionWriter.idleFn=y}e.slashCtx.setSoftStopHandler=y=>a.setSoftStopHandler(y),e.inputSurfaceRef&&(e.inputSurfaceRef.current=a),c=VT();let g=YT();e.clearVerdictLedger=()=>g.reset(),u=new rl,GS(u),XS(u),ek(u),ZS(e.backgroundRegistry),d=new mc(u,e.backgroundRegistry),d.setRowCountChangeHandler(y=>{e.statusLine.setExtraRows(y)}),d.start();let h=50,b=[];for(u.on("complete",y=>{b.length>=h&&b.shift(),b.push(y)});;){if(o&&(e.replRenderer.writeLine(o),e.replRenderer.writeLine(""),o=null),s.length>0){for(let x of s)e.replRenderer.writeLine(x);e.replRenderer.writeLine(""),s=[]}for(;b.length>0;){let x=b.shift(),A=x.status==="succeeded"?"\u2713":"\u2717",P=[];if(x.resultText){let R=x.resultText.trim().split(`
2207
2207
  `)[0]?.slice(0,80)??"";R&&P.push(R)}x.error&&P.push(x.error.message);let C=[x.stats.toolUses>0?`${x.stats.toolUses} tools`:"",x.stats.tokens>0?`${Math.round(x.stats.tokens/1e3)}k tok`:"",x.stats.durationMs>0?`${Math.round(x.stats.durationMs/1e3)}s`:""].filter(Boolean).join(" \xB7 ");C&&P.push(C),e.replRenderer.writeLine(vn({kind:x.status==="succeeded"?"checkpoint":"diagnosis",title:`${A} ${x.id} ${x.label}`,body:P})),e.replRenderer.writeLine("")}let y=c.renderIfChanged(e.stats.sessionId);if(y.length>0){for(let x of y)e.replRenderer.writeLine(x);e.replRenderer.writeLine("")}let w=g.render();w&&e.replRenderer.writeLine(w);let k,E;if(l!==void 0){let x=l;l=void 0;let A=fc(e.stats.model,e.stats.planMode),P=pr({buffer:x.text,promptText:A,isTTY:!!process.stdout.isTTY,attachmentSummary:xo([...x.attachments])});e.replRenderer.writeLine(P),k=x.text.trim(),E=x.attachments}else{let x=await a.readLine({promptFn:()=>fc(e.stats.model,e.stats.planMode),onSigint:r,onShiftTab:()=>{let A=e.slashCtx;A.stats.planMode&&A.stats.pendingPlanExit?(A.stats.pendingPlanExit=!1,Rt(A,!1,{closureSummarySkipped:!0}).catch(()=>{})):Rt(A).catch(()=>{}),e.statusLine.rearm()}});k=x.text.trim(),E=x.attachments}if(!k&&E.length===0)continue;let T=!1;if(k.startsWith("/")){let x=await dS(k,e.slashCtx,E);if(x.handled){if(x.result==="exit"){e.rl.close();return}if((k==="/clear"||k.startsWith("/clear "))&&(await t.rotateOnClear(),e.replRenderer.writeLine(p.dim(` transcript: ${t.path()}`)),g.reset()),x.result!==null&&typeof x.result=="object"&&"kind"in x.result&&x.result.kind==="submit"){l={text:x.result.message,attachments:E??[]},e.statusLine.rearm();continue}e.statusLine.rearm();continue}T=!0}i.push(k);let I=k;if(T){let x=zd(k);if(x){let A=x.name.replace(/^\//,"").split(":").pop()??"";if(A&&Kp(A)){let P={skillName:A,rawArgs:x.args,source:"plugin",capabilities:{compose:!0,subagents:!0}},C=e.session.current.sessionId,R=kr(C),M=Date.now();J(`[afk trace] preflight.start commandName=${A}`);let _=!1,F=await Sr(P,{cwd:e.stats.cwd??process.cwd(),artifactDir:R},U=>{Ue()&&e.replRenderer.writeLine(p.warning(`\u26A0 preflight(${A}) failed: `)+(U instanceof Error?U.message:String(U)))});_=F!==null,J(`[afk trace] preflight.end commandName=${A} durationMs=${Date.now()-M} success=${_}`),I=zp(F?.manifestBlock,k)}}}let $;if(e.firstTurnHook&&e.stats.totalTurns===0){let x=e.firstTurnHook;e.firstTurnHook=void 0,$=Promise.resolve().then(()=>x(k)).catch(A=>{e.completionWriter.fn(p.warning("\u26A0 ")+"first-turn hook failed: "+(A instanceof Error?A.message:String(A)))})}await JT({text:I,attachments:E},e.session.current,e.stats,{setInFlight(x){n.turnInFlight=x},async onTurnComplete(x,A){await t.appendTurn(x,A)},async onAfterTurn(){await e.contextSampler.onTurn(e.stats.totalTurns),await xS(e.slashCtx),e.statusLine.rearm()},rearmStatus:()=>e.statusLine.rearm(),onTerminalState:x=>g.push(x),setActiveCompositor:x=>{n.activeCompositor=x},setInterruptNotifier:x=>{n.notifyInterrupting=x},scrollRegion:e.statusLine,getCompositor:()=>a.getCompositor(),setBackgroundHandler:x=>a.setBackgroundHandler(x),setSoftStopHandler:x=>a.setSoftStopHandler(x),async onContextProgress(){await e.contextSampler.refresh(),e.statusLine.repaint(dr(e.stats,e.contextSampler))}},e.options.thinkingUi,e.completionWriter,u,a.toRunTurnRefs(fc(e.stats.model,e.stats.planMode))),$!==void 0&&await $}}finally{if(u!==void 0)for(let f of u.running())u.cancel(f.id);d?.stop(),c?.dispose();let m=f=>console.log(f);e.completionWriter.fn=m,e.completionWriter.idleFn=m,await a.dispose(),e.inputSurfaceRef&&(e.inputSurfaceRef.current=null)}}import{execFile as vB}from"node:child_process";import{dirname as TB,isAbsolute as EB,resolve as xB}from"node:path";import{promisify as RB}from"node:util";var ZT=RB(vB),AB=3e3,_B=new Set(["empty","orphaned-dir","orphaned-registration","dead-owner"]);async function CB(){let t=(await ZT("git",["rev-parse","--git-common-dir"])).stdout.trim();if(!t)throw new Error("Not in a git repository.");let n=EB(t)?t:xB(process.cwd(),t);return TB(n)}async function QT(e){if(e?.disabled)return{ran:!1,removedCount:0,skippedReason:"disabled"};let t;try{t=await CB()}catch{return{ran:!1,removedCount:0,skippedReason:"not-in-repo"}}let n,r=new Promise(o=>{n=setTimeout(()=>o("timeout"),AB)});try{let o=Gt({execFile:ZT,repoRoot:t,dryRun:!1,scope:"interactive",bypassSoftLaunch:!0}),s=await Promise.race([o,r]);if(s==="timeout")return{ran:!1,removedCount:0,skippedReason:"timeout"};let i=s;return i.warnings.some(c=>c.toLowerCase().includes("contested"))?{ran:!1,removedCount:0,skippedReason:"lock-contested"}:{ran:!0,removedCount:i.candidates.filter(c=>_B.has(c.verdict)&&i.removed.includes(c.path)).length}}catch{return{ran:!1,removedCount:0,skippedReason:"error"}}finally{n&&clearTimeout(n)}}import{promises as IB}from"node:fs";import{dirname as PB,join as MB}from"node:path";import{randomBytes as OB}from"node:crypto";var $B=["Generate a 2-4 word kebab-case slug describing this work request.","Rules:","- ASCII lowercase letters and digits only, separated by single hyphens","- 2 to 4 hyphen-separated words","- Maximum 30 characters total","- No prefix, no quotes, no punctuation other than hyphens","- Output ONLY the slug \u2014 no explanation, no preamble","Examples: fix-cleanup-race, add-telegram-allowlist, refactor-prompt-loader, debug-flaky-test"].join(`
2208
- `),eE=/^[a-z0-9]+(-[a-z0-9]+){1,3}$/,hm=30,DB=1024,LB=8e3,FB="haiku";async function NB(e,t){let n=e.trim();if(n.length===0)return t.onSkip?.("empty-message"),null;if(n.startsWith("/"))return t.onSkip?.("slash-command"),null;let r=WB(n,DB),o=new AbortController,s=setTimeout(()=>o.abort(),t.timeoutMs??LB),i=t.signal?HB([t.signal,o.signal]):o.signal,a;try{t.slugGenerator?a=await t.slugGenerator(r,i):a=await nc({token:t.token,model:t.model??FB,system:$B,user:r,maxTokens:32,signal:i})}catch(d){let m=d instanceof Error?d.message:String(d);return t.onSkip?.("slug-generator-error",m.slice(0,200)),null}finally{clearTimeout(s)}let l=UB(a);if(l===null)return t.onSkip?.("invalid-slug-output",a.slice(0,60)),null;let c=PB(t.worktreePath);return await jB(l,c)}function UB(e){let t=e.trim().toLowerCase();if(t.length===0)return null;if(eE.test(t)&&t.length<=hm)return t;let n=t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(n.length===0)return null;let r=n.split("-").filter(s=>s.length>0).slice(0,4);if(r.length<2)return null;let o=r[0];for(let s=1;s<r.length;s++){let i=`${o}-${r[s]}`;if(i.length>hm)break;o=i}return eE.test(o)?o:null}async function jB(e,t){if(!await BB(MB(t,e)))return e;let n=OB(2).toString("hex");return`${e.split("-").slice(0,3).join("-").slice(0,hm-5)}-${n}`}async function BB(e){try{return await IB.access(e),!0}catch{return!1}}function WB(e,t){let n=Buffer.from(e,"utf8");if(n.length<=t)return e;let r=t;for(;r>0&&n[r]!==void 0&&(n[r]&192)===128;)r--;return n.slice(0,r).toString("utf8")}function HB(e){let t=AbortSignal.any;if(typeof t=="function")return t.call(AbortSignal,e);let n=new AbortController;for(let r of e){if(r.aborted)return n.abort(r.reason),n.signal;r.addEventListener("abort",()=>n.abort(r.reason),{once:!0})}return n.signal}async function nE(e){let t,n,r=await NB(e.message,{token:e.token,...e.model!==void 0?{model:e.model}:{},...e.timeoutMs!==void 0?{timeoutMs:e.timeoutMs}:{},worktreePath:e.handle.path,...e.signal!==void 0?{signal:e.signal}:{},...e.slugGenerator!==void 0?{slugGenerator:e.slugGenerator}:{},onSkip:(i,a)=>{t=i,n=a}});if(r===null)return{status:"skipped",reason:t??"unknown",...n!==void 0?{detail:n}:{}};let s=await(e.renameFn??bb)(e.handle,r,e.branchPrefix!==void 0?{branchPrefix:e.branchPrefix}:void 0);return s.ok?(e.session&&e.session.setCwd(s.newPath),tE(s.newPath),{status:"renamed",oldPath:s.oldPath,newPath:s.newPath,oldBranch:s.oldBranch,newBranch:s.newBranch}):(s.partial==="branch"&&(e.session&&e.session.setCwd(e.handle.path),tE(e.handle.path)),{status:"failed",reason:s.reason,...s.partial!==void 0?{partial:s.partial}:{}})}function tE(e){try{process.chdir(e)}catch{}}B();import{spawn as rE}from"child_process";import{existsSync as JB,mkdirSync as VB,readFileSync as oE,unlinkSync as YB,writeFileSync as XB}from"fs";import{get as ZB}from"https";import{join as sE}from"path";import{readFileSync as KB}from"fs";import{dirname as GB,join as qB}from"path";import{fileURLToPath as zB}from"url";function fn(){try{return"3.56.4"}catch{}try{let e=GB(zB(import.meta.url));for(let t of["../../package.json","../package.json"])try{let n=JSON.parse(KB(qB(e,t),"utf-8"));if(typeof n.version=="string")return n.version}catch{}}catch{}return"0.0.0-unknown"}K();var QB=64*1024,eW=1440*60*1e3,tW="update-check.json",nW="pending-update.json";function iE(){return sE(Ti(),tW)}function ym(){return sE(Ti(),nW)}function aE(){let e=Ti();JB(e)||VB(e,{recursive:!0})}function rW(e,t){let n=e.split(".").map(Number),r=t.split(".").map(Number),o=Math.max(n.length,r.length);for(let s=0;s<o;s++){let i=n[s]??0,a=r[s]??0;if(a>i)return!0;if(a<i)return!1}return!1}function oW(){try{let e=oE(iE(),"utf-8"),t=JSON.parse(e);if(typeof t.latestVersion=="string"&&typeof t.checkedAt=="number")return t}catch{}return null}function sW(){try{aE();let e=`
2208
+ `),eE=/^[a-z0-9]+(-[a-z0-9]+){1,3}$/,hm=30,DB=1024,LB=8e3,FB="haiku";async function NB(e,t){let n=e.trim();if(n.length===0)return t.onSkip?.("empty-message"),null;if(n.startsWith("/"))return t.onSkip?.("slash-command"),null;let r=WB(n,DB),o=new AbortController,s=setTimeout(()=>o.abort(),t.timeoutMs??LB),i=t.signal?HB([t.signal,o.signal]):o.signal,a;try{t.slugGenerator?a=await t.slugGenerator(r,i):a=await nc({token:t.token,model:t.model??FB,system:$B,user:r,maxTokens:32,signal:i})}catch(d){let m=d instanceof Error?d.message:String(d);return t.onSkip?.("slug-generator-error",m.slice(0,200)),null}finally{clearTimeout(s)}let l=UB(a);if(l===null)return t.onSkip?.("invalid-slug-output",a.slice(0,60)),null;let c=PB(t.worktreePath);return await jB(l,c)}function UB(e){let t=e.trim().toLowerCase();if(t.length===0)return null;if(eE.test(t)&&t.length<=hm)return t;let n=t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(n.length===0)return null;let r=n.split("-").filter(s=>s.length>0).slice(0,4);if(r.length<2)return null;let o=r[0];for(let s=1;s<r.length;s++){let i=`${o}-${r[s]}`;if(i.length>hm)break;o=i}return eE.test(o)?o:null}async function jB(e,t){if(!await BB(MB(t,e)))return e;let n=OB(2).toString("hex");return`${e.split("-").slice(0,3).join("-").slice(0,hm-5)}-${n}`}async function BB(e){try{return await IB.access(e),!0}catch{return!1}}function WB(e,t){let n=Buffer.from(e,"utf8");if(n.length<=t)return e;let r=t;for(;r>0&&n[r]!==void 0&&(n[r]&192)===128;)r--;return n.slice(0,r).toString("utf8")}function HB(e){let t=AbortSignal.any;if(typeof t=="function")return t.call(AbortSignal,e);let n=new AbortController;for(let r of e){if(r.aborted)return n.abort(r.reason),n.signal;r.addEventListener("abort",()=>n.abort(r.reason),{once:!0})}return n.signal}async function nE(e){let t,n,r=await NB(e.message,{token:e.token,...e.model!==void 0?{model:e.model}:{},...e.timeoutMs!==void 0?{timeoutMs:e.timeoutMs}:{},worktreePath:e.handle.path,...e.signal!==void 0?{signal:e.signal}:{},...e.slugGenerator!==void 0?{slugGenerator:e.slugGenerator}:{},onSkip:(i,a)=>{t=i,n=a}});if(r===null)return{status:"skipped",reason:t??"unknown",...n!==void 0?{detail:n}:{}};let s=await(e.renameFn??bb)(e.handle,r,e.branchPrefix!==void 0?{branchPrefix:e.branchPrefix}:void 0);return s.ok?(e.session&&e.session.setCwd(s.newPath),tE(s.newPath),{status:"renamed",oldPath:s.oldPath,newPath:s.newPath,oldBranch:s.oldBranch,newBranch:s.newBranch}):(s.partial==="branch"&&(e.session&&e.session.setCwd(e.handle.path),tE(e.handle.path)),{status:"failed",reason:s.reason,...s.partial!==void 0?{partial:s.partial}:{}})}function tE(e){try{process.chdir(e)}catch{}}B();import{spawn as rE}from"child_process";import{existsSync as JB,mkdirSync as VB,readFileSync as oE,unlinkSync as YB,writeFileSync as XB}from"fs";import{get as ZB}from"https";import{join as sE}from"path";import{readFileSync as KB}from"fs";import{dirname as GB,join as qB}from"path";import{fileURLToPath as zB}from"url";function fn(){try{return"3.56.5"}catch{}try{let e=GB(zB(import.meta.url));for(let t of["../../package.json","../package.json"])try{let n=JSON.parse(KB(qB(e,t),"utf-8"));if(typeof n.version=="string")return n.version}catch{}}catch{}return"0.0.0-unknown"}K();var QB=64*1024,eW=1440*60*1e3,tW="update-check.json",nW="pending-update.json";function iE(){return sE(Ti(),tW)}function ym(){return sE(Ti(),nW)}function aE(){let e=Ti();JB(e)||VB(e,{recursive:!0})}function rW(e,t){let n=e.split(".").map(Number),r=t.split(".").map(Number),o=Math.max(n.length,r.length);for(let s=0;s<o;s++){let i=n[s]??0,a=r[s]??0;if(a>i)return!0;if(a<i)return!1}return!1}function oW(){try{let e=oE(iE(),"utf-8"),t=JSON.parse(e);if(typeof t.latestVersion=="string"&&typeof t.checkedAt=="number")return t}catch{}return null}function sW(){try{aE();let e=`
2209
2209
  const https = require('https');
2210
2210
  const fs = require('fs');
2211
2211
  const url = 'https://registry.npmjs.org/agent-afk/latest';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-afk",
3
- "version": "3.56.4",
3
+ "version": "3.56.5",
4
4
  "description": "CLI tool for interacting with AI agents via multiple interfaces",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",