@equationalapplications/core-llm-wiki 4.18.0 → 4.19.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 +8 -0
- package/dist/{chunk-V7QNRQFK.mjs → chunk-3GMXRLKU.mjs} +182 -6
- package/dist/chunk-3GMXRLKU.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +31 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -156
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BfxdUHg9.d.mts → testing-DP3lus54.d.mts} +3 -0
- package/dist/{testing-BfxdUHg9.d.ts → testing-DP3lus54.d.ts} +3 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +26 -8
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-V7QNRQFK.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __privateAdd, EmbeddingService, SearchService, JobManager, PromptService, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, normalizeSourceRef, normalizeSourceHash, generateId,
|
|
2
|
-
export { HOOK_TIMEOUT_MARKER, PromptService, PrunePartialFailureError, WikiBusyError, configureRandomSource, parseEmbedding } from './chunk-
|
|
1
|
+
import { __privateAdd, MetadataRepository, EmbeddingService, SearchService, JobManager, PromptService, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, generateId, BaseRepository, emptyManifest, resolveNodeType, validateInlineEdges, resolveEdgeDefinition, normalizeTitleKey } from './chunk-3GMXRLKU.mjs';
|
|
2
|
+
export { HOOK_TIMEOUT_MARKER, PromptService, PrunePartialFailureError, WikiBusyError, configureRandomSource, parseEmbedding } from './chunk-3GMXRLKU.mjs';
|
|
3
3
|
import { appendRelatedSection, buildConceptDocument, buildLogMd, buildEntityIndexMd, buildRootIndexMd, isAllowedOkfPath, parseRootIndexMd, parseEntityIndexMd, parseConcept, splitRelatedSection, extractMarkdownLinks, parseLogMd, parseEventIdComment, appendEventIdComment } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
// src/db/schema.ts
|
|
@@ -215,21 +215,6 @@ for (let i = 1; i < MIGRATIONS.length; i++) {
|
|
|
215
215
|
}
|
|
216
216
|
var CURRENT_SCHEMA_VERSION = MIGRATIONS.length > 0 ? MIGRATIONS[MIGRATIONS.length - 1].version : 0;
|
|
217
217
|
|
|
218
|
-
// src/repositories/BaseRepository.ts
|
|
219
|
-
var BaseRepository = class {
|
|
220
|
-
constructor(db, prefix) {
|
|
221
|
-
this.db = db;
|
|
222
|
-
this.prefix = prefix;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Return the DB executor for a given transaction handle.
|
|
226
|
-
* If tx is provided, use it; otherwise fall back to this.db.
|
|
227
|
-
*/
|
|
228
|
-
getExecutor(tx) {
|
|
229
|
-
return tx ?? this.db;
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
|
|
233
218
|
// src/repositories/EntryRepository.ts
|
|
234
219
|
function mapRowToFact(row) {
|
|
235
220
|
const tags = (() => {
|
|
@@ -1520,144 +1505,6 @@ function mapRowToEdge(row) {
|
|
|
1520
1505
|
};
|
|
1521
1506
|
}
|
|
1522
1507
|
|
|
1523
|
-
// src/repositories/MetadataRepository.ts
|
|
1524
|
-
var MetadataRepository = class extends BaseRepository {
|
|
1525
|
-
// CHECKPOINTS TABLE METHODS
|
|
1526
|
-
async getCheckpoint(entityId, tx) {
|
|
1527
|
-
const executor = this.getExecutor(tx);
|
|
1528
|
-
const row = await executor.getFirstAsync(
|
|
1529
|
-
`SELECT memory_checkpoint, heal_checkpoint FROM ${this.prefix}checkpoints WHERE entity_id = ?`,
|
|
1530
|
-
[entityId]
|
|
1531
|
-
);
|
|
1532
|
-
if (!row) return {};
|
|
1533
|
-
return {
|
|
1534
|
-
memory: row.memory_checkpoint ?? void 0,
|
|
1535
|
-
heal: row.heal_checkpoint ?? void 0
|
|
1536
|
-
};
|
|
1537
|
-
}
|
|
1538
|
-
async updateCheckpoint(entityId, updates, tx) {
|
|
1539
|
-
const fields = [];
|
|
1540
|
-
const values = [];
|
|
1541
|
-
if (updates.memory !== void 0) {
|
|
1542
|
-
fields.push("memory_checkpoint = ?");
|
|
1543
|
-
values.push(updates.memory);
|
|
1544
|
-
}
|
|
1545
|
-
if (updates.heal !== void 0) {
|
|
1546
|
-
fields.push("heal_checkpoint = ?");
|
|
1547
|
-
values.push(updates.heal);
|
|
1548
|
-
}
|
|
1549
|
-
if (fields.length === 0) return;
|
|
1550
|
-
const executor = this.getExecutor(tx);
|
|
1551
|
-
await executor.runAsync(
|
|
1552
|
-
`INSERT INTO ${this.prefix}checkpoints (entity_id, memory_checkpoint, heal_checkpoint)
|
|
1553
|
-
VALUES (?, ?, ?)
|
|
1554
|
-
ON CONFLICT(entity_id) DO UPDATE SET ${fields.join(", ")}`,
|
|
1555
|
-
[entityId, updates.memory ?? 0, updates.heal ?? 0, ...values]
|
|
1556
|
-
);
|
|
1557
|
-
}
|
|
1558
|
-
async deleteCheckpoint(entityId, tx) {
|
|
1559
|
-
const executor = this.getExecutor(tx);
|
|
1560
|
-
await executor.runAsync(
|
|
1561
|
-
`DELETE FROM ${this.prefix}checkpoints WHERE entity_id = ?`,
|
|
1562
|
-
[entityId]
|
|
1563
|
-
);
|
|
1564
|
-
}
|
|
1565
|
-
// META TABLE METHODS
|
|
1566
|
-
async getMeta(key, tx) {
|
|
1567
|
-
const executor = this.getExecutor(tx);
|
|
1568
|
-
const row = await executor.getFirstAsync(
|
|
1569
|
-
`SELECT value FROM ${this.prefix}meta WHERE key = ?`,
|
|
1570
|
-
[key]
|
|
1571
|
-
);
|
|
1572
|
-
return row ? row.value : null;
|
|
1573
|
-
}
|
|
1574
|
-
async setMeta(key, value, tx) {
|
|
1575
|
-
const executor = this.getExecutor(tx);
|
|
1576
|
-
await executor.runAsync(
|
|
1577
|
-
`INSERT INTO ${this.prefix}meta (key, value) VALUES (?, ?)
|
|
1578
|
-
ON CONFLICT(key) DO UPDATE SET value = excluded.value`,
|
|
1579
|
-
[key, value]
|
|
1580
|
-
);
|
|
1581
|
-
}
|
|
1582
|
-
async clearDimensionMismatch(tx) {
|
|
1583
|
-
const executor = this.getExecutor(tx);
|
|
1584
|
-
await executor.runAsync(
|
|
1585
|
-
`DELETE FROM ${this.prefix}meta WHERE key = 'embedding_dimension_mismatch'`
|
|
1586
|
-
);
|
|
1587
|
-
}
|
|
1588
|
-
async tableExists(tableName, tx) {
|
|
1589
|
-
const executor = this.getExecutor(tx);
|
|
1590
|
-
const row = await executor.getFirstAsync(
|
|
1591
|
-
`SELECT name FROM sqlite_master WHERE type='table' AND name=?`,
|
|
1592
|
-
[tableName]
|
|
1593
|
-
);
|
|
1594
|
-
return row != null;
|
|
1595
|
-
}
|
|
1596
|
-
async getTableDdl(tableName, tx) {
|
|
1597
|
-
const executor = this.getExecutor(tx);
|
|
1598
|
-
const row = await executor.getFirstAsync(
|
|
1599
|
-
`SELECT sql FROM sqlite_master WHERE type='table' AND name=?`,
|
|
1600
|
-
[tableName]
|
|
1601
|
-
);
|
|
1602
|
-
return row?.sql ?? null;
|
|
1603
|
-
}
|
|
1604
|
-
async vacuum() {
|
|
1605
|
-
await this.db.execAsync(`PRAGMA wal_checkpoint(TRUNCATE)`);
|
|
1606
|
-
await this.db.execAsync(`VACUUM`);
|
|
1607
|
-
}
|
|
1608
|
-
async getDistinctEntityIds(tx) {
|
|
1609
|
-
const executor = this.getExecutor(tx);
|
|
1610
|
-
const rows = await executor.getAllAsync(
|
|
1611
|
-
`SELECT DISTINCT entity_id FROM (
|
|
1612
|
-
SELECT entity_id FROM ${this.prefix}entries WHERE deleted_at IS NULL
|
|
1613
|
-
UNION
|
|
1614
|
-
SELECT entity_id FROM ${this.prefix}tasks WHERE deleted_at IS NULL
|
|
1615
|
-
UNION
|
|
1616
|
-
SELECT entity_id FROM ${this.prefix}events
|
|
1617
|
-
) ORDER BY entity_id`
|
|
1618
|
-
);
|
|
1619
|
-
return rows.map((r) => r.entity_id);
|
|
1620
|
-
}
|
|
1621
|
-
async getManifest(entityId, tx) {
|
|
1622
|
-
const executor = this.getExecutor(tx);
|
|
1623
|
-
const row = await executor.getFirstAsync(`SELECT mode, manifest_json FROM ${this.prefix}entity_manifests WHERE entity_id = ?`, [entityId]);
|
|
1624
|
-
if (!row) return null;
|
|
1625
|
-
if (row.mode !== "off" && row.mode !== "strict" && row.mode !== "emergent") {
|
|
1626
|
-
throw new Error(`Invalid ontology mode for entity ${entityId}: ${JSON.stringify(row.mode)}`);
|
|
1627
|
-
}
|
|
1628
|
-
let manifest;
|
|
1629
|
-
try {
|
|
1630
|
-
manifest = JSON.parse(row.manifest_json);
|
|
1631
|
-
} catch (error) {
|
|
1632
|
-
throw new Error(`Invalid manifest_json for entity ${entityId}: ${error.message}`);
|
|
1633
|
-
}
|
|
1634
|
-
validateManifest(manifest);
|
|
1635
|
-
return {
|
|
1636
|
-
mode: row.mode,
|
|
1637
|
-
manifest
|
|
1638
|
-
};
|
|
1639
|
-
}
|
|
1640
|
-
async setManifest(entityId, data, tx) {
|
|
1641
|
-
validateManifest(data.manifest);
|
|
1642
|
-
const executor = this.getExecutor(tx);
|
|
1643
|
-
await executor.runAsync(
|
|
1644
|
-
`INSERT INTO ${this.prefix}entity_manifests (entity_id, mode, manifest_json, updated_at)
|
|
1645
|
-
VALUES (?, ?, ?, ?)
|
|
1646
|
-
ON CONFLICT(entity_id) DO UPDATE SET mode = excluded.mode, manifest_json = excluded.manifest_json, updated_at = excluded.updated_at`,
|
|
1647
|
-
[entityId, data.mode, JSON.stringify(data.manifest), Date.now()]
|
|
1648
|
-
);
|
|
1649
|
-
}
|
|
1650
|
-
async mergeManifestUpdates(entityId, updates, tx) {
|
|
1651
|
-
const current = await this.getManifest(entityId, tx) ?? {
|
|
1652
|
-
mode: "emergent",
|
|
1653
|
-
manifest: emptyManifest()
|
|
1654
|
-
};
|
|
1655
|
-
const merged = mergeOntologyUpdates(current.manifest, updates);
|
|
1656
|
-
await this.setManifest(entityId, { mode: current.mode, manifest: merged }, tx);
|
|
1657
|
-
return merged;
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
|
|
1661
1508
|
// src/prompts/ontology.ts
|
|
1662
1509
|
var FACT_ONTOLOGY_FIELDS = `
|
|
1663
1510
|
Each fact may optionally include:
|
|
@@ -2016,6 +1863,10 @@ var WikiMemory = class {
|
|
|
2016
1863
|
async exportDump(entityIds) {
|
|
2017
1864
|
return this.importExportService.exportDump(entityIds);
|
|
2018
1865
|
}
|
|
1866
|
+
/** Entity summary prose persisted from an OKF profile ≥ 1 import; null when none stored. */
|
|
1867
|
+
async getEntitySummary(entityId) {
|
|
1868
|
+
return this.metadataRepo.getMeta(entitySummaryMetaKey(entityId));
|
|
1869
|
+
}
|
|
2019
1870
|
async importDump(dump, opts) {
|
|
2020
1871
|
return this.importExportService.importDump(dump, opts);
|
|
2021
1872
|
}
|
|
@@ -2447,7 +2298,7 @@ function formatOkfBundle(dump) {
|
|
|
2447
2298
|
const targetPath = idToConceptPath.get(edge.target_id);
|
|
2448
2299
|
if (!targetPath) return null;
|
|
2449
2300
|
return { edge_type: edge.edge_type, path: conceptRelativePath(sourcePath, targetPath) };
|
|
2450
|
-
}).filter((link) => link != null)
|
|
2301
|
+
}).filter((link) => link != null);
|
|
2451
2302
|
};
|
|
2452
2303
|
const dir = sanitizeForFilename(entityId);
|
|
2453
2304
|
const factIdToFilename = new Map(
|