@equationalapplications/core-llm-wiki 9.5.0 → 9.5.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/README.md +1 -1
- package/dist/{chunk-ZVVZACYI.mjs → chunk-Q6ZS2RKS.mjs} +52 -5
- package/dist/chunk-Q6ZS2RKS.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +50 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{testing-CTCRwhs0.d.mts → testing-BZyrIoJp.d.mts} +8 -1
- package/dist/{testing-CTCRwhs0.d.ts → testing-BZyrIoJp.d.ts} +8 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +50 -3
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-ZVVZACYI.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseRepository, WikiGraphNodeOwnershipConflict, serializeSourcePointer, parseStoredSourcePointer, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, warnChangedDefaultsOnce, EdgeRepository, MetadataRepository, EmbeddingService, VectorRemovalRepository, VectorRemovalService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, SourceStoreService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, emitDiagnostic, normalizeSourceRef, normalizeSourceHash, resolveLibrarianStrategy, entitySummaryMetaKey, WikiSourceRefHashCollision, DiagnosticBuffer, validateManifest, WikiDraftNotFound, generateId, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, edgeTripleAllowed, MAX_EMBED_ATTEMPTS, UsageMeter, isWikiSearchUnavailableError, WikiBusyError, WikiInvalidReadOptions, isLiveAt, packFactsByBudget, factTokenCost, probePendingWork, WikiMigrationRequiredError, setupDatabase, UnavailableIndexStrategy, createdAtValue, isUsableDate, validateSourcePointerValue, assertEntityId, assertEpochMs, passageFtsTriggerNames, FTS5_STATE_KEY, fts5LedgerDropSql, passageFtsTablesDdl, passageFtsTriggersDdl, fts5TablesDdl, fts5PendingIndexesDdl, fts5TriggersDdl, writeRebuildStart, FTS5_RETIRED_COUNTER_KEY, retiredTableName, FTS5_RETIRED_TABLES_KEY, isRetiredTableName, idReindexChunkSql, readRebuildProgress, FTS5_DRAIN_CHUNK, FTS5_RECLAIM_MERGE_PAGES, windowHiSql, windowChunkSql, FTS5_REBUILD_WM_KEY, sweepHiSql, sweepChunkSql, FTS5_SWEEP_CURSOR_KEY, drainHiSql, drainChunkSql, FTS5_REBUILD_SNAPSHOT_KEY, idDrainChunkSql, entityDrainHiSql, entityDrainChunkSql, fts5TriggerNames, extractSqliteCode, WikiTransactionError } from './chunk-
|
|
2
|
-
export { CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, EMBED_CHARS_CEILING, EraseStepError, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isWikiSearchUnavailableError, parseEmbedding, safeSlice, validateManifest } from './chunk-
|
|
1
|
+
import { BaseRepository, WikiGraphNodeOwnershipConflict, serializeSourcePointer, parseStoredSourcePointer, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, warnChangedDefaultsOnce, EdgeRepository, MetadataRepository, EmbeddingService, VectorRemovalRepository, VectorRemovalService, SearchService, TemporalService, JobManager, PromptService, resolveGrounding, IngestionService, MaintenanceService, ImportExportService, RetrievalService, SourceStoreService, WriteService, __privateGet, __privateSet, createLegacySourceTypeIndex, writeNormalizeStamp, CURRENT_SCHEMA_VERSION, detectSchemaVersion, MIGRATIONS, runSourceRefNormalize, emitDiagnostic, normalizeSourceRef, normalizeSourceHash, resolveLibrarianStrategy, entitySummaryMetaKey, WikiSourceRefHashCollision, DiagnosticBuffer, validateManifest, WikiDraftNotFound, generateId, emptyManifest, resolveNodeType, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, edgeTripleAllowed, MAX_EMBED_ATTEMPTS, UsageMeter, isWikiSearchUnavailableError, WikiBusyError, WikiInvalidReadOptions, isLiveAt, packFactsByBudget, factTokenCost, probePendingWork, WikiMigrationRequiredError, setupDatabase, UnavailableIndexStrategy, createdAtValue, isUsableDate, validateSourcePointerValue, assertEntityId, assertEpochMs, passageFtsTriggerNames, FTS5_STATE_KEY, fts5LedgerDropSql, passageFtsTablesDdl, passageFtsTriggersDdl, fts5TablesDdl, fts5PendingIndexesDdl, fts5TriggersDdl, writeRebuildStart, FTS5_RETIRED_COUNTER_KEY, retiredTableName, FTS5_RETIRED_TABLES_KEY, isRetiredTableName, idReindexChunkSql, readRebuildProgress, FTS5_DRAIN_CHUNK, FTS5_RECLAIM_MERGE_PAGES, windowHiSql, windowChunkSql, FTS5_REBUILD_WM_KEY, sweepHiSql, sweepChunkSql, FTS5_SWEEP_CURSOR_KEY, drainHiSql, drainChunkSql, FTS5_REBUILD_SNAPSHOT_KEY, idDrainChunkSql, entityDrainHiSql, entityDrainChunkSql, fts5TriggerNames, extractSqliteCode, WikiTransactionError } from './chunk-Q6ZS2RKS.mjs';
|
|
2
|
+
export { CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, EMBED_CHARS_CEILING, EraseStepError, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, chunkText, configureRandomSource, isWikiSearchUnavailableError, parseEmbedding, safeSlice, validateManifest } from './chunk-Q6ZS2RKS.mjs';
|
|
3
3
|
import { deriveTrustTier, isStaleAfter, appendRelatedSection, buildConceptDocument, buildLogMd, buildEntityIndexMd, buildRootIndexMd, isAllowedOkfPath, parseRootIndexMd, parseEntityIndexMd, parseConcept, splitRelatedSection, extractMarkdownLinks, parseLogMd, parseEventIdComment, createEventIdDeriver, latestVerified, formatSourcesJson, appendEventIdComment, parseVerifiedFlexible, parseCitationsList } from '@equationalapplications/core-okf';
|
|
4
4
|
import MiniSearch from 'minisearch';
|
|
5
5
|
|
|
@@ -1534,6 +1534,13 @@ interface WikiInstructions {
|
|
|
1534
1534
|
ingest: string;
|
|
1535
1535
|
librarian: string;
|
|
1536
1536
|
heal: string;
|
|
1537
|
+
/**
|
|
1538
|
+
* Template only: the run-time prompt additionally carries a TITLE CATALOG
|
|
1539
|
+
* of the entity's typed node titles (appended after this text, before the
|
|
1540
|
+
* ontology block) whenever a catalog is built — see
|
|
1541
|
+
* `buildTitleCatalogBlock` and the data-scope note in the ontology-backfill
|
|
1542
|
+
* spec Errata (PR #425).
|
|
1543
|
+
*/
|
|
1537
1544
|
ontologyBackfill: string;
|
|
1538
1545
|
}
|
|
1539
1546
|
type MaintenanceJob = 'librarian' | 'heal' | 'reembed' | 'externalDeletions';
|
|
@@ -3408,7 +3415,7 @@ declare class PromptService {
|
|
|
3408
3415
|
degraded: DegradedRecord[];
|
|
3409
3416
|
groundingCorpus?: string[];
|
|
3410
3417
|
};
|
|
3411
|
-
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
3418
|
+
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null, titleCatalog?: string): {
|
|
3412
3419
|
systemPrompt: string;
|
|
3413
3420
|
userPrompt: string;
|
|
3414
3421
|
};
|
|
@@ -1534,6 +1534,13 @@ interface WikiInstructions {
|
|
|
1534
1534
|
ingest: string;
|
|
1535
1535
|
librarian: string;
|
|
1536
1536
|
heal: string;
|
|
1537
|
+
/**
|
|
1538
|
+
* Template only: the run-time prompt additionally carries a TITLE CATALOG
|
|
1539
|
+
* of the entity's typed node titles (appended after this text, before the
|
|
1540
|
+
* ontology block) whenever a catalog is built — see
|
|
1541
|
+
* `buildTitleCatalogBlock` and the data-scope note in the ontology-backfill
|
|
1542
|
+
* spec Errata (PR #425).
|
|
1543
|
+
*/
|
|
1537
1544
|
ontologyBackfill: string;
|
|
1538
1545
|
}
|
|
1539
1546
|
type MaintenanceJob = 'librarian' | 'heal' | 'reembed' | 'externalDeletions';
|
|
@@ -3408,7 +3415,7 @@ declare class PromptService {
|
|
|
3408
3415
|
degraded: DegradedRecord[];
|
|
3409
3416
|
groundingCorpus?: string[];
|
|
3410
3417
|
};
|
|
3411
|
-
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
3418
|
+
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null, titleCatalog?: string): {
|
|
3412
3419
|
systemPrompt: string;
|
|
3413
3420
|
userPrompt: string;
|
|
3414
3421
|
};
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-
|
|
1
|
+
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-BZyrIoJp.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-
|
|
1
|
+
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-BZyrIoJp.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.js
CHANGED
|
@@ -2412,6 +2412,47 @@ Return ONLY a valid JSON object matching this schema:
|
|
|
2412
2412
|
}
|
|
2413
2413
|
If no manifest type fits a fact, omit that fact from "classifications" entirely \u2014 do not guess.
|
|
2414
2414
|
When 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.`;
|
|
2415
|
+
var TITLE_CATALOG_MAX_ENTRIES = 200;
|
|
2416
|
+
function buildTitleCatalogBlock(rows) {
|
|
2417
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
2418
|
+
for (const r of rows) {
|
|
2419
|
+
if (typeof r.title !== "string" || r.title.length === 0) continue;
|
|
2420
|
+
if (typeof r.okf_type !== "string" || r.okf_type.length === 0) continue;
|
|
2421
|
+
byKey.set(normalizeTitleKey(r.title), { title: r.title, okf_type: r.okf_type });
|
|
2422
|
+
}
|
|
2423
|
+
const typed = [...byKey.values()].sort((a, b) => a.title < b.title ? -1 : a.title > b.title ? 1 : 0);
|
|
2424
|
+
const CHAR_BUDGET = 8e3;
|
|
2425
|
+
const listed = [];
|
|
2426
|
+
let used = 0;
|
|
2427
|
+
for (const r of typed) {
|
|
2428
|
+
const line = `- ${JSON.stringify(r.title)} (${r.okf_type})`;
|
|
2429
|
+
if (line.length + 1 > CHAR_BUDGET) continue;
|
|
2430
|
+
if (listed.length >= TITLE_CATALOG_MAX_ENTRIES) break;
|
|
2431
|
+
if (used + line.length + 1 > CHAR_BUDGET) continue;
|
|
2432
|
+
listed.push(r);
|
|
2433
|
+
used += line.length + 1;
|
|
2434
|
+
}
|
|
2435
|
+
const truncated = typed.length > listed.length;
|
|
2436
|
+
if (typed.length === 0) {
|
|
2437
|
+
return [
|
|
2438
|
+
"TITLE CATALOG: this memory contains no typed nodes yet.",
|
|
2439
|
+
'A fact classified in this same response is a valid "target_title" once typed. Otherwise omit "edges" rather than invent a target_title.'
|
|
2440
|
+
].join("\n");
|
|
2441
|
+
}
|
|
2442
|
+
if (listed.length === 0) {
|
|
2443
|
+
return [
|
|
2444
|
+
"TITLE CATALOG: existing typed nodes exist in this memory, but none fit the catalog budget.",
|
|
2445
|
+
'A fact classified in this same response is a valid "target_title" once typed. Otherwise omit "edges" rather than invent a target_title.'
|
|
2446
|
+
].join("\n");
|
|
2447
|
+
}
|
|
2448
|
+
const catalog = listed.map((r) => `- ${JSON.stringify(r.title)} (${r.okf_type})`).join("\n");
|
|
2449
|
+
return [
|
|
2450
|
+
"TITLE CATALOG: existing typed nodes in this memory include:",
|
|
2451
|
+
catalog,
|
|
2452
|
+
...truncated ? ["(This list is truncated; more typed nodes exist than are shown here.)"] : [],
|
|
2453
|
+
'A "target_title" may be copied verbatim from this catalog, or be another fact classified in this same response. If no valid target exists, omit "edges" rather than invent a target_title.'
|
|
2454
|
+
].join("\n");
|
|
2455
|
+
}
|
|
2415
2456
|
var GROUNDING_SOURCE = {
|
|
2416
2457
|
ingest: { key: "facts", source: "the document chunk" },
|
|
2417
2458
|
librarian: { key: "facts", source: 'the "summary" text of the events' },
|
|
@@ -2742,7 +2783,7 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2742
2783
|
...corpusField
|
|
2743
2784
|
};
|
|
2744
2785
|
}
|
|
2745
|
-
buildOntologyBackfillPrompt(facts, runtimeOverride, ontologyContext) {
|
|
2786
|
+
buildOntologyBackfillPrompt(facts, runtimeOverride, ontologyContext, titleCatalog) {
|
|
2746
2787
|
const template = runtimeOverride ?? this.globalOverrides?.ontologyBackfillSystemPrompt ?? ONTOLOGY_BACKFILL_SYSTEM_PROMPT;
|
|
2747
2788
|
const hasFacts = /\{\{\s*facts\s*\}\}/.test(template);
|
|
2748
2789
|
if (hasFacts || this.hasOntologyPlaceholders(template)) {
|
|
@@ -2752,8 +2793,11 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2752
2793
|
${JSON.stringify(facts, null, 2)}`
|
|
2753
2794
|
};
|
|
2754
2795
|
}
|
|
2796
|
+
const effective = titleCatalog !== void 0 ? `${template}
|
|
2797
|
+
|
|
2798
|
+
${titleCatalog}` : template;
|
|
2755
2799
|
return {
|
|
2756
|
-
systemPrompt: this.appendOntology(
|
|
2800
|
+
systemPrompt: this.appendOntology(effective, ontologyContext),
|
|
2757
2801
|
userPrompt: `Facts:
|
|
2758
2802
|
${JSON.stringify(facts, null, 2)}`
|
|
2759
2803
|
};
|
|
@@ -6738,11 +6782,14 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
6738
6782
|
}
|
|
6739
6783
|
}
|
|
6740
6784
|
const ontologyContext = await ontologyService.buildPromptContext(entityId);
|
|
6785
|
+
const titleRows = await this.entryRepo.findTitleIndexByEntityId(entityId);
|
|
6786
|
+
const titleCatalog = buildTitleCatalogBlock(titleRows);
|
|
6741
6787
|
const toPromptShape = (f) => ({ id: f.id, title: f.title, body: f.body, tags: f.tags });
|
|
6742
6788
|
const buildPrompt = (facts) => this.promptService.buildOntologyBackfillPrompt(
|
|
6743
6789
|
facts.map(toPromptShape),
|
|
6744
6790
|
options?.promptOverride,
|
|
6745
|
-
ontologyContext
|
|
6791
|
+
ontologyContext,
|
|
6792
|
+
titleCatalog
|
|
6746
6793
|
);
|
|
6747
6794
|
const outcome = await runBatched({
|
|
6748
6795
|
items: candidates,
|