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.
- package/README.md +122 -0
- package/bin/crbro.js +99 -0
- package/dist/engine/brain.d.ts +43 -0
- package/dist/engine/brain.d.ts.map +1 -0
- package/dist/engine/brain.js +179 -0
- package/dist/engine/brain.js.map +1 -0
- package/dist/engine/cortex.d.ts +70 -0
- package/dist/engine/cortex.d.ts.map +1 -0
- package/dist/engine/cortex.js +219 -0
- package/dist/engine/cortex.js.map +1 -0
- package/dist/engine/heat.d.ts +28 -0
- package/dist/engine/heat.d.ts.map +1 -0
- package/dist/engine/heat.js +112 -0
- package/dist/engine/heat.js.map +1 -0
- package/dist/engine/hippocampus.d.ts +26 -0
- package/dist/engine/hippocampus.d.ts.map +1 -0
- package/dist/engine/hippocampus.js +73 -0
- package/dist/engine/hippocampus.js.map +1 -0
- package/dist/engine/license.d.ts +29 -0
- package/dist/engine/license.d.ts.map +1 -0
- package/dist/engine/license.js +109 -0
- package/dist/engine/license.js.map +1 -0
- package/dist/engine/maintenance.d.ts +41 -0
- package/dist/engine/maintenance.d.ts.map +1 -0
- package/dist/engine/maintenance.js +156 -0
- package/dist/engine/maintenance.js.map +1 -0
- package/dist/engine/prefrontal.d.ts +31 -0
- package/dist/engine/prefrontal.d.ts.map +1 -0
- package/dist/engine/prefrontal.js +149 -0
- package/dist/engine/prefrontal.js.map +1 -0
- package/dist/engine/synapses.d.ts +39 -0
- package/dist/engine/synapses.d.ts.map +1 -0
- package/dist/engine/synapses.js +154 -0
- package/dist/engine/synapses.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/search/index.d.ts +31 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +139 -0
- package/dist/search/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +543 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.d.ts +121 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/fs.d.ts +35 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +110 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/ids.d.ts +32 -0
- package/dist/utils/ids.d.ts.map +1 -0
- package/dist/utils/ids.js +92 -0
- package/dist/utils/ids.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Brain } from './brain.js';
|
|
2
|
+
import type { Cortex } from './cortex.js';
|
|
3
|
+
import type { Synapses } from './synapses.js';
|
|
4
|
+
import type { HeatEngine } from './heat.js';
|
|
5
|
+
import type { Hippocampus } from './hippocampus.js';
|
|
6
|
+
import type { Prefrontal } from './prefrontal.js';
|
|
7
|
+
import type { SearchEngine } from '../search/index.js';
|
|
8
|
+
export interface MaintenanceReport {
|
|
9
|
+
archived_neurons: number;
|
|
10
|
+
pruned_synapses: number;
|
|
11
|
+
integrity_issues: string[];
|
|
12
|
+
clusters_detected: number;
|
|
13
|
+
index_rebuilt: boolean;
|
|
14
|
+
heat_recalculated: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class Maintenance {
|
|
17
|
+
private brain;
|
|
18
|
+
private cortex;
|
|
19
|
+
private synapses;
|
|
20
|
+
private heatEngine;
|
|
21
|
+
private hippocampus;
|
|
22
|
+
private prefrontal;
|
|
23
|
+
private searchEngine;
|
|
24
|
+
constructor(brain: Brain, cortex: Cortex, synapses: Synapses, heatEngine: HeatEngine, hippocampus: Hippocampus, prefrontal: Prefrontal, searchEngine: SearchEngine);
|
|
25
|
+
/**
|
|
26
|
+
* Run full maintenance cycle.
|
|
27
|
+
*/
|
|
28
|
+
run(dryRun?: boolean): Promise<MaintenanceReport>;
|
|
29
|
+
/**
|
|
30
|
+
* Consolidate session — called at end of session.
|
|
31
|
+
*/
|
|
32
|
+
consolidate(summary: string): Promise<{
|
|
33
|
+
facts_saved: number;
|
|
34
|
+
synapses_updated: number;
|
|
35
|
+
session_logged: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
private archiveColdNeurons;
|
|
38
|
+
private countColdNeurons;
|
|
39
|
+
private checkIntegrity;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=maintenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../src/engine/maintenance.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,qBAAa,WAAW;IAEpB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;gBANZ,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY;IAGpC;;OAEG;IACG,GAAG,CAAC,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqD9D;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAC1C,WAAW,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE,MAAM,CAAC;QACzB,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;YAqCY,kBAAkB;YAwBlB,gBAAgB;YAiBhB,cAAc;CAsB7B"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─── CRBRO Maintenance Engine ────────────────────────────────────
|
|
3
|
+
// Pruning, archiving, integrity checks, and consolidation
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Maintenance = void 0;
|
|
6
|
+
const fs_js_1 = require("../utils/fs.js");
|
|
7
|
+
class Maintenance {
|
|
8
|
+
brain;
|
|
9
|
+
cortex;
|
|
10
|
+
synapses;
|
|
11
|
+
heatEngine;
|
|
12
|
+
hippocampus;
|
|
13
|
+
prefrontal;
|
|
14
|
+
searchEngine;
|
|
15
|
+
constructor(brain, cortex, synapses, heatEngine, hippocampus, prefrontal, searchEngine) {
|
|
16
|
+
this.brain = brain;
|
|
17
|
+
this.cortex = cortex;
|
|
18
|
+
this.synapses = synapses;
|
|
19
|
+
this.heatEngine = heatEngine;
|
|
20
|
+
this.hippocampus = hippocampus;
|
|
21
|
+
this.prefrontal = prefrontal;
|
|
22
|
+
this.searchEngine = searchEngine;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run full maintenance cycle.
|
|
26
|
+
*/
|
|
27
|
+
async run(dryRun = false) {
|
|
28
|
+
const report = {
|
|
29
|
+
archived_neurons: 0,
|
|
30
|
+
pruned_synapses: 0,
|
|
31
|
+
integrity_issues: [],
|
|
32
|
+
clusters_detected: 0,
|
|
33
|
+
index_rebuilt: false,
|
|
34
|
+
heat_recalculated: false,
|
|
35
|
+
};
|
|
36
|
+
// 1. Recalculate heat scores
|
|
37
|
+
await this.heatEngine.recalculate();
|
|
38
|
+
report.heat_recalculated = true;
|
|
39
|
+
// 2. Archive cold neurons (heat < 0.05, not accessed in 90+ days)
|
|
40
|
+
if (!dryRun) {
|
|
41
|
+
report.archived_neurons = await this.archiveColdNeurons();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
report.archived_neurons = await this.countColdNeurons();
|
|
45
|
+
}
|
|
46
|
+
// 3. Decay and prune weak synapses
|
|
47
|
+
if (!dryRun) {
|
|
48
|
+
report.pruned_synapses = await this.synapses.decay(0.05);
|
|
49
|
+
}
|
|
50
|
+
// 4. Integrity check
|
|
51
|
+
report.integrity_issues = await this.checkIntegrity();
|
|
52
|
+
// 5. Rebuild global map
|
|
53
|
+
const globalMap = await this.prefrontal.buildGlobalMap();
|
|
54
|
+
report.clusters_detected = globalMap.clusters.length;
|
|
55
|
+
// 6. Rebuild search index
|
|
56
|
+
if (!dryRun) {
|
|
57
|
+
await this.searchEngine.rebuild();
|
|
58
|
+
report.index_rebuilt = true;
|
|
59
|
+
}
|
|
60
|
+
// 7. Update manifest
|
|
61
|
+
if (!dryRun) {
|
|
62
|
+
const neuronCount = await this.cortex.count();
|
|
63
|
+
const synapseCount = await this.synapses.count();
|
|
64
|
+
await this.brain.updateManifest({
|
|
65
|
+
total_neurons: neuronCount,
|
|
66
|
+
total_synapses: synapseCount,
|
|
67
|
+
last_consolidation: (0, fs_js_1.now)(),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return report;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Consolidate session — called at end of session.
|
|
74
|
+
*/
|
|
75
|
+
async consolidate(summary) {
|
|
76
|
+
// Persist search index
|
|
77
|
+
await this.searchEngine.persist();
|
|
78
|
+
// Log session
|
|
79
|
+
const neuronCount = await this.cortex.count();
|
|
80
|
+
const synapseCount = await this.synapses.count();
|
|
81
|
+
await this.hippocampus.logSession({
|
|
82
|
+
summary,
|
|
83
|
+
topics_touched: [],
|
|
84
|
+
key_facts_added: 0,
|
|
85
|
+
decisions_made: 0,
|
|
86
|
+
});
|
|
87
|
+
// Update active context
|
|
88
|
+
await this.prefrontal.updateContext({});
|
|
89
|
+
// Recalculate heat
|
|
90
|
+
await this.heatEngine.recalculate();
|
|
91
|
+
// Update manifest
|
|
92
|
+
await this.brain.updateManifest({
|
|
93
|
+
total_neurons: neuronCount,
|
|
94
|
+
total_synapses: synapseCount,
|
|
95
|
+
last_consolidation: (0, fs_js_1.now)(),
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
facts_saved: neuronCount,
|
|
99
|
+
synapses_updated: synapseCount,
|
|
100
|
+
session_logged: true,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// ─── Private Helpers ──────────────────────────────────────────
|
|
104
|
+
async archiveColdNeurons() {
|
|
105
|
+
const ids = await this.cortex.allIds();
|
|
106
|
+
let archived = 0;
|
|
107
|
+
for (const id of ids) {
|
|
108
|
+
const neuron = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(id));
|
|
109
|
+
if (!neuron)
|
|
110
|
+
continue;
|
|
111
|
+
// Archive if heat < 0.05 and not accessed in 90+ days
|
|
112
|
+
const lastAccess = new Date(neuron.last_accessed).getTime();
|
|
113
|
+
const diffDays = (Date.now() - lastAccess) / (1000 * 60 * 60 * 24);
|
|
114
|
+
if (neuron.heat < 0.05 && diffDays > 90) {
|
|
115
|
+
await (0, fs_js_1.moveFile)(this.brain.paths.neuron(id), `${this.brain.paths.archives}/${id}.json`);
|
|
116
|
+
archived++;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return archived;
|
|
120
|
+
}
|
|
121
|
+
async countColdNeurons() {
|
|
122
|
+
const ids = await this.cortex.allIds();
|
|
123
|
+
let count = 0;
|
|
124
|
+
for (const id of ids) {
|
|
125
|
+
const neuron = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(id));
|
|
126
|
+
if (!neuron)
|
|
127
|
+
continue;
|
|
128
|
+
const lastAccess = new Date(neuron.last_accessed).getTime();
|
|
129
|
+
const diffDays = (Date.now() - lastAccess) / (1000 * 60 * 60 * 24);
|
|
130
|
+
if (neuron.heat < 0.05 && diffDays > 90)
|
|
131
|
+
count++;
|
|
132
|
+
}
|
|
133
|
+
return count;
|
|
134
|
+
}
|
|
135
|
+
async checkIntegrity() {
|
|
136
|
+
const issues = [];
|
|
137
|
+
const ids = await this.cortex.allIds();
|
|
138
|
+
for (const id of ids) {
|
|
139
|
+
const neuron = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(id));
|
|
140
|
+
if (!neuron) {
|
|
141
|
+
issues.push(`Corrupted neuron file: ${id}`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
// Check for broken connections
|
|
145
|
+
for (const connId of neuron.connections) {
|
|
146
|
+
const connected = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(connId));
|
|
147
|
+
if (!connected) {
|
|
148
|
+
issues.push(`Broken connection: ${id} → ${connId} (target missing)`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return issues;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.Maintenance = Maintenance;
|
|
156
|
+
//# sourceMappingURL=maintenance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maintenance.js","sourceRoot":"","sources":["../../src/engine/maintenance.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,0DAA0D;;;AAE1D,0CAA0F;AAmB1F,MAAa,WAAW;IAEZ;IACA;IACA;IACA;IACA;IACA;IACA;IAPV,YACU,KAAY,EACZ,MAAc,EACd,QAAkB,EAClB,UAAsB,EACtB,WAAwB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C,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC1E,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,MAAM,MAAM,mBAAmB,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA9KD,kCA8KC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Brain } from './brain.js';
|
|
2
|
+
import type { ActiveContext, HotTopics, GlobalMap } from '../types/index.js';
|
|
3
|
+
export declare class Prefrontal {
|
|
4
|
+
private brain;
|
|
5
|
+
constructor(brain: Brain);
|
|
6
|
+
/**
|
|
7
|
+
* Get the current active context.
|
|
8
|
+
*/
|
|
9
|
+
getContext(): Promise<ActiveContext>;
|
|
10
|
+
/**
|
|
11
|
+
* Update the active context.
|
|
12
|
+
*/
|
|
13
|
+
updateContext(updates: {
|
|
14
|
+
set_topics?: string[];
|
|
15
|
+
add_pending?: string;
|
|
16
|
+
resolve_pending?: string;
|
|
17
|
+
}): Promise<ActiveContext>;
|
|
18
|
+
/**
|
|
19
|
+
* Get current hot topics.
|
|
20
|
+
*/
|
|
21
|
+
getHotTopics(limit?: number): Promise<HotTopics>;
|
|
22
|
+
/**
|
|
23
|
+
* Build the global map — clusters of related neurons and bridges between domains.
|
|
24
|
+
*/
|
|
25
|
+
buildGlobalMap(): Promise<GlobalMap>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the current global map (read from cache, or build if missing).
|
|
28
|
+
*/
|
|
29
|
+
getGlobalMap(rebuild?: boolean): Promise<GlobalMap>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=prefrontal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefrontal.d.ts","sourceRoot":"","sources":["../../src/engine/prefrontal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAA2B,MAAM,mBAAmB,CAAC;AAEtG,qBAAa,UAAU;IACT,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK;IAIhC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC;IAU1C;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE;QAC3B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,GAAG,OAAO,CAAC,aAAa,CAAC;IAwB1B;;OAEG;IACG,YAAY,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAa1D;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,SAAS,CAAC;IAkF1C;;OAEG;IACG,YAAY,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,SAAS,CAAC;CAUjE"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─── CRBRO Prefrontal Engine ─────────────────────────────────────
|
|
3
|
+
// Active context, hot topics, and global map (clustering + bridges)
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Prefrontal = void 0;
|
|
6
|
+
const fs_js_1 = require("../utils/fs.js");
|
|
7
|
+
class Prefrontal {
|
|
8
|
+
brain;
|
|
9
|
+
constructor(brain) {
|
|
10
|
+
this.brain = brain;
|
|
11
|
+
}
|
|
12
|
+
// ─── Active Context ────────────────────────────────────────────
|
|
13
|
+
/**
|
|
14
|
+
* Get the current active context.
|
|
15
|
+
*/
|
|
16
|
+
async getContext() {
|
|
17
|
+
const ctx = await (0, fs_js_1.readJSON)(this.brain.paths.activeContext());
|
|
18
|
+
return ctx || {
|
|
19
|
+
last_session: '',
|
|
20
|
+
active_topics: [],
|
|
21
|
+
pending_tasks: [],
|
|
22
|
+
last_updated: (0, fs_js_1.now)(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Update the active context.
|
|
27
|
+
*/
|
|
28
|
+
async updateContext(updates) {
|
|
29
|
+
const ctx = await this.getContext();
|
|
30
|
+
if (updates.set_topics) {
|
|
31
|
+
ctx.active_topics = updates.set_topics;
|
|
32
|
+
}
|
|
33
|
+
if (updates.add_pending) {
|
|
34
|
+
if (!ctx.pending_tasks.includes(updates.add_pending)) {
|
|
35
|
+
ctx.pending_tasks.push(updates.add_pending);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (updates.resolve_pending) {
|
|
39
|
+
ctx.pending_tasks = ctx.pending_tasks.filter(t => t !== updates.resolve_pending);
|
|
40
|
+
}
|
|
41
|
+
ctx.last_updated = (0, fs_js_1.now)();
|
|
42
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.activeContext(), ctx);
|
|
43
|
+
return ctx;
|
|
44
|
+
}
|
|
45
|
+
// ─── Hot Topics ─────────────────────────────────────────────────
|
|
46
|
+
/**
|
|
47
|
+
* Get current hot topics.
|
|
48
|
+
*/
|
|
49
|
+
async getHotTopics(limit = 15) {
|
|
50
|
+
const ht = await (0, fs_js_1.readJSON)(this.brain.paths.hotTopics());
|
|
51
|
+
if (!ht) {
|
|
52
|
+
return { topics: [], last_recalculated: (0, fs_js_1.now)() };
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...ht,
|
|
56
|
+
topics: ht.topics.slice(0, limit),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// ─── Global Map (Premium Feature) ──────────────────────────────
|
|
60
|
+
/**
|
|
61
|
+
* Build the global map — clusters of related neurons and bridges between domains.
|
|
62
|
+
*/
|
|
63
|
+
async buildGlobalMap() {
|
|
64
|
+
const ids = await (0, fs_js_1.listJSONFiles)(this.brain.paths.cortex);
|
|
65
|
+
const neurons = [];
|
|
66
|
+
for (const id of ids) {
|
|
67
|
+
const neuron = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(id));
|
|
68
|
+
if (neuron)
|
|
69
|
+
neurons.push(neuron);
|
|
70
|
+
}
|
|
71
|
+
// Build clusters by domain
|
|
72
|
+
const domainGroups = {};
|
|
73
|
+
for (const neuron of neurons) {
|
|
74
|
+
const domain = neuron.domain || 'uncategorized';
|
|
75
|
+
if (!domainGroups[domain])
|
|
76
|
+
domainGroups[domain] = [];
|
|
77
|
+
domainGroups[domain].push(neuron);
|
|
78
|
+
}
|
|
79
|
+
const clusters = [];
|
|
80
|
+
for (const [domain, domainNeurons] of Object.entries(domainGroups)) {
|
|
81
|
+
const avgHeat = domainNeurons.reduce((sum, n) => sum + n.heat, 0) / domainNeurons.length;
|
|
82
|
+
clusters.push({
|
|
83
|
+
name: domain,
|
|
84
|
+
nodes: domainNeurons.map(n => n.id),
|
|
85
|
+
summary: `${domainNeurons.length} neurons — top: ${domainNeurons
|
|
86
|
+
.sort((a, b) => b.heat - a.heat)
|
|
87
|
+
.slice(0, 3)
|
|
88
|
+
.map(n => n.name)
|
|
89
|
+
.join(', ')}`,
|
|
90
|
+
heat: Math.round(avgHeat * 1000) / 1000,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// Find bridges — neurons that connect different domains
|
|
94
|
+
const bridges = [];
|
|
95
|
+
for (const neuron of neurons) {
|
|
96
|
+
if (neuron.connections.length === 0)
|
|
97
|
+
continue;
|
|
98
|
+
// Get connected neurons' domains
|
|
99
|
+
const connectedDomains = new Set();
|
|
100
|
+
const viaNodes = [];
|
|
101
|
+
for (const connId of neuron.connections) {
|
|
102
|
+
const connNeuron = neurons.find(n => n.id === connId);
|
|
103
|
+
if (connNeuron && connNeuron.domain !== neuron.domain) {
|
|
104
|
+
connectedDomains.add(connNeuron.domain);
|
|
105
|
+
viaNodes.push(connId);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (connectedDomains.size > 0) {
|
|
109
|
+
for (const targetDomain of connectedDomains) {
|
|
110
|
+
// Avoid duplicate bridges
|
|
111
|
+
const existingBridge = bridges.find(b => (b.from === neuron.domain && b.to === targetDomain) ||
|
|
112
|
+
(b.from === targetDomain && b.to === neuron.domain));
|
|
113
|
+
if (!existingBridge) {
|
|
114
|
+
bridges.push({
|
|
115
|
+
from: neuron.domain,
|
|
116
|
+
to: targetDomain,
|
|
117
|
+
via: viaNodes.filter(v => {
|
|
118
|
+
const n = neurons.find(nn => nn.id === v);
|
|
119
|
+
return n && n.domain === targetDomain;
|
|
120
|
+
}),
|
|
121
|
+
context: `Connected through ${neuron.name}`,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const globalMap = {
|
|
128
|
+
last_rebuilt: (0, fs_js_1.now)(),
|
|
129
|
+
clusters: clusters.sort((a, b) => b.heat - a.heat),
|
|
130
|
+
bridges,
|
|
131
|
+
};
|
|
132
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.globalMap(), globalMap);
|
|
133
|
+
return globalMap;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get the current global map (read from cache, or build if missing).
|
|
137
|
+
*/
|
|
138
|
+
async getGlobalMap(rebuild = false) {
|
|
139
|
+
if (rebuild) {
|
|
140
|
+
return this.buildGlobalMap();
|
|
141
|
+
}
|
|
142
|
+
const existing = await (0, fs_js_1.readJSON)(this.brain.paths.globalMap());
|
|
143
|
+
if (existing)
|
|
144
|
+
return existing;
|
|
145
|
+
return this.buildGlobalMap();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.Prefrontal = Prefrontal;
|
|
149
|
+
//# sourceMappingURL=prefrontal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefrontal.js","sourceRoot":"","sources":["../../src/engine/prefrontal.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,oEAAoE;;;AAEpE,0CAAyE;AAIzE,MAAa,UAAU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AG,GAAE;YACnB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;YAClD,OAAO;SACR,CAAC;QAEF,MAAM,IAAA,iBAAS,EAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC;QACzD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,UAAmB,KAAK;QACzC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAA,gBAAQ,EAAY,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACzE,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAE9B,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;IAC/B,CAAC;CACF;AAnKD,gCAmKC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Brain } from './brain.js';
|
|
2
|
+
import type { Synapse, SynapseType } from '../types/index.js';
|
|
3
|
+
export declare class Synapses {
|
|
4
|
+
private brain;
|
|
5
|
+
constructor(brain: Brain);
|
|
6
|
+
/**
|
|
7
|
+
* Create or strengthen a synapse between two neurons.
|
|
8
|
+
*/
|
|
9
|
+
connect(fromId: string, toId: string, type: SynapseType, context?: string): Promise<{
|
|
10
|
+
synapse: Synapse;
|
|
11
|
+
action: 'created' | 'strengthened';
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Get all connections for a neuron.
|
|
15
|
+
*/
|
|
16
|
+
getConnections(neuronId: string, minStrength?: number): Promise<Array<{
|
|
17
|
+
target_id: string;
|
|
18
|
+
target_name: string;
|
|
19
|
+
type: SynapseType;
|
|
20
|
+
strength: number;
|
|
21
|
+
context: string;
|
|
22
|
+
}>>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a specific synapse.
|
|
25
|
+
*/
|
|
26
|
+
get(nodeA: string, nodeB: string): Promise<Synapse | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Decay all synapses based on time since last co-access.
|
|
29
|
+
* Returns number of pruned synapses (strength fell below threshold).
|
|
30
|
+
*/
|
|
31
|
+
decay(pruneThreshold?: number): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Count total synapses.
|
|
34
|
+
*/
|
|
35
|
+
count(): Promise<number>;
|
|
36
|
+
private addConnectionToNeuron;
|
|
37
|
+
private removeConnectionFromNeuron;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=synapses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synapses.d.ts","sourceRoot":"","sources":["../../src/engine/synapses.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAEtE,qBAAa,QAAQ;IACP,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK;IAEhC;;OAEG;IACG,OAAO,CACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,SAAS,GAAG,cAAc,CAAA;KAAE,CAAC;IAyCpE;;OAEG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,KAAK,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,WAAW,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IAoCH;;OAEG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAKhE;;;OAGG;IACG,KAAK,CAAC,cAAc,GAAE,MAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAwC3D;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;YAOhB,qBAAqB;YAUrB,0BAA0B;CAOzC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─── CRBRO Synapses Engine ───────────────────────────────────────
|
|
3
|
+
// Connection management between neurons with strength decay
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Synapses = void 0;
|
|
6
|
+
const fs_js_1 = require("../utils/fs.js");
|
|
7
|
+
const ids_js_1 = require("../utils/ids.js");
|
|
8
|
+
class Synapses {
|
|
9
|
+
brain;
|
|
10
|
+
constructor(brain) {
|
|
11
|
+
this.brain = brain;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create or strengthen a synapse between two neurons.
|
|
15
|
+
*/
|
|
16
|
+
async connect(fromId, toId, type, context) {
|
|
17
|
+
const id = (0, ids_js_1.synapseId)(fromId, toId);
|
|
18
|
+
let synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
19
|
+
let action;
|
|
20
|
+
if (synapse) {
|
|
21
|
+
// Strengthen existing synapse
|
|
22
|
+
synapse.strength = Math.min(1.0, synapse.strength + 0.1);
|
|
23
|
+
synapse.co_access_count += 1;
|
|
24
|
+
synapse.last_co_access = (0, fs_js_1.now)();
|
|
25
|
+
if (context) {
|
|
26
|
+
synapse.context = context;
|
|
27
|
+
}
|
|
28
|
+
action = 'strengthened';
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Create new synapse
|
|
32
|
+
synapse = {
|
|
33
|
+
id,
|
|
34
|
+
nodes: [fromId, toId],
|
|
35
|
+
strength: 0.5,
|
|
36
|
+
type,
|
|
37
|
+
context: context || '',
|
|
38
|
+
co_access_count: 1,
|
|
39
|
+
last_co_access: (0, fs_js_1.now)(),
|
|
40
|
+
};
|
|
41
|
+
action = 'created';
|
|
42
|
+
// Update manifest
|
|
43
|
+
const manifest = await this.brain.getManifest();
|
|
44
|
+
await this.brain.updateManifest({ total_synapses: manifest.total_synapses + 1 });
|
|
45
|
+
}
|
|
46
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.synapse(id), synapse);
|
|
47
|
+
// Update neuron connection lists
|
|
48
|
+
await this.addConnectionToNeuron(fromId, toId);
|
|
49
|
+
await this.addConnectionToNeuron(toId, fromId);
|
|
50
|
+
return { synapse, action };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get all connections for a neuron.
|
|
54
|
+
*/
|
|
55
|
+
async getConnections(neuronId, minStrength) {
|
|
56
|
+
const ids = await (0, fs_js_1.listJSONFiles)(this.brain.paths.synapses);
|
|
57
|
+
const connections = [];
|
|
58
|
+
for (const id of ids) {
|
|
59
|
+
const synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
60
|
+
if (!synapse)
|
|
61
|
+
continue;
|
|
62
|
+
if (!synapse.nodes.includes(neuronId))
|
|
63
|
+
continue;
|
|
64
|
+
if (minStrength && synapse.strength < minStrength)
|
|
65
|
+
continue;
|
|
66
|
+
const targetId = synapse.nodes[0] === neuronId ? synapse.nodes[1] : synapse.nodes[0];
|
|
67
|
+
// Get target neuron name
|
|
68
|
+
const targetNeuron = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(targetId));
|
|
69
|
+
const targetName = targetNeuron?.name || targetId;
|
|
70
|
+
connections.push({
|
|
71
|
+
target_id: targetId,
|
|
72
|
+
target_name: targetName,
|
|
73
|
+
type: synapse.type,
|
|
74
|
+
strength: synapse.strength,
|
|
75
|
+
context: synapse.context,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// Sort by strength descending
|
|
79
|
+
connections.sort((a, b) => b.strength - a.strength);
|
|
80
|
+
return connections;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get a specific synapse.
|
|
84
|
+
*/
|
|
85
|
+
async get(nodeA, nodeB) {
|
|
86
|
+
const id = (0, ids_js_1.synapseId)(nodeA, nodeB);
|
|
87
|
+
return (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Decay all synapses based on time since last co-access.
|
|
91
|
+
* Returns number of pruned synapses (strength fell below threshold).
|
|
92
|
+
*/
|
|
93
|
+
async decay(pruneThreshold = 0.05) {
|
|
94
|
+
const ids = await (0, fs_js_1.listJSONFiles)(this.brain.paths.synapses);
|
|
95
|
+
let pruned = 0;
|
|
96
|
+
for (const id of ids) {
|
|
97
|
+
const synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
98
|
+
if (!synapse)
|
|
99
|
+
continue;
|
|
100
|
+
// Calculate decay
|
|
101
|
+
const lastAccess = new Date(synapse.last_co_access).getTime();
|
|
102
|
+
const diffDays = (Date.now() - lastAccess) / (1000 * 60 * 60 * 24);
|
|
103
|
+
let decayFactor = 1.0;
|
|
104
|
+
if (diffDays > 90)
|
|
105
|
+
decayFactor = 0.8;
|
|
106
|
+
else if (diffDays > 30)
|
|
107
|
+
decayFactor = 0.9;
|
|
108
|
+
else if (diffDays > 7)
|
|
109
|
+
decayFactor = 0.95;
|
|
110
|
+
synapse.strength = Math.round(synapse.strength * decayFactor * 1000) / 1000;
|
|
111
|
+
if (synapse.strength < pruneThreshold) {
|
|
112
|
+
// Prune weak synapse
|
|
113
|
+
const { deleteJSON } = await import('../utils/fs.js');
|
|
114
|
+
await deleteJSON(this.brain.paths.synapse(id));
|
|
115
|
+
// Remove from neuron connection lists
|
|
116
|
+
await this.removeConnectionFromNeuron(synapse.nodes[0], synapse.nodes[1]);
|
|
117
|
+
await this.removeConnectionFromNeuron(synapse.nodes[1], synapse.nodes[0]);
|
|
118
|
+
const manifest = await this.brain.getManifest();
|
|
119
|
+
await this.brain.updateManifest({ total_synapses: Math.max(0, manifest.total_synapses - 1) });
|
|
120
|
+
pruned++;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.synapse(id), synapse);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return pruned;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Count total synapses.
|
|
130
|
+
*/
|
|
131
|
+
async count() {
|
|
132
|
+
const ids = await (0, fs_js_1.listJSONFiles)(this.brain.paths.synapses);
|
|
133
|
+
return ids.length;
|
|
134
|
+
}
|
|
135
|
+
// ─── Private helpers ────────────────────────────────────────────
|
|
136
|
+
async addConnectionToNeuron(neuronId, connectedId) {
|
|
137
|
+
const neuron = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(neuronId));
|
|
138
|
+
if (!neuron)
|
|
139
|
+
return;
|
|
140
|
+
if (!neuron.connections.includes(connectedId)) {
|
|
141
|
+
neuron.connections.push(connectedId);
|
|
142
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.neuron(neuronId), neuron);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async removeConnectionFromNeuron(neuronId, connectedId) {
|
|
146
|
+
const neuron = await (0, fs_js_1.readJSON)(this.brain.paths.neuron(neuronId));
|
|
147
|
+
if (!neuron)
|
|
148
|
+
return;
|
|
149
|
+
neuron.connections = neuron.connections.filter(c => c !== connectedId);
|
|
150
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.neuron(neuronId), neuron);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.Synapses = Synapses;
|
|
154
|
+
//# sourceMappingURL=synapses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synapses.js","sourceRoot":"","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CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC;QACvE,MAAM,IAAA,iBAAS,EAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC;CACF;AAnLD,4BAmLC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─── CRBRO Entry Point ───────────────────────────────────────────
|
|
3
|
+
// MCP server via stdio transport
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const server_js_1 = require("./server.js");
|
|
7
|
+
async function main() {
|
|
8
|
+
const server = (0, server_js_1.createServer)();
|
|
9
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
10
|
+
await server.connect(transport);
|
|
11
|
+
}
|
|
12
|
+
main().catch((err) => {
|
|
13
|
+
console.error('CRBRO Fatal Error:', err);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,iCAAiC;;AAEjC,wEAAiF;AACjF,2CAA2C;AAE3C,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAA,wBAAY,GAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|