module.exports=[18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},50227,(e,t,r)=>{t.exports=e.x("node:path",()=>require("node:path"))},60526,(e,t,r)=>{t.exports=e.x("node:os",()=>require("node:os"))},66680,(e,t,r)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},2157,(e,t,r)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},86607,(e,t,r)=>{t.exports=e.x("better-sqlite3-cf218e5bd1d5f04c",()=>require("better-sqlite3-cf218e5bd1d5f04c"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},65198,e=>{"use strict";var t=e.i(53533),r=e.i(90886);async function a(){let e=await (0,t.cookies)(),a=e.get("notfair_active_project")?.value;if(a){let e=(0,r.getProject)(a);if(e&&!e.archived_at)return e}return(0,r.listProjects)()[0]??null}e.s(["getActiveProject",0,a])},60273,e=>{"use strict";var t=e.i(66680),r=e.i(31770);function a(e){return(0,r.getDb)().prepare("SELECT * FROM tasks WHERE id = ? OR display_id = ?").get(e,e)??null}e.s(["claimProposedTask",0,function(e){let t=(0,r.getDb)(),n=new Date().toISOString();return 0===t.prepare("UPDATE tasks SET status = 'working', updated_at = ? WHERE id = ? AND status = 'proposed'").run(n,e).changes?null:a(e)},"clearBlockerAndPromote",0,function(e){let t=(0,r.getDb)(),n=new Date().toISOString();return 0===t.prepare("UPDATE tasks SET status = 'proposed', blocked_by_task_id = NULL, updated_at = ? WHERE id = ? AND status = 'blocked'").run(n,e).changes?null:a(e)},"createTask",0,function(e){var n,s;let i,o,l=(0,r.getDb)(),d=new Date().toISOString(),u=e.status??"proposed",p=e.blocked_by_task_id??null;if(p){let e=a(p);e&&"done"!==(s=e.status)&&"failed"!==s&&"cancelled"!==s?u="blocked":p=null}let c={id:(0,t.randomUUID)(),display_id:(n=e.project_slug,i=(0,r.getDb)().prepare(`SELECT COALESCE(MAX(CAST(substr(display_id, ?) AS INTEGER)), 0) AS max_n
       FROM tasks
       WHERE project_slug = ? AND display_id LIKE ?`).get(n.length+2,n,`${n}-%`),o=(i?.max_n??0)+1,`${n}-${o}`),project_slug:e.project_slug,agent_id:e.agent_id,title:e.title??null,brief:e.brief,success_criteria:e.success_criteria??null,deadline_iso:e.deadline_iso??null,status:u,result_json:null,error_message:null,thread_id:null,assigner_agent_id:e.assigner_agent_id??null,blocked_by_task_id:p,created_at:d,updated_at:d};return l.prepare(`INSERT INTO tasks
       (id, display_id, project_slug, agent_id, title, brief, success_criteria, deadline_iso,
        status, result_json, error_message, thread_id, assigner_agent_id, blocked_by_task_id, created_at, updated_at)
     VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, NULL, ?, ?, ?, ?)`).run(c.id,c.display_id,c.project_slug,c.agent_id,c.title,c.brief,c.success_criteria,c.deadline_iso,c.status,c.assigner_agent_id,c.blocked_by_task_id,c.created_at,c.updated_at),c},"getTask",0,a,"inFlightCountsByAgent",0,function(e){let t=(0,r.getDb)().prepare(`SELECT agent_id, COUNT(*) as count
       FROM tasks
       WHERE project_slug = ? AND status IN ('proposed', 'approved', 'working', 'blocked')
       GROUP BY agent_id`).all(e),a=new Map;for(let e of t)a.set(e.agent_id,e.count);return a},"listTasks",0,function(e,t){let a=(0,r.getDb)();return t?a.prepare("SELECT * FROM tasks WHERE project_slug = ? AND status = ? ORDER BY created_at DESC").all(e,t):a.prepare("SELECT * FROM tasks WHERE project_slug = ? ORDER BY created_at DESC").all(e)},"listTasksBlockedBy",0,function(e){return(0,r.getDb)().prepare("SELECT * FROM tasks WHERE blocked_by_task_id = ? AND status = 'blocked' ORDER BY created_at ASC").all(e)},"listTasksByAgent",0,function(e,t){let a=(0,r.getDb)();return t?a.prepare("SELECT * FROM tasks WHERE agent_id = ? AND status = ? ORDER BY created_at DESC").all(e,t):a.prepare("SELECT * FROM tasks WHERE agent_id = ? ORDER BY created_at DESC").all(e)},"markTaskBlocked",0,function(e){let t=(0,r.getDb)(),n=new Date().toISOString();return t.prepare("UPDATE tasks SET status = 'blocked', updated_at = ? WHERE id = ? AND status IN ('working','proposed','approved')").run(n,e),a(e)},"setTaskThreadIfMissing",0,function(e,t){let n=(0,r.getDb)(),s=a(e);return s?s.thread_id?s:(n.prepare("UPDATE tasks SET thread_id = ?, updated_at = ? WHERE id = ? AND thread_id IS NULL").run(t,new Date().toISOString(),e),a(e)):null},"unblockTask",0,function(e){let t=(0,r.getDb)(),n=new Date().toISOString();return t.prepare("UPDATE tasks SET status = 'working', updated_at = ? WHERE id = ? AND status = 'blocked'").run(n,e),a(e)},"updateTask",0,function(e,t){let n=(0,r.getDb)(),s=new Date().toISOString(),i=a(e);if(!i)return null;let o=void 0!==t.result?JSON.stringify(t.result):i.result_json,l=void 0!==t.error_message?t.error_message:i.error_message,d=t.status??i.status;return n.prepare("UPDATE tasks SET status = ?, result_json = ?, error_message = ?, updated_at = ? WHERE id = ?").run(d,o,l,s,e),a(e)}])},22117,e=>{"use strict";var t=e.i(66680),r=e.i(31770);function a(e){let a=(0,r.getDb)(),n={id:(0,t.randomUUID)(),approval_id:e.approval_id,author_kind:e.author_kind,author_id:e.author_id??null,body:e.body,created_at:new Date().toISOString()};return a.prepare(`INSERT INTO approval_comments (id, approval_id, author_kind, author_id, body, created_at)
     VALUES (?, ?, ?, ?, ?, ?)`).run(n.id,n.approval_id,n.author_kind,n.author_id,n.body,n.created_at),n}e.s(["actionableApprovalCount",0,function(e){return(0,r.getDb)().prepare(`SELECT COUNT(*) AS n FROM approvals
        WHERE project_slug = ? AND status IN ('pending','revision_requested')`).get(e).n},"appendComment",0,a,"createApproval",0,function(e){var n,s,i,o;let l=(0,r.getDb)(),d=(0,t.randomUUID)(),u=new Date().toISOString(),p=(n=e.project_slug,s=e.action_type,i=e.agent_id,o=e.cost_estimate_usd,(0,r.getDb)().prepare(`SELECT * FROM approval_policies
        WHERE project_slug = ?
          AND action_type = ?
          AND (agent_id IS NULL OR agent_id = ?)
          AND (max_cost_usd IS NULL OR max_cost_usd >= ?)
        ORDER BY
          CASE WHEN agent_id IS NULL THEN 1 ELSE 0 END,
          CASE WHEN max_cost_usd IS NULL THEN 1 ELSE 0 END,
          max_cost_usd ASC NULLS LAST,
          created_at DESC`).all(n,s,i,o)[0]??null),c=p?"approve"===p.auto_decision?"approved":"rejected":"pending";return l.prepare(`INSERT INTO approvals
       (id, project_slug, agent_id, task_id, action_summary, action_type,
        cost_estimate_usd, reasoning, payload_json, status,
        decision_note, decided_by_kind, decided_by_id,
        created_at, resolved_at)
     VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(d,e.project_slug,e.agent_id,e.task_id??null,e.action_summary,e.action_type,e.cost_estimate_usd,e.reasoning??null,JSON.stringify(e.payload??{}),c,p?p.note??"Auto-decided by policy.":null,p?"policy":null,p?p.id:null,u,p?u:null),p&&a({approval_id:d,author_kind:"system",author_id:p.id,body:`Auto-${"approve"===p.auto_decision?"approved":"rejected"} by policy: ${p.note??"(no note)"}`}),l.prepare("SELECT * FROM approvals WHERE id = ?").get(d)},"getApproval",0,function(e){return(0,r.getDb)().prepare("SELECT * FROM approvals WHERE id = ?").get(e)??null},"listActionableApprovals",0,function(e){return(0,r.getDb)().prepare(`SELECT * FROM approvals
        WHERE project_slug = ?
          AND status IN ('pending','revision_requested')
        ORDER BY created_at DESC`).all(e)},"listApprovalsForTask",0,function(e){return(0,r.getDb)().prepare("SELECT * FROM approvals WHERE task_id = ? ORDER BY created_at DESC").all(e)},"listComments",0,function(e){return(0,r.getDb)().prepare("SELECT * FROM approval_comments WHERE approval_id = ? ORDER BY created_at ASC").all(e)}])},9085,e=>{"use strict";var t=e.i(34953),r=e.i(49201),a=e.i(69102),n=e.i(19309),s=e.i(89554),i=e.i(73525),o=e.i(27176),l=e.i(99736),d=e.i(97998),u=e.i(14255),p=e.i(69267),c=e.i(80309),_=e.i(31611),E=e.i(88950),g=e.i(31065),R=e.i(93695);e.i(971);var v=e.i(67902),h=e.i(73943),S=e.i(65198),f=e.i(22117),b=e.i(60273);async function D(){let e=await (0,S.getActiveProject)();if(!e)return h.NextResponse.json({project:null,agents:{},approvals:0});let t=(0,b.inFlightCountsByAgent)(e.slug),r={};for(let[e,a]of t)r[e]=a;let a=(0,f.actionableApprovalCount)(e.slug);return h.NextResponse.json({project:e.slug,agents:r,approvals:a})}e.s(["GET",0,D,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],4008);var k=e.i(4008);let A=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/in-flight-counts/route",pathname:"/api/in-flight-counts",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/in-flight-counts/route.ts",nextConfigOutput:"standalone",userland:k,...{}}),{workAsyncStorage:x,workUnitAsyncStorage:T,serverHooks:y}=A;async function m(e,t,a){a.requestMeta&&(0,n.setRequestMeta)(e,a.requestMeta),A.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let h="/api/in-flight-counts/route";h=h.replace(/\/index$/,"")||"/";let S=await A.prepare(e,t,{srcPage:h,multiZoneDraftMode:!1});if(!S)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:f,deploymentId:b,params:D,nextConfig:k,parsedUrl:x,isDraftMode:T,prerenderManifest:y,routerServerContext:m,isOnDemandRevalidate:C,revalidateOnlyGenerated:N,resolvedPathname:O,clientReferenceManifest:w,serverActionsManifest:j}=S,L=(0,o.normalizeAppPath)(h),I=!!(y.dynamicRoutes[L]||y.routes[O]),U=async()=>((null==m?void 0:m.render404)?await m.render404(e,t,x,!1):t.end("This page could not be found"),null);if(I&&!T){let e=!!y.routes[O],t=y.dynamicRoutes[L];if(t&&!1===t.fallback&&!e){if(k.adapterPath)return await U();throw new R.NoFallbackError}}let H=null;!I||A.isDev||T||(H="/index"===(H=O)?"/":H);let P=!0===A.isDev||!I,M=I&&!P;j&&w&&(0,i.setManifestsSingleton)({page:h,clientReferenceManifest:w,serverActionsManifest:j});let q=e.method||"GET",F=(0,s.getTracer)(),W=F.getActiveScopeSpan(),B=!!(null==m?void 0:m.isWrappedByNextServer),$=!!(0,n.getRequestMeta)(e,"minimalMode"),Y=(0,n.getRequestMeta)(e,"incrementalCache")||await A.getIncrementalCache(e,k,y,$);null==Y||Y.resetRequestCache(),globalThis.__incrementalCache=Y;let K={params:D,previewProps:y.preview,renderOpts:{experimental:{authInterrupts:!!k.experimental.authInterrupts},cacheComponents:!!k.cacheComponents,supportsDynamicResponse:P,incrementalCache:Y,cacheLifeProfiles:k.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>A.onRequestError(e,t,a,n,m)},sharedContext:{buildId:f,deploymentId:b}},G=new l.NodeNextRequest(e),V=new l.NodeNextResponse(t),X=d.NextRequestAdapter.fromNodeNextRequest(G,(0,d.signalFromNodeResponse)(t));try{let n,i=async e=>A.handle(X,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${q} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t),n&&n!==e&&(n.setAttribute("http.route",a),n.updateName(t))}else e.updateName(`${q} ${h}`)}),o=async n=>{var s,o;let l=async({previousCacheEntry:r})=>{try{if(!$&&C&&N&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=K.renderOpts.fetchMetrics;let o=K.renderOpts.pendingWaitUntil;o&&a.waitUntil&&(a.waitUntil(o),o=void 0);let l=K.renderOpts.collectedTags;if(!I)return await (0,c.sendResponse)(G,V,s,K.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,_.toNodeOutgoingHttpHeaders)(s.headers);l&&(t[g.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,a=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:v.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await A.onRequestError(e,t,{routerKind:"App Router",routePath:h,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,m),t}},d=await A.handleResponse({req:e,nextConfig:k,cacheKey:H,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:C,revalidateOnlyGenerated:N,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:$});if(!I)return null;if((null==d||null==(s=d.value)?void 0:s.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(o=d.value)?void 0:o.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});$||t.setHeader("x-nextjs-cache",C?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),T&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,_.fromNodeOutgoingHttpHeaders)(d.value.headers);return $&&I||u.delete(g.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,E.getCacheControlHeader)(d.cacheControl)),await (0,c.sendResponse)(G,V,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&W?await o(W):(n=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${q} ${h}`,kind:s.SpanKind.SERVER,attributes:{"http.method":q,"http.target":e.url}},o),void 0,!B))}catch(t){if(t instanceof R.NoFallbackError||await A.onRequestError(e,t,{routerKind:"App Router",routePath:L,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,m),I)throw t;return await (0,c.sendResponse)(G,V,new Response(null,{status:500})),null}}e.s(["handler",0,m,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:x,workUnitAsyncStorage:T})},"routeModule",0,A,"serverHooks",0,y,"workAsyncStorage",0,x,"workUnitAsyncStorage",0,T],9085)}];

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