@equationalapplications/core-llm-wiki 9.5.3 → 9.7.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-QIS2SGUM.mjs → chunk-6UTHJFXH.mjs} +390 -95
- package/dist/chunk-6UTHJFXH.mjs.map +1 -0
- package/dist/index.d.mts +91 -17
- package/dist/index.d.ts +91 -17
- package/dist/index.js +434 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -12
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BA6CedgZ.d.mts → testing-T0GgG1L6.d.mts} +152 -11
- package/dist/{testing-BA6CedgZ.d.ts → testing-T0GgG1L6.d.ts} +152 -11
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +347 -54
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-QIS2SGUM.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, R as ReadOptions, S as SQLiteAdapter,
|
|
2
|
-
export { C as CheckpointIncompleteError,
|
|
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-T0GgG1L6.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_MAX_PROMPT_CHARS, $ 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 isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-T0GgG1L6.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -62,6 +62,22 @@ declare const HEAL_MAX_FACT_BODY_CHARS_L3 = 4000;
|
|
|
62
62
|
*/
|
|
63
63
|
declare const HEAL_MAX_TASKS = 50;
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Default maximum characters per chunk that `ingestDocument` uses when a
|
|
67
|
+
* caller doesn't override `maxChunkLength` (directly or via
|
|
68
|
+
* `WikiOptions.config.maxChunkLength`).
|
|
69
|
+
*/
|
|
70
|
+
declare const DEFAULT_MAX_CHUNK_LENGTH = 12000;
|
|
71
|
+
/**
|
|
72
|
+
* Default/fallback character overlap between consecutive chunks.
|
|
73
|
+
* `ingestDocument` uses this when a caller doesn't override `chunkOverlap`
|
|
74
|
+
* (directly or via `WikiOptions.config.chunkOverlap`), and clamps the
|
|
75
|
+
* effective overlap (including this default) to `maxChunkLength - 1` when
|
|
76
|
+
* needed. The clamp is a no-op for the shipped defaults; it can also apply
|
|
77
|
+
* when a custom `maxChunkLength` makes the resolved overlap too large.
|
|
78
|
+
*/
|
|
79
|
+
declare const DEFAULT_CHUNK_OVERLAP = 400;
|
|
80
|
+
|
|
65
81
|
declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
|
|
66
82
|
|
|
67
83
|
/**
|
|
@@ -111,20 +127,32 @@ declare function validUsage(u: unknown): u is {
|
|
|
111
127
|
};
|
|
112
128
|
|
|
113
129
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*
|
|
121
|
-
* `ingestDocument` uses this when a caller doesn't override `chunkOverlap`
|
|
122
|
-
* (directly or via `WikiOptions.config.chunkOverlap`), and clamps the
|
|
123
|
-
* effective overlap (including this default) to `maxChunkLength - 1` when
|
|
124
|
-
* needed. The clamp is a no-op for the shipped defaults; it can also apply
|
|
125
|
-
* when a custom `maxChunkLength` makes the resolved overlap too large.
|
|
130
|
+
* Context-budget wrapper (specs/context-budget Proposed change 2).
|
|
131
|
+
*
|
|
132
|
+
* Core ships no tokenizer: every estimate is chars/`charsPerToken`. The
|
|
133
|
+
* meter keeps plain `estimateTokens` (chars/4) this PR — metering is out of
|
|
134
|
+
* scope — so `estimateTokensWith` under a legacy budget (`charsPerToken: 4`)
|
|
135
|
+
* is byte-equal to `estimateTokens` for every input, and the wrapper ships
|
|
136
|
+
* unused by metering.
|
|
126
137
|
*/
|
|
127
|
-
|
|
138
|
+
interface ContextBudget {
|
|
139
|
+
mode: 'legacy' | 'declared';
|
|
140
|
+
/** Set iff mode === 'declared'. */
|
|
141
|
+
contextWindowTokens?: number;
|
|
142
|
+
/** 4 under legacy. */
|
|
143
|
+
charsPerToken: number;
|
|
144
|
+
/** 0.9 under legacy (unused in legacy math). */
|
|
145
|
+
safetyFraction: number;
|
|
146
|
+
/** 4000 under legacy (unused in legacy math). */
|
|
147
|
+
outputReserveTokens: number;
|
|
148
|
+
}
|
|
149
|
+
declare function estimateTokensWith(budget: ContextBudget, text: string): number;
|
|
150
|
+
|
|
151
|
+
type ContextBudgetOp = 'resolve' | 'heal' | 'extract';
|
|
152
|
+
declare function resolveContextBudget(config: WikiConfig | undefined): ContextBudget;
|
|
153
|
+
declare function resolveMaxPromptChars(budget: ContextBudget, op: ContextBudgetOp): number;
|
|
154
|
+
/** The ingest chunk default stays 12000 in both modes (ruling R2). */
|
|
155
|
+
declare function resolveDefaultChunkLength(budget: ContextBudget): number;
|
|
128
156
|
|
|
129
157
|
/**
|
|
130
158
|
* Default clamp on embed input length, in characters (~1,500 tokens).
|
|
@@ -167,9 +195,55 @@ declare function validateLibrarianPromptTemplate(template: string, options: {
|
|
|
167
195
|
}): string[];
|
|
168
196
|
declare function mapLibrarianOptionsToReadOptions(options: LibrarianOptions): Pick<ReadOptions, 'tierWeights' | 'includeZeroWeightEntities'>;
|
|
169
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The one place the ontology-backfill scheduler default is defined
|
|
200
|
+
* (specs/system-one-config §8). Read sites resolve through this so a host
|
|
201
|
+
* that sets nothing gets the same answer everywhere — the same discipline as
|
|
202
|
+
* `engineDefaults.ts` for the 8.0.0 librarian/maintenance defaults.
|
|
203
|
+
*/
|
|
204
|
+
/** Default batch size for scheduler-driven ontology backfill passes. */
|
|
205
|
+
declare const DEFAULT_ONTOLOGY_JOB_BATCH_SIZE = 50;
|
|
206
|
+
interface OntologyJobDefaults {
|
|
207
|
+
batchSize: number;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Resolve the scheduler's ontology-backfill batch size from
|
|
211
|
+
* `WikiConfig.ontology.schedulerBatchSize`. Invalid values (non-finite, < 1)
|
|
212
|
+
* fall back to the default rather than throwing — a bad config value degrades
|
|
213
|
+
* to the default instead of breaking construction or every run.
|
|
214
|
+
*/
|
|
215
|
+
declare function resolveOntologyJobDefaults(ontology: OntologyConfig | undefined): OntologyJobDefaults;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Logs each distinct message at most once per process, sharing the
|
|
219
|
+
* {@link warnedDefaults} set with `warnChangedDefaultsOnce`. System-One
|
|
220
|
+
* resolvers use this for invalid config values (treated as unset) and
|
|
221
|
+
* both-keys-disagree notices (specs/system-one-config §2-§3). Messages carry
|
|
222
|
+
* a distinct `[core-llm-wiki] systemOne:` prefix, so a malformed message can
|
|
223
|
+
* never suppress a defaults-changed warning (plan Risks).
|
|
224
|
+
*/
|
|
225
|
+
declare function warnOnce(message: string): void;
|
|
226
|
+
/**
|
|
227
|
+
* Typing-mode resolution chain (specs/system-one-config §2):
|
|
228
|
+
* call option `classifier` → `systemOne.typing` →
|
|
229
|
+
* `ontology.backfillClassifier` → `'llm'`. The caller validates the call
|
|
230
|
+
* option (a TypeError at the pass boundary); config values validate here.
|
|
231
|
+
* `??` throughout — falsy config values never participate by accident.
|
|
232
|
+
*/
|
|
233
|
+
declare function resolveSystemOneTyping(config: WikiConfig | undefined, classifierCallOption?: 'auto' | 'llm'): 'auto' | 'llm';
|
|
234
|
+
/** Engine default confidence floor for classifier typing. */
|
|
235
|
+
declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
|
|
236
|
+
/**
|
|
237
|
+
* Confidence-floor chain (specs/system-one-config §3):
|
|
238
|
+
* `systemOne.minConfidence.typing` → `ontology.classifyMinConfidence` →
|
|
239
|
+
* `0.5`. `??` throughout, so a configured `0` stays `0`. Only the classifier
|
|
240
|
+
* typing path reads this; call it there, never on the generative path.
|
|
241
|
+
*/
|
|
242
|
+
declare function resolveTypingMinConfidence(config: WikiConfig | undefined): number;
|
|
243
|
+
|
|
170
244
|
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, omit that fact from \"classifications\" entirely \u2014 do not guess.\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.";
|
|
171
245
|
|
|
172
246
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
173
247
|
|
|
174
|
-
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_SETUP_BUDGET_MS, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyMode, ReadOptions, SQLiteAdapter, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, safeSlice, validUsage, validateLibrarianPromptTemplate };
|
|
175
|
-
export type { FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|
|
248
|
+
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_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
249
|
+
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, R as ReadOptions, S as SQLiteAdapter,
|
|
2
|
-
export { C as CheckpointIncompleteError,
|
|
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-T0GgG1L6.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_MAX_PROMPT_CHARS, $ 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 isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-T0GgG1L6.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -62,6 +62,22 @@ declare const HEAL_MAX_FACT_BODY_CHARS_L3 = 4000;
|
|
|
62
62
|
*/
|
|
63
63
|
declare const HEAL_MAX_TASKS = 50;
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Default maximum characters per chunk that `ingestDocument` uses when a
|
|
67
|
+
* caller doesn't override `maxChunkLength` (directly or via
|
|
68
|
+
* `WikiOptions.config.maxChunkLength`).
|
|
69
|
+
*/
|
|
70
|
+
declare const DEFAULT_MAX_CHUNK_LENGTH = 12000;
|
|
71
|
+
/**
|
|
72
|
+
* Default/fallback character overlap between consecutive chunks.
|
|
73
|
+
* `ingestDocument` uses this when a caller doesn't override `chunkOverlap`
|
|
74
|
+
* (directly or via `WikiOptions.config.chunkOverlap`), and clamps the
|
|
75
|
+
* effective overlap (including this default) to `maxChunkLength - 1` when
|
|
76
|
+
* needed. The clamp is a no-op for the shipped defaults; it can also apply
|
|
77
|
+
* when a custom `maxChunkLength` makes the resolved overlap too large.
|
|
78
|
+
*/
|
|
79
|
+
declare const DEFAULT_CHUNK_OVERLAP = 400;
|
|
80
|
+
|
|
65
81
|
declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
|
|
66
82
|
|
|
67
83
|
/**
|
|
@@ -111,20 +127,32 @@ declare function validUsage(u: unknown): u is {
|
|
|
111
127
|
};
|
|
112
128
|
|
|
113
129
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*
|
|
121
|
-
* `ingestDocument` uses this when a caller doesn't override `chunkOverlap`
|
|
122
|
-
* (directly or via `WikiOptions.config.chunkOverlap`), and clamps the
|
|
123
|
-
* effective overlap (including this default) to `maxChunkLength - 1` when
|
|
124
|
-
* needed. The clamp is a no-op for the shipped defaults; it can also apply
|
|
125
|
-
* when a custom `maxChunkLength` makes the resolved overlap too large.
|
|
130
|
+
* Context-budget wrapper (specs/context-budget Proposed change 2).
|
|
131
|
+
*
|
|
132
|
+
* Core ships no tokenizer: every estimate is chars/`charsPerToken`. The
|
|
133
|
+
* meter keeps plain `estimateTokens` (chars/4) this PR — metering is out of
|
|
134
|
+
* scope — so `estimateTokensWith` under a legacy budget (`charsPerToken: 4`)
|
|
135
|
+
* is byte-equal to `estimateTokens` for every input, and the wrapper ships
|
|
136
|
+
* unused by metering.
|
|
126
137
|
*/
|
|
127
|
-
|
|
138
|
+
interface ContextBudget {
|
|
139
|
+
mode: 'legacy' | 'declared';
|
|
140
|
+
/** Set iff mode === 'declared'. */
|
|
141
|
+
contextWindowTokens?: number;
|
|
142
|
+
/** 4 under legacy. */
|
|
143
|
+
charsPerToken: number;
|
|
144
|
+
/** 0.9 under legacy (unused in legacy math). */
|
|
145
|
+
safetyFraction: number;
|
|
146
|
+
/** 4000 under legacy (unused in legacy math). */
|
|
147
|
+
outputReserveTokens: number;
|
|
148
|
+
}
|
|
149
|
+
declare function estimateTokensWith(budget: ContextBudget, text: string): number;
|
|
150
|
+
|
|
151
|
+
type ContextBudgetOp = 'resolve' | 'heal' | 'extract';
|
|
152
|
+
declare function resolveContextBudget(config: WikiConfig | undefined): ContextBudget;
|
|
153
|
+
declare function resolveMaxPromptChars(budget: ContextBudget, op: ContextBudgetOp): number;
|
|
154
|
+
/** The ingest chunk default stays 12000 in both modes (ruling R2). */
|
|
155
|
+
declare function resolveDefaultChunkLength(budget: ContextBudget): number;
|
|
128
156
|
|
|
129
157
|
/**
|
|
130
158
|
* Default clamp on embed input length, in characters (~1,500 tokens).
|
|
@@ -167,9 +195,55 @@ declare function validateLibrarianPromptTemplate(template: string, options: {
|
|
|
167
195
|
}): string[];
|
|
168
196
|
declare function mapLibrarianOptionsToReadOptions(options: LibrarianOptions): Pick<ReadOptions, 'tierWeights' | 'includeZeroWeightEntities'>;
|
|
169
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The one place the ontology-backfill scheduler default is defined
|
|
200
|
+
* (specs/system-one-config §8). Read sites resolve through this so a host
|
|
201
|
+
* that sets nothing gets the same answer everywhere — the same discipline as
|
|
202
|
+
* `engineDefaults.ts` for the 8.0.0 librarian/maintenance defaults.
|
|
203
|
+
*/
|
|
204
|
+
/** Default batch size for scheduler-driven ontology backfill passes. */
|
|
205
|
+
declare const DEFAULT_ONTOLOGY_JOB_BATCH_SIZE = 50;
|
|
206
|
+
interface OntologyJobDefaults {
|
|
207
|
+
batchSize: number;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Resolve the scheduler's ontology-backfill batch size from
|
|
211
|
+
* `WikiConfig.ontology.schedulerBatchSize`. Invalid values (non-finite, < 1)
|
|
212
|
+
* fall back to the default rather than throwing — a bad config value degrades
|
|
213
|
+
* to the default instead of breaking construction or every run.
|
|
214
|
+
*/
|
|
215
|
+
declare function resolveOntologyJobDefaults(ontology: OntologyConfig | undefined): OntologyJobDefaults;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Logs each distinct message at most once per process, sharing the
|
|
219
|
+
* {@link warnedDefaults} set with `warnChangedDefaultsOnce`. System-One
|
|
220
|
+
* resolvers use this for invalid config values (treated as unset) and
|
|
221
|
+
* both-keys-disagree notices (specs/system-one-config §2-§3). Messages carry
|
|
222
|
+
* a distinct `[core-llm-wiki] systemOne:` prefix, so a malformed message can
|
|
223
|
+
* never suppress a defaults-changed warning (plan Risks).
|
|
224
|
+
*/
|
|
225
|
+
declare function warnOnce(message: string): void;
|
|
226
|
+
/**
|
|
227
|
+
* Typing-mode resolution chain (specs/system-one-config §2):
|
|
228
|
+
* call option `classifier` → `systemOne.typing` →
|
|
229
|
+
* `ontology.backfillClassifier` → `'llm'`. The caller validates the call
|
|
230
|
+
* option (a TypeError at the pass boundary); config values validate here.
|
|
231
|
+
* `??` throughout — falsy config values never participate by accident.
|
|
232
|
+
*/
|
|
233
|
+
declare function resolveSystemOneTyping(config: WikiConfig | undefined, classifierCallOption?: 'auto' | 'llm'): 'auto' | 'llm';
|
|
234
|
+
/** Engine default confidence floor for classifier typing. */
|
|
235
|
+
declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
|
|
236
|
+
/**
|
|
237
|
+
* Confidence-floor chain (specs/system-one-config §3):
|
|
238
|
+
* `systemOne.minConfidence.typing` → `ontology.classifyMinConfidence` →
|
|
239
|
+
* `0.5`. `??` throughout, so a configured `0` stays `0`. Only the classifier
|
|
240
|
+
* typing path reads this; call it there, never on the generative path.
|
|
241
|
+
*/
|
|
242
|
+
declare function resolveTypingMinConfidence(config: WikiConfig | undefined): number;
|
|
243
|
+
|
|
170
244
|
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, omit that fact from \"classifications\" entirely \u2014 do not guess.\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.";
|
|
171
245
|
|
|
172
246
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
173
247
|
|
|
174
|
-
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_SETUP_BUDGET_MS, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyMode, ReadOptions, SQLiteAdapter, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, safeSlice, validUsage, validateLibrarianPromptTemplate };
|
|
175
|
-
export type { FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|
|
248
|
+
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_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
249
|
+
export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|