crbro-memory 1.0.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.
Files changed (59) hide show
  1. package/README.md +122 -0
  2. package/bin/crbro.js +99 -0
  3. package/dist/engine/brain.d.ts +43 -0
  4. package/dist/engine/brain.d.ts.map +1 -0
  5. package/dist/engine/brain.js +179 -0
  6. package/dist/engine/brain.js.map +1 -0
  7. package/dist/engine/cortex.d.ts +70 -0
  8. package/dist/engine/cortex.d.ts.map +1 -0
  9. package/dist/engine/cortex.js +219 -0
  10. package/dist/engine/cortex.js.map +1 -0
  11. package/dist/engine/heat.d.ts +28 -0
  12. package/dist/engine/heat.d.ts.map +1 -0
  13. package/dist/engine/heat.js +112 -0
  14. package/dist/engine/heat.js.map +1 -0
  15. package/dist/engine/hippocampus.d.ts +26 -0
  16. package/dist/engine/hippocampus.d.ts.map +1 -0
  17. package/dist/engine/hippocampus.js +73 -0
  18. package/dist/engine/hippocampus.js.map +1 -0
  19. package/dist/engine/license.d.ts +29 -0
  20. package/dist/engine/license.d.ts.map +1 -0
  21. package/dist/engine/license.js +109 -0
  22. package/dist/engine/license.js.map +1 -0
  23. package/dist/engine/maintenance.d.ts +41 -0
  24. package/dist/engine/maintenance.d.ts.map +1 -0
  25. package/dist/engine/maintenance.js +156 -0
  26. package/dist/engine/maintenance.js.map +1 -0
  27. package/dist/engine/prefrontal.d.ts +31 -0
  28. package/dist/engine/prefrontal.d.ts.map +1 -0
  29. package/dist/engine/prefrontal.js +149 -0
  30. package/dist/engine/prefrontal.js.map +1 -0
  31. package/dist/engine/synapses.d.ts +39 -0
  32. package/dist/engine/synapses.d.ts.map +1 -0
  33. package/dist/engine/synapses.js +154 -0
  34. package/dist/engine/synapses.js.map +1 -0
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +16 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/search/index.d.ts +31 -0
  40. package/dist/search/index.d.ts.map +1 -0
  41. package/dist/search/index.js +139 -0
  42. package/dist/search/index.js.map +1 -0
  43. package/dist/server.d.ts +3 -0
  44. package/dist/server.d.ts.map +1 -0
  45. package/dist/server.js +543 -0
  46. package/dist/server.js.map +1 -0
  47. package/dist/types/index.d.ts +121 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/index.js +5 -0
  50. package/dist/types/index.js.map +1 -0
  51. package/dist/utils/fs.d.ts +35 -0
  52. package/dist/utils/fs.d.ts.map +1 -0
  53. package/dist/utils/fs.js +110 -0
  54. package/dist/utils/fs.js.map +1 -0
  55. package/dist/utils/ids.d.ts +32 -0
  56. package/dist/utils/ids.d.ts.map +1 -0
  57. package/dist/utils/ids.js +92 -0
  58. package/dist/utils/ids.js.map +1 -0
  59. package/package.json +52 -0
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # 🧠 CRBRO β€” Persistent Neural Memory for AI
2
+
3
+ **CRBRO** is a local MCP (Model Context Protocol) server that gives your AI assistant **persistent long-term memory** across sessions. It uses a biological neural architecture β€” cortex, synapses, hippocampus β€” to store, connect, and retrieve knowledge automatically.
4
+
5
+ Part of the **[Synthetica Decks](https://synthetica-decks.web.app)** Zero Deck.
6
+
7
+ ## Features
8
+
9
+ - **🧬 Biological Architecture** β€” Knowledge organized as neurons (cortex), connections (synapses), and session memory (hippocampus)
10
+ - **πŸ” Hybrid Search** β€” Powered by [Orama](https://orama.com/) for fast BM25 + fuzzy text search
11
+ - **πŸ”₯ Heat Scores** β€” Automatic relevance tracking based on frequency, recency, and connectivity
12
+ - **πŸ—ΊοΈ Global Map** β€” Cluster detection and cross-domain bridge identification *(premium)*
13
+ - **πŸ“¦ Zero Dependencies** β€” Pure Node.js, no Python, no Docker, no external databases
14
+ - **πŸ’Ύ File-Based** β€” All data stored as readable JSON files in `~/.crbro/`
15
+ - **πŸ”Œ MCP Native** β€” Works with Claude Desktop, Cursor, Windsurf, and any MCP-compatible client
16
+
17
+ ## Quick Start
18
+
19
+ ### 1. Initialize
20
+
21
+ ```bash
22
+ npx crbro-memory init
23
+ ```
24
+
25
+ ### 2. Add to your MCP config
26
+
27
+ **Claude Desktop** (`~/AppData/Roaming/Claude/claude_desktop_config.json`):
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "crbro": {
32
+ "command": "npx",
33
+ "args": ["-y", "crbro-memory"]
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ **Cursor** (`.cursor/mcp.json`):
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "crbro": {
44
+ "command": "npx",
45
+ "args": ["-y", "crbro-memory"]
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### 3. Start using it
52
+
53
+ Your AI will now have access to 15 memory tools. Start any session with `crbro_boot`.
54
+
55
+ ## Tools
56
+
57
+ ### Free (always available)
58
+
59
+ | Tool | Description |
60
+ |------|-------------|
61
+ | `crbro_boot` | Boot the brain at session start β€” loads hot topics and context |
62
+ | `crbro_status` | Brain status β€” neurons, synapses, sessions count |
63
+ | `crbro_learn` | Store a fact, decision, pattern, or preference |
64
+ | `crbro_neuron` | Read a specific neuron (topic) with all its knowledge |
65
+ | `crbro_neurons` | List neurons with optional filters (domain, type, heat) |
66
+ | `crbro_recall` | Search the brain using hybrid text search |
67
+ | `crbro_connect` | Create or strengthen a connection between neurons |
68
+ | `crbro_connections` | Get all connections for a neuron |
69
+ | `crbro_session_log` | Log a session summary |
70
+ | `crbro_sessions` | List recent sessions |
71
+ | `crbro_context` | Read/update active working context |
72
+ | `crbro_hot_topics` | Get the most active topics by heat score |
73
+ | `crbro_consolidate` | End-of-session consolidation |
74
+
75
+ ### Premium (requires Synthetica Zero Deck license)
76
+
77
+ | Tool | Description |
78
+ |------|-------------|
79
+ | `crbro_global_map` | View the neural network β€” clusters and cross-domain bridges |
80
+ | `crbro_maintenance` | Full brain maintenance β€” archive, prune, rebuild |
81
+
82
+ ## Architecture
83
+
84
+ ```
85
+ ~/.crbro/
86
+ β”œβ”€β”€ manifest.json ← Brain metadata
87
+ β”œβ”€β”€ cortex/ ← One JSON per neuron (topic)
88
+ β”‚ β”œβ”€β”€ project_octochat.json
89
+ β”‚ └── tech_firebase.json
90
+ β”œβ”€β”€ synapses/ ← One JSON per connection
91
+ β”‚ └── syn_octochat__firebase.json
92
+ β”œβ”€β”€ hippocampus/ ← One JSON per session
93
+ β”‚ └── session_2026-05-06.json
94
+ β”œβ”€β”€ prefrontal/ ← Working memory
95
+ β”‚ β”œβ”€β”€ active_context.json
96
+ β”‚ β”œβ”€β”€ hot_topics.json
97
+ β”‚ └── global_map.json
98
+ β”œβ”€β”€ archives/ ← Cold neurons
99
+ └── .search/ ← Orama search index
100
+ └── orama.index.json
101
+ ```
102
+
103
+ ## Heat Score Algorithm
104
+
105
+ Each neuron has a heat score (0.0 - 1.0) calculated from:
106
+
107
+ - **Frequency (35%)** β€” How often the neuron is accessed
108
+ - **Recency (40%)** β€” When it was last accessed (today = 1.0, >3 months = 0.05)
109
+ - **Connectivity (25%)** β€” How many synapses connect to it
110
+
111
+ ## CLI Commands
112
+
113
+ ```bash
114
+ npx crbro-memory # Start MCP server
115
+ npx crbro-memory init # Initialize brain
116
+ npx crbro-memory status # Show brain status
117
+ npx crbro-memory --help # Help
118
+ ```
119
+
120
+ ## License
121
+
122
+ MIT β€” Part of [Synthetica Decks](https://synthetica-decks.web.app) by Octonove Agency.
package/bin/crbro.js ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ─── CRBRO CLI ───────────────────────────────────────────────────
4
+ // Command-line interface for CRBRO memory system
5
+
6
+ const args = process.argv.slice(2);
7
+ const command = args[0];
8
+
9
+ if (command === 'init') {
10
+ // Initialize brain
11
+ import('../dist/engine/brain.js').then(async ({ Brain }) => {
12
+ const brain = new Brain();
13
+ const manifest = await brain.initialize();
14
+ console.log('🧠 CRBRO brain initialized!');
15
+ console.log(` Path: ${manifest.brain_path}`);
16
+ console.log('');
17
+ console.log('Add CRBRO to your MCP config:');
18
+ console.log('');
19
+ console.log(JSON.stringify({
20
+ "mcpServers": {
21
+ "crbro": {
22
+ "command": "npx",
23
+ "args": ["-y", "crbro-memory"]
24
+ }
25
+ }
26
+ }, null, 2));
27
+ }).catch(console.error);
28
+
29
+ } else if (command === 'status') {
30
+ // Show brain status
31
+ import('../dist/engine/brain.js').then(async ({ Brain }) => {
32
+ const brain = new Brain();
33
+ try {
34
+ const manifest = await brain.getManifest();
35
+ console.log('🧠 CRBRO Brain Status');
36
+ console.log(` Version: ${manifest.version}`);
37
+ console.log(` Path: ${manifest.brain_path}`);
38
+ console.log(` Neurons: ${manifest.total_neurons}`);
39
+ console.log(` Synapses: ${manifest.total_synapses}`);
40
+ console.log(` Sessions: ${manifest.total_sessions}`);
41
+ console.log(` Last Boot: ${manifest.last_boot || 'never'}`);
42
+ } catch {
43
+ console.log('🧠 CRBRO brain not initialized. Run: npx crbro-memory init');
44
+ }
45
+ }).catch(console.error);
46
+
47
+ } else if (command === 'activate') {
48
+ // Activate license key
49
+ const key = args[1];
50
+ if (!key) {
51
+ console.log('❌ Usage: npx crbro-memory activate SYNTH-ZERO-XXXX-XXXX-XXXX');
52
+ console.log('');
53
+ console.log('Get your license key at https://synthetica-decks.web.app');
54
+ process.exit(1);
55
+ }
56
+
57
+ import('../dist/engine/brain.js').then(async ({ Brain }) => {
58
+ const brain = new Brain();
59
+ try {
60
+ await brain.getManifest(); // Ensure brain exists
61
+ } catch {
62
+ console.log('🧠 Brain not initialized. Initializing now...');
63
+ await brain.initialize();
64
+ }
65
+
66
+ // Validate key format
67
+ if (!key.startsWith('SYNTH-ZERO-') || key.length < 20) {
68
+ console.log('❌ Invalid license key format.');
69
+ console.log(' Keys start with SYNTH-ZERO- and are at least 20 characters.');
70
+ process.exit(1);
71
+ }
72
+
73
+ // Persist key in manifest
74
+ await brain.updateManifest({ license_key: key });
75
+ console.log('βœ… License key activated!');
76
+ console.log('');
77
+ console.log(' πŸ”“ Premium features unlocked:');
78
+ console.log(' β€’ crbro_global_map β€” Neural cluster visualization');
79
+ console.log(' β€’ crbro_maintenance β€” Automated brain optimization');
80
+ console.log('');
81
+ console.log(' Restart your IDE to apply changes.');
82
+ }).catch(console.error);
83
+
84
+ } else if (command === '--help' || command === '-h') {
85
+ console.log('🧠 CRBRO β€” Persistent Neural Memory for AI');
86
+ console.log('');
87
+ console.log('Usage:');
88
+ console.log(' npx crbro-memory Start MCP server (stdio)');
89
+ console.log(' npx crbro-memory init Initialize brain directory');
90
+ console.log(' npx crbro-memory status Show brain status');
91
+ console.log(' npx crbro-memory activate KEY Activate premium license');
92
+ console.log(' npx crbro-memory --help Show this help');
93
+ console.log('');
94
+ console.log('Part of Synthetica Decks β€” https://synthetica-decks.web.app');
95
+
96
+ } else {
97
+ // Default: start MCP server
98
+ import('../dist/index.js').catch(console.error);
99
+ }
@@ -0,0 +1,43 @@
1
+ import type { Manifest, BootResult } from '../types/index.js';
2
+ export declare class BrainPaths {
3
+ readonly root: string;
4
+ readonly cortex: string;
5
+ readonly synapses: string;
6
+ readonly hippocampus: string;
7
+ readonly prefrontal: string;
8
+ readonly archives: string;
9
+ readonly search: string;
10
+ constructor(rootDir?: string);
11
+ manifest(): string;
12
+ neuron(id: string): string;
13
+ synapse(id: string): string;
14
+ session(id: string): string;
15
+ activeContext(): string;
16
+ hotTopics(): string;
17
+ globalMap(): string;
18
+ searchIndex(): string;
19
+ }
20
+ export declare class Brain {
21
+ private manifest;
22
+ readonly paths: BrainPaths;
23
+ constructor(rootDir?: string);
24
+ /**
25
+ * Initialize the brain directory structure.
26
+ * Creates all directories and a fresh manifest.
27
+ */
28
+ initialize(): Promise<Manifest>;
29
+ /**
30
+ * Boot sequence β€” load manifest, verify integrity, return brain state.
31
+ * If brain doesn't exist, initialize it first.
32
+ */
33
+ boot(): Promise<BootResult>;
34
+ /**
35
+ * Get the current manifest.
36
+ */
37
+ getManifest(): Promise<Manifest>;
38
+ /**
39
+ * Update the manifest counters.
40
+ */
41
+ updateManif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AC,GAAG,OAAO,CAAC,IAAI,CAAC;CAMhE"}
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ // ─── CRBRO Brain Manager ─────────────────────────────────────────
3
+ // Core brain initialization, boot sequence, and path management
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Brain = exports.BrainPaths = void 0;
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const node_fs_1 = require("node:fs");
11
+ const fs_js_1 = require("../utils/fs.js");
12
+ const CRBRO_DIR = process.env['CRBRO_PATH'] || node_path_1.default.join(process.env['HOME'] || process.env['USERPROFILE'] || '.', '.crbro');
13
+ const MANIFEST_FILE = 'manifest.json';
14
+ const CRBRO_VERSION = '1.0.0';
15
+ // ─── Paths ───────────────────────────────────────────────────────
16
+ class BrainPaths {
17
+ root;
18
+ cortex;
19
+ synapses;
20
+ hippocampus;
21
+ prefrontal;
22
+ archives;
23
+ search;
24
+ constructor(rootDir) {
25
+ this.root = rootDir || CRBRO_DIR;
26
+ this.cortex = node_path_1.default.join(this.root, 'cortex');
27
+ this.synapses = node_path_1.default.join(this.root, 'synapses');
28
+ this.hippocampus = node_path_1.default.join(this.root, 'hippocampus');
29
+ this.prefrontal = node_path_1.default.join(this.root, 'prefrontal');
30
+ this.archives = node_path_1.default.join(this.root, 'archives');
31
+ this.search = node_path_1.default.join(this.root, '.search');
32
+ }
33
+ manifest() {
34
+ return node_path_1.default.join(this.root, MANIFEST_FILE);
35
+ }
36
+ neuron(id) {
37
+ return node_path_1.default.join(this.cortex, `${id}.json`);
38
+ }
39
+ synapse(id) {
40
+ return node_path_1.default.join(this.synapses, `${id}.json`);
41
+ }
42
+ session(id) {
43
+ return node_path_1.default.join(this.hippocampus, `${id}.json`);
44
+ }
45
+ activeContext() {
46
+ return node_path_1.default.join(this.prefrontal, 'active_context.json');
47
+ }
48
+ hotTopics() {
49
+ return node_path_1.default.join(this.prefrontal, 'hot_topics.json');
50
+ }
51
+ globalMap() {
52
+ return node_path_1.default.join(this.prefrontal, 'global_map.json');
53
+ }
54
+ searchIndex() {
55
+ return node_path_1.default.join(this.search, 'orama.index.json');
56
+ }
57
+ }
58
+ exports.BrainPaths = BrainPaths;
59
+ // ─── Brain Manager ───────────────────────────────────────────────
60
+ class Brain {
61
+ manifest = null;
62
+ paths;
63
+ constructor(rootDir) {
64
+ this.paths = new BrainPaths(rootDir);
65
+ }
66
+ /**
67
+ * Initialize the brain directory structure.
68
+ * Creates all directories and a fresh manifest.
69
+ */
70
+ async initialize() {
71
+ // Create directories
72
+ const dirs = [
73
+ this.paths.cortex,
74
+ this.paths.synapses,
75
+ this.paths.hippocampus,
76
+ this.paths.prefrontal,
77
+ this.paths.archives,
78
+ this.paths.search,
79
+ ];
80
+ for (const dir of dirs) {
81
+ await node_fs_1.promises.mkdir(dir, { recursive: true });
82
+ }
83
+ // Create manifest
84
+ const manifest = {
85
+ version: CRBRO_VERSION,
86
+ created: (0, fs_js_1.now)(),
87
+ owner: 'user',
88
+ brain_path: this.paths.root,
89
+ total_neurons: 0,
90
+ total_synapses: 0,
91
+ total_sessions: 0,
92
+ last_boot: null,
93
+ last_consolidation: null,
94
+ license_key: null,
95
+ };
96
+ await (0, fs_js_1.writeJSON)(this.paths.manifest(), manifest);
97
+ this.manifest = manifest;
98
+ // Create empty prefrontal files
99
+ const emptyContext = {
100
+ last_session: '',
101
+ active_topics: [],
102
+ pending_tasks: [],
103
+ last_updated: (0, fs_js_1.now)(),
104
+ };
105
+ await (0, fs_js_1.writeJSON)(this.paths.activeContext(), emptyContext);
106
+ const emptyHotTopics = {
107
+ topics: [],
108
+ last_recalculated: (0, fs_js_1.now)(),
109
+ };
110
+ await (0, fs_js_1.writeJSON)(this.paths.hotTopics(), emptyHotTopics);
111
+ return manifest;
112
+ }
113
+ /**
114
+ * Boot sequence β€” load manifest, verify integrity, return brain state.
115
+ * If brain doesn't exist, initialize it first.
116
+ */
117
+ async boot() {
118
+ const exists = await (0, fs_js_1.fileExists)(this.paths.manifest());
119
+ if (!exists) {
120
+ // First boot β€” initialize
121
+ const manifest = await this.initialize();
122
+ return {
123
+ status: 'initialized',
124
+ total_neurons: 0,
125
+ total_synapses: 0,
126
+ total_sessions: 0,
127
+ hot_topics: [],
128
+ last_session: null,
129
+ active_context: null,
130
+ message: `CRBRO brain initialized at ${this.paths.root}. Ready for first session.`,
131
+ };
132
+ }
133
+ // Load manifest
134
+ this.manifest = await (0, fs_js_1.readJSON)(this.paths.manifest());
135
+ if (!this.manifest) {
136
+ throw new Error('CRBRO: Manifest exists but could not be read.');
137
+ }
138
+ // Load hot topics
139
+ const hotTopics = await (0, fs_js_1.readJSON)(this.paths.hotTopics());
140
+ // Load active context
141
+ const activeContext = await (0, fs_js_1.readJSON)(this.paths.activeContext());
142
+ // Update boot timestamp
143
+ this.manifest.last_boot = (0, fs_js_1.now)();
144
+ await (0, fs_js_1.writeJSON)(this.paths.manifest(), this.manifest);
145
+ return {
146
+ status: 'ok',
147
+ total_neurons: this.manifest.total_neurons,
148
+ total_synapses: this.manifest.total_synapses,
149
+ total_sessions: this.manifest.total_sessions,
150
+ hot_topics: hotTopics?.topics || [],
151
+ last_session: activeContext?.last_session || null,
152
+ active_context: activeContext,
153
+ message: `CRBRO boot complete. ${this.manifest.total_neurons} neurons, ${this.manifest.total_synapses} synapses, ${this.manifest.total_sessions} sessions.`,
154
+ };
155
+ }
156
+ /**
157
+ * Get the current manifest.
158
+ */
159
+ async getManifest() {
160
+ if (!this.manifest) {
161
+ this.manifest = await (0, fs_js_1.readJSON)(this.paths.manifest());
162
+ if (!this.manifest) {
163
+ throw new Error('CRBRO: Brain not initialized. Call boot() first.');
164
+ }
165
+ }
166
+ return this.manifest;
167
+ }
168
+ /**
169
+ * Update the manifest counters.
170
+ */
171
+ async updateManifest(updates) {
172
+ const manifest = await this.getManifest();
173
+ Object.assign(manifest, updates);
174
+ await (0, fs_js_1.writeJSON)(this.paths.manifest(), manifest);
175
+ this.manifest = manifest;
176
+ }
177
+ }
178
+ exports.Brain = Brain;
179
+ //# sourceMappingURL=brain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brain.js","sourceRoot":"","sources":["../../src/engine/brain.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,gEAAgE;;;;;;AAEhE,0DAA6B;AAC7B,qCAAyC;AACzC,0CAAsE;AAGtE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC7H,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,oEAAoE;AAEpE,MAAa,UAAU;IACZ,IAAI,CAAS;IACb,MAAM,CAAS;IACf,QAAQ,CAAS;IACjB,WAAW,CAAS;IACpB,UAAU,CAAS;IACnB,QAAQ,CAAS;IACjB,MAAM,CAAS;IAExB,YAAY,OAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,OAAO,IAAI,SAAS,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,IAA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,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAtID,sBAsIC"}
@@ -0,0 +1,70 @@
1
+ import type { Brain } from './brain.js';
2
+ import type { Neuron, NeuronType } from '../types/index.js';
3
+ export declare class Cortex {
4
+ private brain;
5
+ constructor(brain: Brain);
6
+ /**
7
+ * Get a neuron by ID.
8
+ */
9
+ get(id: string): Promise<Neuron | null>;
10
+ /**
11
+ * Get a neuron by ID without updating access stats.
12
+ */
13
+ peek(id: string): Promise<Neuron | null>;
14
+ /**
15
+ * Find a neuron by name (fuzzy match against existing neurons).
16
+ * Returns the best match or null.
17
+ */
18
+ findByName(name: string): Promise<Neuron | null>;
19
+ /**
20
+ * Create a new neuron.
21
+ */
22
+ create(name: string, type: NeuronType, domain: string, summary?: string): Promise<Neuron>;
23
+ /**
24
+ * Learn β€” add a fact, decision, or pattern to a neuron.
25
+ * If the neuron doesn't exist, creates it first.
26
+ */
27
+ learn(topic: string, type: 'fact' | 'decision' | 'pattern' | 'preference', content: string, options?: {
28
+ confidence?: number;
29
+ domain?: string;
30
+ rationale?: string;
31
+ neuronType?: NeuronType;
32
+ }): Promise<{
33
+ neuron: Neuron;
34
+ action: 'created' | 'updated';
35
+ }>;
36
+ /**
37
+ * List all neurons with optional filters.
38
+ */
39
+ list(options?: {
40
+ domain?: string;
41
+ type?: NeuronType;
42
+ min_heat?: number;
43
+ limit?: number;
44
+ }): Promise<Array<{
45
+ id: string;
46
+ name: string;
47
+ domain: string;
48
+ type: NeuronType;
49
+ heat: number;
50
+ last_accessed: string;
51
+ facts_count: number;
52
+ }>>;
53
+ /**
54
+ * Update a neuron's summary.
55
+ */
56
+ updateSummary(id: string, summary: string): Promise<Neuron | null>;
57
+ /**
58
+ * Add tags to a neuron.
59
+ */
60
+ addTags(id: string, tags: string[]): Promise<Neuron | null>;
61
+ /**
62
+ * Get all neuron IDs.
63
+ */
64
+ allIds(): Promise<string[]>;
65
+ /**
66
+ * Count total neurons.
67
+ */
68
+ count(): Promise<number>;
69
+ }
70
+ //# sourceMappingURL=cortex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cortex.d.ts","sourceRoot":"","sources":["../../src/engine/cortex.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAkB,MAAM,mBAAmB,CAAC;AAE5E,qBAAa,MAAM;IACL,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK;IAEhC;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAW7C;;OAEG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI9C;;;OAGG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAqBtD;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA8B/F;;;OAGG;IACG,KAAK,CACT,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,EACpD,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB,GACA,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;KAAE,CAAC;IAmE7D;;OAEG;IACG,IAAI,CAAC,OAAO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