"use strict";(()=>{var e={};e.id=1746,e.ids=[1746],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")},5517:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>k,patchFetch:()=>q,requestAsyncStorage:()=>y,routeModule:()=>w,serverHooks:()=>C,staticGenerationAsyncStorage:()=>v});var a={};r.r(a),r.d(a,{GET:()=>h});var o=r(49303),i=r(88716),s=r(60670),n=r(87070),u=r(94925),d=r(30721),l=r(98636),c=r(29414),p=r(20629),m=r.n(p),f=r(55315),g=r.n(f);let x=(0,r(43895).h)("api/logs"),h=(0,c.o)(async(e,{params:t})=>{try{let r=await Promise.resolve(t),a=(0,u.getDbInstance)();if(!(0,d.gU)(a,r.id))return n.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let o=e.nextUrl?.searchParams,i=o?.get("cliTool")||"all",s=await (0,l.e7)(r.id,i),c=(await Promise.all(s.map(async e=>{let t=g().basename(e),r=await m().stat(e),a=e.split(g().sep),o=a[a.length-2];return{filename:t,cliToolId:o,size:r.size,modifiedAt:r.mtime.toISOString()}}))).map(e=>e.filename);return n.NextResponse.json(c,{status:200})}catch(e){return x.error("error-fetching-log-files:",{error:e instanceof Error?e.message:String(e)}),n.NextResponse.json({error:"Failed to fetch log files"},{status:500})}}),w=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/worktrees/[id]/logs/route",pathname:"/api/worktrees/[id]/logs",filename:"route",bundlePath:"app/api/worktrees/[id]/logs/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/logs/route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:y,staticGenerationAsyncStorage:v,serverHooks:C}=w,k="/api/worktrees/[id]/logs/route";function q(){return(0,s.patchFetch)({serverHooks:C,staticGenerationAsyncStorage:v})}},98241:(e,t,r)=>{r.d(t,{s:()=>s});var a=r(55315),o=r.n(a),i=r(98838);function s(){return(0,i.Hb)("CM_LOG_DIR")||o().join(process.cwd(),"data","logs")}},29414:(e,t,r)=>{function a(e,t){let{logLevel:r="info",maxResponseBodyLength:a=1024,skipResponseBody:o=!1}=t??{};return async(t,r)=>e(t,r)}r.d(t,{o:()=>a}),(0,r(43895).h)("api")},98636:(e,t,r)=>{r.d(t,{e7:()=>p,xN:()=>c});var a=r(20629),o=r.n(a),i=r(55315),s=r.n(i),n=r(73853),u=r(98241);function d(e="claude"){return s().join((0,u.s)(),e)}async function l(e="claude"){let t=d(e);try{await o().access(t)}catch{await o().mkdir(t,{recursive:!0})}}async function c(e,t,r,a="claude"){await l(a);let i=function(e,t="claude"){let r=(0,n.WU)(new Date,"yyyy-MM-dd"),a=`${e}-${r}.md`,o=d(t);return s().join(o,a)}(e,a),u=(0,n.WU)(new Date,"yyyy-MM-dd HH:mm:ss"),c="";try{c=await o().readFile(i,"utf-8")}catch{let t="claude"===a?"Claude Code":"codex"===a?"Codex CLI":"Gemini CLI";c=`# ${t} Conversation Log: ${e}

Created: ${u}

---

`}return c+=`## Conversation at ${u}

### User

${t}

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

${r}

---

`,await o().writeFile(i,c,"utf-8"),i}async function p(e,t="all"){let r=[];for(let a of"all"===t?["claude","codex","gemini"]:[t]){await l(a);let t=d(a);try{let a=(await o().readdir(t)).filter(t=>t.startsWith(`${e}-`)&&t.endsWith(".md")).map(e=>s().join(t,e));r.push(...a)}catch{}}return r.sort().reverse()}(0,r(43895).h)("log-manager")}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972,3853,3895,4925,721],()=>r(5517));module.exports=a})();