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

Created: ${l}

---

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

### User

${t}

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

${r}

---

`,await n().writeFile(o,d,"utf-8"),o}async function p(e,t="all"){let r=[];for(let a of"all"===t?["claude","codex","gemini"]:[t]){await c(a);let t=u(a);try{let a=(await n().readdir(t)).filter(t=>t.startsWith(`${e}-`)&&t.endsWith(".md")).map(e=>i().join(t,e));r.push(...a)}catch{}}return r.sort().reverse()}},43895:(e,t,r)=>{r.d(t,{Y:()=>l,h:()=>u});var a=r(98838);let n=[{pattern:/Bearer\s+[A-Za-z0-9\-._~+/]+=*/gi,replacement:"Bearer [REDACTED]"},{pattern:/(password|passwd|pwd)[=:]\s*\S+/gi,replacement:"$1=[REDACTED]"},{pattern:/(token|secret|api_key|apikey|auth)[=:]\s*\S+/gi,replacement:"$1=[REDACTED]"},{pattern:/Authorization:\s*\S+/gi,replacement:"Authorization: [REDACTED]"},{pattern:/-----BEGIN\s+\w+\s+PRIVATE\s+KEY-----[\s\S]*?-----END\s+\w+\s+PRIVATE\s+KEY-----/g,replacement:"[SSH_KEY_REDACTED]"}],o=/password|secret|token|key|auth/i,i={debug:0,info:1,warn:2,error:3};function s(e,t,r,s,l){let u=(0,a.LI)().level;if(i[e]<i[u])return;let c=s?function e(t){if("string"==typeof t){let e=t;for(let{pattern:t,replacement:r}of n)e=e.replace(t,r);return e}if("object"==typeof t&&null!==t){if(Array.isArray(t))return t.map(e);let r={};for(let[a,n]of Object.entries(t))o.test(a)?r[a]="[REDACTED]":r[a]=e(n);return r}return t}(s):void 0,d=function(e){if("json"===(0,a.LI)().format)return JSON.stringify(e);let{timestamp:t,level:r,module:n,action:o,data:i,worktreeId:s,cliToolId:l,requestId:u}=e,c=[s,l].filter(Boolean),d=c.length>0?` [${c.join(":")}]`:"",p=u?` (${u.slice(0,8)})`:"",x=i?` ${JSON.stringify(i)}`:"";return`[${t}] [${r.toUpperCase()}] [${n}]${d}${p} ${o}${x}`}({level:e,module:t,action:r,timestamp:new Date().toISOString(),...l,...c&&{data:c}});switch(e){case"error":console.error(d);break;case"warn":console.warn(d);break;default:console.log(d)}}function l(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function u(e){let t=r=>({debug:(t,a)=>s("debug",e,t,a,r),info:(t,a)=>s("info",e,t,a,r),warn:(t,a)=>s("warn",e,t,a,r),error:(t,a)=>s("error",e,t,a,r),withContext:e=>t({...r,...e})});return t()}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972,3853,7425],()=>r(5517));module.exports=a})();