@equationalapplications/core-llm-wiki 4.7.0 → 4.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/README.md +76 -0
- package/dist/chunk-2FGDZKC2.mjs +2547 -0
- package/dist/chunk-2FGDZKC2.mjs.map +1 -0
- package/dist/index.d.mts +4 -530
- package/dist/index.d.ts +4 -530
- package/dist/index.js +2412 -1980
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +156 -2267
- package/dist/index.mjs.map +1 -1
- package/dist/testing-hfpeX01Q.d.mts +1112 -0
- package/dist/testing-hfpeX01Q.d.ts +1112 -0
- package/dist/testing.d.mts +2 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +2552 -0
- package/dist/testing.js.map +1 -0
- package/dist/testing.mjs +3 -0
- package/dist/testing.mjs.map +1 -0
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,532 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* that wraps its native driver behind this interface.
|
|
5
|
-
*/
|
|
6
|
-
interface SQLiteAdapter {
|
|
7
|
-
execAsync(sql: string): Promise<void>;
|
|
8
|
-
runAsync(sql: string, params?: unknown[]): Promise<{
|
|
9
|
-
changes: number;
|
|
10
|
-
lastInsertRowId: number;
|
|
11
|
-
}>;
|
|
12
|
-
getAllAsync<T>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
13
|
-
getFirstAsync<T>(sql: string, params?: unknown[]): Promise<T | null>;
|
|
14
|
-
withTransactionAsync<T>(fn: (tx: SQLiteAdapter) => Promise<T>): Promise<T>;
|
|
15
|
-
closeAsync(): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
interface WikiConfig {
|
|
18
|
-
tablePrefix?: string;
|
|
19
|
-
maxResults?: number;
|
|
20
|
-
/** @deprecated Use maxResults */
|
|
21
|
-
maxFtsResults?: number;
|
|
22
|
-
pruneEventsAfter?: number;
|
|
23
|
-
pruneRetainSoftDeletedFor?: number;
|
|
24
|
-
autoLibrarianThreshold?: number;
|
|
25
|
-
autoHealThreshold?: number;
|
|
26
|
-
orphanAfterDays?: number | null;
|
|
27
|
-
staleInferredAfterDays?: number | null;
|
|
28
|
-
maxChunkLength?: number;
|
|
29
|
-
chunkOverlap?: number;
|
|
30
|
-
chunkConcurrency?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Max MiniSearch candidates passed to cosine scoring.
|
|
33
|
-
* When set, MiniSearch pre-filters before the cosine scan.
|
|
34
|
-
* Only applies when embed is provided and succeeds.
|
|
35
|
-
* Default: undefined (full scan).
|
|
36
|
-
*/
|
|
37
|
-
preFilterLimit?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Hybrid blend weight (0.0–1.0).
|
|
40
|
-
* 0.0 = pure keyword (skips embed() entirely).
|
|
41
|
-
* 1.0 = pure semantic.
|
|
42
|
-
* Values outside [0,1] are clamped. Ignored when embed is absent or throws.
|
|
43
|
-
* Default: undefined (pure semantic when embed provided).
|
|
44
|
-
*/
|
|
45
|
-
hybridWeight?: number;
|
|
46
|
-
}
|
|
47
|
-
interface ReadOptions {
|
|
48
|
-
maxResults?: number;
|
|
49
|
-
/**
|
|
50
|
-
* undefined → use WikiConfig.preFilterLimit (or no pre-filter if also unset).
|
|
51
|
-
* null → explicitly disable a config-level preFilterLimit for this call.
|
|
52
|
-
*/
|
|
53
|
-
preFilterLimit?: number | null;
|
|
54
|
-
hybridWeight?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Per-entity score multiplier for multi-entity reads. Missing entries default to 1.0.
|
|
57
|
-
* Entities with weight 0 are skipped during scored retrieval unless
|
|
58
|
-
* `includeZeroWeightEntities` is true; in that case they rank below all finite scores.
|
|
59
|
-
* Only meaningful when `entityId` is an array; ignored for single-string calls.
|
|
60
|
-
*/
|
|
61
|
-
tierWeights?: Record<string, number>;
|
|
62
|
-
/**
|
|
63
|
-
* When true, entities with a tier weight of 0 are included in scored retrieval
|
|
64
|
-
* as bottom fillers (ranked below every finite-scored candidate).
|
|
65
|
-
* When false (default), zero-weight entities are skipped entirely.
|
|
66
|
-
* Only meaningful when `entityId` is an array; ignored for single-string calls.
|
|
67
|
-
*/
|
|
68
|
-
includeZeroWeightEntities?: boolean;
|
|
69
|
-
}
|
|
70
|
-
interface WikiFact {
|
|
71
|
-
id: string;
|
|
72
|
-
entity_id: string;
|
|
73
|
-
title: string;
|
|
74
|
-
body: string;
|
|
75
|
-
tags: string[];
|
|
76
|
-
confidence: 'certain' | 'inferred' | 'tentative';
|
|
77
|
-
/**
|
|
78
|
-
* Source type of this fact.
|
|
79
|
-
* - 'immutable_document': From ingestDocument(), cannot be modified by system (librarian/heal).
|
|
80
|
-
* Only removable via forget() or replaced via re-ingest.
|
|
81
|
-
* - 'librarian_inferred': Created by runLibrarian() from events, or by runHeal() when synthesizing new inferred facts.
|
|
82
|
-
* - 'user_stated': Direct user statement.
|
|
83
|
-
* - 'user_confirmed': User-confirmed fact.
|
|
84
|
-
*/
|
|
85
|
-
source_type: 'user_stated' | 'librarian_inferred' | 'user_confirmed' | 'immutable_document';
|
|
86
|
-
source_hash: string | null;
|
|
87
|
-
source_ref: string | null;
|
|
88
|
-
created_at: number;
|
|
89
|
-
updated_at: number;
|
|
90
|
-
/**
|
|
91
|
-
* Raw Float32Array bytes for the fact's embedding vector.
|
|
92
|
-
* Set when the fact was fetched via exportDump() with blob preservation.
|
|
93
|
-
* Accepted in importDump() as a real Uint8Array (in-memory round-trip),
|
|
94
|
-
* a Node.js Buffer JSON shape `{ type: 'Buffer', data: number[] }`,
|
|
95
|
-
* or a numeric-keyed plain object `{ 0: byte, 1: byte, ... }` produced
|
|
96
|
-
* by JSON.stringify(Uint8Array).
|
|
97
|
-
*/
|
|
98
|
-
embedding_blob?: Uint8Array | {
|
|
99
|
-
type: 'Buffer';
|
|
100
|
-
data: number[];
|
|
101
|
-
} | Record<string, number>;
|
|
102
|
-
last_accessed_at: number | null;
|
|
103
|
-
access_count: number;
|
|
104
|
-
deleted_at: number | null;
|
|
105
|
-
}
|
|
106
|
-
interface WikiTask {
|
|
107
|
-
id: string;
|
|
108
|
-
entity_id: string;
|
|
109
|
-
description: string;
|
|
110
|
-
status: 'pending' | 'in_progress' | 'done' | 'abandoned';
|
|
111
|
-
priority: number;
|
|
112
|
-
created_at: number;
|
|
113
|
-
updated_at: number;
|
|
114
|
-
resolved_at: number | null;
|
|
115
|
-
deleted_at: number | null;
|
|
116
|
-
}
|
|
117
|
-
interface WikiEvent {
|
|
118
|
-
id: string;
|
|
119
|
-
entity_id: string;
|
|
120
|
-
event_type: 'observation' | 'decision' | 'action' | 'outcome';
|
|
121
|
-
summary: string;
|
|
122
|
-
related_entry_id?: string | null;
|
|
123
|
-
created_at: number;
|
|
124
|
-
}
|
|
125
|
-
interface WikiCheckpoint {
|
|
126
|
-
entity_id: string;
|
|
127
|
-
heal_checkpoint: number;
|
|
128
|
-
memory_checkpoint: number;
|
|
129
|
-
}
|
|
130
|
-
interface ExtractedFact {
|
|
131
|
-
title: string;
|
|
132
|
-
body: string;
|
|
133
|
-
tags: string[];
|
|
134
|
-
confidence: 'certain' | 'inferred' | 'tentative';
|
|
135
|
-
}
|
|
136
|
-
interface ExtractedTask {
|
|
137
|
-
description: string;
|
|
138
|
-
priority: number;
|
|
139
|
-
}
|
|
140
|
-
interface LLMProvider {
|
|
141
|
-
/**
|
|
142
|
-
* Generates text using the developer's LLM of choice.
|
|
143
|
-
* Expected to return the raw text response (typically a JSON string).
|
|
144
|
-
*/
|
|
145
|
-
generateText: (params: {
|
|
146
|
-
systemPrompt: string;
|
|
147
|
-
userPrompt: string;
|
|
148
|
-
}) => Promise<string>;
|
|
149
|
-
/**
|
|
150
|
-
* Optional. When provided, enables semantic similarity search in `read()`.
|
|
151
|
-
* Must return a stable-dimension float array for any input text.
|
|
152
|
-
* Called once per fact on creation/update, and once per `read()` query.
|
|
153
|
-
* When absent or throws, `read()` falls back to MiniSearch.
|
|
154
|
-
*/
|
|
155
|
-
embed?: (text: string) => Promise<number[]>;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Result of semantic ranking for a single fact.
|
|
159
|
-
*/
|
|
160
|
-
interface VectorRankerSemanticResult {
|
|
161
|
-
id: string;
|
|
162
|
-
/** Cosine similarity in [-1, 1] when exact; implementations MAY document other monotonic scales. */
|
|
163
|
-
semanticScore: number;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Arguments passed to VectorRanker.rankBySimilarity.
|
|
167
|
-
*/
|
|
168
|
-
interface VectorRankerRankArgs {
|
|
169
|
-
entityId: string;
|
|
170
|
-
/**
|
|
171
|
-
* Query embedding. Treat as readonly — core provides a defensive copy,
|
|
172
|
-
* but adapters MUST NOT mutate this array. Mutation can corrupt
|
|
173
|
-
* WikiMemory's internal vector cache and JS-cosine fallback path.
|
|
174
|
-
*/
|
|
175
|
-
queryVec: Float32Array | number[];
|
|
176
|
-
/**
|
|
177
|
-
* When set (MiniSearch pre-filter path): ranker MUST only produce results for ids in this set.
|
|
178
|
-
* When omitted (full-entity semantic path): ranker scopes by entityId per its backing store contract.
|
|
179
|
-
*/
|
|
180
|
-
candidateIds?: readonly string[];
|
|
181
|
-
/**
|
|
182
|
-
* Upper bound on how many distinct fact ids should receive a semanticScore in this call.
|
|
183
|
-
* WikiMemory derives this from maxResults / candidate cardinality / documented oversampling policy.
|
|
184
|
-
*/
|
|
185
|
-
limit: number;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Optional backend for semantic candidate scoring / top-k retrieval.
|
|
189
|
-
* When omitted, WikiMemory scores rows with embedding_blob / embedding TEXT in JS (cosine).
|
|
190
|
-
*/
|
|
191
|
-
interface VectorRanker {
|
|
192
|
-
/**
|
|
193
|
-
* Return semantic scores for facts in scope, sorted descending by semanticScore (stable tie-breaking
|
|
194
|
-
* not required — WikiMemory reapplies existing tie-breakers after blending).
|
|
195
|
-
* Implementations SHOULD omit facts with no usable vector; callers treat missing ids like today's
|
|
196
|
-
* "no embedding" rows (pure semantic: -2; hybrid: keyword-only portion).
|
|
197
|
-
*/
|
|
198
|
-
rankBySimilarity(args: VectorRankerRankArgs): Promise<VectorRankerSemanticResult[]>;
|
|
199
|
-
/**
|
|
200
|
-
* Called after a fact's embedding is successfully persisted to embedding_blob (or cleared).
|
|
201
|
-
* Hosts use this to keep sqlite-vec / external indexes consistent with SQLite as source of truth.
|
|
202
|
-
*
|
|
203
|
-
* On deletion paths (forget, prune, hard-delete), core awaits this hook to ensure ANN cleanup
|
|
204
|
-
* completes before the deletion call resolves (GDPR compliance). Hook failures or timeouts on
|
|
205
|
-
* those paths reject the deletion call.
|
|
206
|
-
*
|
|
207
|
-
* Treat `vector` as readonly — core provides a defensive copy, but adapters MUST NOT mutate.
|
|
208
|
-
*
|
|
209
|
-
* Optional: if omitted, hosts MUST document "index rebuilt separately" and accept stale ANN until rebuild.
|
|
210
|
-
*/
|
|
211
|
-
onEmbeddingPersisted?(event: {
|
|
212
|
-
entityId: string;
|
|
213
|
-
factId: string;
|
|
214
|
-
vector: Float32Array | null;
|
|
215
|
-
}): void | Promise<void>;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Fallback policy when rankBySimilarity rejects.
|
|
219
|
-
*/
|
|
220
|
-
type VectorRankerFallback = 'js-cosine' | 'keyword' | 'empty' | 'throw';
|
|
221
|
-
interface WikiOptions {
|
|
222
|
-
config?: WikiConfig;
|
|
223
|
-
llmProvider: LLMProvider;
|
|
224
|
-
/**
|
|
225
|
-
* Called when embedding-based retrieval is degraded or unavailable during `read()`.
|
|
226
|
-
* This can happen when:
|
|
227
|
-
* - `embed()` throws (e.g. network error, model unavailable) → falls back to keyword search
|
|
228
|
-
* - `embed()` returns a vector with non-finite values (NaN / Infinity) → falls back to keyword search
|
|
229
|
-
* - The query vector's dimension doesn't match stored embeddings (model switch;
|
|
230
|
-
* resolve by calling `runReembed()`) → falls back to keyword search
|
|
231
|
-
* - `vectorRanker` returns IDs that don't belong to the requested entity or don't exist
|
|
232
|
-
* (ranker integrity issue; returned rows will be filtered out, reducing result count) →
|
|
233
|
-
* may still use semantic ranking, but with degraded quality
|
|
234
|
-
*
|
|
235
|
-
* `read()` returns results (keyword fallback or degraded semantic) — this is a notification, not an error path.
|
|
236
|
-
*/
|
|
237
|
-
onRetrievalFallback?: (error: Error) => void;
|
|
238
|
-
/**
|
|
239
|
-
* Optional backend for semantic candidate scoring / top-k retrieval.
|
|
240
|
-
* When omitted, WikiMemory scores rows with embedding_blob / embedding TEXT in JS (cosine).
|
|
241
|
-
*/
|
|
242
|
-
vectorRanker?: VectorRanker;
|
|
243
|
-
/**
|
|
244
|
-
* When rankBySimilarity throws. Default `'js-cosine'`.
|
|
245
|
-
* Ignored when vectorRanker is undefined.
|
|
246
|
-
*/
|
|
247
|
-
vectorRankerFallback?: VectorRankerFallback;
|
|
248
|
-
/**
|
|
249
|
-
* Called only when rankBySimilarity rejects (after embeddings path succeeded).
|
|
250
|
-
* Invoked before applying vectorRankerFallback when that policy recovers or before rejecting when policy is 'throw'.
|
|
251
|
-
*/
|
|
252
|
-
onVectorRankerFallback?: (info: {
|
|
253
|
-
error: Error;
|
|
254
|
-
/** Effective policy core will apply for this read (same as WikiOptions.vectorRankerFallback, default js-cosine). */
|
|
255
|
-
policy: VectorRankerFallback;
|
|
256
|
-
}) => void;
|
|
257
|
-
/**
|
|
258
|
-
* When true: after rankBySimilarity failure, once the recoverable fallback has finished
|
|
259
|
-
* and read() will resolve, invoke onRetrievalFallback — after onVectorRankerFallback if set.
|
|
260
|
-
* Ignored when vectorRankerFallback is 'throw'. Default false.
|
|
261
|
-
*/
|
|
262
|
-
propagateRankerFailureToRetrievalFallback?: boolean;
|
|
263
|
-
/**
|
|
264
|
-
* When true (default), sanitize ranker errors before exposing via error.cause
|
|
265
|
-
* to prevent credential leakage in host telemetry. Disable only when you
|
|
266
|
-
* control the ranker implementation.
|
|
267
|
-
*
|
|
268
|
-
* Sanitization replaces error message/stack with a generic message preserving
|
|
269
|
-
* only the error type (constructor name).
|
|
270
|
-
*/
|
|
271
|
-
sanitizeRankerErrors?: boolean;
|
|
272
|
-
/**
|
|
273
|
-
* Timeout (ms) for onEmbeddingPersisted hook on GDPR deletion paths
|
|
274
|
-
* (forget, _doPrune). Hook must complete within this window or the
|
|
275
|
-
* deletion operation rejects. Default 30000.
|
|
276
|
-
* Lower for interactive deletes; raise for slow remote ANN backends.
|
|
277
|
-
*/
|
|
278
|
-
deletionHookTimeoutMs?: number;
|
|
279
|
-
/**
|
|
280
|
-
* Escape hatch: skip onEmbeddingPersisted on deletion paths entirely.
|
|
281
|
-
* Use ONLY when the ANN backend is permanently decommissioned. Vectors
|
|
282
|
-
* orphaned in the (unreachable) external index are accepted as a tradeoff.
|
|
283
|
-
* NOT GDPR-safe for live indexes. Default false.
|
|
284
|
-
*/
|
|
285
|
-
forceDeleteIgnoreRankerHook?: boolean;
|
|
286
|
-
}
|
|
287
|
-
interface MemoryBundle {
|
|
288
|
-
facts: WikiFact[];
|
|
289
|
-
tasks: WikiTask[];
|
|
290
|
-
events: WikiEvent[];
|
|
291
|
-
factScores?: Record<string, number>;
|
|
292
|
-
metadata?: {
|
|
293
|
-
query: string;
|
|
294
|
-
entityIds: string[];
|
|
295
|
-
tierWeights?: Record<string, number>;
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
interface MemoryDump {
|
|
299
|
-
generatedAt: number;
|
|
300
|
-
entities: Record<string, MemoryBundle>;
|
|
301
|
-
}
|
|
302
|
-
interface FormattedMemoryDump {
|
|
303
|
-
manifest: string;
|
|
304
|
-
files: Array<{
|
|
305
|
-
name: string;
|
|
306
|
-
content: string;
|
|
307
|
-
}>;
|
|
308
|
-
}
|
|
309
|
-
interface FormatContextOptions {
|
|
310
|
-
format?: 'markdown' | 'plain';
|
|
311
|
-
maxFacts?: number;
|
|
312
|
-
maxTasks?: number;
|
|
313
|
-
maxEvents?: number;
|
|
314
|
-
includeConfidence?: boolean;
|
|
315
|
-
includeTags?: boolean;
|
|
316
|
-
includeEntityIds?: boolean;
|
|
317
|
-
includeFactScores?: boolean;
|
|
318
|
-
factWeights?: {
|
|
319
|
-
confidence?: number;
|
|
320
|
-
accessCount?: number;
|
|
321
|
-
recency?: number;
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
interface EntityStatus {
|
|
325
|
-
ingesting: boolean;
|
|
326
|
-
librarian: boolean;
|
|
327
|
-
heal: boolean;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* All operations that can appear in a {@link WikiBusyError}.
|
|
331
|
-
*
|
|
332
|
-
* @remarks **Breaking change from v2.x** — the union previously only contained
|
|
333
|
-
* `'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed'`. The values `'import'`
|
|
334
|
-
* and `'forget'` were added in v3.0. Exhaustive `switch` / narrowing on this type
|
|
335
|
-
* must be updated (or given a `default` arm) to compile without errors.
|
|
336
|
-
*/
|
|
337
|
-
type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget';
|
|
338
|
-
/**
|
|
339
|
-
* Thrown when a background mutator is already running for the requested entity.
|
|
340
|
-
*/
|
|
341
|
-
declare class WikiBusyError extends Error {
|
|
342
|
-
readonly operation: WikiBusyOperation;
|
|
343
|
-
readonly entityId: string;
|
|
344
|
-
constructor(operation: WikiBusyOperation, entityId: string);
|
|
345
|
-
}
|
|
346
|
-
declare class PrunePartialFailureError extends Error {
|
|
347
|
-
readonly deleted: number;
|
|
348
|
-
readonly failedAt: string;
|
|
349
|
-
readonly remaining: number;
|
|
350
|
-
readonly deletedTasks: number;
|
|
351
|
-
readonly deletedEvents: number;
|
|
352
|
-
readonly cause: Error;
|
|
353
|
-
constructor(deleted: number, failedAt: string, remaining: number, cause: Error, deletedTasks?: number, deletedEvents?: number);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
declare class WikiMemory {
|
|
357
|
-
private db;
|
|
358
|
-
private prefix;
|
|
359
|
-
private options;
|
|
360
|
-
private entryRepo;
|
|
361
|
-
private outboxRepo;
|
|
362
|
-
private taskRepo;
|
|
363
|
-
private eventRepo;
|
|
364
|
-
private metadataRepo;
|
|
365
|
-
private activeMaintenanceJobs;
|
|
366
|
-
private activeIngestJobs;
|
|
367
|
-
private statusSubscribers;
|
|
368
|
-
private miniSearch;
|
|
369
|
-
private miniSearchEntryIdsByEntity;
|
|
370
|
-
/**
|
|
371
|
-
* Maximum number of entities whose parsed embedding vectors are held in
|
|
372
|
-
* memory. This cap is intentionally conservative so the cache remains safe
|
|
373
|
-
* on memory-constrained runtimes (e.g., mobile/Expo).
|
|
374
|
-
*/
|
|
375
|
-
private static readonly MAX_VECTOR_CACHE_ENTITIES;
|
|
376
|
-
/**
|
|
377
|
-
* Maximum number of fact vectors cached per entity. Keep this high enough to
|
|
378
|
-
* preserve the parsed-embedding reuse optimization for common mid-sized
|
|
379
|
-
* entities while still maintaining a bounded memory footprint.
|
|
380
|
-
*/
|
|
381
|
-
private static readonly MAX_VECTOR_CACHE_FACTS_PER_ENTITY;
|
|
382
|
-
private vectorCache;
|
|
383
|
-
private normalizeMiniSearchRow;
|
|
384
|
-
private rebuildMiniSearchIndex;
|
|
385
|
-
private storeEmbeddingDimension;
|
|
386
|
-
/**
|
|
387
|
-
* After a successful runReembed(), promote the pending `embedding_dimension_mismatch`
|
|
388
|
-
* value to the canonical `embedding_dimension` key and clear the mismatch flag.
|
|
389
|
-
* This ensures future read() calls use embedding-based retrieval rather than staying
|
|
390
|
-
* stuck on the MiniSearch fallback.
|
|
391
|
-
*/
|
|
392
|
-
private _reconcileEmbeddingDimension;
|
|
393
|
-
private embedFact;
|
|
394
|
-
private _librarianKey;
|
|
395
|
-
private _healKey;
|
|
396
|
-
private _warnCrossEntityCollision;
|
|
397
|
-
/** Maps pre-rename enum strings from older dumps to current source_type values. */
|
|
398
|
-
private _normalizeImportedSourceType;
|
|
399
|
-
private assertNoLegacySourceTypes;
|
|
400
|
-
private _notifyEmbeddingPersisted;
|
|
401
|
-
/**
|
|
402
|
-
* GDPR-critical variant: awaits the hook with a timeout and rethrows failures.
|
|
403
|
-
* Use ONLY on deletion paths. forget() calls after soft-delete UPDATE; runPrune()
|
|
404
|
-
* calls before hard DELETE. For best-effort sync, use _notifyEmbeddingPersisted.
|
|
405
|
-
*/
|
|
406
|
-
private _notifyEmbeddingPersistedOrThrow;
|
|
407
|
-
constructor(db: SQLiteAdapter, options: WikiOptions);
|
|
408
|
-
setup(): Promise<void>;
|
|
409
|
-
hasChanged(entityId: string, sourceRef: string, sourceHash: string): Promise<boolean>;
|
|
410
|
-
private _pruneKey;
|
|
411
|
-
private _reembedKey;
|
|
412
|
-
private _globalReembedKey;
|
|
413
|
-
private _importKey;
|
|
414
|
-
private _globalImportKey;
|
|
415
|
-
private _forgetKey;
|
|
416
|
-
private _isReembedActive;
|
|
417
|
-
private _isImportActiveFor;
|
|
418
|
-
private _isForgetActiveFor;
|
|
419
|
-
/** Returns true if any maintenance job has the given operation suffix (e.g. ':prune'). */
|
|
420
|
-
private _isAnyMaintenanceActiveWithSuffix;
|
|
421
|
-
/** Returns true if any ingest job is active for the given entity. */
|
|
422
|
-
private _isIngestActiveFor;
|
|
423
|
-
private _copyEntityStatus;
|
|
424
|
-
private _notifyStatusSubscribers;
|
|
425
|
-
private _validatePruneDuration;
|
|
426
|
-
runPrune(entityId: string, options?: {
|
|
427
|
-
retainSoftDeletedFor?: number | null;
|
|
428
|
-
retainEventsFor?: number | null;
|
|
429
|
-
vacuum?: boolean;
|
|
430
|
-
}): Promise<{
|
|
431
|
-
entries: number;
|
|
432
|
-
tasks: number;
|
|
433
|
-
events: number;
|
|
434
|
-
}>;
|
|
435
|
-
read(entityId: string | string[], query: string, options?: ReadOptions): Promise<MemoryBundle>;
|
|
436
|
-
/**
|
|
437
|
-
* Returns entity IDs that will participate in scored retrieval.
|
|
438
|
-
* Excludes zero-weight entities unless includeZeroWeightEntities is true.
|
|
439
|
-
*/
|
|
440
|
-
private _filterScoredEntities;
|
|
441
|
-
/**
|
|
442
|
-
* Stable tie-break sort: score desc → access_count desc → updated_at desc → id asc.
|
|
443
|
-
*/
|
|
444
|
-
private _tieBreakSort;
|
|
445
|
-
/**
|
|
446
|
-
* Comparator for score + deterministic tie-break fields.
|
|
447
|
-
* Negative return means "a ranks ahead of b" for descending score order.
|
|
448
|
-
*/
|
|
449
|
-
private _compareScoredRows;
|
|
450
|
-
/**
|
|
451
|
-
* Hydrate full facts by ID. Pass scopedEntityIds to restrict to requested namespaces in SQL
|
|
452
|
-
* (defense-in-depth against a rogue VectorRanker returning cross-entity IDs).
|
|
453
|
-
*/
|
|
454
|
-
private _hydrateFactsByIds;
|
|
455
|
-
/**
|
|
456
|
-
* Strip potentially sensitive data from ranker errors before exposing to host callbacks.
|
|
457
|
-
* Preserves error type for debugging but removes message/stack that may contain credentials.
|
|
458
|
-
* Recursively sanitizes one level of .cause; deeper chains collapse to type only.
|
|
459
|
-
*/
|
|
460
|
-
private _sanitizeRankerError;
|
|
461
|
-
/**
|
|
462
|
-
* Score candidate rows using in-process JS cosine similarity.
|
|
463
|
-
* Applies hybrid blending (if weight set) and tie-break sorting before returning.
|
|
464
|
-
*/
|
|
465
|
-
private _rankWithJsCosine;
|
|
466
|
-
/**
|
|
467
|
-
* Delegate semantic ranking to the injected VectorRanker.
|
|
468
|
-
* Caller should pass an oversampledLimit to preserve recall after re-ranking.
|
|
469
|
-
* Returns scored results ready for hybrid blending and tie-break sorting.
|
|
470
|
-
*/
|
|
471
|
-
private _rankWithVectorRanker;
|
|
472
|
-
getMemoryBundle(entityId: string): Promise<MemoryBundle>;
|
|
473
|
-
write(entityId: string, event: Omit<WikiEvent, 'id' | 'entity_id' | 'created_at'>): Promise<void>;
|
|
474
|
-
private runLibrarianThenMaybeHeal;
|
|
475
|
-
private _doRunLibrarian;
|
|
476
|
-
private _doRunHeal;
|
|
477
|
-
runLibrarian(entityId: string): Promise<void>;
|
|
478
|
-
runHeal(entityId: string): Promise<void>;
|
|
479
|
-
runReembed(entityId?: string, opts?: {
|
|
480
|
-
force?: boolean;
|
|
481
|
-
skipExisting?: boolean;
|
|
482
|
-
}): Promise<{
|
|
483
|
-
embedded: number;
|
|
484
|
-
skipped: number;
|
|
485
|
-
failed: number;
|
|
486
|
-
}>;
|
|
487
|
-
getEntityStatus(entityId: string): EntityStatus;
|
|
488
|
-
/**
|
|
489
|
-
* Subscribe to {@link EntityStatus} changes for a single entity. The callback
|
|
490
|
-
* is invoked synchronously once with the current status before this method
|
|
491
|
-
* returns, then again on every transition where any of `ingesting`,
|
|
492
|
-
* `librarian`, or `heal` flips. No polling, no duplicate snapshots.
|
|
493
|
-
*
|
|
494
|
-
* Returns an idempotent unsubscribe function.
|
|
495
|
-
*
|
|
496
|
-
* See also {@link getEntityStatus} for a synchronous point-in-time read.
|
|
497
|
-
*/
|
|
498
|
-
subscribeEntityStatus(entityId: string, callback: (status: EntityStatus) => void): () => void;
|
|
499
|
-
clearVectorCache(): void;
|
|
500
|
-
private _getFullBundle;
|
|
501
|
-
exportDump(entityIds?: string[]): Promise<MemoryDump>;
|
|
502
|
-
importDump(dump: MemoryDump, opts?: {
|
|
503
|
-
merge?: boolean;
|
|
504
|
-
}): Promise<void>;
|
|
505
|
-
private _doImportEntity;
|
|
506
|
-
forget(entityId: string, params: {
|
|
507
|
-
entryId?: string;
|
|
508
|
-
taskId?: string;
|
|
509
|
-
sourceRef?: string;
|
|
510
|
-
sourceHash?: string;
|
|
511
|
-
clearAll?: boolean;
|
|
512
|
-
}): Promise<{
|
|
513
|
-
deleted: {
|
|
514
|
-
entries: number;
|
|
515
|
-
tasks: number;
|
|
516
|
-
};
|
|
517
|
-
}>;
|
|
518
|
-
ingestDocument(entityId: string, params: {
|
|
519
|
-
sourceRef: string;
|
|
520
|
-
sourceHash: string;
|
|
521
|
-
documentChunk: string;
|
|
522
|
-
maxChunkLength?: number;
|
|
523
|
-
chunkOverlap?: number;
|
|
524
|
-
chunkConcurrency?: number;
|
|
525
|
-
}): Promise<{
|
|
526
|
-
truncated: boolean;
|
|
527
|
-
chunks: number;
|
|
528
|
-
}>;
|
|
529
|
-
}
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-hfpeX01Q.js';
|
|
2
|
+
export { E as EntityStatus, d as ExtractedFact, e as ExtractedTask, H as HOOK_TIMEOUT_MARKER, L as LLMProvider, P as PromptOverrides, f as PromptService, g as PrunePartialFailureError, V as VectorRanker, h as VectorRankerFallback, i as VectorRankerRankArgs, j as VectorRankerSemanticResult, k as WikiBusyError, l as WikiBusyOperation, m as WikiCheckpoint, n as WikiConfig, o as WikiEvent, p as WikiFact, q as WikiMemoryTestAccess, r as WikiTask } from './testing-hfpeX01Q.js';
|
|
3
|
+
import 'minisearch';
|
|
530
4
|
|
|
531
5
|
declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
|
|
532
6
|
|
|
@@ -558,4 +32,4 @@ declare function mapLibrarianOptionsToReadOptions(options: LibrarianOptions): Pi
|
|
|
558
32
|
|
|
559
33
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
560
34
|
|
|
561
|
-
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT,
|
|
35
|
+
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, FormatContextOptions, FormattedMemoryDump, type LibrarianOptions, type LibrarianPromptVariables, MemoryBundle, MemoryDump, ReadOptions, SQLiteAdapter, WikiMemory, WikiOptions, createWiki, formatContext, formatMemoryDump, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, validateLibrarianPromptTemplate };
|