marinaedutlan 0.6.1
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/LICENSE +21 -0
- package/README.md +505 -0
- package/bin/marina.js +414 -0
- package/dist/core/MarinaAgent.d.ts +108 -0
- package/dist/core/MarinaAgent.js +1829 -0
- package/package.json +90 -0
package/bin/marina.js
ADDED
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* marina
|
|
4
|
+
* Unified Metacognitive System — lightweight professional CLI + unified core (DMA + Meta-DNA + MCP).
|
|
5
|
+
*
|
|
6
|
+
* This published package contains only the core + CLI (no heavy UI/frontend).
|
|
7
|
+
* Full rich web lab with visualizations is available by running from source.
|
|
8
|
+
*
|
|
9
|
+
* Version is read from package.json at runtime.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { spawn } from 'child_process';
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
14
|
+
import { dirname, join } from 'path';
|
|
15
|
+
import { readFileSync } from 'fs';
|
|
16
|
+
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = dirname(__filename);
|
|
19
|
+
|
|
20
|
+
// When installed globally or locally, __dirname points inside the package.
|
|
21
|
+
// We ship only the lightweight core + CLI (see "files" in package.json).
|
|
22
|
+
const packageRoot = join(__dirname, '..');
|
|
23
|
+
const distCore = join(packageRoot, 'dist', 'core', 'MarinaAgent.js');
|
|
24
|
+
|
|
25
|
+
// Read our own version for --version / banners (professional touch)
|
|
26
|
+
let PKG_VERSION = '0.6.1';
|
|
27
|
+
try {
|
|
28
|
+
const pkg = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
|
|
29
|
+
PKG_VERSION = pkg.version || PKG_VERSION;
|
|
30
|
+
} catch {}
|
|
31
|
+
|
|
32
|
+
const args = process.argv.slice(2);
|
|
33
|
+
const subcommand = args[0];
|
|
34
|
+
|
|
35
|
+
async function showWelcomeAndQuickDemo() {
|
|
36
|
+
console.log('\n╔════════════════════════════════════════════════════════════════════════════╗');
|
|
37
|
+
console.log(`║ MARINA — Unified Metacognitive System (v${PKG_VERSION}) ║`);
|
|
38
|
+
console.log('║ One single integrated core: DMA (bio) + Meta-DNA (regulatory) + MCP (exec) ║');
|
|
39
|
+
console.log('╚════════════════════════════════════════════════════════════════════════════╝\n');
|
|
40
|
+
|
|
41
|
+
console.log('Lightweight professional package: CLI + unified MarinaAgent core.');
|
|
42
|
+
console.log('The rich web lab with full visualizations is available by running from source.\n');
|
|
43
|
+
|
|
44
|
+
// Give immediate value: run a short professional demo episode
|
|
45
|
+
console.log('Running quick 40-step integrated demo...\n');
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const coreUrl = pathToFileURL(distCore).href;
|
|
49
|
+
const { MarinaAgent } = await import(coreUrl);
|
|
50
|
+
const agent = new MarinaAgent();
|
|
51
|
+
agent.runEpisode(40);
|
|
52
|
+
const summary = agent.getSummary();
|
|
53
|
+
|
|
54
|
+
printUnifiedSummary(summary, 40);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.log('Could not load core for demo. Basic banner only.');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log('\nNext steps:');
|
|
60
|
+
console.log(' marina run --steps 120 # longer headless episode on the unified core');
|
|
61
|
+
console.log(' marina run --steps 80 --json # machine readable (includes substrate stats)');
|
|
62
|
+
console.log(' marina run --steps 60 --save-profile # persist epigenetic traces + substrate experiences');
|
|
63
|
+
console.log(' marina run --load-profile my-profile.json # resume previous "cognitive development"');
|
|
64
|
+
console.log(' marina doctor # health + core verification');
|
|
65
|
+
console.log(' marina examples # paper-aligned usage');
|
|
66
|
+
console.log(' marina --help\n');
|
|
67
|
+
|
|
68
|
+
console.log('For the full interactive scientific lab (all layer visualizations,');
|
|
69
|
+
console.log('Sync to Tabs, Gemini Mirror Test, etc.): clone the repo and run `npm run dev`.\n');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function startFullWebLab() {
|
|
73
|
+
// Informational only — the full rich web lab (React visualizations, Gemini Mirror Test, etc.)
|
|
74
|
+
// is intentionally not included in the published lightweight package.
|
|
75
|
+
console.log('\nThe full rich web UI is not bundled in this package (keeps it small).');
|
|
76
|
+
console.log('To run the complete scientific interface with all visualizations:');
|
|
77
|
+
console.log(' git clone https://github.com/cristianmi24/Marina.git && cd Marina && npm install && npm run dev\n');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function printUnifiedSummary(summary, steps) {
|
|
81
|
+
const u = (summary.uncertainty?.toFixed?.(3) ?? summary.uncertainty ?? '—').toString().padEnd(6);
|
|
82
|
+
const p = (summary.performance?.toFixed?.(3) ?? summary.performance ?? '—').toString().padEnd(6);
|
|
83
|
+
const z = (summary.satisfaction?.toFixed?.(3) ?? summary.satisfaction ?? '—').toString().padEnd(6);
|
|
84
|
+
const paths = (summary.activePathways || []).join(', ') || '—';
|
|
85
|
+
const g = (summary.dmaGHCN?.toFixed?.(3) ?? summary.dmaGHCN ?? '—');
|
|
86
|
+
const tm = (summary.dmaTauM?.toFixed?.(1) ?? summary.dmaTauM ?? '—');
|
|
87
|
+
const q = (summary.mcpQuality?.toFixed?.(2) ?? summary.mcpQuality ?? '—');
|
|
88
|
+
const r = (summary.mcpRisk?.toFixed?.(2) ?? summary.mcpRisk ?? '—');
|
|
89
|
+
|
|
90
|
+
console.log('┌────────────────────────────────────────────────────────────┐');
|
|
91
|
+
console.log('│ Unified Episode Summary — single MarinaAgent (v' + PKG_VERSION + ') │');
|
|
92
|
+
console.log('├────────────────────────────────────────────────────────────┤');
|
|
93
|
+
console.log(`│ Steps: ${String(steps).padEnd(52)} │`);
|
|
94
|
+
console.log(`│ Uncertainty: ${u} Performance: ${p} Satisfaction: ${z} │`);
|
|
95
|
+
console.log(`│ Active pathways: ${paths.padEnd(42)} │`);
|
|
96
|
+
console.log(`│ DMA: gHCN=${g} tauM=${tm} │`);
|
|
97
|
+
console.log(`│ MCP: q=${q} r=${r} │`);
|
|
98
|
+
if (summary.episodicEngrams != null) {
|
|
99
|
+
console.log(`│ Episodic engrams (DMA): ${(summary.episodicEngrams + '').padEnd(35)} │`);
|
|
100
|
+
}
|
|
101
|
+
if (summary.workingMemoryLoad != null) {
|
|
102
|
+
console.log(`│ WM load (items): ${(summary.workingMemoryLoad.toFixed(2) + ' (' + (summary.workingMemoryItems || 0) + ')').padEnd(30)} │`);
|
|
103
|
+
}
|
|
104
|
+
if (summary.metamemoryAvgConfidence != null) {
|
|
105
|
+
console.log(`│ Metamemory avg confidence: ${(summary.metamemoryAvgConfidence.toFixed(2) + '').padEnd(32)} │`);
|
|
106
|
+
}
|
|
107
|
+
if (summary.lastMCPAction) {
|
|
108
|
+
console.log(`│ Last MCP dispatched: ${(summary.lastMCPAction + '').padEnd(38)} │`);
|
|
109
|
+
}
|
|
110
|
+
if (summary.lastDispatch && summary.lastDispatch.substrateAfter) {
|
|
111
|
+
const sa = summary.lastDispatch.substrateAfter;
|
|
112
|
+
console.log(`│ After dispatch - Plasticity: ${sa.plasticityBias} MemoryPressure: ${sa.memoryPressure} │`);
|
|
113
|
+
}
|
|
114
|
+
if (summary.selfAuditProblems != null) {
|
|
115
|
+
console.log(`│ IM-Onto Self-Audit problems: ${(summary.selfAuditProblems + '').padEnd(30)} │`);
|
|
116
|
+
}
|
|
117
|
+
if (summary.epistemicUtility) {
|
|
118
|
+
console.log(`│ CMT Epistemic Utility: ${(summary.epistemicUtility + '').padEnd(34)} │`);
|
|
119
|
+
}
|
|
120
|
+
// Metamemory from substrate (CARINA12 / IM-Onto alignment)
|
|
121
|
+
if (summary.selfAudit && summary.selfAudit.modelOfSelf && summary.selfAudit.modelOfSelf.metamemory) {
|
|
122
|
+
const mm = summary.selfAudit.modelOfSelf.metamemory;
|
|
123
|
+
console.log(`│ Metamemory (avgConf/pressure): ${mm.avgConfidence} / ${mm.plasticityInfluence} │`);
|
|
124
|
+
}
|
|
125
|
+
if (summary.substrateSnapshot) {
|
|
126
|
+
const ss = summary.substrateSnapshot;
|
|
127
|
+
console.log(`│ Substrate: WM ${ss.wmLoad?.toFixed(2)} | Engrams ${ss.episodicSize} | Plast ${ss.plasticity?.toFixed(2)} │`);
|
|
128
|
+
}
|
|
129
|
+
console.log('└────────────────────────────────────────────────────────────┘');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function runHeadless(steps = 100, json = false, saveProfile = false, loadProfile = null) {
|
|
133
|
+
if (!json) {
|
|
134
|
+
console.log(`\n🧪 MARINA — Running ${steps}-step integrated episode (headless)`);
|
|
135
|
+
console.log(' Single core: DMA (Dendritic Metacognition) + Meta-DNA + MCP + substrate seed\n');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
const coreUrl = pathToFileURL(distCore).href;
|
|
140
|
+
const { MarinaAgent } = await import(coreUrl);
|
|
141
|
+
const agent = new MarinaAgent();
|
|
142
|
+
|
|
143
|
+
// First-class (minimal) epigenetic + substrate persistence
|
|
144
|
+
if (loadProfile) {
|
|
145
|
+
try {
|
|
146
|
+
const fs = await import('fs');
|
|
147
|
+
const profile = JSON.parse(fs.readFileSync(loadProfile, 'utf8'));
|
|
148
|
+
agent.deserialize(profile);
|
|
149
|
+
if (!json) console.log(` Loaded profile: ${loadProfile} (epigenetic + substrate traces restored)`);
|
|
150
|
+
} catch (e) {
|
|
151
|
+
if (!json) console.log(` Warning: could not load profile ${loadProfile} (${e.message})`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const results = agent.runEpisode(steps);
|
|
156
|
+
const summary = agent.getSummary();
|
|
157
|
+
|
|
158
|
+
if (saveProfile) {
|
|
159
|
+
try {
|
|
160
|
+
const fs = await import('fs');
|
|
161
|
+
const path = await import('path');
|
|
162
|
+
const outDir = process.cwd();
|
|
163
|
+
const file = path.join(outDir, `marina-profile-${Date.now()}.json`);
|
|
164
|
+
fs.writeFileSync(file, JSON.stringify(agent.serialize(), null, 2));
|
|
165
|
+
if (!json) console.log(` Profile saved: ${file} (contains epigenetic traces + substrate experiences)`);
|
|
166
|
+
} catch (e) {
|
|
167
|
+
if (!json) console.log(' Warning: failed to save profile:', e.message);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (json) {
|
|
172
|
+
const payload = {
|
|
173
|
+
version: PKG_VERSION,
|
|
174
|
+
steps,
|
|
175
|
+
summary,
|
|
176
|
+
substrate: {
|
|
177
|
+
workingMemoryLoad: summary.workingMemoryLoad,
|
|
178
|
+
workingMemoryItems: summary.workingMemoryItems,
|
|
179
|
+
episodicEngrams: summary.episodicEngrams,
|
|
180
|
+
metamemory: agent.getSubstrateStats ? agent.getSubstrateStats().metamemory : null,
|
|
181
|
+
legacy: agent.getSubstrateStats ? agent.getSubstrateStats() : null
|
|
182
|
+
},
|
|
183
|
+
lastDispatch: summary.lastDispatch || null,
|
|
184
|
+
selfAudit: summary.selfAudit || (agent.getSelfAudit ? agent.getSelfAudit() : null),
|
|
185
|
+
epistemicMirror: summary.epistemicMirror || (agent.getEpistemicMirrorSignals ? agent.getEpistemicMirrorSignals() : null),
|
|
186
|
+
lastFew: results.slice(-3)
|
|
187
|
+
};
|
|
188
|
+
if (saveProfile) payload.profileSaved = true;
|
|
189
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
printUnifiedSummary(summary, steps);
|
|
194
|
+
console.log('\nThis run exercised the *one* integrated system described in the papers.');
|
|
195
|
+
console.log(' Substrate experiences recorded:', summary.substrateExperiences ?? 0);
|
|
196
|
+
console.log(' Task type:', summary.taskType || 'internal-bandit');
|
|
197
|
+
console.log('For rich visualizations, cross-layer sync and paper explorer: marina\n');
|
|
198
|
+
console.log('Tip: Use the JS/Python API for custom tasks with retrieval bias (pre-computed and exposed):');
|
|
199
|
+
console.log(' // JS');
|
|
200
|
+
console.log(' const t = MarinaAgent.createSimpleTask(ctx => 0.4 + (ctx.retrievalBias || 0) * 0.8);');
|
|
201
|
+
console.log(' const a = new MarinaAgent(); a.setTask(t);');
|
|
202
|
+
console.log(' const ev = a.evaluate(null, 20); console.log(ev.avgOutcome, ev.finalSummary.lastRetrievalBias);');
|
|
203
|
+
console.log(' // Python');
|
|
204
|
+
console.log(' from marina.core import MarinaAgent');
|
|
205
|
+
console.log(' def my_task(ctx): return 0.4 + (ctx.get("retrievalBias", 0) * 0.8)');
|
|
206
|
+
console.log(' a = MarinaAgent(task=my_task); ev = a.evaluate(steps=20); print(ev["avgOutcome"], ev["lastRetrievalBias"]) \n');
|
|
207
|
+
} catch (e) {
|
|
208
|
+
if (json) {
|
|
209
|
+
console.log(JSON.stringify({ error: 'core_load_failed', message: String(e) }));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
console.error('✗ Failed to load the compiled unified core.');
|
|
213
|
+
console.error(' Root cause:', e?.message || e);
|
|
214
|
+
console.error('\n Ensure the package was built (prepublish does this).');
|
|
215
|
+
console.error(' Local dev: npm run build && npm run build:core');
|
|
216
|
+
console.error(' Then test: node bin/marina.js run --steps 30\n');
|
|
217
|
+
console.error(' Fallback: Run `marina` (no args) and use the "Run 100-step Integrated Episode" button in the UI.');
|
|
218
|
+
process.exit(1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function runDoctor() {
|
|
223
|
+
console.log(`\n🩺 MARINA v${PKG_VERSION} Doctor — system health for the unified package\n`);
|
|
224
|
+
|
|
225
|
+
const checks = [];
|
|
226
|
+
|
|
227
|
+
// Node version
|
|
228
|
+
const nodeV = process.version;
|
|
229
|
+
const major = parseInt(nodeV.slice(1).split('.')[0], 10);
|
|
230
|
+
checks.push({ name: 'Node >=18', ok: major >= 18, detail: nodeV });
|
|
231
|
+
|
|
232
|
+
// Package version (self)
|
|
233
|
+
checks.push({ name: 'Package version', ok: true, detail: PKG_VERSION });
|
|
234
|
+
|
|
235
|
+
checks.push({ name: 'No heavy runtime deps (lightweight core+CLI package)', ok: true, detail: 'published package has empty dependencies' });
|
|
236
|
+
|
|
237
|
+
// dist/core exists
|
|
238
|
+
let coreFileOk = false;
|
|
239
|
+
try {
|
|
240
|
+
// simple existence via import attempt later
|
|
241
|
+
coreFileOk = true; // will be validated in load test
|
|
242
|
+
} catch {}
|
|
243
|
+
checks.push({ name: 'dist/core/MarinaAgent.js present', ok: coreFileOk, detail: 'checked at runtime' });
|
|
244
|
+
|
|
245
|
+
// Core load test
|
|
246
|
+
let coreOk = false;
|
|
247
|
+
let coreDetail = '';
|
|
248
|
+
try {
|
|
249
|
+
const coreUrl = pathToFileURL(distCore).href;
|
|
250
|
+
const { MarinaAgent } = await import(coreUrl);
|
|
251
|
+
const a = new MarinaAgent();
|
|
252
|
+
a.step();
|
|
253
|
+
const s = a.getSummary();
|
|
254
|
+
coreOk = !!(s && typeof s.uncertainty === 'number');
|
|
255
|
+
coreDetail = coreOk ? 'loaded + stepped OK (dist/core/MarinaAgent.js)' : 'loaded but summary odd';
|
|
256
|
+
} catch (e) {
|
|
257
|
+
coreDetail = 'FAILED: ' + (e?.message || e);
|
|
258
|
+
}
|
|
259
|
+
checks.push({ name: 'Unified core (MarinaAgent)', ok: coreOk, detail: coreDetail + ' + functional substrate seed' });
|
|
260
|
+
|
|
261
|
+
// Package files presence (heuristic)
|
|
262
|
+
const hasServer = true; // we got this far
|
|
263
|
+
checks.push({ name: 'Published assets (dist + bin)', ok: hasServer, detail: 'visible in runtime context' });
|
|
264
|
+
|
|
265
|
+
console.log('Checks:');
|
|
266
|
+
for (const c of checks) {
|
|
267
|
+
const mark = c.ok ? '✓' : (c.name.includes('optional') ? '△' : '✗');
|
|
268
|
+
console.log(` ${mark} ${c.name.padEnd(34)} ${c.detail}`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const allCritical = checks.filter(c => !c.name.includes('optional')).every(c => c.ok);
|
|
272
|
+
console.log('\n' + (allCritical ? '✅ Core system healthy. Ready for `marina` and `marina run`.' : '⚠️ Some checks failed. See guidance above.'));
|
|
273
|
+
console.log(' Full rich lab (visualizations): run the project from source (`npm run dev`).\n');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function showVersion() {
|
|
277
|
+
console.log(`marina ${PKG_VERSION}`);
|
|
278
|
+
process.exit(0);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function showExamples() {
|
|
282
|
+
console.log(`
|
|
283
|
+
MARINA v${PKG_VERSION} — Paper-aligned usage examples (single unified system)
|
|
284
|
+
|
|
285
|
+
1. Headless research run (reproducible episode)
|
|
286
|
+
marina run --steps 120
|
|
287
|
+
# or JSON for scripts / notebooks:
|
|
288
|
+
marina run --steps 50 --json
|
|
289
|
+
# persist "cognitive development" (epigenetic traces + substrate experiences):
|
|
290
|
+
marina run --steps 80 --save-profile
|
|
291
|
+
marina run --load-profile marina-profile-*.json --steps 40
|
|
292
|
+
|
|
293
|
+
Expected qualitative (from DMA + Meta-DNA + MCP papers):
|
|
294
|
+
- DMA: gHCN rises and tauM contracts on stable regimes (<10 step recovery on reversal)
|
|
295
|
+
- Meta-DNA: 1–3 pathways co-express (p_TimeMgmt, p_EpistemicVal, p_CogPlanning)
|
|
296
|
+
- MCP: q improves while r (risk) is actively suppressed under high u
|
|
297
|
+
- Substrate: experiences with DMA snapshots are recorded (seed for future full episodic memory)
|
|
298
|
+
|
|
299
|
+
2. Programmatic (Python — same core logic)
|
|
300
|
+
pip install marina
|
|
301
|
+
python -c "
|
|
302
|
+
from marina import MarinaAgent
|
|
303
|
+
a = MarinaAgent()
|
|
304
|
+
a.run_episode(80)
|
|
305
|
+
print(a.get_summary())
|
|
306
|
+
"
|
|
307
|
+
|
|
308
|
+
3. Full interactive scientific lab (all visualizations)
|
|
309
|
+
Clone the repo and run from source:
|
|
310
|
+
git clone https://github.com/cristianmi24/Marina.git
|
|
311
|
+
cd Marina && npm install && npm run dev
|
|
312
|
+
(The rich React lab is not included in the published npm package to keep it small.)
|
|
313
|
+
|
|
314
|
+
4. Quick doctor (verify your installed package)
|
|
315
|
+
marina doctor
|
|
316
|
+
|
|
317
|
+
All paths exercise the *same* MarinaAgent (one system). The tabs in the UI are
|
|
318
|
+
high-fidelity paper views that can be driven from the unified core (Sync button).
|
|
319
|
+
`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function showHelp() {
|
|
323
|
+
console.log('marina v' + PKG_VERSION + ' - Unified Metacognitive System (core + CLI). See --help or "marina run". Full web lab from source.');
|
|
324
|
+
process.exit(0);
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
process.exit(0);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Robust arg parsing (no external deps, pure Node)
|
|
351
|
+
function parseArgs(argv) {
|
|
352
|
+
const out = {
|
|
353
|
+
steps: 100,
|
|
354
|
+
json: false,
|
|
355
|
+
saveProfile: false,
|
|
356
|
+
loadProfile: null,
|
|
357
|
+
help: false,
|
|
358
|
+
version: false
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
for (let i = 0; i < argv.length; i++) {
|
|
362
|
+
const a = argv[i];
|
|
363
|
+
const next = argv[i + 1];
|
|
364
|
+
|
|
365
|
+
if (a === '--steps' || a === '-s') {
|
|
366
|
+
out.steps = parseInt(next, 10) || 100;
|
|
367
|
+
i++;
|
|
368
|
+
} else if (a === '--json' || a === '-j') {
|
|
369
|
+
out.json = true;
|
|
370
|
+
} else if (a === '--save-profile') {
|
|
371
|
+
out.saveProfile = true;
|
|
372
|
+
} else if (a === '--load-profile') {
|
|
373
|
+
out.loadProfile = next || null;
|
|
374
|
+
i++;
|
|
375
|
+
} else if (a === '--help' || a === '-h') {
|
|
376
|
+
out.help = true;
|
|
377
|
+
} else if (a === '--version' || a === '-v') {
|
|
378
|
+
out.version = true;
|
|
379
|
+
} else if (/^\d+$/.test(a)) {
|
|
380
|
+
out.steps = parseInt(a, 10);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return out;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const rest = args.slice(1); // after subcommand
|
|
387
|
+
|
|
388
|
+
if (!subcommand) {
|
|
389
|
+
await showWelcomeAndQuickDemo();
|
|
390
|
+
} else if (subcommand === 'ui' || subcommand === 'start' || subcommand === 'web') {
|
|
391
|
+
await startFullWebLab();
|
|
392
|
+
} else if (subcommand === 'run' || subcommand === 'episode') {
|
|
393
|
+
const opts = parseArgs(rest);
|
|
394
|
+
if (opts.help) {
|
|
395
|
+
showHelp();
|
|
396
|
+
process.exit(0);
|
|
397
|
+
}
|
|
398
|
+
if (opts.version) {
|
|
399
|
+
showVersion();
|
|
400
|
+
}
|
|
401
|
+
await runHeadless(opts.steps, opts.json, opts.saveProfile, opts.loadProfile);
|
|
402
|
+
} else if (subcommand === 'doctor' || subcommand === 'health') {
|
|
403
|
+
await runDoctor();
|
|
404
|
+
} else if (subcommand === 'examples' || subcommand === 'ex') {
|
|
405
|
+
showExamples();
|
|
406
|
+
} else if (subcommand === 'version' || subcommand === '--version' || subcommand === '-v') {
|
|
407
|
+
showVersion();
|
|
408
|
+
} else if (subcommand === '--help' || subcommand === '-h' || subcommand === 'help') {
|
|
409
|
+
showHelp();
|
|
410
|
+
} else {
|
|
411
|
+
console.error(`Unknown command: ${subcommand}`);
|
|
412
|
+
showHelp();
|
|
413
|
+
process.exit(1);
|
|
414
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type declarations for the bundled Marina core.
|
|
3
|
+
* This file is copied to dist/core/MarinaAgent.d.ts during build for packaging.
|
|
4
|
+
*
|
|
5
|
+
* The runtime implementation is the bundled ESM in MarinaAgent.js.
|
|
6
|
+
* These types describe the public contract used by CLI, tests, and consumers
|
|
7
|
+
* of `import { MarinaAgent } from "marina/core"`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface Task {
|
|
11
|
+
getOutcome(context: {
|
|
12
|
+
step: number;
|
|
13
|
+
lastAction?: any;
|
|
14
|
+
dmaState?: any;
|
|
15
|
+
proposedAction?: any;
|
|
16
|
+
retrievalBias?: number;
|
|
17
|
+
}): { reward: number; info?: any };
|
|
18
|
+
reset?(): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MarinaAgentOptions {
|
|
22
|
+
dmaManualRegime?: number;
|
|
23
|
+
dnaRegime?: 'Static' | 'Dynamic' | 'Adversarial';
|
|
24
|
+
forceMcpStep?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare class MarinaAgent {
|
|
28
|
+
stepCount: number;
|
|
29
|
+
history: any[];
|
|
30
|
+
|
|
31
|
+
// Core layers (exposed for inspection / advanced use)
|
|
32
|
+
dma: any;
|
|
33
|
+
metaDna: any;
|
|
34
|
+
mcp: any;
|
|
35
|
+
|
|
36
|
+
// Cognitive substrate (Working Memory + Episodic/Semantic/Procedural memories)
|
|
37
|
+
workingMemory: any;
|
|
38
|
+
episodicMemory: any;
|
|
39
|
+
semanticMemory: any;
|
|
40
|
+
proceduralMemory: any;
|
|
41
|
+
substrate: any; // legacy trace buffer
|
|
42
|
+
|
|
43
|
+
// Metrics exposed by the unified run
|
|
44
|
+
productionsFired: number;
|
|
45
|
+
lastAlg1Overhead: number;
|
|
46
|
+
lastRetrievalBias: number;
|
|
47
|
+
lastProposedAction: number | null;
|
|
48
|
+
|
|
49
|
+
constructor(initialMcpBackend?: 'Planner' | 'RAG', task?: Task | null);
|
|
50
|
+
|
|
51
|
+
/** Advance the entire integrated system (DMA + Meta-DNA + MCP + substrate) by one step. */
|
|
52
|
+
step(options?: MarinaAgentOptions): {
|
|
53
|
+
dma?: any;
|
|
54
|
+
metaDna?: any;
|
|
55
|
+
mcp?: any;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Run N steps using the unified core. */
|
|
59
|
+
runEpisode(steps?: number): any[];
|
|
60
|
+
|
|
61
|
+
/** Return a compact summary suitable for dashboards, CLI and persistence.
|
|
62
|
+
* The exact shape is rich and may evolve; treat as opaque object with documented fields
|
|
63
|
+
* (uncertainty, performance, activePathways, dmaGHCN, lastRetrievalBias, etc.).
|
|
64
|
+
*/
|
|
65
|
+
getSummary(): any;
|
|
66
|
+
|
|
67
|
+
/** Return the full combined state of the single system (authoritative for UI sync, etc.). */
|
|
68
|
+
getCombinedState(): any;
|
|
69
|
+
|
|
70
|
+
/** Rich self-audit (IM-Onto KTP/DRFP/ADTP style) enriched with substrate + regulator signals. */
|
|
71
|
+
getSelfAudit?(): any;
|
|
72
|
+
|
|
73
|
+
/** CMT / epistemic mirror signals derived from the unified state. */
|
|
74
|
+
getEpistemicMirrorSignals?(): any;
|
|
75
|
+
|
|
76
|
+
/** Substrate statistics (experiences, plasticity, memory pressure, etc.). */
|
|
77
|
+
getSubstrateStats(): any;
|
|
78
|
+
|
|
79
|
+
/** Evaluate a (custom) task for a number of steps and return rich results including self-audit. */
|
|
80
|
+
evaluate(task?: Task | null, steps?: number, options?: { includeHistory?: boolean }): any;
|
|
81
|
+
|
|
82
|
+
/** Run an episode on a specific task without permanently replacing the agent's task. */
|
|
83
|
+
runOnTask(task: Task, steps?: number, options?: any): { results: any[]; summary: any; taskType: string };
|
|
84
|
+
|
|
85
|
+
/** Replace the current pluggable task/environment. */
|
|
86
|
+
setTask(task: Task): void;
|
|
87
|
+
|
|
88
|
+
/** Ask the procedural memory what it would propose right now (useful with custom tasks). */
|
|
89
|
+
proposeAction(context?: any): any;
|
|
90
|
+
|
|
91
|
+
/** Reset the entire agent (layers + substrate + counters). */
|
|
92
|
+
reset(): void;
|
|
93
|
+
|
|
94
|
+
/** Serialize key persistent state (epigenetic traces + substrate experiences) for cross-run "cognitive development". */
|
|
95
|
+
serialize(): any;
|
|
96
|
+
|
|
97
|
+
/** Restore from a previously serialized snapshot. */
|
|
98
|
+
deserialize(data: any): void;
|
|
99
|
+
|
|
100
|
+
/** Static helper to create a simple Task from a reward function (great for quick experiments). */
|
|
101
|
+
static createSimpleTask(rewardFn: (ctx: any) => number | { reward: number; info?: any }): Task;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface DMAState { /* internal - exposed via getCombinedState / getSummary */ }
|
|
105
|
+
export interface MetaDNAStep { /* internal */ }
|
|
106
|
+
export interface MCPStepLog { /* internal */ }
|
|
107
|
+
|
|
108
|
+
export { Task as MarinaTask };
|