neural-loom 0.2.50 → 0.2.52

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 (77) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  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 +2 -2
  7. package/.next/fallback-build-manifest.json +3 -3
  8. package/.next/prerender-manifest.json +3 -3
  9. package/.next/server/app/_global-error.html +1 -1
  10. package/.next/server/app/_global-error.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/_not-found.html +1 -1
  17. package/.next/server/app/_not-found.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  24. package/.next/server/app/api/context/aider/route.js.nft.json +1 -1
  25. package/.next/server/app/api/context/claude/route.js.nft.json +1 -1
  26. package/.next/server/app/api/context/route.js.nft.json +1 -1
  27. package/.next/server/app/api/context/ssh/route.js.nft.json +1 -1
  28. package/.next/server/app/api/recents/route.js.nft.json +1 -1
  29. package/.next/server/app/api/sessions/inject/route.js.nft.json +1 -1
  30. package/.next/server/app/api/sessions/input/route.js.nft.json +1 -1
  31. package/.next/server/app/api/sessions/launch/route.js.nft.json +1 -1
  32. package/.next/server/app/api/sessions/route.js.nft.json +1 -1
  33. package/.next/server/app/api/sessions/scope/route.js.nft.json +1 -1
  34. package/.next/server/app/api/sessions/start/route.js.nft.json +1 -1
  35. package/.next/server/app/api/sessions/stats/route.js.nft.json +1 -1
  36. package/.next/server/app/api/sessions/stop/route.js.nft.json +1 -1
  37. package/.next/server/app/api/sql/connections/route.js.nft.json +1 -1
  38. package/.next/server/app/api/sql/mcp/route.js.nft.json +1 -1
  39. package/.next/server/app/api/sql/query/route.js.nft.json +1 -1
  40. package/.next/server/app/api/sql/schema/route.js.nft.json +1 -1
  41. package/.next/server/app/index.html +1 -1
  42. package/.next/server/app/index.rsc +2 -2
  43. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  44. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  45. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  46. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  47. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  48. package/.next/server/app/page_client-reference-manifest.js +1 -1
  49. package/.next/server/chunks/[root-of-the-server]__0.ptwor._.js +49 -9
  50. package/.next/server/chunks/[root-of-the-server]__0.ptwor._.js.map +1 -1
  51. package/.next/server/chunks/[root-of-the-server]__00l5btc._.js +49 -9
  52. package/.next/server/chunks/[root-of-the-server]__00l5btc._.js.map +1 -1
  53. package/.next/server/chunks/[root-of-the-server]__06men8g._.js +41 -1
  54. package/.next/server/chunks/[root-of-the-server]__06men8g._.js.map +1 -1
  55. package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js.map +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__0co.g5k._.js +41 -1
  58. package/.next/server/chunks/[root-of-the-server]__0co.g5k._.js.map +1 -1
  59. package/.next/server/chunks/ssr/_0t7oqy6._.js +1 -1
  60. package/.next/server/chunks/ssr/_0t7oqy6._.js.map +1 -1
  61. package/.next/server/middleware-build-manifest.js +3 -3
  62. package/.next/server/pages/404.html +1 -1
  63. package/.next/server/pages/500.html +1 -1
  64. package/.next/server/server-reference-manifest.js +1 -1
  65. package/.next/server/server-reference-manifest.json +1 -1
  66. package/.next/static/chunks/0bb9anc7wd3_e.js +6 -0
  67. package/.next/trace +1 -1
  68. package/.next/trace-build +1 -1
  69. package/package.json +1 -1
  70. package/src/app/components/DbExplorer.tsx +28 -13
  71. package/src/lib/sql/ConnectionManager.ts +45 -1
  72. package/src/lib/sql/McpServer.ts +40 -14
  73. package/src/lib/sql/adapters/MssqlAdapter.ts +151 -0
  74. package/.next/static/chunks/01mol-lwap~v1.js +0 -6
  75. /package/.next/static/{df_RTMKU1wNmlZ4ehP9yW → nL6vq7onX8i2nzr-zxraV}/_buildManifest.js +0 -0
  76. /package/.next/static/{df_RTMKU1wNmlZ4ehP9yW → nL6vq7onX8i2nzr-zxraV}/_clientMiddlewareManifest.js +0 -0
  77. /package/.next/static/{df_RTMKU1wNmlZ4ehP9yW → nL6vq7onX8i2nzr-zxraV}/_ssgManifest.js +0 -0
@@ -77,8 +77,13 @@ export class McpServer {
77
77
  },
78
78
  {
79
79
  name: "sql_list_tables",
80
- description: "Lists all tables and views in the currently active database.",
81
- inputSchema: { type: "object", properties: {} }
80
+ description: "Lists all tables and views in the database connection.",
81
+ inputSchema: {
82
+ type: "object",
83
+ properties: {
84
+ connection: { type: "string", description: "Optional connection profile ID or Name. Defaults to active database." }
85
+ }
86
+ }
82
87
  },
83
88
  {
84
89
  name: "sql_describe_table",
@@ -86,7 +91,8 @@ export class McpServer {
86
91
  inputSchema: {
87
92
  type: "object",
88
93
  properties: {
89
- table: { type: "string", description: "The name of the table to describe." }
94
+ table: { type: "string", description: "The name of the table to describe." },
95
+ connection: { type: "string", description: "Optional connection profile ID or Name. Defaults to active database." }
90
96
  },
91
97
  required: ["table"]
92
98
  }
@@ -94,15 +100,21 @@ export class McpServer {
94
100
  {
95
101
  name: "sql_get_schema_summary",
96
102
  description: "Returns a complete Markdown representation of the database schema, detailing all tables, columns, constraints, and relationships.",
97
- inputSchema: { type: "object", properties: {} }
103
+ inputSchema: {
104
+ type: "object",
105
+ properties: {
106
+ connection: { type: "string", description: "Optional connection profile ID or Name. Defaults to active database." }
107
+ }
108
+ }
98
109
  },
99
110
  {
100
111
  name: "sql_query",
101
- description: "Executes a SQL query on the active database connection. Select queries return matching rows; modifying queries return affected row count. If readOnly is set on the connection, modifying statements will fail.",
112
+ description: "Executes a SQL query on the database connection. Select queries return matching rows; modifying queries return affected row count. If readOnly is set on the connection, modifying statements will fail.",
102
113
  inputSchema: {
103
114
  type: "object",
104
115
  properties: {
105
- sql: { type: "string", description: "The SQL statement to execute." }
116
+ sql: { type: "string", description: "The SQL statement to execute." },
117
+ connection: { type: "string", description: "Optional connection profile ID or Name. Defaults to active database." }
106
118
  },
107
119
  required: ["sql"]
108
120
  }
@@ -152,14 +164,28 @@ export class McpServer {
152
164
  return;
153
165
  }
154
166
 
155
- const active = await ConnectionManager.getActiveAdapter(this.workspaceRoot);
156
- if (!active) {
157
- this.sendToolResult(
158
- id,
159
- "Error: No active database connection is selected. Please configure and activate a database connection in the NeuralLoom workspace dashboard UI.",
160
- true
161
- );
162
- return;
167
+ let active;
168
+ const connectionRef = args.connection;
169
+ if (connectionRef) {
170
+ active = await ConnectionManager.getAdapterById(connectionRef, this.workspaceRoot);
171
+ if (!active) {
172
+ this.sendToolResult(
173
+ id,
174
+ `Error: Connection profile "${connectionRef}" was not found. Configure it in the NeuralLoom workspace dashboard UI.`,
175
+ true
176
+ );
177
+ return;
178
+ }
179
+ } else {
180
+ active = await ConnectionManager.getActiveAdapter(this.workspaceRoot);
181
+ if (!active) {
182
+ this.sendToolResult(
183
+ id,
184
+ "Error: No active database connection is selected. Please configure and activate a database connection in the NeuralLoom workspace dashboard UI.",
185
+ true
186
+ );
187
+ return;
188
+ }
163
189
  }
164
190
 
165
191
  const { adapter, profile } = active;
@@ -0,0 +1,151 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
2
+ import { DbAdapter, TableSchema, ColumnSchema, QueryResult } from "../DbAdapter";
3
+
4
+ export class MssqlAdapter extends DbAdapter {
5
+ private pool: any = null;
6
+ private schema: string = "dbo";
7
+
8
+ constructor(config: any) {
9
+ super(config);
10
+ this.schema = config.schema || "dbo";
11
+ }
12
+
13
+ async connect(): Promise<void> {
14
+ if (this.pool) return;
15
+
16
+ try {
17
+ let mssql;
18
+ try {
19
+ mssql = require("mssql");
20
+ } catch (err) {
21
+ throw new Error(
22
+ "Microsoft SQL Server driver 'mssql' is not installed. Please run `npm install mssql` in the neural-loom environment."
23
+ );
24
+ }
25
+
26
+ this.pool = await mssql.connect({
27
+ server: this.config.host || "localhost",
28
+ port: this.config.port || 1433,
29
+ database: this.config.database,
30
+ user: this.config.username,
31
+ password: this.config.password,
32
+ options: {
33
+ encrypt: this.config.ssl || false,
34
+ trustServerCertificate: true
35
+ }
36
+ });
37
+ } catch (err: any) {
38
+ console.error("[MssqlAdapter] Connect failed:", err);
39
+ this.pool = null;
40
+ throw err;
41
+ }
42
+ }
43
+
44
+ async query(sql: string, params: any[] = []): Promise<QueryResult> {
45
+ await this.connect();
46
+ try {
47
+ const request = this.pool.request();
48
+
49
+ if (params.length > 0) {
50
+ request.input("schema", params[0]);
51
+ if (params.length > 1) {
52
+ request.input("table", params[1]);
53
+ }
54
+ }
55
+
56
+ const res = await request.query(sql);
57
+ const rows = res.recordset || [];
58
+ const fields = res.recordset && res.recordset.columns
59
+ ? Object.keys(res.recordset.columns)
60
+ : (rows.length > 0 ? Object.keys(rows[0]) : []);
61
+
62
+ return {
63
+ rows,
64
+ fields,
65
+ affectedRows: res.rowsAffected ? res.rowsAffected[0] : undefined
66
+ };
67
+ } catch (err: any) {
68
+ console.error("[MssqlAdapter] Query failed:", err);
69
+ throw err;
70
+ }
71
+ }
72
+
73
+ async listTables(): Promise<TableSchema[]> {
74
+ const sql = `
75
+ SELECT table_name as name, table_type as type
76
+ FROM information_schema.tables
77
+ WHERE table_schema = @schema AND table_type IN ('BASE TABLE', 'VIEW')
78
+ ORDER BY table_name
79
+ `;
80
+ const res = await this.query(sql, [this.schema]);
81
+ return res.rows.map(row => ({
82
+ name: row.name,
83
+ type: row.type === "BASE TABLE" ? "table" : "view"
84
+ }));
85
+ }
86
+
87
+ async describeTable(tableName: string): Promise<ColumnSchema[]> {
88
+ const columnsSql = `
89
+ SELECT
90
+ c.column_name as name,
91
+ c.data_type as type,
92
+ c.is_nullable as nullable,
93
+ c.column_default as default_value,
94
+ (
95
+ SELECT COUNT(*)
96
+ FROM information_schema.table_constraints tc
97
+ JOIN information_schema.key_column_usage kcu
98
+ ON tc.constraint_name = kcu.constraint_name
99
+ AND tc.table_schema = kcu.table_schema
100
+ WHERE tc.constraint_type = 'PRIMARY KEY'
101
+ AND tc.table_name = c.table_name
102
+ AND kcu.column_name = c.column_name
103
+ AND tc.table_schema = c.table_schema
104
+ ) > 0 as is_pk
105
+ FROM information_schema.columns c
106
+ WHERE c.table_schema = @schema AND c.table_name = @table
107
+ ORDER BY c.ordinal_position
108
+ `;
109
+
110
+ const fksSql = `
111
+ SELECT
112
+ kcu.column_name AS local_column,
113
+ ccu.table_name AS foreign_table,
114
+ ccu.column_name AS foreign_column
115
+ FROM information_schema.table_constraints AS tc
116
+ JOIN information_schema.key_column_usage AS kcu
117
+ ON tc.constraint_name = kcu.constraint_name
118
+ AND tc.table_schema = kcu.table_schema
119
+ JOIN information_schema.constraint_column_usage AS ccu
120
+ ON ccu.constraint_name = tc.constraint_name
121
+ AND ccu.table_schema = tc.table_schema
122
+ WHERE tc.constraint_type = 'FOREIGN KEY'
123
+ AND tc.table_schema = @schema
124
+ AND tc.table_name = @table
125
+ `;
126
+
127
+ const colsRes = await this.query(columnsSql, [this.schema, tableName]);
128
+ const fksRes = await this.query(fksSql, [this.schema, tableName]);
129
+
130
+ return colsRes.rows.map((row: any) => {
131
+ const fk = fksRes.rows.find((f: any) => f.local_column === row.name);
132
+ return {
133
+ name: row.name,
134
+ type: row.type,
135
+ nullable: row.nullable === "YES",
136
+ defaultValue: row.default_value,
137
+ isPrimaryKey: row.is_pk,
138
+ isForeignKey: !!fk,
139
+ referencedTable: fk ? fk.foreign_table : null,
140
+ referencedColumn: fk ? fk.foreign_column : null
141
+ };
142
+ });
143
+ }
144
+
145
+ async disconnect(): Promise<void> {
146
+ if (this.pool) {
147
+ await this.pool.close();
148
+ this.pool = null;
149
+ }
150
+ }
151
+ }
@@ -1,6 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66381,e=>{"use strict";var t=e.i(43476),r=e.i(71645);let s={display:"flex",height:"100%",width:"100%",backgroundColor:"#05070a",color:"#cbd5e1",fontSize:"0.875rem",minHeight:0},a={width:"280px",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",minHeight:0,backgroundColor:"rgba(10, 15, 24, 0.4)",flexShrink:0},n={display:"flex",flexDirection:"column",padding:"1rem",minHeight:0},l={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.75rem"},o={fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",fontSize:"0.75rem",color:"var(--muted)"},i={padding:"0.2rem 0.5rem",borderRadius:"4px",border:"1px solid var(--primary)",backgroundColor:"transparent",color:"var(--primary)",fontSize:"0.7rem",fontWeight:600,cursor:"pointer"},d={display:"flex",flexDirection:"column",gap:"0.4rem",overflowY:"auto",maxHeight:"220px"},c={fontSize:"0.65rem",fontWeight:600,color:"var(--muted)",marginTop:"0.5rem",marginBottom:"0.2rem",letterSpacing:"0.05em"},u={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"},p={backgroundColor:"rgba(109, 40, 217, 0.08)",border:"1px solid var(--border-focus)",boxShadow:"0 0 10px rgba(109, 40, 217, 0.1)"},m={display:"flex",flexDirection:"column",gap:"0.15rem",flex:1,minWidth:0},h={fontWeight:600,fontSize:"0.8rem",color:"#fff",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},x={fontSize:"0.7rem",color:"var(--muted)",textTransform:"uppercase"},f={background:"none",border:"none",color:"rgba(239, 68, 68, 0.4)",cursor:"pointer",fontSize:"0.75rem",padding:"0.25rem"},g={display:"flex",flexDirection:"column",gap:"0.25rem",overflowY:"auto",flex:1,minHeight:0},y={fontSize:"0.75rem",color:"var(--muted)",textAlign:"center",padding:"1rem 0"},b={display:"flex",flexDirection:"column"},j={display:"flex",alignItems:"center",padding:"0.35rem 0.5rem",borderRadius:"4px",cursor:"pointer",userSelect:"none",transition:"background 0.2s ease"},v={marginRight:"0.4rem",fontSize:"0.9rem"},_={flex:1,fontSize:"0.8rem",color:"#e2e8f0",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},w={fontSize:"0.6rem",color:"var(--muted)",marginLeft:"0.25rem"},k={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"},S={display:"flex",alignItems:"center",padding:"0.15rem 0.25rem",fontSize:"0.75rem"},C={marginRight:"0.3rem",fontSize:"0.7rem"},N={flex:1,color:"var(--muted)",overflow:"hidden",textOverflow:"ellipsis"},R={fontSize:"0.65rem",color:"rgba(109, 40, 217, 0.75)",fontFamily:"monospace",paddingLeft:"0.5rem"},T={flex:1,display:"flex",flexDirection:"column",minHeight:0,backgroundColor:"#05070a"},P={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},W={fontSize:"0.75rem",color:"var(--muted)"},E={fontSize:"0.8rem",fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:"0.4rem"},L={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)"},I={padding:"0.4rem 0.9rem",borderRadius:"6px",border:"none",backgroundColor:"var(--primary)",color:"#fff",fontSize:"0.8rem",fontWeight:600,transition:"all 0.2s ease"},D={height:"180px",borderBottom:"1px solid var(--border)",position:"relative",flexShrink:0},O={width:"100%",height:"100%",backgroundColor:"#080c14",border:"none",resize:"none",color:"#e2e8f0",fontFamily:"monospace",fontSize:"0.85rem",padding:"1rem",outline:"none",lineHeight:"1.4"},z={flex:1,display:"flex",flexDirection:"column",minHeight:0,padding:"1rem"},A={padding:"1rem",borderRadius:"8px",backgroundColor:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",overflowY:"auto"},B={margin:0,fontFamily:"monospace",fontSize:"0.8rem",color:"#f87171",whiteSpace:"pre-wrap"},q={marginTop:"1rem",padding:"0.75rem",borderRadius:"6px",backgroundColor:"rgba(0, 0, 0, 0.3)",border:"1px solid var(--border)"},F={display:"block",padding:"0.5rem",backgroundColor:"#090d16",borderRadius:"4px",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--primary)",border:"1px solid var(--border)"},M={display:"flex",flexDirection:"column",height:"100%",minHeight:0},H={display:"flex",justifyContent:"space-between",fontSize:"0.75rem",color:"var(--muted)",marginBottom:"0.5rem"},G={flex:1,overflow:"auto",border:"1px solid var(--border)",borderRadius:"6px"},$={width:"100%",borderCollapse:"collapse",fontFamily:"monospace",fontSize:"0.8rem"},Y={padding:"0.5rem 0.75rem",textAlign:"left",backgroundColor:"#0f172a",borderBottom:"1px solid var(--border)",color:"#94a3b8",fontWeight:600,position:"sticky",top:0,zIndex:1},U={padding:"0.4rem 0.75rem",borderBottom:"1px solid rgba(255, 255, 255, 0.03)",color:"#cbd5e1",whiteSpace:"nowrap"},J={backgroundColor:"transparent"},Q={backgroundColor:"rgba(255, 255, 255, 0.01)"},K={flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--muted)",fontSize:"0.8rem",textAlign:"center"},V={flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"1rem"},X={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"},Z={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"},ee={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},et={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)"},er={display:"flex",flexDirection:"column",gap:"0.35rem",marginBottom:"1rem"},es={fontSize:"0.75rem",fontWeight:600,color:"var(--muted)"},ea={padding:"0.5rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"#070a12",color:"#fff",outline:"none",fontSize:"0.8rem"},en={padding:"0.5rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"#070a12",color:"#fff",outline:"none",fontSize:"0.8rem"},el={padding:"0.5rem",borderRadius:"6px",fontSize:"0.75rem",marginBottom:"1rem"},eo={display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},ei={padding:"0.4rem 0.75rem",borderRadius:"6px",border:"1px solid var(--border)",backgroundColor:"transparent",color:"var(--muted)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"},ed={padding:"0.4rem 0.75rem",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--muted)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"},ec={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 e=document.createElement("style");e.innerHTML=`
2
- @keyframes spin {
3
- 0% { transform: rotate(0deg); }
4
- 100% { transform: rotate(360deg); }
5
- }
6
- `,document.head.appendChild(e)}e.s(["default",0,function({workspaceRoot:e}){let[eu,ep]=(0,r.useState)({global:[],workspace:[]}),[em,eh]=(0,r.useState)(null),[ex,ef]=(0,r.useState)(!0),[eg,ey]=(0,r.useState)([]),[eb,ej]=(0,r.useState)(null),[ev,e_]=(0,r.useState)({}),[ew,ek]=(0,r.useState)(!1),[eS,eC]=(0,r.useState)("SELECT * FROM sqlite_master;"),[eN,eR]=(0,r.useState)(!1),[eT,eP]=(0,r.useState)(null),[eW,eE]=(0,r.useState)(null),[eL,eI]=(0,r.useState)(!1),[eD,eO]=(0,r.useState)(!1),[ez,eA]=(0,r.useState)({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),[eB,eq]=(0,r.useState)(!1),[eF,eM]=(0,r.useState)(null),eH=async()=>{try{let t=await fetch(`/api/sql/connections?root=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json();e.success&&(ep({global:e.global||[],workspace:e.workspace||[]}),eh(e.activeId),ef(e.isActiveGlobal))}}catch(e){console.error("Failed to load connection profiles:",e)}},eG=async()=>{if(!em)return void ey([]);ek(!0);try{let t=await fetch(`/api/sql/schema?action=list_tables&root=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json();e.success?(ey(e.tables||[]),eP(null)):eP(e.error||"Failed to load database schema.")}else{let e=await t.json();eP(e.error||"Failed to load database schema.")}}catch(e){console.error("Failed to load schema:",e)}finally{ek(!1)}},e$=async t=>{if(ev[t])return void ej(eb===t?null:t);try{let r=await fetch(`/api/sql/schema?action=describe_table&table=${encodeURIComponent(t)}&root=${encodeURIComponent(e)}`);if(r.ok){let e=await r.json();e.success&&(e_(r=>({...r,[t]:e.columns})),ej(t))}}catch(e){console.error(`Failed to load columns for table ${t}:`,e)}};(0,r.useEffect)(()=>{eH()},[e]),(0,r.useEffect)(()=>{eG(),eE(null),ej(null),e_({});let e=ex?eu.global.find(e=>e.id===em):eu.workspace.find(e=>e.id===em);e&&("sqlite"===e.type?eC("SELECT name, type FROM sqlite_master WHERE type='table';"):eC("SELECT * FROM information_schema.tables LIMIT 10;"))},[em,ex,eu.global.length,eu.workspace.length]);let eY=async(t,r)=>{try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"set_active",profileId:t,isGlobal:r,root:e})})).ok&&(eh(t),ef(r))}catch(e){console.error("Failed to set active profile:",e)}},eU=async()=>{eM(null);try{let t=await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"test",profile:ez,root:e})}),r=await t.json();r.success?eM({success:!0,message:"Connection test successful!"}):eM({success:!1,message:r.error||"Connection test failed."})}catch(e){eM({success:!1,message:e.message||"Failed to make test query."})}},eJ=async t=>{if(t.preventDefault(),!ez.name||!ez.type)return;eq(!0);let r=ez.id||`profile_${Math.random().toString(36).substring(7)}`,s={...ez,id:r,name:ez.name,type:ez.type};try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save",profile:s,isGlobal:eD,root:e})})).ok&&(await eH(),eI(!1),em||eY(r,eD))}catch(e){console.error("Failed to save profile:",e)}finally{eq(!1)}},eQ=async(t,r)=>{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:t,isGlobal:r,root:e})})).ok&&(await eH(),em===t&&eh(null))}catch(e){console.error("Failed to delete connection profile:",e)}},eK=async()=>{if(eS.trim()&&em){eR(!0),eP(null),eE(null);try{let t=await fetch("/api/sql/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:eS.trim(),root:e})}),r=await t.json();t.ok&&r.success?(eE({rows:r.rows||[],fields:r.fields||[],durationMs:r.durationMs||0,affectedRows:r.affectedRows}),(eS.toLowerCase().includes("create table")||eS.toLowerCase().includes("drop table")||eS.toLowerCase().includes("alter table"))&&eG()):eP(r.error||"Failed to execute query.")}catch(e){eP(e.message||"An unexpected error occurred during execution.")}finally{eR(!1)}}},eV=ex?eu.global.find(e=>e.id===em):eu.workspace.find(e=>e.id===em);return(0,t.jsxs)("div",{style:s,children:[(0,t.jsxs)("div",{style:a,children:[(0,t.jsxs)("div",{style:n,children:[(0,t.jsxs)("div",{style:l,children:[(0,t.jsx)("span",{style:o,children:"Connections"}),(0,t.jsx)("button",{style:i,onClick:()=>{eM(null),eA({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),eO(!1),eI(!0)},title:"Add Database Connection Profile",children:"➕ Add"})]}),(0,t.jsxs)("div",{style:d,children:[0===eu.global.length&&0===eu.workspace.length&&(0,t.jsx)("div",{style:y,children:"No connections configured. Add one to start."}),eu.workspace.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{style:c,children:"WORKSPACE CONNECTIONS"}),eu.workspace.map(e=>(0,t.jsxs)("div",{style:{...u,...em===e.id&&!ex?p:{}},onClick:()=>eY(e.id,!1),children:[(0,t.jsxs)("div",{style:m,children:[(0,t.jsxs)("span",{style:h,children:["📁 ",e.name]}),(0,t.jsx)("span",{style:x,children:e.type})]}),(0,t.jsx)("button",{style:f,onClick:t=>{t.stopPropagation(),eQ(e.id,!1)},children:"✖"})]},e.id))]}),eu.global.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{style:c,children:"GLOBAL CONNECTIONS"}),eu.global.map(e=>(0,t.jsxs)("div",{style:{...u,...em===e.id&&ex?p:{}},onClick:()=>eY(e.id,!0),children:[(0,t.jsxs)("div",{style:m,children:[(0,t.jsxs)("span",{style:h,children:["🌐 ",e.name]}),(0,t.jsx)("span",{style:x,children:e.type})]}),(0,t.jsx)("button",{style:f,onClick:t=>{t.stopPropagation(),eQ(e.id,!0)},children:"✖"})]},e.id))]})]})]}),(0,t.jsxs)("div",{style:{...n,flex:1,borderTop:"1px solid var(--border)"},children:[(0,t.jsxs)("div",{style:l,children:[(0,t.jsx)("span",{style:o,children:"Schema Tables"}),ew&&(0,t.jsx)("span",{style:Z})]}),(0,t.jsxs)("div",{style:g,children:[!em&&(0,t.jsx)("div",{style:y,children:"Select an active connection to view tables."}),em&&0===eg.length&&!ew&&(0,t.jsx)("div",{style:y,children:"No tables found in database schema."}),eg.map(e=>(0,t.jsxs)("div",{style:b,children:[(0,t.jsxs)("div",{style:j,onClick:()=>e$(e.name),children:[(0,t.jsx)("span",{style:v,children:"view"===e.type?"👁️":"📊"}),(0,t.jsx)("span",{style:_,children:e.name}),(0,t.jsx)("span",{style:w,children:eb===e.name?"▼":"▶"})]}),eb===e.name&&ev[e.name]&&(0,t.jsx)("div",{style:k,children:ev[e.name].map(e=>(0,t.jsxs)("div",{style:S,children:[(0,t.jsx)("span",{style:C,children:e.isPrimaryKey?"🔑":e.isForeignKey?"🔗":"▫"}),(0,t.jsx)("span",{style:N,title:e.type,children:e.name}),(0,t.jsx)("span",{style:R,children:e.type.toLowerCase().substring(0,12)})]},e.name))})]},e.name))]})]})]}),(0,t.jsxs)("div",{style:T,children:[(0,t.jsxs)("div",{style:P,children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[(0,t.jsx)("span",{style:W,children:"Active Connection:"}),eV?(0,t.jsxs)("span",{style:E,children:[ex?"🌐":"📁"," ",eV.name," (",eV.type,")",eV.readOnly&&(0,t.jsx)("span",{style:L,children:"Read-Only"})]}):(0,t.jsx)("span",{style:{...E,color:"var(--danger)"},children:"No Connection Selected"})]}),(0,t.jsx)("button",{style:{...I,opacity:!em||eN?.6:1,cursor:!em||eN?"not-allowed":"pointer"},onClick:eK,disabled:!em||eN,children:eN?"⌛ Running...":"⚡ Execute Query (F5)"})]}),(0,t.jsx)("div",{style:D,children:(0,t.jsx)("textarea",{style:O,value:eS,onChange:e=>eC(e.target.value),placeholder:"Write your SQL query script here...",onKeyDown:e=>{("F5"===e.key||e.ctrlKey&&"Enter"===e.key)&&(e.preventDefault(),eK())}})}),(0,t.jsxs)("div",{style:z,children:[eT&&(0,t.jsxs)("div",{style:A,children:[(0,t.jsx)("h4",{style:{margin:"0 0 0.5rem 0",color:"var(--danger)"},children:"⚠️ Execution Error"}),(0,t.jsx)("pre",{style:B,children:eT}),eT.includes("not installed")&&(0,t.jsxs)("div",{style:q,children:[(0,t.jsx)("p",{style:{margin:"0 0 0.5rem 0"},children:"To resolve this, run this installer command in your workspace terminal:"}),(0,t.jsx)("code",{style:F,children:eV?.type==="sqlite"?"npm install better-sqlite3":eV?.type==="postgres"?"npm install pg":"npm install mysql2"})]})]}),eW&&(0,t.jsxs)("div",{style:M,children:[(0,t.jsxs)("div",{style:H,children:[(0,t.jsxs)("span",{children:["Query completed."," ",void 0!==eW.affectedRows?`Affected rows: ${eW.affectedRows}`:`Returned ${eW.rows.length} rows`]}),(0,t.jsxs)("span",{children:["Duration: ",eW.durationMs,"ms"]})]}),eW.rows.length>0?(0,t.jsx)("div",{style:G,children:(0,t.jsxs)("table",{style:$,children:[(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{children:eW.fields.map(e=>(0,t.jsx)("th",{style:Y,children:e},e))})}),(0,t.jsx)("tbody",{children:eW.rows.map((e,r)=>(0,t.jsx)("tr",{style:r%2==0?J:Q,children:eW.fields.map(r=>(0,t.jsx)("td",{style:U,children:null===e[r]?"NULL":"object"==typeof e[r]?JSON.stringify(e[r]):String(e[r])},r))},r))})]})}):void 0===eW.affectedRows&&(0,t.jsx)("div",{style:K,children:"Query executed successfully, but returned 0 results."})]}),!eT&&!eW&&!eN&&(0,t.jsx)("div",{style:K,children:"Write a query script and click Execute to view table records."}),eN&&(0,t.jsxs)("div",{style:V,children:[(0,t.jsx)("span",{style:X}),(0,t.jsx)("span",{style:{color:"var(--muted)"},children:"Running database statement..."})]})]})]}),eL&&(0,t.jsx)("div",{style:ee,children:(0,t.jsxs)("div",{style:et,children:[(0,t.jsxs)("h3",{style:{margin:"0 0 1rem 0",display:"flex",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:"🔌 Add Database Profile"}),(0,t.jsx)("span",{style:{cursor:"pointer"},onClick:()=>eI(!1),children:"✖"})]}),(0,t.jsxs)("form",{onSubmit:eJ,children:[(0,t.jsxs)("div",{style:er,children:[(0,t.jsx)("label",{style:es,children:"Profile Name"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.name,onChange:e=>eA(t=>({...t,name:e.target.value})),placeholder:"e.g. Local Postgres, Dev SQLite"})]}),(0,t.jsxs)("div",{style:er,children:[(0,t.jsx)("label",{style:es,children:"Scope Level"}),(0,t.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,t.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,t.jsx)("input",{type:"radio",checked:!eD,onChange:()=>eO(!1)}),"Workspace Local"]}),(0,t.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,t.jsx)("input",{type:"radio",checked:eD,onChange:()=>eO(!0)}),"Global User Profile"]})]})]}),(0,t.jsxs)("div",{style:er,children:[(0,t.jsx)("label",{style:es,children:"Database Type"}),(0,t.jsxs)("select",{style:en,value:ez.type,onChange:e=>eA(t=>({...t,type:e.target.value,filepath:"sqlite"===e.target.value?"./dev.db":void 0})),children:[(0,t.jsx)("option",{value:"sqlite",children:"SQLite (Local File)"}),(0,t.jsx)("option",{value:"postgres",children:"PostgreSQL"}),(0,t.jsx)("option",{value:"mysql",children:"MySQL"})]})]}),"sqlite"===ez.type?(0,t.jsxs)("div",{style:er,children:[(0,t.jsx)("label",{style:es,children:"Database File Path"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.filepath||"",onChange:e=>eA(t=>({...t,filepath:e.target.value})),placeholder:"Relative (e.g. ./data/dev.db) or Absolute path"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,t.jsxs)("div",{style:{...er,flex:3},children:[(0,t.jsx)("label",{style:es,children:"Host IP Address"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.host||"",onChange:e=>eA(t=>({...t,host:e.target.value})),placeholder:"localhost or IP"})]}),(0,t.jsxs)("div",{style:{...er,flex:1},children:[(0,t.jsx)("label",{style:es,children:"Port"}),(0,t.jsx)("input",{style:ea,type:"number",required:!0,value:ez.port||0,onChange:e=>eA(t=>({...t,port:parseInt(e.target.value)}))})]})]}),(0,t.jsxs)("div",{style:er,children:[(0,t.jsx)("label",{style:es,children:"Database Name"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.database||"",onChange:e=>eA(t=>({...t,database:e.target.value}))})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,t.jsxs)("div",{style:{...er,flex:1},children:[(0,t.jsx)("label",{style:es,children:"Username"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.username||"",onChange:e=>eA(t=>({...t,username:e.target.value}))})]}),(0,t.jsxs)("div",{style:{...er,flex:1},children:[(0,t.jsx)("label",{style:es,children:"Password"}),(0,t.jsx)("input",{style:ea,type:"password",value:ez.password||"",onChange:e=>eA(t=>({...t,password:e.target.value}))})]})]}),"postgres"===ez.type&&(0,t.jsx)("div",{style:er,children:(0,t.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,t.jsx)("input",{type:"checkbox",checked:!!ez.ssl,onChange:e=>eA(t=>({...t,ssl:e.target.checked}))}),"Require SSL Secure Connection"]})})]}),(0,t.jsx)("div",{style:er,children:(0,t.jsxs)("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"0.25rem"},children:[(0,t.jsx)("input",{type:"checkbox",checked:!!ez.readOnly,onChange:e=>eA(t=>({...t,readOnly:e.target.checked}))}),"Enforce Read-Only Connection (Disable mutations)"]})}),eF&&(0,t.jsx)("div",{style:{...el,backgroundColor:eF.success?"rgba(16, 185, 129, 0.12)":"rgba(239, 68, 68, 0.12)",border:eF.success?"1px solid var(--success)":"1px solid var(--danger)",color:eF.success?"var(--success)":"var(--danger)"},children:eF.message}),(0,t.jsxs)("div",{style:eo,children:[(0,t.jsx)("button",{type:"button",style:ei,onClick:eU,children:"🔍 Test Connection"}),(0,t.jsxs)("div",{style:{display:"flex",gap:"0.5rem"},children:[(0,t.jsx)("button",{type:"button",style:ed,onClick:()=>eI(!1),children:"Cancel"}),(0,t.jsx)("button",{type:"submit",style:ec,disabled:eB,children:eB?"Saving...":"Save Profile"})]})]})]})]})})]})}])},67585,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"BailoutToCSR",{enumerable:!0,get:function(){return a}});let s=e.r(32061);function a({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new s.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},9885,(e,t,r)=>{"use strict";function s(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"encodeURIPath",{enumerable:!0,get:function(){return s}})},52157,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"PreloadChunks",{enumerable:!0,get:function(){return i}});let s=e.r(43476),a=e.r(74080),n=e.r(63599),l=e.r(9885),o=e.r(43369);function i({moduleIds:e}){if("u">typeof window)return null;let t=n.workAsyncStorage.getStore();if(void 0===t)return null;let r=[];if(t.reactLoadableManifest&&e){let s=t.reactLoadableManifest;for(let t of e){if(!s[t])continue;let e=s[t].files;r.push(...e)}}if(0===r.length)return null;let d=(0,o.getAssetTokenQuery)();return(0,s.jsx)(s.Fragment,{children:r.map(e=>{let r=`${t.assetPrefix}/_next/${(0,l.encodeURIPath)(e)}${d}`;return e.endsWith(".css")?(0,s.jsx)("link",{precedence:"dynamic",href:r,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,a.preload)(r,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},69093,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return d}});let s=e.r(43476),a=e.r(71645),n=e.r(67585),l=e.r(52157);function o(e){return{default:e&&"default"in e?e.default:e}}let i={loader:()=>Promise.resolve(o(()=>null)),loading:null,ssr:!0},d=function(e){let t={...i,...e},r=(0,a.lazy)(()=>t.loader().then(o)),d=t.loading;function c(e){let o=d?(0,s.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,i=!t.ssr||!!t.loading,c=i?a.Suspense:a.Fragment,u=t.ssr?(0,s.jsxs)(s.Fragment,{children:["u"<typeof window?(0,s.jsx)(l.PreloadChunks,{moduleIds:t.modules}):null,(0,s.jsx)(r,{...e})]}):(0,s.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,s.jsx)(r,{...e})});return(0,s.jsx)(c,{...i?{fallback:o}:{},children:u})}return c.displayName="LoadableComponent",c}},70703,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return a}});let s=e.r(55682)._(e.r(69093));function a(e,t){let r={};"function"==typeof e&&(r.loader=e);let a={...r,...t};return(0,s.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},20897,e=>{e.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"})},52683,e=>{"use strict";var t=e.i(43476),r=e.i(71645),s=e.i(70703),a=e.i(20897),n=e.i(66381);let l=(0,s.default)(()=>e.A(33779),{loadableGenerated:{modules:[37314]},ssr:!1,loading:()=>(0,t.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,t.jsx)("span",{children:"Initializing terminal emulator..."})})}),o=(0,s.default)(()=>e.A(39429),{loadableGenerated:{modules:[1985]},ssr:!1,loading:()=>(0,t.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,t.jsx)("span",{style:{color:"var(--muted)"},children:"Initializing prompt editor..."})})}),i=(0,s.default)(()=>e.A(56915),{loadableGenerated:{modules:[99026]},ssr:!1}),d=(0,s.default)(()=>e.A(78716),{loadableGenerated:{modules:[9949]},ssr:!1}),c=(0,s.default)(()=>e.A(33789),{loadableGenerated:{modules:[20032]},ssr:!1}),u=(0,s.default)(()=>e.A(78003),{loadableGenerated:{modules:[97722]},ssr:!1});e.s(["default",0,function(){let[e,s]=(0,r.useState)([]),[p,m]=(0,r.useState)(null),[h,x]=(0,r.useState)(!1),[f,g]=(0,r.useState)(!1),[y,b]=(0,r.useState)(!1),[j,v]=(0,r.useState)(!1),[_,w]=(0,r.useState)(!1),[k,S]=(0,r.useState)(!1),[C,N]=(0,r.useState)(""),[R,T]=(0,r.useState)(3001),[P,W]=(0,r.useState)("0.2.19"),[E,L]=(0,r.useState)(null),I=e.filter(e=>"workspace-terminal"!==e.id),D=e.find(e=>e.id===p),O=I.some(e=>("claude-docker"===e.type||"aider-docker"===e.type)&&"running"===e.status),z=I.some(e=>"claude-ssh"===e.type&&"running"===e.status),A=async()=>{try{let e=await fetch("/api/sessions"),t=await e.json();t.sessions&&s(t.sessions),t.wsPort&&T(t.wsPort),t.originalCwd&&N(t.originalCwd),t.version&&W(t.version)}catch(e){console.error("Failed to fetch sessions:",e)}},B=async()=>{try{let e=await fetch("/api/recents");if(e.ok){let t=await e.json();t.success&&t.recents&&t.recents.lastSession&&L(t.recents.lastSession)}}catch(e){console.error("Failed to fetch recents:",e)}};(0,r.useEffect)(()=>{(async()=>{await A(),await B()})(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(e=>console.log("Service Worker registered:",e.scope)).catch(e=>console.error("Service Worker registration failed:",e));let e=setInterval(A,4e3);return()=>clearInterval(e)},[]);let q=async(e,t,r,s)=>{x(!0);try{let a=t;a||("claude"===e?a="Claude Local":"claude-docker"===e?a="Claude Docker":"claude-ssh"===e?a="Claude SSH":"aider"===e?a="Aider Local":"aider-docker"===e?a="Aider Docker":"mock"===e&&(a="Mock Session"));let n={type:e,name:a,workspaceRoot:r,scopedDirs:s};if(("aider"===e||"aider-docker"===e)&&!r)try{let e=await fetch("/api/context/aider");if(e.ok){let t=await e.json();t.success&&t.config&&(n.workspaceRoot=t.config.workspaceRoot,n.scopedDirs=t.config.scopedDirs)}}catch(e){console.error("Failed to load aider configuration before launch:",e)}let l=await fetch("/api/sessions/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),o=await l.json();o.success&&(await A(),m(o.session.id),L({type:e,name:a,workspaceRoot:r,scopedDirs:s}))}catch(e){console.error("Failed to launch session:",e)}finally{x(!1)}},F=async(e,t=!1)=>{try{let r=await fetch("/api/sessions/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,delete:t})});(await r.json()).success&&(t&&p===e&&m(null),await A())}catch(e){console.error("Failed to stop session:",e)}};return(0,t.jsxs)("div",{className:`${a.default.container} ${D?a.default.containerActive:""}`,children:[(0,t.jsxs)("header",{className:a.default.header,children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"1.5rem"},children:[(0,t.jsx)("img",{src:"/logo.png",alt:"NeuralLoom Logo",style:{width:"160px",height:"160px",borderRadius:"16px",objectFit:"contain"}}),(0,t.jsxs)("div",{className:a.default.logoArea,children:[(0,t.jsx)("h1",{className:a.default.title,style:{margin:0,lineHeight:1.1},children:"NeuralLoom"}),(0,t.jsx)("span",{className:a.default.subtitle,children:"Unified AI Orchestrator & Context Bridge"})]})]}),(0,t.jsxs)("div",{className:a.default.statusIndicator,children:[(0,t.jsx)("span",{className:a.default.pulseDot}),(0,t.jsx)("span",{children:"Orchestrator Online"})]})]}),D?(0,t.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:(0,t.jsx)(u,{sessionId:D.id,workspaceRoot:D.workspaceRoot||"",scopedDirs:D.scopedDirs||[],onClose:()=>m(null),sessions:e,onSwitchSession:e=>m(e),onRefreshSessions:A,wsPort:R})}):(0,t.jsxs)("div",{className:a.default.dashboardGrid,children:[(0,t.jsxs)("main",{className:a.default.mainPanel,children:[(0,t.jsxs)("section",{children:[(0,t.jsx)("h2",{className:a.default.sectionTitle,children:"Active AI Agents"}),0===I.length?(0,t.jsxs)("div",{className:"card",style:{padding:"3rem 1.5rem",textAlign:"center"},children:[(0,t.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,t.jsxs)("div",{style:{display:"flex",gap:"1rem",justifyContent:"center",flexWrap:"wrap"},children:[E&&(0,t.jsx)("button",{className:a.default.quickLaunchBtn,onClick:()=>{q(E.type,E.name,E.workspaceRoot,E.scopedDirs)},disabled:h,style:{background:"linear-gradient(135deg, hsl(38, 92%, 50%) 0%, hsl(0, 84%, 60%) 100%)",border:"none",maxWidth:"200px"},title:`Re-launch: ${E.name||E.type}`,children:"⚡ Re-launch Last Session"}),(0,t.jsx)("button",{className:a.default.quickLaunchBtn,onClick:()=>{S(!1),w(!0)},disabled:h,style:{background:"linear-gradient(135deg, hsl(262, 83%, 60%) 0%, hsl(195, 100%, 45%) 100%)",border:"none",maxWidth:"200px"},children:"Launch Claude PTY"}),(0,t.jsx)("button",{className:a.default.quickLaunchBtn,onClick:()=>{v(!1),b(!0)},disabled:h,style:{background:"linear-gradient(135deg, hsl(210, 80%, 45%) 0%, hsl(262, 80%, 55%) 100%)",border:"none",maxWidth:"200px"},children:"Launch Aider PTY"})]}),(0,t.jsxs)("div",{style:{marginTop:"1.5rem",fontSize:"0.75rem",color:"var(--muted)"},children:["Want to verify layout features first?"," ",(0,t.jsx)("span",{onClick:()=>q("mock"),style:{color:"var(--primary)",cursor:"pointer",textDecoration:"underline"},children:"Start simulated sandbox session"})]})]}):(0,t.jsx)("div",{className:a.default.agentGrid,children:I.map(e=>(0,t.jsxs)("div",{className:`${a.default.agentCard} card ${p===e.id?a.default.activeBorder:""}`,children:[(0,t.jsxs)("div",{className:a.default.agentHeader,children:[(0,t.jsx)("span",{className:a.default.agentName,children:e.name}),(0,t.jsx)("span",{className:`${a.default.agentBadge} ${"stopped"===e.status?a.default.stoppedBadge:""}`,children:e.status})]}),(0,t.jsxs)("div",{className:a.default.cardBody,children:[(0,t.jsxs)("p",{style:{fontSize:"0.825rem",color:"var(--muted)"},children:["ID: ",(0,t.jsx)("code",{style:{fontSize:"0.75rem"},children:e.id.substring(0,8)}),(0,t.jsx)("br",{}),"Type: ","claude"===e.type?"Claude Local PTY":"claude-docker"===e.type?"Claude Docker PTY":"claude-ssh"===e.type?"Claude SSH PTY":"aider"===e.type?"Aider Local PTY":"aider-docker"===e.type?"Aider Docker PTY":"mock"===e.type?"Simulated Mock PTY":"Unknown PTY",(0,t.jsx)("br",{}),"Logs: ",e.logsCount," captured lines"]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"0.5rem",marginTop:"1rem"},children:["running"===e.status?(0,t.jsx)("button",{onClick:()=>F(e.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,t.jsx)("button",{onClick:()=>F(e.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,t.jsx)("button",{onClick:()=>m(e.id),style:{flex:2,padding:"0.4rem 0.6rem",borderRadius:"6px",border:"none",backgroundColor:p===e.id?"var(--border-focus)":"var(--primary)",fontSize:"0.75rem",fontWeight:600,color:"#fff"},children:p===e.id?"Connected":"Open Session"})]})]})]},e.id))})]}),p&&"workspace-terminal"!==p&&(0,t.jsxs)("section",{className:"card",style:{display:"flex",flexDirection:"column",border:"1px solid var(--border-focus)"},children:[(0,t.jsxs)("div",{className:a.default.agentHeader,style:{justifyContent:"space-between",background:"rgba(109, 40, 217, 0.08)"},children:[(0,t.jsxs)("span",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem"},children:["🖥️ Console Bridge — ",e.find(e=>e.id===p)?.name]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.find(e=>e.id===p)?.status==="stopped"&&(0,t.jsx)("button",{onClick:async()=>{try{let e=await fetch("/api/sessions/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:p})});if(e.ok)await A();else{let t=await e.json();alert(t.error||"Failed to restart session.")}}catch(e){console.error("Failed to restart session:",e),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,t.jsx)("button",{onClick:()=>m(null),style:{border:"none",background:"none",color:"var(--muted)",cursor:"pointer",fontSize:"0.75rem"},children:"Close Panel ✖"})]})]}),(0,t.jsx)(l,{sessionId:p,wsPort:R})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h2",{className:a.default.sectionTitle,children:"Workspace Shell Terminal"}),(0,t.jsxs)("div",{className:"card",style:{display:"flex",flexDirection:"column",border:"1px solid var(--border)",padding:0},children:[(0,t.jsxs)("div",{className:a.default.agentHeader,style:{justifyContent:"space-between",background:"rgba(255, 255, 255, 0.02)"},children:[(0,t.jsxs)("span",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.85rem"},children:["💻 Local Workspace Shell (CWD: ",C||"root",")"]}),(0,t.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--muted)"},children:"Pre-configured environment"})]}),(0,t.jsx)(l,{sessionId:"workspace-terminal",height:"300px",wsPort:R})]})]}),(0,t.jsxs)("section",{style:{marginTop:"2rem"},children:[(0,t.jsx)("h2",{className:a.default.sectionTitle,children:"Shared Context Hub & Slash Commands"}),(0,t.jsxs)("div",{className:a.default.contextList,children:[(0,t.jsxs)("div",{className:`${a.default.contextItem} card`,children:[(0,t.jsxs)("div",{className:a.default.contextMeta,children:[(0,t.jsx)("span",{className:a.default.contextTitle,children:"Staged Context & System Rules (/ccc)"}),(0,t.jsx)("span",{className:a.default.contextDetails,children:"Compiles AGENTS.md guidelines and project files folder hierarchy map."})]}),(0,t.jsx)("button",{onClick:async()=>{p&&await fetch("/api/sessions/inject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:p,command:"/ccc"})})},disabled:!p,style:{padding:"0.4rem 0.8rem",borderRadius:"6px",border:"1px solid var(--primary)",backgroundColor:"transparent",color:"var(--primary)",fontSize:"0.75rem",fontWeight:600,opacity:p?1:.5,cursor:p?"pointer":"not-allowed"},children:"🚀 Mount Context (/ccc)"})]}),(0,t.jsxs)("div",{className:`${a.default.contextItem} card`,children:[(0,t.jsxs)("div",{className:a.default.contextMeta,children:[(0,t.jsx)("span",{className:a.default.contextTitle,children:"Staged Developer Prompt (/ccp)"}),(0,t.jsx)("span",{className:a.default.contextDetails,children:"Executes instructions written in .ai/neural-loom/cprompt.md."})]}),(0,t.jsx)("button",{onClick:async()=>{p&&await fetch("/api/sessions/inject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:p,command:"/ccp"})})},disabled:!p,style:{padding:"0.4rem 0.8rem",borderRadius:"6px",border:"1px solid var(--success)",backgroundColor:"transparent",color:"var(--success)",fontSize:"0.75rem",fontWeight:600,opacity:p?1:.5,cursor:p?"pointer":"not-allowed"},children:"⚡ Trigger Prompt (/ccp)"})]})]}),(0,t.jsx)(o,{})]}),(0,t.jsxs)("section",{style:{marginTop:"2rem"},children:[(0,t.jsx)("h2",{className:a.default.sectionTitle,children:"Built-in Database Explorer & SQL Client"}),(0,t.jsx)("div",{className:"card",style:{padding:0,overflow:"hidden",height:"480px",border:"1px solid var(--border)"},children:(0,t.jsx)(n.default,{workspaceRoot:C||""})})]})]}),(0,t.jsxs)("aside",{className:a.default.sidePanel,children:[(0,t.jsxs)("section",{children:[(0,t.jsx)("h2",{className:a.default.sectionTitle,children:"Execution Environments"}),(0,t.jsxs)("div",{className:a.default.envGrid,children:[(0,t.jsxs)("div",{className:a.default.envRow,children:[(0,t.jsx)("span",{className:a.default.envName,children:"💻 Local host OS"}),(0,t.jsx)("span",{className:a.default.envStatus,style:{color:"var(--success)"},children:"Active"})]}),(0,t.jsxs)("div",{className:a.default.envRow,style:{opacity:O?1:.6},children:[(0,t.jsx)("span",{className:a.default.envName,children:"🐳 Docker Sandbox"}),(0,t.jsx)("span",{className:a.default.envStatus,style:{color:O?"var(--success)":"var(--muted)"},children:O?"Active":"Not Mounted"})]}),(0,t.jsxs)("div",{className:a.default.envRow,style:{opacity:z?1:.6},children:[(0,t.jsx)("span",{className:a.default.envName,children:"🌐 Remote VM (SSH)"}),(0,t.jsx)("span",{className:a.default.envStatus,style:{color:z?"var(--success)":"var(--muted)"},children:z?"Active":"Disconnected"})]})]})]}),(0,t.jsxs)("section",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[(0,t.jsxs)("button",{className:a.default.quickLaunchBtn,onClick:()=>{S(!1),w(!0)},disabled:h,style:{background:"linear-gradient(135deg, hsl(262, 83%, 60%) 0%, hsl(195, 100%, 45%) 100%)",border:"none"},children:[(0,t.jsx)("span",{children:"🤖"}),(0,t.jsx)("span",{children:"Launch Claude PTY"})]}),(0,t.jsxs)("button",{className:a.default.quickLaunchBtn,onClick:()=>{S(!0),w(!0)},disabled:h,style:{background:"linear-gradient(135deg, hsl(170, 72%, 40%) 0%, hsl(195, 100%, 40%) 100%)",border:"none"},children:[(0,t.jsx)("span",{children:"🐳"}),(0,t.jsx)("span",{children:"Launch Docker PTY"})]}),(0,t.jsxs)("button",{className:a.default.quickLaunchBtn,onClick:()=>g(!0),disabled:h,style:{background:"linear-gradient(135deg, hsl(38, 92%, 50%) 0%, hsl(0, 84%, 60%) 100%)",border:"none"},children:[(0,t.jsx)("span",{children:"🌐"}),(0,t.jsx)("span",{children:"Launch SSH PTY"})]}),(0,t.jsxs)("button",{className:a.default.quickLaunchBtn,onClick:()=>{v(!1),b(!0)},disabled:h,style:{background:"linear-gradient(135deg, hsl(210, 80%, 45%) 0%, hsl(262, 80%, 55%) 100%)",border:"none"},children:[(0,t.jsx)("span",{children:"🐍"}),(0,t.jsx)("span",{children:"Launch Aider PTY"})]}),(0,t.jsxs)("button",{className:a.default.quickLaunchBtn,onClick:()=>{v(!0),b(!0)},disabled:h,style:{background:"linear-gradient(135deg, hsl(195, 100%, 40%) 0%, hsl(262, 80%, 55%) 100%)",border:"none"},children:[(0,t.jsx)("span",{children:"🐳"}),(0,t.jsx)("span",{children:"Launch Aider Docker"})]})]}),(0,t.jsxs)("section",{className:"card",style:{padding:"1.5rem",display:"flex",flexDirection:"column",gap:"0.75rem"},children:[(0,t.jsx)("h3",{style:{fontSize:"1rem",fontWeight:700},children:"Quick Actions"}),(0,t.jsxs)("ul",{style:{listStyle:"none",fontSize:"0.875rem",display:"flex",flexDirection:"column",gap:"0.5rem",color:"var(--muted)"},children:[(0,t.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:"Configure global API Keys"}),(0,t.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]}),(0,t.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:"Edit rules templates"}),(0,t.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]}),(0,t.jsxs)("li",{style:{display:"flex",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:"Inspect process locks"}),(0,t.jsx)("span",{style:{color:"var(--primary)",cursor:"pointer"},children:"→"})]})]}),(0,t.jsxs)("div",{style:{marginTop:"1.2rem",textAlign:"center",fontSize:"0.72rem",color:"var(--muted)"},children:["Need to troubleshoot?"," ",(0,t.jsx)("span",{onClick:()=>q("mock"),style:{color:"var(--primary)",cursor:"pointer",textDecoration:"underline"},children:"Launch simulated playground sandbox"})]})]})]})]}),(0,t.jsxs)("footer",{className:a.default.footer,children:[(0,t.jsxs)("span",{children:["NeuralLoom v",P," — Experimental AI Orchestrator Bridge"]}),(0,t.jsxs)("span",{children:["Directory: ",C||"Loading..."]})]}),f&&(0,t.jsx)(i,{onClose:()=>g(!1),onConfirmLaunch:()=>{g(!1),q("claude-ssh")}}),y&&(0,t.jsx)(d,{onClose:()=>b(!1),isDocker:j,onConfirmLaunch:()=>{b(!1),q(j?"aider-docker":"aider")}}),_&&(0,t.jsx)(c,{onClose:()=>w(!1),isDocker:k,onConfirmLaunch:(e,t,r)=>{w(!1),q(k?"claude-docker":"claude",e,t,r)}})]})}])},33779,e=>{e.v(t=>Promise.all(["static/chunks/03g6xpslyid3~.js","static/chunks/070hz362~_h8n.js","static/chunks/0ga14ztvrhau2.css"].map(t=>e.l(t))).then(()=>t(37314)))},39429,e=>{e.v(t=>Promise.all(["static/chunks/16w4~t4h7gk13.js"].map(t=>e.l(t))).then(()=>t(1985)))},56915,e=>{e.v(t=>Promise.all(["static/chunks/0lnobx4eh3~-_.js"].map(t=>e.l(t))).then(()=>t(99026)))},78716,e=>{e.v(t=>Promise.all(["static/chunks/0k2co3uj4w81_.js"].map(t=>e.l(t))).then(()=>t(9949)))},33789,e=>{e.v(t=>Promise.all(["static/chunks/076_b43_kienv.js"].map(t=>e.l(t))).then(()=>t(20032)))},78003,e=>{e.v(t=>Promise.all(["static/chunks/0eidfx-s54367.js","static/chunks/070hz362~_h8n.js","static/chunks/0p28yw2f2duy-.js","static/chunks/0ga14ztvrhau2.css"].map(t=>e.l(t))).then(()=>t(97722)))}]);