neural-loom 0.2.52 → 0.2.53

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 (54) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +5 -5
  3. package/.next/cache/.previewinfo +1 -1
  4. package/.next/cache/.rscinfo +1 -1
  5. package/.next/cache/.tsbuildinfo +1 -1
  6. package/.next/diagnostics/route-bundle-stats.json +6 -6
  7. package/.next/fallback-build-manifest.json +3 -3
  8. package/.next/prerender-manifest.json +3 -3
  9. package/.next/server/app/_global-error/page/build-manifest.json +2 -2
  10. package/.next/server/app/_global-error.html +1 -1
  11. package/.next/server/app/_global-error.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  17. package/.next/server/app/_not-found/page/build-manifest.json +2 -2
  18. package/.next/server/app/_not-found.html +1 -1
  19. package/.next/server/app/_not-found.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  26. package/.next/server/app/index.html +1 -1
  27. package/.next/server/app/index.rsc +2 -2
  28. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  29. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  30. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  31. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  32. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  33. package/.next/server/app/page/build-manifest.json +2 -2
  34. package/.next/server/app/page_client-reference-manifest.js +1 -1
  35. package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js +1 -1
  36. package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js.map +1 -1
  37. package/.next/server/chunks/ssr/_0t7oqy6._.js +2 -2
  38. package/.next/server/chunks/ssr/_0t7oqy6._.js.map +1 -1
  39. package/.next/server/middleware-build-manifest.js +5 -5
  40. package/.next/server/pages/404.html +1 -1
  41. package/.next/server/pages/500.html +1 -1
  42. package/.next/server/server-reference-manifest.js +1 -1
  43. package/.next/server/server-reference-manifest.json +1 -1
  44. package/.next/static/chunks/{0fpki3y6aj230.js → 0ljspdd3cv1ft.js} +1 -1
  45. package/.next/static/chunks/0z0d3-6aolefr.js +6 -0
  46. package/.next/static/chunks/{turbopack-08fpdsd.-ns2y.js → turbopack-0.g.4cakdth0h.js} +1 -1
  47. package/.next/trace +1 -1
  48. package/.next/trace-build +1 -1
  49. package/package.json +1 -1
  50. package/src/app/components/DbExplorer.tsx +4 -2
  51. package/.next/static/chunks/0bb9anc7wd3_e.js +0 -6
  52. /package/.next/static/{nL6vq7onX8i2nzr-zxraV → WLQchpoAU3XMEr3Ep5w4b}/_buildManifest.js +0 -0
  53. /package/.next/static/{nL6vq7onX8i2nzr-zxraV → WLQchpoAU3XMEr3Ep5w4b}/_clientMiddlewareManifest.js +0 -0
  54. /package/.next/static/{nL6vq7onX8i2nzr-zxraV → WLQchpoAU3XMEr3Ep5w4b}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/config.ts","../../../src/lib/workspaceParser.ts","../../../src/lib/agents/ContextManager.ts","turbopack:///package.json","../../../src/app/api/sessions/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"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\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) return [];\n\n const filePath = path.join(normRoot, workspaceFile);\n const content = fs.readFileSync(filePath, \"utf8\");\n const json = JSON.parse(content);\n \n if (!json.folders || !Array.isArray(json.folders)) return [];\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 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\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 } catch (err) {\n console.warn(`[ContextManager] Failed to initialize staging at ${root}:`, err);\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","{\"name\":\"neural-loom\",\"version\":\"0.2.51\",\"bin\":{\"neural-loom\":\"./bin/cli.js\"},\"files\":[\"bin\",\"public\",\".next\",\"src\",\"next.config.ts\",\"tsconfig.json\",\"README.md\"],\"scripts\":{\"dev\":\"next dev\",\"build\":\"next build\",\"start\":\"next start\",\"lint\":\"eslint\"},\"dependencies\":{\"next\":\"16.2.6\",\"node-pty\":\"^1.1.0\",\"react\":\"19.2.4\",\"react-dom\":\"19.2.4\",\"ws\":\"^8.21.0\",\"xterm\":\"^5.3.0\",\"xterm-addon-fit\":\"^0.8.0\"},\"devDependencies\":{\"@types/node\":\"^20\",\"@types/react\":\"^19\",\"@types/react-dom\":\"^19\",\"@types/ws\":\"^8.18.1\",\"eslint\":\"^9\",\"eslint-config-next\":\"16.2.6\",\"typescript\":\"^5\"}}","import { NextResponse } from \"next/server\";\nimport { SessionManager } from \"@/lib/agents/SessionManager\";\nimport pkg from \"../../../../package.json\";\n\ndeclare global {\n var wsPort: number | undefined;\n}\n\nexport async function GET(request: Request) {\n try {\n const { searchParams } = new URL(request.url);\n const id = searchParams.get(\"id\");\n const manager = SessionManager.getInstance();\n\n if (id) {\n const session = manager.getSession(id);\n if (!session) {\n return NextResponse.json({ error: \"Session not found\" }, { status: 404 });\n }\n return NextResponse.json({\n ...session.getStatus(),\n logs: session.logs,\n wsPort: global.wsPort || 3001,\n version: pkg.version,\n });\n }\n\n const sessions = manager.listSessions();\n const originalCwd = process.env.ORIGINAL_CWD || process.cwd();\n const wsPort = global.wsPort || 3001;\n return NextResponse.json({ sessions, originalCwd, wsPort, version: pkg.version });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return NextResponse.json({ error: errorMessage }, { status: 500 });\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/route\",\n pathname: \"/api/sessions\",\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/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/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"],"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","getWorkspaceFileFolders","workspaceRoot","normRoot","resolve","files","readdirSync","workspaceFile","find","f","endsWith","filePath","content","readFileSync","json","JSON","parse","folders","Array","isArray","folder","path","resolved","push","ContextManager","writableCache","Map","isWritable","root","has","get","res","set","ensureDirs","aiDir","commandDir","initializeStaging","ccpPath","cccPath","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","GET","request","searchParams","URL","url","id","manager","getInstance","session","getSession","status","getStatus","logs","wsPort","version","sessions","listSessions","originalCwd","errorMessage"],"mappings":"qmCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEA,IAAIA,EAAiC,KAsC9B,SAASyB,EAAcC,CAAW,EACvC,GAAI,CACE,AAAC,EAAA,OAAE,CAAClB,UAAU,CAACkB,IACjB,EADuB,AACvB,OAAE,CAACjB,SAAS,CAACiB,EAAK,CAAEhB,WAAW,CAAK,GAEtC,IAAMC,EAAW,EAAA,OAAI,CAACR,IAAI,CAACuB,EAAK,eAAiBd,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAA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,MAAM,EAAe,EADgB,EAGrC,EAAa,EAAO,kBAAkB,GACtC,MAAM,EAAO,qBAAqB,CAAC,EAAI,OAAO,CAAE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,QAAiB,EAAW,CAAC,GAE5C,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,mCA5TA,SAAS,EACL,MAAO,CAAA,EAAA,EAAA,UAAA,AAAW,EAAC,kBACf,uBACA,CACJ,EACJ","ignoreList":[5]}
1
+ {"version":3,"sources":["../../../src/lib/config.ts","../../../src/lib/workspaceParser.ts","../../../src/lib/agents/ContextManager.ts","turbopack:///package.json","../../../src/app/api/sessions/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"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\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) return [];\n\n const filePath = path.join(normRoot, workspaceFile);\n const content = fs.readFileSync(filePath, \"utf8\");\n const json = JSON.parse(content);\n \n if (!json.folders || !Array.isArray(json.folders)) return [];\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 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\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 } catch (err) {\n console.warn(`[ContextManager] Failed to initialize staging at ${root}:`, err);\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","{\"name\":\"neural-loom\",\"version\":\"0.2.52\",\"bin\":{\"neural-loom\":\"./bin/cli.js\"},\"files\":[\"bin\",\"public\",\".next\",\"src\",\"next.config.ts\",\"tsconfig.json\",\"README.md\"],\"scripts\":{\"dev\":\"next dev\",\"build\":\"next build\",\"start\":\"next start\",\"lint\":\"eslint\"},\"dependencies\":{\"next\":\"16.2.6\",\"node-pty\":\"^1.1.0\",\"react\":\"19.2.4\",\"react-dom\":\"19.2.4\",\"ws\":\"^8.21.0\",\"xterm\":\"^5.3.0\",\"xterm-addon-fit\":\"^0.8.0\"},\"devDependencies\":{\"@types/node\":\"^20\",\"@types/react\":\"^19\",\"@types/react-dom\":\"^19\",\"@types/ws\":\"^8.18.1\",\"eslint\":\"^9\",\"eslint-config-next\":\"16.2.6\",\"typescript\":\"^5\"}}","import { NextResponse } from \"next/server\";\nimport { SessionManager } from \"@/lib/agents/SessionManager\";\nimport pkg from \"../../../../package.json\";\n\ndeclare global {\n var wsPort: number | undefined;\n}\n\nexport async function GET(request: Request) {\n try {\n const { searchParams } = new URL(request.url);\n const id = searchParams.get(\"id\");\n const manager = SessionManager.getInstance();\n\n if (id) {\n const session = manager.getSession(id);\n if (!session) {\n return NextResponse.json({ error: \"Session not found\" }, { status: 404 });\n }\n return NextResponse.json({\n ...session.getStatus(),\n logs: session.logs,\n wsPort: global.wsPort || 3001,\n version: pkg.version,\n });\n }\n\n const sessions = manager.listSessions();\n const originalCwd = process.env.ORIGINAL_CWD || process.cwd();\n const wsPort = global.wsPort || 3001;\n return NextResponse.json({ sessions, originalCwd, wsPort, version: pkg.version });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return NextResponse.json({ error: errorMessage }, { status: 500 });\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/route\",\n pathname: \"/api/sessions\",\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/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/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"],"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","getWorkspaceFileFolders","workspaceRoot","normRoot","resolve","files","readdirSync","workspaceFile","find","f","endsWith","filePath","content","readFileSync","json","JSON","parse","folders","Array","isArray","folder","path","resolved","push","ContextManager","writableCache","Map","isWritable","root","has","get","res","set","ensureDirs","aiDir","commandDir","initializeStaging","ccpPath","cccPath","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","GET","request","searchParams","URL","url","id","manager","getInstance","session","getSession","status","getStatus","logs","wsPort","version","sessions","listSessions","originalCwd","errorMessage"],"mappings":"qmCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEA,IAAIA,EAAiC,KAsC9B,SAASyB,EAAcC,CAAW,EACvC,GAAI,CACE,AAAC,EAAA,OAAE,CAAClB,UAAU,CAACkB,IACjB,EADuB,AACvB,OAAE,CAACjB,SAAS,CAACiB,EAAK,CAAEhB,WAAW,CAAK,GAEtC,IAAMC,EAAW,EAAA,OAAI,CAACR,IAAI,CAACuB,EAAK,eAAiBd,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,IAGtF,OAFA,EAAA,OAAE,CAACC,aAAa,CAACL,EAAU,QAC3B,EAAA,OAAE,CAACM,UAAU,CAACN,IACP,CACT,CAAE,KAAM,CACN,OAAO,CACT,CACF,uBAhDO,SAASV,EACd,GAAID,EACF,OAAOA,EAGT,IAAME,EAJe,AAIF,EAAA,OAAI,CAACC,I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AAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,QAAiB,EAAW,CAAC,GAE5C,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,mCA5TA,SAAS,EACL,MAAO,CAAA,EAAA,EAAA,UAAA,AAAW,EAAC,kBACf,uBACA,CACJ,EACJ","ignoreList":[5]}
@@ -1,8 +1,8 @@
1
- module.exports=[41997,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={BailoutToCSRError:function(){return g},isBailoutToCSRError:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f="BAILOUT_TO_CLIENT_SIDE_RENDERING";class g extends Error{constructor(a){super(`Bail out to client-side rendering: ${a}`),this.reason=a,this.digest=f}}function h(a){return"object"==typeof a&&null!==a&&"digest"in a&&a.digest===f}},32245,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"BailoutToCSR",{enumerable:!0,get:function(){return e}});let d=a.r(41997);function e({reason:a,children:b}){throw Object.defineProperty(new d.BailoutToCSRError(a),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0})}},7773,(a,b,c)=>{"use strict";function d(a){return a.split("/").map(a=>encodeURIComponent(a)).join("/")}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"encodeURIPath",{enumerable:!0,get:function(){return d}})},68063,(a,b,c)=>{"use strict";let d;Object.defineProperty(c,"__esModule",{value:!0});var e={getAssetToken:function(){return i},getAssetTokenQuery:function(){return j},getDeploymentId:function(){return g},getDeploymentIdQuery:function(){return h}};for(var f in e)Object.defineProperty(c,f,{enumerable:!0,get:e[f]});function g(){return d}function h(a=!1){return d?`${a?"&":"?"}dpl=${d}`:""}function i(){return!1}function j(a=!1){return""}d=void 0},97458,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"PreloadChunks",{enumerable:!0,get:function(){return i}});let d=a.r(87924),e=a.r(35112),f=a.r(56704),g=a.r(7773),h=a.r(68063);function i({moduleIds:a}){let b=f.workAsyncStorage.getStore();if(void 0===b)return null;let c=[];if(b.reactLoadableManifest&&a){let d=b.reactLoadableManifest;for(let b of a){if(!d[b])continue;let a=d[b].files;c.push(...a)}}if(0===c.length)return null;let j=(0,h.getAssetTokenQuery)();return(0,d.jsx)(d.Fragment,{children:c.map(a=>{let c=`${b.assetPrefix}/_next/${(0,g.encodeURIPath)(a)}${j}`;return a.endsWith(".css")?(0,d.jsx)("link",{precedence:"dynamic",href:c,rel:"stylesheet",as:"style",nonce:b.nonce},a):((0,e.preload)(c,{as:"script",fetchPriority:"low",nonce:b.nonce}),null)})})}},69853,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return j}});let d=a.r(87924),e=a.r(72131),f=a.r(32245),g=a.r(97458);function h(a){return{default:a&&"default"in a?a.default:a}}let i={loader:()=>Promise.resolve(h(()=>null)),loading:null,ssr:!0},j=function(a){let b={...i,...a},c=(0,e.lazy)(()=>b.loader().then(h)),j=b.loading;function k(a){let h=j?(0,d.jsx)(j,{isLoading:!0,pastDelay:!0,error:null}):null,i=!b.ssr||!!b.loading,k=i?e.Suspense:e.Fragment,l=b.ssr?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.PreloadChunks,{moduleIds:b.modules}),(0,d.jsx)(c,{...a})]}):(0,d.jsx)(f.BailoutToCSR,{reason:"next/dynamic",children:(0,d.jsx)(c,{...a})});return(0,d.jsx)(k,{...i?{fallback:h}:{},children:l})}return k.displayName="LoadableComponent",k}},19721,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return e}});let d=a.r(33354)._(a.r(69853));function e(a,b){let c={};"function"==typeof a&&(c.loader=a);let e={...c,...b};return(0,d.default)({...e,modules:e.loadableGenerated?.modules})}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},46845,a=>{a.v({activeBorder:"page-module___8aEwW__activeBorder",agentBadge:"page-module___8aEwW__agentBadge",agentCard:"page-module___8aEwW__agentCard",agentGrid:"page-module___8aEwW__agentGrid",agentHeader:"page-module___8aEwW__agentHeader",agentName:"page-module___8aEwW__agentName",ansiCyan:"page-module___8aEwW__ansiCyan",ansiGreen:"page-module___8aEwW__ansiGreen",ansiMagenta:"page-module___8aEwW__ansiMagenta",ansiRed:"page-module___8aEwW__ansiRed",ansiYellow:"page-module___8aEwW__ansiYellow",cardBody:"page-module___8aEwW__cardBody",container:"page-module___8aEwW__container",containerActive:"page-module___8aEwW__containerActive",contextDetails:"page-module___8aEwW__contextDetails",contextItem:"page-module___8aEwW__contextItem",contextList:"page-module___8aEwW__contextList",contextMeta:"page-module___8aEwW__contextMeta",contextTitle:"page-module___8aEwW__contextTitle",dashboardGrid:"page-module___8aEwW__dashboardGrid",envGrid:"page-module___8aEwW__envGrid",envName:"page-module___8aEwW__envName",envRow:"page-module___8aEwW__envRow",envStatus:"page-module___8aEwW__envStatus",footer:"page-module___8aEwW__footer",header:"page-module___8aEwW__header",logoArea:"page-module___8aEwW__logoArea",mainPanel:"page-module___8aEwW__mainPanel",pulse:"page-module___8aEwW__pulse",pulseDot:"page-module___8aEwW__pulseDot",quickLaunchBtn:"page-module___8aEwW__quickLaunchBtn",sectionTitle:"page-module___8aEwW__sectionTitle",sidePanel:"page-module___8aEwW__sidePanel",statusIndicator:"page-module___8aEwW__statusIndicator",stoppedBadge:"page-module___8aEwW__stoppedBadge",subtitle:"page-module___8aEwW__subtitle",terminalContainer:"page-module___8aEwW__terminalContainer",terminalInput:"page-module___8aEwW__terminalInput",terminalInputArea:"page-module___8aEwW__terminalInputArea",terminalLine:"page-module___8aEwW__terminalLine",terminalSendBtn:"page-module___8aEwW__terminalSendBtn",title:"page-module___8aEwW__title"})},40777,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(19721),e=a.i(46845);function f({workspaceRoot:a}){let[d,e]=(0,c.useState)({global:[],workspace:[]}),[h,i]=(0,c.useState)(null),[j,k]=(0,c.useState)(!0),[l,m]=(0,c.useState)([]),[n,o]=(0,c.useState)(null),[p,q]=(0,c.useState)({}),[r,s]=(0,c.useState)(!1),[t,u]=(0,c.useState)("SELECT * FROM sqlite_master;"),[v,w]=(0,c.useState)(!1),[x,y]=(0,c.useState)(null),[z,A]=(0,c.useState)(null),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(!1),[F,G]=(0,c.useState)({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),[H,I]=(0,c.useState)(!1),[J,K]=(0,c.useState)(null),L=async()=>{try{let b=await fetch(`/api/sql/connections?root=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json();a.success&&(e({global:a.global||[],workspace:a.workspace||[]}),i(a.activeId),k(a.isActiveGlobal))}}catch(a){console.error("Failed to load connection profiles:",a)}},M=async()=>{if(!h)return void m([]);s(!0);try{let b=await fetch(`/api/sql/schema?action=list_tables&root=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json();a.success?(m(a.tables||[]),y(null)):y(a.error||"Failed to load database schema.")}else{let a=await b.json();y(a.error||"Failed to load database schema.")}}catch(a){console.error("Failed to load schema:",a)}finally{s(!1)}},N=async b=>{if(p[b])return void o(n===b?null:b);try{let c=await fetch(`/api/sql/schema?action=describe_table&table=${encodeURIComponent(b)}&root=${encodeURIComponent(a)}`);if(c.ok){let a=await c.json();a.success&&(q(c=>({...c,[b]:a.columns})),o(b))}}catch(a){console.error(`Failed to load columns for table ${b}:`,a)}};(0,c.useEffect)(()=>{L()},[a]),(0,c.useEffect)(()=>{M(),A(null),o(null),q({});let a=j?d.global.find(a=>a.id===h):d.workspace.find(a=>a.id===h);a&&("sqlite"===a.type?u("SELECT name, type FROM sqlite_master WHERE type='table';"):"mssql"===a.type?u("SELECT * FROM sys.tables;"):u("SELECT * FROM information_schema.tables LIMIT 10;"))},[h,j,d.global.length,d.workspace.length]);let O=async(b,c)=>{try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"set_active",profileId:b,isGlobal:c,root:a})})).ok&&(i(b),k(c))}catch(a){console.error("Failed to set active profile:",a)}},P=async()=>{K(null);try{let b=await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"test",profile:F,root:a})}),c=await b.json();c.success?K({success:!0,message:"Connection test successful!"}):K({success:!1,message:c.error||"Connection test failed."})}catch(a){K({success:!1,message:a.message||"Failed to make test query."})}},Q=async b=>{if(b.preventDefault(),!F.name||!F.type)return;I(!0);let c=F.id||`profile_${Math.random().toString(36).substring(7)}`,d={...F,id:c,name:F.name,type:F.type};try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save",profile:d,isGlobal:D,root:a})})).ok&&(await L(),C(!1),h||O(c,D))}catch(a){console.error("Failed to save profile:",a)}finally{I(!1)}},R=async(b,c)=>{if(confirm("Are you sure you want to delete this connection profile?"))try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",profileId:b,isGlobal:c,root:a})})).ok&&(await L(),h===b&&i(null))}catch(a){console.error("Failed to delete connection profile:",a)}},S=async()=>{if(t.trim()&&h){w(!0),y(null),A(null);try{let b=await fetch("/api/sql/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:t.trim(),root:a})}),c=await b.json();b.ok&&c.success?(A({rows:c.rows||[],fields:c.fields||[],durationMs:c.durationMs||0,affectedRows:c.affectedRows}),(t.toLowerCase().includes("create table")||t.toLowerCase().includes("drop table")||t.toLowerCase().includes("alter table"))&&M()):y(c.error||"Failed to execute query.")}catch(a){y(a.message||"An unexpected error occurred during execution.")}finally{w(!1)}}},T=j?d.global.find(a=>a.id===h):d.workspace.find(a=>a.id===h);return(0,b.jsxs)("div",{style:g.container,children:[(0,b.jsxs)("div",{style:g.sidebar,children:[(0,b.jsxs)("div",{style:g.section,children:[(0,b.jsxs)("div",{style:g.sectionHeader,children:[(0,b.jsx)("span",{style:g.sectionTitle,children:"Connections"}),(0,b.jsx)("button",{style:g.addBtn,onClick:()=>{K(null),G({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),E(!1),C(!0)},title:"Add Database Connection Profile",children:"➕ Add"})]}),(0,b.jsxs)("div",{style:g.profileList,children:[0===d.global.length&&0===d.workspace.length&&(0,b.jsx)("div",{style:g.emptyText,children:"No connections configured. Add one to start."}),d.workspace.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{style:g.groupHeader,children:"WORKSPACE CONNECTIONS"}),d.workspace.map(a=>(0,b.jsxs)("div",{style:{...g.profileItem,...h===a.id&&!j?g.profileItemActive:{}},onClick:()=>O(a.id,!1),children:[(0,b.jsxs)("div",{style:g.profileMeta,children:[(0,b.jsxs)("span",{style:g.profileName,children:["📁 ",a.name]}),(0,b.jsx)("span",{style:g.profileType,children:a.type})]}),(0,b.jsx)("button",{style:g.deleteProfileBtn,onClick:b=>{b.stopPropagation(),R(a.id,!1)},children:"✖"})]},a.id))]}),d.global.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{style:g.groupHeader,children:"GLOBAL CONNECTIONS"}),d.global.map(a=>(0,b.jsxs)("div",{style:{...g.profileItem,...h===a.id&&j?g.profileItemActive:{}},onClick:()=>O(a.id,!0),children:[(0,b.jsxs)("div",{style:g.profileMeta,children:[(0,b.jsxs)("span",{style:g.profileName,children:["🌐 ",a.name]}),(0,b.jsx)("span",{style:g.profileType,children:a.type})]}),(0,b.jsx)("button",{style:g.deleteProfileBtn,onClick:b=>{b.stopPropagation(),R(a.id,!0)},children:"✖"})]},a.id))]})]})]}),(0,b.jsxs)("div",{style:{...g.section,flex:1,borderTop:"1px solid var(--border)"},children:[(0,b.jsxs)("div",{style:g.sectionHeader,children:[(0,b.jsx)("span",{style:g.sectionTitle,children:"Schema Tables"}),r&&(0,b.jsx)("span",{style:g.spinnerMini})]}),(0,b.jsxs)("div",{style:g.tableList,children:[!h&&(0,b.jsx)("div",{style:g.emptyText,children:"Select an active connection to view tables."}),h&&0===l.length&&!r&&(0,b.jsx)("div",{style:g.emptyText,children:"No tables found in database schema."}),l.map(a=>(0,b.jsxs)("div",{style:g.tableTreeItem,children:[(0,b.jsxs)("div",{style:g.tableRow,onClick:()=>N(a.name),children:[(0,b.jsx)("span",{style:g.tableIcon,children:"view"===a.type?"👁️":"📊"}),(0,b.jsx)("span",{style:g.tableName,children:a.name}),(0,b.jsx)("span",{style:g.tableChevron,children:n===a.name?"▼":"▶"})]}),n===a.name&&p[a.name]&&(0,b.jsx)("div",{style:g.columnList,children:p[a.name].map(a=>(0,b.jsxs)("div",{style:g.columnItem,children:[(0,b.jsx)("span",{style:g.columnIcon,children:a.isPrimaryKey?"🔑":a.isForeignKey?"🔗":"▫"}),(0,b.jsx)("span",{style:g.columnName,title:a.type,children:a.name}),(0,b.jsx)("span",{style:g.columnType,children:a.type.toLowerCase().substring(0,12)})]},a.name))})]},a.name))]})]})]}),(0,b.jsxs)("div",{style:g.mainContent,children:[(0,b.jsxs)("div",{style:g.statusBar,children:[(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[(0,b.jsx)("span",{style:g.statusLabel,children:"Active Connection:"}),T?(0,b.jsxs)("span",{style:g.statusValue,children:[j?"🌐":"📁"," ",T.name," (",T.type,")",T.readOnly&&(0,b.jsx)("span",{style:g.readOnlyBadge,children:"Read-Only"})]}):(0,b.jsx)("span",{style:{...g.statusValue,color:"var(--danger)"},children:"No Connection Selected"})]}),(0,b.jsx)("button",{style:{...g.runBtn,opacity:!h||v?.6:1,cursor:!h||v?"not-allowed":"pointer"},onClick:S,disabled:!h||v,children:v?"⌛ Running...":"⚡ Execute Query (F5)"})]}),(0,b.jsx)("div",{style:g.editorArea,children:(0,b.jsx)("textarea",{style:g.textarea,value:t,onChange:a=>u(a.target.value),placeholder:"Write your SQL query script here...",onKeyDown:a=>{("F5"===a.key||a.ctrlKey&&"Enter"===a.key)&&(a.preventDefault(),S())}})}),(0,b.jsxs)("div",{style:g.resultsArea,children:[x&&(0,b.jsxs)("div",{style:g.errorContainer,children:[(0,b.jsx)("h4",{style:{margin:"0 0 0.5rem 0",color:"var(--danger)"},children:"⚠️ Execution Error"}),(0,b.jsx)("pre",{style:g.errorText,children:x}),x.includes("not installed")&&(0,b.jsxs)("div",{style:g.driverPrompt,children:[(0,b.jsx)("p",{style:{margin:"0 0 0.5rem 0"},children:"To resolve this, run this installer command in your workspace terminal:"}),(0,b.jsx)("code",{style:g.driverCode,children:T?.type==="sqlite"?"npm install better-sqlite3":T?.type==="postgres"?"npm install pg":T?.type==="mysql"?"npm install mysql2":"npm install mssql"})]})]}),z&&(0,b.jsxs)("div",{style:g.resultsWrapper,children:[(0,b.jsxs)("div",{style:g.resultsMeta,children:[(0,b.jsxs)("span",{children:["Query completed."," ",void 0!==z.affectedRows?`Affected rows: ${z.affectedRows}`:`Returned ${z.rows.length} rows`]}),(0,b.jsxs)("span",{children:["Duration: ",z.durationMs,"ms"]})]}),z.rows.length>0?(0,b.jsx)("div",{style:g.tableContainer,children:(0,b.jsxs)("table",{style:g.table,children:[(0,b.jsx)("thead",{children:(0,b.jsx)("tr",{children:z.fields.map(a=>(0,b.jsx)("th",{style:g.th,children:a},a))})}),(0,b.jsx)("tbody",{children:z.rows.map((a,c)=>(0,b.jsx)("tr",{style:c%2==0?g.trEven:g.trOdd,children:z.fields.map(c=>(0,b.jsx)("td",{style:g.td,children:null===a[c]?"NULL":"object"==typeof a[c]?JSON.stringify(a[c]):String(a[c])},c))},c))})]})}):void 0===z.affectedRows&&(0,b.jsx)("div",{style:g.emptyResults,children:"Query executed successfully, but returned 0 results."})]}),!x&&!z&&!v&&(0,b.jsx)("div",{style:g.emptyResults,children:"Write a query script and click Execute to view table records."}),v&&(0,b.jsxs)("div",{style:g.loadingWrapper,children:[(0,b.jsx)("span",{style:g.spinnerLarge}),(0,b.jsx)("span",{style:{color:"var(--muted)"},children:"Running database statement..."})]})]})]}),B&&(0,b.jsx)("div",{style:g.modalOverlay,children:(0,b.jsxs)("div",{style:g.modalContent,children:[(0,b.jsxs)("h3",{style:{margin:"0 0 1rem 0",display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"🔌 Add Database Profile"}),(0,b.jsx)("span",{style:{cursor:"pointer"},onClick:()=>C(!1),children:"✖"})]}),(0,b.jsxs)("form",{onSubmit:Q,children:[(0,b.jsxs)("div",{style:g.formRow,children:[(0,b.jsx)("label",{style:g.label,children:"Profile Name"}),(0,b.jsx)("input",{style:g.input,type:"text",required:!0,value:F.name,onChange:a=>G(b=>({...b,name:a.target.value})),placeholder:"e.g. Local Postgres, Dev SQLite"})]}),(0,b.jsxs)("div",{style:g.formRow,children:[(0,b.jsx)("label",{style:g.label,children:"Scope Level"}),(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"radio",checked:!D,onChange:()=>E(!1)}),"Workspace Local"]}),(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"radio",checked:D,onChange:()=>E(!0)}),"Global User Profile"]})]})]}),(0,b.jsxs)("div",{style:g.formRow,children:[(0,b.jsx)("label",{style:g.label,children:"Database Type"}),(0,b.jsxs)("select",{style:g.select,value:F.type,onChange:a=>{let b=a.target.value,c=5432;"mysql"===b&&(c=3306),"mssql"===b&&(c=1433),G(a=>({...a,type:b,filepath:"sqlite"===b?"./dev.db":void 0,port:"sqlite"!==b?c:void 0,database:"sqlite"===b?void 0:"mssql"===b?"master":"postgres"===b?"postgres":"",username:"sqlite"===b?void 0:"mssql"===b?"sa":"postgres"===b?"postgres":"root"}))},children:[(0,b.jsx)("option",{value:"sqlite",children:"SQLite (Local File)"}),(0,b.jsx)("option",{value:"postgres",children:"PostgreSQL"}),(0,b.jsx)("option",{value:"mysql",children:"MySQL"}),(0,b.jsx)("option",{value:"mssql",children:"Microsoft SQL Server"})]})]}),"sqlite"===F.type?(0,b.jsxs)("div",{style:g.formRow,children:[(0,b.jsx)("label",{style:g.label,children:"Database File Path"}),(0,b.jsx)("input",{style:g.input,type:"text",required:!0,value:F.filepath||"",onChange:a=>G(b=>({...b,filepath:a.target.value})),placeholder:"Relative (e.g. ./data/dev.db) or Absolute path"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,b.jsxs)("div",{style:{...g.formRow,flex:3},children:[(0,b.jsx)("label",{style:g.label,children:"Host IP Address"}),(0,b.jsx)("input",{style:g.input,type:"text",required:!0,value:F.host||"",onChange:a=>G(b=>({...b,host:a.target.value})),placeholder:"localhost or IP"})]}),(0,b.jsxs)("div",{style:{...g.formRow,flex:1},children:[(0,b.jsx)("label",{style:g.label,children:"Port"}),(0,b.jsx)("input",{style:g.input,type:"number",required:!0,value:F.port||0,onChange:a=>G(b=>({...b,port:parseInt(a.target.value)}))})]})]}),(0,b.jsxs)("div",{style:g.formRow,children:[(0,b.jsx)("label",{style:g.label,children:"Database Name"}),(0,b.jsx)("input",{style:g.input,type:"text",required:!0,value:F.database||"",onChange:a=>G(b=>({...b,database:a.target.value}))})]}),(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,b.jsxs)("div",{style:{...g.formRow,flex:1},children:[(0,b.jsx)("label",{style:g.label,children:"Username"}),(0,b.jsx)("input",{style:g.input,type:"text",required:!0,value:F.username||"",onChange:a=>G(b=>({...b,username:a.target.value}))})]}),(0,b.jsxs)("div",{style:{...g.formRow,flex:1},children:[(0,b.jsx)("label",{style:g.label,children:"Password"}),(0,b.jsx)("input",{style:g.input,type:"password",value:F.password||"",onChange:a=>G(b=>({...b,password:a.target.value}))})]})]}),("postgres"===F.type||"mssql"===F.type)&&(0,b.jsx)("div",{style:g.formRow,children:(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"checkbox",checked:!!F.ssl,onChange:a=>G(b=>({...b,ssl:a.target.checked}))}),"Require SSL Secure Connection"]})})]}),(0,b.jsx)("div",{style:g.formRow,children:(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"checkbox",checked:!!F.readOnly,onChange:a=>G(b=>({...b,readOnly:a.target.checked}))}),"Enforce Read-Only Connection (Disable mutations)"]})}),J&&(0,b.jsx)("div",{style:{...g.testResult,backgroundColor:J.success?"rgba(16, 185, 129, 0.12)":"rgba(239, 68, 68, 0.12)",border:J.success?"1px solid var(--success)":"1px solid var(--danger)",color:J.success?"var(--success)":"var(--danger)"},children:J.message}),(0,b.jsxs)("div",{style:g.modalFooter,children:[(0,b.jsx)("button",{type:"button",style:g.testBtn,onClick:P,children:"🔍 Test Connection"}),(0,b.jsxs)("div",{style:{display:"flex",gap:"0.5rem"},children:[(0,b.jsx)("button",{type:"button",style:g.cancelBtn,onClick:()=>C(!1),children:"Cancel"}),(0,b.jsx)("button",{type:"submit",style:g.saveBtn,disabled:H,children:H?"Saving...":"Save Profile"})]})]})]})]})})]})}let g={container:{display:"flex",height:"100%",width:"100%",backgroundColor:"#05070a",color:"#cbd5e1",fontSize:"0.875rem",minHeight:0},sidebar:{width:"280px",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",minHeight:0,backgroundColor:"rgba(10, 15, 24, 0.4)",flexShrink:0},section:{display:"flex",flexDirection:"column",padding:"1rem",minHeight:0},sectionHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.75rem"},sectionTitle:{fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",fontSize:"0.75rem",color:"var(--muted)"},addBtn:{padding:"0.2rem 0.5rem",borderRadius:"4px",border:"1px solid var(--primary)",backgroundColor:"transparent",color:"var(--primary)",fontSize:"0.7rem",fontWeight:600,cursor:"pointer"},profileList:{display:"flex",flexDirection:"column",gap:"0.4rem",overflowY:"auto",maxHeight:"220px"},groupHeader:{fontSize:"0.65rem",fontWeight:600,color:"var(--muted)",marginTop:"0.5rem",marginBottom:"0.2rem",letterSpacing:"0.05em"},profileItem:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.5rem 0.6rem",borderRadius:"6px",backgroundColor:"rgba(255, 255, 255, 0.02)",border:"1px solid var(--border)",cursor:"pointer",transition:"all 0.2s ease"},profileItemActive:{backgroundColor:"rgba(109, 40, 217, 0.08)",border:"1px solid var(--border-focus)",boxShadow:"0 0 10px rgba(109, 40, 217, 0.1)"},profileMeta:{display:"flex",flexDirection:"column",gap:"0.15rem",flex:1,minWidth:0},profileName:{fontWeight:600,fontSize:"0.8rem",color:"#fff",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},profileType:{fontSize:"0.7rem",color:"var(--muted)",textTransform:"uppercase"},deleteProfileBtn:{background:"none",border:"none",color:"rgba(239, 68, 68, 0.4)",cursor:"pointer",fontSize:"0.75rem",padding:"0.25rem"},tableList:{display:"flex",flexDirection:"column",gap:"0.25rem",overflowY:"auto",flex:1,minHeight:0},emptyText:{fontSize:"0.75rem",color:"var(--muted)",textAlign:"center",padding:"1rem 0"},tableTreeItem:{display:"flex",flexDirection:"column"},tableRow:{display:"flex",alignItems:"center",padding:"0.35rem 0.5rem",borderRadius:"4px",cursor:"pointer",userSelect:"none",transition:"background 0.2s ease"},tableIcon:{marginRight:"0.4rem",fontSize:"0.9rem"},tableName:{flex:1,fontSize:"0.8rem",color:"#e2e8f0",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},tableChevron:{fontSize:"0.6rem",color:"var(--muted)",marginLeft:"0.25rem"},columnList:{display:"flex",flexDirection:"column",gap:"0.2rem",paddingLeft:"1.5rem",marginTop:"0.15rem",borderLeft:"1px dashed rgba(255,255,255,0.06)",marginLeft:"0.8rem",marginBottom:"0.25rem"},columnItem:{display:"flex",alignItems:"center",padding:"0.15rem 0.25rem",fontSize:"0.75rem"},columnIcon:{marginRight:"0.3rem",fontSize:"0.7rem"},columnName:{flex:1,color:"var(--muted)",overflow:"hidden",textOverflow:"ellipsis"},columnType:{fontSize:"0.65rem",color:"rgba(109, 40, 217, 0.75)",fontFamily:"monospace",paddingLeft:"0.5rem"},mainContent:{flex:1,display:"flex",flexDirection:"column",minHeight:0,backgroundColor:"#05070a"},statusBar:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 1rem",borderBottom:"1px solid var(--border)",backgroundColor:"rgba(15, 23, 42, 0.3)",flexShrink:0},statusLabel:{fontSize:"0.75rem",color:"var(--muted)"},statusValue:{fontSize:"0.8rem",fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:"0.4rem"},readOnlyBadge:{padding:"0.1rem 0.4rem",borderRadius:"4px",backgroundColor:"rgba(234, 179, 8, 0.12)",color:"#eab308",fontSize:"0.65rem",fontWeight:700,border:"1px solid rgba(234, 179, 8, 0.2)"},runBtn:{padding:"0.4rem 0.9rem",borderRadius:"6px",border:"none",backgroundColor:"var(--primary)",color:"#fff",fontSize:"0.8rem",fontWeight:600,transition:"all 0.2s ease"},editorArea:{height:"180px",borderBottom:"1px solid var(--border)",position:"relative",flexShrink:0},textarea:{width:"100%",height:"100%",backgroundColor:"#080c14",border:"none",resize:"none",color:"#e2e8f0",fontFamily:"monospace",fontSize:"0.85rem",padding:"1rem",outline:"none",lineHeight:"1.4"},resultsArea:{flex:1,display:"flex",flexDirection:"column",minHeight:0,padding:"1rem"},errorContainer:{padding:"1rem",borderRadius:"8px",backgroundColor:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",overflowY:"auto"},errorText:{margin:0,fontFamily:"monospace",fontSize:"0.8rem",color:"#f87171",whiteSpace:"pre-wrap"},driverPrompt:{marginTop:"1rem",padding:"0.75rem",borderRadius:"6px",backgroundColor:"rgba(0, 0, 0, 0.3)",border:"1px solid var(--border)"},driverCode:{display:"block",padding:"0.5rem",backgroundColor:"#090d16",borderRadius:"4px",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--primary)",border:"1px solid var(--border)"},resultsWrapper:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},resultsMeta:{display:"flex",justifyContent:"space-between",fontSize:"0.75rem",color:"var(--muted)",marginBottom:"0.5rem"},tableContainer:{flex:1,overflow:"auto",border:"1px solid var(--border)",borderRadius:"6px"},table:{width:"100%",borderCollapse:"collapse",fontFamily:"monospace",fontSize:"0.8rem"},th:{padding:"0.5rem 0.75rem",textAlign:"left",backgroundColor:"#0f172a",borderBottom:"1px solid var(--border)",color:"#94a3b8",fontWeight:600,position:"sticky",top:0,zIndex:1},td:{padding:"0.4rem 0.75rem",borderBottom:"1px solid rgba(255, 255, 255, 0.03)",color:"#cbd5e1",whiteSpace:"nowrap"},trEven:{backgroundColor:"transparent"},trOdd:{backgroundColor:"rgba(255, 255, 255, 0.01)"},emptyResults:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--muted)",fontSize:"0.8rem",textAlign:"center"},loadingWrapper:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"1rem"},spinnerLarge:{width:"24px",height:"24px",border:"3px solid rgba(109, 40, 217, 0.15)",borderTop:"3px solid var(--primary)",borderRadius:"50%",animation:"spin 1s linear infinite"},spinnerMini:{width:"12px",height:"12px",border:"2px solid rgba(255, 255, 255, 0.1)",borderTop:"2px solid var(--muted)",borderRadius:"50%",animation:"spin 1s linear infinite"},modalOverlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:999},modalContent:{width:"480px",backgroundColor:"#0d131f",borderRadius:"12px",border:"1px solid var(--border-focus)",padding:"1.5rem",boxShadow:"0 4px 24px rgba(0, 0, 0, 0.5)"},formRow:{display:"flex",flexDirection:"column",gap:"0.35rem",marginBottom:"1rem"},label:{fontSize:"0.75rem",fontWeight:600,color:"var(--muted)"},input:{padding:"0.5rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"#070a12",color:"#fff",outline:"none",fontSize:"0.8rem"},select:{padding:"0.5rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"#070a12",color:"#fff",outline:"none",fontSize:"0.8rem"},testResult:{padding:"0.5rem",borderRadius:"6px",fontSize:"0.75rem",marginBottom:"1rem"},modalFooter:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},testBtn:{padding:"0.4rem 0.75rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"transparent",color:"var(--muted)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"},cancelBtn:{padding:"0.4rem 0.75rem",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--muted)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"},saveBtn:{padding:"0.4rem 0.75rem",borderRadius:"6px",border:"none",backgroundColor:"var(--primary)",color:"#fff",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"}};if("u">typeof document){let a=document.createElement("style");a.innerHTML=`
1
+ module.exports=[41997,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={BailoutToCSRError:function(){return g},isBailoutToCSRError:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f="BAILOUT_TO_CLIENT_SIDE_RENDERING";class g extends Error{constructor(a){super(`Bail out to client-side rendering: ${a}`),this.reason=a,this.digest=f}}function h(a){return"object"==typeof a&&null!==a&&"digest"in a&&a.digest===f}},32245,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"BailoutToCSR",{enumerable:!0,get:function(){return e}});let d=a.r(41997);function e({reason:a,children:b}){throw Object.defineProperty(new d.BailoutToCSRError(a),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0})}},7773,(a,b,c)=>{"use strict";function d(a){return a.split("/").map(a=>encodeURIComponent(a)).join("/")}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"encodeURIPath",{enumerable:!0,get:function(){return d}})},68063,(a,b,c)=>{"use strict";let d;Object.defineProperty(c,"__esModule",{value:!0});var e={getAssetToken:function(){return i},getAssetTokenQuery:function(){return j},getDeploymentId:function(){return g},getDeploymentIdQuery:function(){return h}};for(var f in e)Object.defineProperty(c,f,{enumerable:!0,get:e[f]});function g(){return d}function h(a=!1){return d?`${a?"&":"?"}dpl=${d}`:""}function i(){return!1}function j(a=!1){return""}d=void 0},97458,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"PreloadChunks",{enumerable:!0,get:function(){return i}});let d=a.r(87924),e=a.r(35112),f=a.r(56704),g=a.r(7773),h=a.r(68063);function i({moduleIds:a}){let b=f.workAsyncStorage.getStore();if(void 0===b)return null;let c=[];if(b.reactLoadableManifest&&a){let d=b.reactLoadableManifest;for(let b of a){if(!d[b])continue;let a=d[b].files;c.push(...a)}}if(0===c.length)return null;let j=(0,h.getAssetTokenQuery)();return(0,d.jsx)(d.Fragment,{children:c.map(a=>{let c=`${b.assetPrefix}/_next/${(0,g.encodeURIPath)(a)}${j}`;return a.endsWith(".css")?(0,d.jsx)("link",{precedence:"dynamic",href:c,rel:"stylesheet",as:"style",nonce:b.nonce},a):((0,e.preload)(c,{as:"script",fetchPriority:"low",nonce:b.nonce}),null)})})}},69853,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return j}});let d=a.r(87924),e=a.r(72131),f=a.r(32245),g=a.r(97458);function h(a){return{default:a&&"default"in a?a.default:a}}let i={loader:()=>Promise.resolve(h(()=>null)),loading:null,ssr:!0},j=function(a){let b={...i,...a},c=(0,e.lazy)(()=>b.loader().then(h)),j=b.loading;function k(a){let h=j?(0,d.jsx)(j,{isLoading:!0,pastDelay:!0,error:null}):null,i=!b.ssr||!!b.loading,k=i?e.Suspense:e.Fragment,l=b.ssr?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.PreloadChunks,{moduleIds:b.modules}),(0,d.jsx)(c,{...a})]}):(0,d.jsx)(f.BailoutToCSR,{reason:"next/dynamic",children:(0,d.jsx)(c,{...a})});return(0,d.jsx)(k,{...i?{fallback:h}:{},children:l})}return k.displayName="LoadableComponent",k}},19721,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return e}});let d=a.r(33354)._(a.r(69853));function e(a,b){let c={};"function"==typeof a&&(c.loader=a);let e={...c,...b};return(0,d.default)({...e,modules:e.loadableGenerated?.modules})}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},46845,a=>{a.v({activeBorder:"page-module___8aEwW__activeBorder",agentBadge:"page-module___8aEwW__agentBadge",agentCard:"page-module___8aEwW__agentCard",agentGrid:"page-module___8aEwW__agentGrid",agentHeader:"page-module___8aEwW__agentHeader",agentName:"page-module___8aEwW__agentName",ansiCyan:"page-module___8aEwW__ansiCyan",ansiGreen:"page-module___8aEwW__ansiGreen",ansiMagenta:"page-module___8aEwW__ansiMagenta",ansiRed:"page-module___8aEwW__ansiRed",ansiYellow:"page-module___8aEwW__ansiYellow",cardBody:"page-module___8aEwW__cardBody",container:"page-module___8aEwW__container",containerActive:"page-module___8aEwW__containerActive",contextDetails:"page-module___8aEwW__contextDetails",contextItem:"page-module___8aEwW__contextItem",contextList:"page-module___8aEwW__contextList",contextMeta:"page-module___8aEwW__contextMeta",contextTitle:"page-module___8aEwW__contextTitle",dashboardGrid:"page-module___8aEwW__dashboardGrid",envGrid:"page-module___8aEwW__envGrid",envName:"page-module___8aEwW__envName",envRow:"page-module___8aEwW__envRow",envStatus:"page-module___8aEwW__envStatus",footer:"page-module___8aEwW__footer",header:"page-module___8aEwW__header",logoArea:"page-module___8aEwW__logoArea",mainPanel:"page-module___8aEwW__mainPanel",pulse:"page-module___8aEwW__pulse",pulseDot:"page-module___8aEwW__pulseDot",quickLaunchBtn:"page-module___8aEwW__quickLaunchBtn",sectionTitle:"page-module___8aEwW__sectionTitle",sidePanel:"page-module___8aEwW__sidePanel",statusIndicator:"page-module___8aEwW__statusIndicator",stoppedBadge:"page-module___8aEwW__stoppedBadge",subtitle:"page-module___8aEwW__subtitle",terminalContainer:"page-module___8aEwW__terminalContainer",terminalInput:"page-module___8aEwW__terminalInput",terminalInputArea:"page-module___8aEwW__terminalInputArea",terminalLine:"page-module___8aEwW__terminalLine",terminalSendBtn:"page-module___8aEwW__terminalSendBtn",title:"page-module___8aEwW__title"})},40777,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(19721),e=a.i(46845),f=a.i(35112);function g({workspaceRoot:a}){let[d,e]=(0,c.useState)({global:[],workspace:[]}),[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)([]),[o,p]=(0,c.useState)(null),[q,r]=(0,c.useState)({}),[s,t]=(0,c.useState)(!1),[u,v]=(0,c.useState)("SELECT * FROM sqlite_master;"),[w,x]=(0,c.useState)(!1),[y,z]=(0,c.useState)(null),[A,B]=(0,c.useState)(null),[C,D]=(0,c.useState)(!1),[E,F]=(0,c.useState)(!1),[G,H]=(0,c.useState)({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),[I,J]=(0,c.useState)(!1),[K,L]=(0,c.useState)(null),M=async()=>{try{let b=await fetch(`/api/sql/connections?root=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json();a.success&&(e({global:a.global||[],workspace:a.workspace||[]}),j(a.activeId),l(a.isActiveGlobal))}}catch(a){console.error("Failed to load connection profiles:",a)}},N=async()=>{if(!i)return void n([]);t(!0);try{let b=await fetch(`/api/sql/schema?action=list_tables&root=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json();a.success?(n(a.tables||[]),z(null)):z(a.error||"Failed to load database schema.")}else{let a=await b.json();z(a.error||"Failed to load database schema.")}}catch(a){console.error("Failed to load schema:",a)}finally{t(!1)}},O=async b=>{if(q[b])return void p(o===b?null:b);try{let c=await fetch(`/api/sql/schema?action=describe_table&table=${encodeURIComponent(b)}&root=${encodeURIComponent(a)}`);if(c.ok){let a=await c.json();a.success&&(r(c=>({...c,[b]:a.columns})),p(b))}}catch(a){console.error(`Failed to load columns for table ${b}:`,a)}};(0,c.useEffect)(()=>{M()},[a]),(0,c.useEffect)(()=>{N(),B(null),p(null),r({});let a=k?d.global.find(a=>a.id===i):d.workspace.find(a=>a.id===i);a&&("sqlite"===a.type?v("SELECT name, type FROM sqlite_master WHERE type='table';"):"mssql"===a.type?v("SELECT * FROM sys.tables;"):v("SELECT * FROM information_schema.tables LIMIT 10;"))},[i,k,d.global.length,d.workspace.length]);let P=async(b,c)=>{try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"set_active",profileId:b,isGlobal:c,root:a})})).ok&&(j(b),l(c))}catch(a){console.error("Failed to set active profile:",a)}},Q=async()=>{L(null);try{let b=await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"test",profile:G,root:a})}),c=await b.json();c.success?L({success:!0,message:"Connection test successful!"}):L({success:!1,message:c.error||"Connection test failed."})}catch(a){L({success:!1,message:a.message||"Failed to make test query."})}},R=async b=>{if(b.preventDefault(),!G.name||!G.type)return;J(!0);let c=G.id||`profile_${Math.random().toString(36).substring(7)}`,d={...G,id:c,name:G.name,type:G.type};try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save",profile:d,isGlobal:E,root:a})})).ok&&(await M(),D(!1),i||P(c,E))}catch(a){console.error("Failed to save profile:",a)}finally{J(!1)}},S=async(b,c)=>{if(confirm("Are you sure you want to delete this connection profile?"))try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",profileId:b,isGlobal:c,root:a})})).ok&&(await M(),i===b&&j(null))}catch(a){console.error("Failed to delete connection profile:",a)}},T=async()=>{if(u.trim()&&i){x(!0),z(null),B(null);try{let b=await fetch("/api/sql/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:u.trim(),root:a})}),c=await b.json();b.ok&&c.success?(B({rows:c.rows||[],fields:c.fields||[],durationMs:c.durationMs||0,affectedRows:c.affectedRows}),(u.toLowerCase().includes("create table")||u.toLowerCase().includes("drop table")||u.toLowerCase().includes("alter table"))&&N()):z(c.error||"Failed to execute query.")}catch(a){z(a.message||"An unexpected error occurred during execution.")}finally{x(!1)}}},U=k?d.global.find(a=>a.id===i):d.workspace.find(a=>a.id===i);return(0,b.jsxs)("div",{style:h.container,children:[(0,b.jsxs)("div",{style:h.sidebar,children:[(0,b.jsxs)("div",{style:h.section,children:[(0,b.jsxs)("div",{style:h.sectionHeader,children:[(0,b.jsx)("span",{style:h.sectionTitle,children:"Connections"}),(0,b.jsx)("button",{style:h.addBtn,onClick:()=>{L(null),H({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),F(!1),D(!0)},title:"Add Database Connection Profile",children:"➕ Add"})]}),(0,b.jsxs)("div",{style:h.profileList,children:[0===d.global.length&&0===d.workspace.length&&(0,b.jsx)("div",{style:h.emptyText,children:"No connections configured. Add one to start."}),d.workspace.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{style:h.groupHeader,children:"WORKSPACE CONNECTIONS"}),d.workspace.map(a=>(0,b.jsxs)("div",{style:{...h.profileItem,...i===a.id&&!k?h.profileItemActive:{}},onClick:()=>P(a.id,!1),children:[(0,b.jsxs)("div",{style:h.profileMeta,children:[(0,b.jsxs)("span",{style:h.profileName,children:["📁 ",a.name]}),(0,b.jsx)("span",{style:h.profileType,children:a.type})]}),(0,b.jsx)("button",{style:h.deleteProfileBtn,onClick:b=>{b.stopPropagation(),S(a.id,!1)},children:"✖"})]},a.id))]}),d.global.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{style:h.groupHeader,children:"GLOBAL CONNECTIONS"}),d.global.map(a=>(0,b.jsxs)("div",{style:{...h.profileItem,...i===a.id&&k?h.profileItemActive:{}},onClick:()=>P(a.id,!0),children:[(0,b.jsxs)("div",{style:h.profileMeta,children:[(0,b.jsxs)("span",{style:h.profileName,children:["🌐 ",a.name]}),(0,b.jsx)("span",{style:h.profileType,children:a.type})]}),(0,b.jsx)("button",{style:h.deleteProfileBtn,onClick:b=>{b.stopPropagation(),S(a.id,!0)},children:"✖"})]},a.id))]})]})]}),(0,b.jsxs)("div",{style:{...h.section,flex:1,borderTop:"1px solid var(--border)"},children:[(0,b.jsxs)("div",{style:h.sectionHeader,children:[(0,b.jsx)("span",{style:h.sectionTitle,children:"Schema Tables"}),s&&(0,b.jsx)("span",{style:h.spinnerMini})]}),(0,b.jsxs)("div",{style:h.tableList,children:[!i&&(0,b.jsx)("div",{style:h.emptyText,children:"Select an active connection to view tables."}),i&&0===m.length&&!s&&(0,b.jsx)("div",{style:h.emptyText,children:"No tables found in database schema."}),m.map(a=>(0,b.jsxs)("div",{style:h.tableTreeItem,children:[(0,b.jsxs)("div",{style:h.tableRow,onClick:()=>O(a.name),children:[(0,b.jsx)("span",{style:h.tableIcon,children:"view"===a.type?"👁️":"📊"}),(0,b.jsx)("span",{style:h.tableName,children:a.name}),(0,b.jsx)("span",{style:h.tableChevron,children:o===a.name?"▼":"▶"})]}),o===a.name&&q[a.name]&&(0,b.jsx)("div",{style:h.columnList,children:q[a.name].map(a=>(0,b.jsxs)("div",{style:h.columnItem,children:[(0,b.jsx)("span",{style:h.columnIcon,children:a.isPrimaryKey?"🔑":a.isForeignKey?"🔗":"▫"}),(0,b.jsx)("span",{style:h.columnName,title:a.type,children:a.name}),(0,b.jsx)("span",{style:h.columnType,children:a.type.toLowerCase().substring(0,12)})]},a.name))})]},a.name))]})]})]}),(0,b.jsxs)("div",{style:h.mainContent,children:[(0,b.jsxs)("div",{style:h.statusBar,children:[(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[(0,b.jsx)("span",{style:h.statusLabel,children:"Active Connection:"}),U?(0,b.jsxs)("span",{style:h.statusValue,children:[k?"🌐":"📁"," ",U.name," (",U.type,")",U.readOnly&&(0,b.jsx)("span",{style:h.readOnlyBadge,children:"Read-Only"})]}):(0,b.jsx)("span",{style:{...h.statusValue,color:"var(--danger)"},children:"No Connection Selected"})]}),(0,b.jsx)("button",{style:{...h.runBtn,opacity:!i||w?.6:1,cursor:!i||w?"not-allowed":"pointer"},onClick:T,disabled:!i||w,children:w?"⌛ Running...":"⚡ Execute Query (F5)"})]}),(0,b.jsx)("div",{style:h.editorArea,children:(0,b.jsx)("textarea",{style:h.textarea,value:u,onChange:a=>v(a.target.value),placeholder:"Write your SQL query script here...",onKeyDown:a=>{("F5"===a.key||a.ctrlKey&&"Enter"===a.key)&&(a.preventDefault(),T())}})}),(0,b.jsxs)("div",{style:h.resultsArea,children:[y&&(0,b.jsxs)("div",{style:h.errorContainer,children:[(0,b.jsx)("h4",{style:{margin:"0 0 0.5rem 0",color:"var(--danger)"},children:"⚠️ Execution Error"}),(0,b.jsx)("pre",{style:h.errorText,children:y}),y.includes("not installed")&&(0,b.jsxs)("div",{style:h.driverPrompt,children:[(0,b.jsx)("p",{style:{margin:"0 0 0.5rem 0"},children:"To resolve this, run this installer command in your workspace terminal:"}),(0,b.jsx)("code",{style:h.driverCode,children:U?.type==="sqlite"?"npm install better-sqlite3":U?.type==="postgres"?"npm install pg":U?.type==="mysql"?"npm install mysql2":"npm install mssql"})]})]}),A&&(0,b.jsxs)("div",{style:h.resultsWrapper,children:[(0,b.jsxs)("div",{style:h.resultsMeta,children:[(0,b.jsxs)("span",{children:["Query completed."," ",void 0!==A.affectedRows?`Affected rows: ${A.affectedRows}`:`Returned ${A.rows.length} rows`]}),(0,b.jsxs)("span",{children:["Duration: ",A.durationMs,"ms"]})]}),A.rows.length>0?(0,b.jsx)("div",{style:h.tableContainer,children:(0,b.jsxs)("table",{style:h.table,children:[(0,b.jsx)("thead",{children:(0,b.jsx)("tr",{children:A.fields.map(a=>(0,b.jsx)("th",{style:h.th,children:a},a))})}),(0,b.jsx)("tbody",{children:A.rows.map((a,c)=>(0,b.jsx)("tr",{style:c%2==0?h.trEven:h.trOdd,children:A.fields.map(c=>(0,b.jsx)("td",{style:h.td,children:null===a[c]?"NULL":"object"==typeof a[c]?JSON.stringify(a[c]):String(a[c])},c))},c))})]})}):void 0===A.affectedRows&&(0,b.jsx)("div",{style:h.emptyResults,children:"Query executed successfully, but returned 0 results."})]}),!y&&!A&&!w&&(0,b.jsx)("div",{style:h.emptyResults,children:"Write a query script and click Execute to view table records."}),w&&(0,b.jsxs)("div",{style:h.loadingWrapper,children:[(0,b.jsx)("span",{style:h.spinnerLarge}),(0,b.jsx)("span",{style:{color:"var(--muted)"},children:"Running database statement..."})]})]})]}),C&&"u">typeof document&&(0,f.createPortal)((0,b.jsx)("div",{style:h.modalOverlay,children:(0,b.jsxs)("div",{style:h.modalContent,children:[(0,b.jsxs)("h3",{style:{margin:"0 0 1rem 0",display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"🔌 Add Database Profile"}),(0,b.jsx)("span",{style:{cursor:"pointer"},onClick:()=>D(!1),children:"✖"})]}),(0,b.jsxs)("form",{onSubmit:R,children:[(0,b.jsxs)("div",{style:h.formRow,children:[(0,b.jsx)("label",{style:h.label,children:"Profile Name"}),(0,b.jsx)("input",{style:h.input,type:"text",required:!0,value:G.name,onChange:a=>H(b=>({...b,name:a.target.value})),placeholder:"e.g. Local Postgres, Dev SQLite"})]}),(0,b.jsxs)("div",{style:h.formRow,children:[(0,b.jsx)("label",{style:h.label,children:"Scope Level"}),(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"radio",checked:!E,onChange:()=>F(!1)}),"Workspace Local"]}),(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"radio",checked:E,onChange:()=>F(!0)}),"Global User Profile"]})]})]}),(0,b.jsxs)("div",{style:h.formRow,children:[(0,b.jsx)("label",{style:h.label,children:"Database Type"}),(0,b.jsxs)("select",{style:h.select,value:G.type,onChange:a=>{let b=a.target.value,c=5432;"mysql"===b&&(c=3306),"mssql"===b&&(c=1433),H(a=>({...a,type:b,filepath:"sqlite"===b?"./dev.db":void 0,port:"sqlite"!==b?c:void 0,database:"sqlite"===b?void 0:"mssql"===b?"master":"postgres"===b?"postgres":"",username:"sqlite"===b?void 0:"mssql"===b?"sa":"postgres"===b?"postgres":"root"}))},children:[(0,b.jsx)("option",{value:"sqlite",children:"SQLite (Local File)"}),(0,b.jsx)("option",{value:"postgres",children:"PostgreSQL"}),(0,b.jsx)("option",{value:"mysql",children:"MySQL"}),(0,b.jsx)("option",{value:"mssql",children:"Microsoft SQL Server"})]})]}),"sqlite"===G.type?(0,b.jsxs)("div",{style:h.formRow,children:[(0,b.jsx)("label",{style:h.label,children:"Database File Path"}),(0,b.jsx)("input",{style:h.input,type:"text",required:!0,value:G.filepath||"",onChange:a=>H(b=>({...b,filepath:a.target.value})),placeholder:"Relative (e.g. ./data/dev.db) or Absolute path"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,b.jsxs)("div",{style:{...h.formRow,flex:3},children:[(0,b.jsx)("label",{style:h.label,children:"Host IP Address"}),(0,b.jsx)("input",{style:h.input,type:"text",required:!0,value:G.host||"",onChange:a=>H(b=>({...b,host:a.target.value})),placeholder:"localhost or IP"})]}),(0,b.jsxs)("div",{style:{...h.formRow,flex:1},children:[(0,b.jsx)("label",{style:h.label,children:"Port"}),(0,b.jsx)("input",{style:h.input,type:"number",required:!0,value:G.port||0,onChange:a=>H(b=>({...b,port:parseInt(a.target.value)}))})]})]}),(0,b.jsxs)("div",{style:h.formRow,children:[(0,b.jsx)("label",{style:h.label,children:"Database Name"}),(0,b.jsx)("input",{style:h.input,type:"text",required:!0,value:G.database||"",onChange:a=>H(b=>({...b,database:a.target.value}))})]}),(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,b.jsxs)("div",{style:{...h.formRow,flex:1},children:[(0,b.jsx)("label",{style:h.label,children:"Username"}),(0,b.jsx)("input",{style:h.input,type:"text",required:!0,value:G.username||"",onChange:a=>H(b=>({...b,username:a.target.value}))})]}),(0,b.jsxs)("div",{style:{...h.formRow,flex:1},children:[(0,b.jsx)("label",{style:h.label,children:"Password"}),(0,b.jsx)("input",{style:h.input,type:"password",value:G.password||"",onChange:a=>H(b=>({...b,password:a.target.value}))})]})]}),("postgres"===G.type||"mssql"===G.type)&&(0,b.jsx)("div",{style:h.formRow,children:(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"checkbox",checked:!!G.ssl,onChange:a=>H(b=>({...b,ssl:a.target.checked}))}),"Require SSL Secure Connection"]})})]}),(0,b.jsx)("div",{style:h.formRow,children:(0,b.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,b.jsx)("input",{type:"checkbox",checked:!!G.readOnly,onChange:a=>H(b=>({...b,readOnly:a.target.checked}))}),"Enforce Read-Only Connection (Disable mutations)"]})}),K&&(0,b.jsx)("div",{style:{...h.testResult,backgroundColor:K.success?"rgba(16, 185, 129, 0.12)":"rgba(239, 68, 68, 0.12)",border:K.success?"1px solid var(--success)":"1px solid var(--danger)",color:K.success?"var(--success)":"var(--danger)"},children:K.message}),(0,b.jsxs)("div",{style:h.modalFooter,children:[(0,b.jsx)("button",{type:"button",style:h.testBtn,onClick:Q,children:"🔍 Test Connection"}),(0,b.jsxs)("div",{style:{display:"flex",gap:"0.5rem"},children:[(0,b.jsx)("button",{type:"button",style:h.cancelBtn,onClick:()=>D(!1),children:"Cancel"}),(0,b.jsx)("button",{type:"submit",style:h.saveBtn,disabled:I,children:I?"Saving...":"Save Profile"})]})]})]})]})}),document.body)]})}let h={container:{display:"flex",height:"100%",width:"100%",backgroundColor:"#05070a",color:"#cbd5e1",fontSize:"0.875rem",minHeight:0},sidebar:{width:"280px",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",minHeight:0,backgroundColor:"rgba(10, 15, 24, 0.4)",flexShrink:0},section:{display:"flex",flexDirection:"column",padding:"1rem",minHeight:0},sectionHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.75rem"},sectionTitle:{fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",fontSize:"0.75rem",color:"var(--muted)"},addBtn:{padding:"0.2rem 0.5rem",borderRadius:"4px",border:"1px solid var(--primary)",backgroundColor:"transparent",color:"var(--primary)",fontSize:"0.7rem",fontWeight:600,cursor:"pointer"},profileList:{display:"flex",flexDirection:"column",gap:"0.4rem",overflowY:"auto",maxHeight:"220px"},groupHeader:{fontSize:"0.65rem",fontWeight:600,color:"var(--muted)",marginTop:"0.5rem",marginBottom:"0.2rem",letterSpacing:"0.05em"},profileItem:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.5rem 0.6rem",borderRadius:"6px",backgroundColor:"rgba(255, 255, 255, 0.02)",border:"1px solid var(--border)",cursor:"pointer",transition:"all 0.2s ease"},profileItemActive:{backgroundColor:"rgba(109, 40, 217, 0.08)",border:"1px solid var(--border-focus)",boxShadow:"0 0 10px rgba(109, 40, 217, 0.1)"},profileMeta:{display:"flex",flexDirection:"column",gap:"0.15rem",flex:1,minWidth:0},profileName:{fontWeight:600,fontSize:"0.8rem",color:"#fff",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},profileType:{fontSize:"0.7rem",color:"var(--muted)",textTransform:"uppercase"},deleteProfileBtn:{background:"none",border:"none",color:"rgba(239, 68, 68, 0.4)",cursor:"pointer",fontSize:"0.75rem",padding:"0.25rem"},tableList:{display:"flex",flexDirection:"column",gap:"0.25rem",overflowY:"auto",flex:1,minHeight:0},emptyText:{fontSize:"0.75rem",color:"var(--muted)",textAlign:"center",padding:"1rem 0"},tableTreeItem:{display:"flex",flexDirection:"column"},tableRow:{display:"flex",alignItems:"center",padding:"0.35rem 0.5rem",borderRadius:"4px",cursor:"pointer",userSelect:"none",transition:"background 0.2s ease"},tableIcon:{marginRight:"0.4rem",fontSize:"0.9rem"},tableName:{flex:1,fontSize:"0.8rem",color:"#e2e8f0",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},tableChevron:{fontSize:"0.6rem",color:"var(--muted)",marginLeft:"0.25rem"},columnList:{display:"flex",flexDirection:"column",gap:"0.2rem",paddingLeft:"1.5rem",marginTop:"0.15rem",borderLeft:"1px dashed rgba(255,255,255,0.06)",marginLeft:"0.8rem",marginBottom:"0.25rem"},columnItem:{display:"flex",alignItems:"center",padding:"0.15rem 0.25rem",fontSize:"0.75rem"},columnIcon:{marginRight:"0.3rem",fontSize:"0.7rem"},columnName:{flex:1,color:"var(--muted)",overflow:"hidden",textOverflow:"ellipsis"},columnType:{fontSize:"0.65rem",color:"rgba(109, 40, 217, 0.75)",fontFamily:"monospace",paddingLeft:"0.5rem"},mainContent:{flex:1,display:"flex",flexDirection:"column",minHeight:0,backgroundColor:"#05070a"},statusBar:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0.75rem 1rem",borderBottom:"1px solid var(--border)",backgroundColor:"rgba(15, 23, 42, 0.3)",flexShrink:0},statusLabel:{fontSize:"0.75rem",color:"var(--muted)"},statusValue:{fontSize:"0.8rem",fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:"0.4rem"},readOnlyBadge:{padding:"0.1rem 0.4rem",borderRadius:"4px",backgroundColor:"rgba(234, 179, 8, 0.12)",color:"#eab308",fontSize:"0.65rem",fontWeight:700,border:"1px solid rgba(234, 179, 8, 0.2)"},runBtn:{padding:"0.4rem 0.9rem",borderRadius:"6px",border:"none",backgroundColor:"var(--primary)",color:"#fff",fontSize:"0.8rem",fontWeight:600,transition:"all 0.2s ease"},editorArea:{height:"180px",borderBottom:"1px solid var(--border)",position:"relative",flexShrink:0},textarea:{width:"100%",height:"100%",backgroundColor:"#080c14",border:"none",resize:"none",color:"#e2e8f0",fontFamily:"monospace",fontSize:"0.85rem",padding:"1rem",outline:"none",lineHeight:"1.4"},resultsArea:{flex:1,display:"flex",flexDirection:"column",minHeight:0,padding:"1rem"},errorContainer:{padding:"1rem",borderRadius:"8px",backgroundColor:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",overflowY:"auto"},errorText:{margin:0,fontFamily:"monospace",fontSize:"0.8rem",color:"#f87171",whiteSpace:"pre-wrap"},driverPrompt:{marginTop:"1rem",padding:"0.75rem",borderRadius:"6px",backgroundColor:"rgba(0, 0, 0, 0.3)",border:"1px solid var(--border)"},driverCode:{display:"block",padding:"0.5rem",backgroundColor:"#090d16",borderRadius:"4px",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--primary)",border:"1px solid var(--border)"},resultsWrapper:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},resultsMeta:{display:"flex",justifyContent:"space-between",fontSize:"0.75rem",color:"var(--muted)",marginBottom:"0.5rem"},tableContainer:{flex:1,overflow:"auto",border:"1px solid var(--border)",borderRadius:"6px"},table:{width:"100%",borderCollapse:"collapse",fontFamily:"monospace",fontSize:"0.8rem"},th:{padding:"0.5rem 0.75rem",textAlign:"left",backgroundColor:"#0f172a",borderBottom:"1px solid var(--border)",color:"#94a3b8",fontWeight:600,position:"sticky",top:0,zIndex:1},td:{padding:"0.4rem 0.75rem",borderBottom:"1px solid rgba(255, 255, 255, 0.03)",color:"#cbd5e1",whiteSpace:"nowrap"},trEven:{backgroundColor:"transparent"},trOdd:{backgroundColor:"rgba(255, 255, 255, 0.01)"},emptyResults:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--muted)",fontSize:"0.8rem",textAlign:"center"},loadingWrapper:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"1rem"},spinnerLarge:{width:"24px",height:"24px",border:"3px solid rgba(109, 40, 217, 0.15)",borderTop:"3px solid var(--primary)",borderRadius:"50%",animation:"spin 1s linear infinite"},spinnerMini:{width:"12px",height:"12px",border:"2px solid rgba(255, 255, 255, 0.1)",borderTop:"2px solid var(--muted)",borderRadius:"50%",animation:"spin 1s linear infinite"},modalOverlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:999},modalContent:{width:"480px",backgroundColor:"#0d131f",borderRadius:"12px",border:"1px solid var(--border-focus)",padding:"1.5rem",boxShadow:"0 4px 24px rgba(0, 0, 0, 0.5)"},formRow:{display:"flex",flexDirection:"column",gap:"0.35rem",marginBottom:"1rem"},label:{fontSize:"0.75rem",fontWeight:600,color:"var(--muted)"},input:{padding:"0.5rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"#070a12",color:"#fff",outline:"none",fontSize:"0.8rem"},select:{padding:"0.5rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"#070a12",color:"#fff",outline:"none",fontSize:"0.8rem"},testResult:{padding:"0.5rem",borderRadius:"6px",fontSize:"0.75rem",marginBottom:"1rem"},modalFooter:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},testBtn:{padding:"0.4rem 0.75rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"transparent",color:"var(--muted)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"},cancelBtn:{padding:"0.4rem 0.75rem",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--muted)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"},saveBtn:{padding:"0.4rem 0.75rem",borderRadius:"6px",border:"none",backgroundColor:"var(--primary)",color:"#fff",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"}};if("u">typeof document){let a=document.createElement("style");a.innerHTML=`
2
2
  @keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
5
5
  }
6
- `,document.head.appendChild(a)}let h=(0,d.default)(async()=>{},{loadableGenerated:{modules:[37314]},ssr:!1,loading:()=>(0,b.jsx)("div",{style:{height:"400px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#05070a",color:"var(--muted)",border:"1px solid var(--border)",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px"},children:(0,b.jsx)("span",{children:"Initializing terminal emulator..."})})}),i=(0,d.default)(async()=>{},{loadableGenerated:{modules:[1985]},ssr:!1,loading:()=>(0,b.jsx)("div",{style:{height:"280px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--card)",border:"1px solid var(--border)",borderRadius:"12px",marginTop:"1.5rem"},children:(0,b.jsx)("span",{style:{color:"var(--muted)"},children:"Initializing prompt editor..."})})}),j=(0,d.default)(async()=>{},{loadableGenerated:{modules:[99026]},ssr:!1}),k=(0,d.default)(async()=>{},{loadableGenerated:{modules:[9949]},ssr:!1}),l=(0,d.default)(async()=>{},{loadableGenerated:{modules:[20032]},ssr:!1}),m=(0,d.default)(async()=>{},{loadableGenerated:{modules:[97722]},ssr:!1});a.s(["default",0,function(){let[a,d]=(0,c.useState)([]),[g,n]=(0,c.useState)(null),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)(!1),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(!1),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)(""),[C,D]=(0,c.useState)(3001),[E,F]=(0,c.useState)("0.2.19"),[G,H]=(0,c.useState)(null),I=a.filter(a=>"workspace-terminal"!==a.id),J=a.find(a=>a.id===g),K=I.some(a=>("claude-docker"===a.type||"aider-docker"===a.type)&&"running"===a.status),L=I.some(a=>"claude-ssh"===a.type&&"running"===a.status),M=async()=>{try{let a=await fetch("/api/sessions"),b=await a.json();b.sessions&&d(b.sessions),b.wsPort&&D(b.wsPort),b.originalCwd&&B(b.originalCwd),b.version&&F(b.version)}catch(a){console.error("Failed to fetch sessions:",a)}},N=async()=>{try{let a=await fetch("/api/recents");if(a.ok){let b=await a.json();b.success&&b.recents&&b.recents.lastSession&&H(b.recents.lastSession)}}catch(a){console.error("Failed to fetch recents:",a)}};(0,c.useEffect)(()=>{(async()=>{await M(),await N()})(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(a=>console.log("Service Worker registered:",a.scope)).catch(a=>console.error("Service Worker registration failed:",a));let a=setInterval(M,4e3);return()=>clearInterval(a)},[]);let O=async(a,b,c,d)=>{p(!0);try{let e=b;e||("claude"===a?e="Claude Local":"claude-docker"===a?e="Claude Docker":"claude-ssh"===a?e="Claude SSH":"aider"===a?e="Aider Local":"aider-docker"===a?e="Aider Docker":"mock"===a&&(e="Mock Session"));let f={type:a,name:e,workspaceRoot:c,scopedDirs:d};if(("aider"===a||"aider-docker"===a)&&!c)try{let a=await fetch("/api/context/aider");if(a.ok){let b=await a.json();b.success&&b.config&&(f.workspaceRoot=b.config.workspaceRoot,f.scopedDirs=b.config.scopedDirs)}}catch(a){console.error("Failed to load aider configuration before launch:",a)}let g=await fetch("/api/sessions/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),h=await g.json();h.success&&(await M(),n(h.session.id),H({type:a,name:e,workspaceRoot:c,scopedDirs:d}))}catch(a){console.error("Failed to launch session:",a)}finally{p(!1)}},P=async(a,b=!1)=>{try{let c=await fetch("/api/sessions/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a,delete:b})});(await c.json()).success&&(b&&g===a&&n(null),await M())}catch(a){console.error("Failed to stop session:",a)}};return(0,b.jsxs)("div",{className:`${e.default.container} ${J?e.default.containerActive:""}`,children:[(0,b.jsxs)("header",{className:e.default.header,children:[(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"1.5rem"},children:[(0,b.jsx)("img",{src:"/logo.png",alt:"NeuralLoom Logo",style:{width:"160px",height:"160px",borderRadius:"16px",objectFit:"contain"}}),(0,b.jsxs)("div",{className:e.default.logoArea,children:[(0,b.jsx)("h1",{className:e.default.title,style:{margin:0,lineHeight:1.1},children:"NeuralLoom"}),(0,b.jsx)("span",{className:e.default.subtitle,children:"Unified AI Orchestrator & Context Bridge"})]})]}),(0,b.jsxs)("div",{className:e.default.statusIndicator,children:[(0,b.jsx)("span",{className:e.default.pulseDot}),(0,b.jsx)("span",{children:"Orchestrator Online"})]})]}),J?(0,b.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:(0,b.jsx)(m,{sessionId:J.id,workspaceRoot:J.workspaceRoot||"",scopedDirs:J.scopedDirs||[],onClose:()=>n(null),sessions:a,onSwitchSession:a=>n(a),onRefreshSessions:M,wsPort:C})}):(0,b.jsxs)("div",{className:e.default.dashboardGrid,children:[(0,b.jsxs)("main",{className:e.default.mainPanel,children:[(0,b.jsxs)("section",{children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Active AI Agents"}),0===I.length?(0,b.jsxs)("div",{className:"card",style:{padding:"3rem 1.5rem",textAlign:"center"},children:[(0,b.jsx)("p",{style:{color:"var(--muted)",marginBottom:"1.5rem"},children:"No active agent sessions in this workspace. Launch a Claude or Aider agent session to begin."}),(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem",justifyContent:"center",flexWrap:"wrap"},children:[G&&(0,b.jsx)("button",{className:e.default.quickLaunchBtn,onClick:()=>{O(G.type,G.name,G.workspaceRoot,G.scopedDirs)},disabled:o,style:{background:"linear-gradient(135deg, hsl(38, 92%, 50%) 0%, hsl(0, 84%, 60%) 100%)",border:"none",maxWidth:"200px"},title:`Re-launch: ${G.name||G.type}`,children:"⚡ Re-launch Last Session"}),(0,b.jsx)("button",{className:e.default.quickLaunchBtn,onClick:()=>{z(!1),x(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(262, 83%, 60%) 0%, hsl(195, 100%, 45%) 100%)",border:"none",maxWidth:"200px"},children:"Launch Claude PTY"}),(0,b.jsx)("button",{className:e.default.quickLaunchBtn,onClick:()=>{v(!1),t(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(210, 80%, 45%) 0%, hsl(262, 80%, 55%) 100%)",border:"none",maxWidth:"200px"},children:"Launch Aider PTY"})]}),(0,b.jsxs)("div",{style:{marginTop:"1.5rem",fontSize:"0.75rem",color:"var(--muted)"},children:["Want to verify layout features first?"," ",(0,b.jsx)("span",{onClick:()=>O("mock"),style:{color:"var(--primary)",cursor:"pointer",textDecoration:"underline"},children:"Start simulated sandbox session"})]})]}):(0,b.jsx)("div",{className:e.default.agentGrid,children:I.map(a=>(0,b.jsxs)("div",{className:`${e.default.agentCard} card ${g===a.id?e.default.activeBorder:""}`,children:[(0,b.jsxs)("div",{className:e.default.agentHeader,children:[(0,b.jsx)("span",{className:e.default.agentName,children:a.name}),(0,b.jsx)("span",{className:`${e.default.agentBadge} ${"stopped"===a.status?e.default.stoppedBadge:""}`,children:a.status})]}),(0,b.jsxs)("div",{className:e.default.cardBody,children:[(0,b.jsxs)("p",{style:{fontSize:"0.825rem",color:"var(--muted)"},children:["ID: ",(0,b.jsx)("code",{style:{fontSize:"0.75rem"},children:a.id.substring(0,8)}),(0,b.jsx)("br",{}),"Type: ","claude"===a.type?"Claude Local PTY":"claude-docker"===a.type?"Claude Docker PTY":"claude-ssh"===a.type?"Claude SSH PTY":"aider"===a.type?"Aider Local PTY":"aider-docker"===a.type?"Aider Docker PTY":"mock"===a.type?"Simulated Mock PTY":"Unknown PTY",(0,b.jsx)("br",{}),"Logs: ",a.logsCount," captured lines"]}),(0,b.jsxs)("div",{style:{display:"flex",gap:"0.5rem",marginTop:"1rem"},children:["running"===a.status?(0,b.jsx)("button",{onClick:()=>P(a.id,!1),style:{flex:1,padding:"0.4rem 0.6rem",borderRadius:"6px",border:"1px solid var(--danger)",backgroundColor:"transparent",fontSize:"0.75rem",fontWeight:600,color:"var(--danger)"},children:"Stop"}):(0,b.jsx)("button",{onClick:()=>P(a.id,!0),style:{flex:1,padding:"0.4rem 0.6rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"transparent",fontSize:"0.75rem",fontWeight:600,color:"var(--muted)"},children:"Delete"}),(0,b.jsx)("button",{onClick:()=>n(a.id),style:{flex:2,padding:"0.4rem 0.6rem",borderRadius:"6px",border:"none",backgroundColor:g===a.id?"var(--border-focus)":"var(--primary)",fontSize:"0.75rem",fontWeight:600,color:"#fff"},children:g===a.id?"Connected":"Open Session"})]})]})]},a.id))})]}),g&&"workspace-terminal"!==g&&(0,b.jsxs)("section",{className:"card",style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-focus)"},children:[(0,b.jsxs)("div",{className:e.default.agentHeader,style:{justifyContent:"space-between",background:"rgba(109, 40, 217, 0.08)"},children:[(0,b.jsxs)("span",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem"},children:["🖥️ Console Bridge — ",a.find(a=>a.id===g)?.name]}),(0,b.jsxs)("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.find(a=>a.id===g)?.status==="stopped"&&(0,b.jsx)("button",{onClick:async()=>{try{let a=await fetch("/api/sessions/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:g})});if(a.ok)await M();else{let b=await a.json();alert(b.error||"Failed to restart session.")}}catch(a){console.error("Failed to restart session:",a),alert("Network error: failed to restart session.")}},style:{padding:"0.2rem 0.5rem",borderRadius:"4px",border:"1px solid #eab308",backgroundColor:"rgba(234, 179, 8, 0.15)",color:"#eab308",fontSize:"0.7rem",fontWeight:600,cursor:"pointer",boxShadow:"0 0 8px rgba(234, 179, 8, 0.2)"},title:"Restart the stopped session process runner",children:"⚡ Restart Session"}),(0,b.jsx)("button",{onClick:()=>n(null),style:{border:"none",background:"none",color:"var(--muted)",cursor:"pointer",fontSize:"0.75rem"},children:"Close Panel ✖"})]})]}),(0,b.jsx)(h,{sessionId:g,wsPort:C})]}),(0,b.jsxs)("section",{children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Workspace Shell Terminal"}),(0,b.jsxs)("div",{className:"card",style:{display:"flex",flexDirection:"column",border:"1px solid var(--border)",padding:0},children:[(0,b.jsxs)("div",{className:e.default.agentHeader,style:{justifyContent:"space-between",background:"rgba(255, 255, 255, 0.02)"},children:[(0,b.jsxs)("span",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.85rem"},children:["💻 Local Workspace Shell (CWD: ",A||"root",")"]}),(0,b.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--muted)"},children:"Pre-configured environment"})]}),(0,b.jsx)(h,{sessionId:"workspace-terminal",height:"300px",wsPort:C})]})]}),(0,b.jsxs)("section",{style:{marginTop:"2rem"},children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Shared Context Hub & Slash Commands"}),(0,b.jsxs)("div",{className:e.default.contextList,children:[(0,b.jsxs)("div",{className:`${e.default.contextItem} card`,children:[(0,b.jsxs)("div",{className:e.default.contextMeta,children:[(0,b.jsx)("span",{className:e.default.contextTitle,children:"Staged Context & System Rules (/ccc)"}),(0,b.jsx)("span",{className:e.default.contextDetails,children:"Compiles AGENTS.md guidelines and project files folder hierarchy map."})]}),(0,b.jsx)("button",{onClick:async()=>{g&&await fetch("/api/sessions/inject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:g,command:"/ccc"})})},disabled:!g,style:{padding:"0.4rem 0.8rem",borderRadius:"6px",border:"1px solid var(--primary)",backgroundColor:"transparent",color:"var(--primary)",fontSize:"0.75rem",fontWeight:600,opacity:g?1:.5,cursor:g?"pointer":"not-allowed"},children:"🚀 Mount Context (/ccc)"})]}),(0,b.jsxs)("div",{className:`${e.default.contextItem} card`,children:[(0,b.jsxs)("div",{className:e.default.contextMeta,children:[(0,b.jsx)("span",{className:e.default.contextTitle,children:"Staged Developer Prompt (/ccp)"}),(0,b.jsx)("span",{className:e.default.contextDetails,children:"Executes instructions written in .ai/neural-loom/cprompt.md."})]}),(0,b.jsx)("button",{onClick:async()=>{g&&await fetch("/api/sessions/inject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:g,command:"/ccp"})})},disabled:!g,style:{padding:"0.4rem 0.8rem",borderRadius:"6px",border:"1px solid var(--success)",backgroundColor:"transparent",color:"var(--success)",fontSize:"0.75rem",fontWeight:600,opacity:g?1:.5,cursor:g?"pointer":"not-allowed"},children:"⚡ Trigger Prompt (/ccp)"})]})]}),(0,b.jsx)(i,{})]}),(0,b.jsxs)("section",{style:{marginTop:"2rem"},children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Built-in Database Explorer & SQL Client"}),(0,b.jsx)("div",{className:"card",style:{padding:0,overflow:"hidden",height:"480px",border:"1px solid var(--border)"},children:(0,b.jsx)(f,{workspaceRoot:A||""})})]})]}),(0,b.jsxs)("aside",{className:e.default.sidePanel,children:[(0,b.jsxs)("section",{children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Execution Environments"}),(0,b.jsxs)("div",{className:e.default.envGrid,children:[(0,b.jsxs)("div",{className:e.default.envRow,children:[(0,b.jsx)("span",{className:e.default.envName,children:"💻 Local host OS"}),(0,b.jsx)("span",{className:e.default.envStatus,style:{color:"var(--success)"},children:"Active"})]}),(0,b.jsxs)("div",{className:e.default.envRow,style:{opacity:K?1:.6},children:[(0,b.jsx)("span",{className:e.default.envName,children:"🐳 Docker Sandbox"}),(0,b.jsx)("span",{className:e.default.envStatus,style:{color:K?"var(--success)":"var(--muted)"},children:K?"Active":"Not Mounted"})]}),(0,b.jsxs)("div",{className:e.default.envRow,style:{opacity:L?1:.6},children:[(0,b.jsx)("span",{className:e.default.envName,children:"🌐 Remote VM (SSH)"}),(0,b.jsx)("span",{className:e.default.envStatus,style:{color:L?"var(--success)":"var(--muted)"},children:L?"Active":"Disconnected"})]})]})]}),(0,b.jsxs)("section",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{z(!1),x(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(262, 83%, 60%) 0%, hsl(195, 100%, 45%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🤖"}),(0,b.jsx)("span",{children:"Launch Claude PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{z(!0),x(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(170, 72%, 40%) 0%, hsl(195, 100%, 40%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🐳"}),(0,b.jsx)("span",{children:"Launch Docker PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>r(!0),disabled:o,style:{background:"linear-gradient(135deg, hsl(38, 92%, 50%) 0%, hsl(0, 84%, 60%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🌐"}),(0,b.jsx)("span",{children:"Launch SSH PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{v(!1),t(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(210, 80%, 45%) 0%, hsl(262, 80%, 55%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🐍"}),(0,b.jsx)("span",{children:"Launch Aider PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{v(!0),t(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(195, 100%, 40%) 0%, hsl(262, 80%, 55%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🐳"}),(0,b.jsx)("span",{children:"Launch Aider Docker"})]})]}),(0,b.jsxs)("section",{className:"card",style:{padding:"1.5rem",display:"flex",flexDirection:"column",gap:"0.75rem"},children:[(0,b.jsx)("h3",{style:{fontSize:"1rem",fontWeight:700},children:"Quick Actions"}),(0,b.jsxs)("ul",{style:{listStyle:"none",fontSize:"0.875rem",display:"flex",flexDirection:"column",gap:"0.5rem",color:"var(--muted)"},children:[(0,b.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"Configure global API Keys"}),(0,b.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]}),(0,b.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"Edit rules templates"}),(0,b.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]}),(0,b.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"Inspect process locks"}),(0,b.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]})]}),(0,b.jsxs)("div",{style:{marginTop:"1.2rem",textAlign:"center",fontSize:"0.72rem",color:"var(--muted)"},children:["Need to troubleshoot?"," ",(0,b.jsx)("span",{onClick:()=>O("mock"),style:{color:"var(--primary)",cursor:"pointer",textDecoration:"underline"},children:"Launch simulated playground sandbox"})]})]})]})]}),(0,b.jsxs)("footer",{className:e.default.footer,children:[(0,b.jsxs)("span",{children:["NeuralLoom v",E," — Experimental AI Orchestrator Bridge"]}),(0,b.jsxs)("span",{children:["Directory: ",A||"Loading..."]})]}),q&&(0,b.jsx)(j,{onClose:()=>r(!1),onConfirmLaunch:()=>{r(!1),O("claude-ssh")}}),s&&(0,b.jsx)(k,{onClose:()=>t(!1),isDocker:u,onConfirmLaunch:()=>{t(!1),O(u?"aider-docker":"aider")}}),w&&(0,b.jsx)(l,{onClose:()=>x(!1),isDocker:y,onConfirmLaunch:(a,b,c)=>{x(!1),O(y?"claude-docker":"claude",a,b,c)}})]})}],40777)}];
6
+ `,document.head.appendChild(a)}let i=(0,d.default)(async()=>{},{loadableGenerated:{modules:[37314]},ssr:!1,loading:()=>(0,b.jsx)("div",{style:{height:"400px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#05070a",color:"var(--muted)",border:"1px solid var(--border)",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px"},children:(0,b.jsx)("span",{children:"Initializing terminal emulator..."})})}),j=(0,d.default)(async()=>{},{loadableGenerated:{modules:[1985]},ssr:!1,loading:()=>(0,b.jsx)("div",{style:{height:"280px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--card)",border:"1px solid var(--border)",borderRadius:"12px",marginTop:"1.5rem"},children:(0,b.jsx)("span",{style:{color:"var(--muted)"},children:"Initializing prompt editor..."})})}),k=(0,d.default)(async()=>{},{loadableGenerated:{modules:[99026]},ssr:!1}),l=(0,d.default)(async()=>{},{loadableGenerated:{modules:[9949]},ssr:!1}),m=(0,d.default)(async()=>{},{loadableGenerated:{modules:[20032]},ssr:!1}),n=(0,d.default)(async()=>{},{loadableGenerated:{modules:[97722]},ssr:!1});a.s(["default",0,function(){let[a,d]=(0,c.useState)([]),[f,h]=(0,c.useState)(null),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)(!1),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(!1),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)(""),[C,D]=(0,c.useState)(3001),[E,F]=(0,c.useState)("0.2.19"),[G,H]=(0,c.useState)(null),I=a.filter(a=>"workspace-terminal"!==a.id),J=a.find(a=>a.id===f),K=I.some(a=>("claude-docker"===a.type||"aider-docker"===a.type)&&"running"===a.status),L=I.some(a=>"claude-ssh"===a.type&&"running"===a.status),M=async()=>{try{let a=await fetch("/api/sessions"),b=await a.json();b.sessions&&d(b.sessions),b.wsPort&&D(b.wsPort),b.originalCwd&&B(b.originalCwd),b.version&&F(b.version)}catch(a){console.error("Failed to fetch sessions:",a)}},N=async()=>{try{let a=await fetch("/api/recents");if(a.ok){let b=await a.json();b.success&&b.recents&&b.recents.lastSession&&H(b.recents.lastSession)}}catch(a){console.error("Failed to fetch recents:",a)}};(0,c.useEffect)(()=>{(async()=>{await M(),await N()})(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(a=>console.log("Service Worker registered:",a.scope)).catch(a=>console.error("Service Worker registration failed:",a));let a=setInterval(M,4e3);return()=>clearInterval(a)},[]);let O=async(a,b,c,d)=>{p(!0);try{let e=b;e||("claude"===a?e="Claude Local":"claude-docker"===a?e="Claude Docker":"claude-ssh"===a?e="Claude SSH":"aider"===a?e="Aider Local":"aider-docker"===a?e="Aider Docker":"mock"===a&&(e="Mock Session"));let f={type:a,name:e,workspaceRoot:c,scopedDirs:d};if(("aider"===a||"aider-docker"===a)&&!c)try{let a=await fetch("/api/context/aider");if(a.ok){let b=await a.json();b.success&&b.config&&(f.workspaceRoot=b.config.workspaceRoot,f.scopedDirs=b.config.scopedDirs)}}catch(a){console.error("Failed to load aider configuration before launch:",a)}let g=await fetch("/api/sessions/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),i=await g.json();i.success&&(await M(),h(i.session.id),H({type:a,name:e,workspaceRoot:c,scopedDirs:d}))}catch(a){console.error("Failed to launch session:",a)}finally{p(!1)}},P=async(a,b=!1)=>{try{let c=await fetch("/api/sessions/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a,delete:b})});(await c.json()).success&&(b&&f===a&&h(null),await M())}catch(a){console.error("Failed to stop session:",a)}};return(0,b.jsxs)("div",{className:`${e.default.container} ${J?e.default.containerActive:""}`,children:[(0,b.jsxs)("header",{className:e.default.header,children:[(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"1.5rem"},children:[(0,b.jsx)("img",{src:"/logo.png",alt:"NeuralLoom Logo",style:{width:"160px",height:"160px",borderRadius:"16px",objectFit:"contain"}}),(0,b.jsxs)("div",{className:e.default.logoArea,children:[(0,b.jsx)("h1",{className:e.default.title,style:{margin:0,lineHeight:1.1},children:"NeuralLoom"}),(0,b.jsx)("span",{className:e.default.subtitle,children:"Unified AI Orchestrator & Context Bridge"})]})]}),(0,b.jsxs)("div",{className:e.default.statusIndicator,children:[(0,b.jsx)("span",{className:e.default.pulseDot}),(0,b.jsx)("span",{children:"Orchestrator Online"})]})]}),J?(0,b.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:(0,b.jsx)(n,{sessionId:J.id,workspaceRoot:J.workspaceRoot||"",scopedDirs:J.scopedDirs||[],onClose:()=>h(null),sessions:a,onSwitchSession:a=>h(a),onRefreshSessions:M,wsPort:C})}):(0,b.jsxs)("div",{className:e.default.dashboardGrid,children:[(0,b.jsxs)("main",{className:e.default.mainPanel,children:[(0,b.jsxs)("section",{children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Active AI Agents"}),0===I.length?(0,b.jsxs)("div",{className:"card",style:{padding:"3rem 1.5rem",textAlign:"center"},children:[(0,b.jsx)("p",{style:{color:"var(--muted)",marginBottom:"1.5rem"},children:"No active agent sessions in this workspace. Launch a Claude or Aider agent session to begin."}),(0,b.jsxs)("div",{style:{display:"flex",gap:"1rem",justifyContent:"center",flexWrap:"wrap"},children:[G&&(0,b.jsx)("button",{className:e.default.quickLaunchBtn,onClick:()=>{O(G.type,G.name,G.workspaceRoot,G.scopedDirs)},disabled:o,style:{background:"linear-gradient(135deg, hsl(38, 92%, 50%) 0%, hsl(0, 84%, 60%) 100%)",border:"none",maxWidth:"200px"},title:`Re-launch: ${G.name||G.type}`,children:"⚡ Re-launch Last Session"}),(0,b.jsx)("button",{className:e.default.quickLaunchBtn,onClick:()=>{z(!1),x(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(262, 83%, 60%) 0%, hsl(195, 100%, 45%) 100%)",border:"none",maxWidth:"200px"},children:"Launch Claude PTY"}),(0,b.jsx)("button",{className:e.default.quickLaunchBtn,onClick:()=>{v(!1),t(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(210, 80%, 45%) 0%, hsl(262, 80%, 55%) 100%)",border:"none",maxWidth:"200px"},children:"Launch Aider PTY"})]}),(0,b.jsxs)("div",{style:{marginTop:"1.5rem",fontSize:"0.75rem",color:"var(--muted)"},children:["Want to verify layout features first?"," ",(0,b.jsx)("span",{onClick:()=>O("mock"),style:{color:"var(--primary)",cursor:"pointer",textDecoration:"underline"},children:"Start simulated sandbox session"})]})]}):(0,b.jsx)("div",{className:e.default.agentGrid,children:I.map(a=>(0,b.jsxs)("div",{className:`${e.default.agentCard} card ${f===a.id?e.default.activeBorder:""}`,children:[(0,b.jsxs)("div",{className:e.default.agentHeader,children:[(0,b.jsx)("span",{className:e.default.agentName,children:a.name}),(0,b.jsx)("span",{className:`${e.default.agentBadge} ${"stopped"===a.status?e.default.stoppedBadge:""}`,children:a.status})]}),(0,b.jsxs)("div",{className:e.default.cardBody,children:[(0,b.jsxs)("p",{style:{fontSize:"0.825rem",color:"var(--muted)"},children:["ID: ",(0,b.jsx)("code",{style:{fontSize:"0.75rem"},children:a.id.substring(0,8)}),(0,b.jsx)("br",{}),"Type: ","claude"===a.type?"Claude Local PTY":"claude-docker"===a.type?"Claude Docker PTY":"claude-ssh"===a.type?"Claude SSH PTY":"aider"===a.type?"Aider Local PTY":"aider-docker"===a.type?"Aider Docker PTY":"mock"===a.type?"Simulated Mock PTY":"Unknown PTY",(0,b.jsx)("br",{}),"Logs: ",a.logsCount," captured lines"]}),(0,b.jsxs)("div",{style:{display:"flex",gap:"0.5rem",marginTop:"1rem"},children:["running"===a.status?(0,b.jsx)("button",{onClick:()=>P(a.id,!1),style:{flex:1,padding:"0.4rem 0.6rem",borderRadius:"6px",border:"1px solid var(--danger)",backgroundColor:"transparent",fontSize:"0.75rem",fontWeight:600,color:"var(--danger)"},children:"Stop"}):(0,b.jsx)("button",{onClick:()=>P(a.id,!0),style:{flex:1,padding:"0.4rem 0.6rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"transparent",fontSize:"0.75rem",fontWeight:600,color:"var(--muted)"},children:"Delete"}),(0,b.jsx)("button",{onClick:()=>h(a.id),style:{flex:2,padding:"0.4rem 0.6rem",borderRadius:"6px",border:"none",backgroundColor:f===a.id?"var(--border-focus)":"var(--primary)",fontSize:"0.75rem",fontWeight:600,color:"#fff"},children:f===a.id?"Connected":"Open Session"})]})]})]},a.id))})]}),f&&"workspace-terminal"!==f&&(0,b.jsxs)("section",{className:"card",style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-focus)"},children:[(0,b.jsxs)("div",{className:e.default.agentHeader,style:{justifyContent:"space-between",background:"rgba(109, 40, 217, 0.08)"},children:[(0,b.jsxs)("span",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem"},children:["🖥️ Console Bridge — ",a.find(a=>a.id===f)?.name]}),(0,b.jsxs)("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.find(a=>a.id===f)?.status==="stopped"&&(0,b.jsx)("button",{onClick:async()=>{try{let a=await fetch("/api/sessions/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:f})});if(a.ok)await M();else{let b=await a.json();alert(b.error||"Failed to restart session.")}}catch(a){console.error("Failed to restart session:",a),alert("Network error: failed to restart session.")}},style:{padding:"0.2rem 0.5rem",borderRadius:"4px",border:"1px solid #eab308",backgroundColor:"rgba(234, 179, 8, 0.15)",color:"#eab308",fontSize:"0.7rem",fontWeight:600,cursor:"pointer",boxShadow:"0 0 8px rgba(234, 179, 8, 0.2)"},title:"Restart the stopped session process runner",children:"⚡ Restart Session"}),(0,b.jsx)("button",{onClick:()=>h(null),style:{border:"none",background:"none",color:"var(--muted)",cursor:"pointer",fontSize:"0.75rem"},children:"Close Panel ✖"})]})]}),(0,b.jsx)(i,{sessionId:f,wsPort:C})]}),(0,b.jsxs)("section",{children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Workspace Shell Terminal"}),(0,b.jsxs)("div",{className:"card",style:{display:"flex",flexDirection:"column",border:"1px solid var(--border)",padding:0},children:[(0,b.jsxs)("div",{className:e.default.agentHeader,style:{justifyContent:"space-between",background:"rgba(255, 255, 255, 0.02)"},children:[(0,b.jsxs)("span",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.85rem"},children:["💻 Local Workspace Shell (CWD: ",A||"root",")"]}),(0,b.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--muted)"},children:"Pre-configured environment"})]}),(0,b.jsx)(i,{sessionId:"workspace-terminal",height:"300px",wsPort:C})]})]}),(0,b.jsxs)("section",{style:{marginTop:"2rem"},children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Shared Context Hub & Slash Commands"}),(0,b.jsxs)("div",{className:e.default.contextList,children:[(0,b.jsxs)("div",{className:`${e.default.contextItem} card`,children:[(0,b.jsxs)("div",{className:e.default.contextMeta,children:[(0,b.jsx)("span",{className:e.default.contextTitle,children:"Staged Context & System Rules (/ccc)"}),(0,b.jsx)("span",{className:e.default.contextDetails,children:"Compiles AGENTS.md guidelines and project files folder hierarchy map."})]}),(0,b.jsx)("button",{onClick:async()=>{f&&await fetch("/api/sessions/inject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:f,command:"/ccc"})})},disabled:!f,style:{padding:"0.4rem 0.8rem",borderRadius:"6px",border:"1px solid var(--primary)",backgroundColor:"transparent",color:"var(--primary)",fontSize:"0.75rem",fontWeight:600,opacity:f?1:.5,cursor:f?"pointer":"not-allowed"},children:"🚀 Mount Context (/ccc)"})]}),(0,b.jsxs)("div",{className:`${e.default.contextItem} card`,children:[(0,b.jsxs)("div",{className:e.default.contextMeta,children:[(0,b.jsx)("span",{className:e.default.contextTitle,children:"Staged Developer Prompt (/ccp)"}),(0,b.jsx)("span",{className:e.default.contextDetails,children:"Executes instructions written in .ai/neural-loom/cprompt.md."})]}),(0,b.jsx)("button",{onClick:async()=>{f&&await fetch("/api/sessions/inject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:f,command:"/ccp"})})},disabled:!f,style:{padding:"0.4rem 0.8rem",borderRadius:"6px",border:"1px solid var(--success)",backgroundColor:"transparent",color:"var(--success)",fontSize:"0.75rem",fontWeight:600,opacity:f?1:.5,cursor:f?"pointer":"not-allowed"},children:"⚡ Trigger Prompt (/ccp)"})]})]}),(0,b.jsx)(j,{})]}),(0,b.jsxs)("section",{style:{marginTop:"2rem"},children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Built-in Database Explorer & SQL Client"}),(0,b.jsx)("div",{className:"card",style:{padding:0,overflow:"hidden",height:"480px",border:"1px solid var(--border)"},children:(0,b.jsx)(g,{workspaceRoot:A||""})})]})]}),(0,b.jsxs)("aside",{className:e.default.sidePanel,children:[(0,b.jsxs)("section",{children:[(0,b.jsx)("h2",{className:e.default.sectionTitle,children:"Execution Environments"}),(0,b.jsxs)("div",{className:e.default.envGrid,children:[(0,b.jsxs)("div",{className:e.default.envRow,children:[(0,b.jsx)("span",{className:e.default.envName,children:"💻 Local host OS"}),(0,b.jsx)("span",{className:e.default.envStatus,style:{color:"var(--success)"},children:"Active"})]}),(0,b.jsxs)("div",{className:e.default.envRow,style:{opacity:K?1:.6},children:[(0,b.jsx)("span",{className:e.default.envName,children:"🐳 Docker Sandbox"}),(0,b.jsx)("span",{className:e.default.envStatus,style:{color:K?"var(--success)":"var(--muted)"},children:K?"Active":"Not Mounted"})]}),(0,b.jsxs)("div",{className:e.default.envRow,style:{opacity:L?1:.6},children:[(0,b.jsx)("span",{className:e.default.envName,children:"🌐 Remote VM (SSH)"}),(0,b.jsx)("span",{className:e.default.envStatus,style:{color:L?"var(--success)":"var(--muted)"},children:L?"Active":"Disconnected"})]})]})]}),(0,b.jsxs)("section",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{z(!1),x(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(262, 83%, 60%) 0%, hsl(195, 100%, 45%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🤖"}),(0,b.jsx)("span",{children:"Launch Claude PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{z(!0),x(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(170, 72%, 40%) 0%, hsl(195, 100%, 40%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🐳"}),(0,b.jsx)("span",{children:"Launch Docker PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>r(!0),disabled:o,style:{background:"linear-gradient(135deg, hsl(38, 92%, 50%) 0%, hsl(0, 84%, 60%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🌐"}),(0,b.jsx)("span",{children:"Launch SSH PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{v(!1),t(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(210, 80%, 45%) 0%, hsl(262, 80%, 55%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🐍"}),(0,b.jsx)("span",{children:"Launch Aider PTY"})]}),(0,b.jsxs)("button",{className:e.default.quickLaunchBtn,onClick:()=>{v(!0),t(!0)},disabled:o,style:{background:"linear-gradient(135deg, hsl(195, 100%, 40%) 0%, hsl(262, 80%, 55%) 100%)",border:"none"},children:[(0,b.jsx)("span",{children:"🐳"}),(0,b.jsx)("span",{children:"Launch Aider Docker"})]})]}),(0,b.jsxs)("section",{className:"card",style:{padding:"1.5rem",display:"flex",flexDirection:"column",gap:"0.75rem"},children:[(0,b.jsx)("h3",{style:{fontSize:"1rem",fontWeight:700},children:"Quick Actions"}),(0,b.jsxs)("ul",{style:{listStyle:"none",fontSize:"0.875rem",display:"flex",flexDirection:"column",gap:"0.5rem",color:"var(--muted)"},children:[(0,b.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"Configure global API Keys"}),(0,b.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]}),(0,b.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"Edit rules templates"}),(0,b.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]}),(0,b.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,b.jsx)("span",{children:"Inspect process locks"}),(0,b.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]})]}),(0,b.jsxs)("div",{style:{marginTop:"1.2rem",textAlign:"center",fontSize:"0.72rem",color:"var(--muted)"},children:["Need to troubleshoot?"," ",(0,b.jsx)("span",{onClick:()=>O("mock"),style:{color:"var(--primary)",cursor:"pointer",textDecoration:"underline"},children:"Launch simulated playground sandbox"})]})]})]})]}),(0,b.jsxs)("footer",{className:e.default.footer,children:[(0,b.jsxs)("span",{children:["NeuralLoom v",E," — Experimental AI Orchestrator Bridge"]}),(0,b.jsxs)("span",{children:["Directory: ",A||"Loading..."]})]}),q&&(0,b.jsx)(k,{onClose:()=>r(!1),onConfirmLaunch:()=>{r(!1),O("claude-ssh")}}),s&&(0,b.jsx)(l,{onClose:()=>t(!1),isDocker:u,onConfirmLaunch:()=>{t(!1),O(u?"aider-docker":"aider")}}),w&&(0,b.jsx)(m,{onClose:()=>x(!1),isDocker:y,onConfirmLaunch:(a,b,c)=>{x(!1),O(y?"claude-docker":"claude",a,b,c)}})]})}],40777)}];
7
7
 
8
8
  //# sourceMappingURL=_0t7oqy6._.js.map