@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 CHANGED
@@ -951,6 +951,7 @@ The flowchart shows:
951
951
  | [@equationalapplications/prisma-outbox](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/prisma-outbox/README.md) | Sync SQLite outbox events to Prisma |
952
952
  | [@equationalapplications/core-llm-tools](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/core-llm-tools/README.md) | Gemini tool schemas and capability injector |
953
953
  | [@equationalapplications/core-okf](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/okf/README.md) | Zero-dependency Open Knowledge Format (OKF) v0.1 primitives — parse and produce interoperable knowledge bundles. |
954
+ | [@equationalapplications/schema-org-llm-wiki](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/schema-org/README.md) | Curated schema.org warm-agent ontology manifest |
954
955
 
955
956
  ## License
956
957
 
@@ -109,6 +109,106 @@ function generateId(prefix = "") {
109
109
  );
110
110
  }
111
111
 
112
+ // src/utils/ontology.ts
113
+ function emptyManifest() {
114
+ return { node_types: [], edge_types: [] };
115
+ }
116
+ function normalizeTitleKey(title) {
117
+ return title.trim().toLowerCase().replace(/\s+/g, " ");
118
+ }
119
+ function resolveNodeType(raw, manifest) {
120
+ const slug = raw.trim();
121
+ if (!slug) return null;
122
+ const hit = manifest.node_types.find((n) => n.type.toLowerCase() === slug.toLowerCase());
123
+ return hit?.type ?? null;
124
+ }
125
+ function resolveEdgeDefinitions(rawEdgeType, manifest) {
126
+ const slug = rawEdgeType.trim();
127
+ if (!slug) return [];
128
+ return manifest.edge_types.filter((e) => e.type.toLowerCase() === slug.toLowerCase());
129
+ }
130
+ function edgeTripleKey(type, sourceType, targetType) {
131
+ return `${type.trim().toLowerCase()}|${sourceType.trim().toLowerCase()}|${targetType.trim().toLowerCase()}`;
132
+ }
133
+ function validateManifest(manifest) {
134
+ const nodeSlugs = /* @__PURE__ */ new Set();
135
+ for (const node of manifest.node_types ?? []) {
136
+ const type = node.type?.trim();
137
+ if (!type) throw new Error("Ontology node type slug must be non-empty");
138
+ const key = type.toLowerCase();
139
+ if (nodeSlugs.has(key)) throw new Error(`Duplicate node type: ${type}`);
140
+ nodeSlugs.add(key);
141
+ }
142
+ const edgeKeys = /* @__PURE__ */ new Set();
143
+ const edgeNames = /* @__PURE__ */ new Map();
144
+ for (const edge of manifest.edge_types ?? []) {
145
+ const edgeType = edge.type?.trim();
146
+ const sourceType = edge.source_type?.trim();
147
+ const targetType = edge.target_type?.trim();
148
+ if (!edgeType) throw new Error("Ontology edge type slug must be non-empty");
149
+ if (!sourceType || !targetType || !nodeSlugs.has(sourceType.toLowerCase()) || !nodeSlugs.has(targetType.toLowerCase())) {
150
+ throw new Error(`Edge type ${edgeType} references unknown node type`);
151
+ }
152
+ const edgeKey = edgeTripleKey(edgeType, sourceType, targetType);
153
+ if (edgeKeys.has(edgeKey)) {
154
+ throw new Error(`Duplicate edge definition: ${edgeType} (${sourceType} \u2192 ${targetType})`);
155
+ }
156
+ edgeKeys.add(edgeKey);
157
+ const canonical = edgeNames.get(edgeType.toLowerCase());
158
+ if (canonical === void 0) {
159
+ edgeNames.set(edgeType.toLowerCase(), edgeType);
160
+ } else if (canonical !== edgeType) {
161
+ throw new Error(`Inconsistent casing for edge type: ${edgeType} conflicts with ${canonical}`);
162
+ }
163
+ }
164
+ }
165
+ function mergeOntologyUpdates(current, updates) {
166
+ const node_types = [...current.node_types];
167
+ const edge_types = [...current.edge_types];
168
+ const nodeSlugs = new Set(node_types.map((n) => n.type.trim().toLowerCase()));
169
+ const edgeKeys = new Set(edge_types.map((e) => edgeTripleKey(e.type, e.source_type, e.target_type)));
170
+ const edgeNames = new Map(edge_types.map((e) => [e.type.trim().toLowerCase(), e.type.trim()]));
171
+ for (const node of updates.node_types ?? []) {
172
+ const type = node?.type?.trim();
173
+ if (!type) continue;
174
+ const key = type.toLowerCase();
175
+ if (nodeSlugs.has(key)) continue;
176
+ node_types.push({ type, description: String(node.description ?? "") });
177
+ nodeSlugs.add(key);
178
+ }
179
+ for (const edge of updates.edge_types ?? []) {
180
+ const rawEdgeType = edge?.type?.trim();
181
+ const sourceType = edge?.source_type?.trim();
182
+ const targetType = edge?.target_type?.trim();
183
+ if (!rawEdgeType || !sourceType || !targetType) continue;
184
+ const edgeType = edgeNames.get(rawEdgeType.toLowerCase()) ?? rawEdgeType;
185
+ const edgeKey = edgeTripleKey(edgeType, sourceType, targetType);
186
+ if (edgeKeys.has(edgeKey)) continue;
187
+ if (!nodeSlugs.has(sourceType.toLowerCase()) || !nodeSlugs.has(targetType.toLowerCase())) continue;
188
+ edgeNames.set(edgeType.toLowerCase(), edgeType);
189
+ edge_types.push({
190
+ type: edgeType,
191
+ source_type: sourceType,
192
+ target_type: targetType,
193
+ description: String(edge.description ?? "")
194
+ });
195
+ edgeKeys.add(edgeKey);
196
+ }
197
+ return { node_types, edge_types };
198
+ }
199
+ function validateInlineEdges(sourceType, _targetType, edges, manifest) {
200
+ if (!Array.isArray(edges)) return [];
201
+ const valid = [];
202
+ for (const edge of edges) {
203
+ if (typeof edge?.edge_type !== "string" || typeof edge?.target_title !== "string") continue;
204
+ const defs = resolveEdgeDefinitions(edge.edge_type, manifest);
205
+ const match = defs.find((d) => d.source_type.toLowerCase() === sourceType.toLowerCase());
206
+ if (!match) continue;
207
+ valid.push({ edge_type: match.type, target_title: edge.target_title });
208
+ }
209
+ return valid;
210
+ }
211
+
112
212
  // src/utils/embedding.ts
113
213
  function parseEmbedding(blob, text) {
114
214
  if (blob && blob.byteLength > 0) {
@@ -1012,91 +1112,6 @@ function jaccardScore(a, b) {
1012
1112
  return intersection.size / union.size;
1013
1113
  }
1014
1114
 
1015
- // src/utils/ontology.ts
1016
- function emptyManifest() {
1017
- return { node_types: [], edge_types: [] };
1018
- }
1019
- function normalizeTitleKey(title) {
1020
- return title.trim().toLowerCase().replace(/\s+/g, " ");
1021
- }
1022
- function resolveNodeType(raw, manifest) {
1023
- const slug = raw.trim();
1024
- if (!slug) return null;
1025
- const hit = manifest.node_types.find((n) => n.type.toLowerCase() === slug.toLowerCase());
1026
- return hit?.type ?? null;
1027
- }
1028
- function resolveEdgeDefinition(rawEdgeType, manifest) {
1029
- const slug = rawEdgeType.trim();
1030
- if (!slug) return null;
1031
- return manifest.edge_types.find((e) => e.type.toLowerCase() === slug.toLowerCase()) ?? null;
1032
- }
1033
- function validateManifest(manifest) {
1034
- const nodeSlugs = /* @__PURE__ */ new Set();
1035
- for (const node of manifest.node_types ?? []) {
1036
- const type = node.type?.trim();
1037
- if (!type) throw new Error("Ontology node type slug must be non-empty");
1038
- const key = type.toLowerCase();
1039
- if (nodeSlugs.has(key)) throw new Error(`Duplicate node type: ${type}`);
1040
- nodeSlugs.add(key);
1041
- }
1042
- const edgeSlugs = /* @__PURE__ */ new Set();
1043
- for (const edge of manifest.edge_types ?? []) {
1044
- const edgeType = edge.type?.trim();
1045
- const sourceType = edge.source_type?.trim();
1046
- const targetType = edge.target_type?.trim();
1047
- if (!edgeType) throw new Error("Ontology edge type slug must be non-empty");
1048
- const edgeKey = edgeType.toLowerCase();
1049
- if (edgeSlugs.has(edgeKey)) throw new Error(`Duplicate edge type: ${edgeType}`);
1050
- edgeSlugs.add(edgeKey);
1051
- if (!sourceType || !targetType || !nodeSlugs.has(sourceType.toLowerCase()) || !nodeSlugs.has(targetType.toLowerCase())) {
1052
- throw new Error(`Edge type ${edgeType} references unknown node type`);
1053
- }
1054
- }
1055
- }
1056
- function mergeOntologyUpdates(current, updates) {
1057
- const node_types = [...current.node_types];
1058
- const edge_types = [...current.edge_types];
1059
- const nodeSlugs = new Set(node_types.map((n) => n.type.trim().toLowerCase()));
1060
- const edgeSlugs = new Set(edge_types.map((e) => e.type.trim().toLowerCase()));
1061
- for (const node of updates.node_types ?? []) {
1062
- const type = node?.type?.trim();
1063
- if (!type) continue;
1064
- const key = type.toLowerCase();
1065
- if (nodeSlugs.has(key)) continue;
1066
- node_types.push({ type, description: String(node.description ?? "") });
1067
- nodeSlugs.add(key);
1068
- }
1069
- for (const edge of updates.edge_types ?? []) {
1070
- const edgeType = edge?.type?.trim();
1071
- const sourceType = edge?.source_type?.trim();
1072
- const targetType = edge?.target_type?.trim();
1073
- if (!edgeType || !sourceType || !targetType) continue;
1074
- const edgeKey = edgeType.toLowerCase();
1075
- if (edgeSlugs.has(edgeKey)) continue;
1076
- if (!nodeSlugs.has(sourceType.toLowerCase()) || !nodeSlugs.has(targetType.toLowerCase())) continue;
1077
- edge_types.push({
1078
- type: edgeType,
1079
- source_type: sourceType,
1080
- target_type: targetType,
1081
- description: String(edge.description ?? "")
1082
- });
1083
- edgeSlugs.add(edgeKey);
1084
- }
1085
- return { node_types, edge_types };
1086
- }
1087
- function validateInlineEdges(sourceType, _targetType, edges, manifest) {
1088
- if (!Array.isArray(edges)) return [];
1089
- const valid = [];
1090
- for (const edge of edges) {
1091
- if (typeof edge?.edge_type !== "string" || typeof edge?.target_title !== "string") continue;
1092
- const def = resolveEdgeDefinition(edge.edge_type, manifest);
1093
- if (!def) continue;
1094
- if (def.source_type.toLowerCase() !== sourceType.toLowerCase()) continue;
1095
- valid.push({ edge_type: def.type, target_title: edge.target_title });
1096
- }
1097
- return valid;
1098
- }
1099
-
1100
1115
  // src/services/IngestionService.ts
1101
1116
  var IngestionService = class {
1102
1117
  constructor(db, prefix, options, entryRepo, searchService, jobManager, embeddingService, promptService, ontologyService) {
@@ -3206,6 +3221,6 @@ var WriteService = class {
3206
3221
  }
3207
3222
  };
3208
3223
 
3209
- export { BaseRepository, EmbeddingService, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, WikiBusyError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, configureRandomSource, emptyManifest, entitySummaryMetaKey, extractSqliteCode, generateId, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, parseEmbedding, resolveEdgeDefinition, resolveNodeType, validateInlineEdges };
3210
- //# sourceMappingURL=chunk-UYLYN5N4.mjs.map
3211
- //# sourceMappingURL=chunk-UYLYN5N4.mjs.map
3224
+ export { BaseRepository, EmbeddingService, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, WikiBusyError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, configureRandomSource, emptyManifest, entitySummaryMetaKey, extractSqliteCode, generateId, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, parseEmbedding, resolveEdgeDefinitions, resolveNodeType, validateInlineEdges, validateManifest };
3225
+ //# sourceMappingURL=chunk-LCAU6NYC.mjs.map
3226
+ //# sourceMappingURL=chunk-LCAU6NYC.mjs.map