| 3961 | duration_ms: ${q.totalDurationMs}</usage>`}]}}throw Error(`Unexpected agent tool result status: ${q.status}`)},renderToolResultMessage:mKK,renderToolUseMessage:pKK,renderToolUseTag:BKK,renderToolUseProgressMessage:cE6,renderToolUseRejectedMessage:gKK,renderToolUseErrorMessage:FKK,renderGroupedToolUse:UKK})});function Qb8(){return N4Y??=[i_,QX,UX,kb,$R,R4,qp,Qm8]}var N4Y;var Nr1=y(()=>{rb8();p0();LK6();$p();ka();tL6();lj6();eL6()});import{normalize as y4Y,posix as SXK,win32 as CXK}from"path";function E4Y(q){return q.split(CXK.sep).join(SXK.sep)}function ba(q){let K=E4Y(q);return V67?K.toLowerCase():K}function l88(q){let K=c1(),_=ba(q),z=ba(K);if(!_.startsWith(z))return null;if(_.includes("/session-memory/")&&_.endsWith(".md"))return"session_memory";if(_.includes("/projects/")&&_.endsWith(".jsonl"))return"session_transcript";return null}function cm8(q){let K=q.split(CXK.sep).join(SXK.sep);if(K.includes("session-memory")&&(K.includes(".md")||K.endsWith("*")))return"session_memory";if(K.includes(".jsonl")||K.includes("projects")&&K.includes("*.jsonl"))return"session_transcript";return null}function pR6(q){if(l3())return f16(q);return!1}function L4Y(q){if(l3())return i88(q);return!1}function AH6(q){if(pR6(q))return!0;if(k67.isTeamMemFile(q))return!0;if(l88(q)!==null)return!0;if(L4Y(q))return!0;return!1}function N67(q){let K=y4Y(q),_=ba(K);if(l3()&&(_.includes("/agent-memory/")||_.includes("/agent-memory-local/")))return!0;if(k67.isTeamMemoryEnabled()&&k67.isTeamMemPath(K))return!0;if(l3()){let O=Vj(),w=ba(O.replace(/[/\\]+$/,"")),j=ba(O);if(_===w||_.startsWith(j))return!0}let z=ba(c1()),Y=ba(D16()),$=_.startsWith(z),A=_.startsWith(Y);if(!$&&!A)return!1;if(_.includes("/session-memory/"))return!0;if($&&_.includes("/projects/"))return!0;if(l3()&&_.includes("/memory/"))return!0;return!1}function bXK(q){let K=c1(),_=D16(),z=l3()?Vj().replace(/[/\\]+$/,""):"",Y=ba(q);if(![K,_,z].filter(Boolean).some((w)=>{if(Y.includes(ba(w)))return!0;if(V67)return Y.includes(ff(w).toLowerCase());return!1}))return!1;let O=q.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!O)return!1;for(let w of O){let j=w.replace(/[,;|&>]+$/,""),H=V67?w_6(j):j;if(AH6(H)||N67(H))return!0}return!1}function xXK(q){if(cm8(q)!==null)return!0;if(l3()&&(q.replace(/\\/g,"/").includes("agent-memory/")||q.replace(/\\/g,"/").includes("agent-memory-local/")))return!0;return!1}var k67,V67;var n88=y(()=>{rw();pu();m8();NB();k67=(YL(),Eq(Pi)),V67=process.platform==="win32"});var IXK={};T8(IXK,{isTeamMemoryWriteOrEdit:()=>h4Y,isTeamMemorySearch:()=>R4Y,isTeamMemFile:()=>Lc6,appendTeamMemorySummaryParts:()=>S4Y});function R4Y(q){let K=q;if(!K)return!1;if(K.path&&Lc6(K.path))return!0;return!1}function h4Y(q,K){if(q!==tK&&q!==X4)return!1;let _=K,z=_?.file_path??_?.path;return z!==void 0&&Lc6(z)}function S4Y(q,K,_){let z=q.teamMemoryReadCount??0,Y=q.teamMemorySearchCount??0,$=q.teamMemoryWriteCount??0;if(z>0){let A=K?_.length===0?"Recalling":"recalling":_.length===0?"Recalled":"recalled";_.push(`${A} ${z} team ${z===1?"memory":"memories"}`)}if(Y>0){let A=K?_.length===0?"Searching":"searching":_.length===0?"Searched":"searched";_.push(`${A} team memories`)}if($>0){let A=K?_.length===0?"Writing":"writing":_.length===0?"Wrote":"wrote";_.push(`${A} ${$} team ${$===1?"memory":"memories"}`)}}var uXK=y(()=>{YL();E2()});function C4Y(q){let K=q;return K?.file_path??K?.path}function b4Y(q){let K=q;if(!K)return!1;if(K.path){if(AH6(K.path)||N67(K.path))return!0}if(K.glob&&xXK(K.glob))return!0;if(K.command&&bXK(K.command))return!0;return!1}function x4Y(q,K){if(q!==tK&&q!==X4)return!1;let _=C4Y(K);return _!==void 0&&AH6(_)}function y67(q){let K="$ "+q.split(` |
| 3962 | `).map((_)=>_.replace(/\s+/g," ").trim()).filter((_)=>_!=="").join(` |
| 3963 | `);return K.length>mXK?K.slice(0,mXK-1)+"…":K}function OH6(q,K,_){if(q===FS)return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!0,isMemoryWrite:!1,isAbsorbedSilently:!0};if(x4Y(q,K))return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!0,isAbsorbedSilently:!1};if(p4()&&q===CP)return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!0};let z=L5(_,q)??L5(Qb8(),q);if(!z?.isSearchOrReadCommand)return{isCollapsible:!1,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!1};let Y=z.isSearchOrReadCommand(K),$=Y.isList??!1,A=Y.isSearch||Y.isRead||$;return{isCollapsible:A||(p4()?q===_q:!1),isSearch:Y.isSearch,isRead:Y.isRead,isList:$,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!1,...z.isMcp&&{mcpServerName:z.mcpInfo?.serverName},isBash:p4()?!A&&q===_q:void 0}}function ie6(q,K){if(q?.type==="tool_use"&&q.name){let _=OH6(q.name,q.input,K);if(_.isCollapsible||_.isREPL)return{isSearch:_.isSearch,isRead:_.isRead,isList:_.isList,isREPL:_.isREPL,isMemoryWrite:_.isMemoryWrite,isAbsorbedSilently:_.isAbsorbedSilently,mcpServerName:_.mcpServerName,isBash:_.isBash}}return null}function lm8(q,K,_){return OH6(q,K,_).isCollapsible}function I4Y(q,K){if(q.type==="assistant"){let _=q.message.content[0],z=ie6(_,K);if(z&&_?.type==="tool_use")return{name:_.name,input:_.input,...z}}if(q.type==="grouped_tool_use"){let _=q.messages[0]?.message.content[0],z=ie6(_?{type:"tool_use",name:q.toolName,input:_.input}:void 0,K);if(z&&_?.type==="tool_use")return{name:q.toolName,input:_.input,...z}}return null}function u4Y(q){if(q.type==="assistant"){let K=q.message.content[0];if(K?.type==="text"&&K.text.trim().length>0)return!0}return!1}function m4Y(q,K){if(q.type==="assistant"){let _=q.message.content[0];if(_?.type==="tool_use"&&!lm8(_.name,_.input,K))return!0}if(q.type==="grouped_tool_use"){let _=q.messages[0]?.message.content[0];if(_?.type==="tool_use"&&!lm8(q.toolName,_.input,K))return!0}return!1}function p4Y(q){return q.type==="system"&&q.subtype==="stop_hook_summary"&&q.hookLabel==="PreToolUse"}function B4Y(q){if(q.type==="assistant"){let K=q.message.content[0];if(K?.type==="thinking"||K?.type==="redacted_thinking")return!0}if(q.type==="attachment")return!0;if(q.type==="system")return!0;return!1}function g4Y(q,K){if(q.type==="assistant"){let _=q.message.content[0];return _?.type==="tool_use"&&lm8(_.name,_.input,K)}if(q.type==="grouped_tool_use"){let _=q.messages[0]?.message.content[0];return _?.type==="tool_use"&&lm8(q.toolName,_.input,K)}return!1}function F4Y(q,K){if(q.type==="user"){let _=q.message.content.filter((z)=>z.type==="tool_result");return _.length>0&&_.every((z)=>K.has(z.tool_use_id))}return!1}function E67(q){if(q.type==="assistant"){let K=q.message.content[0];if(K?.type==="tool_use")return[K.id]}if(q.type==="grouped_tool_use")return q.messages.map((K)=>{let _=K.message.content[0];return _.type==="tool_use"?_.id:""}).filter(Boolean);return[]}function UE6(q){let K=[];for(let _ of q.messages)K.push(...E67(_));return K}function L67(q,K){return UE6(q).some((_)=>K.has(_))}function BXK(q){let K=q.displayMessage;if(K.type==="grouped_tool_use")return K.displayMessage;return K}function BR6(q){if(q.type==="grouped_tool_use")return q.messages.length;return 1}function U4Y(q){let K=[];if(q.type==="assistant"){let _=q.message.content[0];if(_?.type==="tool_use"){let z=_.input;if(z?.file_path)K.push(z.file_path)}}else if(q.type==="grouped_tool_use")for(let _ of q.messages){let z=_.message.content[0];if(z?.type==="tool_use"){let Y=z.input;if(Y?.file_path)K.push(Y.file_path)}}return K}function Q4Y(q,K){if(q.type!=="user")return;let _=q.toolUseResult;if(!_?.stdout&&!_?.stderr)return;let z=(_.stdout??"")+` |
| 3964 | `+(_.stderr??"");for(let Y of q.message.content){if(Y.type!=="tool_result")continue;let $=K.bashCommands?.get(Y.tool_use_id);if(!$)continue;let{commit:A,push:O,branch:w,pr:j}=gzK($,z);if(A)K.commits?.push(A);if(O)K.pushes?.push(O);if(w)K.branches?.push(w);if(j)K.prs?.push(j);if(A||O||w||j)K.gitOpBashCount=(K.gitOpBashCount??0)+1}}function pXK(){let q={messages:[],searchCount:0,readFilePaths:new Set,readOperationCount:0,listCount:0,toolUseIds:new Set,memorySearchCount:0,memoryReadFilePaths:new Set,memoryWriteCount:0,nonMemSearchArgs:[],latestDisplayHint:void 0,hookTotalMs:0,hookCount:0,hookInfos:[]};if(q.teamMemorySearchCount=0,q.teamMemoryReadFilePaths=new Set,q.teamMemoryWriteCount=0,q.mcpCallCount=0,q.mcpServerNames=new Set,p4())q.bashCount=0,q.bashCommands=new Map,q.commits=[],q.pushes=[],q.branches=[],q.prs=[],q.gitOpBashCount=0;return q}function d4Y(q){let K=q.messages[0],_=q.readFilePaths.size>0?q.readFilePaths.size:q.readOperationCount,z=q.memoryReadFilePaths.size,Y=z+(q.relevantMemories?.length??0),$=q.teamMemoryReadFilePaths,A=[...q.readFilePaths].filter((J)=>!q.memoryReadFilePaths.has(J)&&!($?.has(J)??!1)),O=q.teamMemorySearchCount??0,w=q.teamMemoryReadFilePaths?.size??0,j=q.teamMemoryWriteCount??0,H={type:"collapsed_read_search",searchCount:Math.max(0,q.searchCount-q.memorySearchCount-O),readCount:Math.max(0,_-z-w),listCount:q.listCount,replCount:0,memorySearchCount:q.memorySearchCount,memoryReadCount:Y,memoryWriteCount:q.memoryWriteCount,readFilePaths:A,searchArgs:q.nonMemSearchArgs,latestDisplayHint:q.latestDisplayHint,messages:q.messages,displayMessage:K,uuid:`collapsed-${K.uuid}`,timestamp:K.timestamp};if(H.teamMemorySearchCount=O,H.teamMemoryReadCount=w,H.teamMemoryWriteCount=j,(q.mcpCallCount??0)>0)H.mcpCallCount=q.mcpCallCount,H.mcpServerNames=[...q.mcpServerNames??[]];if(p4()){if((q.bashCount??0)>0)H.bashCount=q.bashCount,H.gitOpBashCount=q.gitOpBashCount;if((q.commits?.length??0)>0)H.commits=q.commits;if((q.pushes?.length??0)>0)H.pushes=q.pushes;if((q.branches?.length??0)>0)H.branches=q.branches;if((q.prs?.length??0)>0)H.prs=q.prs}if(q.hookCount>0)H.hookTotalMs=q.hookTotalMs,H.hookCount=q.hookCount,H.hookInfos=q.hookInfos;if(q.relevantMemories&&q.relevantMemories.length>0)H.relevantMemories=q.relevantMemories;return H}function gXK(q,K){let _=[],z=pXK(),Y=[];function $(){if(z.messages.length===0)return;_.push(d4Y(z));for(let A of Y)_.push(A);Y=[],z=pXK()}for(let A of q)if(g4Y(A,K)){let O=I4Y(A,K);if(O.isMemoryWrite){let w=BR6(A);if(r88?.isTeamMemoryWriteOrEdit(O.name,O.input))z.teamMemoryWriteCount=(z.teamMemoryWriteCount??0)+w;else z.memoryWriteCount+=w}else if(O.isAbsorbedSilently);else if(O.mcpServerName){let w=BR6(A);z.mcpCallCount=(z.mcpCallCount??0)+w,z.mcpServerNames?.add(O.mcpServerName);let j=O.input;if(j?.query)z.latestDisplayHint=`"${j.query}"`}else if(p4()&&O.isBash){let w=BR6(A);z.bashCount=(z.bashCount??0)+w;let j=O.input;if(j?.command){z.latestDisplayHint=UN8(j.command)??y67(j.command);for(let H of E67(A))z.bashCommands?.set(H,j.command)}}else if(O.isList){z.listCount+=BR6(A);let w=O.input;if(w?.command)z.latestDisplayHint=y67(w.command)}else if(O.isSearch){let w=BR6(A);if(z.searchCount+=w,r88?.isTeamMemorySearch(O.input))z.teamMemorySearchCount=(z.teamMemorySearchCount??0)+w;else if(b4Y(O.input))z.memorySearchCount+=w;else{let j=O.input;if(j?.pattern)z.nonMemSearchArgs.push(j.pattern),z.latestDisplayHint=`"${j.pattern}"`}}else{let w=U4Y(A);for(let j of w)if(z.readFilePaths.add(j),r88?.isTeamMemFile(j))z.teamMemoryReadFilePaths?.add(j);else if(AH6(j))z.memoryReadFilePaths.add(j);else z.latestDisplayHint=_3(j);if(w.length===0){z.readOperationCount+=BR6(A);let j=O.input;if(j?.command)z.latestDisplayHint=y67(j.command)}}for(let w of E67(A))z.toolUseIds.add(w);z.messages.push(A)}else if(F4Y(A,z.toolUseIds)){if(z.messages.push(A),p4()&&z.bashCommands?.size)Q4Y(A,z)}else if(z.messages.length>0&&p4Y(A))z.hookCount+=A.hookCount,z.hookTotalMs+=A.totalDurationMs??A.hookInfos.reduce((O,w)=>O+(w.durationMs??0),0),z.hookInfos.push(...A.hookInfos);else if(z.messages.length>0&&A.type==="attachment"&&A.attachment.type==="relevant_memories")z.relevantMemories??=[],z.relevantMemories.push(...A.attachment.memories);else if(B4Y(A))if(z.messages.length>0&&!(A.type==="attachment"&&A.attachment.type==="nested_memory"))Y.push(A);else _.push(A);else if(u4Y(A))$(),_.push(A);else if(m4Y(A,K))$(),_.push(A);else $(),_.push(A);return $(),_}function ob8(q,K,_,z=0,Y,$=0){let A=[];if(Y){let{memorySearchCount:w,memoryReadCount:j,memoryWriteCount:H}=Y;if(j>0){let J=_?A.length===0?"Recalling":"recalling":A.length===0?"Recalled":"recalled";A.push(`${J} ${j} ${j===1?"memory":"memories"}`)}if(w>0){let J=_?A.length===0?"Searching":"searching":A.length===0?"Searched":"searched";A.push(`${J} memories`)}if(H>0){let J=_?A.length===0?"Writing":"writing":A.length===0?"Wrote":"wrote";A.push(`${J} ${H} ${H===1?"memory":"memories"}`)}if(r88)r88.appendTeamMemorySummaryParts(Y,_,A)}if(q>0){let w=_?A.length===0?"Searching for":"searching for":A.length===0?"Searched for":"searched for";A.push(`${w} ${q} ${q===1?"pattern":"patterns"}`)}if(K>0){let w=_?A.length===0?"Reading":"reading":A.length===0?"Read":"read";A.push(`${w} ${K} ${K===1?"file":"files"}`)}if($>0){let w=_?A.length===0?"Listing":"listing":A.length===0?"Listed":"listed";A.push(`${w} ${$} ${$===1?"directory":"directories"}`)}if(z>0){let w=_?"REPL'ing":"REPL'd";A.push(`${w} ${z} ${z===1?"time":"times"}`)}let O=A.join(", ");return _?`${O}…`:O}function $E6(q){if(q.length===0)return;let K=0,_=0;for(let Y=q.length-1;Y>=0;Y--){let $=q[Y];if($.isSearch)K++;else if($.isRead)_++;else break}if(K+_>=2)return ob8(K,_,!0);for(let Y=q.length-1;Y>=0;Y--)if(q[Y]?.activityDescription)return q[Y].activityDescription;return}var r88,mXK=300;var Bo=y(()=>{Bq();E2();k16();Nr1();Q68();rF();bK();_M();n88();r88=(uXK(),Eq(IXK))});function dw6(){return{toolUseCount:0,latestInputTokens:0,cumulativeOutputTokens:0,recentActivities:[]}}function na6(q){return q.latestInputTokens+q.cumulativeOutputTokens}function oq6(q,K,_,z){if(K.type!=="assistant")return;let Y=K.message.usage;q.latestInputTokens=Y.input_tokens+(Y.cache_creation_input_tokens??0)+(Y.cache_read_input_tokens??0),q.cumulativeOutputTokens+=Y.output_tokens;for(let $ of K.message.content)if($.type==="tool_use"){if(q.toolUseCount++,$.name!==MD){let A=$.input,O=z?OH6($.name,A,z):void 0;q.recentActivities.push({toolName:$.name,input:A,activityDescription:_?.($.name,A),isSearch:O?.isSearch,isRead:O?.isRead})}}while(q.recentActivities.length>c4Y)q.recentActivities.shift()}function Ao(q){return{toolUseCount:q.toolUseCount,tokenCount:na6(q),lastActivity:q.recentActivities.length>0?q.recentActivities[q.recentActivities.length-1]:void 0,recentActivities:[...q.recentActivities]}}function cw6(q){return(K,_)=>{return L5(q,K)?.getActivityDescription?.(_)??void 0}}function EJ(q){return typeof q==="object"&&q!==null&&"type"in q&&q.type==="local_agent"}function FXK(q){return EJ(q)&&q.agentType!=="main-session"}function Um8(q,K,_){A3(q,_,(z)=>({...z,pendingMessages:[...z.pendingMessages,K]}))}function UXK(q,K,_){A3(q,_,(z)=>({...z,messages:[...z.messages??[],K]}))}function QXK(q,K,_){let z=K().tasks[q];if(!EJ(z)||z.pendingMessages.length===0)return[];let Y=z.pendingMessages;return A3(q,_,($)=>({...$,pendingMessages:[]})),Y}function iq6({taskId:q,description:K,status:_,error:z,setAppState:Y,finalMessage:$,usage:A,toolUseId:O,worktreePath:w,worktreeBranch:j}){let H=!1;if(A3(q,Y,(G)=>{if(G.notified)return G;return H=!0,{...G,notified:!0}}),!H)return;ou(Y);let J=_==="completed"?`Agent "${K}" completed`:_==="failed"?`Agent "${K}" failed: ${z||"Unknown error"}`:`Agent "${K}" was stopped`,M=sz(q),X=O?` |
| 3965 | <${gT}>${O}</${gT}>`:"",P=$?` |
| 3966 | <result>${$}</result>`:"",W=A?` |
| 3967 | <usage><total_tokens>${A.totalTokens}</total_tokens><tool_uses>${A.toolUses}</tool_uses><duration_ms>${A.durationMs}</duration_ms></usage>`:"",D=w?` |
| 3968 | <${oq1}><${aq1}>${w}</${aq1}>${j?`<${sq1}>${j}</${sq1}>`:""}</${oq1}>`:"",f=`<${XA}> |
| 3969 | <${jP}>${q}</${jP}>${X} |
| 3970 | <${FT}>${M}</${FT}> |
| 3971 | <${wj}>${_}</${wj}> |
| 3972 | <${gw}>${J}</${gw}>${P}${W}${D} |
| 3973 | </${XA}>`;IO({value:f,mode:"task-notification"})}function aq6(q,K){let _=!1;if(A3(q,K,(z)=>{if(z.status!=="running")return z;return _=!0,z.abortController?.abort(),z.unregisterCleanup?.(),{...z,status:"killed",endTime:Date.now(),evictAfter:z.retain?void 0:Date.now()+BN8,abortController:void 0,unregisterCleanup:void 0,selectedAgent:void 0}}),_)Zw(q)}function dXK(q,K){for(let[_,z]of Object.entries(q))if(z.type==="local_agent"&&z.status==="running")aq6(_,K)}function cXK(q,K){A3(q,K,(_)=>{if(_.notified)return _;return{..._,notified:!0}})}function ia6(q,K,_){A3(q,_,(z)=>{if(z.status!=="running")return z;let Y=z.progress?.summary;return{...z,progress:Y?{...K,summary:Y}:K}})}function _5K(q,K,_){let z=null;if(A3(q,_,(Y)=>{if(Y.status!=="running")return Y;return z={tokenCount:Y.progress?.tokenCount??0,toolUseCount:Y.progress?.toolUseCount??0,startTime:Y.startTime,toolUseId:Y.toolUseId},{...Y,progress:{...Y.progress,toolUseCount:Y.progress?.toolUseCount??0,tokenCount:Y.progress?.tokenCount??0,summary:K}}}),z&&sp()){let{tokenCount:Y,toolUseCount:$,startTime:A,toolUseId:O}=z;VL8({taskId:q,toolUseId:O,description:K,startTime:A,totalTokens:Y,toolUses:$,summary:K})}}function hL8(q,K){let _=q.agentId;A3(_,K,(z)=>{if(z.status!=="running")return z;return z.unregisterCleanup?.(),{...z,status:"completed",result:q,endTime:Date.now(),evictAfter:z.retain?void 0:Date.now()+BN8,abortController:void 0,unregisterCleanup:void 0,selectedAgent:void 0}}),Zw(_)}function SL8(q,K,_){A3(q,_,(z)=>{if(z.status!=="running")return z;return z.unregisterCleanup?.(),{...z,status:"failed",error:K,endTime:Date.now(),evictAfter:z.retain?void 0:Date.now()+BN8,abortController:void 0,unregisterCleanup:void 0,selectedAgent:void 0}}),Zw(q)}function Fm8({agentId:q,description:K,prompt:_,selectedAgent:z,setAppState:Y,parentAbortController:$,toolUseId:A}){zH6(q,c0(pO(q)));let O=$?bC($):P3(),w={...C0(q,"local_agent",K,A),type:"local_agent",status:"running",agentId:q,prompt:_,selectedAgent:z,agentType:z.agentType??"general-purpose",abortController:O,retrieved:!1,lastReportedToolCount:0,lastReportedTokenCount:0,isBackgrounded:!0,pendingMessages:[],retain:!1,diskLoaded:!1},j=pq(async()=>{aq6(q,Y)});return w.unregisterCleanup=j,H0(w,Y),w}function EXK({agentId:q,description:K,prompt:_,selectedAgent:z,setAppState:Y,autoBackgroundMs:$,toolUseId:A}){zH6(q,c0(pO(q)));let O=P3(),w=pq(async()=>{aq6(q,Y)}),j={...C0(q,"local_agent",K,A),type:"local_agent",status:"running",agentId:q,prompt:_,selectedAgent:z,agentType:z.agentType??"general-purpose",abortController:O,unregisterCleanup:w,retrieved:!1,lastReportedToolCount:0,lastReportedTokenCount:0,isBackgrounded:!1,pendingMessages:[],retain:!1,diskLoaded:!1},H,J=new Promise((X)=>{H=X});gR6.set(q,H),H0(j,Y);let M;if($!==void 0&&$>0){let X=setTimeout((P,W)=>{P((f)=>{let G=f.tasks[W];if(!EJ(G)||G.isBackgrounded)return f;return{...f,tasks:{...f.tasks,[W]:{...G,isBackgrounded:!0}}}});let D=gR6.get(W);if(D)D(),gR6.delete(W)},$,Y,q);M=()=>clearTimeout(X)}return{taskId:q,backgroundSignal:J,cancelAutoBackground:M}}function lXK(q,K,_){let Y=K().tasks[q];if(!EJ(Y)||Y.isBackgrounded)return!1;_((A)=>{let O=A.tasks[q];if(!EJ(O))return A;return{...A,tasks:{...A.tasks,[q]:{...O,isBackgrounded:!0}}}});let $=gR6.get(q);if($)$(),gR6.delete(q);return!0}function LXK(q,K){gR6.delete(q);let _;K((z)=>{let Y=z.tasks[q];if(!EJ(Y)||Y.isBackgrounded)return z;_=Y.unregisterCleanup;let{[q]:$,...A}=z.tasks;return{...z,tasks:A}}),_?.()}var c4Y=5,Jm8,gR6;var gP=y(()=>{v8();RY();Yw6();GN();Bq();GU();M0();B2();c9();Bo();p2();_K();Ij();J0();ZF1();Jm8={name:"LocalAgentTask",type:"local_agent",async kill(q,K){aq6(q,K)}};gR6=new Map});import{stat as n4Y}from"fs/promises";function s4Y(q){let K=q.trimEnd().split(` |
| 3974 | `).pop()??"";return a4Y.some((_)=>_.test(K))}function R67(q,K,_,z,Y){if(_==="monitor")return()=>{};let $=sz(q),A=0,O=Date.now(),w=!1,j=setInterval(()=>{n4Y($).then((H)=>{if(H.size>A){A=H.size,O=Date.now();return}if(Date.now()-O<r4Y)return;ot($,o4Y).then(({content:J})=>{if(w)return;if(!s4Y(J)){O=Date.now();return}w=!0,clearInterval(j);let M=z?` |
| 3975 | <${gT}>${z}</${gT}>`:"",X=`${FR6}"${K}" appears to be waiting for interactive input`,P=`<${XA}> |