@equationalapplications/core-llm-wiki 9.19.0 → 9.20.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.
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, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-hg6O6N-X.mjs';
2
- export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as IngestTypingCounters, N as LLMProvider, P as LibrarianConfig, Q as LibrarianGateConfig, T as LockedMaintenanceJob, U as MaintenanceJob, V as MaintenanceStopReason, X as MemoryDumpEntity, Y as MigrationPolicy, Z as ONTOLOGY_ABSTAIN_SENTINEL, _ as ONTOLOGY_BACKFILL_BATCH_SIZE, $ as ONTOLOGY_BACKFILL_RECHECK_MS, a0 as OntologyBackfillResult, a1 as OntologyEdgeType, a2 as OntologyManifest, a3 as OntologyNodeType, a4 as OntologyPromptContext, a5 as OntologyUpdates, a6 as PendingMaintenance, a7 as PendingMigrationWork, a8 as PendingSourceStatus, a9 as PromptOverrides, aa as PromptService, ab as PrunePartialFailureError, ac as ReembedResult, ad as RememberInput, ae as RunPendingMaintenanceOptions, af as RunPendingMaintenanceResult, ag as SourcePassage, ah as StoreSourceResult, ai as StoredSource, aj as StoredSourceDump, ak as StoredSourceSummary, al as SupersedeReplacement, am as SystemOneConfig, an as SystemOneThresholdSite, ao as VectorRanker, ap as VectorRankerFallback, aq as VectorRankerRankArgs, ar as VectorRankerSemanticResult, as as WikiBusyError, at as WikiBusyOperation, au as WikiCheckpoint, av as WikiDiagnostic, aw as WikiDiagnosticCode, ax as WikiDiagnosticDetail, ay as WikiDiagnosticOperation, az as WikiDiagnosticSeverity, aA as WikiDiagnosticTrigger, aB as WikiDraftNotFound, aC as WikiDuplicateHashError, aD as WikiEdge, aE as WikiEvent, aF as WikiExternalDeletionError, aG as WikiFact, aH as WikiGraphNodeOwnershipConflict, aI as WikiIngestEmptyError, aJ as WikiInstructions, aK as WikiInvalidReadOptions, aL as WikiLintReport, aM as WikiMemoryTestAccess, aN as WikiMigrationRequiredError, aO as WikiOutboxEvent, aP as WikiParseError, aQ as WikiSearchUnavailableError, aR as WikiSourcePointer, aS as WikiSourceRefHashCollision, aT as WikiStrictOntologyViolation, aU as WikiSupersedeError, aV as WikiSupersedeReason, aW as WikiTask, aX as WikiTransactionError, aY as WriteOntologyPromptContext, aZ as isReservedAbstainSlug, a_ as isWikiSearchUnavailableError, a$ as validateManifest } from './testing-hg6O6N-X.mjs';
1
+ import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-DS_d9qmP.mjs';
2
+ export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as IngestTypingCounters, N as LLMProvider, P as LibrarianConfig, Q as LibrarianGateConfig, T as ListStoredSourcesOptions, U as LockedMaintenanceJob, V as MaintenanceJob, X as MaintenanceStopReason, Y as MemoryDumpEntity, Z as MigrationPolicy, _ as ONTOLOGY_ABSTAIN_SENTINEL, $ as ONTOLOGY_BACKFILL_BATCH_SIZE, a0 as ONTOLOGY_BACKFILL_RECHECK_MS, a1 as OntologyBackfillResult, a2 as OntologyEdgeType, a3 as OntologyManifest, a4 as OntologyNodeType, a5 as OntologyPromptContext, a6 as OntologyUpdates, a7 as PendingMaintenance, a8 as PendingMigrationWork, a9 as PendingSourceStatus, aa as PromptOverrides, ab as PromptService, ac as PrunePartialFailureError, ad as ReembedResult, ae as RememberInput, af as RunPendingMaintenanceOptions, ag as RunPendingMaintenanceResult, ah as SourcePassage, ai as StoreSourceResult, aj as StoredSource, ak as StoredSourceDump, al as StoredSourceSummary, am as SupersedeReplacement, an as SystemOneConfig, ao as SystemOneThresholdSite, ap as VectorRanker, aq as VectorRankerFallback, ar as VectorRankerRankArgs, as as VectorRankerSemanticResult, at as WikiBusyError, au as WikiBusyOperation, av as WikiCheckpoint, aw as WikiDiagnostic, ax as WikiDiagnosticCode, ay as WikiDiagnosticDetail, az as WikiDiagnosticOperation, aA as WikiDiagnosticSeverity, aB as WikiDiagnosticTrigger, aC as WikiDraftNotFound, aD as WikiDuplicateHashError, aE as WikiEdge, aF as WikiEvent, aG as WikiExternalDeletionError, aH as WikiFact, aI as WikiGraphNodeOwnershipConflict, aJ as WikiIngestEmptyError, aK as WikiInstructions, aL as WikiInvalidReadOptions, aM as WikiLintReport, aN as WikiMemoryTestAccess, aO as WikiMigrationRequiredError, aP as WikiOutboxEvent, aQ as WikiParseError, aR as WikiSearchUnavailableError, aS as WikiSourcePointer, aT as WikiSourceRefHashCollision, aU as WikiStrictOntologyViolation, aV as WikiSupersedeError, aW as WikiSupersedeReason, aX as WikiTask, aY as WikiTransactionError, aZ as WriteOntologyPromptContext, a_ as isReservedAbstainSlug, a$ as isWikiSearchUnavailableError, b0 as validateManifest } from './testing-DS_d9qmP.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, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-hg6O6N-X.js';
2
- export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as IngestTypingCounters, N as LLMProvider, P as LibrarianConfig, Q as LibrarianGateConfig, T as LockedMaintenanceJob, U as MaintenanceJob, V as MaintenanceStopReason, X as MemoryDumpEntity, Y as MigrationPolicy, Z as ONTOLOGY_ABSTAIN_SENTINEL, _ as ONTOLOGY_BACKFILL_BATCH_SIZE, $ as ONTOLOGY_BACKFILL_RECHECK_MS, a0 as OntologyBackfillResult, a1 as OntologyEdgeType, a2 as OntologyManifest, a3 as OntologyNodeType, a4 as OntologyPromptContext, a5 as OntologyUpdates, a6 as PendingMaintenance, a7 as PendingMigrationWork, a8 as PendingSourceStatus, a9 as PromptOverrides, aa as PromptService, ab as PrunePartialFailureError, ac as ReembedResult, ad as RememberInput, ae as RunPendingMaintenanceOptions, af as RunPendingMaintenanceResult, ag as SourcePassage, ah as StoreSourceResult, ai as StoredSource, aj as StoredSourceDump, ak as StoredSourceSummary, al as SupersedeReplacement, am as SystemOneConfig, an as SystemOneThresholdSite, ao as VectorRanker, ap as VectorRankerFallback, aq as VectorRankerRankArgs, ar as VectorRankerSemanticResult, as as WikiBusyError, at as WikiBusyOperation, au as WikiCheckpoint, av as WikiDiagnostic, aw as WikiDiagnosticCode, ax as WikiDiagnosticDetail, ay as WikiDiagnosticOperation, az as WikiDiagnosticSeverity, aA as WikiDiagnosticTrigger, aB as WikiDraftNotFound, aC as WikiDuplicateHashError, aD as WikiEdge, aE as WikiEvent, aF as WikiExternalDeletionError, aG as WikiFact, aH as WikiGraphNodeOwnershipConflict, aI as WikiIngestEmptyError, aJ as WikiInstructions, aK as WikiInvalidReadOptions, aL as WikiLintReport, aM as WikiMemoryTestAccess, aN as WikiMigrationRequiredError, aO as WikiOutboxEvent, aP as WikiParseError, aQ as WikiSearchUnavailableError, aR as WikiSourcePointer, aS as WikiSourceRefHashCollision, aT as WikiStrictOntologyViolation, aU as WikiSupersedeError, aV as WikiSupersedeReason, aW as WikiTask, aX as WikiTransactionError, aY as WriteOntologyPromptContext, aZ as isReservedAbstainSlug, a_ as isWikiSearchUnavailableError, a$ as validateManifest } from './testing-hg6O6N-X.js';
1
+ import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-DS_d9qmP.js';
2
+ export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as IngestTypingCounters, N as LLMProvider, P as LibrarianConfig, Q as LibrarianGateConfig, T as ListStoredSourcesOptions, U as LockedMaintenanceJob, V as MaintenanceJob, X as MaintenanceStopReason, Y as MemoryDumpEntity, Z as MigrationPolicy, _ as ONTOLOGY_ABSTAIN_SENTINEL, $ as ONTOLOGY_BACKFILL_BATCH_SIZE, a0 as ONTOLOGY_BACKFILL_RECHECK_MS, a1 as OntologyBackfillResult, a2 as OntologyEdgeType, a3 as OntologyManifest, a4 as OntologyNodeType, a5 as OntologyPromptContext, a6 as OntologyUpdates, a7 as PendingMaintenance, a8 as PendingMigrationWork, a9 as PendingSourceStatus, aa as PromptOverrides, ab as PromptService, ac as PrunePartialFailureError, ad as ReembedResult, ae as RememberInput, af as RunPendingMaintenanceOptions, ag as RunPendingMaintenanceResult, ah as SourcePassage, ai as StoreSourceResult, aj as StoredSource, ak as StoredSourceDump, al as StoredSourceSummary, am as SupersedeReplacement, an as SystemOneConfig, ao as SystemOneThresholdSite, ap as VectorRanker, aq as VectorRankerFallback, ar as VectorRankerRankArgs, as as VectorRankerSemanticResult, at as WikiBusyError, au as WikiBusyOperation, av as WikiCheckpoint, aw as WikiDiagnostic, ax as WikiDiagnosticCode, ay as WikiDiagnosticDetail, az as WikiDiagnosticOperation, aA as WikiDiagnosticSeverity, aB as WikiDiagnosticTrigger, aC as WikiDraftNotFound, aD as WikiDuplicateHashError, aE as WikiEdge, aF as WikiEvent, aG as WikiExternalDeletionError, aH as WikiFact, aI as WikiGraphNodeOwnershipConflict, aJ as WikiIngestEmptyError, aK as WikiInstructions, aL as WikiInvalidReadOptions, aM as WikiLintReport, aN as WikiMemoryTestAccess, aO as WikiMigrationRequiredError, aP as WikiOutboxEvent, aQ as WikiParseError, aR as WikiSearchUnavailableError, aS as WikiSourcePointer, aT as WikiSourceRefHashCollision, aU as WikiStrictOntologyViolation, aV as WikiSupersedeError, aW as WikiSupersedeReason, aX as WikiTask, aY as WikiTransactionError, aZ as WriteOntologyPromptContext, a_ as isReservedAbstainSlug, a$ as isWikiSearchUnavailableError, b0 as validateManifest } from './testing-DS_d9qmP.js';
3
3
  import { OkfFile } from '@equationalapplications/core-okf';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -6814,14 +6814,17 @@ var DEFAULT_MAX_TOTAL_CHARS = 5e6;
6814
6814
  function limitOr(value, fallback) {
6815
6815
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
6816
6816
  }
6817
- function listStoredSourcesSql(prefix) {
6817
+ function listStoredSourcesSql(prefix, paging) {
6818
+ const cursorPredicate = paging?.hasCursor ? "\n AND d.source_ref > ?" : "";
6819
+ const limitClause = paging ? "\n LIMIT ?" : "";
6818
6820
  return `SELECT d.source_ref, d.source_hash, d.char_count, d.created_at,
6819
6821
  (SELECT COUNT(*) FROM ${prefix}source_passages p
6820
6822
  WHERE p.document_id = d.id AND +p.entity_id = d.entity_id) AS passage_count
6821
6823
  FROM ${prefix}source_documents d
6822
- WHERE d.entity_id = ?
6823
- ORDER BY d.source_ref COLLATE BINARY`;
6824
+ WHERE d.entity_id = ?${cursorPredicate}
6825
+ ORDER BY d.source_ref COLLATE BINARY${limitClause}`;
6824
6826
  }
6827
+ var DEFAULT_LIST_PAGE_LIMIT = 200;
6825
6828
  var SourceStoreService = class {
6826
6829
  constructor(db, prefix, options, jobManager) {
6827
6830
  this.db = db;
@@ -6898,9 +6901,48 @@ var SourceStoreService = class {
6898
6901
  storedAt: Number(row.created_at)
6899
6902
  };
6900
6903
  }
6901
- /** Spec §4/§7: full store listing, including sources stored with no ingest. */
6902
- async listStoredSources(entityId) {
6903
- const rows = await this.db.getAllAsync(listStoredSourcesSql(this.prefix), [entityId]);
6904
+ /** Spec source-store-paging §2: point probe — true iff the document row exists for the
6905
+ * normalized ref. Plain read, no write lock, hash-blind: the UNIQUE index on
6906
+ * (entity_id, source_ref) makes one row per pair the only possible state, so a
6907
+ * re-stored changed copy is still stored. Blank/non-string refs return false (no throw). */
6908
+ async hasStoredSource(entityId, sourceRef) {
6909
+ const ref = normalizeSourceRef(sourceRef);
6910
+ if (!ref) return false;
6911
+ const row = await this.db.getFirstAsync(
6912
+ `SELECT id FROM ${this.prefix}source_documents WHERE entity_id = ? AND source_ref = ?`,
6913
+ [entityId, ref]
6914
+ );
6915
+ return row !== void 0 && row !== null;
6916
+ }
6917
+ /** Spec §4/§7: full store listing, including sources stored with no ingest.
6918
+ * With `opts` (spec source-store §7): keyset paging in source_ref
6919
+ * COLLATE BINARY order; validation order opts shape → afterSourceRef →
6920
+ * limit, each a named throw before any query. `Number.isSafeInteger`
6921
+ * subsumes 0/negative/NaN/Infinity/non-number limits. */
6922
+ async listStoredSources(entityId, opts) {
6923
+ let cursor;
6924
+ let limit;
6925
+ if (opts !== void 0) {
6926
+ if (opts === null || typeof opts !== "object" || Array.isArray(opts)) {
6927
+ throw new Error("Invalid opts");
6928
+ }
6929
+ if (opts.afterSourceRef !== void 0) {
6930
+ const normalized = normalizeSourceRef(opts.afterSourceRef);
6931
+ if (!normalized) throw new Error("Invalid afterSourceRef");
6932
+ cursor = normalized;
6933
+ }
6934
+ if (opts.limit !== void 0) {
6935
+ const raw = opts.limit;
6936
+ if (typeof raw !== "number" || !Number.isSafeInteger(raw) || raw < 1) {
6937
+ throw new Error("Invalid limit");
6938
+ }
6939
+ limit = raw;
6940
+ }
6941
+ }
6942
+ const paging = cursor !== void 0 || limit !== void 0;
6943
+ const sql = listStoredSourcesSql(this.prefix, paging ? { hasCursor: cursor !== void 0 } : void 0);
6944
+ const bindings = paging ? cursor !== void 0 ? [entityId, cursor, limit ?? DEFAULT_LIST_PAGE_LIMIT] : [entityId, limit ?? DEFAULT_LIST_PAGE_LIMIT] : [entityId];
6945
+ const rows = await this.db.getAllAsync(sql, bindings);
6904
6946
  return rows.map((r) => ({
6905
6947
  sourceRef: r.source_ref,
6906
6948
  sourceHash: r.source_hash,
@@ -18029,9 +18071,14 @@ var WikiMemory = class {
18029
18071
  assertEntityId2(entityId);
18030
18072
  return this.sourceStoreService.getStoredSource(entityId, sourceRef);
18031
18073
  }
18032
- async listStoredSources(entityId) {
18074
+ async listStoredSources(entityId, opts) {
18075
+ assertEntityId2(entityId);
18076
+ return this.sourceStoreService.listStoredSources(entityId, opts);
18077
+ }
18078
+ /** Spec source-store-paging §2: point probe passthrough; a bad entityId throws here, never a silent false. */
18079
+ async hasStoredSource(entityId, sourceRef) {
18033
18080
  assertEntityId2(entityId);
18034
- return this.sourceStoreService.listStoredSources(entityId);
18081
+ return this.sourceStoreService.hasStoredSource(entityId, sourceRef);
18035
18082
  }
18036
18083
  /**
18037
18084
  * End `oldId`'s validity and link it to its replacement (spec §4.3). One