@equationalapplications/core-llm-wiki 3.2.0 → 4.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/dist/index.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +68 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -60,7 +60,15 @@ interface WikiFact {
|
|
|
60
60
|
body: string;
|
|
61
61
|
tags: string[];
|
|
62
62
|
confidence: 'certain' | 'inferred' | 'tentative';
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Source type of this fact.
|
|
65
|
+
* - 'immutable_document': From ingestDocument(), cannot be modified by system (librarian/heal).
|
|
66
|
+
* Only removable via forget() or replaced via re-ingest.
|
|
67
|
+
* - 'librarian_inferred': Created by runLibrarian() from events, or by runHeal() when synthesizing new inferred facts.
|
|
68
|
+
* - 'user_stated': Direct user statement.
|
|
69
|
+
* - 'user_confirmed': User-confirmed fact.
|
|
70
|
+
*/
|
|
71
|
+
source_type: 'user_stated' | 'librarian_inferred' | 'user_confirmed' | 'immutable_document';
|
|
64
72
|
source_hash: string | null;
|
|
65
73
|
source_ref: string | null;
|
|
66
74
|
created_at: number;
|
|
@@ -358,6 +366,9 @@ declare class WikiMemory {
|
|
|
358
366
|
private _librarianKey;
|
|
359
367
|
private _healKey;
|
|
360
368
|
private _warnCrossEntityCollision;
|
|
369
|
+
/** Maps pre-rename enum strings from older dumps to current source_type values. */
|
|
370
|
+
private _normalizeImportedSourceType;
|
|
371
|
+
private assertNoLegacySourceTypes;
|
|
361
372
|
private _notifyEmbeddingPersisted;
|
|
362
373
|
/**
|
|
363
374
|
* GDPR-critical variant: awaits the hook with a timeout and rethrows failures.
|
|
@@ -470,6 +481,8 @@ declare function formatContext(bundle: MemoryBundle, options?: FormatContextOpti
|
|
|
470
481
|
|
|
471
482
|
declare function formatMemoryDump(dump: MemoryDump): FormattedMemoryDump;
|
|
472
483
|
|
|
484
|
+
declare function parseEmbedding(blob: Uint8Array | null | undefined, text: string | null | undefined): Float32Array | null;
|
|
485
|
+
|
|
473
486
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
474
487
|
|
|
475
|
-
export { type EntityStatus, type ExtractedFact, type ExtractedTask, type FormatContextOptions, type FormattedMemoryDump, type LLMProvider, type MemoryBundle, type MemoryDump, PrunePartialFailureError, type ReadOptions, type SQLiteAdapter, type VectorRanker, type VectorRankerFallback, type VectorRankerRankArgs, type VectorRankerSemanticResult, WikiBusyError, type WikiBusyOperation, type WikiCheckpoint, type WikiConfig, type WikiEvent, type WikiFact, WikiMemory, type WikiOptions, type WikiTask, createWiki, formatContext, formatMemoryDump };
|
|
488
|
+
export { type EntityStatus, type ExtractedFact, type ExtractedTask, type FormatContextOptions, type FormattedMemoryDump, type LLMProvider, type MemoryBundle, type MemoryDump, PrunePartialFailureError, type ReadOptions, type SQLiteAdapter, type VectorRanker, type VectorRankerFallback, type VectorRankerRankArgs, type VectorRankerSemanticResult, WikiBusyError, type WikiBusyOperation, type WikiCheckpoint, type WikiConfig, type WikiEvent, type WikiFact, WikiMemory, type WikiOptions, type WikiTask, createWiki, formatContext, formatMemoryDump, parseEmbedding };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,7 +60,15 @@ interface WikiFact {
|
|
|
60
60
|
body: string;
|
|
61
61
|
tags: string[];
|
|
62
62
|
confidence: 'certain' | 'inferred' | 'tentative';
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Source type of this fact.
|
|
65
|
+
* - 'immutable_document': From ingestDocument(), cannot be modified by system (librarian/heal).
|
|
66
|
+
* Only removable via forget() or replaced via re-ingest.
|
|
67
|
+
* - 'librarian_inferred': Created by runLibrarian() from events, or by runHeal() when synthesizing new inferred facts.
|
|
68
|
+
* - 'user_stated': Direct user statement.
|
|
69
|
+
* - 'user_confirmed': User-confirmed fact.
|
|
70
|
+
*/
|
|
71
|
+
source_type: 'user_stated' | 'librarian_inferred' | 'user_confirmed' | 'immutable_document';
|
|
64
72
|
source_hash: string | null;
|
|
65
73
|
source_ref: string | null;
|
|
66
74
|
created_at: number;
|
|
@@ -358,6 +366,9 @@ declare class WikiMemory {
|
|
|
358
366
|
private _librarianKey;
|
|
359
367
|
private _healKey;
|
|
360
368
|
private _warnCrossEntityCollision;
|
|
369
|
+
/** Maps pre-rename enum strings from older dumps to current source_type values. */
|
|
370
|
+
private _normalizeImportedSourceType;
|
|
371
|
+
private assertNoLegacySourceTypes;
|
|
361
372
|
private _notifyEmbeddingPersisted;
|
|
362
373
|
/**
|
|
363
374
|
* GDPR-critical variant: awaits the hook with a timeout and rethrows failures.
|
|
@@ -470,6 +481,8 @@ declare function formatContext(bundle: MemoryBundle, options?: FormatContextOpti
|
|
|
470
481
|
|
|
471
482
|
declare function formatMemoryDump(dump: MemoryDump): FormattedMemoryDump;
|
|
472
483
|
|
|
484
|
+
declare function parseEmbedding(blob: Uint8Array | null | undefined, text: string | null | undefined): Float32Array | null;
|
|
485
|
+
|
|
473
486
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
474
487
|
|
|
475
|
-
export { type EntityStatus, type ExtractedFact, type ExtractedTask, type FormatContextOptions, type FormattedMemoryDump, type LLMProvider, type MemoryBundle, type MemoryDump, PrunePartialFailureError, type ReadOptions, type SQLiteAdapter, type VectorRanker, type VectorRankerFallback, type VectorRankerRankArgs, type VectorRankerSemanticResult, WikiBusyError, type WikiBusyOperation, type WikiCheckpoint, type WikiConfig, type WikiEvent, type WikiFact, WikiMemory, type WikiOptions, type WikiTask, createWiki, formatContext, formatMemoryDump };
|
|
488
|
+
export { type EntityStatus, type ExtractedFact, type ExtractedTask, type FormatContextOptions, type FormattedMemoryDump, type LLMProvider, type MemoryBundle, type MemoryDump, PrunePartialFailureError, type ReadOptions, type SQLiteAdapter, type VectorRanker, type VectorRankerFallback, type VectorRankerRankArgs, type VectorRankerSemanticResult, WikiBusyError, type WikiBusyOperation, type WikiCheckpoint, type WikiConfig, type WikiEvent, type WikiFact, WikiMemory, type WikiOptions, type WikiTask, createWiki, formatContext, formatMemoryDump, parseEmbedding };
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ async function setupDatabase(db, prefix) {
|
|
|
16
16
|
body TEXT NOT NULL,
|
|
17
17
|
tags TEXT NOT NULL DEFAULT '[]',
|
|
18
18
|
confidence TEXT NOT NULL DEFAULT 'inferred',
|
|
19
|
-
source_type TEXT NOT NULL DEFAULT '
|
|
19
|
+
source_type TEXT NOT NULL DEFAULT 'librarian_inferred',
|
|
20
20
|
source_hash TEXT,
|
|
21
21
|
source_ref TEXT,
|
|
22
22
|
created_at INTEGER NOT NULL,
|
|
@@ -593,6 +593,44 @@ var _WikiMemory = class _WikiMemory {
|
|
|
593
593
|
_warnCrossEntityCollision(type, id, existingEntityId, targetEntityId) {
|
|
594
594
|
console.warn(`[WikiMemory] importDump: ${type} id "${id}" already belongs to entity "${existingEntityId}"; skipping for entity "${targetEntityId}"`);
|
|
595
595
|
}
|
|
596
|
+
/** Maps pre-rename enum strings from older dumps to current source_type values. */
|
|
597
|
+
_normalizeImportedSourceType(raw, ctx) {
|
|
598
|
+
if (raw === "user_document") return "immutable_document";
|
|
599
|
+
if (raw === "agent_inferred") return "librarian_inferred";
|
|
600
|
+
const allowed = ["user_stated", "librarian_inferred", "user_confirmed", "immutable_document"];
|
|
601
|
+
if (allowed.includes(raw)) return raw;
|
|
602
|
+
const where = ctx !== void 0 ? ` for entity "${ctx.entityId}" fact "${ctx.factId}"` : "";
|
|
603
|
+
throw new Error(
|
|
604
|
+
`importDump: invalid source_type "${raw}"${where} (expected one of: ${allowed.join(", ")}, or legacy aliases user_document / agent_inferred)`
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
async assertNoLegacySourceTypes() {
|
|
608
|
+
const legacyProbe = await this.db.getFirstAsync(
|
|
609
|
+
`SELECT 1 AS one FROM ${this.prefix}entries
|
|
610
|
+
WHERE source_type IN ('user_document', 'agent_inferred')
|
|
611
|
+
LIMIT 1`,
|
|
612
|
+
[]
|
|
613
|
+
);
|
|
614
|
+
if (!legacyProbe) return;
|
|
615
|
+
const legacyCount = await this.db.getFirstAsync(
|
|
616
|
+
`SELECT COUNT(*) as count FROM ${this.prefix}entries
|
|
617
|
+
WHERE source_type IN ('user_document', 'agent_inferred')`,
|
|
618
|
+
[]
|
|
619
|
+
);
|
|
620
|
+
const count = legacyCount?.count ?? 0;
|
|
621
|
+
const migrationSQL = `
|
|
622
|
+
-- Migrate legacy source_type values (targets your WikiMemory prefix: ${this.prefix})
|
|
623
|
+
UPDATE ${this.prefix}entries SET source_type = 'immutable_document' WHERE source_type = 'user_document';
|
|
624
|
+
UPDATE ${this.prefix}entries SET source_type = 'librarian_inferred' WHERE source_type = 'agent_inferred';
|
|
625
|
+
`.trim();
|
|
626
|
+
throw new Error(
|
|
627
|
+
`Database contains ${count} entries with legacy source_type values ('user_document' or 'agent_inferred'). These enum values were renamed in this release. Running without migration would allow legacy 'user_document' facts to bypass immutability guards, causing data corruption.
|
|
628
|
+
|
|
629
|
+
${migrationSQL}
|
|
630
|
+
|
|
631
|
+
After running the migration SQL, restart your application.`
|
|
632
|
+
);
|
|
633
|
+
}
|
|
596
634
|
async _notifyEmbeddingPersisted(entityId, factId, vector) {
|
|
597
635
|
if (!this.options.vectorRanker?.onEmbeddingPersisted) return;
|
|
598
636
|
const vectorCopy = vector ? vector.slice() : null;
|
|
@@ -694,6 +732,9 @@ var _WikiMemory = class _WikiMemory {
|
|
|
694
732
|
);
|
|
695
733
|
}
|
|
696
734
|
}
|
|
735
|
+
if (entriesExistedBeforeSetup) {
|
|
736
|
+
await this.assertNoLegacySourceTypes();
|
|
737
|
+
}
|
|
697
738
|
const rows = await this.db.getAllAsync(`
|
|
698
739
|
SELECT rowid, source_ref FROM ${this.prefix}entries
|
|
699
740
|
WHERE source_ref IS NOT NULL
|
|
@@ -830,7 +871,7 @@ var _WikiMemory = class _WikiMemory {
|
|
|
830
871
|
const cutoff = now - retainSoftDeletedFor * 864e5;
|
|
831
872
|
const entriesToDelete = await this.db.getAllAsync(
|
|
832
873
|
`SELECT id, entity_id FROM ${this.prefix}entries
|
|
833
|
-
WHERE entity_id = ? AND deleted_at IS NOT NULL AND deleted_at
|
|
874
|
+
WHERE entity_id = ? AND deleted_at IS NOT NULL AND deleted_at <= ?`,
|
|
834
875
|
[entityId, cutoff]
|
|
835
876
|
);
|
|
836
877
|
const succeeded = [];
|
|
@@ -850,7 +891,7 @@ var _WikiMemory = class _WikiMemory {
|
|
|
850
891
|
const chunk = succeeded.slice(i, i + chunkSize);
|
|
851
892
|
const placeholders = chunk.map(() => "?").join(",");
|
|
852
893
|
const entryResult = await this.db.runAsync(
|
|
853
|
-
`DELETE FROM ${this.prefix}entries WHERE entity_id = ? AND deleted_at IS NOT NULL AND deleted_at
|
|
894
|
+
`DELETE FROM ${this.prefix}entries WHERE entity_id = ? AND deleted_at IS NOT NULL AND deleted_at <= ? AND id IN (${placeholders})`,
|
|
854
895
|
[entityId, cutoff, ...chunk.map((r) => r.id)]
|
|
855
896
|
);
|
|
856
897
|
deletedEntries += entryResult.changes;
|
|
@@ -858,7 +899,7 @@ var _WikiMemory = class _WikiMemory {
|
|
|
858
899
|
}
|
|
859
900
|
const taskResult = await this.db.runAsync(
|
|
860
901
|
`DELETE FROM ${this.prefix}tasks
|
|
861
|
-
WHERE entity_id = ? AND deleted_at IS NOT NULL AND deleted_at
|
|
902
|
+
WHERE entity_id = ? AND deleted_at IS NOT NULL AND deleted_at <= ?`,
|
|
862
903
|
[entityId, cutoff]
|
|
863
904
|
);
|
|
864
905
|
deletedTasks = taskResult.changes;
|
|
@@ -896,7 +937,7 @@ var _WikiMemory = class _WikiMemory {
|
|
|
896
937
|
const cutoff = now - retainEventsFor * 864e5;
|
|
897
938
|
const eventResult = await this.db.runAsync(
|
|
898
939
|
`DELETE FROM ${this.prefix}events
|
|
899
|
-
WHERE entity_id = ? AND created_at
|
|
940
|
+
WHERE entity_id = ? AND created_at <= ?`,
|
|
900
941
|
[entityId, cutoff]
|
|
901
942
|
);
|
|
902
943
|
deletedEvents = eventResult.changes;
|
|
@@ -1597,7 +1638,7 @@ ${JSON.stringify(currentFacts, null, 2)}`;
|
|
|
1597
1638
|
let skip = false;
|
|
1598
1639
|
if (newTokens.size >= MIN_TOKENS_TO_QUALIFY) {
|
|
1599
1640
|
for (const existing of currentFactsRows) {
|
|
1600
|
-
if (existing.source_type !== "
|
|
1641
|
+
if (existing.source_type !== "librarian_inferred") continue;
|
|
1601
1642
|
const existingTokens = titleTokens(existing.title);
|
|
1602
1643
|
if (existingTokens.size >= MIN_TOKENS_TO_QUALIFY) {
|
|
1603
1644
|
if (jaccardScore(newTokens, existingTokens) >= FUZZY_THRESHOLD) {
|
|
@@ -1612,7 +1653,7 @@ ${JSON.stringify(currentFacts, null, 2)}`;
|
|
|
1612
1653
|
await this.db.runAsync(`
|
|
1613
1654
|
INSERT INTO ${this.prefix}entries (id, entity_id, title, body, tags, confidence, source_type, created_at, updated_at)
|
|
1614
1655
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1615
|
-
`, [id, entityId, fact.title, fact.body, JSON.stringify(fact.tags), fact.confidence, "
|
|
1656
|
+
`, [id, entityId, fact.title, fact.body, JSON.stringify(fact.tags), fact.confidence, "librarian_inferred", now, now]);
|
|
1616
1657
|
insertedFacts.push({ id, entity_id: entityId, title: fact.title, body: fact.body, tags: JSON.stringify(fact.tags) });
|
|
1617
1658
|
}
|
|
1618
1659
|
for (const task of validTasks) {
|
|
@@ -1645,25 +1686,25 @@ ${JSON.stringify(currentFacts, null, 2)}`;
|
|
|
1645
1686
|
if (orphanAfterDays !== null) {
|
|
1646
1687
|
const orphanThreshold = now - orphanAfterDays * MS_PER_DAY;
|
|
1647
1688
|
await this.db.runAsync(`
|
|
1648
|
-
UPDATE ${this.prefix}entries
|
|
1649
|
-
SET deleted_at = ?, updated_at = ?
|
|
1650
|
-
WHERE entity_id = ? AND access_count = 0 AND created_at
|
|
1689
|
+
UPDATE ${this.prefix}entries
|
|
1690
|
+
SET deleted_at = ?, updated_at = ?
|
|
1691
|
+
WHERE entity_id = ? AND access_count = 0 AND created_at <= ? AND source_type != 'immutable_document' AND deleted_at IS NULL
|
|
1651
1692
|
`, [now, now, entityId, orphanThreshold]);
|
|
1652
1693
|
}
|
|
1653
1694
|
if (staleInferredAfterDays !== null) {
|
|
1654
1695
|
const staleThreshold = now - staleInferredAfterDays * MS_PER_DAY;
|
|
1655
1696
|
await this.db.runAsync(`
|
|
1656
|
-
UPDATE ${this.prefix}entries
|
|
1657
|
-
SET confidence = 'tentative', updated_at = ?
|
|
1658
|
-
WHERE entity_id = ? AND confidence = 'inferred' AND (last_accessed_at
|
|
1697
|
+
UPDATE ${this.prefix}entries
|
|
1698
|
+
SET confidence = 'tentative', updated_at = ?
|
|
1699
|
+
WHERE entity_id = ? AND confidence = 'inferred' AND (last_accessed_at <= ? OR (last_accessed_at IS NULL AND created_at <= ?)) AND source_type != 'immutable_document' AND deleted_at IS NULL
|
|
1659
1700
|
`, [now, entityId, staleThreshold, staleThreshold]);
|
|
1660
1701
|
}
|
|
1661
1702
|
});
|
|
1662
1703
|
const allFactsRows = await this.db.getAllAsync(`SELECT * FROM ${this.prefix}entries WHERE entity_id = ? AND deleted_at IS NULL`, [entityId]);
|
|
1663
1704
|
const allTasks = await this.db.getAllAsync(`SELECT * FROM ${this.prefix}tasks WHERE entity_id = ? AND status IN ('pending', 'in_progress') AND deleted_at IS NULL`, [entityId]);
|
|
1664
1705
|
const recentEvents = await this.db.getAllAsync(`SELECT * FROM ${this.prefix}events WHERE entity_id = ? ORDER BY created_at DESC LIMIT 20`, [entityId]);
|
|
1665
|
-
const healCandidates = allFactsRows.filter((f) => f.source_type !== "
|
|
1666
|
-
const documentAnchors = allFactsRows.filter((f) => f.source_type === "
|
|
1706
|
+
const healCandidates = allFactsRows.filter((f) => f.source_type !== "immutable_document");
|
|
1707
|
+
const documentAnchors = allFactsRows.filter((f) => f.source_type === "immutable_document").map(({ id, title, source_ref }) => ({ id, title, source_ref }));
|
|
1667
1708
|
const userPrompt = `Heal Candidates:
|
|
1668
1709
|
${JSON.stringify(healCandidates.map((f) => {
|
|
1669
1710
|
const { embedding: _embedding, embedding_blob: _blob, ...rest } = f;
|
|
@@ -1706,7 +1747,7 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
1706
1747
|
await this.db.runAsync(`
|
|
1707
1748
|
INSERT INTO ${this.prefix}entries (id, entity_id, title, body, tags, confidence, source_type, created_at, updated_at)
|
|
1708
1749
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1709
|
-
`, [id, entityId, fact.title, fact.body, JSON.stringify(fact.tags), fact.confidence, "
|
|
1750
|
+
`, [id, entityId, fact.title, fact.body, JSON.stringify(fact.tags), fact.confidence, "librarian_inferred", now, now]);
|
|
1710
1751
|
insertedFacts.push({ id, entity_id: entityId, title: fact.title, body: fact.body, tags: JSON.stringify(fact.tags) });
|
|
1711
1752
|
}
|
|
1712
1753
|
});
|
|
@@ -2006,6 +2047,7 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2006
2047
|
this.activeMaintenanceJobs.add(this._importKey(entityId));
|
|
2007
2048
|
}
|
|
2008
2049
|
try {
|
|
2050
|
+
await this.assertNoLegacySourceTypes();
|
|
2009
2051
|
for (const [entityId, bundle] of Object.entries(dump.entities)) {
|
|
2010
2052
|
await this._doImportEntity(entityId, bundle, merge);
|
|
2011
2053
|
}
|
|
@@ -2059,6 +2101,10 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2059
2101
|
}
|
|
2060
2102
|
}
|
|
2061
2103
|
for (const fact of bundle.facts) {
|
|
2104
|
+
const sourceType = this._normalizeImportedSourceType(String(fact.source_type), {
|
|
2105
|
+
entityId,
|
|
2106
|
+
factId: fact.id
|
|
2107
|
+
});
|
|
2062
2108
|
const tagsJson = JSON.stringify(Array.isArray(fact.tags) ? fact.tags : []);
|
|
2063
2109
|
const safeUpdatedAt = Number.isFinite(fact.updated_at) ? fact.updated_at : 0;
|
|
2064
2110
|
const existing = existingFactsById.get(fact.id);
|
|
@@ -2107,14 +2153,14 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2107
2153
|
if (blobData != null) {
|
|
2108
2154
|
await this.db.runAsync(
|
|
2109
2155
|
`UPDATE ${this.prefix}entries SET entity_id = ?, title = ?, body = ?, tags = ?, confidence = ?, source_type = ?, source_hash = ?, source_ref = ?, created_at = ?, updated_at = ?, last_accessed_at = ?, access_count = ?, deleted_at = ?, embedding_blob = ?, embedding = NULL WHERE id = ?`,
|
|
2110
|
-
[entityId, fact.title, fact.body, tagsJson, fact.confidence,
|
|
2156
|
+
[entityId, fact.title, fact.body, tagsJson, fact.confidence, sourceType, fact.source_hash, fact.source_ref, fact.created_at, safeUpdatedAt, fact.last_accessed_at, fact.access_count, fact.deleted_at, blobData, fact.id]
|
|
2111
2157
|
);
|
|
2112
2158
|
factsWithPreservedBlob.set(fact.id, blobData);
|
|
2113
2159
|
if (!fact.deleted_at) preservedBlobDims.add(blobData.byteLength / 4);
|
|
2114
2160
|
} else {
|
|
2115
2161
|
await this.db.runAsync(
|
|
2116
2162
|
`UPDATE ${this.prefix}entries SET entity_id = ?, title = ?, body = ?, tags = ?, confidence = ?, source_type = ?, source_hash = ?, source_ref = ?, created_at = ?, updated_at = ?, last_accessed_at = ?, access_count = ?, deleted_at = ?, embedding_blob = NULL, embedding = NULL WHERE id = ?`,
|
|
2117
|
-
[entityId, fact.title, fact.body, tagsJson, fact.confidence,
|
|
2163
|
+
[entityId, fact.title, fact.body, tagsJson, fact.confidence, sourceType, fact.source_hash, fact.source_ref, fact.created_at, safeUpdatedAt, fact.last_accessed_at, fact.access_count, fact.deleted_at, fact.id]
|
|
2118
2164
|
);
|
|
2119
2165
|
}
|
|
2120
2166
|
existingFactsById.set(fact.id, { id: fact.id, entity_id: entityId, updated_at: safeUpdatedAt });
|
|
@@ -2124,14 +2170,14 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2124
2170
|
if (blobData != null) {
|
|
2125
2171
|
await this.db.runAsync(
|
|
2126
2172
|
`INSERT INTO ${this.prefix}entries (id, entity_id, title, body, tags, confidence, source_type, source_hash, source_ref, created_at, updated_at, last_accessed_at, access_count, deleted_at, embedding_blob) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
2127
|
-
[fact.id, entityId, fact.title, fact.body, tagsJson, fact.confidence,
|
|
2173
|
+
[fact.id, entityId, fact.title, fact.body, tagsJson, fact.confidence, sourceType, fact.source_hash, fact.source_ref, fact.created_at, safeUpdatedAt, fact.last_accessed_at, fact.access_count, fact.deleted_at, blobData]
|
|
2128
2174
|
);
|
|
2129
2175
|
factsWithPreservedBlob.set(fact.id, blobData);
|
|
2130
2176
|
if (!fact.deleted_at) preservedBlobDims.add(blobData.byteLength / 4);
|
|
2131
2177
|
} else {
|
|
2132
2178
|
await this.db.runAsync(
|
|
2133
2179
|
`INSERT INTO ${this.prefix}entries (id, entity_id, title, body, tags, confidence, source_type, source_hash, source_ref, created_at, updated_at, last_accessed_at, access_count, deleted_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
2134
|
-
[fact.id, entityId, fact.title, fact.body, tagsJson, fact.confidence,
|
|
2180
|
+
[fact.id, entityId, fact.title, fact.body, tagsJson, fact.confidence, sourceType, fact.source_hash, fact.source_ref, fact.created_at, safeUpdatedAt, fact.last_accessed_at, fact.access_count, fact.deleted_at]
|
|
2135
2181
|
);
|
|
2136
2182
|
}
|
|
2137
2183
|
existingFactsById.set(fact.id, { id: fact.id, entity_id: entityId, updated_at: safeUpdatedAt });
|
|
@@ -2478,7 +2524,7 @@ ${chunk}`;
|
|
|
2478
2524
|
await this.db.runAsync(
|
|
2479
2525
|
`INSERT INTO ${this.prefix}entries (id, entity_id, title, body, tags, confidence, source_type, source_hash, source_ref, created_at, updated_at)
|
|
2480
2526
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
2481
|
-
[id, entityId, fact.title, fact.body, JSON.stringify(fact.tags), fact.confidence, "
|
|
2527
|
+
[id, entityId, fact.title, fact.body, JSON.stringify(fact.tags), fact.confidence, "immutable_document", sourceHash, sourceRef, now, now]
|
|
2482
2528
|
);
|
|
2483
2529
|
insertedFacts.push({ id, entity_id: entityId, title: fact.title, body: fact.body, tags: JSON.stringify(fact.tags) });
|
|
2484
2530
|
}
|
|
@@ -2743,5 +2789,6 @@ exports.WikiMemory = WikiMemory;
|
|
|
2743
2789
|
exports.createWiki = createWiki;
|
|
2744
2790
|
exports.formatContext = formatContext;
|
|
2745
2791
|
exports.formatMemoryDump = formatMemoryDump;
|
|
2792
|
+
exports.parseEmbedding = parseEmbedding;
|
|
2746
2793
|
//# sourceMappingURL=index.js.map
|
|
2747
2794
|
//# sourceMappingURL=index.js.map
|