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,45 +1,16 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import readline from "readline";
3
2
  import { ConnectionManager } from "./ConnectionManager";
4
3
  import { isReadOnlyViolation } from "./sqlGuard";
5
4
 
5
+ // The SQL Model Context Protocol server. Reached over HTTP (/api/sql/mcp) and,
6
+ // externally, via the `neural-loom mcp` stdio↔HTTP bridge in bin/cli.js — both
7
+ // consume the return value of handleMessage(). There is no in-process stdio
8
+ // transport here; the bridge owns stdio and forwards each message over HTTP.
6
9
  export class McpServer {
7
10
  private workspaceRoot?: string;
8
11
 
9
12
  constructor(workspaceRoot?: string) {
10
13
  this.workspaceRoot = workspaceRoot;
11
- // Redirect console.log to stderr so that it doesn't corrupt stdout JSON-RPC stream
12
- console.log = (...args) => {
13
- console.error("[LOG]", ...args);
14
- };
15
- }
16
-
17
- public start(): void {
18
- const rl = readline.createInterface({
19
- input: process.stdin,
20
- output: process.stdout,
21
- terminal: false
22
- });
23
-
24
- rl.on("line", async (line) => {
25
- if (!line.trim()) return;
26
- try {
27
- const message = JSON.parse(line);
28
- if (message.method) {
29
- const response = await this.handleMessage(message);
30
- if (response) {
31
- process.stdout.write(JSON.stringify(response) + "\n");
32
- }
33
- }
34
- } catch (err) {
35
- this.sendError(null, -32700, "Parse error: " + (err instanceof Error ? err.message : String(err)));
36
- }
37
- });
38
-
39
- console.error("[McpServer] SQL Model Context Protocol Server listening on stdio...");
40
- if (this.workspaceRoot) {
41
- console.error(`[McpServer] Workspace Root Context resolved to: ${this.workspaceRoot}`);
42
- }
43
14
  }
44
15
 
45
16
  public async handleMessage(message: any): Promise<any> {
@@ -139,13 +110,13 @@ export class McpServer {
139
110
  }
140
111
  }
141
112
 
142
- // Returns the JSON-RPC response object rather than writing to stdout. Both
143
- // transports consume the return value of handleMessage: the stdio loop in
144
- // start() writes it, and the HTTP route (/api/sql/mcp) serializes it into the
145
- // response body. Writing tool results to process.stdout here would strand
146
- // them for the HTTP path handleMessage would return undefined and the route
147
- // would fail to serialize it, so every SQL tool call over HTTP came back as
148
- // "Value is not JSON serializable" and Claude Code saw the tools as unusable.
113
+ // Returns the JSON-RPC response object rather than writing to stdout. The
114
+ // HTTP route (/api/sql/mcp) serializes the return value into the response
115
+ // body (and the CLI bridge forwards that back over stdio). Writing tool
116
+ // results to process.stdout here would strand them — handleMessage would
117
+ // return undefined and the route would fail to serialize it, so every SQL
118
+ // tool call over HTTP came back as "Value is not JSON serializable" and
119
+ // Claude Code saw the tools as unusable.
149
120
  private async handleToolCall(id: any, params: any): Promise<any> {
150
121
  const toolName = params.name;
151
122
  const args = params.arguments || {};
@@ -267,8 +238,4 @@ export class McpServer {
267
238
  }
268
239
  };
269
240
  }
270
-
271
- private sendError(id: any, code: number, message: string): void {
272
- process.stdout.write(JSON.stringify(this.buildError(id, code, message)) + "\n");
273
- }
274
241
  }
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
2
2
  import { DbAdapter, TableSchema, ColumnSchema, QueryResult } from "../DbAdapter";
3
+ import { loadOptionalDriver } from "../loadDriver";
3
4
 
4
5
  export class MssqlAdapter extends DbAdapter {
5
6
  private pool: any = null;
@@ -14,14 +15,7 @@ export class MssqlAdapter extends DbAdapter {
14
15
  if (this.pool) return;
15
16
 
16
17
  try {
17
- let mssql;
18
- try {
19
- mssql = eval("require")("mssql");
20
- } catch (err) {
21
- throw new Error(
22
- "Microsoft SQL Server driver 'mssql' is not installed. Please run `npm install mssql` in the neural-loom environment."
23
- );
24
- }
18
+ const mssql = loadOptionalDriver("mssql") as any;
25
19
 
26
20
  this.pool = await mssql.connect({
27
21
  server: this.config.host || "localhost",
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
2
2
  import { DbAdapter, TableSchema, ColumnSchema, QueryResult } from "../DbAdapter";
3
+ import { loadOptionalDriver } from "../loadDriver";
3
4
 
4
5
  export class MysqlAdapter extends DbAdapter {
5
6
  private connection: any = null;
@@ -14,14 +15,7 @@ export class MysqlAdapter extends DbAdapter {
14
15
  if (this.connection) return;
15
16
 
16
17
  try {
17
- let mysql;
18
- try {
19
- mysql = eval("require")("mysql2/promise");
20
- } catch (err) {
21
- throw new Error(
22
- "MySQL driver 'mysql2' is not installed. Please run `npm install mysql2` in the neural-loom environment."
23
- );
24
- }
18
+ const mysql = loadOptionalDriver("mysql2/promise", "mysql2") as any;
25
19
 
26
20
  this.connection = await mysql.createConnection({
27
21
  host: this.config.host || "localhost",
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
2
2
  import { DbAdapter, TableSchema, ColumnSchema, QueryResult } from "../DbAdapter";
3
+ import { loadOptionalDriver } from "../loadDriver";
3
4
 
4
5
  export class PostgresAdapter extends DbAdapter {
5
6
  private client: any = null;
@@ -14,15 +15,8 @@ export class PostgresAdapter extends DbAdapter {
14
15
  if (this.client) return;
15
16
 
16
17
  try {
17
- let ClientClass;
18
- try {
19
- const pg = eval("require")("pg");
20
- ClientClass = pg.Client;
21
- } catch (err) {
22
- throw new Error(
23
- "PostgreSQL driver 'pg' is not installed. Please run `npm install pg` in the neural-loom environment."
24
- );
25
- }
18
+ const pg = loadOptionalDriver("pg") as any;
19
+ const ClientClass = pg.Client;
26
20
 
27
21
  this.client = new ClientClass({
28
22
  host: this.config.host || "localhost",
@@ -2,6 +2,7 @@
2
2
  import path from "path";
3
3
  import fs from "fs";
4
4
  import { DbAdapter, TableSchema, ColumnSchema, QueryResult } from "../DbAdapter";
5
+ import { loadOptionalDriver } from "../loadDriver";
5
6
 
6
7
  export class SqliteAdapter extends DbAdapter {
7
8
  private db: any = null;
@@ -31,15 +32,8 @@ export class SqliteAdapter extends DbAdapter {
31
32
  }
32
33
 
33
34
  try {
34
- // Lazy load better-sqlite3
35
- let Database;
36
- try {
37
- Database = eval("require")("better-sqlite3");
38
- } catch (err) {
39
- throw new Error(
40
- "SQLite driver 'better-sqlite3' is not installed. Please run `npm install better-sqlite3` in the neural-loom environment."
41
- );
42
- }
35
+ // Lazy load better-sqlite3 from the workspace / global install locations.
36
+ const Database = loadOptionalDriver("better-sqlite3") as any;
43
37
 
44
38
  // Read-only profiles open the database with the driver's readonly flag, so
45
39
  // any write attempt fails at the engine level (not just our SQL guard).
@@ -0,0 +1,93 @@
1
+ import path from "path";
2
+ import type { createRequire as CreateRequire } from "module";
3
+ import { getDriversDir } from "../config";
4
+
5
+ /**
6
+ * Load an optional SQL driver by module name, resolving it from the places a
7
+ * user might actually have installed it — not just neural-loom's own
8
+ * node_modules.
9
+ *
10
+ * WHY THIS EXISTS: the published CLI runs `next start` from the package's install
11
+ * directory, so a bare `require("pg")` only ever searches neural-loom's
12
+ * node_modules. A driver the user installed in *their* workspace or globally is
13
+ * invisible to it. That is the "it's installed but not found" bug — and the
14
+ * reason `mssql` used to be bundled as a hard dependency as a workaround. With
15
+ * this resolver every driver can be optional and still work.
16
+ *
17
+ * Resolution order (first hit wins):
18
+ * 1. neural-loom's own node_modules (bundled / co-installed)
19
+ * 2. the user's workspace (ORIGINAL_CWD) and its parent dirs
20
+ * 3. the process cwd and its parent dirs
21
+ * 4. the global npm root (`npm root -g`)
22
+ */
23
+ export function loadOptionalDriver(moduleName: string, installName = moduleName): unknown {
24
+ // eval("require") yields Node's real require, opaque to the Next/Turbopack
25
+ // bundler (the same trick the adapters and node-pty loader already use).
26
+ const nodeRequire = eval("require") as NodeRequire;
27
+ const createRequire = (nodeRequire("module") as { createRequire: typeof CreateRequire }).createRequire;
28
+ const attempts: string[] = [];
29
+
30
+ const record = (label: string, err: unknown) => {
31
+ // Keep only the first line ("Cannot find module 'x'") — the multi-line
32
+ // Require stack that follows is noise in a user-facing error.
33
+ const msg = (err instanceof Error ? err.message : String(err)).split("\n")[0];
34
+ attempts.push(`${label}: ${msg}`);
35
+ };
36
+
37
+ // 1. Package-local resolution.
38
+ try {
39
+ return nodeRequire(moduleName);
40
+ } catch (err) {
41
+ record("package", err);
42
+ }
43
+
44
+ // Resolve as if required from `baseDir` — createRequire searches
45
+ // baseDir/node_modules and every parent's node_modules. The anchor file need
46
+ // not exist; only its directory matters for resolution.
47
+ const requireFrom = (baseDir: string, label: string): unknown | null => {
48
+ try {
49
+ const req = createRequire(path.join(baseDir, "noop.js"));
50
+ return req(moduleName);
51
+ } catch (err) {
52
+ record(label, err);
53
+ return null;
54
+ }
55
+ };
56
+
57
+ // 2. NeuralLoom-managed drivers dir (where the "Install driver" button puts
58
+ // them). Checked before the user's own locations since it's ours to control.
59
+ try {
60
+ const managed = requireFrom(getDriversDir(), "managed");
61
+ if (managed) return managed;
62
+ } catch (err) {
63
+ record("managed", err);
64
+ }
65
+
66
+ // 3 + 4. Workspace and cwd.
67
+ const bases: Array<[string, string]> = [];
68
+ if (process.env.ORIGINAL_CWD) bases.push([process.env.ORIGINAL_CWD, "workspace"]);
69
+ bases.push([process.cwd(), "cwd"]);
70
+ for (const [dir, label] of bases) {
71
+ const mod = requireFrom(dir, label);
72
+ if (mod) return mod;
73
+ }
74
+
75
+ // 4. Global npm root (best-effort; only reached if everything above missed).
76
+ try {
77
+ const cp = nodeRequire("child_process") as typeof import("child_process");
78
+ const globalRoot = cp.execSync("npm root -g", { encoding: "utf8" }).trim();
79
+ if (globalRoot) {
80
+ // Anchor one level above the global node_modules so it's on the search path.
81
+ const mod = requireFrom(path.dirname(globalRoot), "global");
82
+ if (mod) return mod;
83
+ }
84
+ } catch (err) {
85
+ record("global", err);
86
+ }
87
+
88
+ throw new Error(
89
+ `SQL driver '${moduleName}' is not installed or could not be resolved. ` +
90
+ `Install it in your workspace (\`npm install ${installName}\`) or globally ` +
91
+ `(\`npm install -g ${installName}\`). Tried — ${attempts.join(" | ")}`
92
+ );
93
+ }
@@ -1,3 +0,0 @@
1
- module.exports=[93695,(e,r,t)=>{r.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/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"))},24361,(e,r,t)=>{r.exports=e.x("util",()=>require("util"))},33405,(e,r,t)=>{r.exports=e.x("child_process",()=>require("child_process"))}];
2
-
3
- //# sourceMappingURL=%5Bexternals%5D__0tfzbjg._.js.map
@@ -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])},74961,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,resume:r}=await e.json();if(!t)return g.NextResponse.json({error:"Missing required field 'id'."},{status:400});let a=w.SessionManager.getInstance(),s=await a.startSession(t,r);return g.NextResponse.json({success:s})}catch(t){let e=t instanceof Error?t.message:"Unknown error";return g.NextResponse.json({error:e},{status:500})}}e.s(["POST",0,S],52453);var v=e.i(52453);let R=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/sessions/start/route",pathname:"/api/sessions/start",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/sessions/start/route.ts",nextConfigOutput:"",userland:v,...{}}),{workAsyncStorage:C,workUnitAsyncStorage:b,serverHooks:j}=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/start/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:b,parsedUrl:j,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,j,!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(b.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,b,E,L);null==K||K.resetRequestCache(),globalThis.__incrementalCache=K;let B={params:C,previewProps:E.preview,renderOpts:{experimental:{authInterrupts:!!b.experimental.authInterrupts},cacheComponents:!!b.cacheComponents,supportsDynamicResponse:W,incrementalCache:K,cacheLifeProfiles:b.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:b,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:b})},"routeModule",0,R,"serverHooks",0,j,"workAsyncStorage",0,C,"workUnitAsyncStorage",0,b],74961)}];
14
-
15
- //# sourceMappingURL=%5Broot-of-the-server%5D__0.r1zm9._.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/start/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/start/route\",\n pathname: \"/api/sessions/start\",\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/start/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/start/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, resume } = body;\n\n if (!id) {\n return NextResponse.json({ error: \"Missing required field 'id'.\" }, { status: 400 });\n }\n\n const manager = SessionManager.getInstance();\n const success = await manager.startSession(id, resume);\n return NextResponse.json({ success });\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","resume","status","manager","getInstance","success","startSession","errorMessage"],"mappings":"4pCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEA,IAAIA,E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ports=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(){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}}}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}}function o(e){let t=e.toLowerCase().replace(/\\/g,"/");return t.includes("/program files")||t.includes("/windows/system32")||t.includes("/winnt")||t.startsWith("/usr/")||t.startsWith("/bin/")||t.startsWith("/sbin/")||t.startsWith("/etc/")||t.startsWith("/var/")}function l(){let e=process.env.ORIGINAL_CWD||process.cwd();if(n(e)&&!o(e))return e.replace(/\\/g,"/");let s=a.default.homedir();for(let e of[r.default.join(s,"OneDrive","Projects"),r.default.join(s,"Projects"),r.default.join(s,"source","repos"),r.default.join(s,"Documents"),s])try{if(t.default.existsSync(e)&&n(e))return e.replace(/\\/g,"/")}catch{}return s.replace(/\\/g,"/")}e.s(["getConfigDir",0,i,"getDefaultWorkspaceRoot",0,l,"isDirWritable",0,n])},24417,e=>{"use strict";var t=e.i(22734),r=e.i(14747);let a=new Map;function s(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),[]}}e.s(["getWorkspaceFileFolders",0,s])},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])},6299,__turbopack_context__=>{"use strict";var __TURBOPACK__imported__module__47909__=__turbopack_context__.i(47909),__TURBOPACK__imported__module__74017__=__turbopack_context__.i(74017),__TURBOPACK__imported__module__96250__=__turbopack_context__.i(96250),__TURBOPACK__imported__module__59756__=__turbopack_context__.i(59756),__TURBOPACK__imported__module__61916__=__turbopack_context__.i(61916),__TURBOPACK__imported__module__74677__=__turbopack_context__.i(74677),__TURBOPACK__imported__module__69741__=__turbopack_context__.i(69741),__TURBOPACK__imported__module__16795__=__turbopack_context__.i(16795),__TURBOPACK__imported__module__87718__=__turbopack_context__.i(87718),__TURBOPACK__imported__module__95169__=__turbopack_context__.i(95169),__TURBOPACK__imported__module__47587__=__turbopack_context__.i(47587),__TURBOPACK__imported__module__66012__=__turbopack_context__.i(66012),__TURBOPACK__imported__module__70101__=__turbopack_context__.i(70101),__TURBOPACK__imported__module__26937__=__turbopack_context__.i(26937),__TURBOPACK__imported__module__10372__=__turbopack_context__.i(10372),__TURBOPACK__imported__module__93695__=__turbopack_context__.i(93695),__TURBOPACK__imported__module__52474__=__turbopack_context__.i(52474),__TURBOPACK__imported__module__220__=__turbopack_context__.i(220),__TURBOPACK__imported__module__89171__=__turbopack_context__.i(89171),__TURBOPACK__imported__module__29307__=__turbopack_context__.i(29307),__TURBOPACK__imported__module__24361__=__turbopack_context__.i(24361),__TURBOPACK__imported__module__33405__=__turbopack_context__.i(33405),__TURBOPACK__imported__module__46786__=__turbopack_context__.i(46786);let execFilePromise=(0,__TURBOPACK__imported__module__24361__.promisify)(__TURBOPACK__imported__module__33405__.execFile);async function getProcessStats(pid){if(!pid)return null;try{let pidusage=eval("require")("pidusage"),stat=await pidusage(pid);return{cpu:stat.cpu,memory:stat.memory}}catch{return null}}async function GET(e){try{let{searchParams:t}=new URL(e.url),r=t.get("id");if(!r)return __TURBOPACK__imported__module__89171__.NextResponse.json({error:"Missing session id"},{status:400});let a=__TURBOPACK__imported__module__29307__.SessionManager.getInstance().getSession(r);if(!a)return __TURBOPACK__imported__module__89171__.NextResponse.json({error:"Session not found"},{status:404});let s="0.0%",i="0.0MiB",n="0.0%",o=!1;if("running"===a.status)if("claude-docker"===a.type||"aider-docker"===a.type)try{let e=`neural-loom-session-${r}`,{stdout:t}=await execFilePromise("docker",["stats",e,"--no-stream","--format","{{.CPUPerc}},{{.MemUsage}},{{.MemPerc}}"]),a=t.toString().trim().split(",");a.length>=3&&(s=a[0].trim(),i=a[1].trim().split(" / ")[0],n=a[2].trim(),o=!0)}catch{}else{let e=await getProcessStats(a.getPid());e&&(s=e.cpu.toFixed(1)+"%",i=(e.memory/1048576).toFixed(1)+"MiB",n=(e.memory/__TURBOPACK__imported__module__46786__.default.totalmem()*100).toFixed(2)+"%",o=!0)}return __TURBOPACK__imported__module__89171__.NextResponse.json({success:!0,id:r,status:a.status,type:a.type,cpu:s,memory:i,memoryPercent:n,available:o})}catch(t){let e=t instanceof Error?t.message:"Unknown error";return __TURBOPACK__imported__module__89171__.NextResponse.json({error:e},{status:500})}}__turbopack_context__.s(["GET",0,GET],40607);var __TURBOPACK__imported__module__40607__=__turbopack_context__.i(40607);let nextConfigOutput="",routeModule=new __TURBOPACK__imported__module__47909__.AppRouteRouteModule({definition:{kind:__TURBOPACK__imported__module__74017__.RouteKind.APP_ROUTE,page:"/api/sessions/stats/route",pathname:"/api/sessions/stats",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/sessions/stats/route.ts",nextConfigOutput,userland:__TURBOPACK__imported__module__40607__,...{}}),{workAsyncStorage,workUnitAsyncStorage,serverHooks}=routeModule;function patchFetch(){return(0,__TURBOPACK__imported__module__96250__.patchFetch)({workAsyncStorage,workUnitAsyncStorage})}async function handler(e,t,r){r.requestMeta&&(0,__TURBOPACK__imported__module__59756__.setRequestMeta)(e,r.requestMeta),routeModule.isDev&&(0,__TURBOPACK__imported__module__59756__.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let a="/api/sessions/stats/route";a=a.replace(/\/index$/,"")||"/";let s=!1,i=await routeModule.prepare(e,t,{srcPage:a,multiZoneDraftMode:s});if(!i)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:n,deploymentId:o,params:l,nextConfig:c,parsedUrl:u,isDraftMode:d,prerenderManifest:p,routerServerContext:f,isOnDemandRevalidate:m,revalidateOnlyGenerated:h,resolvedPathname:y,clientReferenceManifest:x,serverActionsManifest:g}=i,w=(0,__TURBOPACK__imported__module__69741__.normalizeAppPath)(a),S=!!(p.dynamicRoutes[w]||p.routes[y]),v=async()=>((null==f?void 0:f.render404)?await f.render404(e,t,u,!1):t.end("This page could not be found"),null);if(S&&!d){let e=!!p.routes[y],t=p.dynamicRoutes[w];if(t&&!1===t.fallback&&!e){if(c.adapterPath)return await v();throw new __TURBOPACK__imported__module__93695__.NoFallbackError}}let R=null;!S||routeModule.isDev||d||(R="/index"===(R=y)?"/":R);let C=!0===routeModule.isDev||!S,b=S&&!C;g&&x&&(0,__TURBOPACK__imported__module__74677__.setManifestsSingleton)({page:a,clientReferenceManifest:x,serverActionsManifest:g});let j=e.method||"GET",E=(0,__TURBOPACK__imported__module__61916__.getTracer)(),A=E.getActiveScopeSpan(),N=!!(null==f?void 0:f.isWrappedByNextServer),k=!!(0,__TURBOPACK__imported__module__59756__.getRequestMeta)(e,"minimalMode"),M=(0,__TURBOPACK__imported__module__59756__.getRequestMeta)(e,"incrementalCache")||await routeModule.getIncrementalCache(e,c,p,k);null==M||M.resetRequestCache(),globalThis.__incrementalCache=M;let F={params:l,previewProps:p.preview,renderOpts:{experimental:{authInterrupts:!!c.experimental.authInterrupts},cacheComponents:!!c.cacheComponents,supportsDynamicResponse:C,incrementalCache:M,cacheLifeProfiles:c.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,s)=>routeModule.onRequestError(e,t,a,s,f)},sharedContext:{buildId:n,deploymentId:o}},P=new __TURBOPACK__imported__module__16795__.NodeNextRequest(e),I=new __TURBOPACK__imported__module__16795__.NodeNextResponse(t),D=__TURBOPACK__imported__module__87718__.NextRequestAdapter.fromNodeNextRequest(P,(0,__TURBOPACK__imported__module__87718__.signalFromNodeResponse)(t));try{let s,i=async e=>routeModule.handle(D,F).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=E.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==__TURBOPACK__imported__module__95169__.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 i=r.get("next.route");if(i){let t=`${j} ${i}`;e.setAttributes({"next.route":i,"http.route":i,"next.span_name":t}),e.updateName(t),s&&s!==e&&(s.setAttribute("http.route",i),s.updateName(t))}else e.updateName(`${j} ${a}`)}),n=async s=>{var n,o;let l=async({previousCacheEntry:n})=>{try{if(!k&&m&&h&&!n)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await i(s);e.fetchMetrics=F.renderOpts.fetchMetrics;let o=F.renderOpts.pendingWaitUntil;o&&r.waitUntil&&(r.waitUntil(o),o=void 0);let l=F.renderOpts.collectedTags;if(!S)return await (0,__TURBOPACK__imported__module__66012__.sendResponse)(P,I,a,F.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,__TURBOPACK__imported__module__70101__.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[__TURBOPACK__imported__module__10372__.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==F.renderOpts.collectedRevalidate&&!(F.renderOpts.collectedRevalidate>=__TURBOPACK__imported__module__10372__.INFINITE_CACHE)&&F.renderOpts.collectedRevalidate,s=void 0===F.renderOpts.collectedExpire||F.renderOpts.collectedExpire>=__TURBOPACK__imported__module__10372__.INFINITE_CACHE?void 0:F.renderOpts.collectedExpire;return{value:{kind:__TURBOPACK__imported__module__220__.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:s}}}}catch(t){if(null==n?void 0:n.isStale){let r=!1;await routeModule.onRequestError(e,t,{routerKind:"App Router",routePath:a,routeType:"route",revalidateReason:(0,__TURBOPACK__imported__module__47587__.getRevalidateReason)({isStaticGeneration:b,isOnDemandRevalidate:m})},r,f)}throw t}},u=await routeModule.handleResponse({req:e,nextConfig:c,cacheKey:R,routeKind:__TURBOPACK__imported__module__74017__.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:p,isRoutePPREnabled:!1,isOnDemandRevalidate:m,revalidateOnlyGenerated:h,responseGenerator:l,waitUntil:r.waitUntil,isMinimalMode:k});if(!S)return null;if((null==u||null==(n=u.value)?void 0:n.kind)!==__TURBOPACK__imported__module__220__.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(o=u.value)?void 0:o.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});k||t.setHeader("x-nextjs-cache",m?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),d&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let y=(0,__TURBOPACK__imported__module__70101__.fromNodeOutgoingHttpHeaders)(u.value.headers);return k&&S||y.delete(__TURBOPACK__imported__module__10372__.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||y.get("Cache-Control")||y.set("Cache-Control",(0,__TURBOPACK__imported__module__26937__.getCacheControlHeader)(u.cacheControl)),await (0,__TURBOPACK__imported__module__66012__.sendResponse)(P,I,new Response(u.value.body,{headers:y,status:u.value.status||200})),null};N&&A?await n(A):(s=E.getActiveScopeSpan(),await E.withPropagatedContext(e.headers,()=>E.trace(__TURBOPACK__imported__module__95169__.BaseServerSpan.handleRequest,{spanName:`${j} ${a}`,kind:__TURBOPACK__imported__module__61916__.SpanKind.SERVER,attributes:{"http.method":j,"http.target":e.url}},n),void 0,!N))}catch(t){if(!(t instanceof __TURBOPACK__imported__module__93695__.NoFallbackError)){let r=!1;await routeModule.onRequestError(e,t,{routerKind:"App Router",routePath:w,routeType:"route",revalidateReason:(0,__TURBOPACK__imported__module__47587__.getRevalidateReason)({isStaticGeneration:b,isOnDemandRevalidate:m})},r,f)}if(S)throw t;return await (0,__TURBOPACK__imported__module__66012__.sendResponse)(P,I,new Response(null,{status:500})),null}}__turbopack_context__.s(["handler",0,handler,"patchFetch",0,patchFetch,"routeModule",0,routeModule,"serverHooks",0,serverHooks,"workAsyncStorage",0,workAsyncStorage,"workUnitAsyncStorage",0,workUnitAsyncStorage],6299)}];
14
-
15
- //# sourceMappingURL=%5Broot-of-the-server%5D__03_0gmx._.js.map