@equationalapplications/core-llm-wiki 8.4.0 → 9.0.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/README.md +1 -1
- package/dist/{chunk-EKYWAR2E.mjs → chunk-G2H6TJUC.mjs} +130 -25
- package/dist/chunk-G2H6TJUC.mjs.map +1 -0
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +141 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-Og5x9rFu.d.mts → testing-s6DBqXxQ.d.mts} +73 -9
- package/dist/{testing-Og5x9rFu.d.ts → testing-s6DBqXxQ.d.ts} +73 -9
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +126 -21
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-EKYWAR2E.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ The [Node.js quickstart](https://equationalapplications.github.io/expo-llm-wiki/
|
|
|
59
59
|
| [@equationalapplications/core-llm-tools](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/core-llm-tools/README.md) | Gemini tool schemas and capability injector |
|
|
60
60
|
| [@equationalapplications/core-okf](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/okf/README.md) | Zero-dependency Open Knowledge Format (OKF) v0.1 + v0.2 primitives — parse and produce interoperable knowledge bundles. |
|
|
61
61
|
| [@equationalapplications/schema-org-llm-wiki](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/schema-org/README.md) | Curated schema.org warm-agent ontology manifest |
|
|
62
|
-
| [@equationalapplications/schema-software-org](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/schema-software-org/README.md) | Software-organization executive ontology manifest —
|
|
62
|
+
| [@equationalapplications/schema-software-org](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/schema-software-org/README.md) | Software-organization executive ontology manifest — 21 node types, 42 edges, warm-agent superset, data-only |
|
|
63
63
|
| [@equationalapplications/mcp-server](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/mcp-server/README.md) | MCP server exposing SynapseTree memory tools to coding agents |
|
|
64
64
|
|
|
65
65
|
## License
|
|
@@ -1785,6 +1785,14 @@ var JobManager = class {
|
|
|
1785
1785
|
};
|
|
1786
1786
|
|
|
1787
1787
|
// src/prompts.ts
|
|
1788
|
+
var LEAVE_OUT_RULE_SENTENCE = "Memory leaves out what a better record already holds, and points to that record.";
|
|
1789
|
+
var GUIDANCE_MAX_CHARS = 2e3;
|
|
1790
|
+
function guidanceSection(guidance) {
|
|
1791
|
+
return `--- Host guidance ---
|
|
1792
|
+
${guidance}
|
|
1793
|
+
--- End host guidance ---
|
|
1794
|
+
${LEAVE_OUT_RULE_SENTENCE}`;
|
|
1795
|
+
}
|
|
1788
1796
|
var LIBRARIAN_SYSTEM_PROMPT = `You are a knowledge extraction agent. Your job is to analyze recent episodic events and extract stable facts and actionable tasks about the user or entity.
|
|
1789
1797
|
Return ONLY a valid JSON object matching this schema:
|
|
1790
1798
|
{
|
|
@@ -1908,6 +1916,64 @@ var PromptService = class {
|
|
|
1908
1916
|
this.globalOverrides = globalOverrides;
|
|
1909
1917
|
this.grounding = grounding;
|
|
1910
1918
|
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Specs/librarian-guidance: resolve the effective guidance for one pass
|
|
1921
|
+
* or call — default `config.prompts.guidance`, per-entity
|
|
1922
|
+
* `config.librarian.guidanceForEntity` winning when it returns a
|
|
1923
|
+
* non-empty (trimmed) string. Synchronous: a resolver that throws,
|
|
1924
|
+
* returns a thenable (its rejection is swallowed with a no-op handler;
|
|
1925
|
+
* a throwing `then` counts too), or returns any non-string value is
|
|
1926
|
+
* treated as "no value" and reported in `diagnostic`. Over-cap text
|
|
1927
|
+
* (UTF-16 units, verbatim) is not sent and reported in `diagnostic`.
|
|
1928
|
+
* Emits nothing itself; the caller emits, immediately at resolution.
|
|
1929
|
+
*/
|
|
1930
|
+
static resolveGuidance(config, entityId) {
|
|
1931
|
+
let source = null;
|
|
1932
|
+
let effective;
|
|
1933
|
+
let resolverDiagnostic;
|
|
1934
|
+
const defaultValue = config?.prompts?.guidance;
|
|
1935
|
+
const resolver = config?.librarian?.guidanceForEntity;
|
|
1936
|
+
let entityValue;
|
|
1937
|
+
if (resolver) {
|
|
1938
|
+
try {
|
|
1939
|
+
entityValue = resolver(entityId);
|
|
1940
|
+
if (entityValue === void 0) {
|
|
1941
|
+
} else if (typeof entityValue === "string") {
|
|
1942
|
+
if (entityValue.trim() !== "") {
|
|
1943
|
+
source = "per_entity";
|
|
1944
|
+
effective = entityValue;
|
|
1945
|
+
}
|
|
1946
|
+
} else {
|
|
1947
|
+
try {
|
|
1948
|
+
entityValue?.then?.(() => void 0, () => void 0);
|
|
1949
|
+
} catch {
|
|
1950
|
+
}
|
|
1951
|
+
resolverDiagnostic = {
|
|
1952
|
+
code: "guidance_resolver_failed",
|
|
1953
|
+
detail: { reason: "non_string" }
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
} catch {
|
|
1957
|
+
resolverDiagnostic = { code: "guidance_resolver_failed", detail: { reason: "threw" } };
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
if (source === null && defaultValue !== void 0 && defaultValue.trim() !== "") {
|
|
1961
|
+
source = "default";
|
|
1962
|
+
effective = defaultValue;
|
|
1963
|
+
}
|
|
1964
|
+
if (source === null || effective === void 0) {
|
|
1965
|
+
return resolverDiagnostic ? { diagnostic: resolverDiagnostic } : {};
|
|
1966
|
+
}
|
|
1967
|
+
if (effective.length > GUIDANCE_MAX_CHARS) {
|
|
1968
|
+
return {
|
|
1969
|
+
diagnostic: {
|
|
1970
|
+
code: "guidance_too_long",
|
|
1971
|
+
detail: { guidanceLength: effective.length, guidanceSource: source }
|
|
1972
|
+
}
|
|
1973
|
+
};
|
|
1974
|
+
}
|
|
1975
|
+
return resolverDiagnostic ? { guidance: effective, diagnostic: resolverDiagnostic } : { guidance: effective };
|
|
1976
|
+
}
|
|
1911
1977
|
/** The resolved grounding config when `writer` is in `grounding.writers`; otherwise null (spec §6.2). */
|
|
1912
1978
|
groundingFor(writer) {
|
|
1913
1979
|
return this.grounding?.writers.has(writer) ? this.grounding : null;
|
|
@@ -1918,6 +1984,19 @@ var PromptService = class {
|
|
|
1918
1984
|
return cfg ? `${systemPrompt}
|
|
1919
1985
|
|
|
1920
1986
|
${groundingEvidenceBlock(writer, cfg)}` : systemPrompt;
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Specs/librarian-guidance: append the marked guidance section (with the
|
|
1990
|
+
* general leave-out rule) to the ALREADY-HYDRATED system prompt — after
|
|
1991
|
+
* ontology, immediately before grounding. The guidance text is never
|
|
1992
|
+
* run through hydration, so `{{…}}` inside it cannot change a builder's
|
|
1993
|
+
* template branch or be expanded with data. No-op on empty input.
|
|
1994
|
+
*/
|
|
1995
|
+
appendGuidance(systemPrompt, guidance) {
|
|
1996
|
+
if (!guidance) return systemPrompt;
|
|
1997
|
+
return `${systemPrompt}
|
|
1998
|
+
|
|
1999
|
+
${guidanceSection(guidance)}`;
|
|
1921
2000
|
}
|
|
1922
2001
|
hydrate(template, variables) {
|
|
1923
2002
|
return template.replace(/\{\{\s*(\w+)\s*\}\}/g, (_match, key) => {
|
|
@@ -1954,31 +2033,31 @@ ${groundingEvidenceBlock(writer, cfg)}` : systemPrompt;
|
|
|
1954
2033
|
|
|
1955
2034
|
${ctx.ontologyModeInstructions}`;
|
|
1956
2035
|
}
|
|
1957
|
-
buildIngestPrompt(documentChunk, runtimeOverride, ontologyContext) {
|
|
2036
|
+
buildIngestPrompt(documentChunk, runtimeOverride, ontologyContext, guidance) {
|
|
1958
2037
|
const template = runtimeOverride ?? this.globalOverrides?.ingestSystemPrompt ?? INGEST_SYSTEM_PROMPT;
|
|
1959
2038
|
const hasDocumentChunk = /\{\{\s*documentChunk\s*\}\}/.test(template);
|
|
1960
2039
|
if (hasDocumentChunk || this.hasOntologyPlaceholders(template)) {
|
|
1961
2040
|
return {
|
|
1962
|
-
systemPrompt: this.appendGrounding(this.buildSystemPrompt(template, { documentChunk }, ontologyContext), "ingest"),
|
|
2041
|
+
systemPrompt: this.appendGrounding(this.appendGuidance(this.buildSystemPrompt(template, { documentChunk }, ontologyContext), guidance), "ingest"),
|
|
1963
2042
|
userPrompt: hasDocumentChunk ? "Please extract the facts." : `Document Chunk:
|
|
1964
2043
|
${documentChunk}`
|
|
1965
2044
|
};
|
|
1966
2045
|
}
|
|
1967
2046
|
return {
|
|
1968
|
-
systemPrompt: this.appendGrounding(this.appendOntology(template, ontologyContext), "ingest"),
|
|
2047
|
+
systemPrompt: this.appendGrounding(this.appendGuidance(this.appendOntology(template, ontologyContext), guidance), "ingest"),
|
|
1969
2048
|
userPrompt: `Document Chunk:
|
|
1970
2049
|
${documentChunk}`
|
|
1971
2050
|
};
|
|
1972
2051
|
}
|
|
1973
|
-
buildLibrarianPrompt(events, currentFacts, runtimeOverride, ontologyContext) {
|
|
1974
|
-
const template = runtimeOverride ??
|
|
2052
|
+
buildLibrarianPrompt(events, currentFacts, runtimeOverride, ontologyContext, guidance) {
|
|
2053
|
+
const template = runtimeOverride ?? LIBRARIAN_SYSTEM_PROMPT;
|
|
1975
2054
|
const hasEvents = /\{\{\s*events\s*\}\}/.test(template);
|
|
1976
2055
|
const hasCurrentFacts = /\{\{\s*currentFacts\s*\}\}/.test(template);
|
|
1977
2056
|
const eventsShown = hasEvents || !hasCurrentFacts;
|
|
1978
2057
|
const corpusField = this.groundingFor("librarian") ? { groundingCorpus: buildGroundingCorpus(eventsShown ? events.map(summaryOf) : []) } : {};
|
|
1979
2058
|
if (hasEvents || hasCurrentFacts || this.hasOntologyPlaceholders(template)) {
|
|
1980
2059
|
return {
|
|
1981
|
-
systemPrompt: this.appendGrounding(this.buildSystemPrompt(template, { events, currentFacts }, ontologyContext), "librarian"),
|
|
2060
|
+
systemPrompt: this.appendGrounding(this.appendGuidance(this.buildSystemPrompt(template, { events, currentFacts }, ontologyContext), guidance), "librarian"),
|
|
1982
2061
|
userPrompt: hasEvents || hasCurrentFacts ? "Please synthesize the context." : `Events:
|
|
1983
2062
|
${JSON.stringify(events, null, 2)}
|
|
1984
2063
|
|
|
@@ -1988,7 +2067,7 @@ ${JSON.stringify(currentFacts, null, 2)}`,
|
|
|
1988
2067
|
};
|
|
1989
2068
|
}
|
|
1990
2069
|
return {
|
|
1991
|
-
systemPrompt: this.appendGrounding(this.appendOntology(template, ontologyContext), "librarian"),
|
|
2070
|
+
systemPrompt: this.appendGrounding(this.appendGuidance(this.appendOntology(template, ontologyContext), guidance), "librarian"),
|
|
1992
2071
|
userPrompt: `Events:
|
|
1993
2072
|
${JSON.stringify(events, null, 2)}
|
|
1994
2073
|
|
|
@@ -2091,11 +2170,11 @@ ${JSON.stringify(facts, null, 2)}`
|
|
|
2091
2170
|
};
|
|
2092
2171
|
}
|
|
2093
2172
|
/** Ops extract (spec §5.2): events only — no existing facts. */
|
|
2094
|
-
buildOpsExtractPrompt(events, ontologyContext) {
|
|
2173
|
+
buildOpsExtractPrompt(events, ontologyContext, guidance) {
|
|
2095
2174
|
const lines = events.map((l) => `${l.label} [${new Date(l.at).toISOString()}] (${l.event.event_type}) ${l.event.summary}`);
|
|
2096
2175
|
const grounding = this.groundingFor("librarian");
|
|
2097
2176
|
return {
|
|
2098
|
-
systemPrompt: this.appendGrounding(this.appendOntology(OPS_EXTRACT_SYSTEM_PROMPT, ontologyContext), "librarian"),
|
|
2177
|
+
systemPrompt: this.appendGrounding(this.appendGuidance(this.appendOntology(OPS_EXTRACT_SYSTEM_PROMPT, ontologyContext), guidance), "librarian"),
|
|
2099
2178
|
userPrompt: `Events:
|
|
2100
2179
|
${lines.join("\n")}`,
|
|
2101
2180
|
...grounding ? { groundingCorpus: buildGroundingCorpus(events.map((l) => l.event.summary)) } : {}
|
|
@@ -2112,11 +2191,11 @@ ${JSON.stringify({ items })}` };
|
|
|
2112
2191
|
* placeholders and leaves data placeholders verbatim; heal never receives
|
|
2113
2192
|
* ontology context, matching `buildHealPrompt`.
|
|
2114
2193
|
*/
|
|
2115
|
-
buildInstructionTemplates(ontologyContext, librarianStrategy) {
|
|
2194
|
+
buildInstructionTemplates(ontologyContext, librarianStrategy, guidance) {
|
|
2116
2195
|
const o = this.globalOverrides;
|
|
2117
2196
|
return {
|
|
2118
|
-
ingest: this.appendGrounding(this.buildSystemPrompt(o?.ingestSystemPrompt ?? INGEST_SYSTEM_PROMPT, {}, ontologyContext), "ingest"),
|
|
2119
|
-
librarian: librarianStrategy === "ops" ? this.appendGrounding(this.appendOntology(OPS_EXTRACT_SYSTEM_PROMPT, ontologyContext), "librarian") : this.appendGrounding(this.buildSystemPrompt(
|
|
2197
|
+
ingest: this.appendGrounding(this.appendGuidance(this.buildSystemPrompt(o?.ingestSystemPrompt ?? INGEST_SYSTEM_PROMPT, {}, ontologyContext), guidance), "ingest"),
|
|
2198
|
+
librarian: librarianStrategy === "ops" ? this.appendGrounding(this.appendGuidance(this.appendOntology(OPS_EXTRACT_SYSTEM_PROMPT, ontologyContext), guidance), "librarian") : this.appendGrounding(this.appendGuidance(this.buildSystemPrompt(LIBRARIAN_SYSTEM_PROMPT, {}, ontologyContext), guidance), "librarian"),
|
|
2120
2199
|
heal: this.appendGrounding(o?.healSystemPrompt ?? HEAL_SYSTEM_PROMPT, "heal"),
|
|
2121
2200
|
ontologyBackfill: this.buildSystemPrompt(o?.ontologyBackfillSystemPrompt ?? ONTOLOGY_BACKFILL_SYSTEM_PROMPT, {}, ontologyContext)
|
|
2122
2201
|
};
|
|
@@ -2195,7 +2274,9 @@ var SEVERITY = {
|
|
|
2195
2274
|
event_created_at_clamped: "warn",
|
|
2196
2275
|
event_created_at_restamped: "info",
|
|
2197
2276
|
external_deletion_pending: "warn",
|
|
2198
|
-
external_deletion_discarded: "warn"
|
|
2277
|
+
external_deletion_discarded: "warn",
|
|
2278
|
+
guidance_too_long: "warn",
|
|
2279
|
+
guidance_resolver_failed: "warn"
|
|
2199
2280
|
};
|
|
2200
2281
|
var MESSAGE = {
|
|
2201
2282
|
ingest_chunk_failed: "One or more document chunks failed to parse or generate.",
|
|
@@ -2221,7 +2302,9 @@ var MESSAGE = {
|
|
|
2221
2302
|
event_created_at_clamped: "Imported events dated in the future were re-dated just after the current time, or after the librarian position if that is later, keeping their order.",
|
|
2222
2303
|
event_created_at_restamped: "Imported events that would have sorted behind the librarian position, or had an unusable date, were adjusted: an affected created_at was re-dated just after the current time, or after the librarian position if that is later, keeping their order; an unusable occurred_at was cleared.",
|
|
2223
2304
|
external_deletion_pending: "Removals owed to the external vector index are still pending.",
|
|
2224
|
-
external_deletion_discarded: "Pending external vector removals were discarded because forceDeleteIgnoreRankerHook is set."
|
|
2305
|
+
external_deletion_discarded: "Pending external vector removals were discarded because forceDeleteIgnoreRankerHook is set.",
|
|
2306
|
+
guidance_too_long: "The configured guidance exceeded the length cap and was not sent for this pass.",
|
|
2307
|
+
guidance_resolver_failed: "The per-entity guidance resolver failed; its value was not used for this pass."
|
|
2225
2308
|
};
|
|
2226
2309
|
var warnedNonFunction = /* @__PURE__ */ new WeakSet();
|
|
2227
2310
|
function copyDetail(detail) {
|
|
@@ -2448,13 +2531,24 @@ var IngestionService = class {
|
|
|
2448
2531
|
const { chunks: chunks2, truncated } = chunkText(params.documentChunk, maxChunkLength, chunkOverlap);
|
|
2449
2532
|
if (chunks2.length === 0) return zeroChunkResult();
|
|
2450
2533
|
const ontologyContext = await this.ontologyService?.buildPromptContext(entityId) ?? null;
|
|
2534
|
+
const { guidance, diagnostic } = PromptService.resolveGuidance(this.options.config, entityId);
|
|
2535
|
+
if (diagnostic) {
|
|
2536
|
+
emitDiagnostic(this.options, {
|
|
2537
|
+
code: diagnostic.code,
|
|
2538
|
+
operation: "ingest",
|
|
2539
|
+
trigger: "call",
|
|
2540
|
+
entityId,
|
|
2541
|
+
detail: diagnostic.detail
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2451
2544
|
const ingestGrounding = this.promptService.groundingFor("ingest");
|
|
2452
2545
|
const chunkResults = await withConcurrency(
|
|
2453
2546
|
chunks2.map((chunk, chunkIndex) => async () => {
|
|
2454
2547
|
const { systemPrompt, userPrompt } = this.promptService.buildIngestPrompt(
|
|
2455
2548
|
chunk,
|
|
2456
2549
|
params.promptOverride,
|
|
2457
|
-
ontologyContext
|
|
2550
|
+
ontologyContext,
|
|
2551
|
+
guidance
|
|
2458
2552
|
);
|
|
2459
2553
|
try {
|
|
2460
2554
|
const responseText = await callLlm(this.options, { operation: "ingest", entityId, trigger: "call" }, { systemPrompt, userPrompt });
|
|
@@ -3093,9 +3187,9 @@ function changedDefaultWarnings(config) {
|
|
|
3093
3187
|
"[core-llm-wiki] auto-run thresholds are set, but `maintenance` now defaults to 'deferred', so write() will not start the librarian or heal. Set `maintenance: 'auto'` or call runPendingMaintenance()."
|
|
3094
3188
|
);
|
|
3095
3189
|
}
|
|
3096
|
-
if (config?.prompts?.librarianSystemPrompt !== void 0
|
|
3190
|
+
if (config?.prompts?.librarianSystemPrompt !== void 0) {
|
|
3097
3191
|
warnings.push(
|
|
3098
|
-
"[core-llm-wiki] `prompts.librarianSystemPrompt`
|
|
3192
|
+
"[core-llm-wiki] `prompts.librarianSystemPrompt` was removed in 9.0.0 and its value is ignored. Move the domain part of it to `prompts.guidance`, which works under both librarian strategies."
|
|
3099
3193
|
);
|
|
3100
3194
|
}
|
|
3101
3195
|
if (config?.librarian?.strategy === "legacy" && config?.maintenance === void 0 && !hasThreshold) {
|
|
@@ -5098,7 +5192,8 @@ var runLegacyLibrarianPass = async (deps, ctx) => {
|
|
|
5098
5192
|
promptEvents,
|
|
5099
5193
|
currentFacts,
|
|
5100
5194
|
promptOverride,
|
|
5101
|
-
ontologyContext
|
|
5195
|
+
ontologyContext,
|
|
5196
|
+
ctx.guidance
|
|
5102
5197
|
);
|
|
5103
5198
|
let responseText;
|
|
5104
5199
|
try {
|
|
@@ -5270,7 +5365,7 @@ var OPS_MAX_EVENTS_PER_PASS = 50;
|
|
|
5270
5365
|
var OPS_MAX_EXTRACT_CHARS = 24e3;
|
|
5271
5366
|
var RESOLVE_RESERVE_FACTOR = 2;
|
|
5272
5367
|
var estimatePrompt = (p) => estimateTokens(p.systemPrompt) + estimateTokens(p.userPrompt);
|
|
5273
|
-
async function selectBatch(deps, entityId, wm, meter) {
|
|
5368
|
+
async function selectBatch(deps, entityId, wm, meter, guidance) {
|
|
5274
5369
|
const events = await deps.eventRepo.getAfter(entityId, wm, OPS_MAX_EVENTS_PER_PASS);
|
|
5275
5370
|
if (events.length === 0) return { batch: [] };
|
|
5276
5371
|
let n = 0;
|
|
@@ -5284,7 +5379,7 @@ async function selectBatch(deps, entityId, wm, meter) {
|
|
|
5284
5379
|
if (meter && meter.budget !== void 0) {
|
|
5285
5380
|
const ontologyContext = await deps.ontologyService?.buildPromptContext(entityId) ?? null;
|
|
5286
5381
|
for (; ; ) {
|
|
5287
|
-
const need = RESOLVE_RESERVE_FACTOR * estimatePrompt(deps.promptService.buildOpsExtractPrompt(batch, ontologyContext));
|
|
5382
|
+
const need = RESOLVE_RESERVE_FACTOR * estimatePrompt(deps.promptService.buildOpsExtractPrompt(batch, ontologyContext, guidance));
|
|
5288
5383
|
if (meter.fits(need)) break;
|
|
5289
5384
|
if (batch.length === 1) return { budgetStop: { requiredEstimate: need } };
|
|
5290
5385
|
batch = labelEvents(events.slice(0, Math.max(1, Math.floor(batch.length / 2))));
|
|
@@ -5295,7 +5390,7 @@ async function selectBatch(deps, entityId, wm, meter) {
|
|
|
5295
5390
|
async function runExtract(deps, ctx, batch) {
|
|
5296
5391
|
const { entityId, trigger } = ctx;
|
|
5297
5392
|
const ontologyContext = await deps.ontologyService?.buildPromptContext(entityId) ?? null;
|
|
5298
|
-
const prompt = deps.promptService.buildOpsExtractPrompt(batch, ontologyContext);
|
|
5393
|
+
const prompt = deps.promptService.buildOpsExtractPrompt(batch, ontologyContext, ctx.guidance);
|
|
5299
5394
|
const text = await callLlm(deps.options, { operation: "librarian", entityId, trigger, meter: ctx.meter }, prompt);
|
|
5300
5395
|
const parsed = parseJsonResponse(text);
|
|
5301
5396
|
const base = { entityId, operation: "librarian", trigger };
|
|
@@ -5753,7 +5848,7 @@ var runOpsLibrarianPass = async (deps, ctx) => {
|
|
|
5753
5848
|
const cfg = resolveGateConfig(deps.options.config?.librarian?.gate);
|
|
5754
5849
|
await deps.seedWatermark(entityId);
|
|
5755
5850
|
const wm = await deps.getWatermark(entityId);
|
|
5756
|
-
const sel = await selectBatch(deps, entityId, wm, ctx.meter);
|
|
5851
|
+
const sel = await selectBatch(deps, entityId, wm, ctx.meter, ctx.guidance);
|
|
5757
5852
|
if ("budgetStop" in sel) return { processedThrough: null, factsWritten: 0, budgetStop: sel.budgetStop };
|
|
5758
5853
|
if (sel.batch.length === 0) return { processedThrough: null, factsWritten: 0 };
|
|
5759
5854
|
if (!deps.searchService.isKeywordAvailable() && await gateNeedsKeyword(deps, entityId)) {
|
|
@@ -6391,7 +6486,17 @@ var MaintenanceService = class {
|
|
|
6391
6486
|
* A budget-stopped pass wrote nothing and must not move the watermark.
|
|
6392
6487
|
*/
|
|
6393
6488
|
async runLibrarianPass(ctx) {
|
|
6394
|
-
const
|
|
6489
|
+
const { guidance, diagnostic } = PromptService.resolveGuidance(this.options.config, ctx.entityId);
|
|
6490
|
+
if (diagnostic) {
|
|
6491
|
+
emitDiagnostic(this.options, {
|
|
6492
|
+
code: diagnostic.code,
|
|
6493
|
+
operation: "librarian",
|
|
6494
|
+
trigger: ctx.trigger,
|
|
6495
|
+
entityId: ctx.entityId,
|
|
6496
|
+
detail: diagnostic.detail
|
|
6497
|
+
});
|
|
6498
|
+
}
|
|
6499
|
+
const result = await runLibrarianStrategy(this.librarianDeps(), { ...ctx, guidance });
|
|
6395
6500
|
if (result.processedThrough && !result.budgetStop) {
|
|
6396
6501
|
await this.advanceLibrarianWatermark(ctx.entityId, result.processedThrough);
|
|
6397
6502
|
}
|
|
@@ -8994,5 +9099,5 @@ var WriteService = class {
|
|
|
8994
9099
|
};
|
|
8995
9100
|
|
|
8996
9101
|
export { BaseRepository, CURRENT_SCHEMA_VERSION, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, TemporalService, UnavailableIndexStrategy, UsageMeter, VectorRemovalRepository, VectorRemovalService, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, chunkText, configureRandomSource, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emitDiagnostic, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveEdgeDefinitions, resolveGrounding, resolveLibrarianStrategy, resolveNodeType, retiredTableName, runSourceRefNormalize, safeSlice, setupDatabase, sweepChunkSql, sweepHiSql, typeSatisfies, validateInlineEdges, validateManifest, warnChangedDefaultsOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
8997
|
-
//# sourceMappingURL=chunk-
|
|
8998
|
-
//# sourceMappingURL=chunk-
|
|
9102
|
+
//# sourceMappingURL=chunk-G2H6TJUC.mjs.map
|
|
9103
|
+
//# sourceMappingURL=chunk-G2H6TJUC.mjs.map
|