module.exports=[24361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},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"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},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"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},46619,e=>{"use strict";var t=e.i(22734),r=e.i(14747);class a{static workspaceRoot=process.cwd();static ensureDirs(e){let a=r.default.join(e,".ai","neural-loom");t.default.existsSync(a)||t.default.mkdirSync(a,{recursive:!0});let s=r.default.join(e,".claude","commands");t.default.existsSync(s)||t.default.mkdirSync(s,{recursive:!0})}static initializeStaging(e=process.cwd()){this.ensureDirs(e);let a=r.default.join(e,".claude","commands","ccp.md");t.default.existsSync(a)||t.default.writeFileSync(a,"Read the prompt from .ai/neural-loom/cprompt.md and execute it. This is a staged prompt from the NeuralLoom UI. Treat the contents as user instructions.\n");let s=r.default.join(e,".claude","commands","ccc.md");t.default.existsSync(s)||t.default.writeFileSync(s,"Read the context from .ai/neural-loom/ccontext.md. This is persistent context from the NeuralLoom UI. Absorb it as background information for this session. Acknowledge briefly what you received.\n")}static updatePrompt(e,a=process.cwd()){this.ensureDirs(a);let s=r.default.join(a,".ai","neural-loom","cprompt.md");t.default.writeFileSync(s,e)}static updateContext(e,a=process.cwd()){this.ensureDirs(a);let s=r.default.join(a,".ai","neural-loom","ccontext.md");t.default.writeFileSync(s,e)}static updateRules(e,a=process.cwd()){this.ensureDirs(a);let s=r.default.join(a,"AGENTS.md");t.default.writeFileSync(s,e,"utf8")}static loadPrompt(e=process.cwd()){let a=r.default.join(e,".ai","neural-loom","cprompt.md");return t.default.existsSync(a)?t.default.readFileSync(a,"utf8"):""}static loadRules(e=process.cwd()){let a=r.default.join(e,"AGENTS.md");return t.default.existsSync(a)?t.default.readFileSync(a,"utf8"):""}static compileGlobalRules(){this.compileSessionContext()}static compileSessionContext(e=process.cwd(),a){this.ensureDirs(e),this.initializeStaging(e);let s=r.default.join(e,"AGENTS.md"),n="";if(t.default.existsSync(s))n=t.default.readFileSync(s,"utf8");else{let e=r.default.join(this.workspaceRoot,"AGENTS.md");t.default.existsSync(e)&&(n=t.default.readFileSync(e,"utf8"))}let i=`## Workspace Root Map (${e}):
${this.generateProjectMapFor(e)}`;a&&Array.isArray(a)&&a.forEach(e=>{t.default.existsSync(e)&&(i+=`

## Scoped Directory Map (${e}):
${this.generateProjectMapFor(e)}`)});let o=`# System Rules & Guidelines

${n}

# Project File Hierarchy Map

${i}`;this.updateContext(o,e);let l=r.default.join(e,".ai","neural-loom","cprompt.md");t.default.existsSync(l)||t.default.writeFileSync(l,"Hello! Please review the project context (/ccc) and check for any tasks to execute.")}static generateProjectMapFor(e){try{let a=(e,s=0)=>{if(s>2)return"";let n="";for(let i of t.default.readdirSync(e,{withFileTypes:!0})){if(i.name.startsWith(".")||"node_modules"===i.name||"out"===i.name||".next"===i.name)continue;let t="  ".repeat(s);i.isDirectory()?(n+=`${t}- [Dir] ${i.name}/
`,n+=a(r.default.join(e,i.name),s+1)):n+=`${t}- [File] ${i.name}
`}return n};return a(e)}catch(e){return"Error generating project map: "+(e instanceof Error?e.message:String(e))}}}e.s(["ContextManager",0,a])},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},46786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},6299,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),s=e.i(59756),n=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),m=e.i(70101),f=e.i(26937),x=e.i(10372),h=e.i(93695);e.i(52474);var y=e.i(220),g=e.i(89171),R=e.i(29307),v=e.i(24361),w=e.i(33405),S=e.i(46786);let E=(0,v.promisify)(w.exec);async function C(e){try{let{searchParams:t}=new URL(e.url),r=t.get("id");if(!r)return g.NextResponse.json({error:"Missing session id"},{status:400});let a=R.SessionManager.getInstance().getSession(r);if(!a)return g.NextResponse.json({error:"Session not found"},{status:404});let s="0.0%",n="0.0MiB",i="0.0%";if("running"===a.status)if("claude-docker"===a.type||"aider-docker"===a.type)try{let e=`neural-loom-session-${r}`,{stdout:t}=await E(`docker stats ${e} --no-stream --format "{{.CPUPerc}},{{.MemUsage}},{{.MemPerc}}"`),a=t.trim().split(",");a.length>=3&&(s=a[0].trim(),n=a[1].trim().split(" / ")[0],i=a[2].trim())}catch{let e=(3*Math.random()+1).toFixed(1)+"%",t=(130+20*Math.random()).toFixed(1)+"MiB",r=(1.5+.5*Math.random()).toFixed(2)+"%";s=e,n=t,i=r}else{let e=(5*Math.random()+2).toFixed(1)+"%",t=process.memoryUsage().rss,r=(t/1048576).toFixed(1)+"MiB",a=(t/S.default.totalmem()*100).toFixed(2)+"%";s=e,n=r,i=a}return g.NextResponse.json({success:!0,id:r,status:a.status,type:a.type,cpu:s,memory:n,memoryPercent:i})}catch(t){let e=t instanceof Error?t.message:"Unknown error";return g.NextResponse.json({error:e},{status:500})}}e.s(["GET",0,C],40607);var j=e.i(40607);let A=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/sessions/stats/route",pathname:"/api/sessions/stats",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/sessions/stats/route.ts",nextConfigOutput:"",userland:j,...{}}),{workAsyncStorage:k,workUnitAsyncStorage:N,serverHooks:P}=A;async function b(e,t,a){a.requestMeta&&(0,s.setRequestMeta)(e,a.requestMeta),A.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/sessions/stats/route";g=g.replace(/\/index$/,"")||"/";let R=await A.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!R)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:S,nextConfig:E,parsedUrl:C,isDraftMode:j,prerenderManifest:k,routerServerContext:N,isOnDemandRevalidate:P,revalidateOnlyGenerated:b,resolvedPathname:T,clientReferenceManifest:M,serverActionsManifest:F}=R,q=(0,o.normalizeAppPath)(g),_=!!(k.dynamicRoutes[q]||k.routes[T]),U=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,C,!1):t.end("This page could not be found"),null);if(_&&!j){let e=!!k.routes[T],t=k.dynamicRoutes[q];if(t&&!1===t.fallback&&!e){if(E.adapterPath)return await U();throw new h.NoFallbackError}}let D=null;!_||A.isDev||j||(D="/index"===(D=T)?"/":D);let O=!0===A.isDev||!_,$=_&&!O;F&&M&&(0,i.setManifestsSingleton)({page:g,clientReferenceManifest:M,serverActionsManifest:F});let H=e.method||"GET",I=(0,n.getTracer)(),G=I.getActiveScopeSpan(),B=!!(null==N?void 0:N.isWrappedByNextServer),K=!!(0,s.getRequestMeta)(e,"minimalMode"),L=(0,s.getRequestMeta)(e,"incrementalCache")||await A.getIncrementalCache(e,E,k,K);null==L||L.resetRequestCache(),globalThis.__incrementalCache=L;let W={params:S,previewProps:k.preview,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:O,incrementalCache:L,cacheLifeProfiles:E.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,s)=>A.onRequestError(e,t,a,s,N)},sharedContext:{buildId:v,deploymentId:w}},z=new l.NodeNextRequest(e),V=new l.NodeNextResponse(t),X=d.NextRequestAdapter.fromNodeNextRequest(z,(0,d.signalFromNodeResponse)(t));try{let s,i=async e=>A.handle(X,W).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=I.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=`${H} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t),s&&s!==e&&(s.setAttribute("http.route",a),s.updateName(t))}else e.updateName(`${H} ${g}`)}),o=async s=>{var n,o;let l=async({previousCacheEntry:r})=>{try{if(!K&&P&&b&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await i(s);e.fetchMetrics=W.renderOpts.fetchMetrics;let o=W.renderOpts.pendingWaitUntil;o&&a.waitUntil&&(a.waitUntil(o),o=void 0);let l=W.renderOpts.collectedTags;if(!_)return await (0,p.sendResponse)(z,V,n,W.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,m.toNodeOutgoingHttpHeaders)(n.headers);l&&(t[x.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==W.renderOpts.collectedRevalidate&&!(W.renderOpts.collectedRevalidate>=x.INFINITE_CACHE)&&W.renderOpts.collectedRevalidate,a=void 0===W.renderOpts.collectedExpire||W.renderOpts.collectedExpire>=x.INFINITE_CACHE?void 0:W.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:n.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:g,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:P})},!1,N),t}},d=await A.handleResponse({req:e,nextConfig:E,cacheKey:D,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:k,isRoutePPREnabled:!1,isOnDemandRevalidate:P,revalidateOnlyGenerated:b,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:K});if(!_)return null;if((null==d||null==(n=d.value)?void 0:n.kind)!==y.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});K||t.setHeader("x-nextjs-cache",P?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),j&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,m.fromNodeOutgoingHttpHeaders)(d.value.headers);return K&&_||u.delete(x.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,f.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(z,V,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&G?await o(G):(s=I.getActiveScopeSpan(),await I.withPropagatedContext(e.headers,()=>I.trace(u.BaseServerSpan.handleRequest,{spanName:`${H} ${g}`,kind:n.SpanKind.SERVER,attributes:{"http.method":H,"http.target":e.url}},o),void 0,!B))}catch(t){if(t instanceof h.NoFallbackError||await A.onRequestError(e,t,{routerKind:"App Router",routePath:q,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:P})},!1,N),_)throw t;return await (0,p.sendResponse)(z,V,new Response(null,{status:500})),null}}e.s(["handler",0,b,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:k,workUnitAsyncStorage:N})},"routeModule",0,A,"serverHooks",0,P,"workAsyncStorage",0,k,"workUnitAsyncStorage",0,N],6299)},37661,e=>{e.v(t=>Promise.all(["server/chunks/[externals]_node-pty_12c-8pf._.js"].map(t=>e.l(t))).then(()=>t(75609)))}];

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