@conarium-ai/core 0.2.12 → 0.2.13
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/CHANGELOG.md +123 -1
- package/LICENSE +21 -21
- package/LIMITATIONS.md +23 -2
- package/LIMITATIONS.tr.md +13 -2
- package/bin/conarium-coverage.mjs +89 -6
- package/bin/conarium-doctor.mjs +44 -0
- package/bin/conarium-verify.mjs +110 -51
- package/dist/anchor.d.ts +11 -0
- package/dist/anchor.d.ts.map +1 -1
- package/dist/anchor.js +27 -0
- package/dist/anchor.js.map +1 -1
- package/dist/audit.d.ts +4 -0
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +124 -30
- package/dist/audit.js.map +1 -1
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -0
- package/dist/config.js.map +1 -1
- package/dist/connectors/openapi.d.ts +14 -1
- package/dist/connectors/openapi.d.ts.map +1 -1
- package/dist/connectors/openapi.js +78 -5
- package/dist/connectors/openapi.js.map +1 -1
- package/dist/connectors/postgres.js +8 -8
- package/dist/console-receipts.d.ts +12 -1
- package/dist/console-receipts.d.ts.map +1 -1
- package/dist/console-receipts.js +14 -2
- package/dist/console-receipts.js.map +1 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +15 -4
- package/dist/console.js.map +1 -1
- package/dist/coverage.d.ts +17 -1
- package/dist/coverage.d.ts.map +1 -1
- package/dist/coverage.js +30 -3
- package/dist/coverage.js.map +1 -1
- package/dist/digit_pii.d.ts.map +1 -1
- package/dist/digit_pii.js +24 -5
- package/dist/digit_pii.js.map +1 -1
- package/dist/governance.d.ts +2 -0
- package/dist/governance.d.ts.map +1 -1
- package/dist/governance.js +23 -8
- package/dist/governance.js.map +1 -1
- package/dist/http.d.ts +11 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +87 -7
- package/dist/http.js.map +1 -1
- package/dist/iban.d.ts.map +1 -1
- package/dist/iban.js +6 -3
- package/dist/iban.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +5 -0
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +22 -7
- package/dist/keys.js.map +1 -1
- package/dist/mask-text.d.ts +11 -0
- package/dist/mask-text.d.ts.map +1 -0
- package/dist/mask-text.js +42 -0
- package/dist/mask-text.js.map +1 -0
- package/dist/receipt-view.d.ts +13 -0
- package/dist/receipt-view.d.ts.map +1 -1
- package/dist/receipt-view.js +28 -5
- package/dist/receipt-view.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +31 -15
- package/dist/server.js.map +1 -1
- package/dist/sql-gate/mssql.d.ts.map +1 -1
- package/dist/sql-gate/mssql.js +36 -2
- package/dist/sql-gate/mssql.js.map +1 -1
- package/dist/sql-gate/oracle.d.ts.map +1 -1
- package/dist/sql-gate/oracle.js +24 -3
- package/dist/sql-gate/oracle.js.map +1 -1
- package/dist/sql-gate/rules.d.ts +19 -1
- package/dist/sql-gate/rules.d.ts.map +1 -1
- package/dist/sql-gate/rules.js +116 -7
- package/dist/sql-gate/rules.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/API-STABILITY.md +2 -2
- package/docs/ARCHITECTURE.md +42 -42
- package/docs/RECEIPT-SPEC.md +17 -11
- package/docs/plans/2026-07-02-redteam-harness.md +416 -416
- package/docs/specs/2026-07-02-redteam-harness-design.md +90 -90
- package/docs/superpowers/TODO-gate1-f4.md +23 -23
- package/docs/superpowers/plans/2026-07-29-conarium-receipt-plan.md +200 -200
- package/docs/superpowers/specs/2026-07-29-conarium-receipt-design.md +202 -202
- package/examples/claude-desktop-config.json +9 -9
- package/examples/cursor-mcp-settings.json +10 -10
- package/package.json +8 -1
- package/public/app.js +378 -378
- package/public/index.html +160 -160
- package/public/style.css +504 -504
- package/scripts/conarium_sabah_brief.mjs +107 -107
- package/scripts/start-mcp-c1.mjs +93 -93
- package/test-vectors/sql-gate/LAST-RUN.json +1 -1
- package/test-vectors/sql-gate/vectors.json +28 -0
- package/dist/openapi_connector.d.ts +0 -6
- package/dist/openapi_connector.d.ts.map +0 -1
- package/dist/openapi_connector.js +0 -145
- package/dist/openapi_connector.js.map +0 -1
- package/docs/audit/2026-08-14-security-scan.md +0 -48
- package/docs/audit/2026-08-14-surface-sync.md +0 -34
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Conarium sabah brief — zion-rest queries → markdown file.
|
|
3
|
-
* Usage: node scripts/conarium_sabah_brief.mjs
|
|
4
|
-
* Writes: AI_GOVERNANCE/cursor_memory/sabah_conarium.md (no secrets)
|
|
5
|
-
*/
|
|
6
|
-
import { spawn } from 'child_process'
|
|
7
|
-
import { writeFileSync, mkdirSync, existsSync } from 'fs'
|
|
8
|
-
import { join } from 'path'
|
|
9
|
-
|
|
10
|
-
const launcher = join(
|
|
11
|
-
'C:/Users/emek.dogru/Desktop/projeler/Documents/conarium-public/scripts/start-mcp-c1.mjs'
|
|
12
|
-
)
|
|
13
|
-
const outDir = 'C:/Users/emek.dogru/AI_GOVERNANCE/cursor_memory'
|
|
14
|
-
const outFile = join(outDir, 'sabah_conarium.md')
|
|
15
|
-
const nodeExe = 'C:/Program Files/nodejs/node.exe'
|
|
16
|
-
|
|
17
|
-
function rpc(id, method, params) {
|
|
18
|
-
return JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function runMcp(messages) {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
const p = spawn(nodeExe, [launcher], { stdio: ['pipe', 'pipe', 'pipe'] })
|
|
24
|
-
let out = '', err = ''
|
|
25
|
-
p.stdout.on('data', d => (out += d))
|
|
26
|
-
p.stderr.on('data', d => (err += d))
|
|
27
|
-
p.on('error', reject)
|
|
28
|
-
setTimeout(() => {
|
|
29
|
-
for (const m of messages) p.stdin.write(m)
|
|
30
|
-
p.stdin.end()
|
|
31
|
-
}, 200)
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
try { p.kill() } catch {}
|
|
34
|
-
resolve({ out, err })
|
|
35
|
-
}, 12000)
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function parseToolResults(out) {
|
|
40
|
-
const map = {}
|
|
41
|
-
for (const line of out.split(/\r?\n/)) {
|
|
42
|
-
if (!line.trim()) continue
|
|
43
|
-
let o
|
|
44
|
-
try { o = JSON.parse(line) } catch { continue }
|
|
45
|
-
if (o.id == null || !o.result?.content?.[0]?.text) continue
|
|
46
|
-
const t = o.result.content[0].text
|
|
47
|
-
if (t.startsWith('Error:')) {
|
|
48
|
-
map[o.id] = { error: t }
|
|
49
|
-
continue
|
|
50
|
-
}
|
|
51
|
-
try { map[o.id] = JSON.parse(t) } catch { map[o.id] = { raw: t.slice(0, 500) } }
|
|
52
|
-
}
|
|
53
|
-
return map
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function fmtRows(payload, max = 8) {
|
|
57
|
-
if (payload?.error) return `_Hata: ${payload.error}_\n`
|
|
58
|
-
const rows = payload?.rows || []
|
|
59
|
-
if (!rows.length) return '_boş_\n'
|
|
60
|
-
const keys = Object.keys(rows[0]).filter(k => !/phone|email|gsm|tckn/i.test(k)).slice(0, 6)
|
|
61
|
-
const lines = ['| ' + keys.join(' | ') + ' |', '| ' + keys.map(() => '---').join(' | ') + ' |']
|
|
62
|
-
for (const r of rows.slice(0, max)) {
|
|
63
|
-
lines.push('| ' + keys.map(k => String(r[k] ?? '')).join(' | ') + ' |')
|
|
64
|
-
}
|
|
65
|
-
return lines.join('\n') + '\n'
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const { out, err } = await runMcp([
|
|
69
|
-
rpc(1, 'initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'sabah', version: '1' } }),
|
|
70
|
-
JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n',
|
|
71
|
-
rpc(2, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_dead_stock_summary LIMIT 1' } }),
|
|
72
|
-
rpc(3, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_branch_summary LIMIT 10' } }),
|
|
73
|
-
rpc(4, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_stock_runout LIMIT 10' } }),
|
|
74
|
-
rpc(5, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_ship_summary LIMIT 1' } }),
|
|
75
|
-
])
|
|
76
|
-
|
|
77
|
-
const r = parseToolResults(out)
|
|
78
|
-
const now = new Date().toISOString()
|
|
79
|
-
const md = `# Conarium sabah — ${now}
|
|
80
|
-
|
|
81
|
-
> Kaynak: zion-rest (Codes sync aynası). Canlı Codes değil. PII maskeli alanlar atlandı.
|
|
82
|
-
|
|
83
|
-
## 1) Ölü stok
|
|
84
|
-
${fmtRows(r[2], 3)}
|
|
85
|
-
|
|
86
|
-
## 2) Şube özet
|
|
87
|
-
${fmtRows(r[3], 10)}
|
|
88
|
-
|
|
89
|
-
## 3) Stock runout
|
|
90
|
-
${fmtRows(r[4], 10)}
|
|
91
|
-
|
|
92
|
-
## 4) Sevk özet
|
|
93
|
-
${fmtRows(r[5], 3)}
|
|
94
|
-
|
|
95
|
-
## Not
|
|
96
|
-
- |marj| uçuksa önce maliyet/veri_hatası hipotezi.
|
|
97
|
-
- 3 hamleyi Agent skill \`conarium-sabah\` ile yorumla.
|
|
98
|
-
|
|
99
|
-
## stderr (kısa)
|
|
100
|
-
\`\`\`
|
|
101
|
-
${err.split('\\n').filter(l => /allow=|Connected|running|Fatal/.test(l)).slice(0, 8).join('\\n')}
|
|
102
|
-
\`\`\`
|
|
103
|
-
`
|
|
104
|
-
|
|
105
|
-
if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true })
|
|
106
|
-
writeFileSync(outFile, md, 'utf8')
|
|
107
|
-
console.error('[sabah] wrote', outFile)
|
|
1
|
+
/**
|
|
2
|
+
* Conarium sabah brief — zion-rest queries → markdown file.
|
|
3
|
+
* Usage: node scripts/conarium_sabah_brief.mjs
|
|
4
|
+
* Writes: AI_GOVERNANCE/cursor_memory/sabah_conarium.md (no secrets)
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from 'child_process'
|
|
7
|
+
import { writeFileSync, mkdirSync, existsSync } from 'fs'
|
|
8
|
+
import { join } from 'path'
|
|
9
|
+
|
|
10
|
+
const launcher = join(
|
|
11
|
+
'C:/Users/emek.dogru/Desktop/projeler/Documents/conarium-public/scripts/start-mcp-c1.mjs'
|
|
12
|
+
)
|
|
13
|
+
const outDir = 'C:/Users/emek.dogru/AI_GOVERNANCE/cursor_memory'
|
|
14
|
+
const outFile = join(outDir, 'sabah_conarium.md')
|
|
15
|
+
const nodeExe = 'C:/Program Files/nodejs/node.exe'
|
|
16
|
+
|
|
17
|
+
function rpc(id, method, params) {
|
|
18
|
+
return JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function runMcp(messages) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const p = spawn(nodeExe, [launcher], { stdio: ['pipe', 'pipe', 'pipe'] })
|
|
24
|
+
let out = '', err = ''
|
|
25
|
+
p.stdout.on('data', d => (out += d))
|
|
26
|
+
p.stderr.on('data', d => (err += d))
|
|
27
|
+
p.on('error', reject)
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
for (const m of messages) p.stdin.write(m)
|
|
30
|
+
p.stdin.end()
|
|
31
|
+
}, 200)
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
try { p.kill() } catch {}
|
|
34
|
+
resolve({ out, err })
|
|
35
|
+
}, 12000)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function parseToolResults(out) {
|
|
40
|
+
const map = {}
|
|
41
|
+
for (const line of out.split(/\r?\n/)) {
|
|
42
|
+
if (!line.trim()) continue
|
|
43
|
+
let o
|
|
44
|
+
try { o = JSON.parse(line) } catch { continue }
|
|
45
|
+
if (o.id == null || !o.result?.content?.[0]?.text) continue
|
|
46
|
+
const t = o.result.content[0].text
|
|
47
|
+
if (t.startsWith('Error:')) {
|
|
48
|
+
map[o.id] = { error: t }
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
51
|
+
try { map[o.id] = JSON.parse(t) } catch { map[o.id] = { raw: t.slice(0, 500) } }
|
|
52
|
+
}
|
|
53
|
+
return map
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function fmtRows(payload, max = 8) {
|
|
57
|
+
if (payload?.error) return `_Hata: ${payload.error}_\n`
|
|
58
|
+
const rows = payload?.rows || []
|
|
59
|
+
if (!rows.length) return '_boş_\n'
|
|
60
|
+
const keys = Object.keys(rows[0]).filter(k => !/phone|email|gsm|tckn/i.test(k)).slice(0, 6)
|
|
61
|
+
const lines = ['| ' + keys.join(' | ') + ' |', '| ' + keys.map(() => '---').join(' | ') + ' |']
|
|
62
|
+
for (const r of rows.slice(0, max)) {
|
|
63
|
+
lines.push('| ' + keys.map(k => String(r[k] ?? '')).join(' | ') + ' |')
|
|
64
|
+
}
|
|
65
|
+
return lines.join('\n') + '\n'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const { out, err } = await runMcp([
|
|
69
|
+
rpc(1, 'initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'sabah', version: '1' } }),
|
|
70
|
+
JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n',
|
|
71
|
+
rpc(2, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_dead_stock_summary LIMIT 1' } }),
|
|
72
|
+
rpc(3, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_branch_summary LIMIT 10' } }),
|
|
73
|
+
rpc(4, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_stock_runout LIMIT 10' } }),
|
|
74
|
+
rpc(5, 'tools/call', { name: 'query', arguments: { connector: 'zion-rest', sql: 'SELECT * FROM zion.v_ship_summary LIMIT 1' } }),
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
const r = parseToolResults(out)
|
|
78
|
+
const now = new Date().toISOString()
|
|
79
|
+
const md = `# Conarium sabah — ${now}
|
|
80
|
+
|
|
81
|
+
> Kaynak: zion-rest (Codes sync aynası). Canlı Codes değil. PII maskeli alanlar atlandı.
|
|
82
|
+
|
|
83
|
+
## 1) Ölü stok
|
|
84
|
+
${fmtRows(r[2], 3)}
|
|
85
|
+
|
|
86
|
+
## 2) Şube özet
|
|
87
|
+
${fmtRows(r[3], 10)}
|
|
88
|
+
|
|
89
|
+
## 3) Stock runout
|
|
90
|
+
${fmtRows(r[4], 10)}
|
|
91
|
+
|
|
92
|
+
## 4) Sevk özet
|
|
93
|
+
${fmtRows(r[5], 3)}
|
|
94
|
+
|
|
95
|
+
## Not
|
|
96
|
+
- |marj| uçuksa önce maliyet/veri_hatası hipotezi.
|
|
97
|
+
- 3 hamleyi Agent skill \`conarium-sabah\` ile yorumla.
|
|
98
|
+
|
|
99
|
+
## stderr (kısa)
|
|
100
|
+
\`\`\`
|
|
101
|
+
${err.split('\\n').filter(l => /allow=|Connected|running|Fatal/.test(l)).slice(0, 8).join('\\n')}
|
|
102
|
+
\`\`\`
|
|
103
|
+
`
|
|
104
|
+
|
|
105
|
+
if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true })
|
|
106
|
+
writeFileSync(outFile, md, 'utf8')
|
|
107
|
+
console.error('[sabah] wrote', outFile)
|
package/scripts/start-mcp-c1.mjs
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* C1 launcher — same-process (no nested spawn; Cursor MCP-safe).
|
|
3
|
-
* Loads Supabase URL/key from jarvis-web .env.local, never prints secrets.
|
|
4
|
-
*/
|
|
5
|
-
import { readFileSync, existsSync } from 'fs'
|
|
6
|
-
import { homedir } from 'os'
|
|
7
|
-
import { pathToFileURL } from 'url'
|
|
8
|
-
import { dirname, join } from 'path'
|
|
9
|
-
import { fileURLToPath } from 'url'
|
|
10
|
-
|
|
11
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
12
|
-
const root = join(__dirname, '..')
|
|
13
|
-
const dist = join(root, 'dist', 'index.js')
|
|
14
|
-
const configPath = join(root, 'conarium.config.c1.json')
|
|
15
|
-
const envPath = process.env.CONARIUM_ENV_FILE ||
|
|
16
|
-
'C:/Users/emek.dogru/Desktop/1/X/jarvis-web/.env.local'
|
|
17
|
-
|
|
18
|
-
function loadEnvFile(path) {
|
|
19
|
-
if (!existsSync(path)) throw new Error(`env file missing: ${path}`)
|
|
20
|
-
const out = {}
|
|
21
|
-
for (const line of readFileSync(path, 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/)) {
|
|
22
|
-
const t = line.trim()
|
|
23
|
-
if (!t || t.startsWith('#') || !t.includes('=')) continue
|
|
24
|
-
const i = t.indexOf('=')
|
|
25
|
-
const k = t.slice(0, i).trim()
|
|
26
|
-
let v = t.slice(i + 1).trim()
|
|
27
|
-
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) {
|
|
28
|
-
v = v.slice(1, -1)
|
|
29
|
-
}
|
|
30
|
-
out[k] = v
|
|
31
|
-
}
|
|
32
|
-
return out
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!existsSync(dist)) {
|
|
36
|
-
console.error('[conarium-c1] dist/index.js missing — run npm run build')
|
|
37
|
-
process.exit(1)
|
|
38
|
-
}
|
|
39
|
-
if (!existsSync(configPath)) {
|
|
40
|
-
console.error('[conarium-c1] conarium.config.c1.json missing')
|
|
41
|
-
process.exit(1)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const fileEnv = loadEnvFile(envPath)
|
|
45
|
-
const url = fileEnv.NEXT_PUBLIC_SUPABASE_URL || fileEnv.SUPABASE_URL
|
|
46
|
-
const key = fileEnv.SUPABASE_SERVICE_ROLE_KEY
|
|
47
|
-
if (!url || !key) {
|
|
48
|
-
console.error('[conarium-c1] NEXT_PUBLIC_SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY missing')
|
|
49
|
-
process.exit(1)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
process.env.CONARIUM_SUPABASE_URL = url
|
|
53
|
-
process.env.CONARIUM_SUPABASE_KEY = key
|
|
54
|
-
|
|
55
|
-
// receiptSink in c1 config requires Ed25519 at boot. Cursor mcp.json does not
|
|
56
|
-
// set CONARIUM_AUDIT_SIGNING_KEY — that is why receipts-c1.jsonl never appeared
|
|
57
|
-
// after the sink was added. Do not create an empty sink; the first governed
|
|
58
|
-
// access writes the first line.
|
|
59
|
-
if (!process.env.CONARIUM_AUDIT_SIGNING_KEY?.trim()) {
|
|
60
|
-
let receiptSink = ''
|
|
61
|
-
try {
|
|
62
|
-
receiptSink = JSON.parse(readFileSync(configPath, 'utf8'))?.audit?.receiptSink || ''
|
|
63
|
-
} catch { /* probe below still runs */ }
|
|
64
|
-
if (receiptSink) {
|
|
65
|
-
const fallback = join(homedir(), '.conarium', 'audit-ed25519.pem')
|
|
66
|
-
if (!existsSync(fallback)) {
|
|
67
|
-
console.error('[conarium-c1] receiptSink is set but CONARIUM_AUDIT_SIGNING_KEY is missing')
|
|
68
|
-
console.error(`[conarium-c1] expected signing key at ${fallback}`)
|
|
69
|
-
process.exit(1)
|
|
70
|
-
}
|
|
71
|
-
process.env.CONARIUM_AUDIT_SIGNING_KEY = fallback
|
|
72
|
-
console.error(`[conarium-c1] signing key=${fallback}`)
|
|
73
|
-
console.error('[conarium-c1] receipt file is created on the first governed access, not at start')
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Ensure dist/index.js sees --config (it reads process.argv)
|
|
78
|
-
process.argv = [process.argv[0], dist, '--config', configPath]
|
|
79
|
-
|
|
80
|
-
// Prove which policy file this process loaded (Cursor stale-process debug).
|
|
81
|
-
try {
|
|
82
|
-
const cfg = JSON.parse(readFileSync(configPath, 'utf8'))
|
|
83
|
-
const zion = (cfg.connectors || []).find(c => c.name === 'zion-rest')
|
|
84
|
-
const n = (zion?.config?.allowTables || '').split(',').filter(Boolean).length
|
|
85
|
-
const p = (cfg.policy?.allowTables || []).filter(t => String(t).startsWith('zion.')).length
|
|
86
|
-
console.error(`[conarium-c1] config=${configPath}`)
|
|
87
|
-
console.error(`[conarium-c1] zion connector allow=${n} policy zion allow=${p}`)
|
|
88
|
-
} catch (e) {
|
|
89
|
-
console.error('[conarium-c1] config probe failed:', e.message)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
console.error('[conarium-c1] starting MCP same-process (zion-rest + docs)')
|
|
93
|
-
await import(pathToFileURL(dist).href)
|
|
1
|
+
/**
|
|
2
|
+
* C1 launcher — same-process (no nested spawn; Cursor MCP-safe).
|
|
3
|
+
* Loads Supabase URL/key from jarvis-web .env.local, never prints secrets.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, existsSync } from 'fs'
|
|
6
|
+
import { homedir } from 'os'
|
|
7
|
+
import { pathToFileURL } from 'url'
|
|
8
|
+
import { dirname, join } from 'path'
|
|
9
|
+
import { fileURLToPath } from 'url'
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
12
|
+
const root = join(__dirname, '..')
|
|
13
|
+
const dist = join(root, 'dist', 'index.js')
|
|
14
|
+
const configPath = join(root, 'conarium.config.c1.json')
|
|
15
|
+
const envPath = process.env.CONARIUM_ENV_FILE ||
|
|
16
|
+
'C:/Users/emek.dogru/Desktop/1/X/jarvis-web/.env.local'
|
|
17
|
+
|
|
18
|
+
function loadEnvFile(path) {
|
|
19
|
+
if (!existsSync(path)) throw new Error(`env file missing: ${path}`)
|
|
20
|
+
const out = {}
|
|
21
|
+
for (const line of readFileSync(path, 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/)) {
|
|
22
|
+
const t = line.trim()
|
|
23
|
+
if (!t || t.startsWith('#') || !t.includes('=')) continue
|
|
24
|
+
const i = t.indexOf('=')
|
|
25
|
+
const k = t.slice(0, i).trim()
|
|
26
|
+
let v = t.slice(i + 1).trim()
|
|
27
|
+
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) {
|
|
28
|
+
v = v.slice(1, -1)
|
|
29
|
+
}
|
|
30
|
+
out[k] = v
|
|
31
|
+
}
|
|
32
|
+
return out
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!existsSync(dist)) {
|
|
36
|
+
console.error('[conarium-c1] dist/index.js missing — run npm run build')
|
|
37
|
+
process.exit(1)
|
|
38
|
+
}
|
|
39
|
+
if (!existsSync(configPath)) {
|
|
40
|
+
console.error('[conarium-c1] conarium.config.c1.json missing')
|
|
41
|
+
process.exit(1)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const fileEnv = loadEnvFile(envPath)
|
|
45
|
+
const url = fileEnv.NEXT_PUBLIC_SUPABASE_URL || fileEnv.SUPABASE_URL
|
|
46
|
+
const key = fileEnv.SUPABASE_SERVICE_ROLE_KEY
|
|
47
|
+
if (!url || !key) {
|
|
48
|
+
console.error('[conarium-c1] NEXT_PUBLIC_SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY missing')
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
process.env.CONARIUM_SUPABASE_URL = url
|
|
53
|
+
process.env.CONARIUM_SUPABASE_KEY = key
|
|
54
|
+
|
|
55
|
+
// receiptSink in c1 config requires Ed25519 at boot. Cursor mcp.json does not
|
|
56
|
+
// set CONARIUM_AUDIT_SIGNING_KEY — that is why receipts-c1.jsonl never appeared
|
|
57
|
+
// after the sink was added. Do not create an empty sink; the first governed
|
|
58
|
+
// access writes the first line.
|
|
59
|
+
if (!process.env.CONARIUM_AUDIT_SIGNING_KEY?.trim()) {
|
|
60
|
+
let receiptSink = ''
|
|
61
|
+
try {
|
|
62
|
+
receiptSink = JSON.parse(readFileSync(configPath, 'utf8'))?.audit?.receiptSink || ''
|
|
63
|
+
} catch { /* probe below still runs */ }
|
|
64
|
+
if (receiptSink) {
|
|
65
|
+
const fallback = join(homedir(), '.conarium', 'audit-ed25519.pem')
|
|
66
|
+
if (!existsSync(fallback)) {
|
|
67
|
+
console.error('[conarium-c1] receiptSink is set but CONARIUM_AUDIT_SIGNING_KEY is missing')
|
|
68
|
+
console.error(`[conarium-c1] expected signing key at ${fallback}`)
|
|
69
|
+
process.exit(1)
|
|
70
|
+
}
|
|
71
|
+
process.env.CONARIUM_AUDIT_SIGNING_KEY = fallback
|
|
72
|
+
console.error(`[conarium-c1] signing key=${fallback}`)
|
|
73
|
+
console.error('[conarium-c1] receipt file is created on the first governed access, not at start')
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Ensure dist/index.js sees --config (it reads process.argv)
|
|
78
|
+
process.argv = [process.argv[0], dist, '--config', configPath]
|
|
79
|
+
|
|
80
|
+
// Prove which policy file this process loaded (Cursor stale-process debug).
|
|
81
|
+
try {
|
|
82
|
+
const cfg = JSON.parse(readFileSync(configPath, 'utf8'))
|
|
83
|
+
const zion = (cfg.connectors || []).find(c => c.name === 'zion-rest')
|
|
84
|
+
const n = (zion?.config?.allowTables || '').split(',').filter(Boolean).length
|
|
85
|
+
const p = (cfg.policy?.allowTables || []).filter(t => String(t).startsWith('zion.')).length
|
|
86
|
+
console.error(`[conarium-c1] config=${configPath}`)
|
|
87
|
+
console.error(`[conarium-c1] zion connector allow=${n} policy zion allow=${p}`)
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error('[conarium-c1] config probe failed:', e.message)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.error('[conarium-c1] starting MCP same-process (zion-rest + docs)')
|
|
93
|
+
await import(pathToFileURL(dist).href)
|
|
@@ -317,6 +317,34 @@
|
|
|
317
317
|
"oracle": " "
|
|
318
318
|
}
|
|
319
319
|
},
|
|
320
|
+
{
|
|
321
|
+
"id": "deny-string-agg",
|
|
322
|
+
"class": "dump-fn",
|
|
323
|
+
"expect": "deny",
|
|
324
|
+
"sql": {
|
|
325
|
+
"postgres": "SELECT STRING_AGG(email, ',') FROM public.customers",
|
|
326
|
+
"mssql": "SELECT STRING_AGG(email, ',') FROM dbo.customers",
|
|
327
|
+
"oracle": "SELECT LISTAGG(email, ',') WITHIN GROUP (ORDER BY email) FROM app.customers"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"id": "deny-user-fn",
|
|
332
|
+
"class": "dump-fn",
|
|
333
|
+
"expect": "deny",
|
|
334
|
+
"sql": {
|
|
335
|
+
"postgres": "SELECT app.pkg.fn(id) FROM public.customers",
|
|
336
|
+
"mssql": "SELECT dbo.fn_x(id) FROM dbo.customers",
|
|
337
|
+
"oracle": "SELECT app.pkg.fn(id) FROM app.customers"
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"id": "deny-updlock",
|
|
342
|
+
"class": "locking-hint",
|
|
343
|
+
"expect": "deny",
|
|
344
|
+
"sql": {
|
|
345
|
+
"mssql": "SELECT id FROM dbo.customers WITH (UPDLOCK)"
|
|
346
|
+
}
|
|
347
|
+
},
|
|
320
348
|
{
|
|
321
349
|
"id": "fail-two-statements",
|
|
322
350
|
"class": "fail-closed",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parses an OpenAPI spec and returns a list of MCP Tool definitions.
|
|
4
|
-
*/
|
|
5
|
-
export declare function generateMcpToolsFromSpec(source: string): Promise<Tool[]>;
|
|
6
|
-
//# sourceMappingURL=openapi_connector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi_connector.d.ts","sourceRoot":"","sources":["../src/openapi_connector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAsH1D;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAkC9E"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import * as yaml from 'js-yaml';
|
|
3
|
-
import fetch from 'node-fetch';
|
|
4
|
-
/**
|
|
5
|
-
* Loads an OpenAPI specification from a URL or a local file path.
|
|
6
|
-
*/
|
|
7
|
-
async function loadSpec(source) {
|
|
8
|
-
let rawText = '';
|
|
9
|
-
if (source.startsWith('http://') || source.startsWith('https://')) {
|
|
10
|
-
const res = await fetch(source);
|
|
11
|
-
if (!res.ok) {
|
|
12
|
-
throw new Error(`Failed to fetch OpenAPI spec from ${source}: ${res.statusText}`);
|
|
13
|
-
}
|
|
14
|
-
rawText = await res.text();
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
rawText = fs.readFileSync(source, 'utf8');
|
|
18
|
-
}
|
|
19
|
-
// Try parsing as JSON first, fallback to YAML
|
|
20
|
-
try {
|
|
21
|
-
return JSON.parse(rawText);
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
try {
|
|
25
|
-
return yaml.load(rawText);
|
|
26
|
-
}
|
|
27
|
-
catch (yamlErr) {
|
|
28
|
-
throw new Error(`Failed to parse OpenAPI spec as JSON or YAML. JSON error: ${err}, YAML error: ${yamlErr}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Resolves $ref in OpenAPI schema
|
|
34
|
-
*/
|
|
35
|
-
function resolveRef(obj, doc, seen = new Set()) {
|
|
36
|
-
if (!obj || typeof obj !== 'object')
|
|
37
|
-
return obj;
|
|
38
|
-
if ('$ref' in obj && typeof obj.$ref === 'string') {
|
|
39
|
-
const ref = obj.$ref;
|
|
40
|
-
if (seen.has(ref))
|
|
41
|
-
return obj; // circular $ref (A->B->A) — stop, never recurse forever
|
|
42
|
-
if (ref.startsWith('#/')) {
|
|
43
|
-
seen.add(ref);
|
|
44
|
-
const parts = ref.slice(2).split('/');
|
|
45
|
-
let current = doc;
|
|
46
|
-
for (const part of parts) {
|
|
47
|
-
if (current && typeof current === 'object' && part in current) {
|
|
48
|
-
current = current[part];
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return obj;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return resolveRef(current, doc, seen);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return obj;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Converts OpenAPI parameters and requestBody to JSON Schema for MCP inputSchema
|
|
61
|
-
*/
|
|
62
|
-
function buildInputSchema(operation, pathParameters, doc) {
|
|
63
|
-
const schema = {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: {},
|
|
66
|
-
required: []
|
|
67
|
-
};
|
|
68
|
-
const mergedParams = [...(pathParameters || []), ...(operation.parameters || [])];
|
|
69
|
-
// Handle parameters (query, path, header)
|
|
70
|
-
for (const paramRef of mergedParams) {
|
|
71
|
-
const param = resolveRef(paramRef, doc);
|
|
72
|
-
if (!param || !param.name)
|
|
73
|
-
continue;
|
|
74
|
-
const paramSchema = resolveRef(param.schema, doc) || { type: 'string' };
|
|
75
|
-
schema.properties[param.name] = {
|
|
76
|
-
...paramSchema,
|
|
77
|
-
description: param.description || paramSchema.description || `Parameter in ${param.in}`
|
|
78
|
-
};
|
|
79
|
-
if (param.required) {
|
|
80
|
-
schema.required.push(param.name);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// Handle requestBody
|
|
84
|
-
if (operation.requestBody) {
|
|
85
|
-
const body = resolveRef(operation.requestBody, doc);
|
|
86
|
-
if (body.content) {
|
|
87
|
-
const contentKey = Object.keys(body.content).find(k => k.includes('application/json')) || Object.keys(body.content)[0];
|
|
88
|
-
if (contentKey && body.content[contentKey].schema) {
|
|
89
|
-
const bodySchema = resolveRef(body.content[contentKey].schema, doc);
|
|
90
|
-
if (bodySchema.type === 'object' && bodySchema.properties) {
|
|
91
|
-
for (const propName of Object.keys(bodySchema.properties)) {
|
|
92
|
-
const prop = resolveRef(bodySchema.properties[propName], doc);
|
|
93
|
-
schema.properties[propName] = prop;
|
|
94
|
-
if (bodySchema.required && Array.isArray(bodySchema.required) && bodySchema.required.includes(propName)) {
|
|
95
|
-
schema.required.push(propName);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
schema.properties['body'] = bodySchema;
|
|
101
|
-
if (body.required) {
|
|
102
|
-
schema.required.push('body');
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// If no required properties, we can omit the array to be cleaner
|
|
109
|
-
if (schema.required.length === 0) {
|
|
110
|
-
delete schema.required;
|
|
111
|
-
}
|
|
112
|
-
return schema;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Parses an OpenAPI spec and returns a list of MCP Tool definitions.
|
|
116
|
-
*/
|
|
117
|
-
export async function generateMcpToolsFromSpec(source) {
|
|
118
|
-
const doc = await loadSpec(source);
|
|
119
|
-
const paths = doc.paths || {};
|
|
120
|
-
const tools = [];
|
|
121
|
-
for (const path of Object.keys(paths)) {
|
|
122
|
-
const pathItem = paths[path];
|
|
123
|
-
const pathParameters = pathItem.parameters || [];
|
|
124
|
-
for (const method of Object.keys(pathItem)) {
|
|
125
|
-
if (!['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'trace'].includes(method.toLowerCase())) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const operation = pathItem[method];
|
|
129
|
-
// operationId or fallback
|
|
130
|
-
let name = operation.operationId;
|
|
131
|
-
if (!name) {
|
|
132
|
-
name = `${method.toLowerCase()}_${path.replace(/[^a-zA-Z0-9]/g, '_').replace(/_+/g, '_').replace(/^_|_$/g, '')}`;
|
|
133
|
-
}
|
|
134
|
-
const summary = operation.summary || operation.description || `Call ${method.toUpperCase()} ${path}`;
|
|
135
|
-
const inputSchema = buildInputSchema(operation, pathParameters, doc);
|
|
136
|
-
tools.push({
|
|
137
|
-
name,
|
|
138
|
-
description: summary,
|
|
139
|
-
inputSchema
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return tools;
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=openapi_connector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi_connector.js","sourceRoot":"","sources":["../src/openapi_connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B;;GAEG;AACH,KAAK,UAAU,QAAQ,CAAC,MAAc;IACpC,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAClE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,OAAO,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAA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