@equationalapplications/core-llm-wiki 4.14.1 → 4.15.1

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.
@@ -123,6 +123,12 @@ interface WikiFact {
123
123
  last_accessed_at: number | null;
124
124
  access_count: number;
125
125
  deleted_at: number | null;
126
+ /**
127
+ * Verbatim OKF `type:` frontmatter value when this fact originated from (or was
128
+ * re-imported via) an OKF bundle. `null`/`undefined` for facts never touched by
129
+ * OKF import. Distinct from `source_type`, which governs immutability rules.
130
+ */
131
+ okf_type?: string | null;
126
132
  }
127
133
  interface WikiTask {
128
134
  id: string;
@@ -134,6 +140,8 @@ interface WikiTask {
134
140
  updated_at: number;
135
141
  resolved_at: number | null;
136
142
  deleted_at: number | null;
143
+ /** Verbatim OKF `type:` frontmatter value when this task originated from an OKF bundle. */
144
+ okf_type?: string | null;
137
145
  }
138
146
  interface WikiEvent {
139
147
  id: string;
@@ -143,6 +151,14 @@ interface WikiEvent {
143
151
  related_entry_id?: string | null;
144
152
  created_at: number;
145
153
  }
154
+ interface WikiEdge {
155
+ id: string;
156
+ entity_id: string;
157
+ source_id: string;
158
+ target_id: string;
159
+ edge_type: string;
160
+ created_at: number;
161
+ }
146
162
  interface WikiCheckpoint {
147
163
  entity_id: string;
148
164
  heal_checkpoint: number;
@@ -309,6 +325,7 @@ interface MemoryBundle {
309
325
  facts: WikiFact[];
310
326
  tasks: WikiTask[];
311
327
  events: WikiEvent[];
328
+ edges?: WikiEdge[];
312
329
  factScores?: Record<string, number>;
313
330
  metadata?: {
314
331
  query: string;
@@ -952,16 +969,28 @@ declare class MaintenanceService {
952
969
  private _sanitizeRankerError;
953
970
  }
954
971
 
972
+ declare class EdgeRepository extends BaseRepository {
973
+ /**
974
+ * Insert an edge, silently skipping on primary-key or uniqueness conflicts.
975
+ * Throws when the insert was skipped due to an id collision with a different edge tuple.
976
+ */
977
+ addIgnoreDuplicate(edge: WikiEdge, tx?: SQLiteAdapter): Promise<void>;
978
+ getByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiEdge[]>;
979
+ /** Hard delete — edges have no soft-delete concept, only presence/absence. `tx` is REQUIRED. */
980
+ bulkDeleteByEntityId(entityId: string, tx: SQLiteAdapter): Promise<void>;
981
+ }
982
+
955
983
  declare class ImportExportService {
956
984
  private db;
957
985
  private entryRepo;
958
986
  private taskRepo;
959
987
  private eventRepo;
988
+ private edgeRepo;
960
989
  private metadataRepo;
961
990
  private searchService;
962
991
  private jobManager;
963
992
  private embeddingService;
964
- constructor(db: SQLiteAdapter, entryRepo: EntryRepository, taskRepo: TaskRepository, eventRepo: EventRepository, metadataRepo: MetadataRepository, searchService: SearchService, jobManager: JobManager, embeddingService: EmbeddingService);
993
+ constructor(db: SQLiteAdapter, entryRepo: EntryRepository, taskRepo: TaskRepository, eventRepo: EventRepository, edgeRepo: EdgeRepository, metadataRepo: MetadataRepository, searchService: SearchService, jobManager: JobManager, embeddingService: EmbeddingService);
965
994
  exportDump(entityIds?: string[]): Promise<MemoryDump>;
966
995
  importDump(dump: MemoryDump, opts?: {
967
996
  merge?: boolean;
@@ -1050,6 +1079,7 @@ declare class WikiMemory {
1050
1079
  private outboxRepo;
1051
1080
  private taskRepo;
1052
1081
  private eventRepo;
1082
+ private edgeRepo;
1053
1083
  private metadataRepo;
1054
1084
  private embeddingService;
1055
1085
  private searchService;
@@ -1152,4 +1182,4 @@ declare class WikiMemory {
1152
1182
  markOutboxEventsProcessed(eventIds: string[]): Promise<void>;
1153
1183
  }
1154
1184
 
1155
- export { type EntityStatus as E, type FormatContextOptions as F, HOOK_TIMEOUT_MARKER as H, ImportExportService as I, JobManager as J, type LLMProvider as L, type MemoryBundle as M, type PromptOverrides as P, type ReadOptions as R, type SQLiteAdapter as S, type VectorRanker as V, type WikiOptions as W, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedTask as e, PromptService as f, PrunePartialFailureError as g, type VectorRankerFallback as h, type VectorRankerRankArgs as i, type VectorRankerSemanticResult as j, WikiBusyError as k, type WikiBusyOperation as l, type WikiCheckpoint as m, type WikiConfig as n, type WikiEvent as o, type WikiFact as p, type WikiMemoryTestAccess as q, type WikiOutboxEvent as r, type WikiTask as s, EmbeddingService as t, IngestionService as u, MaintenanceService as v, RetrievalService as w, SearchService as x, WriteService as y };
1185
+ export { type EntityStatus as E, type FormatContextOptions as F, HOOK_TIMEOUT_MARKER as H, ImportExportService as I, JobManager as J, type LLMProvider as L, type MemoryBundle as M, type PromptOverrides as P, type ReadOptions as R, type SQLiteAdapter as S, type VectorRanker as V, type WikiOptions as W, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedTask as e, PromptService as f, PrunePartialFailureError as g, type VectorRankerFallback as h, type VectorRankerRankArgs as i, type VectorRankerSemanticResult as j, WikiBusyError as k, type WikiBusyOperation as l, type WikiCheckpoint as m, type WikiConfig as n, type WikiEdge as o, type WikiEvent as p, type WikiFact as q, type WikiMemoryTestAccess as r, type WikiOutboxEvent as s, type WikiTask as t, EmbeddingService as u, IngestionService as v, MaintenanceService as w, RetrievalService as x, SearchService as y, WriteService as z };
@@ -123,6 +123,12 @@ interface WikiFact {
123
123
  last_accessed_at: number | null;
124
124
  access_count: number;
125
125
  deleted_at: number | null;
126
+ /**
127
+ * Verbatim OKF `type:` frontmatter value when this fact originated from (or was
128
+ * re-imported via) an OKF bundle. `null`/`undefined` for facts never touched by
129
+ * OKF import. Distinct from `source_type`, which governs immutability rules.
130
+ */
131
+ okf_type?: string | null;
126
132
  }
127
133
  interface WikiTask {
128
134
  id: string;
@@ -134,6 +140,8 @@ interface WikiTask {
134
140
  updated_at: number;
135
141
  resolved_at: number | null;
136
142
  deleted_at: number | null;
143
+ /** Verbatim OKF `type:` frontmatter value when this task originated from an OKF bundle. */
144
+ okf_type?: string | null;
137
145
  }
138
146
  interface WikiEvent {
139
147
  id: string;
@@ -143,6 +151,14 @@ interface WikiEvent {
143
151
  related_entry_id?: string | null;
144
152
  created_at: number;
145
153
  }
154
+ interface WikiEdge {
155
+ id: string;
156
+ entity_id: string;
157
+ source_id: string;
158
+ target_id: string;
159
+ edge_type: string;
160
+ created_at: number;
161
+ }
146
162
  interface WikiCheckpoint {
147
163
  entity_id: string;
148
164
  heal_checkpoint: number;
@@ -309,6 +325,7 @@ interface MemoryBundle {
309
325
  facts: WikiFact[];
310
326
  tasks: WikiTask[];
311
327
  events: WikiEvent[];
328
+ edges?: WikiEdge[];
312
329
  factScores?: Record<string, number>;
313
330
  metadata?: {
314
331
  query: string;
@@ -952,16 +969,28 @@ declare class MaintenanceService {
952
969
  private _sanitizeRankerError;
953
970
  }
954
971
 
972
+ declare class EdgeRepository extends BaseRepository {
973
+ /**
974
+ * Insert an edge, silently skipping on primary-key or uniqueness conflicts.
975
+ * Throws when the insert was skipped due to an id collision with a different edge tuple.
976
+ */
977
+ addIgnoreDuplicate(edge: WikiEdge, tx?: SQLiteAdapter): Promise<void>;
978
+ getByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiEdge[]>;
979
+ /** Hard delete — edges have no soft-delete concept, only presence/absence. `tx` is REQUIRED. */
980
+ bulkDeleteByEntityId(entityId: string, tx: SQLiteAdapter): Promise<void>;
981
+ }
982
+
955
983
  declare class ImportExportService {
956
984
  private db;
957
985
  private entryRepo;
958
986
  private taskRepo;
959
987
  private eventRepo;
988
+ private edgeRepo;
960
989
  private metadataRepo;
961
990
  private searchService;
962
991
  private jobManager;
963
992
  private embeddingService;
964
- constructor(db: SQLiteAdapter, entryRepo: EntryRepository, taskRepo: TaskRepository, eventRepo: EventRepository, metadataRepo: MetadataRepository, searchService: SearchService, jobManager: JobManager, embeddingService: EmbeddingService);
993
+ constructor(db: SQLiteAdapter, entryRepo: EntryRepository, taskRepo: TaskRepository, eventRepo: EventRepository, edgeRepo: EdgeRepository, metadataRepo: MetadataRepository, searchService: SearchService, jobManager: JobManager, embeddingService: EmbeddingService);
965
994
  exportDump(entityIds?: string[]): Promise<MemoryDump>;
966
995
  importDump(dump: MemoryDump, opts?: {
967
996
  merge?: boolean;
@@ -1050,6 +1079,7 @@ declare class WikiMemory {
1050
1079
  private outboxRepo;
1051
1080
  private taskRepo;
1052
1081
  private eventRepo;
1082
+ private edgeRepo;
1053
1083
  private metadataRepo;
1054
1084
  private embeddingService;
1055
1085
  private searchService;
@@ -1152,4 +1182,4 @@ declare class WikiMemory {
1152
1182
  markOutboxEventsProcessed(eventIds: string[]): Promise<void>;
1153
1183
  }
1154
1184
 
1155
- export { type EntityStatus as E, type FormatContextOptions as F, HOOK_TIMEOUT_MARKER as H, ImportExportService as I, JobManager as J, type LLMProvider as L, type MemoryBundle as M, type PromptOverrides as P, type ReadOptions as R, type SQLiteAdapter as S, type VectorRanker as V, type WikiOptions as W, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedTask as e, PromptService as f, PrunePartialFailureError as g, type VectorRankerFallback as h, type VectorRankerRankArgs as i, type VectorRankerSemanticResult as j, WikiBusyError as k, type WikiBusyOperation as l, type WikiCheckpoint as m, type WikiConfig as n, type WikiEvent as o, type WikiFact as p, type WikiMemoryTestAccess as q, type WikiOutboxEvent as r, type WikiTask as s, EmbeddingService as t, IngestionService as u, MaintenanceService as v, RetrievalService as w, SearchService as x, WriteService as y };
1185
+ export { type EntityStatus as E, type FormatContextOptions as F, HOOK_TIMEOUT_MARKER as H, ImportExportService as I, JobManager as J, type LLMProvider as L, type MemoryBundle as M, type PromptOverrides as P, type ReadOptions as R, type SQLiteAdapter as S, type VectorRanker as V, type WikiOptions as W, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedTask as e, PromptService as f, PrunePartialFailureError as g, type VectorRankerFallback as h, type VectorRankerRankArgs as i, type VectorRankerSemanticResult as j, WikiBusyError as k, type WikiBusyOperation as l, type WikiCheckpoint as m, type WikiConfig as n, type WikiEdge as o, type WikiEvent as p, type WikiFact as q, type WikiMemoryTestAccess as r, type WikiOutboxEvent as s, type WikiTask as t, EmbeddingService as u, IngestionService as v, MaintenanceService as w, RetrievalService as x, SearchService as y, WriteService as z };
@@ -1,2 +1,2 @@
1
- export { t as EmbeddingService, I as ImportExportService, u as IngestionService, J as JobManager, J as JobManagerType, v as MaintenanceService, w as RetrievalService, x as SearchService, x as SearchServiceType, q as WikiMemoryTestAccess, y as WriteService } from './testing-DW1qufP0.mjs';
1
+ export { u as EmbeddingService, I as ImportExportService, v as IngestionService, J as JobManager, J as JobManagerType, w as MaintenanceService, x as RetrievalService, y as SearchService, y as SearchServiceType, r as WikiMemoryTestAccess, z as WriteService } from './testing-NH1_Aigh.mjs';
2
2
  import 'minisearch';
package/dist/testing.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { t as EmbeddingService, I as ImportExportService, u as IngestionService, J as JobManager, J as JobManagerType, v as MaintenanceService, w as RetrievalService, x as SearchService, x as SearchServiceType, q as WikiMemoryTestAccess, y as WriteService } from './testing-DW1qufP0.js';
1
+ export { u as EmbeddingService, I as ImportExportService, v as IngestionService, J as JobManager, J as JobManagerType, w as MaintenanceService, x as RetrievalService, y as SearchService, y as SearchServiceType, r as WikiMemoryTestAccess, z as WriteService } from './testing-NH1_Aigh.js';
2
2
  import 'minisearch';
package/dist/testing.js CHANGED
@@ -374,11 +374,12 @@ var MAX_EMBEDDING_BLOB_BYTES = 32 * 1024;
374
374
  var IMPORT_TITLE_MAX = 500;
375
375
  var IMPORT_BODY_MAX = 8e3;
376
376
  var ImportExportService = class {
377
- constructor(db, entryRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService) {
377
+ constructor(db, entryRepo, taskRepo, eventRepo, edgeRepo, metadataRepo, searchService, jobManager, embeddingService) {
378
378
  this.db = db;
379
379
  this.entryRepo = entryRepo;
380
380
  this.taskRepo = taskRepo;
381
381
  this.eventRepo = eventRepo;
382
+ this.edgeRepo = edgeRepo;
382
383
  this.metadataRepo = metadataRepo;
383
384
  this.searchService = searchService;
384
385
  this.jobManager = jobManager;
@@ -423,10 +424,11 @@ var ImportExportService = class {
423
424
  }
424
425
  }
425
426
  async getFullBundle(entityId, opts) {
426
- const [factsRaw, tasks, events] = await Promise.all([
427
+ const [factsRaw, tasks, events, edges] = await Promise.all([
427
428
  opts?.includeBlobs ? this.entryRepo.findAllByEntityIdWithBlobs(entityId) : this.entryRepo.findAllByEntityId(entityId),
428
429
  this.taskRepo.findAllByEntityId(entityId),
429
- this.eventRepo.getByEntityId(entityId, opts?.maxEvents)
430
+ this.eventRepo.getByEntityId(entityId, opts?.maxEvents),
431
+ this.edgeRepo.getByEntityId(entityId)
430
432
  ]);
431
433
  const facts = factsRaw.map((f) => {
432
434
  const {
@@ -445,7 +447,7 @@ var ImportExportService = class {
445
447
  tags: typeof factBase.tags === "string" ? JSON.parse(factBase.tags) : factBase.tags
446
448
  };
447
449
  });
448
- return { facts, tasks, events };
450
+ return { facts, tasks, events, edges };
449
451
  }
450
452
  /** Single-entity import transaction + post-processing; package-internal hook for tests. */
451
453
  async doImportEntity(entityId, bundle, merge) {
@@ -467,6 +469,7 @@ var ImportExportService = class {
467
469
  softDeletedFactIds.push(...deletedLiveFactIds);
468
470
  await this.entryRepo.bulkSoftDeleteByEntityId(entityId, tx);
469
471
  await this.taskRepo.bulkSoftDeleteByEntityId(entityId, tx);
472
+ await this.edgeRepo.bulkDeleteByEntityId(entityId, tx);
470
473
  await this.metadataRepo.deleteCheckpoint(entityId, tx);
471
474
  }
472
475
  const factIds = bundle.facts.map((fact) => fact.id);
@@ -564,7 +567,8 @@ var ImportExportService = class {
564
567
  last_accessed_at: fact.last_accessed_at,
565
568
  access_count: fact.access_count,
566
569
  deleted_at: fact.deleted_at,
567
- embedding_blob: blobData ?? void 0
570
+ embedding_blob: blobData ?? void 0,
571
+ okf_type: fact.okf_type ?? null
568
572
  };
569
573
  await this.entryRepo.upsertForImport(factObj, tx);
570
574
  if (blobData != null) {
@@ -613,7 +617,8 @@ var ImportExportService = class {
613
617
  created_at: task.created_at,
614
618
  updated_at: safeUpdatedAt,
615
619
  resolved_at: task.resolved_at,
616
- deleted_at: task.deleted_at
620
+ deleted_at: task.deleted_at,
621
+ okf_type: task.okf_type ?? null
617
622
  },
618
623
  tx,
619
624
  safeUpdatedAt
@@ -637,6 +642,19 @@ var ImportExportService = class {
637
642
  tx
638
643
  );
639
644
  }
645
+ for (const edge of bundle.edges ?? []) {
646
+ await this.edgeRepo.addIgnoreDuplicate(
647
+ {
648
+ id: edge.id,
649
+ entity_id: entityId,
650
+ source_id: edge.source_id,
651
+ target_id: edge.target_id,
652
+ edge_type: edge.edge_type,
653
+ created_at: edge.created_at
654
+ },
655
+ tx
656
+ );
657
+ }
640
658
  });
641
659
  await this.searchService.sync(entityId);
642
660
  for (const fact of bundle.facts) {
@@ -1493,7 +1511,7 @@ var RetrievalService = class {
1493
1511
  const sanitizedTierWeights = shouldExposeReadMetadata(entityId) ? sanitizeTierWeights(entityIds, options?.tierWeights) : void 0;
1494
1512
  const exposeMetadata = shouldExposeReadMetadata(entityId);
1495
1513
  if (entityIds.length === 0) {
1496
- const empty = { facts: [], tasks: [], events: [] };
1514
+ const empty = { facts: [], tasks: [], events: [], edges: [] };
1497
1515
  if (exposeMetadata) {
1498
1516
  empty.metadata = { query, entityIds: [] };
1499
1517
  if (sanitizedTierWeights && Object.keys(sanitizedTierWeights).length > 0) empty.metadata.tierWeights = sanitizedTierWeights;
@@ -1883,7 +1901,7 @@ var RetrievalService = class {
1883
1901
  if (exposeMetadata && trimmedQuery && scoreByFactId) {
1884
1902
  factScores = Object.fromEntries(facts.map((fact) => [fact.id, scoreByFactId.get(fact.id) ?? 0]));
1885
1903
  }
1886
- const bundle = { facts, tasks, events: events.reverse() };
1904
+ const bundle = { facts, tasks, events: events.reverse(), edges: [] };
1887
1905
  if (exposeMetadata) {
1888
1906
  bundle.metadata = { query, entityIds };
1889
1907
  if (sanitizedTierWeights && Object.keys(sanitizedTierWeights).length > 0) bundle.metadata.tierWeights = sanitizedTierWeights;