@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
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __privateAdd, MetadataRepository, EmbeddingService, SearchService, JobManager, PromptService, IngestionService, MaintenanceService, ImportExportService, RetrievalService, WriteService, __privateGet, __privateSet, normalizeSourceRef, normalizeSourceHash, entitySummaryMetaKey, generateId, BaseRepository, emptyManifest, resolveNodeType, validateInlineEdges,
|
|
2
|
-
export { HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiTransactionError, 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, resolveEdgeDefinitions, normalizeTitleKey, WikiTransactionError, extractSqliteCode } from './chunk-MYZJLVX4.mjs';
|
|
2
|
+
export { HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiTransactionError, configureRandomSource, parseEmbedding, validateManifest } from './chunk-MYZJLVX4.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
|
|
@@ -602,6 +602,45 @@ var EntryRepository = class extends BaseRepository {
|
|
|
602
602
|
);
|
|
603
603
|
return rows.map(mapRowToFact);
|
|
604
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* Fetch live, mutable entries for an entity — everything heal is allowed to
|
|
607
|
+
* downgrade or delete. Heal previously loaded every row via
|
|
608
|
+
* findAllByEntityId and filtered in JS, which on a document-heavy corpus
|
|
609
|
+
* meant loading 2560 rows to keep 31.
|
|
610
|
+
*/
|
|
611
|
+
async findHealCandidatesByEntityId(entityId, tx) {
|
|
612
|
+
const executor = this.getExecutor(tx);
|
|
613
|
+
const rows = await executor.getAllAsync(
|
|
614
|
+
`SELECT * FROM ${this.prefix}entries
|
|
615
|
+
WHERE entity_id = ? AND deleted_at IS NULL AND source_type != 'immutable_document'
|
|
616
|
+
ORDER BY updated_at DESC`,
|
|
617
|
+
[entityId]
|
|
618
|
+
);
|
|
619
|
+
return rows.map(mapRowToFact);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Resolve search hits to document anchors. The MiniSearch index holds every
|
|
623
|
+
* fact, not only immutable_document rows, so the source-type restriction has
|
|
624
|
+
* to be applied here, after retrieval.
|
|
625
|
+
*/
|
|
626
|
+
async findAnchorRowsByIds(entityId, ids, tx) {
|
|
627
|
+
if (ids.length === 0) return [];
|
|
628
|
+
const executor = this.getExecutor(tx);
|
|
629
|
+
const rows = [];
|
|
630
|
+
for (let i = 0; i < ids.length; i += this.chunkSize) {
|
|
631
|
+
const chunk = ids.slice(i, i + this.chunkSize);
|
|
632
|
+
const placeholders = chunk.map(() => "?").join(", ");
|
|
633
|
+
const chunkRows = await executor.getAllAsync(
|
|
634
|
+
`SELECT id, title, source_ref FROM ${this.prefix}entries
|
|
635
|
+
WHERE entity_id = ? AND deleted_at IS NULL
|
|
636
|
+
AND source_type = 'immutable_document'
|
|
637
|
+
AND id IN (${placeholders})`,
|
|
638
|
+
[entityId, ...chunk]
|
|
639
|
+
);
|
|
640
|
+
rows.push(...chunkRows);
|
|
641
|
+
}
|
|
642
|
+
return rows;
|
|
643
|
+
}
|
|
605
644
|
/**
|
|
606
645
|
* Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
|
|
607
646
|
* Used by MaintenanceService.doRunLibrarian().
|
|
@@ -1643,7 +1682,8 @@ function mapRowToEdge(row) {
|
|
|
1643
1682
|
var FACT_ONTOLOGY_FIELDS = `
|
|
1644
1683
|
Each fact may optionally include:
|
|
1645
1684
|
- "okf_type": string \u2014 must be one of the node_types in the manifest
|
|
1646
|
-
- "edges": [{ "edge_type": string, "target_title": string }] \u2014 target_title must match another fact's title in this response or existing memory
|
|
1685
|
+
- "edges": [{ "edge_type": string, "target_title": string }] \u2014 target_title must match another fact's title in this response or existing memory
|
|
1686
|
+
- An edge_type may appear in the manifest multiple times with different source_type/target_type; use the row whose types match your fact and target.`;
|
|
1647
1687
|
var EMERGENT_EXTRA = `
|
|
1648
1688
|
You may also return "ontology_updates" to propose new types:
|
|
1649
1689
|
"ontology_updates": {
|
|
@@ -1728,12 +1768,15 @@ var OntologyService = class {
|
|
|
1728
1768
|
if (!sourceType || edges.length === 0) return 0;
|
|
1729
1769
|
let persisted = 0;
|
|
1730
1770
|
for (const edge of edges) {
|
|
1731
|
-
const
|
|
1732
|
-
if (
|
|
1771
|
+
const candidates = resolveEdgeDefinitions(edge.edge_type, manifest).filter((d) => d.source_type.toLowerCase() === sourceType.toLowerCase());
|
|
1772
|
+
if (candidates.length === 0) continue;
|
|
1733
1773
|
const targetKey = normalizeTitleKey(edge.target_title);
|
|
1734
1774
|
const target = titleIndex.get(targetKey);
|
|
1735
1775
|
if (!target) continue;
|
|
1736
|
-
|
|
1776
|
+
const def = candidates.find(
|
|
1777
|
+
(d) => d.target_type.toLowerCase() === (target.okf_type ?? "").toLowerCase()
|
|
1778
|
+
);
|
|
1779
|
+
if (!def) continue;
|
|
1737
1780
|
const wikiEdge = {
|
|
1738
1781
|
id: generateId(),
|
|
1739
1782
|
entity_id: entityId,
|