const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BReNcLSo.js","./B7lbTX5X.js","./DrKWWDpL.js","./DsanjglN.js","./CbGRcr-D.js","./CG84LPq-.js","./DsQIgu-4.js","./2PQNgpBd.js","./DgZn9uJn.js","./CudpqN6Z.js","./DYP3EJMY.js","./DTkg6Mnx.js","./DIQmuJJZ.js","./D7w7HllH.js","./DB5ifLM-.js","./CX8DOZuw2.js","./DOqzs8kl2.js","./CxlOpib82.js","./BmWTAsFW.js","./DeO5NWhN.js","./Czb-RtcG.js","./C0nwgWmB.js","./B5XQZRTz.js","./CWxOfblT.js","./CVwAhlPZ.js","./BVC3q6GM.js","./B8PRMiR2.js","./BDDiPmhF.js","./BYJC6_MM.js","./bG-fsHMS.js","./D-eE9s2f.js","./DlZwu-Y7.js","./Cx_-1PHK2.js","./B_DA9RKE2.js","./DOPTvi6T.js","./CvaH7m0y.js","./O2P-f9sv.js","./BQ9wXJVQ2.js","./OnYyYdSr2.js"])))=>i.map(i=>d[i]);
import{n as e,t}from"./DsQIgu-4.js";import{a as n,s as r,t as i}from"./B7lbTX5X.js";e(),Object.freeze({maxRetries:3,baseDelayMs:1e3,maxDelayMs:3e4,backoffMultiplier:2,jitter:!0,retryOnUnknown:!0});async function a(e=3e4,a){let o=[],s=await i(e,a);for(let e of s)await r(e.id,{status:`crashed`,error:`Heartbeat timeout detected during recovery sweep`},a);let c=await n({status:`crashed`},a);for(let e of c){let{getAgentErrorHistory:n}=await t(async()=>{let{getAgentErrorHistory:e}=await import(`./BReNcLSo.js`);return{getAgentErrorHistory:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]),import.meta.url),i=await n(e.id,a),s=i.length>0?i[i.length-1]:null;if(e.errorCount>=5){await r(e.id,{status:`stopped`},a),o.push({agentId:e.id,recovered:!1,action:`abandoned`,reason:`Error count (${e.errorCount}) exceeds threshold (5)`});continue}if(s?.errorType===`permanent`){await r(e.id,{status:`stopped`},a),o.push({agentId:e.id,recovered:!1,action:`abandoned`,reason:`Permanent error: ${s.message}`});continue}await r(e.id,{status:`starting`},a),o.push({agentId:e.id,recovered:!0,action:`restarted`,reason:`Agent reset to starting for re-assignment`})}return o}export{a as recoverCrashedAgents};