"use strict";(()=>{var e={};e.id=2568,e.ids=[2568],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")},74859:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>f,patchFetch:()=>I,requestAsyncStorage:()=>q,routeModule:()=>h,serverHooks:()=>w,staticGenerationAsyncStorage:()=>g});var o={};t.r(o),t.d(o,{POST:()=>k});var s=t(49303),a=t(88716),n=t(60670),u=t(87070),i=t(94925),p=t(30721),d=t(98134),l=t(11425),c=t(89287),m=t(76966);let x=(0,t(43895).h)("api/hooks-claude-done");async function k(e){try{let r;let t=(0,i.getDbInstance)(),o=await e.json();if(!o.worktreeId||"string"!=typeof o.worktreeId)return u.NextResponse.json({error:"worktreeId is required and must be a string"},{status:400});if(!(0,p.gU)(t,o.worktreeId))return u.NextResponse.json({error:`Worktree '${o.worktreeId}' not found`},{status:404});try{r=await (0,d.Lm)(o.worktreeId,1e4)}catch(r){x.error("failed-to-capture-claude-output:",{error:r instanceof Error?r.message:String(r)});let e=r instanceof Error?r.message:"Unknown error";return u.NextResponse.json({error:`Failed to capture Claude output: ${e}`},{status:500})}let s=(0,c.Z)(r);await (0,m.o)(t,o.worktreeId,s.content,"claude");let a=(0,p.tn)(t,{worktreeId:o.worktreeId,role:"assistant",content:s.content,summary:s.summary,timestamp:new Date,logFileName:s.logFileName,requestId:s.requestId,messageType:"normal",cliToolId:"claude"}),n=r.split("\n").length;return(0,p.IH)(t,o.worktreeId,"claude",n),(0,l.ps)("message",{worktreeId:o.worktreeId,message:a}),x.info("processed-claude-response-for-worktree:"),u.NextResponse.json({success:!0,messageId:a.id,summary:s.summary},{status:200})}catch(e){return x.error("error-processing-claude-done-hook:",{error:e instanceof Error?e.message:String(e)}),u.NextResponse.json({error:"Failed to process Claude done hook"},{status:500})}}let h=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/hooks/claude-done/route",pathname:"/api/hooks/claude-done",filename:"route",bundlePath:"app/api/hooks/claude-done/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/hooks/claude-done/route.ts",nextConfigOutput:"",userland:o}),{requestAsyncStorage:q,staticGenerationAsyncStorage:g,serverHooks:w}=h,f="/api/hooks/claude-done/route";function I(){return(0,n.patchFetch)({serverHooks:w,staticGenerationAsyncStorage:g})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),o=r.X(0,[8948,5972,3853,4893,3895,4925,721,9228],()=>t(74859));module.exports=o})();