neural-loom 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/cache/.previewinfo +1 -1
  5. package/.next/cache/.rscinfo +1 -1
  6. package/.next/cache/.tsbuildinfo +1 -1
  7. package/.next/diagnostics/route-bundle-stats.json +2 -2
  8. package/.next/fallback-build-manifest.json +3 -3
  9. package/.next/prerender-manifest.json +3 -3
  10. package/.next/required-server-files.js +3 -3
  11. package/.next/required-server-files.json +3 -3
  12. package/.next/routes-manifest.json +6 -0
  13. package/.next/server/app/_global-error.html +1 -1
  14. package/.next/server/app/_global-error.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  17. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  18. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  19. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.html +1 -1
  21. package/.next/server/app/_not-found.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  26. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  27. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  28. package/.next/server/app/api/configs/route.js.nft.json +1 -1
  29. package/.next/server/app/api/context/aider/route.js.nft.json +1 -1
  30. package/.next/server/app/api/context/claude/route.js.nft.json +1 -1
  31. package/.next/server/app/api/context/route.js.nft.json +1 -1
  32. package/.next/server/app/api/context/ssh/route.js.nft.json +1 -1
  33. package/.next/server/app/api/files/route.js +1 -1
  34. package/.next/server/app/api/files/route.js.nft.json +1 -1
  35. package/.next/server/app/api/git/route.js +1 -1
  36. package/.next/server/app/api/git/route.js.nft.json +1 -1
  37. package/.next/server/app/api/recents/route.js.nft.json +1 -1
  38. package/.next/server/app/api/sessions/inject/route.js +1 -1
  39. package/.next/server/app/api/sessions/inject/route.js.nft.json +1 -1
  40. package/.next/server/app/api/sessions/input/route.js +1 -1
  41. package/.next/server/app/api/sessions/input/route.js.nft.json +1 -1
  42. package/.next/server/app/api/sessions/launch/route.js +1 -1
  43. package/.next/server/app/api/sessions/launch/route.js.nft.json +1 -1
  44. package/.next/server/app/api/sessions/model/route.js +1 -1
  45. package/.next/server/app/api/sessions/model/route.js.nft.json +1 -1
  46. package/.next/server/app/api/sessions/route.js +1 -1
  47. package/.next/server/app/api/sessions/route.js.nft.json +1 -1
  48. package/.next/server/app/api/sessions/scope/route.js +1 -1
  49. package/.next/server/app/api/sessions/scope/route.js.nft.json +1 -1
  50. package/.next/server/app/api/sessions/start/route.js +1 -1
  51. package/.next/server/app/api/sessions/start/route.js.nft.json +1 -1
  52. package/.next/server/app/api/sessions/stats/route.js +1 -1
  53. package/.next/server/app/api/sessions/stats/route.js.nft.json +1 -1
  54. package/.next/server/app/api/sessions/stop/route.js +1 -1
  55. package/.next/server/app/api/sessions/stop/route.js.nft.json +1 -1
  56. package/.next/server/app/api/sessions/upload-image/route.js +1 -1
  57. package/.next/server/app/api/sessions/upload-image/route.js.nft.json +1 -1
  58. package/.next/server/app/api/sql/connections/route.js +1 -1
  59. package/.next/server/app/api/sql/connections/route.js.nft.json +1 -1
  60. package/.next/server/app/api/sql/drivers/route/app-paths-manifest.json +3 -0
  61. package/.next/server/app/api/sql/drivers/route/build-manifest.json +9 -0
  62. package/.next/server/app/api/sql/drivers/route/server-reference-manifest.json +4 -0
  63. package/.next/server/app/api/sql/drivers/route.js +6 -0
  64. package/.next/server/app/api/sql/drivers/route.js.map +5 -0
  65. package/.next/server/app/api/sql/drivers/route.js.nft.json +1 -0
  66. package/.next/server/app/api/sql/drivers/route_client-reference-manifest.js +3 -0
  67. package/.next/server/app/api/sql/mcp/route.js +1 -1
  68. package/.next/server/app/api/sql/mcp/route.js.nft.json +1 -1
  69. package/.next/server/app/api/sql/query/route.js +1 -1
  70. package/.next/server/app/api/sql/query/route.js.nft.json +1 -1
  71. package/.next/server/app/api/sql/schema/route.js +1 -1
  72. package/.next/server/app/api/sql/schema/route.js.nft.json +1 -1
  73. package/.next/server/app/api/telemetry/route.js.nft.json +1 -1
  74. package/.next/server/app/index.html +1 -1
  75. package/.next/server/app/index.rsc +2 -2
  76. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  77. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  78. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  79. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  80. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  81. package/.next/server/app/page/react-loadable-manifest.json +3 -3
  82. package/.next/server/app/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app-paths-manifest.json +1 -0
  84. package/.next/server/chunks/[root-of-the-server]__00.krah._.js +114 -0
  85. package/.next/server/chunks/[root-of-the-server]__00.krah._.js.map +1 -0
  86. package/.next/server/chunks/[root-of-the-server]__018ug13._.js +3 -0
  87. package/.next/server/chunks/[root-of-the-server]__018ug13._.js.map +1 -0
  88. package/.next/server/chunks/[root-of-the-server]__02ier.3._.js +15 -0
  89. package/.next/server/chunks/[root-of-the-server]__02ier.3._.js.map +1 -0
  90. package/.next/server/chunks/[root-of-the-server]__02m4far._.js +1 -1
  91. package/.next/server/chunks/[root-of-the-server]__02m4far._.js.map +1 -1
  92. package/.next/server/chunks/[root-of-the-server]__04lxa97._.js +15 -0
  93. package/.next/server/chunks/[root-of-the-server]__04lxa97._.js.map +1 -0
  94. package/.next/server/chunks/[root-of-the-server]__09lbn1j._.js +3 -0
  95. package/.next/server/chunks/[root-of-the-server]__09lbn1j._.js.map +1 -0
  96. package/.next/server/chunks/[root-of-the-server]__0_wpk0y._.js +15 -0
  97. package/.next/server/chunks/[root-of-the-server]__0_wpk0y._.js.map +1 -0
  98. package/.next/server/chunks/[root-of-the-server]__0ctzfr2._.js +1 -1
  99. package/.next/server/chunks/[root-of-the-server]__0ctzfr2._.js.map +1 -1
  100. package/.next/server/chunks/[root-of-the-server]__0e9idf4._.js +114 -0
  101. package/.next/server/chunks/[root-of-the-server]__0e9idf4._.js.map +1 -0
  102. package/.next/server/chunks/[root-of-the-server]__0fe0p8z._.js +1 -1
  103. package/.next/server/chunks/[root-of-the-server]__0fe0p8z._.js.map +1 -1
  104. package/.next/server/chunks/[root-of-the-server]__0fozpi-._.js +125 -0
  105. package/.next/server/chunks/[root-of-the-server]__0fozpi-._.js.map +1 -0
  106. package/.next/server/chunks/[root-of-the-server]__0i0vbbm._.js +1 -1
  107. package/.next/server/chunks/[root-of-the-server]__0i0vbbm._.js.map +1 -1
  108. package/.next/server/chunks/[root-of-the-server]__0jtpjnb._.js +1 -1
  109. package/.next/server/chunks/[root-of-the-server]__0jtpjnb._.js.map +1 -1
  110. package/.next/server/chunks/[root-of-the-server]__0k_8diy._.js +15 -0
  111. package/.next/server/chunks/[root-of-the-server]__0k_8diy._.js.map +1 -0
  112. package/.next/server/chunks/[root-of-the-server]__0li1h1u._.js +13 -13
  113. package/.next/server/chunks/[root-of-the-server]__0li1h1u._.js.map +1 -1
  114. package/.next/server/chunks/[root-of-the-server]__0m0xdm-._.js +15 -0
  115. package/.next/server/chunks/[root-of-the-server]__0m0xdm-._.js.map +1 -0
  116. package/.next/server/chunks/[root-of-the-server]__0mkuqc3._.js +1 -1
  117. package/.next/server/chunks/[root-of-the-server]__0mkuqc3._.js.map +1 -1
  118. package/.next/server/chunks/[root-of-the-server]__0mz~7tk._.js +15 -0
  119. package/.next/server/chunks/[root-of-the-server]__0mz~7tk._.js.map +1 -0
  120. package/.next/server/chunks/[root-of-the-server]__0o60pwz._.js +15 -0
  121. package/.next/server/chunks/[root-of-the-server]__0o60pwz._.js.map +1 -0
  122. package/.next/server/chunks/[root-of-the-server]__0quymg_._.js +3 -0
  123. package/.next/server/chunks/[root-of-the-server]__0quymg_._.js.map +1 -0
  124. package/.next/server/chunks/[root-of-the-server]__0s096ts._.js +15 -0
  125. package/.next/server/chunks/[root-of-the-server]__0s096ts._.js.map +1 -0
  126. package/.next/server/chunks/[root-of-the-server]__0s0oi.9._.js +114 -0
  127. package/.next/server/chunks/[root-of-the-server]__0s0oi.9._.js.map +1 -0
  128. package/.next/server/chunks/[root-of-the-server]__0udaxr.._.js +15 -0
  129. package/.next/server/chunks/[root-of-the-server]__0udaxr.._.js.map +1 -0
  130. package/.next/server/chunks/[root-of-the-server]__0xx7.pw._.js +2 -2
  131. package/.next/server/chunks/[root-of-the-server]__0xx7.pw._.js.map +1 -1
  132. package/.next/server/chunks/[root-of-the-server]__0~uv7de._.js +15 -0
  133. package/.next/server/chunks/[root-of-the-server]__0~uv7de._.js.map +1 -0
  134. package/.next/server/chunks/_next-internal_server_app_api_sql_drivers_route_actions_06_~q-1.js +3 -0
  135. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_016qk~0.js +2 -2
  136. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_016qk~0.js.map +1 -1
  137. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0ev3h.z.js +1 -1
  138. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0ev3h.z.js.map +1 -1
  139. package/.next/server/chunks/ssr/_0t7oqy6._.js +1 -1
  140. package/.next/server/chunks/ssr/_0t7oqy6._.js.map +1 -1
  141. package/.next/server/middleware/middleware-manifest.json +5 -5
  142. package/.next/server/middleware-build-manifest.js +3 -3
  143. package/.next/server/middleware-manifest.json +5 -5
  144. package/.next/server/pages/404.html +1 -1
  145. package/.next/server/pages/500.html +1 -1
  146. package/.next/server/server-reference-manifest.js +1 -1
  147. package/.next/server/server-reference-manifest.json +1 -1
  148. package/.next/static/chunks/{0qu9wa_keet3..js → 02i8ipqrdqb4k.js} +4 -4
  149. package/.next/static/chunks/{0xhaghhxllgzs.js → 0opgpyt9f2o.y.js} +1 -1
  150. package/.next/static/chunks/{0-mwzfyigo.qs.js → 0uzl0alxdlg3l.js} +1 -1
  151. package/.next/static/chunks/{0r~-9nw2vt0gl.js → 0zt22n-2fftsr.js} +1 -1
  152. package/.next/trace +1 -1
  153. package/.next/trace-build +1 -1
  154. package/.next/types/routes.d.ts +2 -1
  155. package/.next/types/validator.ts +9 -0
  156. package/README.md +34 -1
  157. package/package.json +2 -3
  158. package/public/feature-guide.html +1 -1
  159. package/src/app/api/files/route.ts +8 -0
  160. package/src/app/api/git/route.ts +2 -0
  161. package/src/app/api/sessions/launch/route.ts +4 -1
  162. package/src/app/api/sql/drivers/route.ts +135 -0
  163. package/src/app/api/sql/query/route.ts +10 -0
  164. package/src/app/components/AiderWizard.tsx +1 -1
  165. package/src/app/components/ClaudeWizard.tsx +1 -1
  166. package/src/app/components/DbExplorer.tsx +57 -0
  167. package/src/app/page.tsx +0 -9
  168. package/src/lib/agents/AgentRunner.ts +18 -0
  169. package/src/lib/agents/SessionManager.ts +24 -0
  170. package/src/lib/agents/claudeModels.ts +49 -0
  171. package/src/lib/agents/runtime.ts +1 -1
  172. package/src/lib/audit.ts +44 -0
  173. package/src/lib/config.ts +27 -0
  174. package/src/lib/sql/McpServer.ts +11 -44
  175. package/src/lib/sql/adapters/MssqlAdapter.ts +2 -8
  176. package/src/lib/sql/adapters/MysqlAdapter.ts +2 -8
  177. package/src/lib/sql/adapters/PostgresAdapter.ts +3 -9
  178. package/src/lib/sql/adapters/SqliteAdapter.ts +3 -9
  179. package/src/lib/sql/loadDriver.ts +93 -0
  180. package/.next/server/chunks/[externals]__0tfzbjg._.js +0 -3
  181. package/.next/server/chunks/[root-of-the-server]__0.r1zm9._.js +0 -15
  182. package/.next/server/chunks/[root-of-the-server]__0.r1zm9._.js.map +0 -1
  183. package/.next/server/chunks/[root-of-the-server]__03_0gmx._.js +0 -15
  184. package/.next/server/chunks/[root-of-the-server]__03_0gmx._.js.map +0 -1
  185. package/.next/server/chunks/[root-of-the-server]__0ac9~el._.js +0 -3
  186. package/.next/server/chunks/[root-of-the-server]__0ac9~el._.js.map +0 -1
  187. package/.next/server/chunks/[root-of-the-server]__0avy0.e._.js +0 -15
  188. package/.next/server/chunks/[root-of-the-server]__0avy0.e._.js.map +0 -1
  189. package/.next/server/chunks/[root-of-the-server]__0c4n7et._.js +0 -15
  190. package/.next/server/chunks/[root-of-the-server]__0c4n7et._.js.map +0 -1
  191. package/.next/server/chunks/[root-of-the-server]__0dliu9v._.js +0 -15
  192. package/.next/server/chunks/[root-of-the-server]__0dliu9v._.js.map +0 -1
  193. package/.next/server/chunks/[root-of-the-server]__0i.1k6m._.js +0 -15
  194. package/.next/server/chunks/[root-of-the-server]__0i.1k6m._.js.map +0 -1
  195. package/.next/server/chunks/[root-of-the-server]__0o4bi75._.js +0 -114
  196. package/.next/server/chunks/[root-of-the-server]__0o4bi75._.js.map +0 -1
  197. package/.next/server/chunks/[root-of-the-server]__0ov-pzx._.js +0 -15
  198. package/.next/server/chunks/[root-of-the-server]__0ov-pzx._.js.map +0 -1
  199. package/.next/server/chunks/[root-of-the-server]__0oza.h3._.js +0 -114
  200. package/.next/server/chunks/[root-of-the-server]__0oza.h3._.js.map +0 -1
  201. package/.next/server/chunks/[root-of-the-server]__0p_sd_b._.js +0 -15
  202. package/.next/server/chunks/[root-of-the-server]__0p_sd_b._.js.map +0 -1
  203. package/.next/server/chunks/[root-of-the-server]__0uv1g1q._.js +0 -15
  204. package/.next/server/chunks/[root-of-the-server]__0uv1g1q._.js.map +0 -1
  205. package/.next/server/chunks/[root-of-the-server]__0v~ctt1._.js +0 -15
  206. package/.next/server/chunks/[root-of-the-server]__0v~ctt1._.js.map +0 -1
  207. package/.next/server/chunks/[root-of-the-server]__0ztnzjr._.js +0 -125
  208. package/.next/server/chunks/[root-of-the-server]__0ztnzjr._.js.map +0 -1
  209. package/.next/server/chunks/[root-of-the-server]__109k-xt._.js +0 -114
  210. package/.next/server/chunks/[root-of-the-server]__109k-xt._.js.map +0 -1
  211. /package/.next/server/chunks/{[externals]__0tfzbjg._.js.map → _next-internal_server_app_api_sql_drivers_route_actions_06_~q-1.js.map} +0 -0
  212. /package/.next/static/{7Rt23xVOwYg-hHmWh-bzT → VBSsDlGuAVHnm8EevFS5o}/_buildManifest.js +0 -0
  213. /package/.next/static/{7Rt23xVOwYg-hHmWh-bzT → VBSsDlGuAVHnm8EevFS5o}/_clientMiddlewareManifest.js +0 -0
  214. /package/.next/static/{7Rt23xVOwYg-hHmWh-bzT → VBSsDlGuAVHnm8EevFS5o}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/config.ts","../../../src/lib/workspaceParser.ts","../../../src/lib/agents/ContextManager.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js","../../../src/app/api/sessions/stats/route.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport os from \"os\";\n\nlet cachedConfigDir: string | null = null;\n\nexport function getConfigDir(): string {\n if (cachedConfigDir) {\n return cachedConfigDir;\n }\n\n const primaryDir = path.join(process.env.ORIGINAL_CWD || process.cwd(), \".ai\", \"neural-loom\");\n \n try {\n // Check if primary directory exists. If not, try to create it.\n if (!fs.existsSync(primaryDir)) {\n fs.mkdirSync(primaryDir, { recursive: true });\n }\n // Perform a test write to verify write permissions (crucial for read-only directories like C:\\Program Files)\n const testFile = path.join(primaryDir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n cachedConfigDir = primaryDir;\n return primaryDir;\n } catch (err) {\n // If EPERM or any other write error occurs, fall back to the user's home directory\n console.warn(`[Config] Primary config dir is not writable (${primaryDir}). Falling back to home directory.`);\n const fallbackDir = path.join(os.homedir(), \".ai\", \"neural-loom\");\n try {\n if (!fs.existsSync(fallbackDir)) {\n fs.mkdirSync(fallbackDir, { recursive: true });\n }\n cachedConfigDir = fallbackDir;\n return fallbackDir;\n } catch (fallbackErr) {\n console.error(\"[Config] Fallback config dir is also not writable!\", fallbackErr);\n cachedConfigDir = primaryDir;\n return primaryDir;\n }\n }\n}\n\nexport function isDirWritable(dir: string): boolean {\n try {\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n const testFile = path.join(dir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isSystemDirectory(dir: string): boolean {\n const normalized = dir.toLowerCase().replace(/\\\\/g, \"/\");\n return (\n normalized.includes(\"/program files\") ||\n normalized.includes(\"/windows/system32\") ||\n normalized.includes(\"/winnt\") ||\n normalized.startsWith(\"/usr/\") ||\n normalized.startsWith(\"/bin/\") ||\n normalized.startsWith(\"/sbin/\") ||\n normalized.startsWith(\"/etc/\") ||\n normalized.startsWith(\"/var/\")\n );\n}\n\nexport function getDefaultWorkspaceRoot(): string {\n const launchDir = process.env.ORIGINAL_CWD || process.cwd();\n \n if (isDirWritable(launchDir) && !isSystemDirectory(launchDir)) {\n return launchDir.replace(/\\\\/g, \"/\");\n }\n \n const home = os.homedir();\n const commonDirs = [\n path.join(home, \"OneDrive\", \"Projects\"),\n path.join(home, \"Projects\"),\n path.join(home, \"source\", \"repos\"),\n path.join(home, \"Documents\"),\n home\n ];\n \n for (const dir of commonDirs) {\n try {\n if (fs.existsSync(dir) && isDirWritable(dir)) {\n return dir.replace(/\\\\/g, \"/\");\n }\n } catch {\n // Continue checking\n }\n }\n \n return home.replace(/\\\\/g, \"/\");\n}\n\n","import fs from \"fs\";\nimport path from \"path\";\n\n// Cache parsed folders per workspace root, keyed off the .code-workspace file's\n// mtime so repeated polling doesn't re-read and re-parse it every call.\nconst folderCache = new Map<string, { mtimeMs: number; folders: string[] }>();\n\nexport function getWorkspaceFileFolders(workspaceRoot: string): string[] {\n try {\n if (!workspaceRoot || !fs.existsSync(workspaceRoot)) return [];\n\n // Normalize workspaceRoot path\n const normRoot = path.resolve(workspaceRoot).replace(/\\\\/g, \"/\");\n\n const files = fs.readdirSync(normRoot);\n const workspaceFile = files.find(f => f.endsWith(\".code-workspace\"));\n if (!workspaceFile) {\n folderCache.delete(normRoot);\n return [];\n }\n\n const filePath = path.join(normRoot, workspaceFile);\n const mtimeMs = fs.statSync(filePath).mtimeMs;\n const cached = folderCache.get(normRoot);\n if (cached && cached.mtimeMs === mtimeMs) {\n return cached.folders;\n }\n\n const content = fs.readFileSync(filePath, \"utf8\");\n const json = JSON.parse(content);\n \n if (!json.folders || !Array.isArray(json.folders)) {\n folderCache.set(normRoot, { mtimeMs, folders: [] });\n return [];\n }\n\n const folders: string[] = [];\n for (const folder of json.folders) {\n if (folder.path) {\n // Resolve relative to workspace root (where the workspace file resides)\n const resolved = path.resolve(normRoot, folder.path).replace(/\\\\/g, \"/\");\n\n // Exclude the workspace root folder itself\n if (resolved !== normRoot) {\n if (fs.existsSync(resolved)) {\n folders.push(resolved);\n }\n }\n }\n }\n folderCache.set(normRoot, { mtimeMs, folders });\n return folders;\n } catch (err) {\n console.error(\"[WorkspaceParser] Failed to parse code-workspace file:\", err);\n return [];\n }\n}\n","import fs from \"fs\";\nimport path from \"path\";\nimport { isDirWritable } from \"../config\";\n\ninterface McpServerEntry {\n command: string;\n args: string[];\n [key: string]: unknown;\n}\n\nexport class ContextManager {\n private static writableCache = new Map<string, boolean>();\n\n private static isWritable(root: string): boolean {\n if (this.writableCache.has(root)) {\n return this.writableCache.get(root)!;\n }\n const res = isDirWritable(root);\n this.writableCache.set(root, res);\n return res;\n }\n\n private static get workspaceRoot(): string {\n return process.env.ORIGINAL_CWD || process.cwd();\n }\n\n private static ensureDirs(root: string) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n const aiDir = path.join(root, \".ai\", \"neural-loom\");\n if (!fs.existsSync(aiDir)) {\n fs.mkdirSync(aiDir, { recursive: true });\n }\n\n const commandDir = path.join(root, \".claude\", \"commands\");\n if (!fs.existsSync(commandDir)) {\n fs.mkdirSync(commandDir, { recursive: true });\n }\n } catch (err) {\n console.warn(`[ContextManager] Failed to ensure directories at ${root}:`, err);\n }\n }\n\n public static initializeStaging(root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n\n // Create /ccp.md custom slash command file\n const ccpPath = path.join(root, \".claude\", \"commands\", \"ccp.md\");\n if (!fs.existsSync(ccpPath)) {\n fs.writeFileSync(\n ccpPath,\n \"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\"\n );\n }\n\n // Create /ccc.md custom slash command file\n const cccPath = path.join(root, \".claude\", \"commands\", \"ccc.md\");\n if (!fs.existsSync(cccPath)) {\n fs.writeFileSync(\n cccPath,\n \"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\"\n );\n }\n\n this.ensureMcpConfig(root);\n } catch (err) {\n console.warn(`[ContextManager] Failed to initialize staging at ${root}:`, err);\n }\n }\n\n // Registers the built-in SQL MCP server (see src/lib/sql/McpServer.ts) with\n // Claude Code by writing a project-scoped .mcp.json. Without this, spawned\n // Claude Code sessions have no way of discovering the server exists.\n private static ensureMcpConfig(root: string) {\n const mcpPath = path.join(root, \".mcp.json\");\n let config: { mcpServers?: Record<string, McpServerEntry> } = {};\n\n if (fs.existsSync(mcpPath)) {\n try {\n config = JSON.parse(fs.readFileSync(mcpPath, \"utf8\"));\n } catch (err) {\n console.warn(`[ContextManager] Existing .mcp.json at ${mcpPath} is not valid JSON, leaving it untouched:`, err);\n return;\n }\n }\n\n if (!config.mcpServers) {\n config.mcpServers = {};\n }\n\n // The SQL MCP bridge resolves connection profiles by workspace root, and\n // connections are workspace-scoped (no global tier). Pin the exact root as\n // the third CLI arg so the bridge reports the same x-workspace-root the\n // dashboard saved connections under. Without it, bin/cli.js falls back to\n // ORIGINAL_CWD/process.cwd() — which for a per-session workspace differs\n // from the save root — and every SQL tool call comes back empty, i.e.\n // Claude Code is effectively denied access to the databases.\n //\n // process.cwd() is the package root here (never the user's workspace —\n // bin/cli.js chdir's into it before booting Next.js), so this reliably\n // finds our own CLI regardless of how NeuralLoom was launched.\n const absRoot = path.resolve(root);\n const cliPath = path.join(process.cwd(), \"bin\", \"cli.js\");\n const desired: McpServerEntry = fs.existsSync(cliPath)\n ? { command: process.execPath, args: [cliPath, \"mcp\", absRoot] }\n : { command: \"neural-loom\", args: [\"mcp\", absRoot] };\n\n const existing = config.mcpServers[\"neural-loom-sql\"];\n if (existing) {\n // Only rewrite an entry that looks like one we generated, so a user's\n // hand-tuned command is never clobbered. Upgrade a managed entry in place\n // when it is missing the pinned root or points at a stale one (e.g. an\n // older install that shipped `args: [cli, \"mcp\"]`).\n if (!this.isManagedMcpEntry(existing)) {\n return;\n }\n if (JSON.stringify(existing.args) === JSON.stringify(desired.args)) {\n return; // already correct\n }\n }\n\n config.mcpServers[\"neural-loom-sql\"] = desired;\n fs.writeFileSync(mcpPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n\n // A `neural-loom-sql` entry is \"ours to manage\" when it is a `... mcp`\n // invocation of our own CLI (either the `neural-loom` binary or a cli.js\n // path). Anything else is treated as a user customization and left untouched.\n private static isManagedMcpEntry(entry: McpServerEntry): boolean {\n if (!entry || !Array.isArray(entry.args) || !entry.args.includes(\"mcp\")) {\n return false;\n }\n if (entry.command === \"neural-loom\") {\n return true;\n }\n return entry.args.some(\n (a) => typeof a === \"string\" && (a.endsWith(\"cli.js\") || a.includes(\"neural-loom\"))\n );\n }\n\n public static updatePrompt(promptText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n fs.writeFileSync(promptFile, promptText);\n } catch (err) {\n console.error(`[ContextManager] Failed to write prompt file at ${root}:`, err);\n }\n }\n\n public static updateContext(contextText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const contextFile = path.join(root, \".ai\", \"neural-loom\", \"ccontext.md\");\n fs.writeFileSync(contextFile, contextText);\n } catch (err) {\n console.error(`[ContextManager] Failed to write context file at ${root}:`, err);\n }\n }\n\n public static updateRules(rulesText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n fs.writeFileSync(agentsMdPath, rulesText, \"utf8\");\n } catch (err) {\n console.error(`[ContextManager] Failed to write rules file at ${root}:`, err);\n }\n }\n\n public static loadPrompt(root: string = process.env.ORIGINAL_CWD || process.cwd()): string {\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n return fs.existsSync(promptFile) ? fs.readFileSync(promptFile, \"utf8\") : \"\";\n }\n\n public static loadRules(root: string = process.env.ORIGINAL_CWD || process.cwd()): string {\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n return fs.existsSync(agentsMdPath) ? fs.readFileSync(agentsMdPath, \"utf8\") : \"\";\n }\n\n public static compileGlobalRules() {\n this.compileSessionContext();\n }\n\n public static compileSessionContext(root: string = process.env.ORIGINAL_CWD || process.cwd(), scopedDirs?: string[]) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n this.initializeStaging(root);\n \n // Check if AGENTS.md rules template exists\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n let agentsRules = \"\";\n if (fs.existsSync(agentsMdPath)) {\n agentsRules = fs.readFileSync(agentsMdPath, \"utf8\");\n } else {\n // Try fallback from global\n const fallbackPath = path.join(this.workspaceRoot, \"AGENTS.md\");\n if (fs.existsSync(fallbackPath)) {\n agentsRules = fs.readFileSync(fallbackPath, \"utf8\");\n }\n }\n\n // Generate maps\n let maps = `## Workspace Root Map (${root}):\\n${this.generateProjectMapFor(root)}`;\n\n if (scopedDirs && Array.isArray(scopedDirs)) {\n scopedDirs.forEach((dir) => {\n if (fs.existsSync(dir)) {\n maps += `\\n\\n## Scoped Directory Map (${dir}):\\n${this.generateProjectMapFor(dir)}`;\n }\n });\n }\n\n // Combine rules and folder map\n const compiledContext = `# System Rules & Guidelines\\n\\n${agentsRules}\\n\\n# Project File Hierarchy Map\\n\\n${maps}`;\n this.updateContext(compiledContext, root);\n\n // Write a default empty prompt staging file if missing\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n if (!fs.existsSync(promptFile)) {\n fs.writeFileSync(promptFile, \"Hello! Please review the project context (/ccc) and check for any tasks to execute.\");\n }\n } catch (err) {\n console.warn(`[ContextManager] Failed to compile session context at ${root}:`, err);\n }\n }\n\n private static generateProjectMapFor(targetDir: string): string {\n try {\n const walk = (dir: string, depth = 0): string => {\n if (depth > 2) return \"\"; // Keep map depth concise to fit tokens\n let result = \"\";\n const files = fs.readdirSync(dir, { withFileTypes: true });\n for (const file of files) {\n if (\n file.name.startsWith(\".\") ||\n file.name === \"node_modules\" ||\n file.name === \"out\" ||\n file.name === \".next\"\n ) {\n continue;\n }\n const indent = \" \".repeat(depth);\n if (file.isDirectory()) {\n result += `${indent}- [Dir] ${file.name}/\\n`;\n result += walk(path.join(dir, file.name), depth + 1);\n } else {\n result += `${indent}- [File] ${file.name}\\n`;\n }\n }\n return result;\n };\n return walk(targetDir);\n } catch (err) {\n return \"Error generating project map: \" + (err instanceof Error ? err.message : String(err));\n }\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/sessions/stats/route\",\n pathname: \"/api/sessions/stats\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/sessions/stats/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"INNER_APP_ROUTE\")\n } : {}\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/sessions/stats/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId,\n deploymentId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n","import { NextResponse } from \"next/server\";\nimport { SessionManager } from \"@/lib/agents/SessionManager\";\nimport { promisify } from \"util\";\nimport { execFile } from \"child_process\";\nimport os from \"os\";\n\nconst execFilePromise = promisify(execFile);\n\n// Real per-process stats for the PTY. Returns null when unavailable (pidusage\n// not installed, or no live pid) so callers report honestly instead of faking it.\nasync function getProcessStats(pid: number | undefined): Promise<{ cpu: number; memory: number } | null> {\n if (!pid) return null;\n try {\n /* eslint-disable @typescript-eslint/no-require-imports */\n const pidusage = eval(\"require\")(\"pidusage\");\n const stat = await pidusage(pid);\n return { cpu: stat.cpu, memory: stat.memory };\n } catch {\n return null;\n }\n}\n\nexport async function GET(request: Request) {\n try {\n const { searchParams } = new URL(request.url);\n const id = searchParams.get(\"id\");\n\n if (!id) {\n return NextResponse.json({ error: \"Missing session id\" }, { status: 400 });\n }\n\n const manager = SessionManager.getInstance();\n const session = manager.getSession(id);\n if (!session) {\n return NextResponse.json({ error: \"Session not found\" }, { status: 404 });\n }\n\n // Default response metrics. `available` reports whether these are real\n // measurements (vs. a placeholder when telemetry can't be collected).\n let cpu = \"0.0%\";\n let memory = \"0.0MiB\";\n let memoryPercent = \"0.0%\";\n let available = false;\n\n if (session.status === \"running\") {\n const isDocker = session.type === \"claude-docker\" || session.type === \"aider-docker\";\n if (isDocker) {\n try {\n // Real container stats from the Docker daemon.\n const containerName = `neural-loom-session-${id}`;\n const { stdout } = await execFilePromise(\"docker\", [\n \"stats\",\n containerName,\n \"--no-stream\",\n \"--format\",\n \"{{.CPUPerc}},{{.MemUsage}},{{.MemPerc}}\",\n ]);\n const parts = stdout.toString().trim().split(\",\");\n if (parts.length >= 3) {\n cpu = parts[0].trim();\n memory = parts[1].trim().split(\" / \")[0]; // used part, e.g. \"142.2MiB\"\n memoryPercent = parts[2].trim();\n available = true;\n }\n } catch {\n // Docker daemon/container not reachable — leave defaults, available=false.\n }\n } else {\n // Real per-process stats for the local/SSH PTY process.\n const stats = await getProcessStats(session.getPid());\n if (stats) {\n cpu = stats.cpu.toFixed(1) + \"%\";\n memory = (stats.memory / (1024 * 1024)).toFixed(1) + \"MiB\";\n memoryPercent = ((stats.memory / os.totalmem()) * 100).toFixed(2) + \"%\";\n available = true;\n }\n }\n }\n\n return NextResponse.json({\n success: true,\n id,\n status: session.status,\n type: session.type,\n cpu,\n memory,\n memoryPercent,\n available,\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return NextResponse.json({ error: errorMessage }, { status: 500 });\n }\n}\n"],"names":["cachedConfigDir","getConfigDir","primaryDir","join","process","env","ORIGINAL_CWD","cwd","existsSync","mkdirSync","recursive","testFile","Math","random","toString","substring","writeFileSync","unlinkSync","err","console","warn","fallbackDir","homedir","fallbackErr","error","isDirWritable","dir","isSystemDirectory","normalized","toLowerCase","replace","includes","startsWith","getDefaultWorkspaceRoot","launchDir","home","commonDirs","folderCache","Map","getWorkspaceFileFolders","workspaceRoot","normRoot","resolve","files","readdirSync","workspaceFile","find","f","endsWith","delete","filePath","mtimeMs","statSync","cached","get","folders","content","readFileSync","json","JSON","parse","Array","isArray","set","folder","path","resolved","push","ContextManager","writableCache","isWritable","root","has","res","ensureDirs","aiDir","commandDir","initializeStaging","ccpPath","cccPath","ensureMcpConfig","mcpPath","config","mcpServers","absRoot","cliPath","desired","command","execPath","args","existing","isManagedMcpEntry","stringify","entry","some","a","updatePrompt","promptText","promptFile","updateContext","contextText","contextFile","updateRules","rulesText","agentsMdPath","loadPrompt","loadRules","compileGlobalRules","compileSessionContext","scopedDirs","agentsRules","fallbackPath","maps","generateProjectMapFor","forEach","compiledContext","targetDir","walk","depth","result","withFileTypes","file","name","indent","repeat","isDirectory","Error","message","String","execFilePromise","getProcessStats","pid","pidusage","eval","stat","cpu","memory","isDocker","GET","request","searchParams","URL","url","id","status","manager","getInstance","session","getSession","memoryPercent","available","type","success","containerName","stdout","parts","trim","split","length","stats","getPid","toFixed","totalmem","errorMessage"],"mappings":"4pCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEA,IAAIA,EAAiC,KAE9B,SAASC,IACd,GAAID,EACF,OAAOA,EAGT,IAAME,EAJe,AAIF,EAAA,OAAI,CAACC,IAAI,CAACC,QAAQC,GAAG,CAACC,YAAY,EAAIF,QAAQG,GAAG,GAAI,MAAO,eAE/E,GAAI,CAEE,AAAC,EAAA,OAAE,CAACC,UAAU,CAACN,IACjB,EAAA,OAD8B,AAC5B,CAACO,SAAS,CAACP,EAAY,CAAEQ,UAAW,EAAK,GAG7C,IAAMC,EAAW,EAAA,OAAI,CAACR,IAAI,CAACD,EAAY,eAAiBU,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,IAI7F,OAHA,EAAA,OAAE,CAACC,aAAa,CAACL,EAAU,QAC3B,EAAA,OAAE,CAACM,UAAU,CAACN,GACdX,EAAkBE,EACXA,CACT,CAAE,MAAOgB,EAAK,CAEZC,QAAQC,IAAI,CAAC,CAAC,6CAA6C,EAAElB,EAAW,kCAAkC,CAAC,EAC3G,IAAMmB,EAAc,EAAA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ared/lib/no-fallback-error.external.js"))},18622,(e,r,t)=>{r.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,r,t)=>{r.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,r,t)=>{r.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,r,t)=>{r.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,r,t)=>{r.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},14747,(e,r,t)=>{r.exports=e.x("path",()=>require("path"))},22734,(e,r,t)=>{r.exports=e.x("fs",()=>require("fs"))},46786,(e,r,t)=>{r.exports=e.x("os",()=>require("os"))},98003,e=>{"use strict";var r=e.i(22734),t=e.i(14747),s=e.i(46786);let n=null;function i(e){try{r.default.existsSync(e)||r.default.mkdirSync(e,{recursive:!0});let s=t.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return r.default.writeFileSync(s,"test"),r.default.unlinkSync(s),!0}catch{return!1}}e.s(["getConfigDir",0,function(){if(n)return n;let e=t.default.join(process.env.ORIGINAL_CWD||process.cwd(),".ai","neural-loom");try{r.default.existsSync(e)||r.default.mkdirSync(e,{recursive:!0});let s=t.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return r.default.writeFileSync(s,"test"),r.default.unlinkSync(s),n=e,e}catch(a){console.warn(`[Config] Primary config dir is not writable (${e}). Falling back to home directory.`);let i=t.default.join(s.default.homedir(),".ai","neural-loom");try{return r.default.existsSync(i)||r.default.mkdirSync(i,{recursive:!0}),n=i,i}catch(r){return console.error("[Config] Fallback config dir is also not writable!",r),n=e,e}}},"getDefaultWorkspaceRoot",0,function(){let e,n=process.env.ORIGINAL_CWD||process.cwd();if(i(n)&&!((e=n.toLowerCase().replace(/\\/g,"/")).includes("/program files")||e.includes("/windows/system32")||e.includes("/winnt")||e.startsWith("/usr/")||e.startsWith("/bin/")||e.startsWith("/sbin/")||e.startsWith("/etc/")||e.startsWith("/var/")))return n.replace(/\\/g,"/");let a=s.default.homedir();for(let e of[t.default.join(a,"OneDrive","Projects"),t.default.join(a,"Projects"),t.default.join(a,"source","repos"),t.default.join(a,"Documents"),a])try{if(r.default.existsSync(e)&&i(e))return e.replace(/\\/g,"/")}catch{}return a.replace(/\\/g,"/")},"isDirWritable",0,i])}];
2
-
3
- //# sourceMappingURL=%5Broot-of-the-server%5D__0ac9~el._.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/config.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport os from \"os\";\n\nlet cachedConfigDir: string | null = null;\n\nexport function getConfigDir(): string {\n if (cachedConfigDir) {\n return cachedConfigDir;\n }\n\n const primaryDir = path.join(process.env.ORIGINAL_CWD || process.cwd(), \".ai\", \"neural-loom\");\n \n try {\n // Check if primary directory exists. If not, try to create it.\n if (!fs.existsSync(primaryDir)) {\n fs.mkdirSync(primaryDir, { recursive: true });\n }\n // Perform a test write to verify write permissions (crucial for read-only directories like C:\\Program Files)\n const testFile = path.join(primaryDir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n cachedConfigDir = primaryDir;\n return primaryDir;\n } catch (err) {\n // If EPERM or any other write error occurs, fall back to the user's home directory\n console.warn(`[Config] Primary config dir is not writable (${primaryDir}). Falling back to home directory.`);\n const fallbackDir = path.join(os.homedir(), \".ai\", \"neural-loom\");\n try {\n if (!fs.existsSync(fallbackDir)) {\n fs.mkdirSync(fallbackDir, { recursive: true });\n }\n cachedConfigDir = fallbackDir;\n return fallbackDir;\n } catch (fallbackErr) {\n console.error(\"[Config] Fallback config dir is also not writable!\", fallbackErr);\n cachedConfigDir = primaryDir;\n return primaryDir;\n }\n }\n}\n\nexport function isDirWritable(dir: string): boolean {\n try {\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n const testFile = path.join(dir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isSystemDirectory(dir: string): boolean {\n const normalized = dir.toLowerCase().replace(/\\\\/g, \"/\");\n return (\n normalized.includes(\"/program files\") ||\n normalized.includes(\"/windows/system32\") ||\n normalized.includes(\"/winnt\") ||\n normalized.startsWith(\"/usr/\") ||\n normalized.startsWith(\"/bin/\") ||\n normalized.startsWith(\"/sbin/\") ||\n normalized.startsWith(\"/etc/\") ||\n normalized.startsWith(\"/var/\")\n );\n}\n\nexport function getDefaultWorkspaceRoot(): string {\n const launchDir = process.env.ORIGINAL_CWD || process.cwd();\n \n if (isDirWritable(launchDir) && !isSystemDirectory(launchDir)) {\n return launchDir.replace(/\\\\/g, \"/\");\n }\n \n const home = os.homedir();\n const commonDirs = [\n path.join(home, \"OneDrive\", \"Projects\"),\n path.join(home, \"Projects\"),\n path.join(home, \"source\", \"repos\"),\n path.join(home, \"Documents\"),\n home\n ];\n \n for (const dir of commonDirs) {\n try {\n if (fs.existsSync(dir) && isDirWritable(dir)) {\n return dir.replace(/\\\\/g, \"/\");\n }\n } catch {\n // Continue checking\n }\n }\n \n return home.replace(/\\\\/g, \"/\");\n}\n\n"],"names":["cachedConfigDir","getConfigDir","primaryDir","join","process","env","ORIGINAL_CWD","cwd","existsSync","mkdirSync","recursive","testFile","Math","random","toString","substring","writeFileSync","unlinkSync","err","console","warn","fallbackDir","homedir","fallbackErr","error","isDirWritable","dir","isSystemDirectory","normalized","toLowerCase","replace","includes","startsWith","getDefaultWorkspaceRoot","launchDir","home","commonDirs"],"mappings":"4pCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,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5BZ,SAAS,CAACY,EAAa,CAAEX,WAAW,CAAK,GAE9CV,EAAkBqB,EACXA,CACT,CAAE,MAAOE,EAAa,CAGpB,OAFAJ,QAAQK,KAAK,CAAC,qDAAsDD,GACpEvB,EAAkBE,EACXA,CACT,CACF,CACF,8BA8BO,SAAS+B,EACd,MAAMC,EAAY9B,QAAQC,GAAG,CAACC,YAAY,EAAIF,QAAQG,GAAG,GAEzD,GAAIkB,EAAcS,MAdhBN,CAFIA,EAAaF,AAgBgCQ,EAhB5BL,GAgBS,CAACF,MAA8B,CAhB7B,GAAGG,OAAO,CAAC,MAAO,MAEvCC,QAAQ,CAAC,mBACpBH,EAAWG,QAAQ,CAAC,sBACpBH,EAAWG,QAAQ,CAAC,WACpBH,EAAWI,UAAU,CAAC,UACtBJ,EAAWI,UAAU,CAAC,UACtBJ,EAAWI,UAAU,CAAC,WACtBJ,EAAWI,UAAU,CAAC,UACtBJ,EAAWI,UAAU,CAAC,QAAA,EAQtB,OAAOE,EAAUJ,OAAO,CAAC,MAAO,KAGlC,IAAMK,EAAO,EAAA,OAAE,CAACb,OAAO,GASvB,IAAK,IAAMI,IARQ,CACjB,EAAA,AAOgBU,OAPZ,CAACjC,GAOuB,CAPnB,CAACgC,EAAM,WAAY,YAC5B,EAAA,OAAI,CAAChC,IAAI,CAACgC,EAAM,YAChB,EAAA,OAAI,CAAChC,IAAI,CAACgC,EAAM,SAAU,SAC1B,EAAA,OAAI,CAAChC,IAAI,CAACgC,EAAM,aAChBA,EACD,CAGC,GAAI,CACF,GAAI,EAAA,OAAE,CAAC3B,UAAU,CAACkB,IAAQD,EAAcC,GACtC,GAD4C,IACrCA,EAAII,OAAO,CAAC,MAAO,IAE9B,CAAE,KAAM,CAER,CAGF,OAAOK,EAAKL,OAAO,CAAC,MAAO,IAC7B"}
@@ -1,15 +0,0 @@
1
- module.exports=[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"))},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"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},46786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},98003,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(46786);let s=null;function n(e){try{t.default.existsSync(e)||t.default.mkdirSync(e,{recursive:!0});let a=r.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return t.default.writeFileSync(a,"test"),t.default.unlinkSync(a),!0}catch{return!1}}e.s(["getConfigDir",0,function(){if(s)return s;let e=r.default.join(process.env.ORIGINAL_CWD||process.cwd(),".ai","neural-loom");try{t.default.existsSync(e)||t.default.mkdirSync(e,{recursive:!0});let a=r.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return t.default.writeFileSync(a,"test"),t.default.unlinkSync(a),s=e,e}catch(i){console.warn(`[Config] Primary config dir is not writable (${e}). Falling back to home directory.`);let n=r.default.join(a.default.homedir(),".ai","neural-loom");try{return t.default.existsSync(n)||t.default.mkdirSync(n,{recursive:!0}),s=n,n}catch(t){return console.error("[Config] Fallback config dir is also not writable!",t),s=e,e}}},"getDefaultWorkspaceRoot",0,function(){let e,s=process.env.ORIGINAL_CWD||process.cwd();if(n(s)&&!((e=s.toLowerCase().replace(/\\/g,"/")).includes("/program files")||e.includes("/windows/system32")||e.includes("/winnt")||e.startsWith("/usr/")||e.startsWith("/bin/")||e.startsWith("/sbin/")||e.startsWith("/etc/")||e.startsWith("/var/")))return s.replace(/\\/g,"/");let i=a.default.homedir();for(let e of[r.default.join(i,"OneDrive","Projects"),r.default.join(i,"Projects"),r.default.join(i,"source","repos"),r.default.join(i,"Documents"),i])try{if(t.default.existsSync(e)&&n(e))return e.replace(/\\/g,"/")}catch{}return i.replace(/\\/g,"/")},"isDirWritable",0,n])},24417,e=>{"use strict";var t=e.i(22734),r=e.i(14747);let a=new Map;e.s(["getWorkspaceFileFolders",0,function(e){try{if(!e||!t.default.existsSync(e))return[];let s=r.default.resolve(e).replace(/\\/g,"/"),n=t.default.readdirSync(s).find(e=>e.endsWith(".code-workspace"));if(!n)return a.delete(s),[];let i=r.default.join(s,n),o=t.default.statSync(i).mtimeMs,l=a.get(s);if(l&&l.mtimeMs===o)return l.folders;let c=t.default.readFileSync(i,"utf8"),u=JSON.parse(c);if(!u.folders||!Array.isArray(u.folders))return a.set(s,{mtimeMs:o,folders:[]}),[];let d=[];for(let e of u.folders)if(e.path){let a=r.default.resolve(s,e.path).replace(/\\/g,"/");a!==s&&t.default.existsSync(a)&&d.push(a)}return a.set(s,{mtimeMs:o,folders:d}),d}catch(e){return console.error("[WorkspaceParser] Failed to parse code-workspace file:",e),[]}}])},24361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},46619,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(98003);class s{static writableCache=new Map;static isWritable(e){if(this.writableCache.has(e))return this.writableCache.get(e);let t=(0,a.isDirWritable)(e);return this.writableCache.set(e,t),t}static get workspaceRoot(){return process.env.ORIGINAL_CWD||process.cwd()}static ensureDirs(e){if(this.isWritable(e))try{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})}catch(t){console.warn(`[ContextManager] Failed to ensure directories at ${e}:`,t)}}static initializeStaging(e=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(e))try{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"),this.ensureMcpConfig(e)}catch(t){console.warn(`[ContextManager] Failed to initialize staging at ${e}:`,t)}}static ensureMcpConfig(e){let a=r.default.join(e,".mcp.json"),s={};if(t.default.existsSync(a))try{s=JSON.parse(t.default.readFileSync(a,"utf8"))}catch(e){console.warn(`[ContextManager] Existing .mcp.json at ${a} is not valid JSON, leaving it untouched:`,e);return}s.mcpServers||(s.mcpServers={});let n=r.default.resolve(e),i=r.default.join(process.cwd(),"bin","cli.js"),o=t.default.existsSync(i)?{command:process.execPath,args:[i,"mcp",n]}:{command:"neural-loom",args:["mcp",n]},l=s.mcpServers["neural-loom-sql"];(!l||this.isManagedMcpEntry(l)&&JSON.stringify(l.args)!==JSON.stringify(o.args))&&(s.mcpServers["neural-loom-sql"]=o,t.default.writeFileSync(a,JSON.stringify(s,null,2)+"\n"))}static isManagedMcpEntry(e){return!!e&&!!Array.isArray(e.args)&&!!e.args.includes("mcp")&&("neural-loom"===e.command||e.args.some(e=>"string"==typeof e&&(e.endsWith("cli.js")||e.includes("neural-loom"))))}static updatePrompt(e,a=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(a))try{this.ensureDirs(a);let s=r.default.join(a,".ai","neural-loom","cprompt.md");t.default.writeFileSync(s,e)}catch(e){console.error(`[ContextManager] Failed to write prompt file at ${a}:`,e)}}static updateContext(e,a=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(a))try{this.ensureDirs(a);let s=r.default.join(a,".ai","neural-loom","ccontext.md");t.default.writeFileSync(s,e)}catch(e){console.error(`[ContextManager] Failed to write context file at ${a}:`,e)}}static updateRules(e,a=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(a))try{this.ensureDirs(a);let s=r.default.join(a,"AGENTS.md");t.default.writeFileSync(s,e,"utf8")}catch(e){console.error(`[ContextManager] Failed to write rules file at ${a}:`,e)}}static loadPrompt(e=process.env.ORIGINAL_CWD||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.env.ORIGINAL_CWD||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.env.ORIGINAL_CWD||process.cwd(),a){if(this.isWritable(e))try{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}):
2
- ${this.generateProjectMapFor(e)}`;a&&Array.isArray(a)&&a.forEach(e=>{t.default.existsSync(e)&&(i+=`
3
-
4
- ## Scoped Directory Map (${e}):
5
- ${this.generateProjectMapFor(e)}`)});let o=`# System Rules & Guidelines
6
-
7
- ${n}
8
-
9
- # Project File Hierarchy Map
10
-
11
- ${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.")}catch(t){console.warn(`[ContextManager] Failed to compile session context at ${e}:`,t)}}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}/
12
- `,n+=a(r.default.join(e,i.name),s+1)):n+=`${t}- [File] ${i.name}
13
- `}return n};return a(e)}catch(e){return"Error generating project map: "+(e instanceof Error?e.message:String(e))}}}e.s(["ContextManager",0,s])},78761,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),c=e.i(87718),u=e.i(95169),d=e.i(47587),p=e.i(66012),f=e.i(70101),h=e.i(26937),m=e.i(10372),x=e.i(93695);e.i(52474);var g=e.i(220),y=e.i(89171),w=e.i(29307);async function S(e){try{let{id:t,text:r}=await e.json();if(!t||void 0===r)return y.NextResponse.json({error:"Missing required fields 'id' or 'text'."},{status:400});let a=w.SessionManager.getInstance().getSession(t);if(!a)return y.NextResponse.json({error:"Session not found"},{status:404});return await a.sendInput(r),y.NextResponse.json({success:!0,logs:a.logs})}catch(t){let e=t instanceof Error?t.message:"Unknown error";return y.NextResponse.json({error:e},{status:500})}}e.s(["POST",0,S],9853);var v=e.i(9853);let R=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/sessions/input/route",pathname:"/api/sessions/input",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/sessions/input/route.ts",nextConfigOutput:"",userland:v,...{}}),{workAsyncStorage:C,workUnitAsyncStorage:j,serverHooks:b}=R;async function A(e,t,a){a.requestMeta&&(0,s.setRequestMeta)(e,a.requestMeta),R.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let y="/api/sessions/input/route";y=y.replace(/\/index$/,"")||"/";let w=await R.prepare(e,t,{srcPage:y,multiZoneDraftMode:!1});if(!w)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:S,deploymentId:v,params:C,nextConfig:j,parsedUrl:b,isDraftMode:A,prerenderManifest:E,routerServerContext:N,isOnDemandRevalidate:k,revalidateOnlyGenerated:M,resolvedPathname:F,clientReferenceManifest:I,serverActionsManifest:O}=w,D=(0,o.normalizeAppPath)(y),P=!!(E.dynamicRoutes[D]||E.routes[F]),_=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,b,!1):t.end("This page could not be found"),null);if(P&&!A){let e=!!E.routes[F],t=E.dynamicRoutes[D];if(t&&!1===t.fallback&&!e){if(j.adapterPath)return await _();throw new x.NoFallbackError}}let T=null;!P||R.isDev||A||(T="/index"===(T=F)?"/":T);let W=!0===R.isDev||!P,q=P&&!W;O&&I&&(0,i.setManifestsSingleton)({page:y,clientReferenceManifest:I,serverActionsManifest:O});let $=e.method||"GET",G=(0,n.getTracer)(),H=G.getActiveScopeSpan(),U=!!(null==N?void 0:N.isWrappedByNextServer),L=!!(0,s.getRequestMeta)(e,"minimalMode"),K=(0,s.getRequestMeta)(e,"incrementalCache")||await R.getIncrementalCache(e,j,E,L);null==K||K.resetRequestCache(),globalThis.__incrementalCache=K;let B={params:C,previewProps:E.preview,renderOpts:{experimental:{authInterrupts:!!j.experimental.authInterrupts},cacheComponents:!!j.cacheComponents,supportsDynamicResponse:W,incrementalCache:K,cacheLifeProfiles:j.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,s)=>R.onRequestError(e,t,a,s,N)},sharedContext:{buildId:S,deploymentId:v}},J=new l.NodeNextRequest(e),z=new l.NodeNextResponse(t),V=c.NextRequestAdapter.fromNodeNextRequest(J,(0,c.signalFromNodeResponse)(t));try{let s,i=async e=>R.handle(V,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=G.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=`${$} ${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(`${$} ${y}`)}),o=async s=>{var n,o;let l=async({previousCacheEntry:r})=>{try{if(!L&&k&&M&&!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=B.renderOpts.fetchMetrics;let o=B.renderOpts.pendingWaitUntil;o&&a.waitUntil&&(a.waitUntil(o),o=void 0);let l=B.renderOpts.collectedTags;if(!P)return await (0,p.sendResponse)(J,z,n,B.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(n.headers);l&&(t[m.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,a=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=m.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:g.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 R.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:q,isOnDemandRevalidate:k})},!1,N),t}},c=await R.handleResponse({req:e,nextConfig:j,cacheKey:T,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:E,isRoutePPREnabled:!1,isOnDemandRevalidate:k,revalidateOnlyGenerated:M,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:L});if(!P)return null;if((null==c||null==(n=c.value)?void 0:n.kind)!==g.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(o=c.value)?void 0:o.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",k?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,f.fromNodeOutgoingHttpHeaders)(c.value.headers);return L&&P||u.delete(m.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,h.getCacheControlHeader)(c.cacheControl)),await (0,p.sendResponse)(J,z,new Response(c.value.body,{headers:u,status:c.value.status||200})),null};U&&H?await o(H):(s=G.getActiveScopeSpan(),await G.withPropagatedContext(e.headers,()=>G.trace(u.BaseServerSpan.handleRequest,{spanName:`${$} ${y}`,kind:n.SpanKind.SERVER,attributes:{"http.method":$,"http.target":e.url}},o),void 0,!U))}catch(t){if(t instanceof x.NoFallbackError||await R.onRequestError(e,t,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:q,isOnDemandRevalidate:k})},!1,N),P)throw t;return await (0,p.sendResponse)(J,z,new Response(null,{status:500})),null}}e.s(["handler",0,A,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:C,workUnitAsyncStorage:j})},"routeModule",0,R,"serverHooks",0,b,"workAsyncStorage",0,C,"workUnitAsyncStorage",0,j],78761)}];
14
-
15
- //# sourceMappingURL=%5Broot-of-the-server%5D__0avy0.e._.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/config.ts","../../../src/lib/workspaceParser.ts","../../../src/lib/agents/ContextManager.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js","../../../src/app/api/sessions/input/route.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport os from \"os\";\n\nlet cachedConfigDir: string | null = null;\n\nexport function getConfigDir(): string {\n if (cachedConfigDir) {\n return cachedConfigDir;\n }\n\n const primaryDir = path.join(process.env.ORIGINAL_CWD || process.cwd(), \".ai\", \"neural-loom\");\n \n try {\n // Check if primary directory exists. If not, try to create it.\n if (!fs.existsSync(primaryDir)) {\n fs.mkdirSync(primaryDir, { recursive: true });\n }\n // Perform a test write to verify write permissions (crucial for read-only directories like C:\\Program Files)\n const testFile = path.join(primaryDir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n cachedConfigDir = primaryDir;\n return primaryDir;\n } catch (err) {\n // If EPERM or any other write error occurs, fall back to the user's home directory\n console.warn(`[Config] Primary config dir is not writable (${primaryDir}). Falling back to home directory.`);\n const fallbackDir = path.join(os.homedir(), \".ai\", \"neural-loom\");\n try {\n if (!fs.existsSync(fallbackDir)) {\n fs.mkdirSync(fallbackDir, { recursive: true });\n }\n cachedConfigDir = fallbackDir;\n return fallbackDir;\n } catch (fallbackErr) {\n console.error(\"[Config] Fallback config dir is also not writable!\", fallbackErr);\n cachedConfigDir = primaryDir;\n return primaryDir;\n }\n }\n}\n\nexport function isDirWritable(dir: string): boolean {\n try {\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n const testFile = path.join(dir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isSystemDirectory(dir: string): boolean {\n const normalized = dir.toLowerCase().replace(/\\\\/g, \"/\");\n return (\n normalized.includes(\"/program files\") ||\n normalized.includes(\"/windows/system32\") ||\n normalized.includes(\"/winnt\") ||\n normalized.startsWith(\"/usr/\") ||\n normalized.startsWith(\"/bin/\") ||\n normalized.startsWith(\"/sbin/\") ||\n normalized.startsWith(\"/etc/\") ||\n normalized.startsWith(\"/var/\")\n );\n}\n\nexport function getDefaultWorkspaceRoot(): string {\n const launchDir = process.env.ORIGINAL_CWD || process.cwd();\n \n if (isDirWritable(launchDir) && !isSystemDirectory(launchDir)) {\n return launchDir.replace(/\\\\/g, \"/\");\n }\n \n const home = os.homedir();\n const commonDirs = [\n path.join(home, \"OneDrive\", \"Projects\"),\n path.join(home, \"Projects\"),\n path.join(home, \"source\", \"repos\"),\n path.join(home, \"Documents\"),\n home\n ];\n \n for (const dir of commonDirs) {\n try {\n if (fs.existsSync(dir) && isDirWritable(dir)) {\n return dir.replace(/\\\\/g, \"/\");\n }\n } catch {\n // Continue checking\n }\n }\n \n return home.replace(/\\\\/g, \"/\");\n}\n\n","import fs from \"fs\";\nimport path from \"path\";\n\n// Cache parsed folders per workspace root, keyed off the .code-workspace file's\n// mtime so repeated polling doesn't re-read and re-parse it every call.\nconst folderCache = new Map<string, { mtimeMs: number; folders: string[] }>();\n\nexport function getWorkspaceFileFolders(workspaceRoot: string): string[] {\n try {\n if (!workspaceRoot || !fs.existsSync(workspaceRoot)) return [];\n\n // Normalize workspaceRoot path\n const normRoot = path.resolve(workspaceRoot).replace(/\\\\/g, \"/\");\n\n const files = fs.readdirSync(normRoot);\n const workspaceFile = files.find(f => f.endsWith(\".code-workspace\"));\n if (!workspaceFile) {\n folderCache.delete(normRoot);\n return [];\n }\n\n const filePath = path.join(normRoot, workspaceFile);\n const mtimeMs = fs.statSync(filePath).mtimeMs;\n const cached = folderCache.get(normRoot);\n if (cached && cached.mtimeMs === mtimeMs) {\n return cached.folders;\n }\n\n const content = fs.readFileSync(filePath, \"utf8\");\n const json = JSON.parse(content);\n \n if (!json.folders || !Array.isArray(json.folders)) {\n folderCache.set(normRoot, { mtimeMs, folders: [] });\n return [];\n }\n\n const folders: string[] = [];\n for (const folder of json.folders) {\n if (folder.path) {\n // Resolve relative to workspace root (where the workspace file resides)\n const resolved = path.resolve(normRoot, folder.path).replace(/\\\\/g, \"/\");\n\n // Exclude the workspace root folder itself\n if (resolved !== normRoot) {\n if (fs.existsSync(resolved)) {\n folders.push(resolved);\n }\n }\n }\n }\n folderCache.set(normRoot, { mtimeMs, folders });\n return folders;\n } catch (err) {\n console.error(\"[WorkspaceParser] Failed to parse code-workspace file:\", err);\n return [];\n }\n}\n","import fs from \"fs\";\nimport path from \"path\";\nimport { isDirWritable } from \"../config\";\n\ninterface McpServerEntry {\n command: string;\n args: string[];\n [key: string]: unknown;\n}\n\nexport class ContextManager {\n private static writableCache = new Map<string, boolean>();\n\n private static isWritable(root: string): boolean {\n if (this.writableCache.has(root)) {\n return this.writableCache.get(root)!;\n }\n const res = isDirWritable(root);\n this.writableCache.set(root, res);\n return res;\n }\n\n private static get workspaceRoot(): string {\n return process.env.ORIGINAL_CWD || process.cwd();\n }\n\n private static ensureDirs(root: string) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n const aiDir = path.join(root, \".ai\", \"neural-loom\");\n if (!fs.existsSync(aiDir)) {\n fs.mkdirSync(aiDir, { recursive: true });\n }\n\n const commandDir = path.join(root, \".claude\", \"commands\");\n if (!fs.existsSync(commandDir)) {\n fs.mkdirSync(commandDir, { recursive: true });\n }\n } catch (err) {\n console.warn(`[ContextManager] Failed to ensure directories at ${root}:`, err);\n }\n }\n\n public static initializeStaging(root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n\n // Create /ccp.md custom slash command file\n const ccpPath = path.join(root, \".claude\", \"commands\", \"ccp.md\");\n if (!fs.existsSync(ccpPath)) {\n fs.writeFileSync(\n ccpPath,\n \"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\"\n );\n }\n\n // Create /ccc.md custom slash command file\n const cccPath = path.join(root, \".claude\", \"commands\", \"ccc.md\");\n if (!fs.existsSync(cccPath)) {\n fs.writeFileSync(\n cccPath,\n \"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\"\n );\n }\n\n this.ensureMcpConfig(root);\n } catch (err) {\n console.warn(`[ContextManager] Failed to initialize staging at ${root}:`, err);\n }\n }\n\n // Registers the built-in SQL MCP server (see src/lib/sql/McpServer.ts) with\n // Claude Code by writing a project-scoped .mcp.json. Without this, spawned\n // Claude Code sessions have no way of discovering the server exists.\n private static ensureMcpConfig(root: string) {\n const mcpPath = path.join(root, \".mcp.json\");\n let config: { mcpServers?: Record<string, McpServerEntry> } = {};\n\n if (fs.existsSync(mcpPath)) {\n try {\n config = JSON.parse(fs.readFileSync(mcpPath, \"utf8\"));\n } catch (err) {\n console.warn(`[ContextManager] Existing .mcp.json at ${mcpPath} is not valid JSON, leaving it untouched:`, err);\n return;\n }\n }\n\n if (!config.mcpServers) {\n config.mcpServers = {};\n }\n\n // The SQL MCP bridge resolves connection profiles by workspace root, and\n // connections are workspace-scoped (no global tier). Pin the exact root as\n // the third CLI arg so the bridge reports the same x-workspace-root the\n // dashboard saved connections under. Without it, bin/cli.js falls back to\n // ORIGINAL_CWD/process.cwd() — which for a per-session workspace differs\n // from the save root — and every SQL tool call comes back empty, i.e.\n // Claude Code is effectively denied access to the databases.\n //\n // process.cwd() is the package root here (never the user's workspace —\n // bin/cli.js chdir's into it before booting Next.js), so this reliably\n // finds our own CLI regardless of how NeuralLoom was launched.\n const absRoot = path.resolve(root);\n const cliPath = path.join(process.cwd(), \"bin\", \"cli.js\");\n const desired: McpServerEntry = fs.existsSync(cliPath)\n ? { command: process.execPath, args: [cliPath, \"mcp\", absRoot] }\n : { command: \"neural-loom\", args: [\"mcp\", absRoot] };\n\n const existing = config.mcpServers[\"neural-loom-sql\"];\n if (existing) {\n // Only rewrite an entry that looks like one we generated, so a user's\n // hand-tuned command is never clobbered. Upgrade a managed entry in place\n // when it is missing the pinned root or points at a stale one (e.g. an\n // older install that shipped `args: [cli, \"mcp\"]`).\n if (!this.isManagedMcpEntry(existing)) {\n return;\n }\n if (JSON.stringify(existing.args) === JSON.stringify(desired.args)) {\n return; // already correct\n }\n }\n\n config.mcpServers[\"neural-loom-sql\"] = desired;\n fs.writeFileSync(mcpPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n\n // A `neural-loom-sql` entry is \"ours to manage\" when it is a `... mcp`\n // invocation of our own CLI (either the `neural-loom` binary or a cli.js\n // path). Anything else is treated as a user customization and left untouched.\n private static isManagedMcpEntry(entry: McpServerEntry): boolean {\n if (!entry || !Array.isArray(entry.args) || !entry.args.includes(\"mcp\")) {\n return false;\n }\n if (entry.command === \"neural-loom\") {\n return true;\n }\n return entry.args.some(\n (a) => typeof a === \"string\" && (a.endsWith(\"cli.js\") || a.includes(\"neural-loom\"))\n );\n }\n\n public static updatePrompt(promptText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n fs.writeFileSync(promptFile, promptText);\n } catch (err) {\n console.error(`[ContextManager] Failed to write prompt file at ${root}:`, err);\n }\n }\n\n public static updateContext(contextText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const contextFile = path.join(root, \".ai\", \"neural-loom\", \"ccontext.md\");\n fs.writeFileSync(contextFile, contextText);\n } catch (err) {\n console.error(`[ContextManager] Failed to write context file at ${root}:`, err);\n }\n }\n\n public static updateRules(rulesText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n fs.writeFileSync(agentsMdPath, rulesText, \"utf8\");\n } catch (err) {\n console.error(`[ContextManager] Failed to write rules file at ${root}:`, err);\n }\n }\n\n public static loadPrompt(root: string = process.env.ORIGINAL_CWD || process.cwd()): string {\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n return fs.existsSync(promptFile) ? fs.readFileSync(promptFile, \"utf8\") : \"\";\n }\n\n public static loadRules(root: string = process.env.ORIGINAL_CWD || process.cwd()): string {\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n return fs.existsSync(agentsMdPath) ? fs.readFileSync(agentsMdPath, \"utf8\") : \"\";\n }\n\n public static compileGlobalRules() {\n this.compileSessionContext();\n }\n\n public static compileSessionContext(root: string = process.env.ORIGINAL_CWD || process.cwd(), scopedDirs?: string[]) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n this.initializeStaging(root);\n \n // Check if AGENTS.md rules template exists\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n let agentsRules = \"\";\n if (fs.existsSync(agentsMdPath)) {\n agentsRules = fs.readFileSync(agentsMdPath, \"utf8\");\n } else {\n // Try fallback from global\n const fallbackPath = path.join(this.workspaceRoot, \"AGENTS.md\");\n if (fs.existsSync(fallbackPath)) {\n agentsRules = fs.readFileSync(fallbackPath, \"utf8\");\n }\n }\n\n // Generate maps\n let maps = `## Workspace Root Map (${root}):\\n${this.generateProjectMapFor(root)}`;\n\n if (scopedDirs && Array.isArray(scopedDirs)) {\n scopedDirs.forEach((dir) => {\n if (fs.existsSync(dir)) {\n maps += `\\n\\n## Scoped Directory Map (${dir}):\\n${this.generateProjectMapFor(dir)}`;\n }\n });\n }\n\n // Combine rules and folder map\n const compiledContext = `# System Rules & Guidelines\\n\\n${agentsRules}\\n\\n# Project File Hierarchy Map\\n\\n${maps}`;\n this.updateContext(compiledContext, root);\n\n // Write a default empty prompt staging file if missing\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n if (!fs.existsSync(promptFile)) {\n fs.writeFileSync(promptFile, \"Hello! Please review the project context (/ccc) and check for any tasks to execute.\");\n }\n } catch (err) {\n console.warn(`[ContextManager] Failed to compile session context at ${root}:`, err);\n }\n }\n\n private static generateProjectMapFor(targetDir: string): string {\n try {\n const walk = (dir: string, depth = 0): string => {\n if (depth > 2) return \"\"; // Keep map depth concise to fit tokens\n let result = \"\";\n const files = fs.readdirSync(dir, { withFileTypes: true });\n for (const file of files) {\n if (\n file.name.startsWith(\".\") ||\n file.name === \"node_modules\" ||\n file.name === \"out\" ||\n file.name === \".next\"\n ) {\n continue;\n }\n const indent = \" \".repeat(depth);\n if (file.isDirectory()) {\n result += `${indent}- [Dir] ${file.name}/\\n`;\n result += walk(path.join(dir, file.name), depth + 1);\n } else {\n result += `${indent}- [File] ${file.name}\\n`;\n }\n }\n return result;\n };\n return walk(targetDir);\n } catch (err) {\n return \"Error generating project map: \" + (err instanceof Error ? err.message : String(err));\n }\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/sessions/input/route\",\n pathname: \"/api/sessions/input\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/sessions/input/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"INNER_APP_ROUTE\")\n } : {}\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/sessions/input/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId,\n deploymentId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n","import { NextResponse } from \"next/server\";\nimport { SessionManager } from \"@/lib/agents/SessionManager\";\n\nexport async function POST(request: Request) {\n try {\n const body = await request.json();\n const { id, text } = body;\n\n if (!id || text === undefined) {\n return NextResponse.json({ error: \"Missing required fields 'id' or 'text'.\" }, { status: 400 });\n }\n\n const manager = SessionManager.getInstance();\n const session = manager.getSession(id);\n\n if (!session) {\n return NextResponse.json({ error: \"Session not found\" }, { status: 404 });\n }\n\n await session.sendInput(text);\n\n return NextResponse.json({\n success: true,\n logs: session.logs\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return NextResponse.json({ error: errorMessage }, { status: 500 });\n }\n}\n"],"names":["cachedConfigDir","getConfigDir","primaryDir","join","process","env","ORIGINAL_CWD","cwd","existsSync","mkdirSync","recursive","testFile","Math","random","toString","substring","writeFileSync","unlinkSync","err","console","warn","fallbackDir","homedir","fallbackErr","error","isDirWritable","dir","isSystemDirectory","normalized","toLowerCase","replace","includes","startsWith","getDefaultWorkspaceRoot","launchDir","home","commonDirs","folderCache","Map","getWorkspaceFileFolders","workspaceRoot","normRoot","resolve","files","readdirSync","workspaceFile","find","f","endsWith","delete","filePath","mtimeMs","statSync","cached","get","folders","content","readFileSync","json","JSON","parse","Array","isArray","set","folder","path","resolved","push","ContextManager","writableCache","isWritable","root","has","res","ensureDirs","aiDir","commandDir","initializeStaging","ccpPath","cccPath","ensureMcpConfig","mcpPath","config","mcpServers","absRoot","cliPath","desired","command","execPath","args","existing","isManagedMcpEntry","stringify","entry","some","a","updatePrompt","promptText","promptFile","updateContext","contextText","contextFile","updateRules","rulesText","agentsMdPath","loadPrompt","loadRules","compileGlobalRules","compileSessionContext","scopedDirs","agentsRules","fallbackPath","maps","generateProjectMapFor","forEach","compiledContext","targetDir","walk","depth","result","withFileTypes","file","name","indent","repeat","isDirectory","Error","message","String","POST","request","body","id","text","undefined","status","manager","getInstance","session","getSession","sendInput","success","logs","errorMessage"],"mappings":"4pCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,E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Aa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,mCA5TA,SAAS,EACL,MAAO,CAAA,EAAA,EAAA,UAAA,AAAW,EAAC,kBACf,uBACA,CACJ,EACJ","ignoreList":[3]}
@@ -1,15 +0,0 @@
1
- module.exports=[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"))},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"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},46786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},98003,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(46786);let s=null;function i(e){try{t.default.existsSync(e)||t.default.mkdirSync(e,{recursive:!0});let a=r.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return t.default.writeFileSync(a,"test"),t.default.unlinkSync(a),!0}catch{return!1}}e.s(["getConfigDir",0,function(){if(s)return s;let e=r.default.join(process.env.ORIGINAL_CWD||process.cwd(),".ai","neural-loom");try{t.default.existsSync(e)||t.default.mkdirSync(e,{recursive:!0});let a=r.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return t.default.writeFileSync(a,"test"),t.default.unlinkSync(a),s=e,e}catch(n){console.warn(`[Config] Primary config dir is not writable (${e}). Falling back to home directory.`);let i=r.default.join(a.default.homedir(),".ai","neural-loom");try{return t.default.existsSync(i)||t.default.mkdirSync(i,{recursive:!0}),s=i,i}catch(t){return console.error("[Config] Fallback config dir is also not writable!",t),s=e,e}}},"getDefaultWorkspaceRoot",0,function(){let e,s=process.env.ORIGINAL_CWD||process.cwd();if(i(s)&&!((e=s.toLowerCase().replace(/\\/g,"/")).includes("/program files")||e.includes("/windows/system32")||e.includes("/winnt")||e.startsWith("/usr/")||e.startsWith("/bin/")||e.startsWith("/sbin/")||e.startsWith("/etc/")||e.startsWith("/var/")))return s.replace(/\\/g,"/");let n=a.default.homedir();for(let e of[r.default.join(n,"OneDrive","Projects"),r.default.join(n,"Projects"),r.default.join(n,"source","repos"),r.default.join(n,"Documents"),n])try{if(t.default.existsSync(e)&&i(e))return e.replace(/\\/g,"/")}catch{}return n.replace(/\\/g,"/")},"isDirWritable",0,i])},24417,e=>{"use strict";var t=e.i(22734),r=e.i(14747);let a=new Map;e.s(["getWorkspaceFileFolders",0,function(e){try{if(!e||!t.default.existsSync(e))return[];let s=r.default.resolve(e).replace(/\\/g,"/"),i=t.default.readdirSync(s).find(e=>e.endsWith(".code-workspace"));if(!i)return a.delete(s),[];let n=r.default.join(s,i),o=t.default.statSync(n).mtimeMs,l=a.get(s);if(l&&l.mtimeMs===o)return l.folders;let c=t.default.readFileSync(n,"utf8"),u=JSON.parse(c);if(!u.folders||!Array.isArray(u.folders))return a.set(s,{mtimeMs:o,folders:[]}),[];let d=[];for(let e of u.folders)if(e.path){let a=r.default.resolve(s,e.path).replace(/\\/g,"/");a!==s&&t.default.existsSync(a)&&d.push(a)}return a.set(s,{mtimeMs:o,folders:d}),d}catch(e){return console.error("[WorkspaceParser] Failed to parse code-workspace file:",e),[]}}])},24361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},46619,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(98003);class s{static writableCache=new Map;static isWritable(e){if(this.writableCache.has(e))return this.writableCache.get(e);let t=(0,a.isDirWritable)(e);return this.writableCache.set(e,t),t}static get workspaceRoot(){return process.env.ORIGINAL_CWD||process.cwd()}static ensureDirs(e){if(this.isWritable(e))try{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})}catch(t){console.warn(`[ContextManager] Failed to ensure directories at ${e}:`,t)}}static initializeStaging(e=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(e))try{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"),this.ensureMcpConfig(e)}catch(t){console.warn(`[ContextManager] Failed to initialize staging at ${e}:`,t)}}static ensureMcpConfig(e){let a=r.default.join(e,".mcp.json"),s={};if(t.default.existsSync(a))try{s=JSON.parse(t.default.readFileSync(a,"utf8"))}catch(e){console.warn(`[ContextManager] Existing .mcp.json at ${a} is not valid JSON, leaving it untouched:`,e);return}s.mcpServers||(s.mcpServers={});let i=r.default.resolve(e),n=r.default.join(process.cwd(),"bin","cli.js"),o=t.default.existsSync(n)?{command:process.execPath,args:[n,"mcp",i]}:{command:"neural-loom",args:["mcp",i]},l=s.mcpServers["neural-loom-sql"];(!l||this.isManagedMcpEntry(l)&&JSON.stringify(l.args)!==JSON.stringify(o.args))&&(s.mcpServers["neural-loom-sql"]=o,t.default.writeFileSync(a,JSON.stringify(s,null,2)+"\n"))}static isManagedMcpEntry(e){return!!e&&!!Array.isArray(e.args)&&!!e.args.includes("mcp")&&("neural-loom"===e.command||e.args.some(e=>"string"==typeof e&&(e.endsWith("cli.js")||e.includes("neural-loom"))))}static updatePrompt(e,a=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(a))try{this.ensureDirs(a);let s=r.default.join(a,".ai","neural-loom","cprompt.md");t.default.writeFileSync(s,e)}catch(e){console.error(`[ContextManager] Failed to write prompt file at ${a}:`,e)}}static updateContext(e,a=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(a))try{this.ensureDirs(a);let s=r.default.join(a,".ai","neural-loom","ccontext.md");t.default.writeFileSync(s,e)}catch(e){console.error(`[ContextManager] Failed to write context file at ${a}:`,e)}}static updateRules(e,a=process.env.ORIGINAL_CWD||process.cwd()){if(this.isWritable(a))try{this.ensureDirs(a);let s=r.default.join(a,"AGENTS.md");t.default.writeFileSync(s,e,"utf8")}catch(e){console.error(`[ContextManager] Failed to write rules file at ${a}:`,e)}}static loadPrompt(e=process.env.ORIGINAL_CWD||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.env.ORIGINAL_CWD||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.env.ORIGINAL_CWD||process.cwd(),a){if(this.isWritable(e))try{this.ensureDirs(e),this.initializeStaging(e);let s=r.default.join(e,"AGENTS.md"),i="";if(t.default.existsSync(s))i=t.default.readFileSync(s,"utf8");else{let e=r.default.join(this.workspaceRoot,"AGENTS.md");t.default.existsSync(e)&&(i=t.default.readFileSync(e,"utf8"))}let n=`## Workspace Root Map (${e}):
2
- ${this.generateProjectMapFor(e)}`;a&&Array.isArray(a)&&a.forEach(e=>{t.default.existsSync(e)&&(n+=`
3
-
4
- ## Scoped Directory Map (${e}):
5
- ${this.generateProjectMapFor(e)}`)});let o=`# System Rules & Guidelines
6
-
7
- ${i}
8
-
9
- # Project File Hierarchy Map
10
-
11
- ${n}`;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.")}catch(t){console.warn(`[ContextManager] Failed to compile session context at ${e}:`,t)}}static generateProjectMapFor(e){try{let a=(e,s=0)=>{if(s>2)return"";let i="";for(let n of t.default.readdirSync(e,{withFileTypes:!0})){if(n.name.startsWith(".")||"node_modules"===n.name||"out"===n.name||".next"===n.name)continue;let t=" ".repeat(s);n.isDirectory()?(i+=`${t}- [Dir] ${n.name}/
12
- `,i+=a(r.default.join(e,n.name),s+1)):i+=`${t}- [File] ${n.name}
13
- `}return i};return a(e)}catch(e){return"Error generating project map: "+(e instanceof Error?e.message:String(e))}}}e.s(["ContextManager",0,s])},71188,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),s=e.i(59756),i=e.i(61916),n=e.i(74677),o=e.i(69741),l=e.i(16795),c=e.i(87718),u=e.i(95169),d=e.i(47587),p=e.i(66012),f=e.i(70101),h=e.i(26937),m=e.i(10372),x=e.i(93695);e.i(52474);var y=e.i(220),g=e.i(89171),w=e.i(29307);async function S(e){try{let{id:t,delete:r}=await e.json();if(!t)return g.NextResponse.json({error:"Missing required field 'id'."},{status:400});let a=w.SessionManager.getInstance();if(r){let e=await a.deleteSession(t);return g.NextResponse.json({success:e})}{let e=await a.stopSession(t);return g.NextResponse.json({success:e})}}catch(t){let e=t instanceof Error?t.message:"Unknown error";return g.NextResponse.json({error:e},{status:500})}}e.s(["POST",0,S],64662);var v=e.i(64662);let R=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/sessions/stop/route",pathname:"/api/sessions/stop",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/sessions/stop/route.ts",nextConfigOutput:"",userland:v,...{}}),{workAsyncStorage:C,workUnitAsyncStorage:j,serverHooks:b}=R;async function A(e,t,a){a.requestMeta&&(0,s.setRequestMeta)(e,a.requestMeta),R.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/sessions/stop/route";g=g.replace(/\/index$/,"")||"/";let w=await R.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!w)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:S,deploymentId:v,params:C,nextConfig:j,parsedUrl:b,isDraftMode:A,prerenderManifest:E,routerServerContext:N,isOnDemandRevalidate:k,revalidateOnlyGenerated:M,resolvedPathname:F,clientReferenceManifest:I,serverActionsManifest:O}=w,D=(0,o.normalizeAppPath)(g),P=!!(E.dynamicRoutes[D]||E.routes[F]),_=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,b,!1):t.end("This page could not be found"),null);if(P&&!A){let e=!!E.routes[F],t=E.dynamicRoutes[D];if(t&&!1===t.fallback&&!e){if(j.adapterPath)return await _();throw new x.NoFallbackError}}let T=null;!P||R.isDev||A||(T="/index"===(T=F)?"/":T);let W=!0===R.isDev||!P,q=P&&!W;O&&I&&(0,n.setManifestsSingleton)({page:g,clientReferenceManifest:I,serverActionsManifest:O});let $=e.method||"GET",G=(0,i.getTracer)(),H=G.getActiveScopeSpan(),U=!!(null==N?void 0:N.isWrappedByNextServer),L=!!(0,s.getRequestMeta)(e,"minimalMode"),K=(0,s.getRequestMeta)(e,"incrementalCache")||await R.getIncrementalCache(e,j,E,L);null==K||K.resetRequestCache(),globalThis.__incrementalCache=K;let B={params:C,previewProps:E.preview,renderOpts:{experimental:{authInterrupts:!!j.experimental.authInterrupts},cacheComponents:!!j.cacheComponents,supportsDynamicResponse:W,incrementalCache:K,cacheLifeProfiles:j.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,s)=>R.onRequestError(e,t,a,s,N)},sharedContext:{buildId:S,deploymentId:v}},J=new l.NodeNextRequest(e),z=new l.NodeNextResponse(t),V=c.NextRequestAdapter.fromNodeNextRequest(J,(0,c.signalFromNodeResponse)(t));try{let s,n=async e=>R.handle(V,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=G.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=`${$} ${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(`${$} ${g}`)}),o=async s=>{var i,o;let l=async({previousCacheEntry:r})=>{try{if(!L&&k&&M&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await n(s);e.fetchMetrics=B.renderOpts.fetchMetrics;let o=B.renderOpts.pendingWaitUntil;o&&a.waitUntil&&(a.waitUntil(o),o=void 0);let l=B.renderOpts.collectedTags;if(!P)return await (0,p.sendResponse)(J,z,i,B.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(i.headers);l&&(t[m.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,a=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=m.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await R.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:q,isOnDemandRevalidate:k})},!1,N),t}},c=await R.handleResponse({req:e,nextConfig:j,cacheKey:T,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:E,isRoutePPREnabled:!1,isOnDemandRevalidate:k,revalidateOnlyGenerated:M,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:L});if(!P)return null;if((null==c||null==(i=c.value)?void 0:i.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(o=c.value)?void 0:o.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",k?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,f.fromNodeOutgoingHttpHeaders)(c.value.headers);return L&&P||u.delete(m.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,h.getCacheControlHeader)(c.cacheControl)),await (0,p.sendResponse)(J,z,new Response(c.value.body,{headers:u,status:c.value.status||200})),null};U&&H?await o(H):(s=G.getActiveScopeSpan(),await G.withPropagatedContext(e.headers,()=>G.trace(u.BaseServerSpan.handleRequest,{spanName:`${$} ${g}`,kind:i.SpanKind.SERVER,attributes:{"http.method":$,"http.target":e.url}},o),void 0,!U))}catch(t){if(t instanceof x.NoFallbackError||await R.onRequestError(e,t,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:q,isOnDemandRevalidate:k})},!1,N),P)throw t;return await (0,p.sendResponse)(J,z,new Response(null,{status:500})),null}}e.s(["handler",0,A,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:C,workUnitAsyncStorage:j})},"routeModule",0,R,"serverHooks",0,b,"workAsyncStorage",0,C,"workUnitAsyncStorage",0,j],71188)}];
14
-
15
- //# sourceMappingURL=%5Broot-of-the-server%5D__0c4n7et._.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/config.ts","../../../src/lib/workspaceParser.ts","../../../src/lib/agents/ContextManager.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js","../../../src/app/api/sessions/stop/route.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport os from \"os\";\n\nlet cachedConfigDir: string | null = null;\n\nexport function getConfigDir(): string {\n if (cachedConfigDir) {\n return cachedConfigDir;\n }\n\n const primaryDir = path.join(process.env.ORIGINAL_CWD || process.cwd(), \".ai\", \"neural-loom\");\n \n try {\n // Check if primary directory exists. If not, try to create it.\n if (!fs.existsSync(primaryDir)) {\n fs.mkdirSync(primaryDir, { recursive: true });\n }\n // Perform a test write to verify write permissions (crucial for read-only directories like C:\\Program Files)\n const testFile = path.join(primaryDir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n cachedConfigDir = primaryDir;\n return primaryDir;\n } catch (err) {\n // If EPERM or any other write error occurs, fall back to the user's home directory\n console.warn(`[Config] Primary config dir is not writable (${primaryDir}). Falling back to home directory.`);\n const fallbackDir = path.join(os.homedir(), \".ai\", \"neural-loom\");\n try {\n if (!fs.existsSync(fallbackDir)) {\n fs.mkdirSync(fallbackDir, { recursive: true });\n }\n cachedConfigDir = fallbackDir;\n return fallbackDir;\n } catch (fallbackErr) {\n console.error(\"[Config] Fallback config dir is also not writable!\", fallbackErr);\n cachedConfigDir = primaryDir;\n return primaryDir;\n }\n }\n}\n\nexport function isDirWritable(dir: string): boolean {\n try {\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n const testFile = path.join(dir, \".write-test-\" + Math.random().toString(36).substring(7));\n fs.writeFileSync(testFile, \"test\");\n fs.unlinkSync(testFile);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isSystemDirectory(dir: string): boolean {\n const normalized = dir.toLowerCase().replace(/\\\\/g, \"/\");\n return (\n normalized.includes(\"/program files\") ||\n normalized.includes(\"/windows/system32\") ||\n normalized.includes(\"/winnt\") ||\n normalized.startsWith(\"/usr/\") ||\n normalized.startsWith(\"/bin/\") ||\n normalized.startsWith(\"/sbin/\") ||\n normalized.startsWith(\"/etc/\") ||\n normalized.startsWith(\"/var/\")\n );\n}\n\nexport function getDefaultWorkspaceRoot(): string {\n const launchDir = process.env.ORIGINAL_CWD || process.cwd();\n \n if (isDirWritable(launchDir) && !isSystemDirectory(launchDir)) {\n return launchDir.replace(/\\\\/g, \"/\");\n }\n \n const home = os.homedir();\n const commonDirs = [\n path.join(home, \"OneDrive\", \"Projects\"),\n path.join(home, \"Projects\"),\n path.join(home, \"source\", \"repos\"),\n path.join(home, \"Documents\"),\n home\n ];\n \n for (const dir of commonDirs) {\n try {\n if (fs.existsSync(dir) && isDirWritable(dir)) {\n return dir.replace(/\\\\/g, \"/\");\n }\n } catch {\n // Continue checking\n }\n }\n \n return home.replace(/\\\\/g, \"/\");\n}\n\n","import fs from \"fs\";\nimport path from \"path\";\n\n// Cache parsed folders per workspace root, keyed off the .code-workspace file's\n// mtime so repeated polling doesn't re-read and re-parse it every call.\nconst folderCache = new Map<string, { mtimeMs: number; folders: string[] }>();\n\nexport function getWorkspaceFileFolders(workspaceRoot: string): string[] {\n try {\n if (!workspaceRoot || !fs.existsSync(workspaceRoot)) return [];\n\n // Normalize workspaceRoot path\n const normRoot = path.resolve(workspaceRoot).replace(/\\\\/g, \"/\");\n\n const files = fs.readdirSync(normRoot);\n const workspaceFile = files.find(f => f.endsWith(\".code-workspace\"));\n if (!workspaceFile) {\n folderCache.delete(normRoot);\n return [];\n }\n\n const filePath = path.join(normRoot, workspaceFile);\n const mtimeMs = fs.statSync(filePath).mtimeMs;\n const cached = folderCache.get(normRoot);\n if (cached && cached.mtimeMs === mtimeMs) {\n return cached.folders;\n }\n\n const content = fs.readFileSync(filePath, \"utf8\");\n const json = JSON.parse(content);\n \n if (!json.folders || !Array.isArray(json.folders)) {\n folderCache.set(normRoot, { mtimeMs, folders: [] });\n return [];\n }\n\n const folders: string[] = [];\n for (const folder of json.folders) {\n if (folder.path) {\n // Resolve relative to workspace root (where the workspace file resides)\n const resolved = path.resolve(normRoot, folder.path).replace(/\\\\/g, \"/\");\n\n // Exclude the workspace root folder itself\n if (resolved !== normRoot) {\n if (fs.existsSync(resolved)) {\n folders.push(resolved);\n }\n }\n }\n }\n folderCache.set(normRoot, { mtimeMs, folders });\n return folders;\n } catch (err) {\n console.error(\"[WorkspaceParser] Failed to parse code-workspace file:\", err);\n return [];\n }\n}\n","import fs from \"fs\";\nimport path from \"path\";\nimport { isDirWritable } from \"../config\";\n\ninterface McpServerEntry {\n command: string;\n args: string[];\n [key: string]: unknown;\n}\n\nexport class ContextManager {\n private static writableCache = new Map<string, boolean>();\n\n private static isWritable(root: string): boolean {\n if (this.writableCache.has(root)) {\n return this.writableCache.get(root)!;\n }\n const res = isDirWritable(root);\n this.writableCache.set(root, res);\n return res;\n }\n\n private static get workspaceRoot(): string {\n return process.env.ORIGINAL_CWD || process.cwd();\n }\n\n private static ensureDirs(root: string) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n const aiDir = path.join(root, \".ai\", \"neural-loom\");\n if (!fs.existsSync(aiDir)) {\n fs.mkdirSync(aiDir, { recursive: true });\n }\n\n const commandDir = path.join(root, \".claude\", \"commands\");\n if (!fs.existsSync(commandDir)) {\n fs.mkdirSync(commandDir, { recursive: true });\n }\n } catch (err) {\n console.warn(`[ContextManager] Failed to ensure directories at ${root}:`, err);\n }\n }\n\n public static initializeStaging(root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n\n // Create /ccp.md custom slash command file\n const ccpPath = path.join(root, \".claude\", \"commands\", \"ccp.md\");\n if (!fs.existsSync(ccpPath)) {\n fs.writeFileSync(\n ccpPath,\n \"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\"\n );\n }\n\n // Create /ccc.md custom slash command file\n const cccPath = path.join(root, \".claude\", \"commands\", \"ccc.md\");\n if (!fs.existsSync(cccPath)) {\n fs.writeFileSync(\n cccPath,\n \"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\"\n );\n }\n\n this.ensureMcpConfig(root);\n } catch (err) {\n console.warn(`[ContextManager] Failed to initialize staging at ${root}:`, err);\n }\n }\n\n // Registers the built-in SQL MCP server (see src/lib/sql/McpServer.ts) with\n // Claude Code by writing a project-scoped .mcp.json. Without this, spawned\n // Claude Code sessions have no way of discovering the server exists.\n private static ensureMcpConfig(root: string) {\n const mcpPath = path.join(root, \".mcp.json\");\n let config: { mcpServers?: Record<string, McpServerEntry> } = {};\n\n if (fs.existsSync(mcpPath)) {\n try {\n config = JSON.parse(fs.readFileSync(mcpPath, \"utf8\"));\n } catch (err) {\n console.warn(`[ContextManager] Existing .mcp.json at ${mcpPath} is not valid JSON, leaving it untouched:`, err);\n return;\n }\n }\n\n if (!config.mcpServers) {\n config.mcpServers = {};\n }\n\n // The SQL MCP bridge resolves connection profiles by workspace root, and\n // connections are workspace-scoped (no global tier). Pin the exact root as\n // the third CLI arg so the bridge reports the same x-workspace-root the\n // dashboard saved connections under. Without it, bin/cli.js falls back to\n // ORIGINAL_CWD/process.cwd() — which for a per-session workspace differs\n // from the save root — and every SQL tool call comes back empty, i.e.\n // Claude Code is effectively denied access to the databases.\n //\n // process.cwd() is the package root here (never the user's workspace —\n // bin/cli.js chdir's into it before booting Next.js), so this reliably\n // finds our own CLI regardless of how NeuralLoom was launched.\n const absRoot = path.resolve(root);\n const cliPath = path.join(process.cwd(), \"bin\", \"cli.js\");\n const desired: McpServerEntry = fs.existsSync(cliPath)\n ? { command: process.execPath, args: [cliPath, \"mcp\", absRoot] }\n : { command: \"neural-loom\", args: [\"mcp\", absRoot] };\n\n const existing = config.mcpServers[\"neural-loom-sql\"];\n if (existing) {\n // Only rewrite an entry that looks like one we generated, so a user's\n // hand-tuned command is never clobbered. Upgrade a managed entry in place\n // when it is missing the pinned root or points at a stale one (e.g. an\n // older install that shipped `args: [cli, \"mcp\"]`).\n if (!this.isManagedMcpEntry(existing)) {\n return;\n }\n if (JSON.stringify(existing.args) === JSON.stringify(desired.args)) {\n return; // already correct\n }\n }\n\n config.mcpServers[\"neural-loom-sql\"] = desired;\n fs.writeFileSync(mcpPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n\n // A `neural-loom-sql` entry is \"ours to manage\" when it is a `... mcp`\n // invocation of our own CLI (either the `neural-loom` binary or a cli.js\n // path). Anything else is treated as a user customization and left untouched.\n private static isManagedMcpEntry(entry: McpServerEntry): boolean {\n if (!entry || !Array.isArray(entry.args) || !entry.args.includes(\"mcp\")) {\n return false;\n }\n if (entry.command === \"neural-loom\") {\n return true;\n }\n return entry.args.some(\n (a) => typeof a === \"string\" && (a.endsWith(\"cli.js\") || a.includes(\"neural-loom\"))\n );\n }\n\n public static updatePrompt(promptText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n fs.writeFileSync(promptFile, promptText);\n } catch (err) {\n console.error(`[ContextManager] Failed to write prompt file at ${root}:`, err);\n }\n }\n\n public static updateContext(contextText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const contextFile = path.join(root, \".ai\", \"neural-loom\", \"ccontext.md\");\n fs.writeFileSync(contextFile, contextText);\n } catch (err) {\n console.error(`[ContextManager] Failed to write context file at ${root}:`, err);\n }\n }\n\n public static updateRules(rulesText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n fs.writeFileSync(agentsMdPath, rulesText, \"utf8\");\n } catch (err) {\n console.error(`[ContextManager] Failed to write rules file at ${root}:`, err);\n }\n }\n\n public static loadPrompt(root: string = process.env.ORIGINAL_CWD || process.cwd()): string {\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n return fs.existsSync(promptFile) ? fs.readFileSync(promptFile, \"utf8\") : \"\";\n }\n\n public static loadRules(root: string = process.env.ORIGINAL_CWD || process.cwd()): string {\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n return fs.existsSync(agentsMdPath) ? fs.readFileSync(agentsMdPath, \"utf8\") : \"\";\n }\n\n public static compileGlobalRules() {\n this.compileSessionContext();\n }\n\n public static compileSessionContext(root: string = process.env.ORIGINAL_CWD || process.cwd(), scopedDirs?: string[]) {\n if (!this.isWritable(root)) {\n return;\n }\n try {\n this.ensureDirs(root);\n this.initializeStaging(root);\n \n // Check if AGENTS.md rules template exists\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n let agentsRules = \"\";\n if (fs.existsSync(agentsMdPath)) {\n agentsRules = fs.readFileSync(agentsMdPath, \"utf8\");\n } else {\n // Try fallback from global\n const fallbackPath = path.join(this.workspaceRoot, \"AGENTS.md\");\n if (fs.existsSync(fallbackPath)) {\n agentsRules = fs.readFileSync(fallbackPath, \"utf8\");\n }\n }\n\n // Generate maps\n let maps = `## Workspace Root Map (${root}):\\n${this.generateProjectMapFor(root)}`;\n\n if (scopedDirs && Array.isArray(scopedDirs)) {\n scopedDirs.forEach((dir) => {\n if (fs.existsSync(dir)) {\n maps += `\\n\\n## Scoped Directory Map (${dir}):\\n${this.generateProjectMapFor(dir)}`;\n }\n });\n }\n\n // Combine rules and folder map\n const compiledContext = `# System Rules & Guidelines\\n\\n${agentsRules}\\n\\n# Project File Hierarchy Map\\n\\n${maps}`;\n this.updateContext(compiledContext, root);\n\n // Write a default empty prompt staging file if missing\n const promptFile = path.join(root, \".ai\", \"neural-loom\", \"cprompt.md\");\n if (!fs.existsSync(promptFile)) {\n fs.writeFileSync(promptFile, \"Hello! Please review the project context (/ccc) and check for any tasks to execute.\");\n }\n } catch (err) {\n console.warn(`[ContextManager] Failed to compile session context at ${root}:`, err);\n }\n }\n\n private static generateProjectMapFor(targetDir: string): string {\n try {\n const walk = (dir: string, depth = 0): string => {\n if (depth > 2) return \"\"; // Keep map depth concise to fit tokens\n let result = \"\";\n const files = fs.readdirSync(dir, { withFileTypes: true });\n for (const file of files) {\n if (\n file.name.startsWith(\".\") ||\n file.name === \"node_modules\" ||\n file.name === \"out\" ||\n file.name === \".next\"\n ) {\n continue;\n }\n const indent = \" \".repeat(depth);\n if (file.isDirectory()) {\n result += `${indent}- [Dir] ${file.name}/\\n`;\n result += walk(path.join(dir, file.name), depth + 1);\n } else {\n result += `${indent}- [File] ${file.name}\\n`;\n }\n }\n return result;\n };\n return walk(targetDir);\n } catch (err) {\n return \"Error generating project map: \" + (err instanceof Error ? err.message : String(err));\n }\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/sessions/stop/route\",\n pathname: \"/api/sessions/stop\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/sessions/stop/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"INNER_APP_ROUTE\")\n } : {}\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/sessions/stop/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId,\n deploymentId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n","import { NextResponse } from \"next/server\";\nimport { SessionManager } from \"@/lib/agents/SessionManager\";\n\nexport async function POST(request: Request) {\n try {\n const body = await request.json();\n const { id, delete: deleteSession } = body;\n\n if (!id) {\n return NextResponse.json({ error: \"Missing required field 'id'.\" }, { status: 400 });\n }\n\n const manager = SessionManager.getInstance();\n \n if (deleteSession) {\n const success = await manager.deleteSession(id);\n return NextResponse.json({ success });\n } else {\n const success = await manager.stopSession(id);\n return NextResponse.json({ success });\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return NextResponse.json({ error: errorMessage }, { status: 500 });\n }\n}\n"],"names":["cachedConfigDir","getConfigDir","primaryDir","join","process","env","ORIGINAL_CWD","cwd","existsSync","mkdirSync","recursive","testFile","Math","random","toString","substring","writeFileSync","unlinkSync","err","console","warn","fallbackDir","homedir","fallbackErr","error","isDirWritable","dir","isSystemDirectory","normalized","toLowerCase","replace","includes","startsWith","getDefaultWorkspaceRoot","launchDir","home","commonDirs","folderCache","Map","getWorkspaceFileFolders","workspaceRoot","normRoot","resolve","files","readdirSync","workspaceFile","find","f","endsWith","delete","filePath","mtimeMs","statSync","cached","get","folders","content","readFileSync","json","JSON","parse","Array","isArray","set","folder","path","resolved","push","ContextManager","writableCache","isWritable","root","has","res","ensureDirs","aiDir","commandDir","initializeStaging","ccpPath","cccPath","ensureMcpConfig","mcpPath","config","mcpServers","absRoot","cliPath","desired","command","execPath","args","existing","isManagedMcpEntry","stringify","entry","some","a","updatePrompt","promptText","promptFile","updateContext","contextText","contextFile","updateRules","rulesText","agentsMdPath","loadPrompt","loadRules","compileGlobalRules","compileSessionContext","scopedDirs","agentsRules","fallbackPath","maps","generateProjectMapFor","forEach","compiledContext","targetDir","walk","depth","result","withFileTypes","file","name","indent","repeat","isDirectory","Error","message","String","body","POST","request","id","deleteSession","status","manager","getInstance","success","stopSession","errorMessage"],"mappings":"4pCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEA,IAAIA,EAAiC,KAsC9B,SAASyB,EAAcC,CAAW,EACvC,GAAI,CACE,AAAC,EAAA,OAAE,CAAClB,UAAU,CAACkB,IACjB,EADuB,AACvB,OAAE,CAACjB,SAAS,CAACiB,EAAK,CAAEhB,WAAW,CAAK,GAEtC,IAAMC,EAAW,EAAA,OAAI,CAACR,IAAI,CAACuB,EAAK,eAAiBd,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,IAGtF,OAFA,EAAA,OAAE,CAACC,aAAa,CAACL,EAAU,QAC3B,EAAA,OAAE,CAACM,UAAU,CAACN,IACP,CACT,CAAE,KAAM,CACN,OAAO,CACT,CACF,uBAhDO,SAASV,EACd,GAAID,EACF,OAAOA,EAGT,IAAME,EAAa,AAJE,EAIF,OAAI,CAACC,IAAI,CAACC,QAAQC,GAAG,CAACC,YAAY,EAAIF,QAAQG,GAAG,GAAI,MAAO,eAE/E,GAAI,CAEE,AAAC,EAAA,OAAE,CAACC,UAAU,CAACN,IACjB,EAAA,OAD8B,AAC5B,CAACO,SAAS,CAACP,EAAY,CAAEQ,WAAW,CAAK,GAG7C,IAAMC,EAAW,EAAA,OAAI,CAACR,IAAI,CAACD,EAAY,eAAiBU,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,IAI7F,OAHA,EAAA,OAAE,CAACC,aAAa,CAACL,EAAU,QAC3B,EAAA,OAAE,CAACM,UAAU,CAACN,GACdX,EAAkBE,EACXA,CACT,CAAE,MAAOgB,EAAK,CAEZC,QAAQC,IAAI,CAAC,CAAC,6CAA6C,EAAElB,E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