@equationalapplications/core-llm-wiki 4.21.0 → 4.23.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 +11 -6
- package/dist/{chunk-UYLYN5N4.mjs → chunk-MYZJLVX4.mjs} +412 -131
- package/dist/chunk-MYZJLVX4.mjs.map +1 -0
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +389 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-i91HR1TG.d.mts → testing-CBjAuTSl.d.mts} +73 -1
- package/dist/{testing-i91HR1TG.d.ts → testing-CBjAuTSl.d.ts} +73 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +309 -43
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +6 -6
- package/dist/chunk-UYLYN5N4.mjs.map +0 -1
|
@@ -96,6 +96,9 @@ interface OntologyBackfillResult {
|
|
|
96
96
|
remaining: number;
|
|
97
97
|
/** Untyped facts inside the recheck cooldown. */
|
|
98
98
|
deferred: number;
|
|
99
|
+
/** Facts a batch could not process even alone, skipped so the pass could finish.
|
|
100
|
+
* Stamped with the recheck cooldown, so they reappear as `deferred` next pass. */
|
|
101
|
+
skipped: number;
|
|
99
102
|
}
|
|
100
103
|
interface WikiConfig {
|
|
101
104
|
/**
|
|
@@ -303,6 +306,17 @@ interface LLMProvider {
|
|
|
303
306
|
* When absent or throws, `read()` falls back to MiniSearch.
|
|
304
307
|
*/
|
|
305
308
|
embed?: (text: string) => Promise<number[]>;
|
|
309
|
+
/**
|
|
310
|
+
* Optional. The provider's hard output-token ceiling for `generateText`.
|
|
311
|
+
* Core cannot observe it — the token budget lives entirely in the host's
|
|
312
|
+
* adapter — so maintenance passes that generate response-size-proportional
|
|
313
|
+
* output size their batches blind unless this is declared.
|
|
314
|
+
*
|
|
315
|
+
* When absent, batching falls back to a conservative default and adapts
|
|
316
|
+
* downward on failure. When present, it is used as a sizing hint only and is
|
|
317
|
+
* never trusted as a guarantee.
|
|
318
|
+
*/
|
|
319
|
+
maxOutputTokens?: number;
|
|
306
320
|
}
|
|
307
321
|
/**
|
|
308
322
|
* Result of semantic ranking for a single fact.
|
|
@@ -648,6 +662,23 @@ declare class EntryRepository extends BaseRepository {
|
|
|
648
662
|
* Used by _getFullBundle().
|
|
649
663
|
*/
|
|
650
664
|
findAllByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
665
|
+
/**
|
|
666
|
+
* Fetch live, mutable entries for an entity — everything heal is allowed to
|
|
667
|
+
* downgrade or delete. Heal previously loaded every row via
|
|
668
|
+
* findAllByEntityId and filtered in JS, which on a document-heavy corpus
|
|
669
|
+
* meant loading 2560 rows to keep 31.
|
|
670
|
+
*/
|
|
671
|
+
findHealCandidatesByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
672
|
+
/**
|
|
673
|
+
* Resolve search hits to document anchors. The MiniSearch index holds every
|
|
674
|
+
* fact, not only immutable_document rows, so the source-type restriction has
|
|
675
|
+
* to be applied here, after retrieval.
|
|
676
|
+
*/
|
|
677
|
+
findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter): Promise<Array<{
|
|
678
|
+
id: string;
|
|
679
|
+
title: string;
|
|
680
|
+
source_ref: string | null;
|
|
681
|
+
}>>;
|
|
651
682
|
/**
|
|
652
683
|
* Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
|
|
653
684
|
* Used by MaintenanceService.doRunLibrarian().
|
|
@@ -845,10 +876,23 @@ declare class SearchService {
|
|
|
845
876
|
private miniSearch;
|
|
846
877
|
private miniSearchEntryIdsByEntity;
|
|
847
878
|
private vectorCache;
|
|
879
|
+
/**
|
|
880
|
+
* Serializes rebuilds. `rebuildIndex` awaits a repository read between
|
|
881
|
+
* snapshotting the previous id set and discarding it, so two concurrent
|
|
882
|
+
* sync() calls for one entity can interleave: a slow, stale read lands last
|
|
883
|
+
* and discards documents the fresh read just added. Chaining also keeps
|
|
884
|
+
* discard()/addAll() out of each other's way, which is what accrued the
|
|
885
|
+
* auto-vacuum debt behind the TypeError in #64.
|
|
886
|
+
*/
|
|
887
|
+
private syncChain;
|
|
848
888
|
constructor(entryRepo: EntryRepository);
|
|
849
889
|
/**
|
|
850
890
|
* Rebuilds the search index and clears the vector cache for a given entity.
|
|
851
891
|
* A direct replacement for manually syncing state after a DB transaction.
|
|
892
|
+
*
|
|
893
|
+
* Rebuilds are serialized per instance and never reject: the MiniSearch index
|
|
894
|
+
* is a rebuildable cache over SQLite, so degraded keyword search is the
|
|
895
|
+
* correct failure mode and killing the host process is not.
|
|
852
896
|
*/
|
|
853
897
|
sync(entityId?: string): Promise<void>;
|
|
854
898
|
/**
|
|
@@ -1221,7 +1265,35 @@ declare class MaintenanceService {
|
|
|
1221
1265
|
promptOverride?: string;
|
|
1222
1266
|
batchSize?: number;
|
|
1223
1267
|
}): Promise<OntologyBackfillResult>;
|
|
1268
|
+
/**
|
|
1269
|
+
* Applies one parsed backfill batch in its own transaction. Per-batch rather
|
|
1270
|
+
* than one transaction for the pass, so mergeEmergentUpdates semantics and
|
|
1271
|
+
* the mid-flight `mode === 'off'` abort check keep the shape they had when a
|
|
1272
|
+
* pass was a single call.
|
|
1273
|
+
*/
|
|
1274
|
+
private _applyOntologyBackfillBatch;
|
|
1224
1275
|
private _validatePruneDuration;
|
|
1276
|
+
/**
|
|
1277
|
+
* Anchors relevant to one batch of heal candidates.
|
|
1278
|
+
*
|
|
1279
|
+
* Heal used to pass every immutable_document fact for the entity — 2560 rows
|
|
1280
|
+
* against 31 candidates on the corpus behind #63 — which is what blew the
|
|
1281
|
+
* output ceiling. Anchors are now retrieved by keyword relevance to the batch
|
|
1282
|
+
* and capped.
|
|
1283
|
+
*
|
|
1284
|
+
* The MiniSearch index holds all facts, not only anchors, so hits are
|
|
1285
|
+
* overfetched and the source_type restriction is applied after retrieval, in
|
|
1286
|
+
* SQL. Search rank order is preserved through the filter.
|
|
1287
|
+
*
|
|
1288
|
+
* Accepted tradeoff: an anchor that contradicts a candidate while sharing no
|
|
1289
|
+
* vocabulary with it is now missed. Exhaustive-but-broken traded for
|
|
1290
|
+
* relevance-scoped-and-working.
|
|
1291
|
+
*
|
|
1292
|
+
* `cache` is keyed by the derived query rather than by the batch, so two
|
|
1293
|
+
* batches that reduce to the same query share one lookup. Caller-owned and
|
|
1294
|
+
* per-pass — see the call site in doRunHeal.
|
|
1295
|
+
*/
|
|
1296
|
+
private _selectHealAnchors;
|
|
1225
1297
|
private _sanitizeRankerError;
|
|
1226
1298
|
}
|
|
1227
1299
|
|
|
@@ -1480,4 +1552,4 @@ declare class WikiMemory {
|
|
|
1480
1552
|
}): Promise<void>;
|
|
1481
1553
|
}
|
|
1482
1554
|
|
|
1483
|
-
export { WriteService as $, type WikiConfig as A, type WikiEdge as B, type WikiEvent as C, type WikiFact as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HOOK_TIMEOUT_MARKER as H, type WikiMemoryTestAccess as I, type WikiOutboxEvent as J, type WikiTask as K, type LLMProvider as L, type MemoryBundle as M, WikiTransactionError as N,
|
|
1555
|
+
export { WriteService as $, type WikiConfig as A, type WikiEdge as B, type WikiEvent as C, type WikiFact as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HOOK_TIMEOUT_MARKER as H, type WikiMemoryTestAccess as I, type WikiOutboxEvent as J, type WikiTask as K, type LLMProvider as L, type MemoryBundle as M, WikiTransactionError as N, type OntologyManifest as O, type PromptOverrides as P, EmbeddingService as Q, type ReadOptions as R, type SQLiteAdapter as S, ImportExportService as T, IngestionService as U, type VectorRanker as V, type WikiOptions as W, JobManager as X, MaintenanceService as Y, RetrievalService as Z, SearchService as _, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedFactEdge as e, type ExtractedFactWithOntology as f, type ExtractedTask as g, type GraphTraversalOptions as h, ONTOLOGY_BACKFILL_BATCH_SIZE as i, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as j, ONTOLOGY_BACKFILL_RECHECK_MS as k, type OntologyBackfillResult as l, type OntologyConfig as m, type OntologyEdgeType as n, type OntologyMode as o, type OntologyNodeType as p, type OntologyPromptContext as q, type OntologyUpdates as r, PromptService as s, PrunePartialFailureError as t, type VectorRankerFallback as u, type VectorRankerRankArgs as v, type VectorRankerSemanticResult as w, WikiBusyError as x, type WikiBusyOperation as y, type WikiCheckpoint as z };
|
|
@@ -96,6 +96,9 @@ interface OntologyBackfillResult {
|
|
|
96
96
|
remaining: number;
|
|
97
97
|
/** Untyped facts inside the recheck cooldown. */
|
|
98
98
|
deferred: number;
|
|
99
|
+
/** Facts a batch could not process even alone, skipped so the pass could finish.
|
|
100
|
+
* Stamped with the recheck cooldown, so they reappear as `deferred` next pass. */
|
|
101
|
+
skipped: number;
|
|
99
102
|
}
|
|
100
103
|
interface WikiConfig {
|
|
101
104
|
/**
|
|
@@ -303,6 +306,17 @@ interface LLMProvider {
|
|
|
303
306
|
* When absent or throws, `read()` falls back to MiniSearch.
|
|
304
307
|
*/
|
|
305
308
|
embed?: (text: string) => Promise<number[]>;
|
|
309
|
+
/**
|
|
310
|
+
* Optional. The provider's hard output-token ceiling for `generateText`.
|
|
311
|
+
* Core cannot observe it — the token budget lives entirely in the host's
|
|
312
|
+
* adapter — so maintenance passes that generate response-size-proportional
|
|
313
|
+
* output size their batches blind unless this is declared.
|
|
314
|
+
*
|
|
315
|
+
* When absent, batching falls back to a conservative default and adapts
|
|
316
|
+
* downward on failure. When present, it is used as a sizing hint only and is
|
|
317
|
+
* never trusted as a guarantee.
|
|
318
|
+
*/
|
|
319
|
+
maxOutputTokens?: number;
|
|
306
320
|
}
|
|
307
321
|
/**
|
|
308
322
|
* Result of semantic ranking for a single fact.
|
|
@@ -648,6 +662,23 @@ declare class EntryRepository extends BaseRepository {
|
|
|
648
662
|
* Used by _getFullBundle().
|
|
649
663
|
*/
|
|
650
664
|
findAllByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
665
|
+
/**
|
|
666
|
+
* Fetch live, mutable entries for an entity — everything heal is allowed to
|
|
667
|
+
* downgrade or delete. Heal previously loaded every row via
|
|
668
|
+
* findAllByEntityId and filtered in JS, which on a document-heavy corpus
|
|
669
|
+
* meant loading 2560 rows to keep 31.
|
|
670
|
+
*/
|
|
671
|
+
findHealCandidatesByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
672
|
+
/**
|
|
673
|
+
* Resolve search hits to document anchors. The MiniSearch index holds every
|
|
674
|
+
* fact, not only immutable_document rows, so the source-type restriction has
|
|
675
|
+
* to be applied here, after retrieval.
|
|
676
|
+
*/
|
|
677
|
+
findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter): Promise<Array<{
|
|
678
|
+
id: string;
|
|
679
|
+
title: string;
|
|
680
|
+
source_ref: string | null;
|
|
681
|
+
}>>;
|
|
651
682
|
/**
|
|
652
683
|
* Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
|
|
653
684
|
* Used by MaintenanceService.doRunLibrarian().
|
|
@@ -845,10 +876,23 @@ declare class SearchService {
|
|
|
845
876
|
private miniSearch;
|
|
846
877
|
private miniSearchEntryIdsByEntity;
|
|
847
878
|
private vectorCache;
|
|
879
|
+
/**
|
|
880
|
+
* Serializes rebuilds. `rebuildIndex` awaits a repository read between
|
|
881
|
+
* snapshotting the previous id set and discarding it, so two concurrent
|
|
882
|
+
* sync() calls for one entity can interleave: a slow, stale read lands last
|
|
883
|
+
* and discards documents the fresh read just added. Chaining also keeps
|
|
884
|
+
* discard()/addAll() out of each other's way, which is what accrued the
|
|
885
|
+
* auto-vacuum debt behind the TypeError in #64.
|
|
886
|
+
*/
|
|
887
|
+
private syncChain;
|
|
848
888
|
constructor(entryRepo: EntryRepository);
|
|
849
889
|
/**
|
|
850
890
|
* Rebuilds the search index and clears the vector cache for a given entity.
|
|
851
891
|
* A direct replacement for manually syncing state after a DB transaction.
|
|
892
|
+
*
|
|
893
|
+
* Rebuilds are serialized per instance and never reject: the MiniSearch index
|
|
894
|
+
* is a rebuildable cache over SQLite, so degraded keyword search is the
|
|
895
|
+
* correct failure mode and killing the host process is not.
|
|
852
896
|
*/
|
|
853
897
|
sync(entityId?: string): Promise<void>;
|
|
854
898
|
/**
|
|
@@ -1221,7 +1265,35 @@ declare class MaintenanceService {
|
|
|
1221
1265
|
promptOverride?: string;
|
|
1222
1266
|
batchSize?: number;
|
|
1223
1267
|
}): Promise<OntologyBackfillResult>;
|
|
1268
|
+
/**
|
|
1269
|
+
* Applies one parsed backfill batch in its own transaction. Per-batch rather
|
|
1270
|
+
* than one transaction for the pass, so mergeEmergentUpdates semantics and
|
|
1271
|
+
* the mid-flight `mode === 'off'` abort check keep the shape they had when a
|
|
1272
|
+
* pass was a single call.
|
|
1273
|
+
*/
|
|
1274
|
+
private _applyOntologyBackfillBatch;
|
|
1224
1275
|
private _validatePruneDuration;
|
|
1276
|
+
/**
|
|
1277
|
+
* Anchors relevant to one batch of heal candidates.
|
|
1278
|
+
*
|
|
1279
|
+
* Heal used to pass every immutable_document fact for the entity — 2560 rows
|
|
1280
|
+
* against 31 candidates on the corpus behind #63 — which is what blew the
|
|
1281
|
+
* output ceiling. Anchors are now retrieved by keyword relevance to the batch
|
|
1282
|
+
* and capped.
|
|
1283
|
+
*
|
|
1284
|
+
* The MiniSearch index holds all facts, not only anchors, so hits are
|
|
1285
|
+
* overfetched and the source_type restriction is applied after retrieval, in
|
|
1286
|
+
* SQL. Search rank order is preserved through the filter.
|
|
1287
|
+
*
|
|
1288
|
+
* Accepted tradeoff: an anchor that contradicts a candidate while sharing no
|
|
1289
|
+
* vocabulary with it is now missed. Exhaustive-but-broken traded for
|
|
1290
|
+
* relevance-scoped-and-working.
|
|
1291
|
+
*
|
|
1292
|
+
* `cache` is keyed by the derived query rather than by the batch, so two
|
|
1293
|
+
* batches that reduce to the same query share one lookup. Caller-owned and
|
|
1294
|
+
* per-pass — see the call site in doRunHeal.
|
|
1295
|
+
*/
|
|
1296
|
+
private _selectHealAnchors;
|
|
1225
1297
|
private _sanitizeRankerError;
|
|
1226
1298
|
}
|
|
1227
1299
|
|
|
@@ -1480,4 +1552,4 @@ declare class WikiMemory {
|
|
|
1480
1552
|
}): Promise<void>;
|
|
1481
1553
|
}
|
|
1482
1554
|
|
|
1483
|
-
export { WriteService as $, type WikiConfig as A, type WikiEdge as B, type WikiEvent as C, type WikiFact as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HOOK_TIMEOUT_MARKER as H, type WikiMemoryTestAccess as I, type WikiOutboxEvent as J, type WikiTask as K, type LLMProvider as L, type MemoryBundle as M, WikiTransactionError as N,
|
|
1555
|
+
export { WriteService as $, type WikiConfig as A, type WikiEdge as B, type WikiEvent as C, type WikiFact as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HOOK_TIMEOUT_MARKER as H, type WikiMemoryTestAccess as I, type WikiOutboxEvent as J, type WikiTask as K, type LLMProvider as L, type MemoryBundle as M, WikiTransactionError as N, type OntologyManifest as O, type PromptOverrides as P, EmbeddingService as Q, type ReadOptions as R, type SQLiteAdapter as S, ImportExportService as T, IngestionService as U, type VectorRanker as V, type WikiOptions as W, JobManager as X, MaintenanceService as Y, RetrievalService as Z, SearchService as _, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedFactEdge as e, type ExtractedFactWithOntology as f, type ExtractedTask as g, type GraphTraversalOptions as h, ONTOLOGY_BACKFILL_BATCH_SIZE as i, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as j, ONTOLOGY_BACKFILL_RECHECK_MS as k, type OntologyBackfillResult as l, type OntologyConfig as m, type OntologyEdgeType as n, type OntologyMode as o, type OntologyNodeType as p, type OntologyPromptContext as q, type OntologyUpdates as r, PromptService as s, PrunePartialFailureError as t, type VectorRankerFallback as u, type VectorRankerRankArgs as v, type VectorRankerSemanticResult as w, WikiBusyError as x, type WikiBusyOperation as y, type WikiCheckpoint as z };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Q as EmbeddingService, T as ImportExportService, U as IngestionService, X as JobManager, X as JobManagerType, Y as MaintenanceService, Z as RetrievalService, _ as SearchService, _ as SearchServiceType, I as WikiMemoryTestAccess, $ as WriteService } from './testing-
|
|
1
|
+
export { Q as EmbeddingService, T as ImportExportService, U as IngestionService, X as JobManager, X as JobManagerType, Y as MaintenanceService, Z as RetrievalService, _ as SearchService, _ as SearchServiceType, I as WikiMemoryTestAccess, $ as WriteService } from './testing-CBjAuTSl.mjs';
|
|
2
2
|
import 'minisearch';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Q as EmbeddingService, T as ImportExportService, U as IngestionService, X as JobManager, X as JobManagerType, Y as MaintenanceService, Z as RetrievalService, _ as SearchService, _ as SearchServiceType, I as WikiMemoryTestAccess, $ as WriteService } from './testing-
|
|
1
|
+
export { Q as EmbeddingService, T as ImportExportService, U as IngestionService, X as JobManager, X as JobManagerType, Y as MaintenanceService, Z as RetrievalService, _ as SearchService, _ as SearchServiceType, I as WikiMemoryTestAccess, $ as WriteService } from './testing-CBjAuTSl.js';
|
|
2
2
|
import 'minisearch';
|