@auxiora/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/LICENSE +191 -0
- package/dist/extractor.d.ts +40 -0
- package/dist/extractor.d.ts.map +1 -0
- package/dist/extractor.js +130 -0
- package/dist/extractor.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/partition.d.ts +25 -0
- package/dist/partition.d.ts.map +1 -0
- package/dist/partition.js +104 -0
- package/dist/partition.js.map +1 -0
- package/dist/pattern-detector.d.ts +27 -0
- package/dist/pattern-detector.d.ts.map +1 -0
- package/dist/pattern-detector.js +260 -0
- package/dist/pattern-detector.js.map +1 -0
- package/dist/personality-adapter.d.ts +10 -0
- package/dist/personality-adapter.d.ts.map +1 -0
- package/dist/personality-adapter.js +72 -0
- package/dist/personality-adapter.js.map +1 -0
- package/dist/retriever.d.ts +15 -0
- package/dist/retriever.d.ts.map +1 -0
- package/dist/retriever.js +179 -0
- package/dist/retriever.js.map +1 -0
- package/dist/sentiment.d.ts +7 -0
- package/dist/sentiment.d.ts.map +1 -0
- package/dist/sentiment.js +118 -0
- package/dist/sentiment.js.map +1 -0
- package/dist/store.d.ts +41 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +352 -0
- package/dist/store.js.map +1 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +26 -0
- package/src/extractor.ts +212 -0
- package/src/index.ts +22 -0
- package/src/partition.ts +123 -0
- package/src/pattern-detector.ts +304 -0
- package/src/personality-adapter.ts +82 -0
- package/src/retriever.ts +213 -0
- package/src/sentiment.ts +129 -0
- package/src/store.ts +384 -0
- package/src/types.ts +92 -0
- package/tests/extractor.test.ts +247 -0
- package/tests/partition.test.ts +168 -0
- package/tests/pattern-detector.test.ts +150 -0
- package/tests/personality-adapter.test.ts +155 -0
- package/tests/retriever.test.ts +240 -0
- package/tests/sentiment.test.ts +207 -0
- package/tests/store.test.ts +390 -0
- package/tsconfig.json +13 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
const DAY_NAMES = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
2
|
+
export class PatternDetector {
|
|
3
|
+
sentimentHistory = [];
|
|
4
|
+
recordSentiment(snapshot) {
|
|
5
|
+
this.sentimentHistory.push(snapshot);
|
|
6
|
+
// Keep only the last 200 snapshots
|
|
7
|
+
if (this.sentimentHistory.length > 200) {
|
|
8
|
+
this.sentimentHistory = this.sentimentHistory.slice(-200);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
getSentimentHistory() {
|
|
12
|
+
return [...this.sentimentHistory];
|
|
13
|
+
}
|
|
14
|
+
detectMoodByTime() {
|
|
15
|
+
if (this.sentimentHistory.length < 3)
|
|
16
|
+
return [];
|
|
17
|
+
const signals = [];
|
|
18
|
+
// Group by time period
|
|
19
|
+
const periodSentiments = new Map();
|
|
20
|
+
for (const snap of this.sentimentHistory) {
|
|
21
|
+
const period = this.getTimePeriodName(snap.hour);
|
|
22
|
+
const list = periodSentiments.get(period) ?? [];
|
|
23
|
+
list.push(snap.sentiment);
|
|
24
|
+
periodSentiments.set(period, list);
|
|
25
|
+
}
|
|
26
|
+
for (const [period, sentiments] of periodSentiments) {
|
|
27
|
+
if (sentiments.length < 3)
|
|
28
|
+
continue;
|
|
29
|
+
const dominant = this.getDominantSentiment(sentiments);
|
|
30
|
+
if (dominant && dominant.label !== 'neutral' && dominant.ratio > 0.6) {
|
|
31
|
+
signals.push({
|
|
32
|
+
type: 'mood',
|
|
33
|
+
pattern: `User tends to be ${dominant.label} in the ${period}`,
|
|
34
|
+
confidence: Math.min(0.4 + dominant.ratio * 0.4, 0.85),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Group by day of week
|
|
39
|
+
const daySentiments = new Map();
|
|
40
|
+
for (const snap of this.sentimentHistory) {
|
|
41
|
+
const list = daySentiments.get(snap.dayOfWeek) ?? [];
|
|
42
|
+
list.push(snap.sentiment);
|
|
43
|
+
daySentiments.set(snap.dayOfWeek, list);
|
|
44
|
+
}
|
|
45
|
+
for (const [day, sentiments] of daySentiments) {
|
|
46
|
+
if (sentiments.length < 3)
|
|
47
|
+
continue;
|
|
48
|
+
const dominant = this.getDominantSentiment(sentiments);
|
|
49
|
+
if (dominant && dominant.label !== 'neutral' && dominant.ratio > 0.7) {
|
|
50
|
+
signals.push({
|
|
51
|
+
type: 'mood',
|
|
52
|
+
pattern: `User tends to be ${dominant.label} on ${DAY_NAMES[day]}s`,
|
|
53
|
+
confidence: Math.min(0.4 + dominant.ratio * 0.4, 0.85),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return signals;
|
|
58
|
+
}
|
|
59
|
+
getDominantSentiment(sentiments) {
|
|
60
|
+
const counts = { positive: 0, negative: 0, neutral: 0 };
|
|
61
|
+
for (const s of sentiments) {
|
|
62
|
+
counts[s]++;
|
|
63
|
+
}
|
|
64
|
+
const total = sentiments.length;
|
|
65
|
+
const entries = [
|
|
66
|
+
['positive', counts.positive],
|
|
67
|
+
['negative', counts.negative],
|
|
68
|
+
['neutral', counts.neutral],
|
|
69
|
+
];
|
|
70
|
+
entries.sort((a, b) => b[1] - a[1]);
|
|
71
|
+
return { label: entries[0][0], ratio: entries[0][1] / total };
|
|
72
|
+
}
|
|
73
|
+
getTimePeriodName(hour) {
|
|
74
|
+
if (hour >= 5 && hour < 12)
|
|
75
|
+
return 'morning';
|
|
76
|
+
if (hour >= 12 && hour < 17)
|
|
77
|
+
return 'afternoon';
|
|
78
|
+
if (hour >= 17 && hour < 21)
|
|
79
|
+
return 'evening';
|
|
80
|
+
return 'night';
|
|
81
|
+
}
|
|
82
|
+
detect(messages) {
|
|
83
|
+
if (messages.length < 3)
|
|
84
|
+
return [];
|
|
85
|
+
const userMessages = messages.filter(m => m.role === 'user');
|
|
86
|
+
if (userMessages.length === 0)
|
|
87
|
+
return [];
|
|
88
|
+
const signals = [];
|
|
89
|
+
signals.push(...this.detectCommunicationPatterns(userMessages));
|
|
90
|
+
signals.push(...this.detectSchedulePatterns(userMessages));
|
|
91
|
+
signals.push(...this.detectTopicPatterns(userMessages));
|
|
92
|
+
signals.push(...this.detectMoodPatterns(userMessages));
|
|
93
|
+
return signals;
|
|
94
|
+
}
|
|
95
|
+
detectCommunicationPatterns(messages) {
|
|
96
|
+
const signals = [];
|
|
97
|
+
const lengths = messages.map(m => m.content.length);
|
|
98
|
+
const avgLength = lengths.reduce((a, b) => a + b, 0) / lengths.length;
|
|
99
|
+
if (avgLength < 50 && messages.length >= 5) {
|
|
100
|
+
signals.push({
|
|
101
|
+
type: 'communication',
|
|
102
|
+
pattern: 'User prefers brief messages',
|
|
103
|
+
confidence: Math.min(0.5 + messages.length * 0.05, 0.9),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
else if (avgLength > 200 && messages.length >= 5) {
|
|
107
|
+
signals.push({
|
|
108
|
+
type: 'communication',
|
|
109
|
+
pattern: 'User writes detailed messages',
|
|
110
|
+
confidence: Math.min(0.5 + messages.length * 0.05, 0.9),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
// Question frequency
|
|
114
|
+
const questionMessages = messages.filter(m => m.content.includes('?'));
|
|
115
|
+
const questionRatio = questionMessages.length / messages.length;
|
|
116
|
+
if (questionRatio > 0.6 && messages.length >= 5) {
|
|
117
|
+
signals.push({
|
|
118
|
+
type: 'communication',
|
|
119
|
+
pattern: 'User frequently asks questions',
|
|
120
|
+
confidence: Math.min(0.4 + questionRatio * 0.5, 0.9),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Code-heavy detection
|
|
124
|
+
const codeMessages = messages.filter(m => m.content.includes('```') || m.content.includes('function ') || m.content.includes('const ') || m.content.includes('import '));
|
|
125
|
+
const codeRatio = codeMessages.length / messages.length;
|
|
126
|
+
if (codeRatio > 0.3 && messages.length >= 5) {
|
|
127
|
+
signals.push({
|
|
128
|
+
type: 'communication',
|
|
129
|
+
pattern: 'User frequently shares code snippets',
|
|
130
|
+
confidence: Math.min(0.4 + codeRatio * 0.5, 0.9),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return signals;
|
|
134
|
+
}
|
|
135
|
+
detectSchedulePatterns(messages) {
|
|
136
|
+
const signals = [];
|
|
137
|
+
if (messages.length < 5)
|
|
138
|
+
return signals;
|
|
139
|
+
const hours = messages.map(m => new Date(m.timestamp).getHours());
|
|
140
|
+
const hourCounts = new Map();
|
|
141
|
+
for (const h of hours) {
|
|
142
|
+
hourCounts.set(h, (hourCounts.get(h) ?? 0) + 1);
|
|
143
|
+
}
|
|
144
|
+
// Find the peak 3-hour window
|
|
145
|
+
let peakStart = 0;
|
|
146
|
+
let peakCount = 0;
|
|
147
|
+
for (let h = 0; h < 24; h++) {
|
|
148
|
+
const count = (hourCounts.get(h) ?? 0) +
|
|
149
|
+
(hourCounts.get((h + 1) % 24) ?? 0) +
|
|
150
|
+
(hourCounts.get((h + 2) % 24) ?? 0);
|
|
151
|
+
if (count > peakCount) {
|
|
152
|
+
peakCount = count;
|
|
153
|
+
peakStart = h;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const peakRatio = peakCount / messages.length;
|
|
157
|
+
if (peakRatio > 0.5) {
|
|
158
|
+
const peakEnd = (peakStart + 2) % 24;
|
|
159
|
+
const period = this.getTimePeriod(peakStart);
|
|
160
|
+
signals.push({
|
|
161
|
+
type: 'schedule',
|
|
162
|
+
pattern: `User is most active in the ${period} (${peakStart}:00-${peakEnd}:59)`,
|
|
163
|
+
confidence: Math.min(0.4 + peakRatio * 0.5, 0.9),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return signals;
|
|
167
|
+
}
|
|
168
|
+
detectTopicPatterns(messages) {
|
|
169
|
+
const signals = [];
|
|
170
|
+
if (messages.length < 5)
|
|
171
|
+
return signals;
|
|
172
|
+
const wordCounts = new Map();
|
|
173
|
+
const stopWords = new Set([
|
|
174
|
+
'the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
175
|
+
'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
176
|
+
'should', 'may', 'might', 'can', 'shall', 'to', 'of', 'in', 'for',
|
|
177
|
+
'on', 'with', 'at', 'by', 'from', 'as', 'into', 'through', 'during',
|
|
178
|
+
'and', 'but', 'or', 'not', 'so', 'yet', 'i', 'me', 'my', 'we', 'you',
|
|
179
|
+
'your', 'he', 'she', 'they', 'it', 'what', 'which', 'who', 'when',
|
|
180
|
+
'where', 'how', 'that', 'this', 'just', 'like', 'also', 'about',
|
|
181
|
+
'than', 'too', 'very', 'its', 'them', 'their', 'our',
|
|
182
|
+
]);
|
|
183
|
+
for (const msg of messages) {
|
|
184
|
+
const words = msg.content
|
|
185
|
+
.toLowerCase()
|
|
186
|
+
.replace(/[^a-z0-9\s-]/g, '')
|
|
187
|
+
.split(/\s+/)
|
|
188
|
+
.filter(w => w.length > 2 && !stopWords.has(w));
|
|
189
|
+
for (const word of words) {
|
|
190
|
+
wordCounts.set(word, (wordCounts.get(word) ?? 0) + 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const topWords = Array.from(wordCounts.entries())
|
|
194
|
+
.filter(([, count]) => count >= 3)
|
|
195
|
+
.sort((a, b) => b[1] - a[1])
|
|
196
|
+
.slice(0, 5);
|
|
197
|
+
if (topWords.length >= 2) {
|
|
198
|
+
const topics = topWords.map(([word]) => word).join(', ');
|
|
199
|
+
signals.push({
|
|
200
|
+
type: 'topic',
|
|
201
|
+
pattern: `User frequently discusses: ${topics}`,
|
|
202
|
+
confidence: Math.min(0.5 + topWords.length * 0.05, 0.85),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return signals;
|
|
206
|
+
}
|
|
207
|
+
detectMoodPatterns(messages) {
|
|
208
|
+
const signals = [];
|
|
209
|
+
if (messages.length < 5)
|
|
210
|
+
return signals;
|
|
211
|
+
let enthusiastic = 0;
|
|
212
|
+
let frustrated = 0;
|
|
213
|
+
let casual = 0;
|
|
214
|
+
for (const msg of messages) {
|
|
215
|
+
const text = msg.content;
|
|
216
|
+
if (text.includes('!') || /\b(great|awesome|love|amazing|excellent|perfect)\b/i.test(text)) {
|
|
217
|
+
enthusiastic++;
|
|
218
|
+
}
|
|
219
|
+
if (/\b(ugh|damn|broken|bug|error|fail|wrong|issue|problem)\b/i.test(text)) {
|
|
220
|
+
frustrated++;
|
|
221
|
+
}
|
|
222
|
+
if (/\b(lol|haha|heh|lmao|tbh|imo|btw|gonna|wanna)\b/i.test(text)) {
|
|
223
|
+
casual++;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const total = messages.length;
|
|
227
|
+
if (enthusiastic / total > 0.3) {
|
|
228
|
+
signals.push({
|
|
229
|
+
type: 'mood',
|
|
230
|
+
pattern: 'User tends to be enthusiastic and positive',
|
|
231
|
+
confidence: Math.min(0.4 + (enthusiastic / total) * 0.5, 0.85),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (frustrated / total > 0.3) {
|
|
235
|
+
signals.push({
|
|
236
|
+
type: 'mood',
|
|
237
|
+
pattern: 'User may be experiencing frustration',
|
|
238
|
+
confidence: Math.min(0.4 + (frustrated / total) * 0.5, 0.85),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
if (casual / total > 0.3) {
|
|
242
|
+
signals.push({
|
|
243
|
+
type: 'mood',
|
|
244
|
+
pattern: 'User uses casual, informal language',
|
|
245
|
+
confidence: Math.min(0.4 + (casual / total) * 0.5, 0.85),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return signals;
|
|
249
|
+
}
|
|
250
|
+
getTimePeriod(hour) {
|
|
251
|
+
if (hour >= 5 && hour < 12)
|
|
252
|
+
return 'morning';
|
|
253
|
+
if (hour >= 12 && hour < 17)
|
|
254
|
+
return 'afternoon';
|
|
255
|
+
if (hour >= 17 && hour < 21)
|
|
256
|
+
return 'evening';
|
|
257
|
+
return 'night';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=pattern-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-detector.js","sourceRoot":"","sources":["../src/pattern-detector.ts"],"names":[],"mappings":"AAcA,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAEjG,MAAM,OAAO,eAAe;IAClB,gBAAgB,GAAwB,EAAE,CAAC;IAEnD,eAAe,CAAC,QAA2B;QACzC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,mCAAmC;QACnC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACvC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,mBAAmB;QACjB,OAAO,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;IAED,gBAAgB;QACd,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,EAAE,CAAC;QAEhD,MAAM,OAAO,GAAoB,EAAE,CAAC;QAEpC,uBAAuB;QACvB,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA4B,CAAC;QAC7D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,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CAAC;QAED,IAAI,MAAM,GAAG,KAAK,GAAG,GAAG,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,qCAAqC;gBAC9C,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC;aACzD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,aAAa,CAAC,IAAY;QAChC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,GAAG,EAAE;YAAE,OAAO,SAAS,CAAC;QAC7C,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE;YAAE,OAAO,WAAW,CAAC;QAChD,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE;YAAE,OAAO,SAAS,CAAC;QAC9C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PersonalityAdaptation } from './types.js';
|
|
2
|
+
import type { MemoryStore } from './store.js';
|
|
3
|
+
export declare class PersonalityAdapter {
|
|
4
|
+
private store;
|
|
5
|
+
constructor(store: MemoryStore);
|
|
6
|
+
recordSignal(signal: PersonalityAdaptation): Promise<void>;
|
|
7
|
+
getAdjustments(): Promise<PersonalityAdaptation[]>;
|
|
8
|
+
getPromptModifier(): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=personality-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personality-adapter.d.ts","sourceRoot":"","sources":["../src/personality-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,qBAAa,kBAAkB;IACjB,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,WAAW;IAEhC,YAAY,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuC1D,cAAc,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAgBlD,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;CAgB3C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class PersonalityAdapter {
|
|
2
|
+
store;
|
|
3
|
+
constructor(store) {
|
|
4
|
+
this.store = store;
|
|
5
|
+
}
|
|
6
|
+
async recordSignal(signal) {
|
|
7
|
+
const existing = await this.store.getByCategory('personality');
|
|
8
|
+
// Find existing adaptation for this trait
|
|
9
|
+
const match = existing.find(m => {
|
|
10
|
+
try {
|
|
11
|
+
const data = JSON.parse(m.content);
|
|
12
|
+
return data.trait === signal.trait;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
if (match) {
|
|
19
|
+
const current = JSON.parse(match.content);
|
|
20
|
+
// Accumulate signals: weighted average moving toward the new direction
|
|
21
|
+
const combined = {
|
|
22
|
+
trait: signal.trait,
|
|
23
|
+
adjustment: clamp(current.adjustment + signal.adjustment * 0.2, -1, 1),
|
|
24
|
+
reason: signal.reason,
|
|
25
|
+
signalCount: current.signalCount + 1,
|
|
26
|
+
};
|
|
27
|
+
await this.store.update(match.id, {
|
|
28
|
+
content: JSON.stringify(combined),
|
|
29
|
+
confidence: Math.min(0.5 + combined.signalCount * 0.05, 0.95),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
await this.store.add(JSON.stringify(signal), 'personality', 'observed', {
|
|
34
|
+
importance: 0.6,
|
|
35
|
+
confidence: 0.5,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async getAdjustments() {
|
|
40
|
+
const entries = await this.store.getByCategory('personality');
|
|
41
|
+
const results = [];
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
try {
|
|
44
|
+
const data = JSON.parse(entry.content);
|
|
45
|
+
results.push(data);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Skip malformed entries
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return results;
|
|
52
|
+
}
|
|
53
|
+
async getPromptModifier() {
|
|
54
|
+
const adjustments = await this.getAdjustments();
|
|
55
|
+
if (adjustments.length === 0)
|
|
56
|
+
return '';
|
|
57
|
+
const lines = adjustments
|
|
58
|
+
.filter(a => Math.abs(a.adjustment) > 0.1)
|
|
59
|
+
.map(a => {
|
|
60
|
+
const direction = a.adjustment > 0 ? 'Increase' : 'Decrease';
|
|
61
|
+
const magnitude = Math.abs(a.adjustment) > 0.5 ? 'significantly' : 'slightly';
|
|
62
|
+
return `- ${direction} ${a.trait} ${magnitude} (${a.reason})`;
|
|
63
|
+
});
|
|
64
|
+
if (lines.length === 0)
|
|
65
|
+
return '';
|
|
66
|
+
return `\n\n## Personality Adaptations (learned from interactions)\n${lines.join('\n')}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function clamp(value, min, max) {
|
|
70
|
+
return Math.max(min, Math.min(max, value));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=personality-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personality-adapter.js","sourceRoot":"","sources":["../src/personality-adapter.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,kBAAkB;IACT;IAApB,YAAoB,KAAkB;QAAlB,UAAK,GAAL,KAAK,CAAa;IAAG,CAAC;IAE1C,KAAK,CAAC,YAAY,CAAC,MAA6B;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE/D,0CAA0C;QAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YAC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,GAAW;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MemoryEntry } from './types.js';
|
|
2
|
+
export declare class MemoryRetriever {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve relevant memories for a user message.
|
|
5
|
+
* If accessiblePartitionIds is provided, only memories from those partitions are included.
|
|
6
|
+
* This ensures private memories are never leaked to other users.
|
|
7
|
+
*/
|
|
8
|
+
retrieve(memories: MemoryEntry[], userMessage: string, accessiblePartitionIds?: string[]): string;
|
|
9
|
+
private scoreMemory;
|
|
10
|
+
private boostRelatedMemories;
|
|
11
|
+
private buildSections;
|
|
12
|
+
private formatLine;
|
|
13
|
+
private extractQueryTags;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=retriever.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriever.d.ts","sourceRoot":"","sources":["../src/retriever.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AAuC9D,qBAAa,eAAe;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,sBAAsB,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM;IA0CjG,OAAO,CAAC,WAAW;IAmCnB,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,aAAa;IA6CrB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,gBAAgB;CAkBzB"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const TOKEN_BUDGET = 1000;
|
|
2
|
+
const CHARS_PER_TOKEN = 4;
|
|
3
|
+
const MAX_CHARS = TOKEN_BUDGET * CHARS_PER_TOKEN;
|
|
4
|
+
const MIN_SCORE = 0.1;
|
|
5
|
+
const SCORING_WEIGHTS = {
|
|
6
|
+
tagRelevance: 0.35,
|
|
7
|
+
importance: 0.25,
|
|
8
|
+
recency: 0.15,
|
|
9
|
+
access: 0.10,
|
|
10
|
+
confidence: 0.10,
|
|
11
|
+
relationship: 0.05,
|
|
12
|
+
};
|
|
13
|
+
const BUDGET_ALLOCATION = {
|
|
14
|
+
preference: 0.25,
|
|
15
|
+
fact: 0.25,
|
|
16
|
+
context: 0.15,
|
|
17
|
+
relationship: 0.15,
|
|
18
|
+
pattern: 0.10,
|
|
19
|
+
personality: 0.10,
|
|
20
|
+
};
|
|
21
|
+
const SECTION_HEADERS = {
|
|
22
|
+
fact: '### Key Facts',
|
|
23
|
+
preference: '### Preferences',
|
|
24
|
+
context: '### Context',
|
|
25
|
+
relationship: '### Your Relationship',
|
|
26
|
+
pattern: '### Communication Patterns',
|
|
27
|
+
personality: '### Personality Notes',
|
|
28
|
+
};
|
|
29
|
+
export class MemoryRetriever {
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve relevant memories for a user message.
|
|
32
|
+
* If accessiblePartitionIds is provided, only memories from those partitions are included.
|
|
33
|
+
* This ensures private memories are never leaked to other users.
|
|
34
|
+
*/
|
|
35
|
+
retrieve(memories, userMessage, accessiblePartitionIds) {
|
|
36
|
+
if (memories.length === 0)
|
|
37
|
+
return '';
|
|
38
|
+
// Filter by accessible partitions if specified
|
|
39
|
+
if (accessiblePartitionIds) {
|
|
40
|
+
const idSet = new Set(accessiblePartitionIds);
|
|
41
|
+
memories = memories.filter(m => idSet.has(m.partitionId ?? 'global'));
|
|
42
|
+
}
|
|
43
|
+
if (memories.length === 0)
|
|
44
|
+
return '';
|
|
45
|
+
const now = Date.now();
|
|
46
|
+
// Filter out expired memories
|
|
47
|
+
const active = memories.filter(m => m.expiresAt === undefined || m.expiresAt > now);
|
|
48
|
+
if (active.length === 0)
|
|
49
|
+
return '';
|
|
50
|
+
const queryTags = this.extractQueryTags(userMessage);
|
|
51
|
+
// Score each memory
|
|
52
|
+
const scored = active.map(m => ({
|
|
53
|
+
entry: m,
|
|
54
|
+
score: this.scoreMemory(m, queryTags, now),
|
|
55
|
+
}));
|
|
56
|
+
// Boost related memories
|
|
57
|
+
this.boostRelatedMemories(scored);
|
|
58
|
+
// Filter by minimum score
|
|
59
|
+
const relevant = scored
|
|
60
|
+
.filter(s => s.score >= MIN_SCORE)
|
|
61
|
+
.sort((a, b) => b.score - a.score);
|
|
62
|
+
if (relevant.length === 0)
|
|
63
|
+
return '';
|
|
64
|
+
// Group by category and allocate budget
|
|
65
|
+
const sections = this.buildSections(relevant);
|
|
66
|
+
if (sections.length === 0)
|
|
67
|
+
return '';
|
|
68
|
+
return `\n\n---\n\n## What you know about the user\n\n${sections.join('\n\n')}`;
|
|
69
|
+
}
|
|
70
|
+
scoreMemory(memory, queryTags, now) {
|
|
71
|
+
// 1. Tag relevance (0-1)
|
|
72
|
+
let tagScore = 0;
|
|
73
|
+
if (queryTags.length > 0 && memory.tags.length > 0) {
|
|
74
|
+
const overlap = memory.tags.filter(t => queryTags.includes(t)).length;
|
|
75
|
+
tagScore = overlap / Math.max(queryTags.length, 1);
|
|
76
|
+
}
|
|
77
|
+
// 2. Importance (0-1)
|
|
78
|
+
const importanceScore = memory.importance;
|
|
79
|
+
// 3. Recency (0-1) — decays over 30 days
|
|
80
|
+
const ageMs = now - memory.updatedAt;
|
|
81
|
+
const ageDays = ageMs / (1000 * 60 * 60 * 24);
|
|
82
|
+
const recencyScore = Math.max(0, 1 - ageDays / 30);
|
|
83
|
+
// 4. Access frequency (0-1)
|
|
84
|
+
const accessScore = Math.min(memory.accessCount / 10, 1);
|
|
85
|
+
// 5. Confidence (0-1)
|
|
86
|
+
const confidenceScore = memory.confidence;
|
|
87
|
+
// 6. Relationship bonus
|
|
88
|
+
const relationshipBonus = memory.category === 'relationship' ? 1 : 0;
|
|
89
|
+
return (tagScore * SCORING_WEIGHTS.tagRelevance +
|
|
90
|
+
importanceScore * SCORING_WEIGHTS.importance +
|
|
91
|
+
recencyScore * SCORING_WEIGHTS.recency +
|
|
92
|
+
accessScore * SCORING_WEIGHTS.access +
|
|
93
|
+
confidenceScore * SCORING_WEIGHTS.confidence +
|
|
94
|
+
relationshipBonus * SCORING_WEIGHTS.relationship);
|
|
95
|
+
}
|
|
96
|
+
boostRelatedMemories(scored) {
|
|
97
|
+
const byId = new Map(scored.map(s => [s.entry.id, s]));
|
|
98
|
+
for (const item of scored) {
|
|
99
|
+
if (item.score >= MIN_SCORE && item.entry.relatedMemories) {
|
|
100
|
+
for (const relatedId of item.entry.relatedMemories) {
|
|
101
|
+
const related = byId.get(relatedId);
|
|
102
|
+
if (related) {
|
|
103
|
+
related.score += item.score * 0.15;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
buildSections(scored) {
|
|
110
|
+
// Group by category
|
|
111
|
+
const groups = new Map();
|
|
112
|
+
for (const s of scored) {
|
|
113
|
+
const cat = s.entry.category;
|
|
114
|
+
if (!groups.has(cat))
|
|
115
|
+
groups.set(cat, []);
|
|
116
|
+
groups.get(cat).push(s);
|
|
117
|
+
}
|
|
118
|
+
const sections = [];
|
|
119
|
+
let totalChars = 0;
|
|
120
|
+
// Process categories in budget allocation order (highest allocation first)
|
|
121
|
+
const orderedCategories = Object.entries(BUDGET_ALLOCATION)
|
|
122
|
+
.sort(([, a], [, b]) => b - a)
|
|
123
|
+
.map(([cat]) => cat);
|
|
124
|
+
for (const category of orderedCategories) {
|
|
125
|
+
const items = groups.get(category);
|
|
126
|
+
if (!items || items.length === 0)
|
|
127
|
+
continue;
|
|
128
|
+
const budgetChars = MAX_CHARS * BUDGET_ALLOCATION[category];
|
|
129
|
+
const header = SECTION_HEADERS[category] ?? `### ${category}`;
|
|
130
|
+
const lines = [header];
|
|
131
|
+
let sectionChars = header.length;
|
|
132
|
+
for (const { entry } of items) {
|
|
133
|
+
const line = this.formatLine(entry);
|
|
134
|
+
if (sectionChars + line.length > budgetChars)
|
|
135
|
+
break;
|
|
136
|
+
if (totalChars + sectionChars + line.length > MAX_CHARS)
|
|
137
|
+
break;
|
|
138
|
+
lines.push(line);
|
|
139
|
+
sectionChars += line.length;
|
|
140
|
+
}
|
|
141
|
+
if (lines.length > 1) {
|
|
142
|
+
sections.push(lines.join('\n'));
|
|
143
|
+
totalChars += sectionChars;
|
|
144
|
+
}
|
|
145
|
+
if (totalChars >= MAX_CHARS)
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
return sections;
|
|
149
|
+
}
|
|
150
|
+
formatLine(entry) {
|
|
151
|
+
const meta = [];
|
|
152
|
+
if (entry.category === 'fact' && entry.confidence >= 0.8) {
|
|
153
|
+
meta.push('high confidence');
|
|
154
|
+
}
|
|
155
|
+
if (entry.category === 'relationship') {
|
|
156
|
+
// Try to extract relationship type from tags or just show category
|
|
157
|
+
}
|
|
158
|
+
const suffix = meta.length > 0 ? ` (${meta.join(', ')})` : '';
|
|
159
|
+
return `- ${entry.content}${suffix}`;
|
|
160
|
+
}
|
|
161
|
+
extractQueryTags(text) {
|
|
162
|
+
const stopWords = new Set([
|
|
163
|
+
'the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
164
|
+
'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
165
|
+
'should', 'may', 'might', 'can', 'shall', 'to', 'of', 'in', 'for',
|
|
166
|
+
'on', 'with', 'at', 'by', 'from', 'as', 'into', 'through', 'during',
|
|
167
|
+
'before', 'after', 'and', 'but', 'or', 'not', 'so', 'yet',
|
|
168
|
+
'i', 'me', 'my', 'we', 'you', 'your', 'he', 'she', 'they', 'it',
|
|
169
|
+
'what', 'which', 'who', 'when', 'where', 'how', 'that', 'this',
|
|
170
|
+
]);
|
|
171
|
+
return text
|
|
172
|
+
.toLowerCase()
|
|
173
|
+
.replace(/[^a-z0-9\s-]/g, '')
|
|
174
|
+
.split(/\s+/)
|
|
175
|
+
.filter(w => w.length > 2 && !stopWords.has(w))
|
|
176
|
+
.filter((w, i, arr) => arr.indexOf(w) === i);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=retriever.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriever.js","sourceRoot":"","sources":["../src/retriever.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,SAAS,GAAG,YAAY,GAAG,eAAe,CAAC;AACjD,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAM,eAAe,GAAG;IACtB,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACnB,CAAC;AAEF,MAAM,iBAAiB,GAAmC;IACxD,UAAU,EAAE,IAAI;IAChB,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,IAAI;CAClB,CAAC;AAEF,MAAM,eAAe,GAA2B;IAC9C,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,iBAAiB;IAC7B,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,uBAAuB;IACrC,OAAO,EAAE,4BAA4B;IACrC,WAAW,EAAE,uBAAuB;CACrC,CAAC;AAOF,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,QAAuB,EAAE,WAAmB,EAAE,sBAAiC;QACtF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAErC,+CAA+C;QAC/C,IAAI,sBAAsB,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAC9C,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