module.exports=[933919,(e,r,t)=>{r.exports=e.x("@prisma/client-9249dd53ac5b6a44",()=>require("@prisma/client-9249dd53ac5b6a44"))},233405,(e,r,t)=>{r.exports=e.x("child_process",()=>require("child_process"))},543108,e=>{"use strict";var r=e.i(933919);let t=globalThis.prisma??new r.PrismaClient({log:[]}),a=!1;async function n(){return a||(await t.$connect(),await t.$queryRaw`PRAGMA journal_mode=WAL`,await t.$queryRaw`PRAGMA busy_timeout=5000`,a=!0),t}process.on("SIGTERM",()=>{t.$disconnect().catch(()=>{})}),process.on("SIGINT",()=>{t.$disconnect().catch(()=>{})}),e.s(["db",0,t,"initDb",0,n])},271856,e=>{"use strict";var r=e.i(233405),t=e.i(543108);function a(e,r,t,a){let n=new Date().toISOString(),o=`[${n}] ${e.toUpperCase()} [${r}] ${t}`;return a&&Object.keys(a).length>0?`${o} ${JSON.stringify(a)}`:o}let n=({create:function(e){return{info(r,t){console.log(a("info",e,r,t))},warn(r,t){console.warn(a("warn",e,r,t))},error(r,t,n){console.error(a("error",e,r,t instanceof Error?{...n,error:t.message,stack:t.stack}:{...n,error:String(t)}))}}},info(e,r){console.log(a("info","app",e,r))},warn(e,r){console.warn(a("warn","app",e,r))},error(e,r,t){console.error(a("error","app",e,r instanceof Error?{...t,error:r.message,stack:r.stack}:{...t,error:String(r)}))}}).create("instrumentation");async function o(){try{await (0,t.initDb)();let e=await t.db.taskExecution.updateMany({where:{status:"RUNNING"},data:{status:"FAILED",endedAt:new Date}});e.count>0&&n.warn(`Cleaned up ${e.count} stale RUNNING execution(s)`)}catch(e){n.error("Stale execution cleanup failed",e)}}async function i(){try{await (0,t.initDb)();let e=await t.db.workspace.count();0===e&&(await t.db.workspace.create({data:{name:"Default Workspace"}}),n.info("Created default workspace"))}catch(e){n.error("Failed to ensure default workspace",e)}}async function c(){try{await (0,t.initDb)();let{TOWER_LABEL_NAME:r,TOWER_LABEL_COLOR:a}=await e.A(622305);await t.db.label.findFirst({where:{name:r,isBuiltin:!0}})||(await t.db.label.create({data:{name:r,color:a,isBuiltin:!0}}),n.info("Created builtin Tower label"))}catch(e){n.error("Failed to ensure Tower label",e)}}async function s(){try{for(let e of(await (0,t.initDb)(),await t.db.project.findMany({where:{type:"GIT",localPath:{not:null}},select:{id:!0,localPath:!0,name:!0}})))try{(0,r.execFileSync)("git",["worktree","prune"],{cwd:e.localPath,encoding:"utf-8",timeout:1e4})}catch(r){n.error(`git worktree prune failed for "${e.name}"`,r,{localPath:e.localPath})}}catch(e){n.error("Worktree prune startup task failed",e)}}e.s(["cleanupStaleExecutions",0,o,"ensureDefaultWorkspace",0,i,"ensureTowerLabel",0,c,"pruneOrphanedWorktrees",0,s],271856)},622305,e=>{e.v(r=>Promise.all(["server/chunks/src_lib_constants_ts_04kowl~._.js"].map(r=>e.l(r))).then(()=>r(542117)))}];

//# sourceMappingURL=%5Broot-of-the-server%5D__0965p6t._.js.map