@getanima/core 0.3.3 → 0.4.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/dist/episodes.d.ts +109 -0
- package/dist/episodes.d.ts.map +1 -0
- package/dist/episodes.js +589 -0
- package/dist/episodes.js.map +1 -0
- package/dist/esm/episodes.js +585 -0
- package/dist/esm/episodes.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Episodic Memory Engine — structured records of experiences.
|
|
3
|
+
*
|
|
4
|
+
* Unlike flat memories, episodes capture the full context of an experience:
|
|
5
|
+
* who was involved, what happened, how important it was, what was learned,
|
|
6
|
+
* and how it connects to other memories, opinions, and knowledge.
|
|
7
|
+
*
|
|
8
|
+
* Episodes decay based on importance and emotional weight.
|
|
9
|
+
* High-importance episodes get promoted to semantic knowledge automatically.
|
|
10
|
+
*
|
|
11
|
+
* Zero external dependencies. File-based persistence.
|
|
12
|
+
*/
|
|
13
|
+
import type { Episode, EpisodeInput, EpisodeQuery, EpisodeStats, KnowledgeEntry, KnowledgeInput } from './types';
|
|
14
|
+
export declare class EpisodicMemory {
|
|
15
|
+
private storagePath;
|
|
16
|
+
private episodesDir;
|
|
17
|
+
private knowledgeDir;
|
|
18
|
+
private episodes;
|
|
19
|
+
private knowledge;
|
|
20
|
+
private loaded;
|
|
21
|
+
private knowledgeLoaded;
|
|
22
|
+
constructor(storagePath: string);
|
|
23
|
+
/**
|
|
24
|
+
* Record a new episode — a structured experience.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* await episodes.record({
|
|
29
|
+
* title: 'Customer escalation resolved',
|
|
30
|
+
* summary: 'User was frustrated about billing. De-escalated with empathy first.',
|
|
31
|
+
* emotionalWeight: 0.7,
|
|
32
|
+
* participants: ['user-123'],
|
|
33
|
+
* tags: ['customer-service', 'conflict'],
|
|
34
|
+
* lessons: ['Empathy before solutions works better than jumping to fixes'],
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
record(input: EpisodeInput): Promise<Episode>;
|
|
39
|
+
/**
|
|
40
|
+
* Search episodes by various criteria.
|
|
41
|
+
* Returns episodes sorted by relevance (importance * recency * match).
|
|
42
|
+
*/
|
|
43
|
+
query(q: EpisodeQuery): Promise<Episode[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a single episode by ID.
|
|
46
|
+
*/
|
|
47
|
+
get(id: string): Promise<Episode | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Get the most recent N episodes.
|
|
50
|
+
*/
|
|
51
|
+
recent(limit?: number): Promise<Episode[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get episodes connected to a specific episode.
|
|
54
|
+
*/
|
|
55
|
+
related(episodeId: string): Promise<Episode[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Add a lesson learned to an existing episode.
|
|
58
|
+
* Use when you realize something new about a past experience.
|
|
59
|
+
*/
|
|
60
|
+
addLesson(episodeId: string, lesson: string): Promise<Episode | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Connect two episodes together.
|
|
63
|
+
*/
|
|
64
|
+
connect(episodeIdA: string, episodeIdB: string): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Archive an episode (soft delete). Can be restored.
|
|
67
|
+
*/
|
|
68
|
+
archive(episodeId: string): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Restore an archived episode.
|
|
71
|
+
*/
|
|
72
|
+
restore(episodeId: string): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Store a distilled lesson — semantic knowledge not tied to a specific moment.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* await episodes.learn({
|
|
79
|
+
* topic: 'customer-retention',
|
|
80
|
+
* insight: 'Users who get a callback within 2 hours have 3x retention',
|
|
81
|
+
* confidence: 0.8,
|
|
82
|
+
* tags: ['business', 'retention'],
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
learn(input: KnowledgeInput): Promise<KnowledgeEntry>;
|
|
87
|
+
/**
|
|
88
|
+
* Search knowledge by topic or text.
|
|
89
|
+
*/
|
|
90
|
+
recall(query: string, limit?: number): Promise<KnowledgeEntry[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Get all knowledge entries.
|
|
93
|
+
*/
|
|
94
|
+
getAllKnowledge(): Promise<KnowledgeEntry[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Consolidate episodes — decay old ones, promote lessons, clean up.
|
|
97
|
+
* Call this periodically (e.g., during heartbeats or sleep).
|
|
98
|
+
*/
|
|
99
|
+
consolidate(): Promise<EpisodeStats>;
|
|
100
|
+
stats(): Promise<EpisodeStats>;
|
|
101
|
+
private calculateImportance;
|
|
102
|
+
private validateConnections;
|
|
103
|
+
private extractTopicFromLesson;
|
|
104
|
+
private load;
|
|
105
|
+
private save;
|
|
106
|
+
private loadKnowledge;
|
|
107
|
+
private saveKnowledge;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=episodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"episodes.d.ts","sourceRoot":"","sources":["../src/episodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAwBjH,qBAAa,cAAc;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC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