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,146 +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.DigestCache = exports.DIGEST_CACHE_SCHEMA_VERSION = void 0;
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const node_crypto_1 = __importDefault(require("node:crypto"));
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const sqlite_1 = __importDefault(require("../db/sqlite"));
11
- /**
12
- * Content-addressed store for per-note digests (RENOR_DIGESTS, src/digests/digests.ts).
13
- *
14
- * digest key = sha256(schema \0 model \0 reasoning effort \0 sha256(prompt template) \0 input version \0 note_hash)
15
- *
16
- * A note's digest is keyed by the hash of the note's file (the index's `note_hash`), so an unchanged note is never
17
- * digested twice, an edited note gets a new digest, and a changed prompt, model or input rule re-digests every note.
18
- * An empty digest (the note states nothing about the user's life) is stored too, so it is not asked for again.
19
- *
20
- * The item vectors live beside the digest, one set per embedding space (provider, model, dimensions): a digest
21
- * outlives a change of embedding model, only its vectors are rebuilt. A vector from another space is never read.
22
- *
23
- * Design follows src/router/routerCache.ts: SQLite + WAL + busy_timeout=10000 + INSERT OR IGNORE.
24
- */
25
- exports.DIGEST_CACHE_SCHEMA_VERSION = 'note-digest-v1';
26
- const sha256 = (text) => node_crypto_1.default.createHash('sha256').update(text).digest('hex');
27
- class DigestCache {
28
- db;
29
- getDigestStmt;
30
- putDigestStmt;
31
- getVectorsStmt;
32
- putVectorsStmt;
33
- constructor(dbPath, opts = {}) {
34
- if (!opts.readonly)
35
- node_fs_1.default.mkdirSync(node_path_1.default.dirname(dbPath), { recursive: true });
36
- this.db = new sqlite_1.default(dbPath, opts.readonly ? { readonly: true, fileMustExist: true } : undefined);
37
- if (!opts.readonly) {
38
- this.db.pragma('journal_mode = WAL');
39
- this.db.exec(`
40
- CREATE TABLE IF NOT EXISTS note_digests (
41
- cache_key TEXT PRIMARY KEY,
42
- schema_version TEXT NOT NULL,
43
- model TEXT NOT NULL,
44
- note_hash TEXT NOT NULL,
45
- items_json TEXT NOT NULL,
46
- created_at TEXT NOT NULL
47
- );
48
- CREATE TABLE IF NOT EXISTS digest_vectors (
49
- cache_key TEXT NOT NULL,
50
- space TEXT NOT NULL,
51
- dims INTEGER NOT NULL,
52
- vectors BLOB NOT NULL,
53
- PRIMARY KEY (cache_key, space)
54
- );
55
- -- What the background worker (src/digests/worker.ts) spent per UTC day: the per-workspace cost guard reads it.
56
- CREATE TABLE IF NOT EXISTS digest_spend (
57
- day TEXT PRIMARY KEY,
58
- calls INTEGER NOT NULL DEFAULT 0,
59
- prompt_tokens INTEGER NOT NULL DEFAULT 0,
60
- completion_tokens INTEGER NOT NULL DEFAULT 0,
61
- micro_usd INTEGER NOT NULL DEFAULT 0
62
- );
63
- `);
64
- }
65
- this.db.pragma('busy_timeout = 10000');
66
- this.getDigestStmt = this.db.prepare('SELECT items_json, model FROM note_digests WHERE cache_key = ?');
67
- this.putDigestStmt = this.db.prepare(`INSERT OR IGNORE INTO note_digests (cache_key, schema_version, model, note_hash, items_json, created_at)
68
- VALUES (?, ?, ?, ?, ?, ?)`);
69
- this.getVectorsStmt = this.db.prepare('SELECT dims, vectors FROM digest_vectors WHERE cache_key = ? AND space = ?');
70
- this.putVectorsStmt = this.db.prepare('INSERT OR IGNORE INTO digest_vectors (cache_key, space, dims, vectors) VALUES (?, ?, ?, ?)');
71
- }
72
- static digestKey(model, effort, promptTemplate, inputVersion, noteHash) {
73
- return sha256([exports.DIGEST_CACHE_SCHEMA_VERSION, model, effort, sha256(promptTemplate), inputVersion, noteHash].join('\0'));
74
- }
75
- getDigest(key) {
76
- const row = this.getDigestStmt.get(key);
77
- if (!row)
78
- return null;
79
- return { items: JSON.parse(row.items_json), model: row.model };
80
- }
81
- putDigest(key, noteHash, entry) {
82
- this.putDigestStmt.run(key, exports.DIGEST_CACHE_SCHEMA_VERSION, entry.model, noteHash, JSON.stringify(entry.items), new Date().toISOString());
83
- }
84
- /** The item vectors of one digest in one embedding space, or null when they are absent or do not match the items. */
85
- getVectors(key, space, count) {
86
- const row = this.getVectorsStmt.get(key, space);
87
- if (!row || row.dims <= 0 || row.vectors.length !== count * row.dims * 4)
88
- return null;
89
- const floats = new Float32Array(row.vectors.buffer.slice(row.vectors.byteOffset, row.vectors.byteOffset + row.vectors.length));
90
- const out = [];
91
- for (let i = 0; i < count; i++)
92
- out.push(Array.from(floats.subarray(i * row.dims, (i + 1) * row.dims)));
93
- return out;
94
- }
95
- putVectors(key, space, vectors) {
96
- if (vectors.length === 0)
97
- return;
98
- const dims = vectors[0].length;
99
- const floats = new Float32Array(vectors.length * dims);
100
- vectors.forEach((vector, i) => floats.set(vector, i * dims));
101
- this.putVectorsStmt.run(key, space, dims, Buffer.from(floats.buffer));
102
- }
103
- /** The models the cache holds digests of, and how many digests each: what an eval run reads to arm the digests for the model the cache holds. */
104
- digestsByModel() {
105
- return this.db.prepare('SELECT model, COUNT(*) AS digests FROM note_digests GROUP BY model ORDER BY model').all();
106
- }
107
- /**
108
- * Keep only the digests of the notes whose file hash is in `noteHashes`, and the vectors that go with them: a digest
109
- * of text a note no longer holds (it was edited, forgotten, or its file is gone) is derived from content the user
110
- * removed, so it is not kept. Only the workspace's own cache calls this: an eval cache is shared by many vaults.
111
- * Returns how many digests it removed.
112
- */
113
- retainOnly(noteHashes) {
114
- const rows = this.db.prepare('SELECT cache_key, note_hash FROM note_digests').all();
115
- const stale = rows.filter(row => !noteHashes.has(row.note_hash));
116
- if (stale.length === 0)
117
- return 0;
118
- const dropDigest = this.db.prepare('DELETE FROM note_digests WHERE cache_key = ?');
119
- const dropVectors = this.db.prepare('DELETE FROM digest_vectors WHERE cache_key = ?');
120
- this.db.transaction(() => {
121
- for (const row of stale) {
122
- dropVectors.run(row.cache_key);
123
- dropDigest.run(row.cache_key);
124
- }
125
- })();
126
- return stale.length;
127
- }
128
- /** What the worker has spent on `day` (a UTC `YYYY-MM-DD`), in USD. */
129
- spentUsd(day) {
130
- const row = this.db.prepare('SELECT micro_usd FROM digest_spend WHERE day = ?').get(day);
131
- return (row?.micro_usd ?? 0) / 1e6;
132
- }
133
- addSpend(day, promptTokens, completionTokens, usd) {
134
- this.db.prepare(`INSERT INTO digest_spend (day, calls, prompt_tokens, completion_tokens, micro_usd) VALUES (?, 1, ?, ?, ?)
135
- ON CONFLICT(day) DO UPDATE SET calls = calls + 1, prompt_tokens = prompt_tokens + excluded.prompt_tokens,
136
- completion_tokens = completion_tokens + excluded.completion_tokens, micro_usd = micro_usd + excluded.micro_usd`).run(day, Math.max(0, Math.round(promptTokens)), Math.max(0, Math.round(completionTokens)), Math.max(0, Math.round(usd * 1e6)));
137
- }
138
- /** Spend rows older than the newest `keepDays` days are dropped, so the table does not grow without bound. */
139
- pruneSpend(keepDays) {
140
- this.db.prepare('DELETE FROM digest_spend WHERE day NOT IN (SELECT day FROM digest_spend ORDER BY day DESC LIMIT ?)').run(keepDays);
141
- }
142
- close() {
143
- this.db.close();
144
- }
145
- }
146
- exports.DigestCache = DigestCache;