@equationalapplications/core-llm-wiki 7.18.0 → 8.0.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/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-DRB-65AM.mjs';
2
- export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-DRB-65AM.mjs';
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-De-WJ7xh.mjs';
2
+ export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-De-WJ7xh.mjs';
3
3
  import { OkfFile } from '@equationalapplications/core-okf';
4
4
 
5
5
  /**
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-DRB-65AM.js';
2
- export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-DRB-65AM.js';
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-De-WJ7xh.js';
2
+ export { C as ChunkFailure, d as ClassifierAnswer, e as ClassifierQuestion, f as ClassifyRequest, g as ClassifyResponse, D as DegradedRecord, h as DraftPage, E as EmbedFactResult, i as EmbedFailureKind, j as EmbeddingMarkerKind, k as EntityMaintenanceReport, l as EntityStatus, m as ExtractedFact, n as ExtractedFactEdge, o as ExtractedFactWithOntology, p as ExtractedTask, q as GraphTraversalOptions, r as GroundingConfig, H as HEAL_BATCH_SIZE, s as HEAL_RECHECK_MS, t as HOOK_TIMEOUT_MARKER, u as HealResult, I as IngestDocumentResult, L as LLMProvider, v as LibrarianConfig, w as LibrarianGateConfig, x as MaintenanceJob, y as MaintenanceStopReason, z as MigrationPolicy, O as ONTOLOGY_BACKFILL_BATCH_SIZE, A as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, B as ONTOLOGY_BACKFILL_RECHECK_MS, J as OntologyBackfillResult, K as OntologyConfig, N as OntologyEdgeType, P as OntologyManifest, Q as OntologyMode, T as OntologyNodeType, U as OntologyPromptContext, V as OntologyUpdates, X as PendingMaintenance, Y as PendingMigrationWork, Z as PendingSourceStatus, _ as PromptOverrides, $ as PromptService, a0 as PrunePartialFailureError, a1 as ReembedResult, a2 as RememberInput, a3 as RunPendingMaintenanceOptions, a4 as RunPendingMaintenanceResult, a5 as SupersedeReplacement, a6 as VectorRanker, a7 as VectorRankerFallback, a8 as VectorRankerRankArgs, a9 as VectorRankerSemanticResult, aa as WikiBusyError, ab as WikiBusyOperation, ac as WikiCheckpoint, ad as WikiConfig, ae as WikiDiagnostic, af as WikiDiagnosticCode, ag as WikiDiagnosticDetail, ah as WikiDiagnosticOperation, ai as WikiDiagnosticSeverity, aj as WikiDiagnosticTrigger, ak as WikiDraftNotFound, al as WikiDuplicateHashError, am as WikiEdge, an as WikiEvent, ao as WikiFact, ap as WikiGraphNodeOwnershipConflict, aq as WikiIngestEmptyError, ar as WikiInstructions, as as WikiInvalidReadOptions, at as WikiLintReport, au as WikiMemoryTestAccess, av as WikiMigrationRequiredError, aw as WikiOutboxEvent, ax as WikiParseError, ay as WikiSearchUnavailableError, az as WikiSourceRefHashCollision, aA as WikiStrictOntologyViolation, aB as WikiSupersedeError, aC as WikiSupersedeReason, aD as WikiTask, aE as WikiTransactionError, aF as isWikiSearchUnavailableError, aG as validateManifest } from './testing-De-WJ7xh.js';
3
3
  import { OkfFile } from '@equationalapplications/core-okf';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -6352,11 +6352,11 @@ ${JSON.stringify({ items })}` };
6352
6352
  * placeholders and leaves data placeholders verbatim; heal never receives
6353
6353
  * ontology context, matching `buildHealPrompt`.
6354
6354
  */
6355
- buildInstructionTemplates(ontologyContext) {
6355
+ buildInstructionTemplates(ontologyContext, librarianStrategy) {
6356
6356
  const o = this.globalOverrides;
6357
6357
  return {
6358
6358
  ingest: this.appendGrounding(this.buildSystemPrompt(o?.ingestSystemPrompt ?? INGEST_SYSTEM_PROMPT, {}, ontologyContext), "ingest"),
6359
- librarian: this.appendGrounding(this.buildSystemPrompt(o?.librarianSystemPrompt ?? LIBRARIAN_SYSTEM_PROMPT, {}, ontologyContext), "librarian"),
6359
+ librarian: librarianStrategy === "ops" ? this.appendGrounding(this.appendOntology(OPS_EXTRACT_SYSTEM_PROMPT, ontologyContext), "librarian") : this.appendGrounding(this.buildSystemPrompt(o?.librarianSystemPrompt ?? LIBRARIAN_SYSTEM_PROMPT, {}, ontologyContext), "librarian"),
6360
6360
  heal: this.appendGrounding(o?.healSystemPrompt ?? HEAL_SYSTEM_PROMPT, "heal"),
6361
6361
  ontologyBackfill: this.buildSystemPrompt(o?.ontologyBackfillSystemPrompt ?? ONTOLOGY_BACKFILL_SYSTEM_PROMPT, {}, ontologyContext)
6362
6362
  };
@@ -7174,6 +7174,44 @@ function classifierStateForFact(fact) {
7174
7174
  return parts.join("\n\n");
7175
7175
  }
7176
7176
 
7177
+ // src/utils/engineDefaults.ts
7178
+ var DEFAULT_LIBRARIAN_STRATEGY = "ops";
7179
+ var DEFAULT_MAINTENANCE_MODE = "deferred";
7180
+ function resolveLibrarianStrategy(config) {
7181
+ return config?.librarian?.strategy ?? DEFAULT_LIBRARIAN_STRATEGY;
7182
+ }
7183
+ function resolveMaintenanceMode(config) {
7184
+ return config?.maintenance ?? DEFAULT_MAINTENANCE_MODE;
7185
+ }
7186
+ function changedDefaultWarnings(config) {
7187
+ const warnings = [];
7188
+ const hasThreshold = config?.autoLibrarianThreshold !== void 0 || config?.autoHealThreshold !== void 0 || config?.autoLibrarianTokenThreshold !== void 0;
7189
+ if (hasThreshold && config?.maintenance === void 0) {
7190
+ warnings.push(
7191
+ "[core-llm-wiki] auto-run thresholds are set, but `maintenance` now defaults to 'deferred', so write() will not start the librarian or heal. Set `maintenance: 'auto'` or call runPendingMaintenance()."
7192
+ );
7193
+ }
7194
+ if (config?.prompts?.librarianSystemPrompt !== void 0 && config?.librarian?.strategy === void 0) {
7195
+ warnings.push(
7196
+ "[core-llm-wiki] `prompts.librarianSystemPrompt` is set, but `librarian.strategy` now defaults to 'ops', which does not use it. Set `librarian: { strategy: 'legacy' }` to keep the override."
7197
+ );
7198
+ }
7199
+ if (config?.librarian?.strategy === "legacy" && config?.maintenance === void 0 && !hasThreshold) {
7200
+ warnings.push(
7201
+ "[core-llm-wiki] `librarian.strategy` is pinned to 'legacy', but `maintenance` now defaults to 'deferred', so write() will not start the librarian or heal, and a deferred backlog run keeps only the newest 50 events. Set `maintenance: 'auto'` to keep 7.x auto-run behavior."
7202
+ );
7203
+ }
7204
+ return warnings;
7205
+ }
7206
+ var warnedDefaults = /* @__PURE__ */ new Set();
7207
+ function warnChangedDefaultsOnce(config) {
7208
+ for (const message of changedDefaultWarnings(config)) {
7209
+ if (warnedDefaults.has(message)) continue;
7210
+ warnedDefaults.add(message);
7211
+ console.warn(message);
7212
+ }
7213
+ }
7214
+
7177
7215
  // src/services/BoundedLlmCall.ts
7178
7216
  var DEFAULT_BATCH_SIZE = 10;
7179
7217
  var ESTIMATED_OUTPUT_TOKENS_PER_ITEM = 150;
@@ -8056,7 +8094,7 @@ var STRATEGIES = /* @__PURE__ */ new Map([
8056
8094
  ["ops", runOpsLibrarianPass]
8057
8095
  ]);
8058
8096
  async function runLibrarianStrategy(deps, ctx) {
8059
- const strategy = deps.options.config?.librarian?.strategy ?? "legacy";
8097
+ const strategy = resolveLibrarianStrategy(deps.options.config);
8060
8098
  const fn = STRATEGIES.get(strategy);
8061
8099
  if (!fn) {
8062
8100
  throw new Error(`Unknown librarian strategy: ${strategy}`);
@@ -8205,7 +8243,7 @@ var MaintenanceService = class {
8205
8243
  }
8206
8244
  if (retainEventsFor !== null) {
8207
8245
  const cutoff = now - retainEventsFor * 864e5;
8208
- const guarded = this.options.config?.maintenance === "deferred" || this.options.config?.librarian?.strategy === "ops";
8246
+ const guarded = resolveMaintenanceMode(this.options.config) === "deferred" || resolveLibrarianStrategy(this.options.config) === "ops";
8209
8247
  if (guarded) {
8210
8248
  const wm = await this.metadataRepo.getLibrarianWatermark(entityId, this.db);
8211
8249
  deletedEvents = (await this.eventRepo.pruneThrough(entityId, cutoff, wm)).changes;
@@ -10900,7 +10938,7 @@ var WriteService = class {
10900
10938
  created_at: now,
10901
10939
  occurred_at: occurredAt
10902
10940
  };
10903
- const deferred = this.options.config?.maintenance === "deferred";
10941
+ const deferred = resolveMaintenanceMode(this.options.config) === "deferred";
10904
10942
  if (deferred) {
10905
10943
  await this.eventRepo.add(newEvent);
10906
10944
  return;
@@ -11601,32 +11639,6 @@ var RememberService = class {
11601
11639
  }
11602
11640
  };
11603
11641
 
11604
- // src/utils/upgradeNotice.ts
11605
- function upcomingDefaultsWarning(config) {
11606
- const strategyUnset = config?.librarian?.strategy === void 0;
11607
- const maintenanceUnset = config?.maintenance === void 0;
11608
- if (!strategyUnset && !maintenanceUnset) return null;
11609
- const unset = [];
11610
- const keep = [];
11611
- if (strategyUnset) {
11612
- unset.push("`librarian.strategy` (default becomes 'ops')");
11613
- keep.push("`librarian: { strategy: 'legacy' }`");
11614
- }
11615
- if (maintenanceUnset) {
11616
- unset.push("`maintenance` (default becomes 'deferred')");
11617
- keep.push("`maintenance: 'auto'`");
11618
- }
11619
- const deferredNote = maintenanceUnset ? " Under 'deferred', the auto-run thresholds stop applying and nothing runs until the host calls runPendingMaintenance()." : "";
11620
- return `[core-llm-wiki] 8.0.0 changes engine defaults, and this config does not set ${unset.join(" or ")}.${deferredNote} To keep today's behavior, set ${keep.join(" and ")}.`;
11621
- }
11622
- var warned = /* @__PURE__ */ new Set();
11623
- function warnUpcomingDefaultsOnce(config) {
11624
- const message = upcomingDefaultsWarning(config);
11625
- if (message === null || warned.has(message)) return;
11626
- warned.add(message);
11627
- console.warn(message);
11628
- }
11629
-
11630
11642
  // src/WikiMemory.ts
11631
11643
  var TABLE_PREFIX_PATTERN = /^[A-Za-z][A-Za-z0-9_]{0,30}_$/;
11632
11644
  var SEARCH_REINIT_COOLDOWN_MS = 5e3;
@@ -11663,13 +11675,13 @@ var WikiMemory = class {
11663
11675
  this.reinitFailures = 0;
11664
11676
  this.db = withSerializedTransactions(db);
11665
11677
  this.options = options;
11678
+ warnChangedDefaultsOnce(options.config);
11666
11679
  this.prefix = options.config?.tablePrefix ?? "llm_wiki_";
11667
11680
  if (!TABLE_PREFIX_PATTERN.test(this.prefix)) {
11668
11681
  throw new Error(
11669
11682
  `Invalid tablePrefix: ${JSON.stringify(this.prefix)}. Must match ${TABLE_PREFIX_PATTERN} (letter, then alphanumeric/underscore, ending in "_", max 32 chars total).`
11670
11683
  );
11671
11684
  }
11672
- warnUpcomingDefaultsOnce(options.config);
11673
11685
  this.outboxRepo = new OutboxRepository(this.db, this.prefix, !!options.config?.enableOutbox);
11674
11686
  this.entryRepo = new EntryRepository(this.db, this.prefix, this.outboxRepo);
11675
11687
  this.sourceRefIndexRepo = new SourceRefIndexRepository(this.db, this.prefix);
@@ -11993,7 +12005,7 @@ var WikiMemory = class {
11993
12005
  async getInstructions(entityId) {
11994
12006
  assertEntityId2(entityId);
11995
12007
  const ontologyContext = await this.ontologyService.buildPromptContext(entityId);
11996
- return this.promptService.buildInstructionTemplates(ontologyContext);
12008
+ return this.promptService.buildInstructionTemplates(ontologyContext, resolveLibrarianStrategy(this.options.config));
11997
12009
  }
11998
12010
  /**
11999
12011
  * Returns the live source_refs for an entity, one row per ref, with the most