"use strict";(()=>{var e={};e.id=7586,e.ids=[7586],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")},35135:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>j,patchFetch:()=>k,requestAsyncStorage:()=>g,routeModule:()=>f,serverHooks:()=>v,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{POST:()=>q});var o=t(49303),i=t(88716),n=t(60670),a=t(87070),p=t(83513),u=t(55837),d=t(30721),l=t(94925),m=t(85930),x=t(37577);let c=(0,t(43895).h)("api/terminal");async function q(e,{params:r}){try{let{cliToolId:t,command:s}=await e.json();if(!t||"string"!=typeof t||!(0,p._7)(t))return a.NextResponse.json({error:"Invalid cliToolId parameter"},{status:400});if(!s||"string"!=typeof s)return a.NextResponse.json({error:"Missing command parameter"},{status:400});if(s.length>1e4)return a.NextResponse.json({error:"Invalid command parameter"},{status:400});let o=(0,l.getDbInstance)();if(!(0,d.gU)(o,r.id))return a.NextResponse.json({error:"Worktree not found"},{status:404});let i=u.g.getInstance().getTool(t).getSessionName(r.id);if(!await (0,m.Hk)(i))return a.NextResponse.json({error:"Session not found. Use startSession API to create a session first."},{status:404});return await (0,m.Is)(i,s),(0,x.e5)(i),a.NextResponse.json({success:!0})}catch(e){return c.error("terminal-api-error:",{error:e instanceof Error?e.message:String(e)}),a.NextResponse.json({error:"Failed to send command to terminal"},{status:500})}}let f=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/worktrees/[id]/terminal/route",pathname:"/api/worktrees/[id]/terminal",filename:"route",bundlePath:"app/api/worktrees/[id]/terminal/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/terminal/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:g,staticGenerationAsyncStorage:h,serverHooks:v}=f,j="/api/worktrees/[id]/terminal/route";function k(){return(0,n.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:h})}}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972,3853,4893,3895,4925,721,9228],()=>t(35135));module.exports=s})();