renor-engine 1.1.0 → 1.3.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.
Files changed (193) hide show
  1. package/README.md +27 -2
  2. package/THIRD-PARTY-NOTICES +2661 -0
  3. package/dist/BUILD.json +3 -3
  4. package/dist/cli.js +1656 -490
  5. package/package.json +16 -80
  6. package/dist/.tsbuildinfo +0 -1
  7. package/dist/api/apiAuth.js +0 -43
  8. package/dist/api/server.js +0 -174
  9. package/dist/buildIdentity.js +0 -149
  10. package/dist/callPhases.js +0 -82
  11. package/dist/cli-extractors.js +0 -46
  12. package/dist/config.js +0 -65
  13. package/dist/context/composer.js +0 -320
  14. package/dist/context/readHonesty.js +0 -478
  15. package/dist/context/rowStore.js +0 -238
  16. package/dist/conversation/formatter.js +0 -81
  17. package/dist/conversation/parser.js +0 -193
  18. package/dist/conversation/types.js +0 -2
  19. package/dist/conversation/writer.js +0 -42
  20. package/dist/db/client.js +0 -149
  21. package/dist/db/handoffTable.js +0 -31
  22. package/dist/db/indexSalvage.js +0 -101
  23. package/dist/db/migrations.js +0 -670
  24. package/dist/db/readCache.js +0 -109
  25. package/dist/db/schema.js +0 -5
  26. package/dist/db/sqlite.js +0 -396
  27. package/dist/db/statements.js +0 -89
  28. package/dist/digests/digestCache.js +0 -146
  29. package/dist/digests/digests.js +0 -597
  30. package/dist/digests/worker.js +0 -350
  31. package/dist/embeddings/caching.js +0 -337
  32. package/dist/embeddings/coalescing.js +0 -177
  33. package/dist/embeddings/interactive.js +0 -103
  34. package/dist/embeddings/local.js +0 -70
  35. package/dist/embeddings/openai.js +0 -106
  36. package/dist/embeddings/rebuild.js +0 -166
  37. package/dist/embeddings/simdScan.js +0 -260
  38. package/dist/embeddings/space.js +0 -21
  39. package/dist/embeddings/types.js +0 -14
  40. package/dist/embeddings/vectorIndex.js +0 -674
  41. package/dist/embeddings/vertex.js +0 -334
  42. package/dist/eval/artifacts.js +0 -42
  43. package/dist/eval/cacheReport.js +0 -146
  44. package/dist/eval/comparison.js +0 -182
  45. package/dist/eval/context700-candidate.js +0 -145
  46. package/dist/eval/evalCache.js +0 -568
  47. package/dist/eval/hashEmbedding.js +0 -35
  48. package/dist/eval/indexSnapshots.js +0 -548
  49. package/dist/eval/longmemeval.js +0 -56
  50. package/dist/eval/metrics.js +0 -181
  51. package/dist/eval/pageDump.js +0 -67
  52. package/dist/eval/renorbenchBaseline.js +0 -486
  53. package/dist/eval/renorbenchDocuments.js +0 -134
  54. package/dist/eval/renorbenchProduct.js +0 -182
  55. package/dist/eval/runLedger.js +0 -279
  56. package/dist/eval/runManifest.js +0 -485
  57. package/dist/eval/scoring.js +0 -197
  58. package/dist/eval/textTokens.js +0 -17
  59. package/dist/evidence/attach.js +0 -264
  60. package/dist/evidence/background.js +0 -147
  61. package/dist/evidence/evidenceCache.js +0 -182
  62. package/dist/evidence/gate.js +0 -37
  63. package/dist/evidence/keyPool.js +0 -85
  64. package/dist/evidence/ollamaChat.js +0 -84
  65. package/dist/evidence/optin.js +0 -165
  66. package/dist/evidence/options.js +0 -151
  67. package/dist/evidence/secondPass.js +0 -294
  68. package/dist/extraction/classifyCapture.js +0 -34
  69. package/dist/extraction/decision-model.js +0 -174
  70. package/dist/extraction/eventExtractor.js +0 -113
  71. package/dist/extraction/extractionClient.js +0 -122
  72. package/dist/extraction/factExtractor.js +0 -46
  73. package/dist/extraction/factsWritePath.js +0 -179
  74. package/dist/extraction/preferenceExtractor.js +0 -150
  75. package/dist/extraction/secretGuard.js +0 -176
  76. package/dist/extraction/secretScanner.js +0 -665
  77. package/dist/extraction/typedFacts.js +0 -224
  78. package/dist/extraction/writePathAdjudication.js +0 -110
  79. package/dist/importing/apply.js +0 -672
  80. package/dist/importing/bundle-write.js +0 -80
  81. package/dist/importing/cli.js +0 -408
  82. package/dist/importing/existing.js +0 -51
  83. package/dist/importing/facts.js +0 -121
  84. package/dist/importing/forgetImported.js +0 -79
  85. package/dist/importing/hosted.js +0 -467
  86. package/dist/importing/journalLog.js +0 -96
  87. package/dist/importing/markdown.js +0 -98
  88. package/dist/importing/plan.js +0 -201
  89. package/dist/importing/secretScreen.js +0 -113
  90. package/dist/importing/serialize.js +0 -188
  91. package/dist/importing/source.js +0 -463
  92. package/dist/importing/types.js +0 -6
  93. package/dist/indexer/chunker.js +0 -319
  94. package/dist/indexer/dailyEntries.js +0 -63
  95. package/dist/indexer/hasher.js +0 -10
  96. package/dist/indexer/laneRuns.js +0 -48
  97. package/dist/indexer/o200k.js +0 -481
  98. package/dist/indexer/outsideRoot.js +0 -77
  99. package/dist/indexer/parser.js +0 -170
  100. package/dist/indexer/pipeline.js +0 -988
  101. package/dist/indexer/staleness.js +0 -201
  102. package/dist/indexer/tokenizer.js +0 -77
  103. package/dist/indexer/walker.js +0 -170
  104. package/dist/mcp/hive.js +0 -88
  105. package/dist/mcp/requestErrors.js +0 -47
  106. package/dist/mcp/server.js +0 -426
  107. package/dist/memory/agentLease.js +0 -43
  108. package/dist/memory/confinedWrite.js +0 -315
  109. package/dist/memory/controls.js +0 -73
  110. package/dist/memory/dailyNote.js +0 -265
  111. package/dist/memory/durableAppend.js +0 -57
  112. package/dist/memory/factConflicts.js +0 -203
  113. package/dist/memory/factTerms.js +0 -321
  114. package/dist/memory/handoff.js +0 -363
  115. package/dist/memory/hiveNameHeader.cjs +0 -10
  116. package/dist/memory/inventory.js +0 -55
  117. package/dist/memory/invisibleText.js +0 -20
  118. package/dist/memory/lifecycle.js +0 -1991
  119. package/dist/memory/limits.js +0 -13
  120. package/dist/memory/requests.js +0 -183
  121. package/dist/memory/sourceName.js +0 -276
  122. package/dist/memory/statusFacts.js +0 -61
  123. package/dist/memory/whatsNew.js +0 -158
  124. package/dist/memory/writer.js +0 -175
  125. package/dist/memory/writerConflicts.js +0 -85
  126. package/dist/memorymap/memoryMap.js +0 -1594
  127. package/dist/memorymap/replacedJournal.js +0 -58
  128. package/dist/memorymap/replacements.js +0 -410
  129. package/dist/mvp/activity.js +0 -86
  130. package/dist/mvp/agentMemory.js +0 -1800
  131. package/dist/mvp/answerCheck.js +0 -211
  132. package/dist/mvp/auth.js +0 -531
  133. package/dist/mvp/cli.js +0 -75
  134. package/dist/mvp/client-store.js +0 -462
  135. package/dist/mvp/compileCache.js +0 -242
  136. package/dist/mvp/compileSeed.js +0 -33
  137. package/dist/mvp/config.js +0 -288
  138. package/dist/mvp/connectionStatus.js +0 -80
  139. package/dist/mvp/contextDistinct.js +0 -53
  140. package/dist/mvp/contextProfile.js +0 -87
  141. package/dist/mvp/contextRelevance.js +0 -413
  142. package/dist/mvp/directorySurface.js +0 -68
  143. package/dist/mvp/engine.js +0 -1078
  144. package/dist/mvp/exportAll.js +0 -374
  145. package/dist/mvp/factLanePack.js +0 -77
  146. package/dist/mvp/factMarkers.js +0 -65
  147. package/dist/mvp/factsLane.js +0 -203
  148. package/dist/mvp/hiddenSpans.js +0 -585
  149. package/dist/mvp/history.js +0 -414
  150. package/dist/mvp/hitDates.js +0 -31
  151. package/dist/mvp/hitFloor.js +0 -36
  152. package/dist/mvp/identity.js +0 -18
  153. package/dist/mvp/idle.js +0 -113
  154. package/dist/mvp/log.js +0 -118
  155. package/dist/mvp/memoryDir.js +0 -98
  156. package/dist/mvp/posthogMcp.js +0 -210
  157. package/dist/mvp/readScope.js +0 -104
  158. package/dist/mvp/readUsefulness.js +0 -222
  159. package/dist/mvp/sanitize.js +0 -48
  160. package/dist/mvp/schemaRejections.js +0 -91
  161. package/dist/mvp/scope.js +0 -127
  162. package/dist/mvp/server.js +0 -2604
  163. package/dist/mvp/serverCard.js +0 -38
  164. package/dist/mvp/storedSize.js +0 -139
  165. package/dist/mvp/telemetry.js +0 -474
  166. package/dist/net/poolFetch.js +0 -174
  167. package/dist/recall/actionRecall.js +0 -282
  168. package/dist/recall/autoRecall.js +0 -447
  169. package/dist/recall/searchRecall.js +0 -189
  170. package/dist/retrieval/adviceLines.js +0 -195
  171. package/dist/retrieval/adviceQuestion.js +0 -44
  172. package/dist/retrieval/conversationShape.js +0 -44
  173. package/dist/retrieval/dailyEntryTime.js +0 -55
  174. package/dist/retrieval/entityLookup.js +0 -162
  175. package/dist/retrieval/factsFirst.js +0 -188
  176. package/dist/retrieval/keyword.js +0 -84
  177. package/dist/retrieval/ledgerEventTime.js +0 -51
  178. package/dist/retrieval/ledgerLiveness.js +0 -83
  179. package/dist/retrieval/ledgerPresentation.js +0 -161
  180. package/dist/retrieval/noteIdentity.js +0 -57
  181. package/dist/retrieval/orchestrator.js +0 -1171
  182. package/dist/retrieval/plainWording.js +0 -236
  183. package/dist/retrieval/queryHelpers.js +0 -142
  184. package/dist/retrieval/questionSpan.js +0 -475
  185. package/dist/retrieval/readerEvents.js +0 -690
  186. package/dist/retrieval/readerLayout.js +0 -422
  187. package/dist/retrieval/relativeTimeHints.js +0 -113
  188. package/dist/retrieval/semantic.js +0 -67
  189. package/dist/router/routerCache.js +0 -106
  190. package/dist/router/sessionRouter.js +0 -726
  191. package/dist/toolRefusal.js +0 -120
  192. package/dist/watcher/watcher.js +0 -77
  193. /package/dist/{indexer/o200k.json → o200k.json} +0 -0
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONTEXT_DISTINCT_FLAG = void 0;
4
- exports.contextDistinctEnabled = contextDistinctEnabled;
5
- exports.distinctMemories = distinctMemories;
6
- const ledgerPresentation_1 = require("../retrieval/ledgerPresentation");
7
- /**
8
- * get_context without repeats (RENOR_CONTEXT_DISTINCT, off by default: the reply is then what it always was).
9
- *
10
- * A first-week study of live replies found about 60% of the "memories" were records of the ledger and 64% of those said
11
- * what the same reply already said. The budget counts every one of them, so a repeat is room a distinct memory did not
12
- * get. A memory is a repeat when it adds nothing the reply holds elsewhere:
13
- * - a ledger record whose text is a fact the reply lists (`subject — predicate: object`) under another event;
14
- * - a memory whose words another memory holds whole (the same statement from the ledger and a daily note, or one chunk
15
- * inside a longer one); the first-listed, i.e. higher-ranked, copy stays, and when one holds the other the longer stays.
16
- * A memory that carries a marker (a correction, untrusted, an import, "matched: false") is never dropped: the marker is
17
- * information the copy does not have.
18
- */
19
- exports.CONTEXT_DISTINCT_FLAG = 'RENOR_CONTEXT_DISTINCT';
20
- function contextDistinctEnabled(env = process.env) {
21
- const raw = (env[exports.CONTEXT_DISTINCT_FLAG] ?? '').trim().toLowerCase();
22
- return raw === '1' || raw === 'true' || raw === 'yes' || raw === 'on';
23
- }
24
- /** Shorter than this, a text is too little to say another one holds it ("Yes", a bare name). */
25
- const MIN_CHARS = 20;
26
- const DAILY_PREFIX = /^(?:\s*-\s*\[[^\]]*\]\s*(?:\([^)]*\)\s*)?)+/;
27
- const MARKERS = ['replaced', 'untrusted', 'origin', 'matched'];
28
- /** A text as its words alone, without a daily-log entry's time and writer. */
29
- function words(text) {
30
- return text.replace(DAILY_PREFIX, '').toLowerCase().replace(/[^\p{L}\p{N}]+/gu, ' ').trim();
31
- }
32
- /** `memories` without the repeats, in their order. `isLedger` tells a record of the ledger by its note path. */
33
- function distinctMemories(memories, facts, isLedger) {
34
- const stated = facts.map(f => words((0, ledgerPresentation_1.factText)(f.subject, f.predicate, f.object ?? undefined))).filter(s => s.length >= MIN_CHARS);
35
- const texts = memories.map(m => words(m.text));
36
- const dropped = new Set();
37
- memories.forEach((memory, i) => {
38
- if (MARKERS.some(key => key in memory))
39
- return;
40
- const mine = texts[i];
41
- if (mine.length < MIN_CHARS)
42
- return;
43
- if (isLedger(memory.notePath) && stated.some(s => mine === s)) {
44
- dropped.add(i);
45
- return;
46
- }
47
- const held = texts.some((other, j) => j !== i && !dropped.has(j) && other.length >= mine.length
48
- && (other === mine ? j < i : ` ${other} `.includes(` ${mine} `)));
49
- if (held)
50
- dropped.add(i);
51
- });
52
- return dropped.size === 0 ? [...memories] : memories.filter((_, i) => !dropped.has(i));
53
- }
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LINE_TOOLS = void 0;
7
- exports.contextProfileFromEnv = contextProfileFromEnv;
8
- exports.checkProfileTools = checkProfileTools;
9
- exports.renderLines = renderLines;
10
- const node_fs_1 = __importDefault(require("node:fs"));
11
- function contextProfileFromEnv(env = process.env) {
12
- const profile = {};
13
- const tools = env.RENOR_MCP_TOOLS?.trim();
14
- if (tools)
15
- profile.tools = new Set(tools.split(',').map(t => t.trim()).filter(Boolean));
16
- const descriptions = env.RENOR_MCP_DESCRIPTIONS_FILE?.trim();
17
- if (descriptions) {
18
- const parsed = JSON.parse(node_fs_1.default.readFileSync(descriptions, 'utf8'));
19
- if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed) || Object.values(parsed).some(v => typeof v !== 'string' || v.trim() === '')) {
20
- throw new Error('RENOR_MCP_DESCRIPTIONS_FILE must hold a JSON object of tool name to a non-empty description');
21
- }
22
- profile.descriptions = parsed;
23
- }
24
- const instructions = env.RENOR_MCP_INSTRUCTIONS_FILE?.trim();
25
- if (instructions) {
26
- const text = node_fs_1.default.readFileSync(instructions, 'utf8').trim();
27
- if (!text)
28
- throw new Error('RENOR_MCP_INSTRUCTIONS_FILE is empty');
29
- profile.instructions = text;
30
- }
31
- const response = env.RENOR_MCP_RESPONSE?.trim();
32
- if (response) {
33
- if (response !== 'lines')
34
- throw new Error(`RENOR_MCP_RESPONSE takes lines, not ${response}`);
35
- profile.response = 'lines';
36
- }
37
- return profile;
38
- }
39
- /** Fail the build on a profile that names a tool the server does not have: a typo would otherwise switch a lever off. */
40
- function checkProfileTools(profile, registered) {
41
- const known = new Set(registered);
42
- for (const name of [...(profile.tools ?? []), ...Object.keys(profile.descriptions ?? {})]) {
43
- if (!known.has(name))
44
- throw new Error(`the context profile names ${name}, which this server does not register`);
45
- }
46
- }
47
- exports.LINE_TOOLS = new Set(['get_context', 'search_memory', 'search_text']);
48
- const DAY = /\d{4}-\d{2}-\d{2}/;
49
- /** The item's date: its session_date, else the day its daily note is filed under (headingPath, then notePath). */
50
- function dateOf(m) {
51
- if (typeof m.session_date === 'string')
52
- return m.session_date;
53
- for (const v of [m.headingPath, m.notePath]) {
54
- const day = typeof v === 'string' ? v.match(DAY)?.[0] : undefined;
55
- if (day)
56
- return day;
57
- }
58
- return 'undated';
59
- }
60
- /**
61
- * A read's JSON reply as lines: current facts first (`fact | subject predicate: object`), then each memory or hit in the
62
- * reply's own order (`date | text`, the date being session_date or the day of its daily note, `(replaced)` on one a later save corrected, `(not matched)` on one the query did not
63
- * match). A reply that is not a read's JSON, or that refuses (ok: false), is returned as it is.
64
- */
65
- function renderLines(text) {
66
- let body;
67
- try {
68
- body = JSON.parse(text);
69
- }
70
- catch {
71
- return text;
72
- }
73
- if (typeof body !== 'object' || body === null || body.ok === false)
74
- return text;
75
- const lines = [];
76
- for (const f of Array.isArray(body.facts) ? body.facts : []) {
77
- lines.push(`fact | ${String(f.subject)} ${String(f.predicate)}: ${String(f.object)}${typeof f.scope === 'string' && f.scope !== 'global' ? ` (${f.scope})` : ''}`);
78
- }
79
- const items = Array.isArray(body.memories) ? body.memories : Array.isArray(body.hits) ? body.hits : [];
80
- for (const m of items) {
81
- if (typeof m.text !== 'string')
82
- continue;
83
- const marks = [m.replaced ? '(replaced)' : '', m.matched === false ? '(not matched)' : ''].filter(Boolean).join(' ');
84
- lines.push(`${dateOf(m)} | ${marks ? `${marks} ` : ''}${m.text.replace(/\s*\n\s*/g, ' ')}`);
85
- }
86
- return lines.length === 0 ? 'nothing found' : lines.join('\n');
87
- }
@@ -1,413 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FACT_CEILING = exports.SEARCH_RELEVANCE_GUIDANCE = exports.CONTEXT_BUDGET_KEEPS_NEWEST = exports.CONTEXT_RELEVANCE_KEEPS_MATCH = exports.CONTEXT_RELEVANCE_GUIDANCE = exports.UNKNOWN_NAME_MARGIN = exports.notMentioned = exports.NO_STRONG_MATCH = exports.CALIBRATED_BARS = exports.CONTEXT_RELEVANCE_DEFAULT_ON = exports.CONTEXT_RELEVANCE_MIN_ENV = exports.CONTEXT_RELEVANCE_FLAG = void 0;
4
- exports.requestNames = requestNames;
5
- exports.contextRelevanceEnabled = contextRelevanceEnabled;
6
- exports.embeddingModelKey = embeddingModelKey;
7
- exports.resolveRelevanceBar = resolveRelevanceBar;
8
- exports.contextRelevanceArmed = contextRelevanceArmed;
9
- exports.renderFactForRelevance = renderFactForRelevance;
10
- exports.factLane = factLane;
11
- exports.similaritiesTo = similaritiesTo;
12
- exports.warmFactVectors = warmFactVectors;
13
- exports.combineSimilarity = combineSimilarity;
14
- exports.assessContextRelevance = assessContextRelevance;
15
- exports.assessQueryRelevance = assessQueryRelevance;
16
- const readCache_1 = require("../db/readCache");
17
- const statements_1 = require("../db/statements");
18
- const factTerms_1 = require("../memory/factTerms");
19
- const factLanePack_1 = require("./factLanePack");
20
- const scope_1 = require("./scope");
21
- /**
22
- * get_context relevance signal: "does anything on file actually match the request?"
23
- *
24
- * Without it an agent gets the same five confident-looking memories for a question
25
- * nothing on file answers, and fills the gap by guessing. The signal is the best
26
- * embedding similarity between the query and (a) the note chunks get_context returned
27
- * and (b) a clean "attribute: value" rendering of every current fact, compared with a
28
- * bar calibrated per embedding model on fixtures/relevance (method, confusion matrices
29
- * and the chosen bar: docs/evals/results/RELEVANCE-SIGNAL-20261002.md).
30
- *
31
- * Why not the lexical term coverage RENOR_READ_HONESTY uses: coverage counts query
32
- * words found in the best item, so a paraphrase ("Where am I based?" for
33
- * home_city = Lisbon) scores 0 even when retrieval found the right memory. Why a fact
34
- * rendering and not just the ledger chunk: the chunk is mostly event boilerplate (ids,
35
- * timestamps, "kind: store"), which flattens every similarity toward the same value;
36
- * the rendering is only the claim.
37
- *
38
- * The signal is cheap, and an agent reads `relevant: true` as "the answer is below", so the
39
- * response holds the match it reports (`matchedOn`), the closest fact or note chunk: the
40
- * budget makes room for it, cutting other items if it must (agentMemory.ts), and when it
41
- * does not fit max_tokens even on its own there is no verdict rather than one about something
42
- * the response lacks. The current fact closest to the request, when it clears the bar on its
43
- * own (`closestFact`), is listed when the words of the request did not find it: in their
44
- * place when they found none, else after the facts they found, in the room the rest leaves
45
- * unless it is the match reported. It never takes the place of a fact they found: a
46
- * rendering has no subject, so the closest one is often a fact that mentions the project
47
- * ("role: product manager for Atlas" is near every Atlas question) or another ticket's
48
- * status, and room taken from the rest for it cost answers. Nothing else is added, removed or
49
- * reordered, and it adds no embedding call to get_context: the query vector comes from the
50
- * semantic search that already ran, and fact vectors are embedded once, in the background.
51
- * Two cases are judged without a cosine to compare: a read that found no note by meaning and
52
- * holds no current fact is "not relevant" (similarity null), and a request that names
53
- * something nothing in the scope read mentions needs a match closer by UNKNOWN_NAME_MARGIN.
54
- * It is absent (never a guess) whenever it cannot judge: flag off, no query vector, no
55
- * calibrated bar for the embedding model, or fact vectors still warming - a "not relevant"
56
- * verdict needs every current fact compared.
57
- */
58
- /** RENOR_CONTEXT_RELEVANCE: 1/true/yes/on enables, 0/false/no/off disables. */
59
- exports.CONTEXT_RELEVANCE_FLAG = 'RENOR_CONTEXT_RELEVANCE';
60
- /** RENOR_CONTEXT_RELEVANCE_MIN: explicit bar, for an embedding model with no calibrated one. */
61
- exports.CONTEXT_RELEVANCE_MIN_ENV = 'RENOR_CONTEXT_RELEVANCE_MIN';
62
- /**
63
- * Shipped default: on, because the held-out calibration met the pre-registered bar (false abstentions on
64
- * answerable questions < 5% AND most unanswerable flagged, at both workspace sizes). It can only be on, and
65
- * can only speak, for an embedding model with a calibrated bar (CALIBRATED_BARS) or an explicit
66
- * RENOR_CONTEXT_RELEVANCE_MIN. tests/mvp/context-relevance-calibration.test.ts asserts this constant and the
67
- * recorded calibration cannot disagree.
68
- */
69
- exports.CONTEXT_RELEVANCE_DEFAULT_ON = true;
70
- /**
71
- * Calibrated bars, keyed `<MVP_EMBEDDING_PROVIDER>:<model>:<dimensions>`. Cosine scales
72
- * differ by model and output size, so a bar never transfers between them.
73
- */
74
- exports.CALIBRATED_BARS = {
75
- 'vertex:gemini-embedding-001:768': 0.63,
76
- };
77
- exports.NO_STRONG_MATCH = 'no stored fact or note closely matches this request; the listed items are only the nearest ones';
78
- /** When `names` were looked for and nothing on file mentions them. */
79
- const notMentioned = (names) => `nothing on file mentions ${names.join(', ')}; the listed items are only the nearest ones`;
80
- exports.notMentioned = notMentioned;
81
- /**
82
- * How much closer a match must be when the request names something that nothing on file mentions ("What is the
83
- * Quillmoor pricing?" on a workspace that never said Quillmoor): such a request is about something else than anything
84
- * on file, and its match is on the generic part ("pricing"). Live, those sat at 0.646-0.651 over the 0.63 bar. Chosen
85
- * on the dev questions, where a name a semantic model reads across languages ("Wie heißt meine Frau?", 0.708) must
86
- * stay relevant, and checked on the held-out ones: no answerable question is lost
87
- * (tests/mvp/context-relevance-calibration.test.ts).
88
- */
89
- exports.UNKNOWN_NAME_MARGIN = 0.05;
90
- /** Capitalized in English, but a time rather than the name of something on file. */
91
- const CALENDAR_WORDS = new Set([
92
- 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday',
93
- 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december',
94
- ]);
95
- /**
96
- * The names in a request: capitalized words that do not open a sentence ("Quillmoor" in "What is the Quillmoor
97
- * pricing?"), without a possessive. Not "I", a weekday or a month. A sentence's first word is capitalized for that
98
- * alone, so it is never taken for a name.
99
- */
100
- function requestNames(query) {
101
- const names = new Set();
102
- let opening = true;
103
- for (const [token] of query.matchAll(/[\p{L}\p{N}][\p{L}\p{N}\p{M}'’-]*|[.?!:;]+(?=\s|$)|[¿¡]/gu)) {
104
- if (!/^[\p{L}\p{N}]/u.test(token)) {
105
- opening = true;
106
- continue;
107
- }
108
- const word = token.replace(/['’]s$/i, '').replace(/['’-]+$/, '');
109
- if (!opening && /^\p{Lu}/u.test(word) && !/^I(['’]\p{L}+)?$/u.test(word) && !CALENDAR_WORDS.has(word.toLowerCase()))
110
- names.add(word);
111
- opening = false;
112
- }
113
- return [...names];
114
- }
115
- function contextRelevanceEnabled(env = process.env) {
116
- const raw = (env[exports.CONTEXT_RELEVANCE_FLAG] ?? '').trim().toLowerCase();
117
- if (raw === '1' || raw === 'true' || raw === 'yes' || raw === 'on')
118
- return true;
119
- if (raw === '0' || raw === 'false' || raw === 'no' || raw === 'off')
120
- return false;
121
- return exports.CONTEXT_RELEVANCE_DEFAULT_ON;
122
- }
123
- function embeddingModelKey(provider, model, dims) {
124
- return `${provider}:${model ?? ''}:${dims ?? ''}`;
125
- }
126
- function resolveRelevanceBar(modelKey, env = process.env) {
127
- const raw = (env[exports.CONTEXT_RELEVANCE_MIN_ENV] ?? '').trim();
128
- if (raw !== '') {
129
- const explicit = Number(raw);
130
- if (Number.isFinite(explicit))
131
- return explicit;
132
- }
133
- return modelKey && modelKey in exports.CALIBRATED_BARS ? exports.CALIBRATED_BARS[modelKey] : null;
134
- }
135
- /** Whether get_context can return the signal, i.e. whether agents should be told about it: on, embeddings configured, a bar to judge by. */
136
- function contextRelevanceArmed(engine, env = process.env) {
137
- return Boolean(engine.provider) && contextRelevanceEnabled(env) && resolveRelevanceBar(engine.modelKey, env) !== null;
138
- }
139
- /** Appended to the get_context tool description only while the signal is armed. */
140
- exports.CONTEXT_RELEVANCE_GUIDANCE = ' If the result has relevance.relevant === false, nothing on file closely matches this request: '
141
- + 'the listed items are only the nearest ones, so do not present them as an answer unless one clearly '
142
- + 'answers it; say you have no memory of it and ask the user.';
143
- /**
144
- * Appended to the get_context description after the guidance, while the signal is armed: the one case in which
145
- * max_tokens does not drop the item that ranks last first (agentMemory.ts keeps what a relevant verdict was judged on).
146
- */
147
- exports.CONTEXT_RELEVANCE_KEEPS_MATCH = ' When relevance.relevant is true, the closest match is in the result, or the newer relevant match the budget kept in its place: max_tokens keeps one of them even if another item has to be dropped to make room for it.';
148
- /**
149
- * Appended to the get_context description after the two sentences above, while the signal is armed (the model has a bar to
150
- * judge by): what the budget keeps first when the matches do not all fit (agentMemory.ts newestMatchAbove, sessionMatesAbove).
151
- */
152
- exports.CONTEXT_BUDGET_KEEPS_NEWEST = ' When the matches do not all fit, the newest match above the relevance bar is kept first, with the pieces of its session that say most about the question (at most four, in at most 60% of the budget), then the best-scoring ones, so the latest relevant statement is not the one the budget drops.';
153
- /**
154
- * Appended to the search_memory description while the signal is armed. `relevance.fact` is search's alone, and only
155
- * for the one case where the page could not carry the match: the fact is named, not listed.
156
- */
157
- exports.SEARCH_RELEVANCE_GUIDANCE = ' A relevance object says whether anything on file closely matches the query: relevant is true only when the closest match is among the hits, and when it is false the hits are only the nearest ones, so do not present them as an answer unless one clearly answers it.'
158
- + ' When relevant is true and the closest match is a remembered fact that top_k left no room to list, relevance.fact names it (subject, predicate, object, scope); you can answer from it, and the hits are still at most top_k in all.';
159
- /**
160
- * Most current facts the lane compares per call. A tenant with more is not silently truncated: the lane is
161
- * reported incomplete, so it can still prove relevance but can never be the basis of "nothing matches".
162
- * The fact list is read once until the next write. Each call then dots the query with the unit vectors
163
- * already stored for those facts (scripts/eval/relevance-latency.ts measured the uncached list).
164
- */
165
- exports.FACT_CEILING = 5_000;
166
- /** Vectors of no-longer-current facts kept before the store is pruned to the live set. */
167
- const STALE_VECTORS_KEPT = 256;
168
- /** Texts per embedding request, and requests in flight, while fact vectors are filled. */
169
- const FILL_BATCH = 32;
170
- const FILL_CONCURRENCY = 4;
171
- /** After a failed fill, how long reads leave the embedding backend alone before trying again. */
172
- const FILL_RETRY_MS = 30_000;
173
- /** Per embedding provider, so two models (or two test engines) never share vectors. */
174
- const slots = new WeakMap();
175
- function slotFor(provider) {
176
- let slot = slots.get(provider);
177
- if (!slot)
178
- slots.set(provider, slot = { vectors: new Map(), filling: null, retryAfter: 0, epoch: 0, packed: new Map() });
179
- return slot;
180
- }
181
- function renderFactForRelevance(predicate, object) {
182
- return `${predicate.replace(/_/g, ' ')}: ${object}`;
183
- }
184
- function unit(v) {
185
- let sum = 0;
186
- for (let i = 0; i < v.length; i++)
187
- sum += v[i] * v[i];
188
- const norm = Math.sqrt(sum) || 1;
189
- const out = new Float32Array(v.length);
190
- for (let i = 0; i < v.length; i++)
191
- out[i] = v[i] / norm;
192
- return out;
193
- }
194
- function dot(a, b) {
195
- let s = 0;
196
- for (let i = 0; i < a.length; i++)
197
- s += a[i] * b[i];
198
- return s;
199
- }
200
- /** Embeds `texts` into the slot, FILL_CONCURRENCY requests at a time. A failed batch leaves its texts for the next call. */
201
- async function fill(provider, slot, texts) {
202
- const batches = [];
203
- for (let i = 0; i < texts.length; i += FILL_BATCH)
204
- batches.push(texts.slice(i, i + FILL_BATCH));
205
- let next = 0;
206
- const worker = async () => {
207
- for (let b = next++; b < batches.length; b = next++) {
208
- const batch = batches[b];
209
- const fresh = await provider.embed(batch);
210
- if (fresh.length !== batch.length)
211
- throw new Error('embedding provider returned a wrong vector count');
212
- batch.forEach((text, i) => slot.vectors.set(text, unit(fresh[i])));
213
- slot.epoch++;
214
- }
215
- };
216
- await Promise.all(Array.from({ length: Math.min(FILL_CONCURRENCY, batches.length) }, worker));
217
- }
218
- /** What a lane was asked for (any scope, or one; how many facts at most): the key its snapshot and its pack are kept under. */
219
- function factLaneKey(scope, ceiling) {
220
- return `${scope === undefined ? '*' : (0, scope_1.normalizeScope)(scope)}\0${ceiling}`;
221
- }
222
- function loadFactSnapshot(db, scope, ceiling) {
223
- const inScope = scope === undefined ? undefined : (0, scope_1.savedScopeSqlPredicate)((0, scope_1.normalizeScope)(scope), 'f.scope'); // any spelling of it
224
- const select = `SELECT f.id AS id, f.predicate AS predicate, f.object_text AS object
225
- FROM facts f
226
- WHERE f.valid_to IS NULL AND f.source_path = '_mcp_'${inScope ? ` AND ${inScope.sql}` : ''}`;
227
- const scopeArgs = inScope?.params ?? [];
228
- let rows = (0, statements_1.prepareOnce)(db, `${select} LIMIT ?`).all(...scopeArgs, ceiling + 1);
229
- const truncated = rows.length > ceiling;
230
- if (truncated) {
231
- // Newest by row id: a reverse scan of the primary key, no sort. Only positives can come of this subset.
232
- rows = (0, statements_1.prepareOnce)(db, `${select} ORDER BY f.id DESC LIMIT ?`).all(...scopeArgs, ceiling);
233
- }
234
- // Each rendering once, with the newest fact rendered that way: the one a match is shown as.
235
- const newest = new Map();
236
- for (const r of rows) {
237
- const rendering = renderFactForRelevance(r.predicate, r.object);
238
- const seen = newest.get(rendering);
239
- if (seen === undefined || r.id > seen)
240
- newest.set(rendering, r.id);
241
- }
242
- return { pairs: [...newest], truncated };
243
- }
244
- /** The best fact when there is no matrix to read (vectors of two lengths) or the query is of another length: one lookup and one dot per fact. */
245
- function bestFromSlot(q, snapshot, slot) {
246
- let best = null;
247
- let id = -1;
248
- for (const [rendering, factId] of snapshot.pairs) {
249
- const v = slot.vectors.get(rendering);
250
- if (!v)
251
- continue;
252
- const s = dot(q, v);
253
- if (best === null || s > best) {
254
- best = s;
255
- id = factId;
256
- }
257
- }
258
- return best === null ? null : { score: best, id };
259
- }
260
- /** Drop vectors of facts that are no longer in this snapshot, then embed what is still missing. Same trigger as before. */
261
- function fillMissing(provider, slot, snapshot, missing) {
262
- if (missing.length === 0 || slot.filling || Date.now() < slot.retryAfter)
263
- return;
264
- if (slot.vectors.size > snapshot.pairs.length + STALE_VECTORS_KEPT) {
265
- const live = new Set(snapshot.pairs.map(([rendering]) => rendering));
266
- let dropped = false;
267
- for (const key of slot.vectors.keys())
268
- if (!live.has(key)) {
269
- slot.vectors.delete(key);
270
- dropped = true;
271
- }
272
- // Live rows were not dropped, so a lane packed from them is still the same dots.
273
- if (dropped)
274
- slot.epoch++;
275
- }
276
- const run = slot.filling = fill(provider, slot, missing)
277
- .catch(() => { slot.retryAfter = Date.now() + FILL_RETRY_MS; /* advisory: retried later for what is still missing */ })
278
- .finally(() => { if (slot.filling === run)
279
- slot.filling = null; });
280
- }
281
- /**
282
- * Best similarity between the query vector and the current facts (scope-filtered).
283
- * Never waits on the embedding backend: facts without a vector yet start a background
284
- * fill and are reported through `complete: false`; what is left is a dot product per fact.
285
- * `complete` is true only when EVERY in-scope current fact was compared: past `ceiling`
286
- * facts only the newest are, and the lane says so.
287
- */
288
- function factLane(db, provider, queryVector, scope, ceiling = exports.FACT_CEILING) {
289
- const key = factLaneKey(scope, ceiling);
290
- // The rows change only when something is written. Vectors arrive later, from the background fill.
291
- const snapshot = (0, readCache_1.readUntilWrite)(db, `factLane\0${key}`, () => loadFactSnapshot(db, scope, ceiling));
292
- const slot = slotFor(provider);
293
- let packed = slot.packed.get(key);
294
- if (!packed || packed.snapshot !== snapshot || packed.epoch !== slot.epoch) {
295
- packed = (0, factLanePack_1.packLane)(snapshot, slot.vectors, slot.epoch);
296
- if (slot.packed.size >= 8)
297
- slot.packed.clear();
298
- slot.packed.set(key, packed);
299
- }
300
- fillMissing(provider, slot, snapshot, packed.missing);
301
- if (packed.epoch !== slot.epoch)
302
- packed.epoch = slot.epoch;
303
- const q = unit(queryVector);
304
- const found = packed.matrix && q.length === packed.dim
305
- ? (() => {
306
- const best = (0, factLanePack_1.bestPacked)(q, packed.matrix, packed.ids.length, packed.dim);
307
- return best ? { score: best.score, id: packed.ids[best.index] } : null;
308
- })()
309
- : bestFromSlot(q, snapshot, slot);
310
- return {
311
- similarity: found ? found.score : null,
312
- complete: !snapshot.truncated && packed.missing.length === 0,
313
- ...(found ? { bestFactId: found.id } : {}),
314
- };
315
- }
316
- /**
317
- * Cosine between `queryVector` and each of `texts` (fact renderings, `renderFactForRelevance`), read from the same
318
- * per-provider store the fact lane fills, through the same embedding provider the notes are searched with. A text the
319
- * store lacks is embedded now (awaited, FILL_BATCH at a time), so a caller that needs the answer for this read gets it.
320
- * Null when that fails, or while the backend is in the pause after a failed fill: the caller answers by words instead.
321
- */
322
- async function similaritiesTo(provider, texts, queryVector) {
323
- const slot = slotFor(provider);
324
- const missing = [...new Set(texts)].filter(text => !slot.vectors.has(text));
325
- if (missing.length > 0) {
326
- if (Date.now() < slot.retryAfter)
327
- return null;
328
- try {
329
- await fill(provider, slot, missing);
330
- }
331
- catch {
332
- slot.retryAfter = Date.now() + FILL_RETRY_MS;
333
- return null;
334
- }
335
- }
336
- const q = unit(queryVector);
337
- const out = new Map();
338
- for (const text of texts) {
339
- const v = slot.vectors.get(text);
340
- if (v && v.length === q.length)
341
- out.set(text, dot(q, v));
342
- }
343
- return out;
344
- }
345
- /** Resolves once the fact vectors a call would need are embedded (or a fill failed): for tests, calibration, warm-up. */
346
- async function warmFactVectors(db, provider, scope) {
347
- const probeVector = new Float32Array(provider.dimensions).fill(1);
348
- slotFor(provider).retryAfter = 0; // an explicit warm-up is not held back by an earlier failure
349
- for (let attempt = 0; attempt < 4; attempt++) {
350
- if (factLane(db, provider, probeVector, scope).complete)
351
- return true;
352
- await slotFor(provider).filling;
353
- }
354
- return factLane(db, provider, probeVector, scope).complete;
355
- }
356
- /** The signal is the best match across both lanes; either lane alone may be unavailable. */
357
- function combineSimilarity(chunk, fact) {
358
- if (chunk === null)
359
- return fact;
360
- if (fact === null)
361
- return chunk;
362
- return Math.max(chunk, fact);
363
- }
364
- function assessContextRelevance(topSimilarity, bar) {
365
- if (topSimilarity === null || bar === null || !Number.isFinite(topSimilarity))
366
- return null;
367
- // Decide on the rounded value the caller sees, so a reported similarity equal to
368
- // the bar can never be reported irrelevant.
369
- const similarity = Math.round(topSimilarity * 1000) / 1000;
370
- const relevant = similarity >= bar;
371
- return { relevant, ...(relevant ? {} : { reason: exports.NO_STRONG_MATCH }), similarity, bar };
372
- }
373
- /** Advisory by design: any failure here yields no signal rather than a failed get_context. */
374
- function assessQueryRelevance(input) {
375
- const { db, engine, scope, probe, env } = input;
376
- const bar = resolveRelevanceBar(engine.modelKey, env);
377
- // No query vector means retrieval embedded nothing (empty index): the signal does not pay for one.
378
- if (bar === null || !engine.provider || !probe.queryVector)
379
- return null;
380
- try {
381
- const chunk = probe.topSimilarity ?? null;
382
- const fact = factLane(db, engine.provider, probe.queryVector, scope);
383
- if (input.components) {
384
- input.components.chunk = chunk;
385
- input.components.fact = fact.similarity;
386
- }
387
- const best = combineSimilarity(chunk, fact.similarity);
388
- // Nothing to compare: the read found no note by meaning and holds no current fact, so nothing on file is close to
389
- // the request (withheld while fact vectors are warming, as any "not relevant" is).
390
- if (best === null)
391
- return fact.complete ? { relevance: { relevant: false, reason: exports.NO_STRONG_MATCH, similarity: null, bar } } : null;
392
- // A match just over the bar for a request that names something nothing on file mentions has to be closer.
393
- const raised = Math.round((bar + exports.UNKNOWN_NAME_MARGIN) * 1000) / 1000;
394
- const unknown = input.onFile && assessContextRelevance(best, bar)?.relevant && !assessContextRelevance(best, raised)?.relevant
395
- ? requestNames(input.query ?? '').filter(name => !input.onFile(name))
396
- : [];
397
- const judgedBar = unknown.length > 0 ? raised : bar;
398
- const verdict = assessContextRelevance(best, judgedBar);
399
- // A match found among some facts proves relevance; "nothing matches" needs all of them compared.
400
- if (!verdict || (!verdict.relevant && !fact.complete))
401
- return null;
402
- if (unknown.length > 0)
403
- verdict.reason = (0, exports.notMentioned)(unknown);
404
- const closestFact = fact.bestFactId !== undefined && assessContextRelevance(fact.similarity, judgedBar)?.relevant
405
- ? (0, factTerms_1.currentFactById)(db, fact.bestFactId)
406
- : undefined;
407
- const matchedOn = !verdict.relevant ? undefined : chunk === null || (fact.similarity !== null && fact.similarity >= chunk) ? 'fact' : 'chunk';
408
- return { relevance: verdict, ...(closestFact ? { closestFact } : {}), ...(matchedOn ? { matchedOn } : {}) };
409
- }
410
- catch {
411
- return null;
412
- }
413
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DIRECTORY_DESCRIPTIONS = exports.DIRECTORY_HIDDEN_TOOLS = void 0;
4
- /**
5
- * What a directory client (a claude.ai or chatgpt.com connector, which the gateway marks) is offered, beyond the hive tools it
6
- * never gets (server.ts HIVE_TOOLS).
7
- *
8
- * The directory rules ask a submitter to confirm that tool descriptions contain no instructions about model behaviour or other
9
- * tools. The descriptions in server.ts guide a named agent ("Call this before substantive work", "say you have no memory of it"),
10
- * which those agents rely on, so they stay as they are; a directory client is listed these instead, which say what each tool does
11
- * and returns. The listing is the only difference: a call runs the same code whichever text the client read.
12
- */
13
- const limits_1 = require("../memory/limits");
14
- /**
15
- * Tools a directory client is not offered: neither listed nor run. search_history reads a promoted-history folder a hosted
16
- * workspace does not have, so it could only answer "not configured". The others duplicate a listed tool (save_memory and
17
- * remember_note are remember with fewer choices) or are maintenance a hosted workspace does for itself (index_memory,
18
- * memory_status, lookup_entity). Named agent keys keep all of them.
19
- */
20
- exports.DIRECTORY_HIDDEN_TOOLS = ['search_history', 'save_memory', 'remember_note', 'index_memory', 'memory_status', 'lookup_entity'];
21
- const NOT_FOR_SECRETS = 'Memory is kept as readable Markdown, so it is not a place for passwords, API keys or tokens.';
22
- /** The description a directory client is listed for each tool, by tool name. A tool missing here keeps its own. */
23
- exports.DIRECTORY_DESCRIPTIONS = {
24
- get_context: 'Returns what the workspace holds that is relevant to a request: the current facts first, then the saved memories that match it, by meaning where semantic search is available and by keywords. '
25
- + 'Each memory carries session_date (when it was written) and a score: higher is closer, and keyword matches (reason "fts" or "note-identity") use their own scale. '
26
- + 'rankedBy names the order: "session_date" is newest first, "score" is best match first. '
27
- + 'relevance.relevant is false when nothing on file closely matches the request; the listed items are then only the nearest ones, not an answer. '
28
- + 'A memory marked replaced has a later correction, listed before it. A memory marked "matched": false came along with a matching note without matching itself. '
29
- + 'Facts saved by an import are marked "untrusted": true, and conflicts lists current values that disagree with a returned fact. The reply fits within max_tokens.',
30
- search_memory: 'Searches the saved memories by meaning. Where semantic search is not available yet, the reply has no hits and says why (semantic-unavailable or semantic-rebuilding); keyword search keeps working meanwhile. '
31
- + 'Each hit carries a score (higher is closer) and session_date; rankedBy names the order: "session_date" (the default) is newest first, "score" is best match first. Saved facts that match are included. '
32
- + 'relevance.relevant is false when nothing on file closely matches the query; the hits are then only the nearest ones, not an answer. A hit marked replaced has a later correction, listed before it.',
33
- search_text: 'Keyword search over the saved memories: the query is matched as one exact phrase (OR, AND, NEAR and * are plain words), with no call to an embedding service. '
34
- + 'A term found in no memory text is also matched against note paths and front matter (reason "note-identity"), and matching saved facts are included (reason "fact"). '
35
- + 'Each hit carries session_date, when that text was written. A hit marked replaced has a later correction, listed before it.',
36
- retrieve_memory: 'Returns the current value of the saved facts about a subject, optionally for one predicate, with the full history of earlier values (include_history) or as they stood at a moment (as_of). '
37
- + 'Each value says whether it is current. A value that replaced one another agent saved carries a writerConflict line naming the replaced value: an open disagreement, not a settled answer. '
38
- + 'conflicts names current values that disagree. An empty result says whether the subject exists (known), and closestSubjects lists near matches. Without a subject, the reply lists the known subjects.',
39
- memory_map: 'An overview of everything the workspace holds, for browsing: its memories (notes and daily-log entries), the things saved facts are about, topics, facts with their history, the links between them, recent saves, and retired memories, newest first, up to limit (default 20, at most 200). '
40
- + 'With query, only the memories and retired memories containing its words are returned, rarest words first: this is where the id of one memory is found, which read_memory, retire_memory and restore_memory take.',
41
- read_memory: 'Returns one memory in full by its id (from memory_map or a save\'s receipt): its text, its note details (status, tags, dates), and the facts taken from it. session_date is when it was written.',
42
- export_memory: 'Exports everything the workspace holds as portable Markdown (format renor-export/v1): every fact with its history, every daily-log entry, every note with its details, and everything retired. '
43
- + 'The reply is a JSON manifest (counts, the sections it carries, whether it is complete) and the document. A large workspace is paged, not cut: while the manifest says truncated or names nextSection or nextItem, the rest comes with section and offset. '
44
- + 'The search index, embeddings and activity are not exported; the manifest lists what is left out under notExported.',
45
- remember: 'Saves one statement to memory in plain words and indexes it at once, so later recall finds it. The receipt\'s id identifies the saved memory, and scope ("project:<slug>") keeps it with one project. '
46
- + 'For a value that stays current until it changes (a city, a project\'s database, a deadline, a preference), subject, predicate and object can come with the statement: a later save of the same subject, predicate and scope replaces the value, and the earlier one stays in history. '
47
- + 'replaces, the id of an earlier note or log entry, marks that memory as corrected by this one, and nothing is deleted; with subject, predicate and object as well, the save is a plain-words correction of that note. '
48
- + `${NOT_FOR_SECRETS} A statement over ${limits_1.MAX_STATEMENT_LENGTH} characters is refused.`,
49
- retire_memory: 'Takes one memory (a note, a daily-log entry or a fact, by its id) out of recall without deleting it: it leaves every read and search at once, and restore_memory puts it back. '
50
- + 'Retiring a correction undoes its replaces link, so the memory it replaced reads as current again. A wrong value is corrected by saving the new one, which keeps history; retiring is for forgetting.',
51
- restore_memory: 'Puts a retired memory back exactly as it was and re-indexes it. A file that now occupies the same path is not overwritten, and the restore is refused.',
52
- preview_import: 'Dry run of an import of Markdown notes into Imported/<label>/. The server has no access to the user\'s disk: files arrive as files: [{ relativePath, markdown }], relativePath being the path inside the imported folder (notes/idea.md). '
53
- + 'Only .md files are imported, and names starting with "." are skipped. Returns counts, conflicts (a different file already at the destination is kept, not overwritten), skipped files with reasons, and a batchId that stays valid for 15 minutes; nothing is written to memory. '
54
- + 'Limits: 100 files, 64 KiB per file and 128 KiB per call, with up to 8 previews waiting at once. include and exclude select path prefixes; stage: false only checks.',
55
- apply_import: 'Applies a batch from preview_import (its batchId, within 15 minutes). Additive: existing different files are kept and reported as conflicts. '
56
- + 'The notes are keyword-searchable at once, and searchable by meaning once they are embedded in the background. Returns the batchId undo_import takes; applying the same batch again changes nothing.',
57
- undo_import: 'Undoes one import batch: the notes it created are retired, unless a later batch still holds the same content. Files that existed before, conflicts and later edits are kept, and the reply lists them.',
58
- // The hidden tools, in case one is offered again: a client listed one reads a description in the same terms.
59
- save_memory: 'Saves one fact as subject, predicate and object, e.g. Fjord / database / SQLite. A later save of the same subject, predicate and scope replaces the value, and the earlier one stays in history. '
60
- + 'A value that replaces one another agent saved shows in reads with a writerConflict line until that agent saves it again. The receipt says store, supersede or nochange.',
61
- remember_note: 'Appends one line to a day\'s log (today, or date), timestamped and indexed at once; the receipt\'s id identifies the line. replaces works as it does for remember. '
62
- + `${NOT_FOR_SECRETS} A line over ${limits_1.MAX_STATEMENT_LENGTH} characters is refused.`,
63
- index_memory: 'Indexes the workspace\'s Markdown notes for search: chunks, the keyword index, entities, and embeddings where configured. Saves are indexed as they happen; this pass covers everything, for example after a search reports index.stale. '
64
- + 'Files an embedding service cannot finish are reported (index-unfinished) and finished in the background.',
65
- memory_status: 'Counts what the workspace holds (notes, chunks, entities, facts) and says whether search by meaning can answer now (semantic). While embeddings are being built, semantic is false, embeddingRebuild counts the chunks left, and keyword search works meanwhile.',
66
- lookup_entity: 'Finds a person, project or concept by name or alias: the exact name, an alias, or part of a name or a note path, not words inside note text. A miss returns reason "no-entity-match" and the number of entities.',
67
- search_history: 'Searches conversation notes imported from ChatGPT by their exact words. Available only where a folder of imported conversations is configured.',
68
- };