neural-loom 0.2.51 → 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.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +5 -5
- package/.next/cache/.previewinfo +1 -1
- package/.next/cache/.rscinfo +1 -1
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/diagnostics/route-bundle-stats.json +6 -6
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page/build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page/build-manifest.json +2 -2
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/page/build-manifest.json +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0.ptwor._.js +6 -6
- package/.next/server/chunks/[root-of-the-server]__0.ptwor._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__00l5btc._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__00l5btc._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__06men8g._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__06men8g._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0co.g5k._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0co.g5k._.js.map +1 -1
- package/.next/server/chunks/ssr/_0t7oqy6._.js +2 -2
- package/.next/server/chunks/ssr/_0t7oqy6._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +5 -5
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{0fpki3y6aj230.js → 0ljspdd3cv1ft.js} +1 -1
- package/.next/static/chunks/0z0d3-6aolefr.js +6 -0
- package/.next/static/chunks/{turbopack-08fpdsd.-ns2y.js → turbopack-0.g.4cakdth0h.js} +1 -1
- package/.next/trace +1 -1
- package/.next/trace-build +1 -1
- package/package.json +1 -1
- package/src/app/components/DbExplorer.tsx +4 -2
- package/src/lib/sql/ConnectionManager.ts +41 -0
- package/src/lib/sql/McpServer.ts +40 -14
- package/.next/static/chunks/0bb9anc7wd3_e.js +0 -6
- /package/.next/static/{iopRcvtUwbEGa5VOyZAQh → WLQchpoAU3XMEr3Ep5w4b}/_buildManifest.js +0 -0
- /package/.next/static/{iopRcvtUwbEGa5VOyZAQh → WLQchpoAU3XMEr3Ep5w4b}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{iopRcvtUwbEGa5VOyZAQh → WLQchpoAU3XMEr3Ep5w4b}/_ssgManifest.js +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable react-hooks/set-state-in-effect, react-hooks/exhaustive-deps, @typescript-eslint/no-explicit-any */
|
|
3
3
|
|
|
4
4
|
import React, { useEffect, useState } from "react";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
5
6
|
|
|
6
7
|
interface DbConnectionProfile {
|
|
7
8
|
id: string;
|
|
@@ -617,7 +618,7 @@ export default function DbExplorer({ workspaceRoot }: DbExplorerProps) {
|
|
|
617
618
|
</div>
|
|
618
619
|
|
|
619
620
|
{/* Add Connection Profile Modal */}
|
|
620
|
-
{showAddModal && (
|
|
621
|
+
{showAddModal && typeof document !== "undefined" && createPortal(
|
|
621
622
|
<div style={styles.modalOverlay}>
|
|
622
623
|
<div style={styles.modalContent}>
|
|
623
624
|
<h3 style={{ margin: "0 0 1rem 0", display: "flex", justifyContent: "space-between" }}>
|
|
@@ -814,7 +815,8 @@ export default function DbExplorer({ workspaceRoot }: DbExplorerProps) {
|
|
|
814
815
|
</div>
|
|
815
816
|
</form>
|
|
816
817
|
</div>
|
|
817
|
-
</div
|
|
818
|
+
</div>,
|
|
819
|
+
document.body
|
|
818
820
|
)}
|
|
819
821
|
</div>
|
|
820
822
|
);
|
|
@@ -201,6 +201,47 @@ export class ConnectionManager {
|
|
|
201
201
|
return { adapter, profile };
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
public static async getAdapterById(
|
|
205
|
+
profileIdOrName: string,
|
|
206
|
+
workspaceRoot?: string
|
|
207
|
+
): Promise<{ adapter: DbAdapter; profile: DbConnectionProfile } | null> {
|
|
208
|
+
const { global, workspace } = await this.getProfiles(workspaceRoot);
|
|
209
|
+
|
|
210
|
+
let profile = workspace.find((p) => p.id === profileIdOrName);
|
|
211
|
+
let isActiveGlobal = false;
|
|
212
|
+
|
|
213
|
+
if (!profile) {
|
|
214
|
+
profile = global.find((p) => p.id === profileIdOrName);
|
|
215
|
+
isActiveGlobal = true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!profile) {
|
|
219
|
+
profile = workspace.find(
|
|
220
|
+
(p) => p.name.toLowerCase() === profileIdOrName.toLowerCase()
|
|
221
|
+
);
|
|
222
|
+
isActiveGlobal = false;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (!profile) {
|
|
226
|
+
profile = global.find(
|
|
227
|
+
(p) => p.name.toLowerCase() === profileIdOrName.toLowerCase()
|
|
228
|
+
);
|
|
229
|
+
isActiveGlobal = true;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!profile) return null;
|
|
233
|
+
|
|
234
|
+
const cacheKey = `${isActiveGlobal ? "global" : "ws"}:${profile.id}`;
|
|
235
|
+
const cached = this.activeInstances.get(cacheKey);
|
|
236
|
+
if (cached) {
|
|
237
|
+
return { adapter: cached, profile };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const adapter = this.createAdapter(profile, workspaceRoot);
|
|
241
|
+
this.activeInstances.set(cacheKey, adapter);
|
|
242
|
+
return { adapter, profile };
|
|
243
|
+
}
|
|
244
|
+
|
|
204
245
|
public static async closeAll(): Promise<void> {
|
|
205
246
|
for (const [, instance] of this.activeInstances.entries()) {
|
|
206
247
|
await instance.disconnect().catch(console.error);
|
package/src/lib/sql/McpServer.ts
CHANGED
|
@@ -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
|
|
81
|
-
inputSchema: {
|
|
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: {
|
|
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
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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;
|
|
@@ -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),s=e.i(71645);let r={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"},O={height:"180px",borderBottom:"1px solid var(--border)",position:"relative",flexShrink:0},D={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"},q={padding:"1rem",borderRadius:"8px",backgroundColor:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",overflowY:"auto"},A={margin:0,fontFamily:"monospace",fontSize:"0.8rem",color:"#f87171",whiteSpace:"pre-wrap"},B={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"},Q={backgroundColor:"transparent"},J={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)"},es={display:"flex",flexDirection:"column",gap:"0.35rem",marginBottom:"1rem"},er={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,s.useState)({global:[],workspace:[]}),[em,eh]=(0,s.useState)(null),[ex,ef]=(0,s.useState)(!0),[eg,ey]=(0,s.useState)([]),[eb,ej]=(0,s.useState)(null),[ev,e_]=(0,s.useState)({}),[ew,ek]=(0,s.useState)(!1),[eS,eC]=(0,s.useState)("SELECT * FROM sqlite_master;"),[eN,eR]=(0,s.useState)(!1),[eT,eP]=(0,s.useState)(null),[eW,eE]=(0,s.useState)(null),[eL,eI]=(0,s.useState)(!1),[eO,eD]=(0,s.useState)(!1),[ez,eq]=(0,s.useState)({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),[eA,eB]=(0,s.useState)(!1),[eF,eM]=(0,s.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 s=await fetch(`/api/sql/schema?action=describe_table&table=${encodeURIComponent(t)}&root=${encodeURIComponent(e)}`);if(s.ok){let e=await s.json();e.success&&(e_(s=>({...s,[t]:e.columns})),ej(t))}}catch(e){console.error(`Failed to load columns for table ${t}:`,e)}};(0,s.useEffect)(()=>{eH()},[e]),(0,s.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';"):"mssql"===e.type?eC("SELECT * FROM sys.tables;"):eC("SELECT * FROM information_schema.tables LIMIT 10;"))},[em,ex,eu.global.length,eu.workspace.length]);let eY=async(t,s)=>{try{(await fetch("/api/sql/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"set_active",profileId:t,isGlobal:s,root:e})})).ok&&(eh(t),ef(s))}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})}),s=await t.json();s.success?eM({success:!0,message:"Connection test successful!"}):eM({success:!1,message:s.error||"Connection test failed."})}catch(e){eM({success:!1,message:e.message||"Failed to make test query."})}},eQ=async t=>{if(t.preventDefault(),!ez.name||!ez.type)return;eB(!0);let s=ez.id||`profile_${Math.random().toString(36).substring(7)}`,r={...ez,id:s,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:r,isGlobal:eO,root:e})})).ok&&(await eH(),eI(!1),em||eY(s,eO))}catch(e){console.error("Failed to save profile:",e)}finally{eB(!1)}},eJ=async(t,s)=>{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:s,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})}),s=await t.json();t.ok&&s.success?(eE({rows:s.rows||[],fields:s.fields||[],durationMs:s.durationMs||0,affectedRows:s.affectedRows}),(eS.toLowerCase().includes("create table")||eS.toLowerCase().includes("drop table")||eS.toLowerCase().includes("alter table"))&&eG()):eP(s.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:r,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),eq({id:"",name:"",type:"sqlite",filepath:"./dev.db",host:"localhost",port:5432,database:"postgres",username:"postgres",password:"",ssl:!1,readOnly:!0}),eD(!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(),eJ(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(),eJ(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:O,children:(0,t.jsx)("textarea",{style:D,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:q,children:[(0,t.jsx)("h4",{style:{margin:"0 0 0.5rem 0",color:"var(--danger)"},children:"⚠️ Execution Error"}),(0,t.jsx)("pre",{style:A,children:eT}),eT.includes("not installed")&&(0,t.jsxs)("div",{style:B,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":eV?.type==="mysql"?"npm install mysql2":"npm install mssql"})]})]}),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,s)=>(0,t.jsx)("tr",{style:s%2==0?Q:J,children:eW.fields.map(s=>(0,t.jsx)("td",{style:U,children:null===e[s]?"NULL":"object"==typeof e[s]?JSON.stringify(e[s]):String(e[s])},s))},s))})]})}):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:eQ,children:[(0,t.jsxs)("div",{style:es,children:[(0,t.jsx)("label",{style:er,children:"Profile Name"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.name,onChange:e=>eq(t=>({...t,name:e.target.value})),placeholder:"e.g. Local Postgres, Dev SQLite"})]}),(0,t.jsxs)("div",{style:es,children:[(0,t.jsx)("label",{style:er,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:!eO,onChange:()=>eD(!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:eO,onChange:()=>eD(!0)}),"Global User Profile"]})]})]}),(0,t.jsxs)("div",{style:es,children:[(0,t.jsx)("label",{style:er,children:"Database Type"}),(0,t.jsxs)("select",{style:en,value:ez.type,onChange:e=>{let t=e.target.value,s=5432;"mysql"===t&&(s=3306),"mssql"===t&&(s=1433),eq(e=>({...e,type:t,filepath:"sqlite"===t?"./dev.db":void 0,port:"sqlite"!==t?s:void 0,database:"sqlite"===t?void 0:"mssql"===t?"master":"postgres"===t?"postgres":"",username:"sqlite"===t?void 0:"mssql"===t?"sa":"postgres"===t?"postgres":"root"}))},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"}),(0,t.jsx)("option",{value:"mssql",children:"Microsoft SQL Server"})]})]}),"sqlite"===ez.type?(0,t.jsxs)("div",{style:es,children:[(0,t.jsx)("label",{style:er,children:"Database File Path"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.filepath||"",onChange:e=>eq(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:{...es,flex:3},children:[(0,t.jsx)("label",{style:er,children:"Host IP Address"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.host||"",onChange:e=>eq(t=>({...t,host:e.target.value})),placeholder:"localhost or IP"})]}),(0,t.jsxs)("div",{style:{...es,flex:1},children:[(0,t.jsx)("label",{style:er,children:"Port"}),(0,t.jsx)("input",{style:ea,type:"number",required:!0,value:ez.port||0,onChange:e=>eq(t=>({...t,port:parseInt(e.target.value)}))})]})]}),(0,t.jsxs)("div",{style:es,children:[(0,t.jsx)("label",{style:er,children:"Database Name"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.database||"",onChange:e=>eq(t=>({...t,database:e.target.value}))})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"1rem"},children:[(0,t.jsxs)("div",{style:{...es,flex:1},children:[(0,t.jsx)("label",{style:er,children:"Username"}),(0,t.jsx)("input",{style:ea,type:"text",required:!0,value:ez.username||"",onChange:e=>eq(t=>({...t,username:e.target.value}))})]}),(0,t.jsxs)("div",{style:{...es,flex:1},children:[(0,t.jsx)("label",{style:er,children:"Password"}),(0,t.jsx)("input",{style:ea,type:"password",value:ez.password||"",onChange:e=>eq(t=>({...t,password:e.target.value}))})]})]}),("postgres"===ez.type||"mssql"===ez.type)&&(0,t.jsx)("div",{style:es,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=>eq(t=>({...t,ssl:e.target.checked}))}),"Require SSL Secure Connection"]})})]}),(0,t.jsx)("div",{style:es,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=>eq(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:eA,children:eA?"Saving...":"Save Profile"})]})]})]})]})})]})}])},67585,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"BailoutToCSR",{enumerable:!0,get:function(){return a}});let r=e.r(32061);function a({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new r.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},9885,(e,t,s)=>{"use strict";function r(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"encodeURIPath",{enumerable:!0,get:function(){return r}})},52157,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"PreloadChunks",{enumerable:!0,get:function(){return i}});let r=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 s=[];if(t.reactLoadableManifest&&e){let r=t.reactLoadableManifest;for(let t of e){if(!r[t])continue;let e=r[t].files;s.push(...e)}}if(0===s.length)return null;let d=(0,o.getAssetTokenQuery)();return(0,r.jsx)(r.Fragment,{children:s.map(e=>{let s=`${t.assetPrefix}/_next/${(0,l.encodeURIPath)(e)}${d}`;return e.endsWith(".css")?(0,r.jsx)("link",{precedence:"dynamic",href:s,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,a.preload)(s,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},69093,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"default",{enumerable:!0,get:function(){return d}});let r=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},s=(0,a.lazy)(()=>t.loader().then(o)),d=t.loading;function c(e){let o=d?(0,r.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,i=!t.ssr||!!t.loading,c=i?a.Suspense:a.Fragment,u=t.ssr?(0,r.jsxs)(r.Fragment,{children:["u"<typeof window?(0,r.jsx)(l.PreloadChunks,{moduleIds:t.modules}):null,(0,r.jsx)(s,{...e})]}):(0,r.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(s,{...e})});return(0,r.jsx)(c,{...i?{fallback:o}:{},children:u})}return c.displayName="LoadableComponent",c}},70703,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"default",{enumerable:!0,get:function(){return a}});let r=e.r(55682)._(e.r(69093));function a(e,t){let s={};"function"==typeof e&&(s.loader=e);let a={...s,...t};return(0,r.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof s.default||"object"==typeof s.default&&null!==s.default)&&void 0===s.default.__esModule&&(Object.defineProperty(s.default,"__esModule",{value:!0}),Object.assign(s.default,s),t.exports=s.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),s=e.i(71645),r=e.i(70703),a=e.i(20897),n=e.i(66381);let l=(0,r.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,r.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,r.default)(()=>e.A(56915),{loadableGenerated:{modules:[99026]},ssr:!1}),d=(0,r.default)(()=>e.A(78716),{loadableGenerated:{modules:[9949]},ssr:!1}),c=(0,r.default)(()=>e.A(33789),{loadableGenerated:{modules:[20032]},ssr:!1}),u=(0,r.default)(()=>e.A(78003),{loadableGenerated:{modules:[97722]},ssr:!1});e.s(["default",0,function(){let[e,r]=(0,s.useState)([]),[p,m]=(0,s.useState)(null),[h,x]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[y,b]=(0,s.useState)(!1),[j,v]=(0,s.useState)(!1),[_,w]=(0,s.useState)(!1),[k,S]=(0,s.useState)(!1),[C,N]=(0,s.useState)(""),[R,T]=(0,s.useState)(3001),[P,W]=(0,s.useState)("0.2.19"),[E,L]=(0,s.useState)(null),I=e.filter(e=>"workspace-terminal"!==e.id),O=e.find(e=>e.id===p),D=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),q=async()=>{try{let e=await fetch("/api/sessions"),t=await e.json();t.sessions&&r(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)}},A=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,s.useEffect)(()=>{(async()=>{await q(),await A()})(),"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(q,4e3);return()=>clearInterval(e)},[]);let B=async(e,t,s,r)=>{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:s,scopedDirs:r};if(("aider"===e||"aider-docker"===e)&&!s)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 q(),m(o.session.id),L({type:e,name:a,workspaceRoot:s,scopedDirs:r}))}catch(e){console.error("Failed to launch session:",e)}finally{x(!1)}},F=async(e,t=!1)=>{try{let s=await fetch("/api/sessions/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,delete:t})});(await s.json()).success&&(t&&p===e&&m(null),await q())}catch(e){console.error("Failed to stop session:",e)}};return(0,t.jsxs)("div",{className:`${a.default.container} ${O?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"})]})]}),O?(0,t.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:(0,t.jsx)(u,{sessionId:O.id,workspaceRoot:O.workspaceRoot||"",scopedDirs:O.scopedDirs||[],onClose:()=>m(null),sessions:e,onSwitchSession:e=>m(e),onRefreshSessions:q,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:()=>{B(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:()=>B("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 q();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:D?1:.6},children:[(0,t.jsx)("span",{className:a.default.envName,children:"🐳 Docker Sandbox"}),(0,t.jsx)("span",{className:a.default.envStatus,style:{color:D?"var(--success)":"var(--muted)"},children:D?"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:()=>B("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),B("claude-ssh")}}),y&&(0,t.jsx)(d,{onClose:()=>b(!1),isDocker:j,onConfirmLaunch:()=>{b(!1),B(j?"aider-docker":"aider")}}),_&&(0,t.jsx)(c,{onClose:()=>w(!1),isDocker:k,onConfirmLaunch:(e,t,s)=>{w(!1),B(k?"claude-docker":"claude",e,t,s)}})]})}])},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)))}]);
|
|
File without changes
|
/package/.next/static/{iopRcvtUwbEGa5VOyZAQh → WLQchpoAU3XMEr3Ep5w4b}/_clientMiddlewareManifest.js
RENAMED
|
File without changes
|
|
File without changes
|