agent-afk 3.8.5 → 3.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1759,7 +1759,7 @@ Create a ship-ready summary with next steps.`,c=await a.runToResult(l);if(c.stat
1759
1759
  - Use absolute paths for file operations.
1760
1760
  - Prefer \`agent\` (and \`skill\`) for multi-file investigation, verification, parallel hypotheses, and any work that would otherwise consume large amounts of inline context. The main session is the coordinator; subagents are the investigators.
1761
1761
 
1762
- When you see a \`<command-name>\` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch the same skill again. Instead, treat the \`<command-message>\` as the skill name and \`<command-args>\` as its arguments, then follow the instructions in the body block immediately following the tag.`,Wl=`# Cross-Session Memory
1762
+ When you see a \`<command-name>\` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch that same skill again. Instead, treat the \`<command-message>\` as the skill name and \`<command-args>\` as its arguments, then follow the instructions in the body block immediately following the tag. You MAY still invoke the skill tool to dispatch OTHER skills that are not the one already loaded.`,Wl=`# Cross-Session Memory
1763
1763
 
1764
1764
  You have three tools for persisting knowledge across sessions: memory_search, memory_update, and procedure_write.
1765
1765
 
@@ -1994,7 +1994,7 @@ _ended: ${new Date().toISOString()}_
1994
1994
  `)}function Q0(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 Xb(e,t,n){let r=[];n&&n.trim().length>0&&r.push({type:"text",text:n}),e&&r.push({type:"text",text:e});for(let o of t)r.push({type:"image",source:{type:"base64",media_type:o.mediaType,data:o.bytes.toString("base64")}});return r}async function Qb(e,t,n,r,o="summary",s,i,a){let l=Nb(e.text,e.attachments);r.setInFlight(!0);let c="",d=!1,u,p=!1,f=!1,g=!1,h,b=!1,y=[],w=new Map,v=e.text.startsWith("/")?e.text.split(/[\s:]/)[0]?.slice(1):void 0,A=new an({out:br(),thinkingMode:o,...v?{activeSkillName:v}:{},onCancel:()=>{t.interrupt().catch(_=>{Oe()&&console.error(" "+m.error("session.interrupt() failed:"),_)})},...i?{onBackground:()=>{b=!0}}:{},...a?.history?{history:a.history}:{},...a?.autocompleteState?{autocompleteState:a.autocompleteState}:{},...r.scrollRegion?{scrollRegion:r.scrollRegion}:{}}),T=async()=>{if(!f){f=!0;try{await A.dispose()}catch{}}};try{console.log(),await A.arm();let _=A.getCompositor();if(s&&_){let R=_;s.fn=x=>R.commitAbove(x)}r.setActiveCompositor?.(_),r.rearmStatus?.();let S=e.attachments.length===0?e.text:Xb(e.text,e.attachments),E=t.sendMessageStream(S);if(await qn(A.sink,async()=>{for await(let R of E){if(b&&i){let x=v??e.text.slice(0,40),O=i.register(x),P=ki(O,i);wi(E,c,l,O,i,P,n,r.onTurnComplete,t.abortSignal),await T(),console.log(m.dim(` \u2192 backgrounded as ${O.id}: ${O.label}`)),r.setInFlight(!1),r.rearmStatus?.();return}if(R.type==="chunk"&&R.chunk.type==="content"?(c+=R.chunk.content,d=!0):R.type==="message"&&!d&&(c=R.message.content),R.type==="chunk"&&R.chunk.type==="tool_use_detail"){let x=R.chunk,O={toolName:x.toolName,toolUseId:x.toolUseId,input:x.toolInput};w.set(x.toolUseId,O),y.push(O)}else if(R.type==="chunk"&&R.chunk.type==="tool_result"){let x=R.chunk,O=w.get(x.toolUseId);O&&(O.result=x.content,O.isError=x.isError,w.delete(x.toolUseId))}if(R.type==="paused"){await T(),console.log(Md({reason:R.reason,...R.resetsAt!==void 0?{resetsAt:R.resetsAt}:{},...R.accountId!==void 0?{accountId:R.accountId}:{}}));continue}if(R.type==="resumed"){let x=R.hotSwapped&&R.accountId?`\u25B6 Resumed on ${R.accountId}`:"\u25B6 Resumed";console.log(m.success(x));continue}if(R.type==="error"){await T(),Kn(Hn(R.error)),p=!0;continue}A.process(R),R.type==="done"&&(g=!0,h=R.metadata)}}),!f){let R=A.getCompositor();if(R)try{let{text:x,queued:O}=R.getBuffer();O&&x.length>0&&(u=x)}catch{}}if(await T(),g){ci(n,l,c,h,y),r.onTurnComplete&&await r.onTurnComplete(l,c).catch(()=>{}),d&&console.log(`
1995
1995
  `);let R=Vb(c);if(R&&(console.log(Yb(R)),console.log(),r.onTerminalState))try{r.onTerminalState(R)}catch{}if(Z0(h,n),r.onAfterTurn){let x=r.onAfterTurn();x instanceof Promise&&await x.catch(()=>{})}}}catch(_){await T(),p||Kn(Hn(_))}finally{await T(),s&&(s.fn=_=>console.log(_)),r.setActiveCompositor?.(null),r.setInFlight(!1),r.rearmStatus?.()}return u}function Z0(e,t){if(!e)return;let n=[];e.durationMs&&n.push(re(e.durationMs)),e.totalCostUsd!==void 0&&n.push(Me(e.totalCostUsd));let r=Number(e.usage?.input_tokens??0),o=Number(e.usage?.output_tokens??0);r+o>0&&n.push(q(r+o)+" tok"),n.length>0&&console.log(m.dim(" \u25E6 "+n.join(" \xB7 ")));let s=lc(t);if(s>.5){let i=s>.8?m.error:m.warning;console.log(i(` context ${Math.round(s*100)}% used of ${q(Ze(t.model))}`))}console.log()}function Zb(e={}){let t=e.load??hi,n=e.onResize??(i=>Ft.subscribe(i)),r="",o,s=n(()=>{r=""});return{renderIfChanged(i){let a=i??"unbound",l=t(a),c=uh(l);return a===o&&c===r?[]:(o=a,r=c,c===""?[]:yi(l))},invalidate(){r=""},dispose(){try{s()}catch{}}}}var uu={done:{glyph:"\u2713",color:m.success,label:"done"},blocked:{glyph:"\u2298",color:m.error,label:"blocked"},asking:{glyph:"?",color:m.warning,label:"asking"},interrupted:{glyph:"\u23F8",color:m.meta,label:"interrupted"}};function ek(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=m.dim(" ledger "),o=m.dim(" \xB7 "),s=n.map(d=>{let u=uu[d];return u.color(`${u.glyph} ${u.label}`)}),i=m.dim(` (${n.length} turn${n.length===1?"":"s"})`),a=r+s.join(o)+i,l=Math.max(20,ee()-2);if(W(a)<=l)return a;let c=r+n.map(d=>uu[d].color(uu[d].glyph)).join(m.dim(" "))+i;return pe(c,l)}}}var tk=["\u25D0","\u25D1","\u25D2","\u25D3"],fa=class{stream;manager;registry;throttleMs;started=!1;lastRepaint=0;spinnerIndex=0;spinnerInterval=null;resizeUnsub=null;updateHandler=null;registryStartedHandler=null;registrySettledHandler=null;subagentRunningCount=0;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.subagentRunningCount++,this.scheduleRepaint()},this.registrySettledHandler=t=>{this.subagentRunningCount=Math.max(0,this.subagentRunningCount-1),this.scheduleRepaint()},this.registry.on("started",this.registryStartedHandler),this.registry.on("settled",this.registrySettledHandler)),this.resizeUnsub=Ft.subscribe(()=>this.repaint()),this.spinnerInterval=setInterval(()=>{this.spinnerIndex=(this.spinnerIndex+1)%tk.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(),n=t.length+this.subagentRunningCount;if(n!==this.rowCount&&(this.rowCount>0&&this.clearRows(),this.rowCount=n,this.onRowCountChange?.(n)),n===0)return;let o=(this.stream.rows??24)-n;this.stream.write("\x1B[s");for(let s=0;s<t.length;s++){let i=t[s],a=o+s;this.stream.write(`\x1B[${a};1H`),this.stream.write("\x1B[2K"),this.stream.write(this.formatTaskLine(i))}this.stream.write("\x1B[u")}clearRows(){if(!this.stream.isTTY)return;let n=(this.stream.rows??24)-this.rowCount;this.stream.write("\x1B[s");for(let r=0;r<this.rowCount;r++)this.stream.write(`\x1B[${n+r};1H`),this.stream.write("\x1B[2K");this.stream.write("\x1B[u")}formatTaskLine(t){let n=Math.max(4,(this.stream.columns??80)-2),r=m.brand(tk[this.spinnerIndex]),o=m.dim(t.id),s=m.bold(t.label),i=[r,o,s];t.progressDescription&&i.push(m.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(`${q(t.stats.tokens)} tok`);let l=Date.now()-t.startedAt;return a.push(re(l)),a.length>0&&i.push(m.dim(a.join(" \xB7 "))),pe(" "+i.join(" "),n)}};function nk(e,t){let n=m.brand("afk")+m.dim(` (${e})`),r=t?m.warning(" \u25CF plan"):"";return n+r+m.dim(" \u203A ")}async function rk(e,t,n,r){let o=null,s=[];e.session.current.waitForInitialization().then(async h=>{Oe()&&(o=pi(h)),await Ui(e.session.current),Oe()&&(s=Uy())}).catch(()=>{});let i=await Jb(),a=da(),l,c=Zb(),d=ek();e.clearVerdictLedger=()=>d.reset();let u=new bi;Sh(u),Rh(u),Ph(u),Ah(e.backgroundRegistry);let p=new fa(u,e.backgroundRegistry);p.setRowCountChangeHandler(h=>{e.statusLine.setExtraRows(h)}),p.start();let f=50,g=[];u.on("complete",h=>{g.length>=f&&g.shift(),g.push(h)});try{for(;;){if(o&&(e.replRenderer.writeLine(o),e.replRenderer.writeLine(""),o=null),s.length>0){for(let S of s)e.replRenderer.writeLine(S);e.replRenderer.writeLine(""),s=[]}for(;g.length>0;){let S=g.shift(),E=S.status==="succeeded"?"\u2713":"\u2717",R=[];if(S.resultText){let O=S.resultText.trim().split(`
1996
1996
  `)[0]?.slice(0,80)??"";O&&R.push(O)}S.error&&R.push(S.error.message);let x=[S.stats.toolUses>0?`${S.stats.toolUses} tools`:"",S.stats.tokens>0?`${Math.round(S.stats.tokens/1e3)}k tok`:"",S.stats.durationMs>0?`${Math.round(S.stats.durationMs/1e3)}s`:""].filter(Boolean).join(" \xB7 ");x&&R.push(x),e.replRenderer.writeLine(jt({kind:S.status==="succeeded"?"checkpoint":"diagnosis",title:`${E} ${S.id} ${S.label}`,body:R})),e.replRenderer.writeLine("")}let h=c.renderIfChanged(e.stats.sessionId);if(h.length>0){for(let S of h)e.replRenderer.writeLine(S);e.replRenderer.writeLine("")}let b=d.render();b&&e.replRenderer.writeLine(b);let y,w;if(l!==void 0){let S=l;l=void 0;let E=nk(e.stats.model,e.stats.planMode),R=yo({buffer:S.text,promptText:E,isTTY:!!process.stdout.isTTY,attachmentSummary:ca([...S.attachments])});e.replRenderer.writeLine(R),y=S.text.trim(),w=S.attachments}else{let S=await Kb({rl:e.rl,promptFn:()=>nk(e.stats.model,e.stats.planMode),onSigint:r,statusLine:e.statusLine,compositor:n.activeCompositor??void 0,history:i,autocompleteState:a,onShiftTab:()=>{let E=e.slashCtx;E.stats.planMode&&E.stats.pendingPlanExit?(E.stats.pendingPlanExit=!1,At(E,!1,{closureSummarySkipped:!0}).catch(()=>{})):At(E).catch(()=>{}),e.statusLine.rearm()}});y=S.text.trim(),w=S.attachments}if(!y&&w.length===0)continue;let v=!1;if(y.startsWith("/")){let S=await Bg(y,e.slashCtx,w);if(S.handled){if(S.result==="exit"){e.rl.close();return}if((y==="/clear"||y.startsWith("/clear "))&&(await t.rotateOnClear(),e.replRenderer.writeLine(m.dim(` transcript: ${t.path()}`)),d.reset()),S.result!==null&&typeof S.result=="object"&&"kind"in S.result&&S.result.kind==="submit"){l={text:S.result.message,attachments:w??[]},e.statusLine.rearm();continue}e.statusLine.rearm();continue}v=!0}i.push(y);let A=y;if(v){let S=ac(y);if(S){let E=S.name.replace(/^\//,"").split(":").pop()??"";if(E&&Fc(E)){let R={skillName:E,rawArgs:S.args,source:"plugin",capabilities:{compose:!0,subagents:!0}},x=e.session.current.sessionId,O=To(x),P=Date.now();V(`[afk trace] preflight.start commandName=${E}`);let $=!1,I=await vo(R,{cwd:process.cwd(),artifactDir:O},N=>{Oe()&&e.replRenderer.writeLine(m.warning(`\u26A0 preflight(${E}) failed: `)+(N instanceof Error?N.message:String(N)))});$=I!==null,V(`[afk trace] preflight.end commandName=${E} durationMs=${Date.now()-P} success=${$}`),A=Bc(I?.manifestBlock,y)}}}let T;if(e.firstTurnHook&&e.stats.totalTurns===0){let S=e.firstTurnHook;e.firstTurnHook=void 0,T=Promise.resolve().then(()=>S(y)).catch(E=>{e.completionWriter.fn(m.warning("\u26A0 ")+"first-turn hook failed: "+(E instanceof Error?E.message:String(E)))})}let _=await Qb({text:A,attachments:w},e.session.current,e.stats,{setInFlight(S){n.turnInFlight=S},async onTurnComplete(S,E){await t.appendTurn(S,E)},async onAfterTurn(){await e.contextSampler.onTurn(e.stats.totalTurns),await th(e.slashCtx),e.statusLine.rearm()},rearmStatus:()=>e.statusLine.rearm(),onTerminalState:S=>d.push(S),setActiveCompositor:S=>{n.activeCompositor=S,e.replRenderer.setCompositor(S)},scrollRegion:e.statusLine},e.options.thinkingUi,e.completionWriter,u,{history:i,autocompleteState:a});l=_!==void 0?{text:_,attachments:[]}:void 0,T!==void 0&&await T}}finally{for(let h of u.running())u.cancel(h.id);p.stop(),c.dispose()}}import{promises as t$}from"node:fs";import{dirname as n$,join as r$}from"node:path";import{randomBytes as o$}from"node:crypto";import e$ from"@anthropic-ai/sdk";import{randomUUID as ok}from"node:crypto";async function sk(e){let{token:t,model:n,system:r,user:o,maxTokens:s=64,signal:i,clientFactory:a}=e;if(!t)throw new Error("oneShotCompletion: token required");let l=rs(t),c=Br(t,l),d=a?a(c):new e$(c),u=ok(),p=ok(),f=St(l,u,p),g={};Object.keys(f).length>0&&(g.headers=f),i&&(g.signal=i);let h=await d.messages.create({model:n,max_tokens:s,system:r,messages:[{role:"user",content:o}]},Object.keys(g).length>0?g:void 0),b=[];for(let w of h.content)w.type==="text"&&b.push(w.text);let y=b.join("").trim();return y.length===0&&console.warn("oneShotCompletion: response contained no text blocks \u2014 returning empty string"),y}var s$=["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(`
1997
- `),ik=/^[a-z0-9]+(-[a-z0-9]+){1,3}$/,du=30,i$=1024,a$=8e3,l$="haiku";async function c$(e,t){let n=e.trim();if(n.length===0||n.startsWith("/"))return null;let r=m$(n,i$),o=new AbortController,s=setTimeout(()=>o.abort(),t.timeoutMs??a$),i=t.signal?f$([t.signal,o.signal]):o.signal,a;try{t.slugGenerator?a=await t.slugGenerator(r,i):a=await sk({token:t.token,model:t.model??l$,system:s$,user:r,maxTokens:32,signal:i})}catch{return null}finally{clearTimeout(s)}let l=u$(a);if(l===null)return null;let c=n$(t.worktreePath);return await d$(l,c)}function u$(e){let t=e.trim().toLowerCase();if(t.length===0)return null;if(ik.test(t)&&t.length<=du)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>du)break;o=i}return ik.test(o)?o:null}async function d$(e,t){if(!await p$(r$(t,e)))return e;let n=o$(2).toString("hex");return`${e.split("-").slice(0,3).join("-").slice(0,du-5)}-${n}`}async function p$(e){try{return await t$.access(e),!0}catch{return!1}}function m$(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 f$(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 ak(e){let t=await c$(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}:{}});if(t===null)return{status:"skipped",reason:"slug generation returned null"};let r=await(e.renameFn??Hm)(e.handle,t,e.branchPrefix!==void 0?{branchPrefix:e.branchPrefix}:void 0);return r.ok?(e.session&&e.session.setCwd(r.newPath),{status:"renamed",oldPath:r.oldPath,newPath:r.newPath,oldBranch:r.oldBranch,newBranch:r.newBranch}):(r.partial==="branch"&&e.session&&e.session.setCwd(e.handle.path),{status:"failed",reason:r.reason,...r.partial!==void 0?{partial:r.partial}:{}})}L();import{spawn as lk}from"child_process";import{existsSync as k$,mkdirSync as w$,readFileSync as ck,unlinkSync as S$,writeFileSync as v$}from"fs";import{get as T$}from"https";import{join as uk}from"path";import{readFileSync as g$}from"fs";import{dirname as h$,join as y$}from"path";import{fileURLToPath as b$}from"url";function Pt(){try{return"3.8.5"}catch{}try{let e=h$(b$(import.meta.url));for(let t of["../../package.json","../package.json"])try{let n=JSON.parse(g$(y$(e,t),"utf-8"));if(typeof n.version=="string")return n.version}catch{}}catch{}return"0.0.0-unknown"}var x$=64*1024,E$=1440*60*1e3,R$="update-check.json",A$="pending-update.json";function dk(){return uk(qo(),R$)}function pu(){return uk(qo(),A$)}function pk(){let e=qo();k$(e)||w$(e,{recursive:!0})}function C$(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 P$(){try{let e=ck(dk(),"utf-8"),t=JSON.parse(e);if(typeof t.latestVersion=="string"&&typeof t.checkedAt=="number")return t}catch{}return null}function I$(){try{pk();let e=`
1997
+ `),ik=/^[a-z0-9]+(-[a-z0-9]+){1,3}$/,du=30,i$=1024,a$=8e3,l$="haiku";async function c$(e,t){let n=e.trim();if(n.length===0||n.startsWith("/"))return null;let r=m$(n,i$),o=new AbortController,s=setTimeout(()=>o.abort(),t.timeoutMs??a$),i=t.signal?f$([t.signal,o.signal]):o.signal,a;try{t.slugGenerator?a=await t.slugGenerator(r,i):a=await sk({token:t.token,model:t.model??l$,system:s$,user:r,maxTokens:32,signal:i})}catch{return null}finally{clearTimeout(s)}let l=u$(a);if(l===null)return null;let c=n$(t.worktreePath);return await d$(l,c)}function u$(e){let t=e.trim().toLowerCase();if(t.length===0)return null;if(ik.test(t)&&t.length<=du)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>du)break;o=i}return ik.test(o)?o:null}async function d$(e,t){if(!await p$(r$(t,e)))return e;let n=o$(2).toString("hex");return`${e.split("-").slice(0,3).join("-").slice(0,du-5)}-${n}`}async function p$(e){try{return await t$.access(e),!0}catch{return!1}}function m$(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 f$(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 ak(e){let t=await c$(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}:{}});if(t===null)return{status:"skipped",reason:"slug generation returned null"};let r=await(e.renameFn??Hm)(e.handle,t,e.branchPrefix!==void 0?{branchPrefix:e.branchPrefix}:void 0);return r.ok?(e.session&&e.session.setCwd(r.newPath),{status:"renamed",oldPath:r.oldPath,newPath:r.newPath,oldBranch:r.oldBranch,newBranch:r.newBranch}):(r.partial==="branch"&&e.session&&e.session.setCwd(e.handle.path),{status:"failed",reason:r.reason,...r.partial!==void 0?{partial:r.partial}:{}})}L();import{spawn as lk}from"child_process";import{existsSync as k$,mkdirSync as w$,readFileSync as ck,unlinkSync as S$,writeFileSync as v$}from"fs";import{get as T$}from"https";import{join as uk}from"path";import{readFileSync as g$}from"fs";import{dirname as h$,join as y$}from"path";import{fileURLToPath as b$}from"url";function Pt(){try{return"3.8.6"}catch{}try{let e=h$(b$(import.meta.url));for(let t of["../../package.json","../package.json"])try{let n=JSON.parse(g$(y$(e,t),"utf-8"));if(typeof n.version=="string")return n.version}catch{}}catch{}return"0.0.0-unknown"}var x$=64*1024,E$=1440*60*1e3,R$="update-check.json",A$="pending-update.json";function dk(){return uk(qo(),R$)}function pu(){return uk(qo(),A$)}function pk(){let e=qo();k$(e)||w$(e,{recursive:!0})}function C$(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 P$(){try{let e=ck(dk(),"utf-8"),t=JSON.parse(e);if(typeof t.latestVersion=="string"&&typeof t.checkedAt=="number")return t}catch{}return null}function I$(){try{pk();let e=`
1998
1998
  const https = require('https');
1999
1999
  const fs = require('fs');
2000
2000
  const url = 'https://registry.npmjs.org/agent-afk/latest';
package/dist/index.mjs CHANGED
@@ -1515,7 +1515,7 @@ Create a ship-ready summary with next steps.`,l=await a.runToResult(c);if(l.stat
1515
1515
  - Use absolute paths for file operations.
1516
1516
  - Prefer \`agent\` (and \`skill\`) for multi-file investigation, verification, parallel hypotheses, and any work that would otherwise consume large amounts of inline context. The main session is the coordinator; subagents are the investigators.
1517
1517
 
1518
- When you see a \`<command-name>\` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch the same skill again. Instead, treat the \`<command-message>\` as the skill name and \`<command-args>\` as its arguments, then follow the instructions in the body block immediately following the tag.`,jn=`# Cross-Session Memory
1518
+ When you see a \`<command-name>\` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch that same skill again. Instead, treat the \`<command-message>\` as the skill name and \`<command-args>\` as its arguments, then follow the instructions in the body block immediately following the tag. You MAY still invoke the skill tool to dispatch OTHER skills that are not the one already loaded.`,jn=`# Cross-Session Memory
1519
1519
 
1520
1520
  You have three tools for persisting knowledge across sessions: memory_search, memory_update, and procedure_write.
1521
1521
 
package/dist/telegram.mjs CHANGED
@@ -1561,7 +1561,7 @@ Create a ship-ready summary with next steps.`,l=await a.runToResult(c);if(l.stat
1561
1561
  - Use absolute paths for file operations.
1562
1562
  - Prefer \`agent\` (and \`skill\`) for multi-file investigation, verification, parallel hypotheses, and any work that would otherwise consume large amounts of inline context. The main session is the coordinator; subagents are the investigators.
1563
1563
 
1564
- When you see a \`<command-name>\` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch the same skill again. Instead, treat the \`<command-message>\` as the skill name and \`<command-args>\` as its arguments, then follow the instructions in the body block immediately following the tag.`,br=`# Cross-Session Memory
1564
+ When you see a \`<command-name>\` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch that same skill again. Instead, treat the \`<command-message>\` as the skill name and \`<command-args>\` as its arguments, then follow the instructions in the body block immediately following the tag. You MAY still invoke the skill tool to dispatch OTHER skills that are not the one already loaded.`,br=`# Cross-Session Memory
1565
1565
 
1566
1566
  You have three tools for persisting knowledge across sessions: memory_search, memory_update, and procedure_write.
1567
1567
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-afk",
3
- "version": "3.8.5",
3
+ "version": "3.8.6",
4
4
  "description": "CLI tool for interacting with AI agents via multiple interfaces",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",