"use strict";exports.id=6142,exports.ids=[6142],exports.modules={26142:(a,b,c)=>{c.d(b,{compactDispatcherIfIdle:()=>p,getDispatcherSummary:()=>o,getDispatcherTopic:()=>n});var d=c(73024),e=c(76760),f=c.n(e),g=c(24576),h=c(56843),i=c(17640);function j(){return f().join((0,g.homeRootEntry)().path,"dispatcher.json")}function k(){return f().join((0,g.homeRootEntry)().path,"dispatcher-summary.md")}async function l(){try{return JSON.parse(await d.promises.readFile(j(),"utf8"))}catch{return{}}}async function m(a){await d.promises.mkdir(f().dirname(j()),{recursive:!0}),await d.promises.writeFile(j(),JSON.stringify(a,null,2),"utf8")}async function n(){let a=(0,g.homeRootEntry)(),b=await l();if(b.topicId&&await (0,h.eF)(a.path,b.topicId).catch(()=>null))return{rootId:g.HOME_ROOT_ID,rootPath:a.path,topicId:b.topicId};let c=await (0,i.loadSettings)(),d=c.assignments.chat,e=await (0,h.createTopic)({root:a.path,firstMessage:"Dispatcher",harness:d.harness,model:d.model,language:c.language});return await m({...b,topicId:e.meta.id}),{rootId:g.HOME_ROOT_ID,rootPath:a.path,topicId:e.meta.id}}async function o(a){let b=await l();if(b.topicId!==a||!b.summaryCoveredCount)return null;try{let a=await d.promises.readFile(k(),"utf8");if(!a.trim())return null;return{text:a.trim(),coveredCount:b.summaryCoveredCount}}catch{return null}}async function p(){let a=await l();if(!a.topicId)return;let b=(0,g.homeRootEntry)(),{readEvents:e}=await Promise.resolve().then(c.bind(c,74342)),h=await e(b.path,a.topicId),i=h.length-12;if(i<=1||(a.summaryCoveredCount??0)>=i)return;let j=h[h.length-1],n=j?Date.parse(j.ts):0;if(!Number.isFinite(n)||Date.now()-n<6e5)return;let o=[];for(let a of h.slice(0,i))"user-message"===a.type?o.push(`User: ${a.text}`):"assistant-delta"===a.type&&(o[o.length-1]?.startsWith("Reflex:")?o[o.length-1]+=a.text:o.push(`Reflex: ${a.text}`));let p=o.join("\n").slice(0,24e3);if(!p.trim())return void await m({...a,summaryCoveredCount:i,summaryAt:new Date().toISOString()});let{loadSettings:q}=await Promise.resolve().then(c.bind(c,17640)),{quickComplete:r}=await Promise.resolve().then(c.bind(c,99048)),s=await q(),t=["You maintain a rolling summary of an ongoing dispatcher conversation.\nRewrite the summary so it captures durable context: who/what was discussed, decisions, open threads, things to follow up. Plain text, ≤25 lines, no preamble.\n\n## Current summary",(await d.promises.readFile(k(),"utf8").catch(()=>"")).trim()||"(none yet)","\n## New conversation since then",p].join("\n");try{let b=(await r(s.assignments.quick,t,{timeoutMs:6e4})??"").trim();if(!b)return;await d.promises.mkdir(f().dirname(k()),{recursive:!0}),await d.promises.writeFile(k(),b+"\n","utf8"),await m({...a,summaryCoveredCount:i,summaryAt:new Date().toISOString()})}catch{}}}};