@equationalapplications/core-llm-wiki 9.13.0 → 9.14.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/{chunk-4TG7RQF6.mjs → chunk-2FCE7ZAC.mjs} +124 -12
- package/dist/chunk-2FCE7ZAC.mjs.map +1 -0
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +123 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-DkKZcrhE.d.mts → testing-BclOvn3q.d.mts} +52 -8
- package/dist/{testing-DkKZcrhE.d.ts → testing-BclOvn3q.d.ts} +52 -8
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +121 -9
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-4TG7RQF6.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, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-
|
|
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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-
|
|
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-BclOvn3q.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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-BclOvn3q.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -272,10 +272,25 @@ declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): numb
|
|
|
272
272
|
* The floor is mandatory because a wrong NOOP drops a live fact.
|
|
273
273
|
*/
|
|
274
274
|
declare function resolveResolveMinConfidence(config: WikiConfig | undefined): number | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* Heal-screen mode resolution (specs/heal-screening-system-one §2):
|
|
277
|
+
* `systemOne.healScreen` → `'llm'`. A present non-`'auto'`/non-`'llm'` value
|
|
278
|
+
* warns once and is treated as unset. No legacy chain and no call option.
|
|
279
|
+
*/
|
|
280
|
+
declare function resolveSystemOneHealScreen(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
281
|
+
/**
|
|
282
|
+
* Heal-screen floor (specs/heal-screening-system-one §3): returns the
|
|
283
|
+
* `systemOne.minConfidence.healScreen` floor only when the heal-screen mode
|
|
284
|
+
* resolves `'auto'` and the floor is a finite number in [0.5, 1]. There is no
|
|
285
|
+
* default floor: a missing or out-of-domain value warns once and returns
|
|
286
|
+
* `undefined` (the site then resolves `'llm'`). Under `'llm'` or unset it
|
|
287
|
+
* reads nothing.
|
|
288
|
+
*/
|
|
289
|
+
declare function resolveHealScreenMinConfidence(config: WikiConfig | undefined): number | undefined;
|
|
275
290
|
|
|
276
291
|
declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classification agent. You will receive existing memory facts that currently have no ontology type. For each input fact { \"id\", \"title\", \"body\", \"tags\" }, assign the best matching okf_type from the ontology manifest and optionally propose edges to related facts by title.\nReturn ONLY a valid JSON object matching this schema:\n{\n \"classifications\": [\n { \"id\": \"string (input fact id, copied verbatim)\", \"okf_type\": \"string (manifest node type slug)\", \"edges\": [{ \"edge_type\": \"string\", \"target_title\": \"string\" }] }\n ]\n}\nIf no manifest type fits a fact, assign the closest type the fact is an example of; omit that fact from \"classifications\" only when no type applies even broadly. Use the manifest slug EXACTLY as spelled (spelling variants are folded to the manifest form).\nWhen echoing an existing fact's title verbatim into \"target_title\", preserve every JSON escape sequence (\\\", \\n, \\\\, \\/) exactly as it appeared in the input body \u2014 do not strip backslashes, do not add unescaped quotes. Do not return markdown, just raw JSON.";
|
|
277
292
|
|
|
278
293
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
279
294
|
|
|
280
|
-
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneResolve, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
295
|
+
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
281
296
|
export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|
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-
|
|
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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-
|
|
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-BclOvn3q.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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-BclOvn3q.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -272,10 +272,25 @@ declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): numb
|
|
|
272
272
|
* The floor is mandatory because a wrong NOOP drops a live fact.
|
|
273
273
|
*/
|
|
274
274
|
declare function resolveResolveMinConfidence(config: WikiConfig | undefined): number | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* Heal-screen mode resolution (specs/heal-screening-system-one §2):
|
|
277
|
+
* `systemOne.healScreen` → `'llm'`. A present non-`'auto'`/non-`'llm'` value
|
|
278
|
+
* warns once and is treated as unset. No legacy chain and no call option.
|
|
279
|
+
*/
|
|
280
|
+
declare function resolveSystemOneHealScreen(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
281
|
+
/**
|
|
282
|
+
* Heal-screen floor (specs/heal-screening-system-one §3): returns the
|
|
283
|
+
* `systemOne.minConfidence.healScreen` floor only when the heal-screen mode
|
|
284
|
+
* resolves `'auto'` and the floor is a finite number in [0.5, 1]. There is no
|
|
285
|
+
* default floor: a missing or out-of-domain value warns once and returns
|
|
286
|
+
* `undefined` (the site then resolves `'llm'`). Under `'llm'` or unset it
|
|
287
|
+
* reads nothing.
|
|
288
|
+
*/
|
|
289
|
+
declare function resolveHealScreenMinConfidence(config: WikiConfig | undefined): number | undefined;
|
|
275
290
|
|
|
276
291
|
declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classification agent. You will receive existing memory facts that currently have no ontology type. For each input fact { \"id\", \"title\", \"body\", \"tags\" }, assign the best matching okf_type from the ontology manifest and optionally propose edges to related facts by title.\nReturn ONLY a valid JSON object matching this schema:\n{\n \"classifications\": [\n { \"id\": \"string (input fact id, copied verbatim)\", \"okf_type\": \"string (manifest node type slug)\", \"edges\": [{ \"edge_type\": \"string\", \"target_title\": \"string\" }] }\n ]\n}\nIf no manifest type fits a fact, assign the closest type the fact is an example of; omit that fact from \"classifications\" only when no type applies even broadly. Use the manifest slug EXACTLY as spelled (spelling variants are folded to the manifest form).\nWhen echoing an existing fact's title verbatim into \"target_title\", preserve every JSON escape sequence (\\\", \\n, \\\\, \\/) exactly as it appeared in the input body \u2014 do not strip backslashes, do not add unescaped quotes. Do not return markdown, just raw JSON.";
|
|
277
292
|
|
|
278
293
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
279
294
|
|
|
280
|
-
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneResolve, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
295
|
+
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
281
296
|
export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ var SEVERITY = {
|
|
|
26
26
|
hook_failed: "warn",
|
|
27
27
|
background_job_failed: "error",
|
|
28
28
|
heal_skipped: "warn",
|
|
29
|
+
heal_deleted: "info",
|
|
30
|
+
heal_downgraded: "info",
|
|
29
31
|
grounding_missing: "warn",
|
|
30
32
|
grounding_failed: "warn",
|
|
31
33
|
classification_low_confidence: "info",
|
|
@@ -79,6 +81,8 @@ var MESSAGE = {
|
|
|
79
81
|
hook_failed: "A host hook threw or rejected.",
|
|
80
82
|
background_job_failed: "A background maintenance job failed.",
|
|
81
83
|
heal_skipped: "Heal skipped a candidate fact, or the whole LLM pass when keyword search is unavailable.",
|
|
84
|
+
heal_deleted: "Heal soft-deleted a fact (or withheld the delete below the confidence floor).",
|
|
85
|
+
heal_downgraded: "Heal downgraded a fact to tentative (or withheld the downgrade below the confidence floor).",
|
|
82
86
|
grounding_missing: "A fact carried no qualifying evidence and was stored as a draft.",
|
|
83
87
|
grounding_failed: "A fact carried evidence not found in its source and was stored as a draft.",
|
|
84
88
|
classification_low_confidence: "A classifier answer was below the confidence threshold and was not applied.",
|
|
@@ -7548,10 +7552,11 @@ Keep facts concise. Do not return markdown, just raw JSON.`;
|
|
|
7548
7552
|
var HEAL_SYSTEM_PROMPT = `You are a memory grooming agent. Your job is to review a full dump of facts and recent events to resolve contradictions, downgrade stale claims, and flag obsolete facts for deletion.
|
|
7549
7553
|
Return ONLY a valid JSON object matching this schema:
|
|
7550
7554
|
{
|
|
7551
|
-
"downgraded": ["string (fact
|
|
7552
|
-
"deleted": ["string (fact
|
|
7555
|
+
"downgraded": [{ "id": "string (fact ID)", "confidence": "number 0-1" }],
|
|
7556
|
+
"deleted": [{ "id": "string (fact ID)", "confidence": "number 0-1" }],
|
|
7553
7557
|
"newFacts": [{ "title": "string (max 80 chars)", "body": "string (max 800 chars)", "tags": ["string"], "confidence": "certain|inferred|tentative" }]
|
|
7554
7558
|
}
|
|
7559
|
+
For downgraded and deleted entries, "confidence" is your confidence in that verdict.
|
|
7555
7560
|
Do not return markdown, just raw JSON.`;
|
|
7556
7561
|
var INGEST_SYSTEM_PROMPT = `You are a document ingestion agent. Your job is to extract factual knowledge from the provided document chunk.
|
|
7557
7562
|
Return ONLY a valid JSON object matching this schema:
|
|
@@ -9231,6 +9236,25 @@ function resolveResolveMinConfidence(config) {
|
|
|
9231
9236
|
);
|
|
9232
9237
|
return void 0;
|
|
9233
9238
|
}
|
|
9239
|
+
function resolveSystemOneHealScreen(config) {
|
|
9240
|
+
const healScreen = config?.systemOne?.healScreen;
|
|
9241
|
+
if (healScreen !== void 0 && !isTypingMode(healScreen)) {
|
|
9242
|
+
warnOnce(
|
|
9243
|
+
`[core-llm-wiki] systemOne: \`systemOne.healScreen\` is ${formatConfigValue(healScreen)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
|
|
9244
|
+
);
|
|
9245
|
+
return "llm";
|
|
9246
|
+
}
|
|
9247
|
+
return healScreen ?? "llm";
|
|
9248
|
+
}
|
|
9249
|
+
function resolveHealScreenMinConfidence(config) {
|
|
9250
|
+
if (resolveSystemOneHealScreen(config) !== "auto") return void 0;
|
|
9251
|
+
const floor = config?.systemOne?.minConfidence?.healScreen;
|
|
9252
|
+
if (isEdgesFloor(floor)) return floor;
|
|
9253
|
+
warnOnce(
|
|
9254
|
+
floor === void 0 ? "[core-llm-wiki] systemOne: `systemOne.minConfidence.healScreen` is required when `systemOne.healScreen` is 'auto'. The heal screen is off for this site; heal stays ungated." : `[core-llm-wiki] systemOne: \`systemOne.minConfidence.healScreen\` is ${formatConfigValue(floor)}, which is not a finite number in [0.5, 1]. The heal screen is off for this site; heal stays ungated.`
|
|
9255
|
+
);
|
|
9256
|
+
return void 0;
|
|
9257
|
+
}
|
|
9234
9258
|
|
|
9235
9259
|
// src/repositories/VectorRemovalRepository.ts
|
|
9236
9260
|
var CHUNK2 = 500;
|
|
@@ -12143,12 +12167,24 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12143
12167
|
* `result.remaining > 0` for convergence — see {@link HealResult.remaining}
|
|
12144
12168
|
* for what convergence means here, and for the no-progress flags
|
|
12145
12169
|
* (`searchUnavailable`, `budgetStop`) a loop must also stop on.
|
|
12170
|
+
*
|
|
12171
|
+
* Heal screen (`systemOne.healScreen: 'auto'` + `minConfidence.healScreen`):
|
|
12172
|
+
* a model-directed delete or downgrade whose valid `confidence` is below the
|
|
12173
|
+
* floor is withheld from every reader (apply, sync, removals, counts, id
|
|
12174
|
+
* lists); a missing or invalid confidence is applied unscreened. Each
|
|
12175
|
+
* model-directed move emits a `heal_deleted` / `heal_downgraded` receipt
|
|
12176
|
+
* after commit (`applied`, `applied_unscreened`, or `below_floor`), in every
|
|
12177
|
+
* mode. An `applied` receipt records that the model VERDICT was applied
|
|
12178
|
+
* (`downgradeByIds` runs unconditionally): a fact that was already at
|
|
12179
|
+
* reduced confidence still gets an `applied` receipt. A withheld delete paired with a restating `newFact` leaves the fact
|
|
12180
|
+
* live and the restatement is skipped as `fact_deduplicated`.
|
|
12146
12181
|
*/
|
|
12147
12182
|
async doRunHeal(entityId, options) {
|
|
12148
12183
|
const promptOverride = options?.promptOverride;
|
|
12149
12184
|
const batchSize = options?.batchSize ?? HEAL_BATCH_SIZE;
|
|
12150
12185
|
const trigger = options?.trigger ?? "call";
|
|
12151
12186
|
const diagBase = { entityId, operation: "heal", trigger };
|
|
12187
|
+
const healFloor = resolveHealScreenMinConfidence(this.options.config);
|
|
12152
12188
|
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
12153
12189
|
throw new Error("Invalid batchSize: must be an integer >= 1");
|
|
12154
12190
|
}
|
|
@@ -12194,6 +12230,8 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12194
12230
|
downgraded: staleDowngradedIds.length,
|
|
12195
12231
|
deleted: orphanedIds.length,
|
|
12196
12232
|
newFactsCreated: 0,
|
|
12233
|
+
downgradedIds: Array.from(new Set(staleDowngradedIds)),
|
|
12234
|
+
deletedIds: Array.from(new Set(orphanedIds)),
|
|
12197
12235
|
skipped: [],
|
|
12198
12236
|
degraded: [],
|
|
12199
12237
|
remaining: counts2.eligible,
|
|
@@ -12244,10 +12282,30 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12244
12282
|
call: (prompts) => callLlm(this.options, { operation: "heal", entityId, trigger, meter: options?.meter }, prompts),
|
|
12245
12283
|
parse: (responseText, batch, prompts) => {
|
|
12246
12284
|
const result = parseJsonResponse(responseText);
|
|
12285
|
+
const normalize = (raw) => {
|
|
12286
|
+
const ids = [];
|
|
12287
|
+
const confidence = /* @__PURE__ */ new Map();
|
|
12288
|
+
if (!Array.isArray(raw)) return { ids, confidence };
|
|
12289
|
+
for (const entry of raw) {
|
|
12290
|
+
const id = typeof entry === "string" ? entry : entry?.id;
|
|
12291
|
+
if (typeof id !== "string") continue;
|
|
12292
|
+
ids.push(id);
|
|
12293
|
+
const c = typeof entry === "object" && entry !== null ? entry.confidence : void 0;
|
|
12294
|
+
if (typeof c === "number" && Number.isFinite(c) && c >= 0 && c <= 1) {
|
|
12295
|
+
const prev = confidence.get(id);
|
|
12296
|
+
if (prev === void 0 || c < prev) confidence.set(id, c);
|
|
12297
|
+
}
|
|
12298
|
+
}
|
|
12299
|
+
return { ids, confidence };
|
|
12300
|
+
};
|
|
12301
|
+
const down = normalize(result.downgraded);
|
|
12302
|
+
const del = normalize(result.deleted);
|
|
12247
12303
|
return {
|
|
12248
12304
|
batch,
|
|
12249
|
-
downgraded:
|
|
12250
|
-
deleted:
|
|
12305
|
+
downgraded: down.ids,
|
|
12306
|
+
deleted: del.ids,
|
|
12307
|
+
downgradedConfidence: down.confidence,
|
|
12308
|
+
deletedConfidence: del.confidence,
|
|
12251
12309
|
newFacts: Array.isArray(result.newFacts) ? result.newFacts : [],
|
|
12252
12310
|
corpus: corpusByPrompt.get(prompts) ?? null
|
|
12253
12311
|
};
|
|
@@ -12287,8 +12345,42 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12287
12345
|
newFactCorpora.push(batchResult.corpus);
|
|
12288
12346
|
});
|
|
12289
12347
|
}
|
|
12348
|
+
const downgradeConfidence = /* @__PURE__ */ new Map();
|
|
12349
|
+
const deleteConfidence = /* @__PURE__ */ new Map();
|
|
12350
|
+
const mergeLowest = (into, id, c) => {
|
|
12351
|
+
if (c === void 0) return;
|
|
12352
|
+
const prev = into.get(id);
|
|
12353
|
+
if (prev === void 0 || c < prev) into.set(id, c);
|
|
12354
|
+
};
|
|
12355
|
+
for (const batchResult of outcome.results) {
|
|
12356
|
+
const mutableIds = new Set(batchResult.batch.map((f) => f.id));
|
|
12357
|
+
for (const id of batchResult.downgraded) if (mutableIds.has(id)) mergeLowest(downgradeConfidence, id, batchResult.downgradedConfidence.get(id));
|
|
12358
|
+
for (const id of batchResult.deleted) if (mutableIds.has(id)) mergeLowest(deleteConfidence, id, batchResult.deletedConfidence.get(id));
|
|
12359
|
+
}
|
|
12290
12360
|
const safeDowngraded = Array.from(safeDowngradedSet);
|
|
12291
12361
|
const safeDeleted = Array.from(safeDeletedSet);
|
|
12362
|
+
const withheldDowngraded = /* @__PURE__ */ new Map();
|
|
12363
|
+
const withheldDeleted = /* @__PURE__ */ new Map();
|
|
12364
|
+
let appliedDowngraded = safeDowngraded;
|
|
12365
|
+
let appliedDeleted = safeDeleted;
|
|
12366
|
+
if (healFloor !== void 0) {
|
|
12367
|
+
const screen = (ids, confidences, withheld) => {
|
|
12368
|
+
const applied = [];
|
|
12369
|
+
for (const id of ids) {
|
|
12370
|
+
const c = confidences.get(id);
|
|
12371
|
+
if (c !== void 0 && c < healFloor) withheld.set(id, c);
|
|
12372
|
+
else applied.push(id);
|
|
12373
|
+
}
|
|
12374
|
+
return applied;
|
|
12375
|
+
};
|
|
12376
|
+
appliedDowngraded = screen(safeDowngraded, downgradeConfidence, withheldDowngraded);
|
|
12377
|
+
appliedDeleted = screen(safeDeleted, deleteConfidence, withheldDeleted);
|
|
12378
|
+
if (appliedDowngraded.some((id) => !downgradeConfidence.has(id)) || appliedDeleted.some((id) => !deleteConfidence.has(id))) {
|
|
12379
|
+
warnOnce(
|
|
12380
|
+
'[core-llm-wiki] systemOne: heal returned downgraded/deleted verdicts without a valid `confidence` (out-of-range or non-numeric), so the heal screen could not gate them and they were applied. Restore the schema \u2014 or a `healSystemPrompt` override \u2014 to the `{ "id", "confidence" }` entry contract with confidences in 0-1 (see HEAL_SYSTEM_PROMPT).'
|
|
12381
|
+
);
|
|
12382
|
+
}
|
|
12383
|
+
}
|
|
12292
12384
|
const diagBuffer = new DiagnosticBuffer();
|
|
12293
12385
|
const validNewFacts = [];
|
|
12294
12386
|
const validNewFactItemIndexes = [];
|
|
@@ -12305,10 +12397,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12305
12397
|
}
|
|
12306
12398
|
});
|
|
12307
12399
|
const insertedFacts = [];
|
|
12308
|
-
const uniqueDeletedFactIds = Array.from(new Set(
|
|
12400
|
+
const uniqueDeletedFactIds = Array.from(new Set(appliedDeleted));
|
|
12309
12401
|
await this.db.withTransactionAsync(async (tx) => {
|
|
12310
|
-
await this.entryRepo.downgradeByIds(
|
|
12311
|
-
await this.entryRepo.softDeleteByIds(
|
|
12402
|
+
await this.entryRepo.downgradeByIds(appliedDowngraded, entityId, tx);
|
|
12403
|
+
await this.entryRepo.softDeleteByIds(appliedDeleted, entityId, tx);
|
|
12312
12404
|
const healFactsForDedupe = await this.entryRepo.findInferredTitlesByEntityId(entityId, tx);
|
|
12313
12405
|
for (const [k, fact] of validNewFacts.entries()) {
|
|
12314
12406
|
const newTokens = titleTokens(fact.title);
|
|
@@ -12372,11 +12464,29 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12372
12464
|
for (const { item, reason } of outcome.skipped) {
|
|
12373
12465
|
diagBuffer.push({ ...diagBase, code: "heal_skipped", detail: { factId: item.id, reason } });
|
|
12374
12466
|
}
|
|
12467
|
+
const pushReceipts = (code, applied, confidences, withheld) => {
|
|
12468
|
+
for (const factId of applied) {
|
|
12469
|
+
if (healFloor !== void 0 && !confidences.has(factId)) {
|
|
12470
|
+
diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied_unscreened" } });
|
|
12471
|
+
} else {
|
|
12472
|
+
diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied" } });
|
|
12473
|
+
}
|
|
12474
|
+
}
|
|
12475
|
+
for (const [factId, confidence] of withheld) {
|
|
12476
|
+
diagBuffer.push({
|
|
12477
|
+
...diagBase,
|
|
12478
|
+
code,
|
|
12479
|
+
detail: { factId, reason: "below_floor", ...confidence !== void 0 ? { confidence } : {} }
|
|
12480
|
+
});
|
|
12481
|
+
}
|
|
12482
|
+
};
|
|
12483
|
+
pushReceipts("heal_downgraded", appliedDowngraded, downgradeConfidence, withheldDowngraded);
|
|
12484
|
+
pushReceipts("heal_deleted", appliedDeleted, deleteConfidence, withheldDeleted);
|
|
12375
12485
|
diagBuffer.flush(this.options);
|
|
12376
12486
|
const healSyncIds = Array.from(/* @__PURE__ */ new Set([
|
|
12377
12487
|
...orphanedIds,
|
|
12378
12488
|
...staleDowngradedIds,
|
|
12379
|
-
...
|
|
12489
|
+
...appliedDowngraded,
|
|
12380
12490
|
...uniqueDeletedFactIds,
|
|
12381
12491
|
...insertedFacts.map((f) => f.id)
|
|
12382
12492
|
]));
|
|
@@ -12395,13 +12505,15 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12395
12505
|
}
|
|
12396
12506
|
let scanned = outcome.skipped.length;
|
|
12397
12507
|
for (const batchResult of outcome.results) scanned += batchResult.batch.length;
|
|
12398
|
-
const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...
|
|
12508
|
+
const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...appliedDowngraded]);
|
|
12399
12509
|
const allDeleted = /* @__PURE__ */ new Set([...orphanedIds, ...uniqueDeletedFactIds]);
|
|
12400
12510
|
const counts = await this.entryRepo.countHealCandidatesByEntityId(entityId, recheckCutoff);
|
|
12401
12511
|
return {
|
|
12402
12512
|
scanned,
|
|
12403
12513
|
downgraded: allDowngraded.size,
|
|
12404
12514
|
deleted: allDeleted.size,
|
|
12515
|
+
downgradedIds: Array.from(allDowngraded),
|
|
12516
|
+
deletedIds: Array.from(allDeleted),
|
|
12405
12517
|
newFactsCreated: insertedFacts.length,
|
|
12406
12518
|
skipped: outcome.skipped.map(({ item, reason }) => ({ id: item.id, reason })),
|
|
12407
12519
|
degraded: healedDegraded,
|
|
@@ -18491,10 +18603,12 @@ exports.parseOkfBundle = parseOkfBundle;
|
|
|
18491
18603
|
exports.resolveContextBudget = resolveContextBudget;
|
|
18492
18604
|
exports.resolveDefaultChunkLength = resolveDefaultChunkLength;
|
|
18493
18605
|
exports.resolveEdgesMinConfidence = resolveEdgesMinConfidence;
|
|
18606
|
+
exports.resolveHealScreenMinConfidence = resolveHealScreenMinConfidence;
|
|
18494
18607
|
exports.resolveMaxPromptChars = resolveMaxPromptChars;
|
|
18495
18608
|
exports.resolveOntologyJobDefaults = resolveOntologyJobDefaults;
|
|
18496
18609
|
exports.resolveResolveMinConfidence = resolveResolveMinConfidence;
|
|
18497
18610
|
exports.resolveSystemOneEdges = resolveSystemOneEdges;
|
|
18611
|
+
exports.resolveSystemOneHealScreen = resolveSystemOneHealScreen;
|
|
18498
18612
|
exports.resolveSystemOneResolve = resolveSystemOneResolve;
|
|
18499
18613
|
exports.resolveSystemOneTyping = resolveSystemOneTyping;
|
|
18500
18614
|
exports.resolveTypingMinConfidence = resolveTypingMinConfidence;
|