"use strict";(()=>{var e={};e.id=1732,e.ids=[1732],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")},84770:e=>{e.exports=require("crypto")},92048:e=>{e.exports=require("fs")},20629:e=>{e.exports=require("fs/promises")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},25828:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>k,patchFetch:()=>q,requestAsyncStorage:()=>w,routeModule:()=>h,serverHooks:()=>j,staticGenerationAsyncStorage:()=>v});var o={};t.r(o),t.d(o,{GET:()=>g});var s=t(49303),i=t(88716),n=t(60670),a=t(87070),l=t(97425),u=t(75748),d=t(93346),p=t(20629),m=t.n(p),c=t(55315),f=t.n(c);let x=(0,d.Hb)("CM_LOG_DIR")||f().join(process.cwd(),"data","logs");async function g(e,{params:r}){try{let e=(0,l.n)();if(!(0,u.gU)(e,r.id))return a.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let t=r.filename;if(!t.endsWith(".md")||!t.startsWith(`${r.id}-`))return a.NextResponse.json({error:"Invalid filename"},{status:400});if(t.includes("..")||t.includes("/")||t.includes("\\"))return a.NextResponse.json({error:"Invalid filename: path traversal not allowed"},{status:400});let o=!1,s="",i=null,n="";for(let e of["claude","codex","gemini"]){let r=f().join(x,e,t);try{let t=await m().stat(r);if(t.isFile()){o=!0,n=e,i={size:t.size,mtime:t.mtime},s=await m().readFile(r,"utf-8");break}}catch(e){if("ENOENT"!==e.code)throw e}}if(!o)return a.NextResponse.json({error:`Log file '${t}' not found in any CLI tool directory`},{status:404});return a.NextResponse.json({filename:t,cliToolId:n,content:s,size:i.size,modifiedAt:i.mtime.toISOString()},{status:200})}catch(e){return console.error("Error reading log file:",e),a.NextResponse.json({error:"Failed to read log file"},{status:500})}}let h=new s.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/worktrees/[id]/logs/[filename]/route",pathname:"/api/worktrees/[id]/logs/[filename]",filename:"route",bundlePath:"app/api/worktrees/[id]/logs/[filename]/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/logs/[filename]/route.ts",nextConfigOutput:"",userland:o}),{requestAsyncStorage:w,staticGenerationAsyncStorage:v,serverHooks:j}=h,k="/api/worktrees/[id]/logs/[filename]/route";function q(){return(0,n.patchFetch)({serverHooks:j,staticGenerationAsyncStorage:v})}}};var r=require("../../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),o=r.X(0,[8948,5972,7425],()=>t(25828));module.exports=o})();