@psiclawops/hypermem 0.6.2 → 0.8.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/ARCHITECTURE.md +31 -39
- package/README.md +20 -14
- package/bin/hypermem-status.mjs +1 -1
- package/dist/background-indexer.d.ts +14 -3
- package/dist/background-indexer.d.ts.map +1 -1
- package/dist/background-indexer.js +135 -27
- package/dist/budget-policy.d.ts +22 -0
- package/dist/budget-policy.d.ts.map +1 -0
- package/dist/budget-policy.js +27 -0
- package/dist/cache.d.ts +11 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/compositor-utils.d.ts +31 -0
- package/dist/compositor-utils.d.ts.map +1 -0
- package/dist/compositor-utils.js +47 -0
- package/dist/compositor.d.ts +163 -1
- package/dist/compositor.d.ts.map +1 -1
- package/dist/compositor.js +862 -130
- package/dist/content-hash.d.ts +43 -0
- package/dist/content-hash.d.ts.map +1 -0
- package/dist/content-hash.js +75 -0
- package/dist/context-store.d.ts +54 -0
- package/dist/context-store.d.ts.map +1 -1
- package/dist/context-store.js +102 -0
- package/dist/contradiction-audit-store.d.ts +54 -0
- package/dist/contradiction-audit-store.d.ts.map +1 -0
- package/dist/contradiction-audit-store.js +88 -0
- package/dist/contradiction-detector.d.ts +78 -0
- package/dist/contradiction-detector.d.ts.map +1 -0
- package/dist/contradiction-detector.js +362 -0
- package/dist/contradiction-resolution-policy.d.ts +21 -0
- package/dist/contradiction-resolution-policy.d.ts.map +1 -0
- package/dist/contradiction-resolution-policy.js +17 -0
- package/dist/cross-agent.d.ts +1 -1
- package/dist/cross-agent.js +17 -17
- package/dist/degradation.d.ts +102 -0
- package/dist/degradation.d.ts.map +1 -0
- package/dist/degradation.js +141 -0
- package/dist/dreaming-promoter.d.ts +39 -1
- package/dist/dreaming-promoter.d.ts.map +1 -1
- package/dist/dreaming-promoter.js +70 -4
- package/dist/expertise-store.d.ts +129 -0
- package/dist/expertise-store.d.ts.map +1 -0
- package/dist/expertise-store.js +342 -0
- package/dist/fact-store.d.ts +15 -0
- package/dist/fact-store.d.ts.map +1 -1
- package/dist/fact-store.js +52 -5
- package/dist/index.d.ts +74 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +407 -29
- package/dist/knowledge-lint.d.ts +2 -0
- package/dist/knowledge-lint.d.ts.map +1 -1
- package/dist/knowledge-lint.js +40 -1
- package/dist/library-schema.d.ts +7 -2
- package/dist/library-schema.d.ts.map +1 -1
- package/dist/library-schema.js +307 -2
- package/dist/message-store.d.ts +64 -1
- package/dist/message-store.d.ts.map +1 -1
- package/dist/message-store.js +137 -1
- package/dist/proactive-pass.d.ts +2 -2
- package/dist/proactive-pass.d.ts.map +1 -1
- package/dist/proactive-pass.js +66 -12
- package/dist/replay-recovery.d.ts +29 -0
- package/dist/replay-recovery.d.ts.map +1 -0
- package/dist/replay-recovery.js +82 -0
- package/dist/reranker.d.ts +95 -0
- package/dist/reranker.d.ts.map +1 -0
- package/dist/reranker.js +308 -0
- package/dist/schema.d.ts +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +46 -1
- package/dist/seed.d.ts +1 -1
- package/dist/seed.js +1 -1
- package/dist/session-flusher.d.ts +4 -4
- package/dist/session-flusher.d.ts.map +1 -1
- package/dist/session-flusher.js +3 -3
- package/dist/spawn-context.d.ts +1 -1
- package/dist/spawn-context.js +1 -1
- package/dist/temporal-store.d.ts +1 -0
- package/dist/temporal-store.d.ts.map +1 -1
- package/dist/tool-artifact-store.d.ts +98 -0
- package/dist/tool-artifact-store.d.ts.map +1 -0
- package/dist/tool-artifact-store.js +244 -0
- package/dist/topic-detector.js +2 -2
- package/dist/topic-store.d.ts +6 -0
- package/dist/topic-store.d.ts.map +1 -1
- package/dist/topic-store.js +39 -0
- package/dist/topic-synthesizer.js +1 -1
- package/dist/trigger-registry.d.ts +1 -1
- package/dist/trigger-registry.js +4 -4
- package/dist/types.d.ts +239 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-store.d.ts +2 -1
- package/dist/vector-store.d.ts.map +1 -1
- package/dist/vector-store.js +3 -0
- package/dist/version.d.ts +10 -10
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +10 -10
- package/package.json +6 -4
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hypermem Expertise Store
|
|
3
|
+
*
|
|
4
|
+
* Stores domain expertise patterns — learned behaviors that make the Nth run
|
|
5
|
+
* better than the 1st. Two-phase lifecycle:
|
|
6
|
+
* 1. Observations: raw learnings logged from conversations, pipelines, reviews
|
|
7
|
+
* 2. Patterns: graduated observations with N≥3 confirming instances
|
|
8
|
+
*
|
|
9
|
+
* Patterns are agent-scoped but domain-tagged, enabling cross-agent queries.
|
|
10
|
+
* Patterns have confidence, frequency tracking, and decay on counter-evidence.
|
|
11
|
+
*/
|
|
12
|
+
function nowIso() {
|
|
13
|
+
return new Date().toISOString();
|
|
14
|
+
}
|
|
15
|
+
function parseObservationRow(row) {
|
|
16
|
+
return {
|
|
17
|
+
id: row.id,
|
|
18
|
+
agentId: row.agent_id,
|
|
19
|
+
domain: row.domain,
|
|
20
|
+
context: row.context || null,
|
|
21
|
+
observationText: row.observation_text,
|
|
22
|
+
sourceType: row.source_type,
|
|
23
|
+
sourceRef: row.source_ref || null,
|
|
24
|
+
createdAt: row.created_at,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function parsePatternRow(row) {
|
|
28
|
+
return {
|
|
29
|
+
id: row.id,
|
|
30
|
+
agentId: row.agent_id,
|
|
31
|
+
domain: row.domain,
|
|
32
|
+
patternText: row.pattern_text,
|
|
33
|
+
confidence: row.confidence,
|
|
34
|
+
frequency: row.frequency,
|
|
35
|
+
firstSeen: row.first_seen,
|
|
36
|
+
lastConfirmed: row.last_confirmed,
|
|
37
|
+
invalidatedAt: row.invalidated_at || null,
|
|
38
|
+
invalidationReason: row.invalidation_reason || null,
|
|
39
|
+
decayScore: row.decay_score,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// ── Graduation threshold ──
|
|
43
|
+
const DEFAULT_GRADUATION_THRESHOLD = 3;
|
|
44
|
+
export class ExpertiseStore {
|
|
45
|
+
db;
|
|
46
|
+
graduationThreshold;
|
|
47
|
+
constructor(db, graduationThreshold = DEFAULT_GRADUATION_THRESHOLD) {
|
|
48
|
+
this.db = db;
|
|
49
|
+
this.graduationThreshold = graduationThreshold;
|
|
50
|
+
}
|
|
51
|
+
// ── Observations ──
|
|
52
|
+
/**
|
|
53
|
+
* Record a raw observation from any source.
|
|
54
|
+
*/
|
|
55
|
+
record(agentId, observationText, domain, opts) {
|
|
56
|
+
const now = nowIso();
|
|
57
|
+
const result = this.db.prepare(`
|
|
58
|
+
INSERT INTO expertise_observations
|
|
59
|
+
(agent_id, domain, context, observation_text, source_type, source_ref, created_at)
|
|
60
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
61
|
+
`).run(agentId, domain, opts?.context || null, observationText, opts?.sourceType || 'conversation', opts?.sourceRef || null, now);
|
|
62
|
+
const id = Number(result.lastInsertRowid);
|
|
63
|
+
return {
|
|
64
|
+
id,
|
|
65
|
+
agentId,
|
|
66
|
+
domain,
|
|
67
|
+
context: opts?.context || null,
|
|
68
|
+
observationText,
|
|
69
|
+
sourceType: opts?.sourceType || 'conversation',
|
|
70
|
+
sourceRef: opts?.sourceRef || null,
|
|
71
|
+
createdAt: now,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get observations for an agent, optionally filtered by domain.
|
|
76
|
+
*/
|
|
77
|
+
getObservations(agentId, opts) {
|
|
78
|
+
let sql = 'SELECT * FROM expertise_observations WHERE agent_id = ?';
|
|
79
|
+
const params = [agentId];
|
|
80
|
+
if (opts?.domain) {
|
|
81
|
+
sql += ' AND domain = ?';
|
|
82
|
+
params.push(opts.domain);
|
|
83
|
+
}
|
|
84
|
+
sql += ' ORDER BY created_at DESC';
|
|
85
|
+
if (opts?.limit) {
|
|
86
|
+
sql += ' LIMIT ?';
|
|
87
|
+
params.push(opts.limit);
|
|
88
|
+
}
|
|
89
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
90
|
+
return rows.map(parseObservationRow);
|
|
91
|
+
}
|
|
92
|
+
// ── Patterns ──
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve active expertise patterns for current work context.
|
|
95
|
+
* Returns patterns sorted by confidence DESC, frequency DESC.
|
|
96
|
+
* Excludes invalidated patterns by default.
|
|
97
|
+
*/
|
|
98
|
+
query(agentId, domain, opts) {
|
|
99
|
+
let sql = `
|
|
100
|
+
SELECT * FROM expertise_patterns
|
|
101
|
+
WHERE agent_id = ? AND domain = ?
|
|
102
|
+
AND decay_score < 0.8
|
|
103
|
+
`;
|
|
104
|
+
const params = [agentId, domain];
|
|
105
|
+
if (!opts?.includeInvalidated) {
|
|
106
|
+
sql += ' AND invalidated_at IS NULL';
|
|
107
|
+
}
|
|
108
|
+
if (opts?.minConfidence) {
|
|
109
|
+
sql += ' AND confidence >= ?';
|
|
110
|
+
params.push(opts.minConfidence);
|
|
111
|
+
}
|
|
112
|
+
sql += ' ORDER BY confidence DESC, frequency DESC';
|
|
113
|
+
if (opts?.limit) {
|
|
114
|
+
sql += ' LIMIT ?';
|
|
115
|
+
params.push(opts.limit);
|
|
116
|
+
}
|
|
117
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
118
|
+
return rows.map(parsePatternRow);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Cross-agent query: get patterns from any agent in a given domain.
|
|
122
|
+
* Useful for fleet-wide expertise ("what has any agent learned about X?").
|
|
123
|
+
*/
|
|
124
|
+
queryFleet(domain, opts) {
|
|
125
|
+
let sql = `
|
|
126
|
+
SELECT * FROM expertise_patterns
|
|
127
|
+
WHERE domain = ?
|
|
128
|
+
AND invalidated_at IS NULL
|
|
129
|
+
AND decay_score < 0.8
|
|
130
|
+
`;
|
|
131
|
+
const params = [domain];
|
|
132
|
+
if (opts?.minConfidence) {
|
|
133
|
+
sql += ' AND confidence >= ?';
|
|
134
|
+
params.push(opts.minConfidence);
|
|
135
|
+
}
|
|
136
|
+
sql += ' ORDER BY confidence DESC, frequency DESC';
|
|
137
|
+
if (opts?.limit) {
|
|
138
|
+
sql += ' LIMIT ?';
|
|
139
|
+
params.push(opts.limit);
|
|
140
|
+
}
|
|
141
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
142
|
+
return rows.map(parsePatternRow);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Graduate an observation to a pattern.
|
|
146
|
+
*
|
|
147
|
+
* If a similar pattern already exists (same agent, domain, and pattern text prefix match),
|
|
148
|
+
* increments its frequency and updates lastConfirmed instead of creating a duplicate.
|
|
149
|
+
*
|
|
150
|
+
* Auto-graduation happens when an observation has N≥graduationThreshold confirming
|
|
151
|
+
* evidence links. Can also be called manually.
|
|
152
|
+
*/
|
|
153
|
+
graduate(agentId, observationId, opts) {
|
|
154
|
+
// Get the observation
|
|
155
|
+
const obsRow = this.db.prepare('SELECT * FROM expertise_observations WHERE id = ? AND agent_id = ?').get(observationId, agentId);
|
|
156
|
+
if (!obsRow)
|
|
157
|
+
return null;
|
|
158
|
+
const obs = parseObservationRow(obsRow);
|
|
159
|
+
const patternText = opts?.patternText || obs.observationText;
|
|
160
|
+
const confidence = opts?.confidence || 0.7;
|
|
161
|
+
const now = nowIso();
|
|
162
|
+
// Check for existing similar pattern (same domain, prefix match)
|
|
163
|
+
const prefix = patternText.slice(0, 80);
|
|
164
|
+
const existing = this.db.prepare(`
|
|
165
|
+
SELECT * FROM expertise_patterns
|
|
166
|
+
WHERE agent_id = ? AND domain = ? AND pattern_text LIKE ?
|
|
167
|
+
AND invalidated_at IS NULL
|
|
168
|
+
LIMIT 1
|
|
169
|
+
`).get(agentId, obs.domain, `${prefix}%`);
|
|
170
|
+
if (existing) {
|
|
171
|
+
// Increment frequency and update
|
|
172
|
+
this.db.prepare(`
|
|
173
|
+
UPDATE expertise_patterns
|
|
174
|
+
SET frequency = frequency + 1,
|
|
175
|
+
confidence = MAX(confidence, ?),
|
|
176
|
+
last_confirmed = ?,
|
|
177
|
+
decay_score = MAX(decay_score - 0.1, 0)
|
|
178
|
+
WHERE id = ?
|
|
179
|
+
`).run(confidence, now, existing.id);
|
|
180
|
+
// Link evidence
|
|
181
|
+
this.db.prepare(`
|
|
182
|
+
INSERT INTO expertise_evidence (observation_id, pattern_id, relationship, created_at)
|
|
183
|
+
VALUES (?, ?, 'confirms', ?)
|
|
184
|
+
`).run(observationId, existing.id, now);
|
|
185
|
+
// Return updated pattern
|
|
186
|
+
const updated = this.db.prepare('SELECT * FROM expertise_patterns WHERE id = ?')
|
|
187
|
+
.get(existing.id);
|
|
188
|
+
return parsePatternRow(updated);
|
|
189
|
+
}
|
|
190
|
+
// Create new pattern
|
|
191
|
+
const result = this.db.prepare(`
|
|
192
|
+
INSERT INTO expertise_patterns
|
|
193
|
+
(agent_id, domain, pattern_text, confidence, frequency, first_seen, last_confirmed, decay_score)
|
|
194
|
+
VALUES (?, ?, ?, ?, 1, ?, ?, 0.0)
|
|
195
|
+
`).run(agentId, obs.domain, patternText, confidence, now, now);
|
|
196
|
+
const patternId = Number(result.lastInsertRowid);
|
|
197
|
+
// Link the graduating observation as evidence
|
|
198
|
+
this.db.prepare(`
|
|
199
|
+
INSERT INTO expertise_evidence (observation_id, pattern_id, relationship, created_at)
|
|
200
|
+
VALUES (?, ?, 'confirms', ?)
|
|
201
|
+
`).run(observationId, patternId, now);
|
|
202
|
+
return {
|
|
203
|
+
id: patternId,
|
|
204
|
+
agentId,
|
|
205
|
+
domain: obs.domain,
|
|
206
|
+
patternText,
|
|
207
|
+
confidence,
|
|
208
|
+
frequency: 1,
|
|
209
|
+
firstSeen: now,
|
|
210
|
+
lastConfirmed: now,
|
|
211
|
+
invalidatedAt: null,
|
|
212
|
+
invalidationReason: null,
|
|
213
|
+
decayScore: 0,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Record evidence linking an observation to a pattern.
|
|
218
|
+
* If this pushes a pattern's contradicting evidence past threshold,
|
|
219
|
+
* auto-invalidates the pattern.
|
|
220
|
+
*/
|
|
221
|
+
addEvidence(observationId, patternId, relationship) {
|
|
222
|
+
const now = nowIso();
|
|
223
|
+
this.db.prepare(`
|
|
224
|
+
INSERT INTO expertise_evidence (observation_id, pattern_id, relationship, created_at)
|
|
225
|
+
VALUES (?, ?, ?, ?)
|
|
226
|
+
`).run(observationId, patternId, relationship, now);
|
|
227
|
+
if (relationship === 'confirms') {
|
|
228
|
+
// Boost the pattern
|
|
229
|
+
this.db.prepare(`
|
|
230
|
+
UPDATE expertise_patterns
|
|
231
|
+
SET frequency = frequency + 1,
|
|
232
|
+
last_confirmed = ?,
|
|
233
|
+
decay_score = MAX(decay_score - 0.05, 0)
|
|
234
|
+
WHERE id = ?
|
|
235
|
+
`).run(now, patternId);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
// Contradicting: increase decay, check if should invalidate
|
|
239
|
+
this.db.prepare(`
|
|
240
|
+
UPDATE expertise_patterns
|
|
241
|
+
SET decay_score = MIN(decay_score + 0.2, 1.0)
|
|
242
|
+
WHERE id = ?
|
|
243
|
+
`).run(patternId);
|
|
244
|
+
// Count contradictions vs confirmations
|
|
245
|
+
const counts = this.db.prepare(`
|
|
246
|
+
SELECT relationship, COUNT(*) as cnt
|
|
247
|
+
FROM expertise_evidence
|
|
248
|
+
WHERE pattern_id = ?
|
|
249
|
+
GROUP BY relationship
|
|
250
|
+
`).all(patternId);
|
|
251
|
+
const confirms = counts.find(c => c.relationship === 'confirms')?.cnt ?? 0;
|
|
252
|
+
const contradicts = counts.find(c => c.relationship === 'contradicts')?.cnt ?? 0;
|
|
253
|
+
// Auto-invalidate if contradictions exceed confirmations
|
|
254
|
+
if (contradicts > confirms) {
|
|
255
|
+
this.invalidate(patternId, 'auto: contradicting evidence exceeded confirmations');
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Check if any observations are ready for auto-graduation.
|
|
261
|
+
* An observation graduates when it has N≥threshold confirming evidence links.
|
|
262
|
+
* Returns the number of newly graduated patterns.
|
|
263
|
+
*/
|
|
264
|
+
autoGraduate(agentId) {
|
|
265
|
+
// Find observations with enough confirming evidence that aren't already patterns
|
|
266
|
+
const candidates = this.db.prepare(`
|
|
267
|
+
SELECT e.observation_id, COUNT(*) as confirm_count
|
|
268
|
+
FROM expertise_evidence e
|
|
269
|
+
JOIN expertise_observations o ON o.id = e.observation_id
|
|
270
|
+
WHERE o.agent_id = ?
|
|
271
|
+
AND e.relationship = 'confirms'
|
|
272
|
+
AND e.observation_id NOT IN (
|
|
273
|
+
SELECT DISTINCT e2.observation_id FROM expertise_evidence e2
|
|
274
|
+
JOIN expertise_patterns p ON p.id = e2.pattern_id
|
|
275
|
+
WHERE p.agent_id = ?
|
|
276
|
+
)
|
|
277
|
+
GROUP BY e.observation_id
|
|
278
|
+
HAVING COUNT(*) >= ?
|
|
279
|
+
`).all(agentId, agentId, this.graduationThreshold);
|
|
280
|
+
let graduated = 0;
|
|
281
|
+
for (const candidate of candidates) {
|
|
282
|
+
const result = this.graduate(agentId, candidate.observation_id);
|
|
283
|
+
if (result)
|
|
284
|
+
graduated++;
|
|
285
|
+
}
|
|
286
|
+
return graduated;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Mark a pattern as invalidated.
|
|
290
|
+
*/
|
|
291
|
+
invalidate(patternId, reason) {
|
|
292
|
+
const now = nowIso();
|
|
293
|
+
const result = this.db.prepare(`
|
|
294
|
+
UPDATE expertise_patterns
|
|
295
|
+
SET invalidated_at = ?, invalidation_reason = ?, updated_at = ?
|
|
296
|
+
WHERE id = ? AND invalidated_at IS NULL
|
|
297
|
+
`).run(now, reason, now, patternId);
|
|
298
|
+
return result.changes > 0;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* List all active patterns for an agent, optionally filtered by domain.
|
|
302
|
+
*/
|
|
303
|
+
list(agentId, opts) {
|
|
304
|
+
let sql = 'SELECT * FROM expertise_patterns WHERE agent_id = ?';
|
|
305
|
+
const params = [agentId];
|
|
306
|
+
if (opts?.domain) {
|
|
307
|
+
sql += ' AND domain = ?';
|
|
308
|
+
params.push(opts.domain);
|
|
309
|
+
}
|
|
310
|
+
if (!opts?.includeInvalidated) {
|
|
311
|
+
sql += ' AND invalidated_at IS NULL';
|
|
312
|
+
}
|
|
313
|
+
sql += ' ORDER BY confidence DESC, frequency DESC';
|
|
314
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
315
|
+
return rows.map(parsePatternRow);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Decay all patterns by a fixed rate. Similar to fact decay.
|
|
319
|
+
*/
|
|
320
|
+
decayPatterns(agentId, decayRate = 0.005) {
|
|
321
|
+
const result = this.db.prepare(`
|
|
322
|
+
UPDATE expertise_patterns
|
|
323
|
+
SET decay_score = MIN(decay_score + ?, 1.0)
|
|
324
|
+
WHERE agent_id = ? AND decay_score < 1.0 AND invalidated_at IS NULL
|
|
325
|
+
`).run(decayRate, agentId);
|
|
326
|
+
return result.changes;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get pattern and observation counts for an agent.
|
|
330
|
+
*/
|
|
331
|
+
getStats(agentId) {
|
|
332
|
+
const obs = this.db.prepare('SELECT COUNT(*) as count FROM expertise_observations WHERE agent_id = ?').get(agentId);
|
|
333
|
+
const active = this.db.prepare('SELECT COUNT(*) as count FROM expertise_patterns WHERE agent_id = ? AND invalidated_at IS NULL').get(agentId);
|
|
334
|
+
const invalidated = this.db.prepare('SELECT COUNT(*) as count FROM expertise_patterns WHERE agent_id = ? AND invalidated_at IS NOT NULL').get(agentId);
|
|
335
|
+
return {
|
|
336
|
+
observations: obs.count,
|
|
337
|
+
activePatterns: active.count,
|
|
338
|
+
invalidatedPatterns: invalidated.count,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=expertise-store.js.map
|
package/dist/fact-store.d.ts
CHANGED
|
@@ -71,5 +71,20 @@ export declare class FactStore {
|
|
|
71
71
|
* Get fact count for an agent.
|
|
72
72
|
*/
|
|
73
73
|
getFactCount(agentId: string): number;
|
|
74
|
+
/**
|
|
75
|
+
* Get facts that were valid at a specific point in time.
|
|
76
|
+
* Returns facts where valid_from <= dateMs AND (invalid_at IS NULL OR invalid_at > dateMs).
|
|
77
|
+
* This enables "what was true on date X?" queries (Zep-competitive).
|
|
78
|
+
*/
|
|
79
|
+
getFactsValidAt(agentId: string, dateMs: number, opts?: {
|
|
80
|
+
domain?: string;
|
|
81
|
+
limit?: number;
|
|
82
|
+
}): Fact[];
|
|
83
|
+
/**
|
|
84
|
+
* Mark a fact as invalid at a specific time (or now).
|
|
85
|
+
* Unlike supersede, this doesn't require a replacement fact.
|
|
86
|
+
* Used by contradiction detection to mark stale facts.
|
|
87
|
+
*/
|
|
88
|
+
invalidateFact(factId: number, atDate?: string): boolean;
|
|
74
89
|
}
|
|
75
90
|
//# sourceMappingURL=fact-store.d.ts.map
|
package/dist/fact-store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fact-store.d.ts","sourceRoot":"","sources":["../src/fact-store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"fact-store.d.ts","sourceRoot":"","sources":["../src/fact-store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA6BlD,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,YAAY;IAE7C;;OAEG;IACH,OAAO,CACL,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,SAAS,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,IAAI;IA+EP;;OAEG;IACH,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,SAAS,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GACA,IAAI,EAAE;IAkCT;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,EAAE;IAoCV;;;;;;OAMG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAY7D;;;;;;OAMG;IACH,yBAAyB,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACzB,MAAM,GAAG,IAAI;IA0BhB;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,GAAG,MAAM;IAU7D;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAanC;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAOrC;;;;OAIG;IACH,eAAe,CACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,EAAE;IA4BT;;;;OAIG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;CAUzD"}
|
package/dist/fact-store.js
CHANGED
|
@@ -26,6 +26,8 @@ function parseFactRow(row) {
|
|
|
26
26
|
expiresAt: row.expires_at || null,
|
|
27
27
|
supersededBy: row.superseded_by || null,
|
|
28
28
|
decayScore: row.decay_score,
|
|
29
|
+
validFrom: row.valid_from || null,
|
|
30
|
+
invalidAt: row.invalid_at || null,
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
export class FactStore {
|
|
@@ -66,9 +68,9 @@ export class FactStore {
|
|
|
66
68
|
const result = this.db.prepare(`
|
|
67
69
|
INSERT INTO facts (agent_id, scope, domain, content, confidence,
|
|
68
70
|
visibility, source_type, source_session_key, source_ref,
|
|
69
|
-
created_at, updated_at, expires_at, decay_score)
|
|
70
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0.0)
|
|
71
|
-
`).run(agentId, scope, opts?.domain || null, content, opts?.confidence || 1.0, resolvedVisibility, opts?.sourceType || 'conversation', opts?.sourceSessionKey || null, opts?.sourceRef || null, now, now, opts?.expiresAt || null);
|
|
71
|
+
created_at, updated_at, expires_at, decay_score, valid_from)
|
|
72
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0.0, ?)
|
|
73
|
+
`).run(agentId, scope, opts?.domain || null, content, opts?.confidence || 1.0, resolvedVisibility, opts?.sourceType || 'conversation', opts?.sourceSessionKey || null, opts?.sourceRef || null, now, now, opts?.expiresAt || null, now);
|
|
72
74
|
const id = Number(result.lastInsertRowid);
|
|
73
75
|
return {
|
|
74
76
|
id,
|
|
@@ -86,6 +88,8 @@ export class FactStore {
|
|
|
86
88
|
expiresAt: opts?.expiresAt || null,
|
|
87
89
|
supersededBy: null,
|
|
88
90
|
decayScore: 0,
|
|
91
|
+
validFrom: now,
|
|
92
|
+
invalidAt: null,
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
95
|
/**
|
|
@@ -166,10 +170,10 @@ export class FactStore {
|
|
|
166
170
|
const result = this.db
|
|
167
171
|
.prepare(`
|
|
168
172
|
UPDATE facts
|
|
169
|
-
SET superseded_by = ?, updated_at = ?
|
|
173
|
+
SET superseded_by = ?, invalid_at = ?, updated_at = ?
|
|
170
174
|
WHERE id = ? AND superseded_by IS NULL
|
|
171
175
|
`)
|
|
172
|
-
.run(newFactId, now, oldFactId);
|
|
176
|
+
.run(newFactId, now, now, oldFactId);
|
|
173
177
|
return result.changes > 0;
|
|
174
178
|
}
|
|
175
179
|
/**
|
|
@@ -232,5 +236,48 @@ export class FactStore {
|
|
|
232
236
|
const row = this.db.prepare('SELECT COUNT(*) AS count FROM facts WHERE agent_id = ?').get(agentId);
|
|
233
237
|
return row.count;
|
|
234
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Get facts that were valid at a specific point in time.
|
|
241
|
+
* Returns facts where valid_from <= dateMs AND (invalid_at IS NULL OR invalid_at > dateMs).
|
|
242
|
+
* This enables "what was true on date X?" queries (Zep-competitive).
|
|
243
|
+
*/
|
|
244
|
+
getFactsValidAt(agentId, dateMs, opts) {
|
|
245
|
+
const dateIso = new Date(dateMs).toISOString();
|
|
246
|
+
let sql = `
|
|
247
|
+
SELECT * FROM facts
|
|
248
|
+
WHERE agent_id = ?
|
|
249
|
+
AND (valid_from IS NULL OR valid_from <= ?)
|
|
250
|
+
AND (invalid_at IS NULL OR invalid_at > ?)
|
|
251
|
+
AND superseded_by IS NULL
|
|
252
|
+
AND decay_score < 0.8
|
|
253
|
+
`;
|
|
254
|
+
const params = [agentId, dateIso, dateIso];
|
|
255
|
+
if (opts?.domain) {
|
|
256
|
+
sql += ' AND domain = ?';
|
|
257
|
+
params.push(opts.domain);
|
|
258
|
+
}
|
|
259
|
+
sql += ' ORDER BY confidence DESC, decay_score ASC';
|
|
260
|
+
if (opts?.limit) {
|
|
261
|
+
sql += ' LIMIT ?';
|
|
262
|
+
params.push(opts.limit);
|
|
263
|
+
}
|
|
264
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
265
|
+
return rows.map(parseFactRow);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Mark a fact as invalid at a specific time (or now).
|
|
269
|
+
* Unlike supersede, this doesn't require a replacement fact.
|
|
270
|
+
* Used by contradiction detection to mark stale facts.
|
|
271
|
+
*/
|
|
272
|
+
invalidateFact(factId, atDate) {
|
|
273
|
+
const invalidAt = atDate || new Date().toISOString();
|
|
274
|
+
const result = this.db
|
|
275
|
+
.prepare(`
|
|
276
|
+
UPDATE facts SET invalid_at = ?, updated_at = ?
|
|
277
|
+
WHERE id = ? AND invalid_at IS NULL
|
|
278
|
+
`)
|
|
279
|
+
.run(invalidAt, invalidAt, factId);
|
|
280
|
+
return result.changes > 0;
|
|
281
|
+
}
|
|
235
282
|
}
|
|
236
283
|
//# sourceMappingURL=fact-store.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module @psiclawops/hypermem
|
|
5
5
|
*
|
|
6
6
|
* Architecture:
|
|
7
|
-
* L1:
|
|
7
|
+
* L1: CacheLayer — SQLite `:memory:` hot session working memory
|
|
8
8
|
* L2: messages.db — per-agent conversation log (rotatable)
|
|
9
9
|
* L3: vectors.db — per-agent semantic search index (reconstructable)
|
|
10
10
|
* L4: library.db — fleet-wide structured knowledge (crown jewel)
|
|
@@ -13,6 +13,8 @@ export { ENGINE_VERSION, MIN_NODE_VERSION, MIN_REDIS_VERSION, SQLITE_VEC_VERSION
|
|
|
13
13
|
export { DatabaseManager } from './db.js';
|
|
14
14
|
export type { DatabaseManagerConfig } from './db.js';
|
|
15
15
|
export { MessageStore } from './message-store.js';
|
|
16
|
+
export { ToolArtifactStore } from './tool-artifact-store.js';
|
|
17
|
+
export type { ToolArtifactRecord, PutToolArtifactInput } from './tool-artifact-store.js';
|
|
16
18
|
export { FactStore } from './fact-store.js';
|
|
17
19
|
export { KnowledgeStore } from './knowledge-store.js';
|
|
18
20
|
export type { LinkType } from './knowledge-store.js';
|
|
@@ -25,10 +27,12 @@ export type { FleetAgent, FleetOrg, AgentCapability } from './fleet-store.js';
|
|
|
25
27
|
export { SystemStore } from './system-store.js';
|
|
26
28
|
export type { SystemState, SystemEvent } from './system-store.js';
|
|
27
29
|
export { WorkStore } from './work-store.js';
|
|
28
|
-
export { ensureContextSchema, getActiveContext, getOrCreateActiveContext, updateContextHead, archiveContext, rotateSessionContext } from './context-store.js';
|
|
30
|
+
export { ensureContextSchema, getActiveContext, getOrCreateActiveContext, updateContextHead, archiveContext, rotateSessionContext, getContextById, getArchivedContexts, getArchivedContext, getContextLineage, getForkChildren } from './context-store.js';
|
|
29
31
|
export type { Context } from './context-store.js';
|
|
30
32
|
export type { WorkItem, WorkEvent, WorkStatus } from './work-store.js';
|
|
31
33
|
export { DesiredStateStore } from './desired-state-store.js';
|
|
34
|
+
export { ExpertiseStore } from './expertise-store.js';
|
|
35
|
+
export type { ExpertiseObservation, ExpertisePattern, ExpertiseEvidence } from './expertise-store.js';
|
|
32
36
|
export { evictStaleContent, DEFAULT_EVICTION_CONFIG } from './image-eviction.js';
|
|
33
37
|
export type { ImageEvictionConfig, EvictionStats, EvictionResult } from './image-eviction.js';
|
|
34
38
|
export { KnowledgeGraph } from './knowledge-graph.js';
|
|
@@ -38,7 +42,12 @@ export type { RateLimiterConfig, Priority } from './rate-limiter.js';
|
|
|
38
42
|
export type { DesiredStateEntry, ConfigEvent, DriftStatus } from './desired-state-store.js';
|
|
39
43
|
export type { ModelState } from './cache.js';
|
|
40
44
|
export { CacheLayer } from './cache.js';
|
|
41
|
-
export {
|
|
45
|
+
export { TRIM_SOFT_TARGET, TRIM_GROWTH_THRESHOLD, TRIM_HEADROOM_FRACTION, TRIM_BUDGET_POLICY, resolveTrimBudgets, } from './budget-policy.js';
|
|
46
|
+
export { DEGRADATION_REASONS, DEGRADATION_LIMITS, isDegradationReason, isReplayState, formatToolChainStub, parseToolChainStub, isToolChainStub, formatArtifactRef, parseArtifactRef, isArtifactRef, formatReplayMarker, parseReplayMarker, isReplayMarker, isDegradedContent, } from './degradation.js';
|
|
47
|
+
export type { DegradationReason, ToolChainStub, ArtifactRef, ReplayMarker, ReplayState, DegradationEvent, } from './degradation.js';
|
|
48
|
+
export { REPLAY_RECOVERY_POLICY, decideReplayRecovery, isColdRedisReplay, isReplayRecovered, } from './replay-recovery.js';
|
|
49
|
+
export type { ReplayRecoveryInputs, ReplayRecoveryDecision } from './replay-recovery.js';
|
|
50
|
+
export { Compositor, type CompositorDeps, applyToolGradientToWindow, canPersistReshapedHistory, OPENCLAW_BOOTSTRAP_FILES, resolveToolChainEjections, type ToolChainEjectionResult } from './compositor.js';
|
|
42
51
|
export { type CollectionTrigger, TRIGGER_REGISTRY, TRIGGER_REGISTRY_VERSION, TRIGGER_REGISTRY_HASH, DEFAULT_TRIGGERS, matchTriggers, } from './trigger-registry.js';
|
|
43
52
|
export { ensureCompactionFenceSchema, updateCompactionFence, getCompactionFence, getCompactionEligibility, getCompactableMessages, } from './compaction-fence.js';
|
|
44
53
|
export type { CompactionFence, CompactionEligibility } from './compaction-fence.js';
|
|
@@ -51,6 +60,8 @@ export { VectorStore, generateEmbeddings } from './vector-store.js';
|
|
|
51
60
|
export type { EmbeddingConfig, VectorSearchResult, VectorIndexStats } from './vector-store.js';
|
|
52
61
|
export { hybridSearch, buildFtsQuery } from './hybrid-retrieval.js';
|
|
53
62
|
export type { HybridSearchResult, HybridSearchOptions } from './hybrid-retrieval.js';
|
|
63
|
+
export { ContradictionDetector } from './contradiction-detector.js';
|
|
64
|
+
export type { ContradictionCandidate, ContradictionResult, ContradictionDetectorConfig } from './contradiction-detector.js';
|
|
54
65
|
export { DocChunkStore } from './doc-chunk-store.js';
|
|
55
66
|
export type { DocChunkRow, ChunkQuery, IndexResult as DocIndexResult } from './doc-chunk-store.js';
|
|
56
67
|
export { WorkspaceSeeder, seedWorkspace } from './seed.js';
|
|
@@ -71,7 +82,7 @@ export type { LintResult } from './knowledge-lint.js';
|
|
|
71
82
|
export { buildSpawnContext } from './spawn-context.js';
|
|
72
83
|
export type { SpawnContextOptions, SpawnContext } from './spawn-context.js';
|
|
73
84
|
export { runNoiseSweep, runToolDecay, type NoiseSweepResult, type ToolDecayResult } from './proactive-pass.js';
|
|
74
|
-
export type { NeutralMessage, NeutralToolCall, NeutralToolResult, StoredMessage, MessageRole, ProviderMessage, Conversation, Fact, Topic, Knowledge, Episode, ComposeRequest, ComposeResult, ComposeDiagnostics, SlotTokenCounts, SessionSlots, SessionMeta, HyperMemConfig, RedisConfig, CompositorConfig, IndexerConfig, ChannelType, ConversationStatus, FactScope, TopicStatus, EpisodeType, MemoryVisibility, CrossAgentQuery, AgentIdentity, SessionCursor, RecentTurn, } from './types.js';
|
|
85
|
+
export type { NeutralMessage, NeutralToolCall, NeutralToolResult, StoredMessage, MessageRole, ProviderMessage, Conversation, Fact, Topic, Knowledge, Episode, ComposeRequest, ComposeResult, ComposeDiagnostics, SlotTokenCounts, SessionSlots, SessionMeta, HyperMemConfig, RedisConfig, CompositorConfig, IndexerConfig, ChannelType, ConversationStatus, FactScope, TopicStatus, EpisodeType, MemoryVisibility, CrossAgentQuery, AgentIdentity, SessionCursor, RecentTurn, ExpertiseSourceType, EvidenceRelationship, ArchivedMiningQuery, ArchivedMiningResult, MultiContextMiningOptions, } from './types.js';
|
|
75
86
|
export type { ProviderType } from './provider-translator.js';
|
|
76
87
|
export { classifyContentType, signalWeight, isSignalBearing, SIGNAL_WEIGHT } from './content-type-classifier.js';
|
|
77
88
|
export type { ContentType, ContentTypeResult } from './content-type-classifier.js';
|
|
@@ -89,19 +100,34 @@ import { type EntityType, type KnowledgeLink, type GraphNode, type TraversalResu
|
|
|
89
100
|
import { type DesiredStateEntry, type DriftStatus } from './desired-state-store.js';
|
|
90
101
|
import { CacheLayer } from './cache.js';
|
|
91
102
|
import { Compositor } from './compositor.js';
|
|
103
|
+
import { type Context } from './context-store.js';
|
|
92
104
|
import { VectorStore, type VectorSearchResult, type VectorIndexStats } from './vector-store.js';
|
|
93
105
|
import { type DocChunkRow, type ChunkQuery, type IndexResult } from './doc-chunk-store.js';
|
|
94
106
|
import { type SeedOptions, type SeedResult } from './seed.js';
|
|
95
107
|
import { type DocChunk } from './doc-chunker.js';
|
|
96
|
-
import type { HyperMemConfig, ComposeRequest, ComposeResult, NeutralMessage, StoredMessage, Conversation, ChannelType } from './types.js';
|
|
108
|
+
import type { HyperMemConfig, ComposeRequest, ComposeResult, NeutralMessage, StoredMessage, Conversation, ChannelType, ArchivedMiningQuery, ArchivedMiningResult, MultiContextMiningOptions } from './types.js';
|
|
97
109
|
import { type OrgRegistry } from './cross-agent.js';
|
|
110
|
+
export interface StartupFleetSeedOptions {
|
|
111
|
+
workspaceRoots?: string[];
|
|
112
|
+
includeMessageDbAgents?: boolean;
|
|
113
|
+
hydrateCache?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface StartupFleetSeedResult {
|
|
116
|
+
discovered: number;
|
|
117
|
+
inserted: number;
|
|
118
|
+
updated: number;
|
|
119
|
+
skipped: number;
|
|
120
|
+
orgsCreated: number;
|
|
121
|
+
hydratedAgents: number;
|
|
122
|
+
hydratedSummary: boolean;
|
|
123
|
+
}
|
|
98
124
|
/**
|
|
99
125
|
* hypermem — the main API facade.
|
|
100
126
|
*
|
|
101
127
|
* Usage:
|
|
102
128
|
* const hm = await hypermem.create({ dataDir: '~/.openclaw/hypermem' });
|
|
103
|
-
* await hm.record('
|
|
104
|
-
* const result = await hm.compose({ agentId: '
|
|
129
|
+
* await hm.record('alice', 'agent:alice:webchat:main', userMsg);
|
|
130
|
+
* const result = await hm.compose({ agentId: 'alice', sessionKey: '...', ... });
|
|
105
131
|
*/
|
|
106
132
|
export declare class HyperMem {
|
|
107
133
|
readonly dbManager: DatabaseManager;
|
|
@@ -145,6 +171,38 @@ export declare class HyperMem {
|
|
|
145
171
|
* Compose context for an LLM call.
|
|
146
172
|
*/
|
|
147
173
|
compose(request: ComposeRequest): Promise<ComposeResult>;
|
|
174
|
+
/**
|
|
175
|
+
* Persist a full tool result payload and return the durable record.
|
|
176
|
+
* Used by the plugin wave-guard to capture payloads before stubbing the
|
|
177
|
+
* transcript. Dedupes by content hash within the (agentId, sessionKey)
|
|
178
|
+
* scope — identical payloads bump ref_count on the existing row.
|
|
179
|
+
*/
|
|
180
|
+
recordToolArtifact(agentId: string, sessionKey: string, input: Omit<import('./tool-artifact-store.js').PutToolArtifactInput, 'agentId' | 'sessionKey'>): Promise<import('./tool-artifact-store.js').ToolArtifactRecord>;
|
|
181
|
+
/** Fetch a tool artifact by id. Returns null if unknown. */
|
|
182
|
+
getToolArtifact(agentId: string, artifactId: string): Promise<import('./tool-artifact-store.js').ToolArtifactRecord | null>;
|
|
183
|
+
/** List tool artifacts for a specific turn. */
|
|
184
|
+
listToolArtifactsByTurn(agentId: string, sessionKey: string, turnId: string): Promise<import('./tool-artifact-store.js').ToolArtifactRecord[]>;
|
|
185
|
+
/**
|
|
186
|
+
* List archived or forked contexts for an agent.
|
|
187
|
+
*
|
|
188
|
+
* operator-safe enumeration path. This is the approved archived-context
|
|
189
|
+
* listing surface. Active composition remains separate.
|
|
190
|
+
*/
|
|
191
|
+
listArchivedContexts(agentId: string, opts?: {
|
|
192
|
+
sessionKey?: string;
|
|
193
|
+
limit?: number;
|
|
194
|
+
}): Context[];
|
|
195
|
+
/**
|
|
196
|
+
* Mine a single archived or forked context through the archived-mining
|
|
197
|
+
* surface. This does not widen active composition.
|
|
198
|
+
*/
|
|
199
|
+
mineArchivedContext(agentId: string, query: ArchivedMiningQuery): ArchivedMiningResult<StoredMessage[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Mine multiple archived or forked contexts through the capped archived-
|
|
202
|
+
* mining surface. This does not expose raw DAG helpers and does not widen
|
|
203
|
+
* active composition.
|
|
204
|
+
*/
|
|
205
|
+
mineArchivedContexts(agentId: string, contextIds: number[], opts?: MultiContextMiningOptions): ArchivedMiningResult<StoredMessage[]>[];
|
|
148
206
|
/**
|
|
149
207
|
* Warm a session from SQLite into Redis.
|
|
150
208
|
*/
|
|
@@ -155,7 +213,7 @@ export declare class HyperMem {
|
|
|
155
213
|
/**
|
|
156
214
|
* Recompute the Redis hot history view from SQLite and re-apply tool gradient.
|
|
157
215
|
*/
|
|
158
|
-
refreshRedisGradient(agentId: string, sessionKey: string, tokenBudget?: number): Promise<void>;
|
|
216
|
+
refreshRedisGradient(agentId: string, sessionKey: string, tokenBudget?: number, historyDepth?: number): Promise<void>;
|
|
159
217
|
/**
|
|
160
218
|
* Full-text search across all messages for an agent.
|
|
161
219
|
*/
|
|
@@ -618,6 +676,14 @@ export declare class HyperMem {
|
|
|
618
676
|
agentId?: string;
|
|
619
677
|
collection?: string;
|
|
620
678
|
}): import("./doc-chunk-store.js").DocSourceRow[];
|
|
679
|
+
/**
|
|
680
|
+
* Seed fleet agents from known workspace identity files and existing
|
|
681
|
+
* message-db agent directories, then optionally hydrate the Redis fleet cache.
|
|
682
|
+
*
|
|
683
|
+
* The sweep is idempotent: existing rows are only updated when startup-discovered
|
|
684
|
+
* values differ, so repeated boots do not duplicate or churn fleet rows.
|
|
685
|
+
*/
|
|
686
|
+
seedFleetAgentsOnStartup(opts?: StartupFleetSeedOptions): Promise<StartupFleetSeedResult>;
|
|
621
687
|
/**
|
|
622
688
|
* Hydrate the Redis fleet cache from library.db.
|
|
623
689
|
* Call on gateway startup to warm the cache for dashboard queries.
|