@equationalapplications/core-llm-wiki 4.21.0 → 4.22.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 +1 -0
- package/dist/{chunk-UYLYN5N4.mjs → chunk-LCAU6NYC.mjs} +103 -88
- package/dist/chunk-LCAU6NYC.mjs.map +1 -0
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +41 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-i91HR1TG.d.mts → testing-Bk8J6QLX.d.mts} +1 -1
- package/dist/{testing-i91HR1TG.d.ts → testing-Bk8J6QLX.d.ts} +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-UYLYN5N4.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { E as EntityStatus, d as ExtractedFact, e as ExtractedFactEdge, f as ExtractedFactWithOntology, g as ExtractedTask, h as GraphTraversalOptions, H as HOOK_TIMEOUT_MARKER, L as LLMProvider,
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyManifest, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-Bk8J6QLX.mjs';
|
|
2
|
+
export { E as EntityStatus, d as ExtractedFact, e as ExtractedFactEdge, f as ExtractedFactWithOntology, g as ExtractedTask, h as GraphTraversalOptions, H as HOOK_TIMEOUT_MARKER, L as LLMProvider, i as ONTOLOGY_BACKFILL_BATCH_SIZE, j as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, k as ONTOLOGY_BACKFILL_RECHECK_MS, l as OntologyBackfillResult, m as OntologyConfig, n as OntologyEdgeType, o as OntologyMode, p as OntologyNodeType, q as OntologyPromptContext, r as OntologyUpdates, P as PromptOverrides, s as PromptService, t as PrunePartialFailureError, V as VectorRanker, u as VectorRankerFallback, v as VectorRankerRankArgs, w as VectorRankerSemanticResult, x as WikiBusyError, y as WikiBusyOperation, z as WikiCheckpoint, A as WikiConfig, B as WikiEdge, C as WikiEvent, D as WikiFact, I as WikiMemoryTestAccess, J as WikiOutboxEvent, K as WikiTask, N as WikiTransactionError } from './testing-Bk8J6QLX.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
import 'minisearch';
|
|
5
5
|
|
|
@@ -26,6 +26,8 @@ declare function parseOkfBundle(entityId: string, files: OkfFile[], options?: Ok
|
|
|
26
26
|
|
|
27
27
|
declare function parseEmbedding(blob: Uint8Array | null | undefined, text: string | null | undefined): Float32Array | null;
|
|
28
28
|
|
|
29
|
+
declare function validateManifest(manifest: OntologyManifest): void;
|
|
30
|
+
|
|
29
31
|
type GetRandomValues = (bytes: Uint8Array) => void;
|
|
30
32
|
/**
|
|
31
33
|
* Inject a platform-specific `getRandomValues` implementation.
|
|
@@ -62,4 +64,4 @@ declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classificat
|
|
|
62
64
|
|
|
63
65
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
64
66
|
|
|
65
|
-
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, type LibrarianOptions, type LibrarianPromptVariables, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, type OkfImportOptions, ReadOptions, SQLiteAdapter, WikiMemory, WikiOptions, configureRandomSource, createWiki, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, validateLibrarianPromptTemplate };
|
|
67
|
+
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, type LibrarianOptions, type LibrarianPromptVariables, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, type OkfImportOptions, OntologyManifest, ReadOptions, SQLiteAdapter, WikiMemory, WikiOptions, configureRandomSource, createWiki, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, validateLibrarianPromptTemplate, validateManifest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { E as EntityStatus, d as ExtractedFact, e as ExtractedFactEdge, f as ExtractedFactWithOntology, g as ExtractedTask, h as GraphTraversalOptions, H as HOOK_TIMEOUT_MARKER, L as LLMProvider,
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyManifest, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-Bk8J6QLX.js';
|
|
2
|
+
export { E as EntityStatus, d as ExtractedFact, e as ExtractedFactEdge, f as ExtractedFactWithOntology, g as ExtractedTask, h as GraphTraversalOptions, H as HOOK_TIMEOUT_MARKER, L as LLMProvider, i as ONTOLOGY_BACKFILL_BATCH_SIZE, j as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, k as ONTOLOGY_BACKFILL_RECHECK_MS, l as OntologyBackfillResult, m as OntologyConfig, n as OntologyEdgeType, o as OntologyMode, p as OntologyNodeType, q as OntologyPromptContext, r as OntologyUpdates, P as PromptOverrides, s as PromptService, t as PrunePartialFailureError, V as VectorRanker, u as VectorRankerFallback, v as VectorRankerRankArgs, w as VectorRankerSemanticResult, x as WikiBusyError, y as WikiBusyOperation, z as WikiCheckpoint, A as WikiConfig, B as WikiEdge, C as WikiEvent, D as WikiFact, I as WikiMemoryTestAccess, J as WikiOutboxEvent, K as WikiTask, N as WikiTransactionError } from './testing-Bk8J6QLX.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
import 'minisearch';
|
|
5
5
|
|
|
@@ -26,6 +26,8 @@ declare function parseOkfBundle(entityId: string, files: OkfFile[], options?: Ok
|
|
|
26
26
|
|
|
27
27
|
declare function parseEmbedding(blob: Uint8Array | null | undefined, text: string | null | undefined): Float32Array | null;
|
|
28
28
|
|
|
29
|
+
declare function validateManifest(manifest: OntologyManifest): void;
|
|
30
|
+
|
|
29
31
|
type GetRandomValues = (bytes: Uint8Array) => void;
|
|
30
32
|
/**
|
|
31
33
|
* Inject a platform-specific `getRandomValues` implementation.
|
|
@@ -62,4 +64,4 @@ declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classificat
|
|
|
62
64
|
|
|
63
65
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
64
66
|
|
|
65
|
-
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, type LibrarianOptions, type LibrarianPromptVariables, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, type OkfImportOptions, ReadOptions, SQLiteAdapter, WikiMemory, WikiOptions, configureRandomSource, createWiki, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, validateLibrarianPromptTemplate };
|
|
67
|
+
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, type LibrarianOptions, type LibrarianPromptVariables, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, type OkfImportOptions, OntologyManifest, ReadOptions, SQLiteAdapter, WikiMemory, WikiOptions, configureRandomSource, createWiki, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, validateLibrarianPromptTemplate, validateManifest };
|
package/dist/index.js
CHANGED
|
@@ -1781,10 +1781,13 @@ function resolveNodeType(raw, manifest) {
|
|
|
1781
1781
|
const hit = manifest.node_types.find((n) => n.type.toLowerCase() === slug.toLowerCase());
|
|
1782
1782
|
return hit?.type ?? null;
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1784
|
+
function resolveEdgeDefinitions(rawEdgeType, manifest) {
|
|
1785
1785
|
const slug = rawEdgeType.trim();
|
|
1786
|
-
if (!slug) return
|
|
1787
|
-
return manifest.edge_types.
|
|
1786
|
+
if (!slug) return [];
|
|
1787
|
+
return manifest.edge_types.filter((e) => e.type.toLowerCase() === slug.toLowerCase());
|
|
1788
|
+
}
|
|
1789
|
+
function edgeTripleKey(type, sourceType, targetType) {
|
|
1790
|
+
return `${type.trim().toLowerCase()}|${sourceType.trim().toLowerCase()}|${targetType.trim().toLowerCase()}`;
|
|
1788
1791
|
}
|
|
1789
1792
|
function validateManifest(manifest) {
|
|
1790
1793
|
const nodeSlugs = /* @__PURE__ */ new Set();
|
|
@@ -1795,25 +1798,35 @@ function validateManifest(manifest) {
|
|
|
1795
1798
|
if (nodeSlugs.has(key)) throw new Error(`Duplicate node type: ${type}`);
|
|
1796
1799
|
nodeSlugs.add(key);
|
|
1797
1800
|
}
|
|
1798
|
-
const
|
|
1801
|
+
const edgeKeys = /* @__PURE__ */ new Set();
|
|
1802
|
+
const edgeNames = /* @__PURE__ */ new Map();
|
|
1799
1803
|
for (const edge of manifest.edge_types ?? []) {
|
|
1800
1804
|
const edgeType = edge.type?.trim();
|
|
1801
1805
|
const sourceType = edge.source_type?.trim();
|
|
1802
1806
|
const targetType = edge.target_type?.trim();
|
|
1803
1807
|
if (!edgeType) throw new Error("Ontology edge type slug must be non-empty");
|
|
1804
|
-
const edgeKey = edgeType.toLowerCase();
|
|
1805
|
-
if (edgeSlugs.has(edgeKey)) throw new Error(`Duplicate edge type: ${edgeType}`);
|
|
1806
|
-
edgeSlugs.add(edgeKey);
|
|
1807
1808
|
if (!sourceType || !targetType || !nodeSlugs.has(sourceType.toLowerCase()) || !nodeSlugs.has(targetType.toLowerCase())) {
|
|
1808
1809
|
throw new Error(`Edge type ${edgeType} references unknown node type`);
|
|
1809
1810
|
}
|
|
1811
|
+
const edgeKey = edgeTripleKey(edgeType, sourceType, targetType);
|
|
1812
|
+
if (edgeKeys.has(edgeKey)) {
|
|
1813
|
+
throw new Error(`Duplicate edge definition: ${edgeType} (${sourceType} \u2192 ${targetType})`);
|
|
1814
|
+
}
|
|
1815
|
+
edgeKeys.add(edgeKey);
|
|
1816
|
+
const canonical = edgeNames.get(edgeType.toLowerCase());
|
|
1817
|
+
if (canonical === void 0) {
|
|
1818
|
+
edgeNames.set(edgeType.toLowerCase(), edgeType);
|
|
1819
|
+
} else if (canonical !== edgeType) {
|
|
1820
|
+
throw new Error(`Inconsistent casing for edge type: ${edgeType} conflicts with ${canonical}`);
|
|
1821
|
+
}
|
|
1810
1822
|
}
|
|
1811
1823
|
}
|
|
1812
1824
|
function mergeOntologyUpdates(current, updates) {
|
|
1813
1825
|
const node_types = [...current.node_types];
|
|
1814
1826
|
const edge_types = [...current.edge_types];
|
|
1815
1827
|
const nodeSlugs = new Set(node_types.map((n) => n.type.trim().toLowerCase()));
|
|
1816
|
-
const
|
|
1828
|
+
const edgeKeys = new Set(edge_types.map((e) => edgeTripleKey(e.type, e.source_type, e.target_type)));
|
|
1829
|
+
const edgeNames = new Map(edge_types.map((e) => [e.type.trim().toLowerCase(), e.type.trim()]));
|
|
1817
1830
|
for (const node of updates.node_types ?? []) {
|
|
1818
1831
|
const type = node?.type?.trim();
|
|
1819
1832
|
if (!type) continue;
|
|
@@ -1823,20 +1836,22 @@ function mergeOntologyUpdates(current, updates) {
|
|
|
1823
1836
|
nodeSlugs.add(key);
|
|
1824
1837
|
}
|
|
1825
1838
|
for (const edge of updates.edge_types ?? []) {
|
|
1826
|
-
const
|
|
1839
|
+
const rawEdgeType = edge?.type?.trim();
|
|
1827
1840
|
const sourceType = edge?.source_type?.trim();
|
|
1828
1841
|
const targetType = edge?.target_type?.trim();
|
|
1829
|
-
if (!
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1842
|
+
if (!rawEdgeType || !sourceType || !targetType) continue;
|
|
1843
|
+
const edgeType = edgeNames.get(rawEdgeType.toLowerCase()) ?? rawEdgeType;
|
|
1844
|
+
const edgeKey = edgeTripleKey(edgeType, sourceType, targetType);
|
|
1845
|
+
if (edgeKeys.has(edgeKey)) continue;
|
|
1832
1846
|
if (!nodeSlugs.has(sourceType.toLowerCase()) || !nodeSlugs.has(targetType.toLowerCase())) continue;
|
|
1847
|
+
edgeNames.set(edgeType.toLowerCase(), edgeType);
|
|
1833
1848
|
edge_types.push({
|
|
1834
1849
|
type: edgeType,
|
|
1835
1850
|
source_type: sourceType,
|
|
1836
1851
|
target_type: targetType,
|
|
1837
1852
|
description: String(edge.description ?? "")
|
|
1838
1853
|
});
|
|
1839
|
-
|
|
1854
|
+
edgeKeys.add(edgeKey);
|
|
1840
1855
|
}
|
|
1841
1856
|
return { node_types, edge_types };
|
|
1842
1857
|
}
|
|
@@ -1845,10 +1860,10 @@ function validateInlineEdges(sourceType, _targetType, edges, manifest) {
|
|
|
1845
1860
|
const valid = [];
|
|
1846
1861
|
for (const edge of edges) {
|
|
1847
1862
|
if (typeof edge?.edge_type !== "string" || typeof edge?.target_title !== "string") continue;
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
if (
|
|
1851
|
-
valid.push({ edge_type:
|
|
1863
|
+
const defs = resolveEdgeDefinitions(edge.edge_type, manifest);
|
|
1864
|
+
const match = defs.find((d) => d.source_type.toLowerCase() === sourceType.toLowerCase());
|
|
1865
|
+
if (!match) continue;
|
|
1866
|
+
valid.push({ edge_type: match.type, target_title: edge.target_title });
|
|
1852
1867
|
}
|
|
1853
1868
|
return valid;
|
|
1854
1869
|
}
|
|
@@ -4854,7 +4869,8 @@ var WriteService = class {
|
|
|
4854
4869
|
var FACT_ONTOLOGY_FIELDS = `
|
|
4855
4870
|
Each fact may optionally include:
|
|
4856
4871
|
- "okf_type": string \u2014 must be one of the node_types in the manifest
|
|
4857
|
-
- "edges": [{ "edge_type": string, "target_title": string }] \u2014 target_title must match another fact's title in this response or existing memory
|
|
4872
|
+
- "edges": [{ "edge_type": string, "target_title": string }] \u2014 target_title must match another fact's title in this response or existing memory
|
|
4873
|
+
- 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.`;
|
|
4858
4874
|
var EMERGENT_EXTRA = `
|
|
4859
4875
|
You may also return "ontology_updates" to propose new types:
|
|
4860
4876
|
"ontology_updates": {
|
|
@@ -4939,12 +4955,15 @@ var OntologyService = class {
|
|
|
4939
4955
|
if (!sourceType || edges.length === 0) return 0;
|
|
4940
4956
|
let persisted = 0;
|
|
4941
4957
|
for (const edge of edges) {
|
|
4942
|
-
const
|
|
4943
|
-
if (
|
|
4958
|
+
const candidates = resolveEdgeDefinitions(edge.edge_type, manifest).filter((d) => d.source_type.toLowerCase() === sourceType.toLowerCase());
|
|
4959
|
+
if (candidates.length === 0) continue;
|
|
4944
4960
|
const targetKey = normalizeTitleKey(edge.target_title);
|
|
4945
4961
|
const target = titleIndex.get(targetKey);
|
|
4946
4962
|
if (!target) continue;
|
|
4947
|
-
|
|
4963
|
+
const def = candidates.find(
|
|
4964
|
+
(d) => d.target_type.toLowerCase() === (target.okf_type ?? "").toLowerCase()
|
|
4965
|
+
);
|
|
4966
|
+
if (!def) continue;
|
|
4948
4967
|
const wikiEdge = {
|
|
4949
4968
|
id: generateId(),
|
|
4950
4969
|
entity_id: entityId,
|
|
@@ -6073,5 +6092,6 @@ exports.mapLibrarianOptionsToReadOptions = mapLibrarianOptionsToReadOptions;
|
|
|
6073
6092
|
exports.parseEmbedding = parseEmbedding;
|
|
6074
6093
|
exports.parseOkfBundle = parseOkfBundle;
|
|
6075
6094
|
exports.validateLibrarianPromptTemplate = validateLibrarianPromptTemplate;
|
|
6095
|
+
exports.validateManifest = validateManifest;
|
|
6076
6096
|
//# sourceMappingURL=index.js.map
|
|
6077
6097
|
//# sourceMappingURL=index.js.map
|