@conarium-ai/core 0.2.53 → 0.3.0
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 +78 -0
- package/LIMITATIONS.md +94 -1
- package/LIMITATIONS.tr.md +96 -1
- package/README.md +1 -1
- package/dist/custom_patterns.d.ts +13 -12
- package/dist/custom_patterns.d.ts.map +1 -1
- package/dist/custom_patterns.js +576 -14
- package/dist/custom_patterns.js.map +1 -1
- package/dist/governance.d.ts.map +1 -1
- package/dist/governance.js +37 -139
- package/dist/governance.js.map +1 -1
- package/dist/mask/belt.d.ts +36 -0
- package/dist/mask/belt.d.ts.map +1 -0
- package/dist/mask/belt.js +771 -0
- package/dist/mask/belt.js.map +1 -0
- package/dist/mask/core.d.ts +36 -0
- package/dist/mask/core.d.ts.map +1 -0
- package/dist/mask/core.js +119 -0
- package/dist/mask/core.js.map +1 -0
- package/dist/mask/detectors/bearer.d.ts +6 -0
- package/dist/mask/detectors/bearer.d.ts.map +1 -0
- package/dist/mask/detectors/bearer.js +30 -0
- package/dist/mask/detectors/bearer.js.map +1 -0
- package/dist/mask/detectors/connection.d.ts +7 -0
- package/dist/mask/detectors/connection.d.ts.map +1 -0
- package/dist/mask/detectors/connection.js +20 -0
- package/dist/mask/detectors/connection.js.map +1 -0
- package/dist/mask/detectors/custom.d.ts +12 -0
- package/dist/mask/detectors/custom.d.ts.map +1 -0
- package/dist/mask/detectors/custom.js +44 -0
- package/dist/mask/detectors/custom.js.map +1 -0
- package/dist/mask/detectors/email.d.ts +3 -0
- package/dist/mask/detectors/email.d.ts.map +1 -0
- package/dist/mask/detectors/email.js +41 -0
- package/dist/mask/detectors/email.js.map +1 -0
- package/dist/mask/detectors/embedded.d.ts +3 -0
- package/dist/mask/detectors/embedded.d.ts.map +1 -0
- package/dist/mask/detectors/embedded.js +73 -0
- package/dist/mask/detectors/embedded.js.map +1 -0
- package/dist/mask/detectors/iban.d.ts +3 -0
- package/dist/mask/detectors/iban.d.ts.map +1 -0
- package/dist/mask/detectors/iban.js +92 -0
- package/dist/mask/detectors/iban.js.map +1 -0
- package/dist/mask/detectors/ip.d.ts +3 -0
- package/dist/mask/detectors/ip.d.ts.map +1 -0
- package/dist/mask/detectors/ip.js +42 -0
- package/dist/mask/detectors/ip.js.map +1 -0
- package/dist/mask/detectors/labelled_secret.d.ts +6 -0
- package/dist/mask/detectors/labelled_secret.d.ts.map +1 -0
- package/dist/mask/detectors/labelled_secret.js +31 -0
- package/dist/mask/detectors/labelled_secret.js.map +1 -0
- package/dist/mask/detectors/mrz.d.ts +3 -0
- package/dist/mask/detectors/mrz.d.ts.map +1 -0
- package/dist/mask/detectors/mrz.js +42 -0
- package/dist/mask/detectors/mrz.js.map +1 -0
- package/dist/mask/detectors/name.d.ts +6 -0
- package/dist/mask/detectors/name.d.ts.map +1 -0
- package/dist/mask/detectors/name.js +41 -0
- package/dist/mask/detectors/name.js.map +1 -0
- package/dist/mask/detectors/numeric.d.ts +3 -0
- package/dist/mask/detectors/numeric.d.ts.map +1 -0
- package/dist/mask/detectors/numeric.js +240 -0
- package/dist/mask/detectors/numeric.js.map +1 -0
- package/dist/mask/detectors/secret.d.ts +6 -0
- package/dist/mask/detectors/secret.d.ts.map +1 -0
- package/dist/mask/detectors/secret.js +31 -0
- package/dist/mask/detectors/secret.js.map +1 -0
- package/dist/mask/detectors/whole_base64.d.ts +3 -0
- package/dist/mask/detectors/whole_base64.d.ts.map +1 -0
- package/dist/mask/detectors/whole_base64.js +28 -0
- package/dist/mask/detectors/whole_base64.js.map +1 -0
- package/dist/mask/legacy_0254/conn_linear.d.ts +26 -0
- package/dist/mask/legacy_0254/conn_linear.d.ts.map +1 -0
- package/dist/mask/legacy_0254/conn_linear.js +97 -0
- package/dist/mask/legacy_0254/conn_linear.js.map +1 -0
- package/dist/mask/legacy_0254/custom_patterns.d.ts +42 -0
- package/dist/mask/legacy_0254/custom_patterns.d.ts.map +1 -0
- package/dist/mask/legacy_0254/custom_patterns.js +164 -0
- package/dist/mask/legacy_0254/custom_patterns.js.map +1 -0
- package/dist/mask/legacy_0254/digit_pii.d.ts +46 -0
- package/dist/mask/legacy_0254/digit_pii.d.ts.map +1 -0
- package/dist/mask/legacy_0254/digit_pii.js +230 -0
- package/dist/mask/legacy_0254/digit_pii.js.map +1 -0
- package/dist/mask/legacy_0254/iban.d.ts +56 -0
- package/dist/mask/legacy_0254/iban.d.ts.map +1 -0
- package/dist/mask/legacy_0254/iban.js +171 -0
- package/dist/mask/legacy_0254/iban.js.map +1 -0
- package/dist/mask/legacy_0254/ip_detect.d.ts +28 -0
- package/dist/mask/legacy_0254/ip_detect.d.ts.map +1 -0
- package/dist/mask/legacy_0254/ip_detect.js +92 -0
- package/dist/mask/legacy_0254/ip_detect.js.map +1 -0
- package/dist/mask/legacy_0254/legacy_governance_mask.d.ts +20 -0
- package/dist/mask/legacy_0254/legacy_governance_mask.d.ts.map +1 -0
- package/dist/mask/legacy_0254/legacy_governance_mask.js +171 -0
- package/dist/mask/legacy_0254/legacy_governance_mask.js.map +1 -0
- package/dist/mask/legacy_0254/legacy_mask_text.d.ts +11 -0
- package/dist/mask/legacy_0254/legacy_mask_text.d.ts.map +1 -0
- package/dist/mask/legacy_0254/legacy_mask_text.js +46 -0
- package/dist/mask/legacy_0254/legacy_mask_text.js.map +1 -0
- package/dist/mask/legacy_0254/mrz.d.ts +7 -0
- package/dist/mask/legacy_0254/mrz.d.ts.map +1 -0
- package/dist/mask/legacy_0254/mrz.js +74 -0
- package/dist/mask/legacy_0254/mrz.js.map +1 -0
- package/dist/mask/legacy_0254/pii_normalize.d.ts +38 -0
- package/dist/mask/legacy_0254/pii_normalize.d.ts.map +1 -0
- package/dist/mask/legacy_0254/pii_normalize.js +96 -0
- package/dist/mask/legacy_0254/pii_normalize.js.map +1 -0
- package/dist/mask/legacy_0254/safe-object.d.ts +14 -0
- package/dist/mask/legacy_0254/safe-object.d.ts.map +1 -0
- package/dist/mask/legacy_0254/safe-object.js +27 -0
- package/dist/mask/legacy_0254/safe-object.js.map +1 -0
- package/dist/mask/legacy_0254/tckn.d.ts +10 -0
- package/dist/mask/legacy_0254/tckn.d.ts.map +1 -0
- package/dist/mask/legacy_0254/tckn.js +70 -0
- package/dist/mask/legacy_0254/tckn.js.map +1 -0
- package/dist/mask/legacy_0254/types.d.ts +207 -0
- package/dist/mask/legacy_0254/types.d.ts.map +1 -0
- package/dist/mask/legacy_0254/types.js +2 -0
- package/dist/mask/legacy_0254/types.js.map +1 -0
- package/dist/mask-text.d.ts +11 -1
- package/dist/mask-text.d.ts.map +1 -1
- package/dist/mask-text.js +189 -30
- package/dist/mask-text.js.map +1 -1
- package/docs/claims/reviews/0.2.54.md +20 -0
- package/docs/claims/reviews/0.3.0.md +72 -0
- package/examples/per-user-identity/README.md +6 -6
- package/examples/per-user-identity/mint-token.mjs +1 -1
- package/examples/per-user-identity/policy.overlay.json +3 -3
- package/examples/per-user-identity/prove-identity.mjs +21 -21
- package/package.json +5 -1
- package/scripts/conarium_sabah_brief.mjs +0 -107
- package/scripts/start-mcp-c1.mjs +0 -93
|
@@ -4,12 +4,12 @@ Today a shared token writes `assurance: shared-token` and names nobody.
|
|
|
4
4
|
The code for `policy.profiles` / `policy.actorProfiles` is already in
|
|
5
5
|
`src/governance.ts`. This directory is the operator kit to turn it on
|
|
6
6
|
**locally**, prove it, and roll it back. Copying to `/opt/conarium-mcp`
|
|
7
|
-
is a separate
|
|
7
|
+
is a separate owner decision.
|
|
8
8
|
|
|
9
9
|
## 1. Mint tokens (hash only on disk)
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
node examples/per-user-identity/mint-token.mjs --id
|
|
12
|
+
node examples/per-user-identity/mint-token.mjs --id alice --file ./conarium.tokens.json
|
|
13
13
|
node examples/per-user-identity/mint-token.mjs --id copilot --file ./conarium.tokens.json
|
|
14
14
|
```
|
|
15
15
|
|
|
@@ -28,7 +28,7 @@ Merge `policy.overlay.json` under `policy` of the live c2
|
|
|
28
28
|
config. Do **not** replace `allowTables` / connectors.
|
|
29
29
|
|
|
30
30
|
- Base (AI / unlisted actor): names stay masked.
|
|
31
|
-
- `
|
|
31
|
+
- `alice` → profile `owner`: name columns visible; email / TCKN / IBAN
|
|
32
32
|
scanners still run (a profile cannot switch those off).
|
|
33
33
|
|
|
34
34
|
Backup first:
|
|
@@ -44,9 +44,9 @@ npm run build
|
|
|
44
44
|
node examples/per-user-identity/prove-identity.mjs
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Same row, two tokens:
|
|
48
|
-
Both receipts carry `assurance: per-user-token`. The
|
|
49
|
-
`policy.id` is `conarium.policy/
|
|
47
|
+
Same row, two tokens: owner sees the name, the other sees `[MASKED_PII]`.
|
|
48
|
+
Both receipts carry `assurance: per-user-token`. The owner receipt's
|
|
49
|
+
`policy.id` is `conarium.policy/owner`; the other stays `conarium.policy`.
|
|
50
50
|
`conarium-verify` must exit 0.
|
|
51
51
|
|
|
52
52
|
## 4. Rollback (one command)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The file stores SHA-256 only. The raw token is printed once, to stdout,
|
|
6
6
|
* and is never written. 0600 on POSIX.
|
|
7
7
|
*
|
|
8
|
-
* node mint-token.mjs --id
|
|
8
|
+
* node mint-token.mjs --id alice [--file ./conarium.tokens.json]
|
|
9
9
|
*
|
|
10
10
|
* Exit: 0 wrote · 1 refused · 2 could not run
|
|
11
11
|
*/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "Overlay for a live conarium.config.c2.json. Merge under policy. Do not replace allowTables/denyTables/connectors. Base policy (AI) keeps names masked; the
|
|
2
|
+
"_comment": "Overlay for a live conarium.config.c2.json. Merge under policy. Do not replace allowTables/denyTables/connectors. Base policy (AI) keeps names masked; the owner profile unmasks name columns only. Email/TCKN/IBAN scanners still run.",
|
|
3
3
|
"policy": {
|
|
4
4
|
"maskColumns": ["*.customer_name", "*.email", "*.phone", "*.tckn", "*.iban"],
|
|
5
5
|
"profiles": {
|
|
6
|
-
"
|
|
6
|
+
"owner": {
|
|
7
7
|
"maskColumns": ["*.email", "*.phone", "*.tckn", "*.iban"],
|
|
8
8
|
"maskLabelledNames": false
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"actorProfiles": {
|
|
12
|
-
"
|
|
12
|
+
"alice": "owner"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -34,11 +34,11 @@ const receiptSink = join(dir, 'receipts.jsonl')
|
|
|
34
34
|
const auditSink = join(dir, 'audit.jsonl')
|
|
35
35
|
mkdirSync(dir, { recursive: true })
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const ownerRaw = randomBytes(32).toString('base64url')
|
|
38
38
|
const aiRaw = randomBytes(32).toString('base64url')
|
|
39
39
|
writeFileSync(tokensFile, JSON.stringify({
|
|
40
40
|
tokens: [
|
|
41
|
-
{ sha256: createHash('sha256').update(
|
|
41
|
+
{ sha256: createHash('sha256').update(ownerRaw).digest('hex'), id: 'alice' },
|
|
42
42
|
{ sha256: createHash('sha256').update(aiRaw).digest('hex'), id: 'copilot' },
|
|
43
43
|
],
|
|
44
44
|
}) + '\n')
|
|
@@ -52,38 +52,38 @@ const policy = {
|
|
|
52
52
|
allowTables: ['public.customers'],
|
|
53
53
|
maskColumns: ['*.customer_name', '*.email', '*.phone', '*.tckn', '*.iban'],
|
|
54
54
|
profiles: {
|
|
55
|
-
|
|
55
|
+
owner: {
|
|
56
56
|
maskColumns: ['*.email', '*.phone', '*.tckn', '*.iban'],
|
|
57
57
|
maskLabelledNames: false,
|
|
58
58
|
},
|
|
59
59
|
},
|
|
60
|
-
actorProfiles: {
|
|
60
|
+
actorProfiles: { alice: 'owner' },
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const store = loadTokenStore(tokensFile)
|
|
64
|
-
const
|
|
64
|
+
const owner = resolveActor(ownerRaw, store, 'conarium_c2')
|
|
65
65
|
const ai = resolveActor(aiRaw, store, 'conarium_c2')
|
|
66
|
-
if (
|
|
66
|
+
if (owner.assurance !== 'per-user-token' || owner.id !== 'alice') fail(`owner resolve: ${JSON.stringify(owner)}`)
|
|
67
67
|
if (ai.assurance !== 'per-user-token' || ai.id !== 'copilot') fail(`ai resolve: ${JSON.stringify(ai)}`)
|
|
68
68
|
|
|
69
69
|
const row = { _table: 'public.customers', customer_name: 'Ayşe Yılmaz', email: 'a@b.com', city: 'İzmir' }
|
|
70
70
|
const base = new Governance(policy)
|
|
71
|
-
const
|
|
71
|
+
const asOwner = base.forActor(owner)
|
|
72
72
|
const asAi = base.forActor(ai)
|
|
73
73
|
|
|
74
|
-
const
|
|
74
|
+
const ownerOut = asOwner.redact({ rows: [row], rowCount: 1, fields: Object.keys(row) })
|
|
75
75
|
const aiOut = asAi.redact({ rows: [row], rowCount: 1, fields: Object.keys(row) })
|
|
76
|
-
const pName =
|
|
76
|
+
const pName = ownerOut.rows[0].customer_name
|
|
77
77
|
const aName = aiOut.rows[0].customer_name
|
|
78
78
|
|
|
79
|
-
console.log(`
|
|
79
|
+
console.log(`owner name ${pName}`)
|
|
80
80
|
console.log(`ai name ${aName}`)
|
|
81
|
-
console.log(`
|
|
81
|
+
console.log(`owner email ${ownerOut.rows[0].email}`)
|
|
82
82
|
console.log(`ai email ${aiOut.rows[0].email}`)
|
|
83
83
|
|
|
84
|
-
if (pName !== 'Ayşe Yılmaz') fail(`
|
|
84
|
+
if (pName !== 'Ayşe Yılmaz') fail(`owner should see the name, got ${pName}`)
|
|
85
85
|
if (aName !== '[MASKED_PII]') fail(`ai should see [MASKED_PII], got ${aName}`)
|
|
86
|
-
if (
|
|
86
|
+
if (ownerOut.rows[0].email !== '[MASKED_PII]' || aiOut.rows[0].email !== '[MASKED_PII]') {
|
|
87
87
|
fail('email must stay masked for both (content scanner / remaining maskColumns)')
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -92,9 +92,9 @@ audit.log({
|
|
|
92
92
|
tool: 'query',
|
|
93
93
|
target: 'public.customers',
|
|
94
94
|
denied: false,
|
|
95
|
-
actor:
|
|
96
|
-
actorAssurance:
|
|
97
|
-
policyProfile:
|
|
95
|
+
actor: owner.id,
|
|
96
|
+
actorAssurance: owner.assurance,
|
|
97
|
+
policyProfile: asOwner.appliedProfile() || undefined,
|
|
98
98
|
rowsReturned: 1,
|
|
99
99
|
source: 'postgres',
|
|
100
100
|
})
|
|
@@ -112,15 +112,15 @@ audit.log({
|
|
|
112
112
|
const receipts = readFileSync(receiptSink, 'utf8').trim().split('\n').map((l) => JSON.parse(l))
|
|
113
113
|
if (receipts.length !== 2) fail(`expected 2 receipts, got ${receipts.length}`)
|
|
114
114
|
|
|
115
|
-
const [
|
|
116
|
-
console.log(`
|
|
117
|
-
console.log(`
|
|
115
|
+
const [rOwner, rAi] = receipts
|
|
116
|
+
console.log(`owner policy.id ${rOwner.policy.id}`)
|
|
117
|
+
console.log(`owner assurance ${rOwner.actor.assurance} actor.id=${rOwner.actor.id}`)
|
|
118
118
|
console.log(`ai policy.id ${rAi.policy.id}`)
|
|
119
119
|
console.log(`ai assurance ${rAi.actor.assurance} actor.id=${rAi.actor.id}`)
|
|
120
120
|
|
|
121
|
-
if (
|
|
121
|
+
if (rOwner.policy.id !== 'conarium.policy/owner') fail(`owner policy.id ${rOwner.policy.id}`)
|
|
122
122
|
if (rAi.policy.id !== 'conarium.policy') fail(`ai (no profile) policy.id ${rAi.policy.id}`)
|
|
123
|
-
if (
|
|
123
|
+
if (rOwner.actor.assurance !== 'per-user-token' || rAi.actor.assurance !== 'per-user-token') {
|
|
124
124
|
fail('both receipts must carry per-user-token')
|
|
125
125
|
}
|
|
126
126
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conarium-ai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"mcpName": "io.github.dogrucanemek-alt/conarium",
|
|
5
5
|
"//files-artefakt": "Generated files under examples/ (private key, receipt/audit JSONL) are EXCLUDED. .gitignore does not bind npm: because the allow-list contained 'examples', `npm publish` on a machine that had run the demo was shipping _keys/audit-ed25519.pem (PRIVATE KEY) and the receipts. test/pack_artefakt.mjs locks this. The exclusions are LIMITED to examples/: receipts.jsonl and .pub.pem under test-vectors/ MUST ship, or a third party cannot run the conformance vectors.",
|
|
6
6
|
"//files": "Allow-list of what enters the package. Without it npm sent everything: 296 files / 1.5 MB — CI workflows, gitleaks config, a 137 KB marketing image, the site's api/chat.js. A bank security team opens the tarball and sees those. scripts/ is here ON PURPOSE: conarium-reconcile references scripts/pg-snapshot.sql at runtime; without it the user files a support mail.",
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"dist",
|
|
9
9
|
"bin",
|
|
10
10
|
"scripts",
|
|
11
|
+
"!scripts/conarium_sabah_brief.mjs",
|
|
12
|
+
"!scripts/start-mcp-c1.mjs",
|
|
11
13
|
"docs",
|
|
12
14
|
"!docs/reviews",
|
|
13
15
|
"!docs/teaching",
|
|
@@ -115,12 +117,14 @@
|
|
|
115
117
|
"bench:overhead": "node scripts/benchmark-overhead.mjs"
|
|
116
118
|
},
|
|
117
119
|
"dependencies": {
|
|
120
|
+
"@eslint-community/regexpp": "4.12.2",
|
|
118
121
|
"@guanmingchiu/sqlparser-ts": "^0.62.0",
|
|
119
122
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
120
123
|
"express": "^5.2.1",
|
|
121
124
|
"node-sql-parser": "^5.4.0",
|
|
122
125
|
"pgsql-ast-parser": "^12.0.2",
|
|
123
126
|
"postgres": "^3.4.4",
|
|
127
|
+
"re2js": "2.8.6",
|
|
124
128
|
"zod": "4.5.4"
|
|
125
129
|
},
|
|
126
130
|
"devDependencies": {
|
|
@@ -1,107 +0,0 @@
|
|
|
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 `_Error: ${payload.error}_\n`
|
|
58
|
-
const rows = payload?.rows || []
|
|
59
|
-
if (!rows.length) return '_empty_\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 morning — ${now}
|
|
80
|
-
|
|
81
|
-
> Source: zion-rest (Codes sync mirror). Not live Codes. PII-masked fields omitted.
|
|
82
|
-
|
|
83
|
-
## 1) Dead stock
|
|
84
|
-
${fmtRows(r[2], 3)}
|
|
85
|
-
|
|
86
|
-
## 2) Branch summary
|
|
87
|
-
${fmtRows(r[3], 10)}
|
|
88
|
-
|
|
89
|
-
## 3) Stock runout
|
|
90
|
-
${fmtRows(r[4], 10)}
|
|
91
|
-
|
|
92
|
-
## 4) Shipment summary
|
|
93
|
-
${fmtRows(r[5], 3)}
|
|
94
|
-
|
|
95
|
-
## Note
|
|
96
|
-
- If |margin| looks wild, test the cost / data-error hypothesis first.
|
|
97
|
-
- Interpret the three moves with the \`conarium-sabah\` agent skill.
|
|
98
|
-
|
|
99
|
-
## stderr (short)
|
|
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
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
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)
|