"use strict";exports.id=7220,exports.ids=[7220],exports.modules={37220:(a,b,c)=>{c.d(b,{observeTask:()=>j});var d=c(53905),e=c(20243),f=c(73024);function g(){return globalThis.__reflexPendingCache||(globalThis.__reflexPendingCache=new Map),globalThis.__reflexPendingCache}async function h(a,b){let c,d=(0,e.Rs)(a,b);try{c=await f.promises.stat(d)}catch{return[]}let h=g().get(d);if(h&&h.mtimeMs===c.mtimeMs&&h.size===c.size)return h.result;let i=function(a,b){let c=new Map;for(let d of a)switch(d.type){case"permission-request":c.set(`p:${d.requestId}`,{kind:"permission",topicId:b,requestId:d.requestId,ts:d.ts,summary:d.tool?`Permission: ${d.tool}`:d.action??"Permission request",...d.description?{details:d.description}:{}});break;case"permission-response":c.delete(`p:${d.requestId}`);break;case"question":c.set(`q:${d.questionId}`,{kind:"question",topicId:b,requestId:d.questionId,ts:d.ts,summary:d.prompt.slice(0,200),...d.choices&&d.choices.length?{details:d.choices.join(" / ")}:{}});break;case"answer":c.delete(`q:${d.questionId}`);break;case"mcp-add-request":c.set(`m:${d.requestId}`,{kind:"mcp-add",topicId:b,requestId:d.requestId,ts:d.ts,summary:`MCP add: ${d.label}`,...d.description?{details:d.description}:{}});break;case"mcp-add-response":c.delete(`m:${d.requestId}`)}return[...c.values()]}(await (0,e.readEvents)(a,b),b);return g().set(d,{mtimeMs:c.mtimeMs,size:c.size,result:i}),i}var i=c(26380);async function j(a){let b=await (0,d.getRoot)(a.rootId);if(!b)return null;let c=await (0,i.getTask)(b.path,a.taskId);if(!c)return null;if(!c.topicId)return{taskId:c.id,status:c.status,topicId:null,lastAssistantText:null,pending:[],recentEvents:[],topicEnded:!1};let f=await (0,e.readEvents)(b.path,c.topicId).catch(()=>[]),g=await h(b.path,c.topicId).catch(()=>[]),j=function(a){let b="";for(let c=a.length-1;c>=0;c--){let d=a[c];if("assistant-delta"===d.type&&"string"==typeof d.text)b=d.text+b;else if("turn-start"===d.type||"agent-start"===d.type)break}if(!b.trim())return null;let c=b.replace(/<<reflex:[^>]+>>[\s\S]*?<<\/reflex:[^>]+>>/g,"").trim();return c?c.length>240?c.slice(0,240)+"…":c:null}(f),k=f.slice(-20).map(a=>({ts:a.ts,kind:a.type})),l=f.some(a=>"turn-end"===a.type||"agent-end"===a.type);return{taskId:c.id,status:c.status,topicId:c.topicId,lastAssistantText:j,pending:g.map(a=>({kind:a.kind,summary:a.summary,requestId:a.requestId})),recentEvents:k,topicEnded:l}}}};