(()=>{var e={};e.id=911,e.ids=[911],e.modules={20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},79348:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},30412:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},92048:e=>{"use strict";e.exports=require("fs")},19801:e=>{"use strict";e.exports=require("os")},55315:e=>{"use strict";e.exports=require("path")},2901:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>h,routeModule:()=>x,serverHooks:()=>f,workAsyncStorage:()=>m,workUnitAsyncStorage:()=>R});var s={};t.r(s),t.d(s,{GET:()=>l});var o=t(88797),a=t(10042),n=t(58492),i=t(59540);let u=require("sqlite3");var c=t(19801),p=t(55315),d=t(92048);async function l(e){return new Promise(r=>{let{searchParams:t}=new URL(e.url),s=t.get("lastCreatedTime"),o=process.env.CURATOR_CACHE_DIR||(0,p.join)((0,c.homedir)(),".cache","curator"),a=(0,p.join)(o,"metadata.db");if(!(0,d.existsSync)(a)){console.error(`Database file not found at: ${a}`),r(i.NextResponse.json({error:"NO_CACHE_DB",message:"No cache database found. Please run some prompts first.",path:a},{status:404}));return}try{let e=new u.Database(a,e=>{if(e){console.error("Database connection error:",e),r(i.NextResponse.json({error:"Database connection failed"},{status:500}));return}});e.all(s?"SELECT * FROM runs WHERE created_time > ? ORDER BY created_time DESC":"SELECT * FROM runs ORDER BY created_time DESC",s?[s]:[],(t,s)=>{if(t){console.error("Database query error:",t),r(i.NextResponse.json({error:"Database query failed"},{status:500}));return}let o=Array.isArray(s)?s:[];r(i.NextResponse.json(o)),e.close(e=>{e&&console.error("Error closing database:",e)})})}catch(e){console.error("Unexpected error:",e),r(i.NextResponse.json({error:"Unexpected error occurred"},{status:500}))}})}let x=new o.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/runs/route",pathname:"/api/runs",filename:"route",bundlePath:"app/api/runs/route"},resolvedPagePath:"/home/charlieji/workspace/bella-cli/bespoke-dataset-viewer/app/api/runs/route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:m,workUnitAsyncStorage:R,serverHooks:f}=x;function h(){return(0,n.patchFetch)({workAsyncStorage:m,workUnitAsyncStorage:R})}},78031:()=>{},35303:()=>{}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[492,661],()=>t(2901));module.exports=s})();