"use strict";(()=>{var e={};e.id=1991,e.ids=[1991],e.modules={85890:e=>{e.exports=require("better-sqlite3")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},78893:e=>{e.exports=require("buffer")},61282:e=>{e.exports=require("child_process")},84770:e=>{e.exports=require("crypto")},17702:e=>{e.exports=require("events")},92048:e=>{e.exports=require("fs")},20629:e=>{e.exports=require("fs/promises")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},98216:e=>{e.exports=require("net")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},76162:e=>{e.exports=require("stream")},82452:e=>{e.exports=require("tls")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},26683:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>w,patchFetch:()=>A,requestAsyncStorage:()=>v,routeModule:()=>q,serverHooks:()=>k,staticGenerationAsyncStorage:()=>P});var n={};r.r(n),r.d(n,{GET:()=>f});var i=r(49303),o=r(88716),s=r(60670),a=r(87070),u=r(97425),p=r(75748),c=r(63661),l=r(55837),d=r(83513),h=r(89194),g=r(19377),m=r(13561),x=r(38693);async function f(e,{params:t}){try{if(!(0,x.m$)(t.id))return a.NextResponse.json({error:"Invalid worktree ID format"},{status:400});let r=(0,u.getDbInstance)(),n=(0,p.gU)(r,t.id);if(!n)return a.NextResponse.json({error:`Worktree '${t.id}' not found`},{status:404});let i=new URL(e.url).searchParams.get("cliTool"),o=i&&d.tK.includes(i)?i:n.cliToolId||"claude",s=l.g.getInstance().getTool(o);if(!await s.isRunning(t.id))return a.NextResponse.json({isRunning:!1,content:"",lineCount:0,cliToolId:o},{status:200});let f=(0,p.zl)(r,t.id,o),q=f?.lastCapturedLine||0,v=await (0,h.NA)(t.id,o,1e4),P=v.split("\n"),k=P.length,w=P.slice(Math.max(0,q)).join("\n"),A=(0,g.vp)(v),_=(0,m._)(v,o),j="running"===_.status&&"thinking_indicator"===_.reason,R={isPrompt:!1,cleanContent:A};if(!j){let e=(0,g.Sg)(o);R=(0,c.F)((0,g.BN)(A),e)}let b=_.hasActivePrompt,M=P.slice(-100).join("\n"),C=(0,x.bq)(t.id),N=(0,x.gf)(t.id);return a.NextResponse.json({isRunning:!0,cliToolId:o,content:w,fullOutput:v,realtimeSnippet:M,lineCount:k,lastCapturedLine:q,isComplete:b,isGenerating:j,thinking:j,thinkingMessage:j?"Claude is thinking...":null,isPromptWaiting:b,promptData:b?R.promptData:null,autoYes:{enabled:C?.enabled??!1,expiresAt:C?.enabled?C.expiresAt:null,stopReason:C?.stopReason},lastServerResponseTimestamp:N})}catch(e){return console.error("Error getting current output:",e),a.NextResponse.json({error:"Failed to get current output"},{status:500})}}let q=new i.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/worktrees/[id]/current-output/route",pathname:"/api/worktrees/[id]/current-output",filename:"route",bundlePath:"app/api/worktrees/[id]/current-output/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/current-output/route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:v,staticGenerationAsyncStorage:P,serverHooks:k}=q,w="/api/worktrees/[id]/current-output/route";function A(){return(0,s.patchFetch)({serverHooks:k,staticGenerationAsyncStorage:P})}},13561:(e,t,r)=>{r.d(t,{_:()=>o});var n=r(19377),i=r(63661);function o(e,t,r){let o=(0,n.vp)(e),s=o.split("\n"),a=s.length-1;for(;a>=0&&""===s[a].trim();)a--;let u=s.slice(0,a+1),p=u.slice(-15).join("\n"),c=u.slice(-5).join("\n"),l=(0,n.Sg)(t);if((0,i.F)((0,n.BN)(o),l).isPrompt)return{status:"waiting",confidence:"high",reason:"prompt_detected",hasActivePrompt:!0};if((0,n.Wg)(t,c))return{status:"running",confidence:"high",reason:"thinking_indicator",hasActivePrompt:!1};if("opencode"===t){if(n.nT.test(p))return{status:"running",confidence:"high",reason:"opencode_processing_indicator",hasActivePrompt:!1};let e=(0,n.BN)(o).split("\n"),t=Math.max(0,e.length-7);for(let r=e.length-1;r>=Math.max(0,e.length-10);r--)if(/ctrl\+[tp]/.test(e[r])){t=Math.max(0,r-2);break}let r=e.slice(0,t),i=r.length-1;for(;i>=0&&""===r[i].trim();)i--;if(i>=0){let e=r.slice(Math.max(0,i-5+1),i+1).join("\n");if((0,n.Wg)("opencode",e))return{status:"running",confidence:"high",reason:"thinking_indicator",hasActivePrompt:!1};let t=r.slice(Math.max(0,i-15+1),i+1).join("\n");if(n.n9.test(t))return{status:"ready",confidence:"high",reason:"opencode_response_complete",hasActivePrompt:!1}}}let{promptPattern:d}=(0,n.bs)(t);return d.test(p)?{status:"ready",confidence:"high",reason:"input_prompt",hasActivePrompt:!1}:r&&Date.now()-r.getTime()>5e3?{status:"ready",confidence:"low",reason:"no_recent_output",hasActivePrompt:!1}:{status:"running",confidence:"low",reason:"default",hasActivePrompt:!1}}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[8948,5972,3853,4893,2509,7425,7566,4952,8693],()=>r(26683));module.exports=n})();