@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 CHANGED
@@ -60,7 +60,7 @@ The [Node.js quickstart](https://equationalapplications.github.io/expo-llm-wiki/
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
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
- | [@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 |
63
+ | [@equationalapplications/mcp-server](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/mcp-server/README.md) | MCP server exposing hosted cloud memory tools to coding agents |
64
64
 
65
65
  ## License
66
66
 
@@ -2251,6 +2251,47 @@ Return ONLY a valid JSON object matching this schema:
2251
2251
  }
2252
2252
  If no manifest type fits a fact, omit that fact from "classifications" entirely \u2014 do not guess.
2253
2253
  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.`;
2254
+ var TITLE_CATALOG_MAX_ENTRIES = 200;
2255
+ function buildTitleCatalogBlock(rows) {
2256
+ const byKey = /* @__PURE__ */ new Map();
2257
+ for (const r of rows) {
2258
+ if (typeof r.title !== "string" || r.title.length === 0) continue;
2259
+ if (typeof r.okf_type !== "string" || r.okf_type.length === 0) continue;
2260
+ byKey.set(normalizeTitleKey(r.title), { title: r.title, okf_type: r.okf_type });
2261
+ }
2262
+ const typed = [...byKey.values()].sort((a, b) => a.title < b.title ? -1 : a.title > b.title ? 1 : 0);
2263
+ const CHAR_BUDGET = 8e3;
2264
+ const listed = [];
2265
+ let used = 0;
2266
+ for (const r of typed) {
2267
+ const line = `- ${JSON.stringify(r.title)} (${r.okf_type})`;
2268
+ if (line.length + 1 > CHAR_BUDGET) continue;
2269
+ if (listed.length >= TITLE_CATALOG_MAX_ENTRIES) break;
2270
+ if (used + line.length + 1 > CHAR_BUDGET) continue;
2271
+ listed.push(r);
2272
+ used += line.length + 1;
2273
+ }
2274
+ const truncated = typed.length > listed.length;
2275
+ if (typed.length === 0) {
2276
+ return [
2277
+ "TITLE CATALOG: this memory contains no typed nodes yet.",
2278
+ 'A fact classified in this same response is a valid "target_title" once typed. Otherwise omit "edges" rather than invent a target_title.'
2279
+ ].join("\n");
2280
+ }
2281
+ if (listed.length === 0) {
2282
+ return [
2283
+ "TITLE CATALOG: existing typed nodes exist in this memory, but none fit the catalog budget.",
2284
+ 'A fact classified in this same response is a valid "target_title" once typed. Otherwise omit "edges" rather than invent a target_title.'
2285
+ ].join("\n");
2286
+ }
2287
+ const catalog = listed.map((r) => `- ${JSON.stringify(r.title)} (${r.okf_type})`).join("\n");
2288
+ return [
2289
+ "TITLE CATALOG: existing typed nodes in this memory include:",
2290
+ catalog,
2291
+ ...truncated ? ["(This list is truncated; more typed nodes exist than are shown here.)"] : [],
2292
+ '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.'
2293
+ ].join("\n");
2294
+ }
2254
2295
  var GROUNDING_SOURCE = {
2255
2296
  ingest: { key: "facts", source: "the document chunk" },
2256
2297
  librarian: { key: "facts", source: 'the "summary" text of the events' },
@@ -2581,7 +2622,7 @@ The following document anchors are provided for contradiction detection only. Do
2581
2622
  ...corpusField
2582
2623
  };
2583
2624
  }
2584
- buildOntologyBackfillPrompt(facts, runtimeOverride, ontologyContext) {
2625
+ buildOntologyBackfillPrompt(facts, runtimeOverride, ontologyContext, titleCatalog) {
2585
2626
  const template = runtimeOverride ?? this.globalOverrides?.ontologyBackfillSystemPrompt ?? ONTOLOGY_BACKFILL_SYSTEM_PROMPT;
2586
2627
  const hasFacts = /\{\{\s*facts\s*\}\}/.test(template);
2587
2628
  if (hasFacts || this.hasOntologyPlaceholders(template)) {
@@ -2591,8 +2632,11 @@ The following document anchors are provided for contradiction detection only. Do
2591
2632
  ${JSON.stringify(facts, null, 2)}`
2592
2633
  };
2593
2634
  }
2635
+ const effective = titleCatalog !== void 0 ? `${template}
2636
+
2637
+ ${titleCatalog}` : template;
2594
2638
  return {
2595
- systemPrompt: this.appendOntology(template, ontologyContext),
2639
+ systemPrompt: this.appendOntology(effective, ontologyContext),
2596
2640
  userPrompt: `Facts:
2597
2641
  ${JSON.stringify(facts, null, 2)}`
2598
2642
  };
@@ -7837,11 +7881,14 @@ DROP TRIGGER IF EXISTS ${ad};`);
7837
7881
  }
7838
7882
  }
7839
7883
  const ontologyContext = await ontologyService.buildPromptContext(entityId);
7884
+ const titleRows = await this.entryRepo.findTitleIndexByEntityId(entityId);
7885
+ const titleCatalog = buildTitleCatalogBlock(titleRows);
7840
7886
  const toPromptShape = (f) => ({ id: f.id, title: f.title, body: f.body, tags: f.tags });
7841
7887
  const buildPrompt = (facts) => this.promptService.buildOntologyBackfillPrompt(
7842
7888
  facts.map(toPromptShape),
7843
7889
  options?.promptOverride,
7844
- ontologyContext
7890
+ ontologyContext,
7891
+ titleCatalog
7845
7892
  );
7846
7893
  const outcome = await runBatched({
7847
7894
  items: candidates,
@@ -10721,5 +10768,5 @@ var WriteService = class {
10721
10768
  };
10722
10769
 
10723
10770
  export { BaseRepository, CURRENT_SCHEMA_VERSION, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, EraseStepError, 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, SourceStoreService, 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, parseStoredSourcePointer, passageFtsTablesDdl, passageFtsTriggerNames, passageFtsTriggersDdl, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveEdgeDefinitions, resolveGrounding, resolveLibrarianStrategy, resolveNodeType, retiredTableName, runSourceRefNormalize, safeSlice, serializeSourcePointer, setupDatabase, sweepChunkSql, sweepHiSql, typeSatisfies, validateInlineEdges, validateManifest, validateSourcePointerValue, warnChangedDefaultsOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
10724
- //# sourceMappingURL=chunk-ZVVZACYI.mjs.map
10725
- //# sourceMappingURL=chunk-ZVVZACYI.mjs.map
10771
+ //# sourceMappingURL=chunk-Q6ZS2RKS.mjs.map
10772
+ //# sourceMappingURL=chunk-Q6ZS2RKS.mjs.map