exports.id=9723,exports.ids=[9723],exports.modules={58359:()=>{},93739:()=>{},89287:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});let r=/📄 Session log: (.+?\/([^\/\s]+\.jsonl))/,s=/Request ID: ([^\s\n]+)/,o=/Summary: (.+?)(?:\n─|$)/s;function i(e){let t={content:e},n=r.exec(e);n&&(t.logFileName=n[2]);let i=s.exec(e);i&&(t.requestId=i[1]);let l=o.exec(e);return l&&(t.summary=l[1].trim()),t}},76966:(e,t,n)=>{"use strict";n.d(t,{o:()=>o});var r=n(75748),s=n(98636);async function o(e,t,n,o="claude"){let i=(0,r.vX)(e,t);if(i)try{await (0,s.xN)(t,i.content,n,o)}catch(e){console.error("[recordClaudeConversation] Failed to create log file:",e)}}},98636:(e,t,n)=>{"use strict";n.d(t,{e7:()=>p,xN:()=>d});var r=n(20629),s=n.n(r),o=n(55315),i=n.n(o),l=n(73853);let a=(0,n(93346).Hb)("CM_LOG_DIR")||i().join(process.cwd(),"data","logs");function c(e="claude"){return i().join(a,e)}async function u(e="claude"){let t=c(e);try{await s().access(t)}catch{await s().mkdir(t,{recursive:!0})}}async function d(e,t,n,r="claude"){await u(r);let o=function(e,t="claude"){let n=(0,l.WU)(new Date,"yyyy-MM-dd"),r=`${e}-${n}.md`,s=c(t);return i().join(s,r)}(e,r),a=(0,l.WU)(new Date,"yyyy-MM-dd HH:mm:ss"),d="";try{d=await s().readFile(o,"utf-8")}catch{let t="claude"===r?"Claude Code":"codex"===r?"Codex CLI":"Gemini CLI";d=`# ${t} Conversation Log: ${e}

Created: ${a}

---

`}return d+=`## Conversation at ${a}

### User

${t}

### ${"claude"===r?"Claude":"codex"===r?"Codex":"Gemini"}

${n}

---

`,await s().writeFile(o,d,"utf-8"),o}async function p(e,t="all"){let n=[];for(let r of"all"===t?["claude","codex","gemini"]:[t]){await u(r);let t=c(r);try{let r=(await s().readdir(t)).filter(t=>t.startsWith(`${e}-`)&&t.endsWith(".md")).map(e=>i().join(t,e));n.push(...r)}catch{}}return n.sort().reverse()}},59991:(e,t,n)=>{"use strict";n.d(t,{FN:()=>h,RJ:()=>m,ci:()=>f,cn:()=>C});var r=n(89194),s=n(97425),o=n(75748),i=n(25079),l=n(63661),a=n(76966),c=n(89287),u=n(19377);let d=new Map,p=new Map;function f(e){let t=(0,u.vp)(e).split("\n"),n=-1;for(let e=t.length-1;e>=0;e--)if(/^❯\s+\S/.test(t[e])){n=e;break}let r=n>=0?n+1:0,s=t.slice(r),o=[/CLAUDE_HOOKS_/,/\/bin\/claude/,/^claude\s*$/,/@.*\s+%\s*$/,/^[^⏺]*curl.*POST/,/^[^⏺]*Content-Type/,/^[^⏺]*export\s+CLAUDE_/,/^\s*$/,/^[╭╮╰╯│─\s]+$/,/^[│╭╮╰╯].*[│╭╮╰╯]$/,/Claude Code v[\d.]+/,/^Tips for getting started/,/^Welcome back/,/Run \/init to create/,/^Recent activity/,/^No recent activity/,/▐▛███▜▌|▝▜█████▛▘|▘▘ ▝▝/,/^\s*Opus \d+\.\d+\s*·\s*Claude Max/,/\.com's Organization/,/\?\s*for shortcuts\s*$/,/^─{10,}$/,/^❯\s*$/],i=[];for(let e of s)!o.some(t=>t.test(e))&&e.trim()&&i.push(e);return i.join("\n").trim()}function m(e){let t=e.split("\n"),n=[],r=[/^maenokota@.*%/,/^zsh:/,/^feature-issue-\d+/,/^\s*$/],s=!1,o=[];for(let e of t){if(e.includes("✦")){s=!0;let t=e.indexOf("✦"),n=e.substring(t+1).trim();n&&o.push(n);continue}if(s){if(r.some(t=>t.test(e)))continue;o.push(e)}}if(o.length>0)return o.join("\n").trim();for(let e of t)r.some(t=>t.test(e))||n.push(e);return n.join("\n").trim()}async function g(e,t){let n=(0,s.n)();try{if(!(0,o.gU)(n,e))return console.error(`Worktree ${e} not found, stopping poller`),h(e,t),!1;if(!await (0,r.Lg)(e,t))return h(e,t),!1;let s=(0,o.zl)(n,e,t),d=s?.lastCapturedLine||0,p=await (0,r.NA)(e,t,1e4),g=function(e,t,n){let r=e.split("\n"),s=r.length;for(;s>0&&""===r[s-1].trim();)s--;let o=r.slice(0,s),i=o.length,a=i>0&&t>25&&i+25<t||i>0&&t>50&&i<50;if(!a&&i<t-5)return null;let c=o.slice(Math.max(0,i-20)).join("\n"),{promptPattern:d,separatorPattern:p,thinkingPattern:f,skipPatterns:m}=(0,u.bs)(n),g=(e=60)=>{let t="codex"===n?/^›\s+(?!Implement|Find and fix|Type|Summarize)/:/^[>❯]\s+\S/;for(let n=i-1;n>=Math.max(0,i-e);n--){let e=(0,u.vp)(o[n]);if(t.test(e))return n}return -1};if("claude"===n){let e=o.join("\n"),t=(0,u.vp)(e);if((0,l.F)(t).isPrompt)return{response:t,isComplete:!0,lineCount:i}}let C=(0,u.vp)(c),h=d.test(C),$=p.test(C),y=f.test(C),w=("codex"===n||"gemini"===n)&&h&&!y,x="claude"===n&&h&&$&&!y;if(w||x){let e;let r=[];if(t>=i||a){let t=g(40);e=t>=0?t+1:0}else if("codex"===n)e=Math.max(0,t);else if(t>=i-5){let t=g(50);e=t>=0?t+1:Math.max(0,i-40)}else e=Math.max(0,t);let s=i;for(let t=e;t<i;t++){let e=o[t],i=(0,u.vp)(e);if("codex"===n&&/^›\s+/.test(i)||"gemini"===n&&/^(%|\$|.*@.*[%$#])\s*$/.test(i)){s=t;break}m.some(e=>e.test(i))||r.push(e)}let l=r.join("\n").trim();if(f.test(l))return{response:"",isComplete:!1,lineCount:i};if("claude"===n){let e=(0,u.vp)(l),t=/[╭╮╰╯│]/.test(e)||/░{3,}/.test(e)||/▓{3,}/.test(e),n=/Claude Code|claude\/|v\d+\.\d+/.test(e),r=/Tip:|for shortcuts|\?\s*for help/.test(e),s=/^\s*\/Users\/.*$/m.test(e)&&e.split("\n").length<30,o=e.match(/^[>❯]\s+(\S.*)$/m);if(o){let t=e.indexOf(o[0]);if(0===e.substring(t+o[0].length).trim().split("\n").filter(e=>{let t=e.trim();return t&&!m.some(e=>e.test(t))&&!/^─+$/.test(t)}).length)return{response:"",isComplete:!1,lineCount:i}}else if((t||n||r||s)&&l.length<2e3)return{response:"",isComplete:!1,lineCount:i}}return"gemini"===n&&((l.match(/[░███]/g)||[]).length>.3*l.length||l.includes("Waiting for auth")||l.includes("⠋")||l.includes("⠙")||l.includes("⠹")||l.includes("⠸")||l.includes("⠼")||l.includes("⠴")||l.includes("⠦")||l.includes("⠧")||l.includes("⠇")||l.includes("⠏")||!l.includes("✦")&&l.length<10)?{response:"",isComplete:!1,lineCount:i}:{response:l,isComplete:!0,lineCount:s}}let v=o.join("\n");if((0,l.F)(v).isPrompt)return{response:v,isComplete:!0,lineCount:i};let M=[],k=a||t>=i-5,I=k?g(80):-1,S=k?I>=0?I+1:Math.max(0,i-80):Math.max(0,t);for(let e=S;e<i;e++){let t=o[e],n=(0,u.vp)(t);m.some(e=>e.test(n))||M.push(t)}let b=M.join("\n").trim();return b?{response:b,isComplete:!1,lineCount:i}:{response:"",isComplete:!1,lineCount:i}}(p,d,t);if(!g||!g.isComplete){let{thinkingPattern:r}=(0,u.bs)(t),s=(0,u.vp)(p);if(r.test(s)){let r=(0,o.GP)(n,e,t);r>0&&console.log(`Marked ${r} pending prompt(s) as answered (thinking detected) for ${e}`)}return!1}if(g.lineCount===d&&!s?.inProgressMessageId)return!1;if(g.lineCount<=d)return console.log(`[checkForResponse] Already saved up to line ${d}, skipping (result: ${g.lineCount})`),!1;let C=(0,l.F)(g.response);if(C.isPrompt){(0,o.Mf)(n,e,t);let r=(0,o.tn)(n,{worktreeId:e,role:"assistant",content:C.cleanContent,messageType:"prompt",promptData:C.promptData,timestamp:new Date,cliToolId:t});return(0,o.IH)(n,e,t,g.lineCount),(0,i.ps)("message",{worktreeId:e,message:r}),h(e,t),!0}if(!g.response||""===g.response.trim())return(0,o.IH)(n,e,t,g.lineCount),!1;let $="claude"===t?(0,c.Z)(g.response):void 0,y=g.response;if("gemini"===t?y=m(g.response):"claude"===t&&(y=f(g.response)),!y||""===y.trim()||"[No content]"===y)return(0,o.IH)(n,e,t,g.lineCount),(0,o.Mf)(n,e,t),!1;y&&await (0,a.o)(n,e,y,t);let w=(0,o.GP)(n,e,t);w>0&&console.log(`Marked ${w} pending prompt(s) as answered for ${e}`);let x=(0,o.zl)(n,e,t);if(x&&g.lineCount<=x.lastCapturedLine)return console.log(`[checkForResponse] Race condition detected, skipping save (result: ${g.lineCount}, current: ${x.lastCapturedLine})`),!1;let v=(0,o.tn)(n,{worktreeId:e,role:"assistant",content:y,messageType:"normal",timestamp:new Date,cliToolId:t,summary:$?.summary,logFileName:$?.logFileName,requestId:$?.requestId});return(0,i.ps)("message",{worktreeId:e,message:v}),(0,o.IH)(n,e,t,g.lineCount),!0}catch(t){return console.error(`Error checking for response (${e}):`,t instanceof Error?t.message:String(t)),!1}}function C(e,t){let n=`${e}:${t}`;h(e,t),p.set(n,Date.now());let r=setInterval(async()=>{let r=p.get(n);if(r&&Date.now()-r>3e5){h(e,t);return}try{await g(e,t)}catch(e){console.error("[Poller] Error:",e)}},2e3);d.set(n,r)}function h(e,t){let n=`${e}:${t}`,r=d.get(n);r&&(clearInterval(r),d.delete(n),p.delete(n))}},25079:(e,t,n)=>{"use strict";n.d(t,{ZV:()=>c,fM:()=>l,ps:()=>a});var r=n(34893);let s=new Map,o=new Map;function i(e,t){let n=o.get(e);if(console.log(`[WS] handleBroadcast called for ${e}, room size: ${n?.size||0}`),!n){console.log(`[WS] No room found for ${e}`);return}if(0===n.size){console.log(`[WS] Room for ${e} is empty`);return}try{let s=JSON.stringify({type:"broadcast",worktreeId:e,data:t}),o=0,i=0;n.forEach(e=>{if(e.readyState===r.XY.OPEN)try{e.send(s),o++}catch(e){i++,console.error("Error sending WebSocket message to client:",e)}}),console.log(`Broadcast to worktree ${e}: ${o}/${n.size} clients (${i} errors)`)}catch(t){console.error(`Error broadcasting to worktree ${e}:`,t);try{let t=JSON.stringify({type:"broadcast",worktreeId:e,data:{error:"Message encoding error"}});n.forEach(e=>{if(e.readyState===r.XY.OPEN)try{e.send(t)}catch{}})}catch(e){console.error("Failed to send fallback message:",e)}}}function l(e,t){i(e,t)}function a(e,t){t.worktreeId?i(t.worktreeId,{type:e,...t}):console.warn("broadcastMessage called without worktreeId")}function c(e){for(let t of e){let e=o.get(t);e&&(e.forEach(e=>{let n=s.get(e);n&&n.worktreeIds.delete(t)}),o.delete(t),console.log(`[WS] Cleaned up room for worktree: ${t}`))}}}};