neural-loom 0.2.53 → 0.2.55
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 +3 -3
- 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 +2 -2
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- 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.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/api/context/aider/route.js.nft.json +1 -1
- package/.next/server/app/api/context/claude/route.js.nft.json +1 -1
- package/.next/server/app/api/context/route.js.nft.json +1 -1
- package/.next/server/app/api/context/ssh/route.js.nft.json +1 -1
- package/.next/server/app/api/recents/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/inject/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/input/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/launch/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/scope/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/start/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/stats/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/stop/route.js.nft.json +1 -1
- package/.next/server/app/api/sql/connections/route.js.nft.json +1 -1
- package/.next/server/app/api/sql/mcp/route.js.nft.json +1 -1
- package/.next/server/app/api/sql/query/route.js.nft.json +1 -1
- package/.next/server/app/api/sql/schema/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +3 -3
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +3 -3
- 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 +2 -2
- package/.next/server/app/page/react-loadable-manifest.json +3 -3
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0.ptwor._.js +8 -8
- package/.next/server/chunks/[root-of-the-server]__0.ptwor._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__00l5btc._.js +5 -5
- package/.next/server/chunks/[root-of-the-server]__00l5btc._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__06men8g._.js +5 -5
- 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 +5 -5
- package/.next/server/chunks/[root-of-the-server]__0co.g5k._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0d0pykb._.js +12 -12
- package/.next/server/chunks/[root-of-the-server]__0d0pykb._.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 +3 -3
- 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/{070hz362~_h8n.js → 0-vb7c~yrtpon.js} +1 -1
- package/.next/static/chunks/{0m-_sw1425nkp.css → 0hoyc~vbuqe0t.css} +1 -1
- package/.next/static/chunks/0st7_hghhyuv4.js +1 -0
- package/.next/static/chunks/0ulfmf9nsz_o-.js +6 -0
- package/.next/trace +1 -1
- package/.next/trace-build +1 -1
- package/README.md +4 -0
- package/package.json +1 -1
- package/public/ui-audit.html +1509 -0
- package/src/app/components/IdeLayout.tsx +37 -1
- package/src/app/components/TerminalConsole.tsx +3 -0
- package/src/app/page.module.css +55 -0
- package/src/app/page.tsx +21 -3
- package/src/lib/agents/AgentRunner.ts +74 -0
- package/src/lib/agents/AiderRunner.ts +4 -2
- package/src/lib/agents/ClaudeRunner.ts +4 -3
- package/src/lib/agents/DockerRunner.ts +4 -2
- package/src/lib/agents/MockRunner.ts +2 -1
- package/src/lib/agents/SSHRunner.ts +4 -2
- package/src/lib/agents/ShellRunner.ts +4 -1
- package/src/lib/sql/adapters/MssqlAdapter.ts +1 -1
- package/src/lib/sql/adapters/MysqlAdapter.ts +1 -1
- package/src/lib/sql/adapters/PostgresAdapter.ts +1 -1
- package/src/lib/sql/adapters/SqliteAdapter.ts +1 -1
- package/.next/static/chunks/0p28yw2f2duy-.js +0 -1
- package/.next/static/chunks/0z0d3-6aolefr.js +0 -6
- /package/.next/static/{WLQchpoAU3XMEr3Ep5w4b → PtixAwrSwsBc6DJtUuNCf}/_buildManifest.js +0 -0
- /package/.next/static/{WLQchpoAU3XMEr3Ep5w4b → PtixAwrSwsBc6DJtUuNCf}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{WLQchpoAU3XMEr3Ep5w4b → PtixAwrSwsBc6DJtUuNCf}/_ssgManifest.js +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,a)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,a)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,a)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},14747,(e,t,a)=>{t.exports=e.x("path",()=>require("path"))},46786,(e,t,a)=>{t.exports=e.x("os",()=>require("os"))},98003,e=>{"use strict";var t=e.i(22734),a=e.i(14747),n=e.i(46786);let r=null;function s(
|
|
1
|
+
module.exports=[93695,(e,t,a)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,a)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,a)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},14747,(e,t,a)=>{t.exports=e.x("path",()=>require("path"))},46786,(e,t,a)=>{t.exports=e.x("os",()=>require("os"))},98003,e=>{"use strict";var t=e.i(22734),a=e.i(14747),n=e.i(46786);let r=null;function s(){if(r)return r;let e=a.default.join(process.env.ORIGINAL_CWD||process.cwd(),".ai","neural-loom");try{t.default.existsSync(e)||t.default.mkdirSync(e,{recursive:!0});let n=a.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return t.default.writeFileSync(n,"test"),t.default.unlinkSync(n),r=e,e}catch(i){console.warn(`[Config] Primary config dir is not writable (${e}). Falling back to home directory.`);let s=a.default.join(n.default.homedir(),".ai","neural-loom");try{return t.default.existsSync(s)||t.default.mkdirSync(s,{recursive:!0}),r=s,s}catch(t){return console.error("[Config] Fallback config dir is also not writable!",t),r=e,e}}}function i(e){try{t.default.existsSync(e)||t.default.mkdirSync(e,{recursive:!0});let n=a.default.join(e,".write-test-"+Math.random().toString(36).substring(7));return t.default.writeFileSync(n,"test"),t.default.unlinkSync(n),!0}catch{return!1}}function o(e){let t=e.toLowerCase().replace(/\\/g,"/");return t.includes("/program files")||t.includes("/windows/system32")||t.includes("/winnt")||t.startsWith("/usr/")||t.startsWith("/bin/")||t.startsWith("/sbin/")||t.startsWith("/etc/")||t.startsWith("/var/")}function l(){let e=process.env.ORIGINAL_CWD||process.cwd();if(i(e)&&!o(e))return e.replace(/\\/g,"/");let r=n.default.homedir();for(let e of[a.default.join(r,"OneDrive","Projects"),a.default.join(r,"Projects"),a.default.join(r,"source","repos"),a.default.join(r,"Documents"),r])try{if(t.default.existsSync(e)&&i(e))return e.replace(/\\/g,"/")}catch{}return r.replace(/\\/g,"/")}e.s(["getConfigDir",0,s,"getDefaultWorkspaceRoot",0,l,"isDirWritable",0,i])},41230,__turbopack_context__=>{"use strict";var __TURBOPACK__imported__module__22734__=__turbopack_context__.i(22734),__TURBOPACK__imported__module__14747__=__turbopack_context__.i(14747),__TURBOPACK__imported__module__98003__=__turbopack_context__.i(98003),__TURBOPACK__imported__module__14747__1=__TURBOPACK__imported__module__14747__,__TURBOPACK__imported__module__22734__1=__TURBOPACK__imported__module__22734__;class DbAdapter{config;constructor(e){this.config=e}async getSchemaSummary(){try{let e=await this.listTables(),t=`### Database Schema Summary
|
|
2
2
|
|
|
3
3
|
`;if(0===e.length)return t+"*No tables found in this database.*";for(let a of e){t+=`#### Table: \`${a.name}\` (${a.type})
|
|
4
4
|
`;let e=await this.describeTable(a.name);for(let a of(t+=`| Column | Type | Nullable | Key | References |
|
|
5
5
|
|---|---|---|---|---|
|
|
6
6
|
`,e)){let e=a.isPrimaryKey?"PK":a.isForeignKey?"FK":"",n=a.isForeignKey?`\`${a.referencedTable}.${a.referencedColumn}\``:"";t+=`| \`${a.name}\` | \`${a.type}\` | ${a.nullable?"Yes":"No"} | ${e} | ${n} |
|
|
7
7
|
`}t+=`
|
|
8
|
-
`}return t}catch(e){return`Failed to reflect schema summary: ${e instanceof Error?e.message:String(e)}`}}}class
|
|
8
|
+
`}return t}catch(e){return`Failed to reflect schema summary: ${e instanceof Error?e.message:String(e)}`}}}class SqliteAdapter extends DbAdapter{db=null;resolvedPath="";constructor(e,t){super(e);const a=e.filepath||"dev.db";if(__TURBOPACK__imported__module__14747__1.default.isAbsolute(a))this.resolvedPath=a.replace(/\\/g,"/");else{const e=t||process.cwd();this.resolvedPath=__TURBOPACK__imported__module__14747__1.default.resolve(e,a).replace(/\\/g,"/")}}async connect(){if(this.db)return;let dir=__TURBOPACK__imported__module__14747__1.default.dirname(this.resolvedPath);__TURBOPACK__imported__module__22734__1.default.existsSync(dir)||__TURBOPACK__imported__module__22734__1.default.mkdirSync(dir,{recursive:!0});try{let Database;try{Database=eval("require")("better-sqlite3")}catch(err){throw Error("SQLite driver 'better-sqlite3' is not installed. Please run `npm install better-sqlite3` in the neural-loom environment.")}this.db=new Database(this.resolvedPath)}catch(err){throw console.error("[SqliteAdapter] Connect failed:",err),err}}async query(e,t=[]){await this.connect();try{if(e.trim().toLowerCase().startsWith("select")||e.trim().toLowerCase().startsWith("pragma")||e.trim().toLowerCase().startsWith("explain")){let a=this.db.prepare(e).all(t),n=a.length>0?Object.keys(a[0]):[];return{rows:a,fields:n}}{let a=this.db.prepare(e).run(t);return{rows:[],affectedRows:a.changes}}}catch(e){throw console.error("[SqliteAdapter] Query execution failed:",e),e}}async listTables(){let e="SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%'";return(await this.query(e)).rows.map(e=>({name:e.name,type:"table"===e.type?"table":"view"}))}async describeTable(e){await this.connect();let t=this.db.prepare(`PRAGMA table_info(\`${e}\`)`).all(),a=this.db.prepare(`PRAGMA foreign_key_list(\`${e}\`)`).all();return t.map(e=>{let t=a.find(t=>t.from===e.name);return{name:e.name,type:e.type||"TEXT",nullable:0===e.notnull,defaultValue:e.dflt_value,isPrimaryKey:e.pk>0,isForeignKey:!!t,referencedTable:t?t.table:null,referencedColumn:t?t.to:null}})}async disconnect(){this.db&&(this.db.close(),this.db=null)}}class PostgresAdapter extends DbAdapter{client=null;schema="public";constructor(e){super(e),this.schema=e.schema||"public"}async connect(){if(!this.client)try{let ClientClass;try{let pg=eval("require")("pg");ClientClass=pg.Client}catch(err){throw Error("PostgreSQL driver 'pg' is not installed. Please run `npm install pg` in the neural-loom environment.")}this.client=new ClientClass({host:this.config.host||"localhost",port:this.config.port||5432,database:this.config.database||"postgres",user:this.config.username||"postgres",password:this.config.password||"",ssl:this.config.ssl?this.config.ssl:void 0}),await this.client.connect()}catch(err){throw console.error("[PostgresAdapter] Connect failed:",err),this.client=null,err}}async query(e,t=[]){await this.connect();try{let a=await this.client.query(e,t),n=a.rows||[],r=a.fields?a.fields.map(e=>e.name):[];return{rows:n,fields:r,affectedRows:null!==a.rowCount?a.rowCount:void 0}}catch(e){throw console.error("[PostgresAdapter] Query failed:",e),e}}async listTables(){let e=`
|
|
9
9
|
SELECT table_name as name, table_type as type
|
|
10
10
|
FROM information_schema.tables
|
|
11
11
|
WHERE table_schema = $1 AND table_type IN ('BASE TABLE', 'VIEW')
|
|
@@ -45,7 +45,7 @@ module.exports=[93695,(e,t,a)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-
|
|
|
45
45
|
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
46
46
|
AND tc.table_schema = $1
|
|
47
47
|
AND tc.table_name = $2
|
|
48
|
-
`,n=await this.query(t,[this.schema,e]),r=await this.query(a,[this.schema,e]);return n.rows.map(e=>{let t=r.rows.find(t=>t.local_column===e.name);return{name:e.name,type:e.type,nullable:"YES"===e.nullable,defaultValue:e.default_value,isPrimaryKey:e.is_pk,isForeignKey:!!t,referencedTable:t?t.foreign_table:null,referencedColumn:t?t.foreign_column:null}})}async disconnect(){this.client&&(await this.client.end(),this.client=null)}}class
|
|
48
|
+
`,n=await this.query(t,[this.schema,e]),r=await this.query(a,[this.schema,e]);return n.rows.map(e=>{let t=r.rows.find(t=>t.local_column===e.name);return{name:e.name,type:e.type,nullable:"YES"===e.nullable,defaultValue:e.default_value,isPrimaryKey:e.is_pk,isForeignKey:!!t,referencedTable:t?t.foreign_table:null,referencedColumn:t?t.foreign_column:null}})}async disconnect(){this.client&&(await this.client.end(),this.client=null)}}class MysqlAdapter extends DbAdapter{connection=null;dbName="";constructor(e){super(e),this.dbName=e.database||""}async connect(){if(!this.connection)try{let mysql;try{mysql=eval("require")("mysql2/promise")}catch(err){throw Error("MySQL driver 'mysql2' is not installed. Please run `npm install mysql2` in the neural-loom environment.")}this.connection=await mysql.createConnection({host:this.config.host||"localhost",port:this.config.port||3306,database:this.dbName,user:this.config.username||"root",password:this.config.password||"",ssl:this.config.ssl?this.config.ssl:void 0})}catch(err){throw console.error("[MysqlAdapter] Connect failed:",err),this.connection=null,err}}async query(e,t=[]){await this.connect();try{let[a,n]=await this.connection.execute(e,t),r=Array.isArray(a);return{rows:r?a:[],fields:n?n.map(e=>e.name):[],affectedRows:r||void 0===a.affectedRows?void 0:a.affectedRows}}catch(e){throw console.error("[MysqlAdapter] Query failed:",e),e}}async listTables(){let e=`
|
|
49
49
|
SELECT table_name as name, table_type as type
|
|
50
50
|
FROM information_schema.tables
|
|
51
51
|
WHERE table_schema = ? AND table_type IN ('BASE TABLE', 'VIEW')
|
|
@@ -69,7 +69,7 @@ module.exports=[93695,(e,t,a)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-
|
|
|
69
69
|
WHERE table_schema = ?
|
|
70
70
|
AND table_name = ?
|
|
71
71
|
AND referenced_table_name IS NOT NULL
|
|
72
|
-
`,n=await this.query(t,[this.dbName,e]),r=await this.query(a,[this.dbName,e]);return n.rows.map(e=>{let t=r.rows.find(t=>t.local_column===e.name);return{name:e.name,type:e.type||"VARCHAR",nullable:"YES"===e.nullable,defaultValue:e.default_value,isPrimaryKey:"PRI"===e.col_key,isForeignKey:!!t,referencedTable:t?t.foreign_table:null,referencedColumn:t?t.foreign_column:null}})}async disconnect(){this.connection&&(await this.connection.end(),this.connection=null)}}class
|
|
72
|
+
`,n=await this.query(t,[this.dbName,e]),r=await this.query(a,[this.dbName,e]);return n.rows.map(e=>{let t=r.rows.find(t=>t.local_column===e.name);return{name:e.name,type:e.type||"VARCHAR",nullable:"YES"===e.nullable,defaultValue:e.default_value,isPrimaryKey:"PRI"===e.col_key,isForeignKey:!!t,referencedTable:t?t.foreign_table:null,referencedColumn:t?t.foreign_column:null}})}async disconnect(){this.connection&&(await this.connection.end(),this.connection=null)}}class MssqlAdapter extends DbAdapter{pool=null;schema="dbo";constructor(e){super(e),this.schema=e.schema||"dbo"}async connect(){if(!this.pool)try{let mssql;try{mssql=eval("require")("mssql")}catch(err){throw Error("Microsoft SQL Server driver 'mssql' is not installed. Please run `npm install mssql` in the neural-loom environment.")}this.pool=await mssql.connect({server:this.config.host||"localhost",port:this.config.port||1433,database:this.config.database,user:this.config.username,password:this.config.password,options:{encrypt:this.config.ssl||!1,trustServerCertificate:!0}})}catch(err){throw console.error("[MssqlAdapter] Connect failed:",err),this.pool=null,err}}async query(e,t=[]){await this.connect();try{let a=this.pool.request();t.length>0&&(a.input("schema",t[0]),t.length>1&&a.input("table",t[1]));let n=await a.query(e),r=n.recordset||[],s=n.recordset&&n.recordset.columns?Object.keys(n.recordset.columns):r.length>0?Object.keys(r[0]):[];return{rows:r,fields:s,affectedRows:n.rowsAffected?n.rowsAffected[0]:void 0}}catch(e){throw console.error("[MssqlAdapter] Query failed:",e),e}}async listTables(){let e=`
|
|
73
73
|
SELECT table_name as name, table_type as type
|
|
74
74
|
FROM information_schema.tables
|
|
75
75
|
WHERE table_schema = @schema AND table_type IN ('BASE TABLE', 'VIEW')
|
|
@@ -109,18 +109,18 @@ module.exports=[93695,(e,t,a)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-
|
|
|
109
109
|
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
110
110
|
AND tc.table_schema = @schema
|
|
111
111
|
AND tc.table_name = @table
|
|
112
|
-
`,n=await this.query(t,[this.schema,e]),r=await this.query(a,[this.schema,e]);return n.rows.map(e=>{let t=r.rows.find(t=>t.local_column===e.name);return{name:e.name,type:e.type,nullable:"YES"===e.nullable,defaultValue:e.default_value,isPrimaryKey:e.is_pk,isForeignKey:!!t,referencedTable:t?t.foreign_table:null,referencedColumn:t?t.foreign_column:null}})}async disconnect(){this.pool&&(await this.pool.close(),this.pool=null)}}class
|
|
112
|
+
`,n=await this.query(t,[this.schema,e]),r=await this.query(a,[this.schema,e]);return n.rows.map(e=>{let t=r.rows.find(t=>t.local_column===e.name);return{name:e.name,type:e.type,nullable:"YES"===e.nullable,defaultValue:e.default_value,isPrimaryKey:e.is_pk,isForeignKey:!!t,referencedTable:t?t.foreign_table:null,referencedColumn:t?t.foreign_column:null}})}async disconnect(){this.pool&&(await this.pool.close(),this.pool=null)}}class ConnectionManager{static activeInstances=new Map;static getGlobalConfigPath(){return __TURBOPACK__imported__module__14747__.default.join((0,__TURBOPACK__imported__module__98003__.getConfigDir)(),"global-sql.json")}static getWorkspaceConfigPath(e){return e?__TURBOPACK__imported__module__14747__.default.join(e,".ai","neural-loom","sql-config.json"):null}static loadConfig(e){try{if(__TURBOPACK__imported__module__22734__.default.existsSync(e)){let t=__TURBOPACK__imported__module__22734__.default.readFileSync(e,"utf8");return JSON.parse(t)}}catch(t){console.error(`[ConnectionManager] Failed to load config from ${e}:`,t)}return{connections:{},activeConnection:null}}static saveConfig(e,t){try{let a=__TURBOPACK__imported__module__14747__.default.dirname(e);__TURBOPACK__imported__module__22734__.default.existsSync(a)||__TURBOPACK__imported__module__22734__.default.mkdirSync(a,{recursive:!0}),__TURBOPACK__imported__module__22734__.default.writeFileSync(e,JSON.stringify(t,null,2),"utf8")}catch(t){console.error(`[ConnectionManager] Failed to save config to ${e}:`,t)}}static async getProfiles(e){let t=this.loadConfig(this.getGlobalConfigPath()),a=Object.values(t.connections),n=[],r=t.activeConnection,s=!0;if(e){let t=this.getWorkspaceConfigPath(e);if(t){let e=this.loadConfig(t);n=Object.values(e.connections),e.activeConnection&&(r=e.activeConnection,s=!1)}}return{global:a,workspace:n,activeId:r,isActiveGlobal:s}}static async saveProfile(e,t,a){let n=t?this.getGlobalConfigPath():this.getWorkspaceConfigPath(a);if(!n)throw Error("Invalid workspace root path for saving connection profile.");let r=this.loadConfig(n);r.connections[e.id]=e,this.saveConfig(n,r)}static async deleteProfile(e,t,a){let n=t?this.getGlobalConfigPath():this.getWorkspaceConfigPath(a);if(!n)throw Error("Invalid workspace root path for deleting connection profile.");let r=this.loadConfig(n);r.connections[e]&&(delete r.connections[e],r.activeConnection===e&&(r.activeConnection=null),this.saveConfig(n,r));let s=`${t?"global":"ws"}:${e}`,i=this.activeInstances.get(s);i&&(await i.disconnect().catch(console.error),this.activeInstances.delete(s))}static async setActiveProfile(e,t,a){let n=t?this.getGlobalConfigPath():this.getWorkspaceConfigPath(a);if(!n)throw Error("Invalid workspace root path for setting active profile.");let r=this.loadConfig(n);r.activeConnection=e,this.saveConfig(n,r)}static createAdapter(e,t){switch(e.type){case"sqlite":return new SqliteAdapter(e,t);case"postgres":return new PostgresAdapter(e);case"mysql":return new MysqlAdapter(e);case"mssql":return new MssqlAdapter(e);default:throw Error(`Unsupported database type: ${e.type}`)}}static async getActiveAdapter(e){let{global:t,workspace:a,activeId:n,isActiveGlobal:r}=await this.getProfiles(e);if(!n)return null;let s=`${r?"global":"ws"}:${n}`,i=this.activeInstances.get(s);if(i){let e=(r?t:a).find(e=>e.id===n);if(e)return{adapter:i,profile:e}}let o=(r?t:a).find(e=>e.id===n);if(!o)return null;let l=this.createAdapter(o,e);return this.activeInstances.set(s,l),{adapter:l,profile:o}}static async getAdapterById(e,t){let{global:a,workspace:n}=await this.getProfiles(t),r=n.find(t=>t.id===e),s=!1;if(r||(r=a.find(t=>t.id===e),s=!0),r||(r=n.find(t=>t.name.toLowerCase()===e.toLowerCase()),s=!1),r||(r=a.find(t=>t.name.toLowerCase()===e.toLowerCase()),s=!0),!r)return null;let i=`${s?"global":"ws"}:${r.id}`,o=this.activeInstances.get(i);if(o)return{adapter:o,profile:r};let l=this.createAdapter(r,t);return this.activeInstances.set(i,l),{adapter:l,profile:r}}static async closeAll(){for(let[,e]of this.activeInstances.entries())await e.disconnect().catch(console.error);this.activeInstances.clear()}}__turbopack_context__.s(["ConnectionManager",0,ConnectionManager],41230)},19668,(e,t,a)=>{t.exports=e.x("readline",()=>require("readline"))},53869,e=>{"use strict";var t=e.i(47909),a=e.i(74017),n=e.i(96250),r=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),c=e.i(87718),u=e.i(95169),d=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(26937),f=e.i(10372),y=e.i(93695);e.i(52474);var b=e.i(220),g=e.i(89171),_=e.i(19668),w=e.i(41230);class v{workspaceRoot;constructor(e){this.workspaceRoot=e,console.log=(...e)=>{console.error("[LOG]",...e)}}start(){_.default.createInterface({input:process.stdin,output:process.stdout,terminal:!1}).on("line",async e=>{if(e.trim())try{let t=JSON.parse(e);if(t.method){let e=await this.handleMessage(t);e&&process.stdout.write(JSON.stringify(e)+"\n")}}catch(e){this.sendError(null,-32700,"Parse error: "+(e instanceof Error?e.message:String(e)))}}),console.error("[McpServer] SQL Model Context Protocol Server listening on stdio..."),this.workspaceRoot&&console.error(`[McpServer] Workspace Root Context resolved to: ${this.workspaceRoot}`)}async handleMessage(e){let{id:t,method:a,params:n}=e;switch(a){case"initialize":return{jsonrpc:"2.0",id:t,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"neural-loom-sql-mcp",version:"1.0.0"}}};case"notifications/initialized":return null;case"tools/list":return{jsonrpc:"2.0",id:t,result:{tools:[{name:"sql_list_connections",description:"Lists all configured global and workspace database connection profiles, and identifies which one is active.",inputSchema:{type:"object",properties:{}}},{name:"sql_list_tables",description:"Lists all tables and views in the database connection.",inputSchema:{type:"object",properties:{connection:{type:"string",description:"Optional connection profile ID or Name. Defaults to active database."}}}},{name:"sql_describe_table",description:"Provides column names, types, primary keys, foreign keys, and nullability information for a specific table.",inputSchema:{type:"object",properties:{table:{type:"string",description:"The name of the table to describe."},connection:{type:"string",description:"Optional connection profile ID or Name. Defaults to active database."}},required:["table"]}},{name:"sql_get_schema_summary",description:"Returns a complete Markdown representation of the database schema, detailing all tables, columns, constraints, and relationships.",inputSchema:{type:"object",properties:{connection:{type:"string",description:"Optional connection profile ID or Name. Defaults to active database."}}}},{name:"sql_query",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.",inputSchema:{type:"object",properties:{sql:{type:"string",description:"The SQL statement to execute."},connection:{type:"string",description:"Optional connection profile ID or Name. Defaults to active database."}},required:["sql"]}}]}};case"tools/call":return await this.handleToolCall(t,n);default:return{jsonrpc:"2.0",id:t,error:{code:-32601,message:`Method not found: ${a}`}}}}async handleRequest(e){let t=await this.handleMessage(e);t&&process.stdout.write(JSON.stringify(t)+"\n")}async handleToolCall(e,t){let a=t.name,n=t.arguments||{};try{let t;if("sql_list_connections"===a){let t=await w.ConnectionManager.getProfiles(this.workspaceRoot),a=t.isActiveGlobal?t.global.find(e=>e.id===t.activeId):t.workspace.find(e=>e.id===t.activeId),n=`Active Connection Profile: ${a?`${a.name} (${a.type})`:"None"}
|
|
113
113
|
|
|
114
114
|
Global Profiles:
|
|
115
115
|
`+(t.global.length>0?t.global.map(e=>`- [${e.id}] ${e.name} (${e.type}) ${t.activeId===e.id&&t.isActiveGlobal?"(Active)":""}`).join("\n"):"None")+"\n\n"+`Workspace Profiles:
|
|
116
|
-
`+(t.workspace.length>0?t.workspace.map(e=>`- [${e.id}] ${e.name} (${e.type}) ${t.activeId===e.id&&!t.isActiveGlobal?"(Active)":""}`).join("\n"):"None");this.sendToolResult(e,n);return}let r=n.connection;if(r){if(!(t=await w.ConnectionManager.getAdapterById(r,this.workspaceRoot)))return void this.sendToolResult(e,`Error: Connection profile "${r}" was not found. Configure it in the NeuralLoom workspace dashboard UI.`,!0)}else if(!(t=await w.ConnectionManager.getActiveAdapter(this.workspaceRoot)))return void this.sendToolResult(e,"Error: No active database connection is selected. Please configure and activate a database connection in the NeuralLoom workspace dashboard UI.",!0);let{adapter:s,profile:
|
|
116
|
+
`+(t.workspace.length>0?t.workspace.map(e=>`- [${e.id}] ${e.name} (${e.type}) ${t.activeId===e.id&&!t.isActiveGlobal?"(Active)":""}`).join("\n"):"None");this.sendToolResult(e,n);return}let r=n.connection;if(r){if(!(t=await w.ConnectionManager.getAdapterById(r,this.workspaceRoot)))return void this.sendToolResult(e,`Error: Connection profile "${r}" was not found. Configure it in the NeuralLoom workspace dashboard UI.`,!0)}else if(!(t=await w.ConnectionManager.getActiveAdapter(this.workspaceRoot)))return void this.sendToolResult(e,"Error: No active database connection is selected. Please configure and activate a database connection in the NeuralLoom workspace dashboard UI.",!0);let{adapter:s,profile:i}=t;switch(a){case"sql_list_tables":{let t=await s.listTables(),a=t.length>0?t.map(e=>`- \`${e.name}\` (${e.type})`).join("\n"):"*No tables found in the active database.*";this.sendToolResult(e,`Active Database: ${i.name} (${i.type})
|
|
117
117
|
|
|
118
118
|
### Tables:
|
|
119
|
-
${a}`);break}case"sql_describe_table":{let t=n.table;if(!t)return void this.sendToolResult(e,"Error: Missing required argument 'table'.",!0);let a=await s.describeTable(t),r=`### Table Structure: \`${t}\` (Active Connection: ${
|
|
119
|
+
${a}`);break}case"sql_describe_table":{let t=n.table;if(!t)return void this.sendToolResult(e,"Error: Missing required argument 'table'.",!0);let a=await s.describeTable(t),r=`### Table Structure: \`${t}\` (Active Connection: ${i.name})
|
|
120
120
|
|
|
121
121
|
`;for(let e of(r+=`| Column | Type | Nullable | Key | References |
|
|
122
122
|
|---|---|---|---|---|
|
|
123
123
|
`,a)){let t=e.isPrimaryKey?"PK":e.isForeignKey?"FK":"",a=e.isForeignKey?`\`${e.referencedTable}.${e.referencedColumn}\``:"";r+=`| \`${e.name}\` | \`${e.type}\` | ${e.nullable?"Yes":"No"} | ${t} | ${a} |
|
|
124
|
-
`}this.sendToolResult(e,r);break}case"sql_get_schema_summary":{let t=await s.getSchemaSummary();this.sendToolResult(e,t);break}case"sql_query":{let t=n.sql;if(!t||!t.trim())return void this.sendToolResult(e,"Error: Missing required argument 'sql'.",!0);let a=t.trim().toLowerCase(),r=a.startsWith("insert")||a.startsWith("update")||a.startsWith("delete")||a.startsWith("drop")||a.startsWith("alter")||a.startsWith("create")||a.startsWith("truncate")||a.startsWith("replace");if(
|
|
124
|
+
`}this.sendToolResult(e,r);break}case"sql_get_schema_summary":{let t=await s.getSchemaSummary();this.sendToolResult(e,t);break}case"sql_query":{let t=n.sql;if(!t||!t.trim())return void this.sendToolResult(e,"Error: Missing required argument 'sql'.",!0);let a=t.trim().toLowerCase(),r=a.startsWith("insert")||a.startsWith("update")||a.startsWith("delete")||a.startsWith("drop")||a.startsWith("alter")||a.startsWith("create")||a.startsWith("truncate")||a.startsWith("replace");if(i.readOnly&&r)return void this.sendToolResult(e,"Error: Access Denied. This database connection is configured as Read-Only.",!0);let o=await s.query(t);void 0!==o.affectedRows?this.sendToolResult(e,`Query completed successfully. Affected rows: ${o.affectedRows}`):this.sendToolResult(e,JSON.stringify(o.rows,null,2));break}default:this.sendError(e,-32601,`Tool not implemented: ${a}`)}}catch(t){this.sendToolResult(e,`Exception executing tool: ${t.message||String(t)}`,!0)}}sendResponse(e,t){let a={jsonrpc:"2.0",id:e,result:t};process.stdout.write(JSON.stringify(a)+"\n")}sendToolResult(e,t,a=!1){let n={jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:t}],isError:a}};process.stdout.write(JSON.stringify(n)+"\n")}sendError(e,t,a){let n={jsonrpc:"2.0",id:e,error:{code:t,message:a}};process.stdout.write(JSON.stringify(n)+"\n")}}async function R(e){try{let t=e.headers.get("x-workspace-root")||void 0,a=await e.json(),n=new v(t),r=await n.handleMessage(a);if(null===r)return new Response("",{status:204});return g.NextResponse.json(r)}catch(e){return g.NextResponse.json({jsonrpc:"2.0",id:null,error:{code:-32603,message:"Internal server error: "+(e.message||String(e))}},{status:500})}}e.s(["POST",0,R],37730);var E=e.i(37730);let A="",C=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/sql/mcp/route",pathname:"/api/sql/mcp",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/sql/mcp/route.ts",nextConfigOutput:A,userland:E,...{}}),{workAsyncStorage:S,workUnitAsyncStorage:N,serverHooks:q}=C;function k(){return(0,n.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:N})}async function x(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),C.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/sql/mcp/route";g=g.replace(/\/index$/,"")||"/";let _=!1,w=await C.prepare(e,t,{srcPage:g,multiZoneDraftMode:_});if(!w)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:v,deploymentId:R,params:E,nextConfig:A,parsedUrl:S,isDraftMode:N,prerenderManifest:q,routerServerContext:k,isOnDemandRevalidate:x,revalidateOnlyGenerated:T,resolvedPathname:O,clientReferenceManifest:P,serverActionsManifest:I}=w,$=(0,o.normalizeAppPath)(g),D=!!(q.dynamicRoutes[$]||q.routes[O]),M=async()=>((null==k?void 0:k.render404)?await k.render404(e,t,S,!1):t.end("This page could not be found"),null);if(D&&!N){let e=!!q.routes[O],t=q.dynamicRoutes[$];if(t&&!1===t.fallback&&!e){if(A.adapterPath)return await M();throw new y.NoFallbackError}}let j=null;!D||C.isDev||N||(j="/index"===(j=O)?"/":j);let L=!0===C.isDev||!D,W=D&&!L;I&&P&&(0,i.setManifestsSingleton)({page:g,clientReferenceManifest:P,serverActionsManifest:I});let F=e.method||"GET",K=(0,s.getTracer)(),H=K.getActiveScopeSpan(),B=!!(null==k?void 0:k.isWrappedByNextServer),U=!!(0,r.getRequestMeta)(e,"minimalMode"),G=(0,r.getRequestMeta)(e,"incrementalCache")||await C.getIncrementalCache(e,A,q,U);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let Y={params:E,previewProps:q.preview,renderOpts:{experimental:{authInterrupts:!!A.experimental.authInterrupts},cacheComponents:!!A.cacheComponents,supportsDynamicResponse:L,incrementalCache:G,cacheLifeProfiles:A.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,n,r)=>C.onRequestError(e,t,n,r,k)},sharedContext:{buildId:v,deploymentId:R}},J=new l.NodeNextRequest(e),Q=new l.NodeNextResponse(t),V=c.NextRequestAdapter.fromNodeNextRequest(J,(0,c.signalFromNodeResponse)(t));try{let r,i=async e=>C.handle(V,Y).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=K.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=a.get("next.route");if(n){let t=`${F} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${F} ${g}`)}),o=async r=>{var s,o;let l=async({previousCacheEntry:a})=>{try{if(!U&&x&&T&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(r);e.fetchMetrics=Y.renderOpts.fetchMetrics;let o=Y.renderOpts.pendingWaitUntil;o&&n.waitUntil&&(n.waitUntil(o),o=void 0);let l=Y.renderOpts.collectedTags;if(!D)return await (0,p.sendResponse)(J,Q,s,Y.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(s.headers);l&&(t[f.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==Y.renderOpts.collectedRevalidate&&!(Y.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&Y.renderOpts.collectedRevalidate,n=void 0===Y.renderOpts.collectedExpire||Y.renderOpts.collectedExpire>=f.INFINITE_CACHE?void 0:Y.renderOpts.collectedExpire;return{value:{kind:b.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:n}}}}catch(t){if(null==a?void 0:a.isStale){let a=!1;await C.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:W,isOnDemandRevalidate:x})},a,k)}throw t}},c=await C.handleResponse({req:e,nextConfig:A,cacheKey:j,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:q,isRoutePPREnabled:!1,isOnDemandRevalidate:x,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:U});if(!D)return null;if((null==c||null==(s=c.value)?void 0:s.kind)!==b.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(o=c.value)?void 0:o.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});U||t.setHeader("x-nextjs-cache",x?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),N&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(c.value.headers);return U&&D||u.delete(f.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(c.cacheControl)),await (0,p.sendResponse)(J,Q,new Response(c.value.body,{headers:u,status:c.value.status||200})),null};B&&H?await o(H):(r=K.getActiveScopeSpan(),await K.withPropagatedContext(e.headers,()=>K.trace(u.BaseServerSpan.handleRequest,{spanName:`${F} ${g}`,kind:s.SpanKind.SERVER,attributes:{"http.method":F,"http.target":e.url}},o),void 0,!B))}catch(t){if(!(t instanceof y.NoFallbackError)){let a=!1;await C.onRequestError(e,t,{routerKind:"App Router",routePath:$,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:W,isOnDemandRevalidate:x})},a,k)}if(D)throw t;return await (0,p.sendResponse)(J,Q,new Response(null,{status:500})),null}}e.s(["handler",0,x,"patchFetch",0,k,"routeModule",0,C,"serverHooks",0,q,"workAsyncStorage",0,S,"workUnitAsyncStorage",0,N],53869)}];
|
|
125
125
|
|
|
126
126
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0.ptwor._.js.map
|