@equationalapplications/core-llm-wiki 9.6.0 → 9.8.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-TZMLWQ3G.mjs → chunk-EN37KODZ.mjs} +338 -43
- package/dist/chunk-EN37KODZ.mjs.map +1 -0
- package/dist/index.d.mts +47 -19
- package/dist/index.d.ts +47 -19
- package/dist/index.js +426 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -22
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BBeQQIYp.d.mts → testing-CDSfjx8j.d.mts} +64 -9
- package/dist/{testing-BBeQQIYp.d.ts → testing-CDSfjx8j.d.ts} +64 -9
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +299 -26
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-TZMLWQ3G.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, isReservedAbstainSlug, ONTOLOGY_ABSTAIN_SENTINEL, WikiDraftNotFound, generateId, emptyManifest,
|
|
2
|
-
export { CLASSIFIER_MAX_CHOICES, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, 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_ABSTAIN_SENTINEL, 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, isReservedAbstainSlug, isWikiSearchUnavailableError, parseEmbedding, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateManifest, warnOnce } from './chunk-
|
|
1
|
+
import { BaseRepository, WikiGraphNodeOwnershipConflict, serializeSourcePointer, parseStoredSourcePointer, parseJsonObject, parseJsonArray, liveAtSql, reanchorRebuildFingerprint, __privateAdd, warnChangedDefaultsOnce, resolveContextBudgetOrThrow, 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, isReservedAbstainSlug, ONTOLOGY_ABSTAIN_SENTINEL, WikiDraftNotFound, generateId, emptyManifest, resolveNodeTypeMatch, WikiStrictOntologyViolation, validateInlineEdges, resolveEdgeDefinitions, typeSatisfies, normalizeTitleKey, edgeTripleAllowed, resolveNodeType, shouldEmitOntologyReceipt, nodeTypeReceipts, 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-EN37KODZ.mjs';
|
|
2
|
+
export { CLASSIFIER_MAX_CHOICES, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, 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_ABSTAIN_SENTINEL, 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, isReservedAbstainSlug, isWikiSearchUnavailableError, parseEmbedding, resolveContextBudget, resolveDefaultChunkLength, resolveMaxPromptChars, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateManifest, warnOnce } from './chunk-EN37KODZ.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
|
|
|
@@ -1453,28 +1453,35 @@ var _EntryRepository = class _EntryRepository extends BaseRepository {
|
|
|
1453
1453
|
/**
|
|
1454
1454
|
* Live untyped facts eligible for ontology backfill, oldest first.
|
|
1455
1455
|
* Skips facts checked within the recheck cooldown (ontology_checked_at > recheckCutoff).
|
|
1456
|
+
* The queue sees CURRENT facts only (ontology-curation Task 10): rows whose
|
|
1457
|
+
* validity window excludes "now" are invisible to typing, matching the
|
|
1458
|
+
* read-time liveness definition (utils/temporal.ts).
|
|
1456
1459
|
*/
|
|
1457
1460
|
async findUntypedByEntityId(entityId, limit, recheckCutoff, tx) {
|
|
1458
1461
|
const executor = this.getExecutor(tx);
|
|
1462
|
+
const now = Date.now();
|
|
1459
1463
|
const rows = await executor.getAllAsync(
|
|
1460
1464
|
`SELECT * FROM ${this.prefix}entries
|
|
1461
1465
|
WHERE entity_id = ? AND okf_type IS NULL AND deleted_at IS NULL
|
|
1462
1466
|
AND (ontology_checked_at IS NULL OR ontology_checked_at <= ?)
|
|
1467
|
+
AND ${liveAtSql("current")}
|
|
1463
1468
|
ORDER BY updated_at ASC LIMIT ?`,
|
|
1464
|
-
[entityId, recheckCutoff, limit]
|
|
1469
|
+
[entityId, recheckCutoff, now, now, limit]
|
|
1465
1470
|
);
|
|
1466
1471
|
return rows.map(mapRowToFact);
|
|
1467
1472
|
}
|
|
1468
|
-
/** Counts live untyped facts: eligible (past cooldown) vs deferred (in cooldown). */
|
|
1473
|
+
/** Counts live untyped facts: eligible (past cooldown) vs deferred (in cooldown). Current facts only, as {@link findUntypedByEntityId}. */
|
|
1469
1474
|
async countUntypedByEntityId(entityId, recheckCutoff, tx) {
|
|
1470
1475
|
const executor = this.getExecutor(tx);
|
|
1476
|
+
const now = Date.now();
|
|
1471
1477
|
const row = await executor.getFirstAsync(
|
|
1472
1478
|
`SELECT
|
|
1473
1479
|
SUM(CASE WHEN ontology_checked_at IS NULL OR ontology_checked_at <= ? THEN 1 ELSE 0 END) AS eligible,
|
|
1474
1480
|
SUM(CASE WHEN ontology_checked_at IS NOT NULL AND ontology_checked_at > ? THEN 1 ELSE 0 END) AS deferred
|
|
1475
1481
|
FROM ${this.prefix}entries
|
|
1476
|
-
WHERE entity_id = ? AND okf_type IS NULL AND deleted_at IS NULL
|
|
1477
|
-
|
|
1482
|
+
WHERE entity_id = ? AND okf_type IS NULL AND deleted_at IS NULL
|
|
1483
|
+
AND ${liveAtSql("current")}`,
|
|
1484
|
+
[recheckCutoff, recheckCutoff, entityId, now, now]
|
|
1478
1485
|
);
|
|
1479
1486
|
return { eligible: Number(row?.eligible ?? 0), deferred: Number(row?.deferred ?? 0) };
|
|
1480
1487
|
}
|
|
@@ -3683,7 +3690,8 @@ var FACT_ONTOLOGY_FIELDS = `
|
|
|
3683
3690
|
Each fact may optionally include:
|
|
3684
3691
|
- "okf_type": string \u2014 must be one of the node_types in the manifest
|
|
3685
3692
|
- "edges": [{ "edge_type": string, "target_title": string }] \u2014 target_title must match another fact's title in this response or existing memory
|
|
3686
|
-
- An edge_type may appear in the manifest multiple times with different source_type/target_type; use the row whose types match your fact and target
|
|
3693
|
+
- An edge_type may appear in the manifest multiple times with different source_type/target_type; use the row whose types match your fact and target.
|
|
3694
|
+
Each node is a fact. To link two things with an edge, each must exist as its own fact, titled by the same name you use in \`target_title\`.`;
|
|
3687
3695
|
var EMERGENT_EXTRA = `
|
|
3688
3696
|
You may also return "ontology_updates" to propose new types:
|
|
3689
3697
|
"ontology_updates": {
|
|
@@ -3692,7 +3700,7 @@ You may also return "ontology_updates" to propose new types:
|
|
|
3692
3700
|
}
|
|
3693
3701
|
Only propose types not already in the manifest. Do not redefine existing types.`;
|
|
3694
3702
|
function buildOntologyPromptAppendix(mode, manifestJson) {
|
|
3695
|
-
const strictRules = mode === "strict" ? "STRICT MODE: Use ONLY types defined in the manifest. If a fact does not fit
|
|
3703
|
+
const strictRules = mode === "strict" ? "STRICT MODE: Use ONLY types defined in the manifest. If a fact does not fit a node_type, choose the closest type the fact is an example of; omit only when none applies even broadly." : "EMERGENT MODE: Prefer manifest types. You may propose new types via ontology_updates when necessary.";
|
|
3696
3704
|
const fallback = "If okf_type or an edge is invalid, omit them rather than inventing unlisted types.";
|
|
3697
3705
|
const ontologyModeInstructions = [
|
|
3698
3706
|
"## Ontology constraints",
|
|
@@ -3755,15 +3763,15 @@ var OntologyService = class {
|
|
|
3755
3763
|
}
|
|
3756
3764
|
async mergeEmergentUpdates(entityId, updates, tx) {
|
|
3757
3765
|
const filtered = updates.node_types ? { ...updates, node_types: updates.node_types.filter((nt) => !isReservedAbstainSlug(nt.type)) } : updates;
|
|
3758
|
-
const merged = await this.metadataRepo.mergeManifestUpdates(entityId, filtered, tx);
|
|
3766
|
+
const { manifest: merged, rejected } = await this.metadataRepo.mergeManifestUpdates(entityId, filtered, tx);
|
|
3759
3767
|
this.invalidateCache(entityId);
|
|
3760
|
-
return merged;
|
|
3768
|
+
return { manifest: merged, rejected };
|
|
3761
3769
|
}
|
|
3762
3770
|
validateAndNormalizeFact(fact, manifest, opts) {
|
|
3763
3771
|
const rawType = typeof fact.okf_type === "string" ? fact.okf_type : "";
|
|
3764
3772
|
const strict = opts?.strict === true;
|
|
3765
|
-
const
|
|
3766
|
-
if (!
|
|
3773
|
+
const match = resolveNodeTypeMatch(rawType, manifest);
|
|
3774
|
+
if (!match) {
|
|
3767
3775
|
if (strict) throw new WikiStrictOntologyViolation(opts?.entityId ?? "", "node", rawType);
|
|
3768
3776
|
if (opts?.drops && Array.isArray(fact.edges)) {
|
|
3769
3777
|
for (const edge of fact.edges) {
|
|
@@ -3778,8 +3786,13 @@ var OntologyService = class {
|
|
|
3778
3786
|
}
|
|
3779
3787
|
return { okf_type: null, edges: [] };
|
|
3780
3788
|
}
|
|
3789
|
+
const canonical = match.slug;
|
|
3781
3790
|
const edges = validateInlineEdges(canonical, null, fact.edges ?? [], manifest, opts);
|
|
3782
|
-
return {
|
|
3791
|
+
return {
|
|
3792
|
+
okf_type: canonical,
|
|
3793
|
+
edges,
|
|
3794
|
+
match: { raw: rawType, canonical, via: match.via }
|
|
3795
|
+
};
|
|
3783
3796
|
}
|
|
3784
3797
|
/**
|
|
3785
3798
|
* Pure resolver: given a source type, LLM-supplied edges, the manifest,
|
|
@@ -3959,6 +3972,16 @@ var LintRepository = class extends BaseRepository {
|
|
|
3959
3972
|
[entityId, afterId, limit]
|
|
3960
3973
|
);
|
|
3961
3974
|
}
|
|
3975
|
+
/** Keyset page of TYPED facts in this entity (id + stored slug). Read-only. "Typed" here means the deletion-only scan the edge-violation query uses: soft-deleted and draft rows are out; validity windows are NOT consulted — the count mirrors `pageLiveEdgeViolations` exactly (spec §9, CodeRabbit #441). */
|
|
3976
|
+
async pageLiveTypedFacts(entityId, afterId, limit) {
|
|
3977
|
+
return this.db.getAllAsync(
|
|
3978
|
+
`SELECT id, okf_type FROM ${this.prefix}entries
|
|
3979
|
+
WHERE entity_id = ? AND id > ? AND deleted_at IS NULL
|
|
3980
|
+
AND lifecycle_status != 'draft' AND okf_type IS NOT NULL
|
|
3981
|
+
ORDER BY id ASC LIMIT ?`,
|
|
3982
|
+
[entityId, afterId, limit]
|
|
3983
|
+
);
|
|
3984
|
+
}
|
|
3962
3985
|
};
|
|
3963
3986
|
|
|
3964
3987
|
// src/services/LintService.ts
|
|
@@ -3998,11 +4021,29 @@ var LintService = class {
|
|
|
3998
4021
|
after = page[page.length - 1].id;
|
|
3999
4022
|
}
|
|
4000
4023
|
}
|
|
4024
|
+
let nodeTypeViolations = 0;
|
|
4025
|
+
const nodeTypeViolationIds = [];
|
|
4026
|
+
const nodesConstrained = mode !== "off" && (manifest.node_types?.length ?? 0) > 0;
|
|
4027
|
+
if (nodesConstrained) {
|
|
4028
|
+
let after = "";
|
|
4029
|
+
for (; ; ) {
|
|
4030
|
+
const page = await this.lintRepo.pageLiveTypedFacts(entityId, after, LINT_PAGE_SIZE);
|
|
4031
|
+
for (const f of page) {
|
|
4032
|
+
if (resolveNodeType(f.okf_type, manifest) === null) {
|
|
4033
|
+
nodeTypeViolations++;
|
|
4034
|
+
if (nodeTypeViolationIds.length < LINT_SAMPLE_SIZE) nodeTypeViolationIds.push(f.id);
|
|
4035
|
+
}
|
|
4036
|
+
}
|
|
4037
|
+
if (page.length < LINT_PAGE_SIZE) break;
|
|
4038
|
+
after = page[page.length - 1].id;
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4001
4041
|
return {
|
|
4002
4042
|
danglingEdges,
|
|
4003
4043
|
manifestViolations,
|
|
4044
|
+
nodeTypeViolations,
|
|
4004
4045
|
...health,
|
|
4005
|
-
sample: { danglingEdgeIds, manifestViolationEdgeIds }
|
|
4046
|
+
sample: { danglingEdgeIds, manifestViolationEdgeIds, nodeTypeViolationIds }
|
|
4006
4047
|
};
|
|
4007
4048
|
}
|
|
4008
4049
|
};
|
|
@@ -4229,25 +4270,43 @@ function normalizeRememberInput(entityId, input, now) {
|
|
|
4229
4270
|
|
|
4230
4271
|
// src/services/RememberService.ts
|
|
4231
4272
|
var RememberService = class {
|
|
4232
|
-
constructor(db, entryRepo, ontologyService, searchService, embeddingService) {
|
|
4273
|
+
constructor(db, entryRepo, ontologyService, searchService, embeddingService, options) {
|
|
4233
4274
|
this.db = db;
|
|
4234
4275
|
this.entryRepo = entryRepo;
|
|
4235
4276
|
this.ontologyService = ontologyService;
|
|
4236
4277
|
this.searchService = searchService;
|
|
4237
4278
|
this.embeddingService = embeddingService;
|
|
4279
|
+
this.options = options;
|
|
4238
4280
|
}
|
|
4239
4281
|
async remember(entityId, input) {
|
|
4240
4282
|
const now = Date.now();
|
|
4241
4283
|
const { fact, validFrom, okfType } = normalizeRememberInput(entityId, input, now);
|
|
4242
4284
|
let stored;
|
|
4285
|
+
const pendingReceipts = [];
|
|
4243
4286
|
await this.db.withTransactionAsync(async (tx) => {
|
|
4244
4287
|
if (okfType !== null) {
|
|
4245
4288
|
const { mode, manifest } = await this.ontologyService.getEffectiveState(entityId, tx);
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4289
|
+
if (mode !== "off") {
|
|
4290
|
+
const factLike = { okf_type: okfType, edges: [] };
|
|
4291
|
+
const normalized = this.ontologyService.validateAndNormalizeFact(factLike, manifest, {
|
|
4292
|
+
strict: mode === "strict",
|
|
4293
|
+
entityId
|
|
4294
|
+
});
|
|
4295
|
+
fact.okf_type = normalized.okf_type;
|
|
4296
|
+
if (shouldEmitOntologyReceipt(mode)) {
|
|
4297
|
+
for (const receipt of nodeTypeReceipts(
|
|
4298
|
+
{ entityId, operation: "remember", trigger: "call" },
|
|
4299
|
+
fact.id,
|
|
4300
|
+
okfType,
|
|
4301
|
+
normalized.okf_type,
|
|
4302
|
+
normalized.match
|
|
4303
|
+
)) {
|
|
4304
|
+
pendingReceipts.push(receipt);
|
|
4305
|
+
}
|
|
4306
|
+
}
|
|
4307
|
+
} else {
|
|
4308
|
+
fact.okf_type = okfType;
|
|
4309
|
+
}
|
|
4251
4310
|
}
|
|
4252
4311
|
await this.entryRepo.upsert(fact, tx);
|
|
4253
4312
|
if (validFrom !== void 0) {
|
|
@@ -4259,6 +4318,9 @@ var RememberService = class {
|
|
|
4259
4318
|
}
|
|
4260
4319
|
stored = readBack;
|
|
4261
4320
|
});
|
|
4321
|
+
for (const receipt of pendingReceipts) {
|
|
4322
|
+
emitDiagnostic(this.options ?? {}, receipt);
|
|
4323
|
+
}
|
|
4262
4324
|
await this.searchService.syncEntries(entityId, [fact.id]);
|
|
4263
4325
|
await this.embeddingService.embedFact(
|
|
4264
4326
|
{ id: fact.id, entity_id: entityId, title: fact.title, body: fact.body, tags: fact.tags },
|
|
@@ -4310,6 +4372,7 @@ var WikiMemory = class {
|
|
|
4310
4372
|
this.db = withSerializedTransactions(db);
|
|
4311
4373
|
this.options = options;
|
|
4312
4374
|
warnChangedDefaultsOnce(options.config);
|
|
4375
|
+
resolveContextBudgetOrThrow(options.config);
|
|
4313
4376
|
this.prefix = options.config?.tablePrefix ?? "llm_wiki_";
|
|
4314
4377
|
if (!TABLE_PREFIX_PATTERN.test(this.prefix)) {
|
|
4315
4378
|
throw new Error(
|
|
@@ -4339,7 +4402,7 @@ var WikiMemory = class {
|
|
|
4339
4402
|
new MiniSearchIndexStrategy()
|
|
4340
4403
|
);
|
|
4341
4404
|
this.temporalService = new TemporalService(this.db, this.options, this.entryRepo, this.searchService, this.embeddingService);
|
|
4342
|
-
this.rememberService = new RememberService(this.db, this.entryRepo, this.ontologyService, this.searchService, this.embeddingService);
|
|
4405
|
+
this.rememberService = new RememberService(this.db, this.entryRepo, this.ontologyService, this.searchService, this.embeddingService, this.options);
|
|
4343
4406
|
this.jobManager = new JobManager(this.prefix);
|
|
4344
4407
|
this.promptService = new PromptService(options.config?.prompts, resolveGrounding(options.config?.grounding));
|
|
4345
4408
|
this.ingestionService = new IngestionService(
|
|
@@ -6426,6 +6489,11 @@ function parseOkfBundle(entityId, files, options) {
|
|
|
6426
6489
|
};
|
|
6427
6490
|
}
|
|
6428
6491
|
|
|
6492
|
+
// src/utils/contextBudget.ts
|
|
6493
|
+
function estimateTokensWith(budget, text) {
|
|
6494
|
+
return Math.ceil(text.length / budget.charsPerToken);
|
|
6495
|
+
}
|
|
6496
|
+
|
|
6429
6497
|
// src/librarianPrompt.ts
|
|
6430
6498
|
var DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT = `You are a careful memory synthesis assistant.
|
|
6431
6499
|
Use only the retrieved context when answering the request.
|
|
@@ -6470,6 +6538,6 @@ function createWiki(db, options) {
|
|
|
6470
6538
|
return new WikiMemory(db, options);
|
|
6471
6539
|
}
|
|
6472
6540
|
|
|
6473
|
-
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, WikiMemory, buildOntologyPromptAppendix, createWiki, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseOkfBundle, resolveOntologyJobDefaults, validateLibrarianPromptTemplate };
|
|
6541
|
+
export { DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, WikiMemory, buildOntologyPromptAppendix, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseOkfBundle, resolveOntologyJobDefaults, validateLibrarianPromptTemplate };
|
|
6474
6542
|
//# sourceMappingURL=index.mjs.map
|
|
6475
6543
|
//# sourceMappingURL=index.mjs.map
|