@timmeck/brain-core 1.5.1 → 1.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/README.md +23 -9
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/base-memory-engine.d.ts +19 -0
- package/dist/memory/base-memory-engine.js +35 -0
- package/dist/memory/base-memory-engine.js.map +1 -0
- package/dist/memory/types.d.ts +88 -0
- package/dist/memory/types.js +2 -0
- package/dist/memory/types.js.map +1 -0
- package/package.json +7 -4
- package/brain.log +0 -6
package/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@timmeck/brain-core)
|
|
4
4
|
[](https://www.npmjs.com/package/@timmeck/brain-core)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://github.com/timmeck/brain-ecosystem)
|
|
7
7
|
|
|
8
8
|
**Shared infrastructure for the Brain ecosystem — IPC, MCP, CLI, DB, math, synapses, and utilities.**
|
|
9
9
|
|
|
10
|
-
Brain Core extracts the common infrastructure used across all Brain MCP servers ([Brain](https://github.com/timmeck/brain), [Trading Brain](https://github.com/timmeck/trading-brain), [Marketing Brain](https://github.com/timmeck/marketing-brain)) into a single, reusable package.
|
|
10
|
+
Brain Core extracts the common infrastructure used across all Brain MCP servers ([Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/brain), [Trading Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/trading-brain), [Marketing Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/marketing-brain)) into a single, reusable package. All packages live in the [brain-ecosystem](https://github.com/timmeck/brain-ecosystem) monorepo.
|
|
11
11
|
|
|
12
12
|
## What's Included
|
|
13
13
|
|
|
@@ -32,6 +32,8 @@ Brain Core extracts the common infrastructure used across all Brain MCP servers
|
|
|
32
32
|
| **BaseSynapseManager** | Abstract synapse manager with strengthen/weaken/activate/findPath/decay |
|
|
33
33
|
| **BaseLearningEngine** | Abstract timer-managed learning engine with error handling |
|
|
34
34
|
| **BaseResearchEngine** | Abstract timer-managed research engine with optional initial delay |
|
|
35
|
+
| **BaseMemoryEngine** | Abstract timer-managed memory engine for expiry/consolidation/decay (new in v1.6) |
|
|
36
|
+
| **Memory Types** | Shared types for Memory, Session, Remember/Recall/Session interfaces (new in v1.6) |
|
|
35
37
|
| **Utils** | Path normalization, data dir resolution, SHA-256 hashing |
|
|
36
38
|
|
|
37
39
|
## Installation
|
|
@@ -141,6 +143,7 @@ class MyRouter implements IpcRouter {
|
|
|
141
143
|
├── Synapses ───── Hebbian, Decay, Activation, Pathfinder, BaseSynapseManager
|
|
142
144
|
├── Learning ───── BaseLearningEngine (abstract, timer-managed)
|
|
143
145
|
├── Research ───── BaseResearchEngine (abstract, timer-managed)
|
|
146
|
+
├── Memory ────── BaseMemoryEngine, MemoryRecord, SessionRecord, shared interfaces
|
|
144
147
|
└── Cross-Brain ── CrossBrainClient, CrossBrainNotifier
|
|
145
148
|
```
|
|
146
149
|
|
|
@@ -148,12 +151,12 @@ class MyRouter implements IpcRouter {
|
|
|
148
151
|
|
|
149
152
|
| Brain | Version | Purpose | Ports |
|
|
150
153
|
|-------|---------|---------|-------|
|
|
151
|
-
| [Brain](https://github.com/timmeck/brain) | v2.1
|
|
152
|
-
| [Trading Brain](https://github.com/timmeck/trading-brain) | v1.2
|
|
153
|
-
| [Marketing Brain](https://github.com/timmeck/marketing-brain) | v0.
|
|
154
|
-
| [Brain Core](https://github.com/timmeck/brain-core) | v1.
|
|
154
|
+
| [Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/brain) | v2.2.1 | Error memory, code intelligence & persistent context | 7777/7778 |
|
|
155
|
+
| [Trading Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/trading-brain) | v1.3.2 | Adaptive trading intelligence with memory & sessions | 7779/7780 |
|
|
156
|
+
| [Marketing Brain](https://github.com/timmeck/brain-ecosystem/tree/main/packages/marketing-brain) | v0.5.2 | Content strategy & engagement with memory & sessions | 7781/7782/7783 |
|
|
157
|
+
| [Brain Core](https://github.com/timmeck/brain-ecosystem/tree/main/packages/brain-core) | v1.6.1 | Shared infrastructure (this package) | — |
|
|
155
158
|
|
|
156
|
-
All
|
|
159
|
+
All packages live in the [brain-ecosystem](https://github.com/timmeck/brain-ecosystem) monorepo with npm workspaces. Brain Core provides shared infrastructure that eliminates ~2,800 lines of duplicated code across the ecosystem.
|
|
157
160
|
|
|
158
161
|
## Cross-Brain Communication
|
|
159
162
|
|
|
@@ -165,7 +168,7 @@ import { CrossBrainClient, CrossBrainNotifier } from '@timmeck/brain-core';
|
|
|
165
168
|
// Query peers
|
|
166
169
|
const cross = new CrossBrainClient('brain');
|
|
167
170
|
const peers = await cross.getAvailablePeers();
|
|
168
|
-
// → [{ name: 'trading-brain', version: '1.2
|
|
171
|
+
// → [{ name: 'trading-brain', version: '1.3.2', uptime: 3600, pid: 12345, methods: 22 }, ...]
|
|
169
172
|
|
|
170
173
|
// Push event notifications to peers (v1.5+)
|
|
171
174
|
const notifier = new CrossBrainNotifier(cross, 'brain');
|
|
@@ -178,7 +181,7 @@ notifier.notifyPeer('trading-brain', 'insight:created', { insightId: 7 });
|
|
|
178
181
|
Abstract base classes eliminate timer boilerplate from learning and research engines:
|
|
179
182
|
|
|
180
183
|
```typescript
|
|
181
|
-
import { BaseLearningEngine, BaseResearchEngine } from '@timmeck/brain-core';
|
|
184
|
+
import { BaseLearningEngine, BaseResearchEngine, BaseMemoryEngine } from '@timmeck/brain-core';
|
|
182
185
|
|
|
183
186
|
class MyLearningEngine extends BaseLearningEngine {
|
|
184
187
|
runCycle() { /* your learning logic */ }
|
|
@@ -187,10 +190,21 @@ class MyLearningEngine extends BaseLearningEngine {
|
|
|
187
190
|
class MyResearchEngine extends BaseResearchEngine {
|
|
188
191
|
runCycle() { /* your research logic */ }
|
|
189
192
|
}
|
|
193
|
+
|
|
194
|
+
class MyMemoryEngine extends BaseMemoryEngine {
|
|
195
|
+
runCycle() { /* expiry checks, consolidation, importance decay */ }
|
|
196
|
+
}
|
|
190
197
|
```
|
|
191
198
|
|
|
192
199
|
Visit the [Brain Hub](https://timmeck.github.io/brain-hub/) for the full ecosystem overview.
|
|
193
200
|
|
|
201
|
+
## Support
|
|
202
|
+
|
|
203
|
+
If Brain Core helps you, consider giving it a star — it helps others discover the project and keeps development going.
|
|
204
|
+
|
|
205
|
+
[](https://github.com/timmeck/brain-ecosystem)
|
|
206
|
+
[](https://github.com/sponsors/timmeck)
|
|
207
|
+
|
|
194
208
|
## License
|
|
195
209
|
|
|
196
210
|
[MIT](LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export { BaseLearningEngine } from './learning/base-engine.js';
|
|
|
30
30
|
export type { LearningEngineConfig } from './learning/base-engine.js';
|
|
31
31
|
export { BaseResearchEngine } from './research/base-engine.js';
|
|
32
32
|
export type { ResearchEngineConfig } from './research/base-engine.js';
|
|
33
|
+
export type { MemoryRecord, SessionRecord, MemoryCategory, MemorySource, SessionOutcome, RememberInput, RecallInput, StartSessionInput, EndSessionInput, MemoryRepoInterface, SessionRepoInterface, MemoryEngineConfig, } from './memory/types.js';
|
|
34
|
+
export { BaseMemoryEngine } from './memory/base-memory-engine.js';
|
|
33
35
|
export { CrossBrainClient } from './cross-brain/client.js';
|
|
34
36
|
export type { BrainPeer } from './cross-brain/client.js';
|
|
35
37
|
export { CrossBrainNotifier } from './cross-brain/notifications.js';
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { BaseSynapseManager } from './synapses/synapse-manager.js';
|
|
|
29
29
|
// ── Engines ───────────────────────────────────────────────
|
|
30
30
|
export { BaseLearningEngine } from './learning/base-engine.js';
|
|
31
31
|
export { BaseResearchEngine } from './research/base-engine.js';
|
|
32
|
+
export { BaseMemoryEngine } from './memory/base-memory-engine.js';
|
|
32
33
|
// ── Cross-Brain ────────────────────────────────────────────
|
|
33
34
|
export { CrossBrainClient } from './cross-brain/client.js';
|
|
34
35
|
export { CrossBrainNotifier } from './cross-brain/notifications.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,8DAA8D;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,8DAA8D;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,8DAA8D;AAC9D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,8DAA8D;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,8DAA8D;AAC9D,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEtH,8DAA8D;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,8DAA8D;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,8DAA8D;AAC9D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQ/D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,6DAA6D;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,8DAA8D;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,8DAA8D;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,8DAA8D;AAC9D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,8DAA8D;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,8DAA8D;AAC9D,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEtH,8DAA8D;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,8DAA8D;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,8DAA8D;AAC9D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQ/D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,6DAA6D;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAU/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,8DAA8D;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MemoryEngineConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for memory engines.
|
|
4
|
+
* Handles timer lifecycle for periodic memory maintenance:
|
|
5
|
+
* - Expiry checks (deactivate expired memories)
|
|
6
|
+
* - Consolidation (merge similar memories)
|
|
7
|
+
* - Importance decay (reduce importance of never-recalled memories)
|
|
8
|
+
*
|
|
9
|
+
* Subclasses implement runCycle().
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class BaseMemoryEngine {
|
|
12
|
+
protected config: MemoryEngineConfig;
|
|
13
|
+
protected timer: ReturnType<typeof setInterval> | null;
|
|
14
|
+
protected logger: import("winston").Logger;
|
|
15
|
+
constructor(config: MemoryEngineConfig);
|
|
16
|
+
start(): void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
abstract runCycle(): unknown;
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getLogger } from '../utils/logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for memory engines.
|
|
4
|
+
* Handles timer lifecycle for periodic memory maintenance:
|
|
5
|
+
* - Expiry checks (deactivate expired memories)
|
|
6
|
+
* - Consolidation (merge similar memories)
|
|
7
|
+
* - Importance decay (reduce importance of never-recalled memories)
|
|
8
|
+
*
|
|
9
|
+
* Subclasses implement runCycle().
|
|
10
|
+
*/
|
|
11
|
+
export class BaseMemoryEngine {
|
|
12
|
+
config;
|
|
13
|
+
timer = null;
|
|
14
|
+
logger = getLogger();
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
start() {
|
|
19
|
+
this.timer = setInterval(() => {
|
|
20
|
+
try {
|
|
21
|
+
this.runCycle();
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
this.logger.error('Memory engine cycle error', { error: String(err) });
|
|
25
|
+
}
|
|
26
|
+
}, this.config.intervalMs);
|
|
27
|
+
}
|
|
28
|
+
stop() {
|
|
29
|
+
if (this.timer) {
|
|
30
|
+
clearInterval(this.timer);
|
|
31
|
+
this.timer = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=base-memory-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-memory-engine.js","sourceRoot":"","sources":["../../src/memory/base-memory-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;;;;;GAQG;AACH,MAAM,OAAgB,gBAAgB;IAId;IAHZ,KAAK,GAA0C,IAAI,CAAC;IACpD,MAAM,GAAG,SAAS,EAAE,CAAC;IAE/B,YAAsB,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;IAAG,CAAC;IAEpD,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;YAC5B,IAAI,CAAC;gBACH,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACzE,CAAC;QACH,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;CAGF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export type MemoryCategory = 'preference' | 'decision' | 'context' | 'fact' | 'goal' | 'lesson';
|
|
2
|
+
export type MemorySource = 'explicit' | 'inferred' | 'hook';
|
|
3
|
+
export type SessionOutcome = 'completed' | 'paused' | 'abandoned';
|
|
4
|
+
export interface MemoryRecord {
|
|
5
|
+
id: number;
|
|
6
|
+
project_id: number | null;
|
|
7
|
+
session_id: number | null;
|
|
8
|
+
category: MemoryCategory;
|
|
9
|
+
key: string | null;
|
|
10
|
+
content: string;
|
|
11
|
+
importance: number;
|
|
12
|
+
source: MemorySource;
|
|
13
|
+
tags: string | null;
|
|
14
|
+
expires_at: string | null;
|
|
15
|
+
superseded_by: number | null;
|
|
16
|
+
active: number;
|
|
17
|
+
created_at: string;
|
|
18
|
+
updated_at: string;
|
|
19
|
+
embedding: Buffer | null;
|
|
20
|
+
}
|
|
21
|
+
export interface SessionRecord {
|
|
22
|
+
id: number;
|
|
23
|
+
session_id: string;
|
|
24
|
+
project_id: number | null;
|
|
25
|
+
started_at: string;
|
|
26
|
+
ended_at: string | null;
|
|
27
|
+
summary: string | null;
|
|
28
|
+
goals: string | null;
|
|
29
|
+
outcome: SessionOutcome | null;
|
|
30
|
+
metadata: string | null;
|
|
31
|
+
embedding: Buffer | null;
|
|
32
|
+
}
|
|
33
|
+
export interface RememberInput {
|
|
34
|
+
content: string;
|
|
35
|
+
category: MemoryCategory;
|
|
36
|
+
key?: string;
|
|
37
|
+
importance?: number;
|
|
38
|
+
source?: MemorySource;
|
|
39
|
+
tags?: string[];
|
|
40
|
+
projectId?: number;
|
|
41
|
+
sessionId?: number;
|
|
42
|
+
expiresAt?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface RecallInput {
|
|
45
|
+
query: string;
|
|
46
|
+
category?: MemoryCategory;
|
|
47
|
+
projectId?: number;
|
|
48
|
+
limit?: number;
|
|
49
|
+
activeOnly?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface StartSessionInput {
|
|
52
|
+
sessionId?: string;
|
|
53
|
+
projectId?: number;
|
|
54
|
+
goals?: string[];
|
|
55
|
+
metadata?: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
export interface EndSessionInput {
|
|
58
|
+
sessionId: number;
|
|
59
|
+
summary: string;
|
|
60
|
+
outcome?: SessionOutcome;
|
|
61
|
+
}
|
|
62
|
+
export interface MemoryRepoInterface {
|
|
63
|
+
create(data: Omit<MemoryRecord, 'id' | 'created_at' | 'updated_at'>): number;
|
|
64
|
+
getById(id: number): MemoryRecord | undefined;
|
|
65
|
+
findByKey(projectId: number | null, key: string): MemoryRecord | undefined;
|
|
66
|
+
findByCategory(category: MemoryCategory, projectId?: number, limit?: number): MemoryRecord[];
|
|
67
|
+
findActive(projectId?: number, limit?: number): MemoryRecord[];
|
|
68
|
+
search(query: string, limit?: number): MemoryRecord[];
|
|
69
|
+
supersede(oldId: number, newId: number): void;
|
|
70
|
+
deactivate(id: number): void;
|
|
71
|
+
expireOld(): number;
|
|
72
|
+
update(id: number, data: Partial<MemoryRecord>): void;
|
|
73
|
+
}
|
|
74
|
+
export interface SessionRepoInterface {
|
|
75
|
+
create(data: Omit<SessionRecord, 'id'>): number;
|
|
76
|
+
getById(id: number): SessionRecord | undefined;
|
|
77
|
+
findBySessionId(sessionId: string): SessionRecord | undefined;
|
|
78
|
+
findByProject(projectId: number, limit?: number): SessionRecord[];
|
|
79
|
+
findRecent(limit?: number): SessionRecord[];
|
|
80
|
+
update(id: number, data: Partial<SessionRecord>): void;
|
|
81
|
+
search(query: string, limit?: number): SessionRecord[];
|
|
82
|
+
}
|
|
83
|
+
export interface MemoryEngineConfig {
|
|
84
|
+
intervalMs: number;
|
|
85
|
+
expiryCheckEnabled: boolean;
|
|
86
|
+
consolidationEnabled: boolean;
|
|
87
|
+
importanceDecayDays: number;
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timmeck/brain-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Shared core infrastructure for the Brain ecosystem — IPC, MCP, CLI, DB connection, and utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,12 +29,14 @@
|
|
|
29
29
|
"./synapses/activation": "./dist/synapses/activation.js",
|
|
30
30
|
"./synapses/pathfinder": "./dist/synapses/pathfinder.js",
|
|
31
31
|
"./synapses/synapse-manager": "./dist/synapses/synapse-manager.js",
|
|
32
|
-
"./cross-brain": "./dist/cross-brain/client.js"
|
|
32
|
+
"./cross-brain": "./dist/cross-brain/client.js",
|
|
33
|
+
"./memory/types": "./dist/memory/types.js",
|
|
34
|
+
"./memory/base-memory-engine": "./dist/memory/base-memory-engine.js"
|
|
33
35
|
},
|
|
34
36
|
"scripts": {
|
|
35
37
|
"build": "tsc",
|
|
36
38
|
"dev": "tsx src/index.ts",
|
|
37
|
-
"test": "vitest",
|
|
39
|
+
"test": "vitest run",
|
|
38
40
|
"lint": "eslint src/",
|
|
39
41
|
"lint:fix": "eslint src/ --fix",
|
|
40
42
|
"test:coverage": "vitest --coverage"
|
|
@@ -60,7 +62,8 @@
|
|
|
60
62
|
"license": "MIT",
|
|
61
63
|
"repository": {
|
|
62
64
|
"type": "git",
|
|
63
|
-
"url": "https://github.com/timmeck/brain-
|
|
65
|
+
"url": "https://github.com/timmeck/brain-ecosystem",
|
|
66
|
+
"directory": "packages/brain-core"
|
|
64
67
|
},
|
|
65
68
|
"dependencies": {
|
|
66
69
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
package/brain.log
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
2026-02-27T15:33:52.574Z [error] {"error":"Error: boom"} Learning cycle error
|
|
2
|
-
2026-02-27T15:33:52.575Z [error] {"error":"Error: boom"} Research cycle error
|
|
3
|
-
2026-02-27T15:36:06.467Z [error] {"error":"Error: boom"} Learning cycle error
|
|
4
|
-
2026-02-27T15:36:06.471Z [error] {"error":"Error: boom"} Research cycle error
|
|
5
|
-
2026-02-27T15:40:43.982Z [error] {"error":"Error: boom"} Research cycle error
|
|
6
|
-
2026-02-27T15:40:43.982Z [error] {"error":"Error: boom"} Learning cycle error
|