@theokit/sdk-memory 0.6.0 → 0.6.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.cjs +145 -501
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +36 -467
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/active-memory/active-memory-cache.d.ts +1 -66
  7. package/dist/internal/active-memory/active-memory-cache.d.ts.map +1 -1
  8. package/dist/internal/active-memory/active-memory-types.d.ts +1 -54
  9. package/dist/internal/active-memory/active-memory-types.d.ts.map +1 -1
  10. package/dist/internal/adapter-http-error.d.ts.map +1 -1
  11. package/dist/internal/dreaming/dreaming-phases.d.ts +5 -53
  12. package/dist/internal/dreaming/dreaming-phases.d.ts.map +1 -1
  13. package/dist/internal/dreaming/dreaming-run.d.ts +3 -83
  14. package/dist/internal/dreaming/dreaming-run.d.ts.map +1 -1
  15. package/dist/internal/index/index-db.d.ts +1 -67
  16. package/dist/internal/index/index-db.d.ts.map +1 -1
  17. package/dist/internal/index/index-schema.d.ts +1 -29
  18. package/dist/internal/index/index-schema.d.ts.map +1 -1
  19. package/dist/internal/index/memory-index.d.ts +1 -10
  20. package/dist/internal/index/memory-index.d.ts.map +1 -1
  21. package/dist/internal/index/sqlite-vec-loader.d.ts +2 -59
  22. package/dist/internal/index/sqlite-vec-loader.d.ts.map +1 -1
  23. package/dist/internal/index/vec-index.d.ts +1 -131
  24. package/dist/internal/index/vec-index.d.ts.map +1 -1
  25. package/dist/internal/store/chunk-markdown.d.ts +1 -82
  26. package/dist/internal/store/chunk-markdown.d.ts.map +1 -1
  27. package/dist/internal/store/reader.d.ts +1 -86
  28. package/dist/internal/store/reader.d.ts.map +1 -1
  29. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -5,10 +5,10 @@ var path = require('path');
5
5
  var sdk = require('@theokit/sdk');
6
6
  var memoryStore = require('@theokit/sdk/internal/memory-store');
7
7
  var persistence = require('@theokit/sdk/persistence');
8
- var crypto = require('crypto');
9
8
  var memoryAdapters = require('@theokit/sdk/internal/memory-adapters');
10
9
  var errors = require('@theokit/sdk/errors');
11
10
  var pathSafety = require('@theokit/sdk/path-safety');
11
+ var crypto = require('crypto');
12
12
  var fs = require('fs');
13
13
  var module$1 = require('module');
14
14
 
@@ -505,48 +505,6 @@ var CircuitBreaker = class {
505
505
  return this.opts.now?.() ?? Date.now();
506
506
  }
507
507
  };
508
- var DEFAULT_TTL_MS = 15e3;
509
- var DEFAULT_CAPACITY = 1e3;
510
- var ActiveMemoryCache = class {
511
- constructor(opts = {}) {
512
- this.opts = opts;
513
- }
514
- opts;
515
- map = /* @__PURE__ */ new Map();
516
- get(userText, queryMode, tenantCtx) {
517
- const key = cacheKey(userText, queryMode, tenantCtx);
518
- const entry = this.map.get(key);
519
- if (entry === void 0) return void 0;
520
- if (this.now() >= entry.expiresAtMs) {
521
- this.map.delete(key);
522
- return void 0;
523
- }
524
- this.map.delete(key);
525
- this.map.set(key, entry);
526
- return entry.result;
527
- }
528
- set(userText, queryMode, result, tenantCtx) {
529
- const key = cacheKey(userText, queryMode, tenantCtx);
530
- if (this.map.size >= (this.opts.capacity ?? DEFAULT_CAPACITY)) {
531
- const oldest = this.map.keys().next().value;
532
- if (oldest !== void 0) this.map.delete(oldest);
533
- }
534
- this.map.set(key, {
535
- expiresAtMs: this.now() + (this.opts.ttlMs ?? DEFAULT_TTL_MS),
536
- result
537
- });
538
- }
539
- size() {
540
- return this.map.size;
541
- }
542
- now() {
543
- return this.opts.now?.() ?? Date.now();
544
- }
545
- };
546
- function cacheKey(userText, queryMode, ctx) {
547
- const parts = [queryMode, ctx?.namespace ?? "", ctx?.userId ?? "", ctx?.scope ?? "", userText];
548
- return crypto.createHash("sha256").update(parts.join("\0")).digest("hex");
549
- }
550
508
 
551
509
  // src/internal/embedding/azure-openai-embedding.ts
552
510
  var DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL = "text-embedding-3-small";
@@ -886,6 +844,8 @@ function legacyMemoryJsonPath(cwd, config) {
886
844
 
887
845
  // src/internal/adapter-http-error.ts
888
846
  var RAW_MAX_BYTES = 2048;
847
+ var PROVIDER_DETAIL_MAX_CHARS = 512;
848
+ var MISSING_MODEL_MESSAGE = /no endpoints found/i;
889
849
  function parseRetryAfter(headers) {
890
850
  if (headers === void 0) return void 0;
891
851
  const raw = headers.get("retry-after");
@@ -897,8 +857,8 @@ function parseRetryAfter(headers) {
897
857
  function truncateRaw(body) {
898
858
  if (body === null || body === void 0) return void 0;
899
859
  const s = typeof body === "string" ? body : JSON.stringify(body);
900
- const truncated = s.length <= RAW_MAX_BYTES ? s : `${s.slice(0, RAW_MAX_BYTES)}\u2026`;
901
- return redactSecrets(truncated);
860
+ const redacted = redactSecrets(s);
861
+ return redacted.length <= RAW_MAX_BYTES ? redacted : `${redacted.slice(0, RAW_MAX_BYTES)}\u2026`;
902
862
  }
903
863
  function buildErrorMetadata(args) {
904
864
  const retryAfter = parseRetryAfter(args.headers);
@@ -930,8 +890,16 @@ function mapOpenAICompatibleError(args) {
930
890
  if (status === 429) {
931
891
  return new errors.RateLimitError(message, { code: `${providerId}_rate_limit`, metadata });
932
892
  }
893
+ if (status === 404 && code === "model_unavailable") {
894
+ const detailed = formatMessage(providerId, status, code, boundedProviderDetail(body));
895
+ return new errors.ConfigurationError(detailed, {
896
+ code: `${providerId}_model_unavailable`,
897
+ metadata
898
+ });
899
+ }
933
900
  if (status === 400) {
934
- return new errors.ConfigurationError(message, { code: `${providerId}_${code}`, metadata });
901
+ const detailed = formatMessage(providerId, status, code, boundedProviderDetail(body));
902
+ return new errors.ConfigurationError(detailed, { code: `${providerId}_${code}`, metadata });
935
903
  }
936
904
  if (status === 408) {
937
905
  return new errors.NetworkError(message, { code: `${providerId}_timeout`, metadata });
@@ -941,6 +909,18 @@ function mapOpenAICompatibleError(args) {
941
909
  }
942
910
  return new errors.UnknownAgentError(message, { code: `${providerId}_unknown`, metadata });
943
911
  }
912
+ function extractOpenAiErrorMessage(body) {
913
+ if (body === null || typeof body !== "object") return void 0;
914
+ const err = body.error;
915
+ if (err === void 0 || err === null) return void 0;
916
+ return typeof err.message === "string" ? err.message : void 0;
917
+ }
918
+ function boundedProviderDetail(body) {
919
+ const raw = extractOpenAiErrorMessage(body);
920
+ if (raw === void 0 || raw.trim() === "") return void 0;
921
+ const redacted = redactSecrets(raw);
922
+ return redacted.length <= PROVIDER_DETAIL_MAX_CHARS ? redacted : `${redacted.slice(0, PROVIDER_DETAIL_MAX_CHARS)}\u2026`;
923
+ }
944
924
  function extractOpenAiErrorCode(body) {
945
925
  if (body === null || typeof body !== "object") return void 0;
946
926
  const err = body.error;
@@ -963,6 +943,9 @@ function mapOpenAiStatusToCode(status, body) {
963
943
  if (status === 402 || rawCode.includes("insufficient_quota") || rawCode.includes("quota_exceeded")) {
964
944
  return "quota_exceeded";
965
945
  }
946
+ if (status === 404 && MISSING_MODEL_MESSAGE.test(extractOpenAiErrorMessage(body) ?? "")) {
947
+ return "model_unavailable";
948
+ }
966
949
  if (status === 401 || status === 403) return "auth_failed";
967
950
  if (status === 429) return "rate_limit";
968
951
  if (status === 408) return "timeout";
@@ -970,8 +953,9 @@ function mapOpenAiStatusToCode(status, body) {
970
953
  if (status >= 500 && status < 600) return "server_error";
971
954
  return "unknown";
972
955
  }
973
- function formatMessage(providerId, status, code) {
974
- return `${providerId} API error: ${code} (HTTP ${status})`;
956
+ function formatMessage(providerId, status, code, detail) {
957
+ const base = `${providerId} API error: ${code} (HTTP ${status})`;
958
+ return detail === void 0 || detail === "" ? base : `${base}: ${detail}`;
975
959
  }
976
960
  var FACTS_HEADING = "## Facts";
977
961
  function createCategorizedMemory(options) {
@@ -1099,298 +1083,6 @@ ${bullet}
1099
1083
  return `${raw.slice(0, insertAt)}
1100
1084
  ${bullet}${raw.slice(insertAt)}`;
1101
1085
  }
1102
-
1103
- // src/internal/dreaming/dreaming-phases.ts
1104
- var DEFAULT_DEDUP_THRESHOLD = 0.95;
1105
- var DEFAULT_CLUSTER_THRESHOLD = 0.75;
1106
- async function lightPhase(facts, embedding, threshold = DEFAULT_DEDUP_THRESHOLD) {
1107
- if (facts.length <= 1) return { kept: [...facts], duplicatesRemoved: 0 };
1108
- const vectors = await embedding.embed(facts.map((f) => f.text));
1109
- const keptIdx = [];
1110
- const keptVecs = [];
1111
- for (let i = 0; i < facts.length; i++) {
1112
- const vec = vectors[i] ?? [];
1113
- const isDup = keptVecs.some((kept2) => cosineSimilarity(vec, kept2) >= threshold);
1114
- if (isDup) continue;
1115
- keptIdx.push(i);
1116
- keptVecs.push(vec);
1117
- }
1118
- const kept = keptIdx.map((i) => facts[i]);
1119
- return { kept, duplicatesRemoved: facts.length - kept.length };
1120
- }
1121
- var DEFAULT_MAX_FACTS_PER_SWEEP = 500;
1122
- async function remPhase(facts, embedding, threshold = DEFAULT_CLUSTER_THRESHOLD, maxFactsPerSweep = DEFAULT_MAX_FACTS_PER_SWEEP) {
1123
- if (facts.length === 0) return { clusters: [], factsLeftOut: 0 };
1124
- const capped = facts.length > maxFactsPerSweep ? facts.slice(0, maxFactsPerSweep) : facts;
1125
- const vectors = await embedding.embed(capped.map((f) => f.text));
1126
- const clusterOfIdx = unionFindByPairs(vectors, threshold);
1127
- const groups = bucketFactsByClusterRoot(capped, clusterOfIdx);
1128
- return {
1129
- clusters: [...groups.values()].map(buildClusterFromMembers),
1130
- factsLeftOut: facts.length - capped.length
1131
- };
1132
- }
1133
- function unionFindByPairs(vectors, threshold) {
1134
- const clusterOfIdx = vectors.map((_, i) => i);
1135
- for (let i = 0; i < vectors.length; i++) {
1136
- for (let j = i + 1; j < vectors.length; j++) {
1137
- if (cosineSimilarity(vectors[i] ?? [], vectors[j] ?? []) >= threshold) {
1138
- unifyClusters(clusterOfIdx, i, j);
1139
- }
1140
- }
1141
- }
1142
- return clusterOfIdx;
1143
- }
1144
- function bucketFactsByClusterRoot(facts, clusterOfIdx) {
1145
- const groups = /* @__PURE__ */ new Map();
1146
- for (let i = 0; i < facts.length; i++) {
1147
- const root = findRoot(clusterOfIdx, i);
1148
- const list = groups.get(root) ?? [];
1149
- list.push(facts[i]);
1150
- groups.set(root, list);
1151
- }
1152
- return groups;
1153
- }
1154
- function buildClusterFromMembers(members) {
1155
- const sorted = [...members].sort((a, b) => b.text.length - a.text.length);
1156
- return { representativeText: sorted[0]?.text ?? "", members };
1157
- }
1158
- function deepPhase(clusters, timestampMs) {
1159
- if (clusters.length === 0) return "";
1160
- const isoStamp = new Date(timestampMs).toISOString();
1161
- const lines = [`# Dreamed ${isoStamp}`, ""];
1162
- for (let i = 0; i < clusters.length; i++) {
1163
- const c = clusters[i];
1164
- if (c === void 0) continue;
1165
- lines.push(`## Cluster ${i + 1}: ${c.representativeText}`);
1166
- lines.push("");
1167
- for (const member of c.members) lines.push(`- ${member.text}`);
1168
- lines.push("");
1169
- }
1170
- return `${lines.join("\n")}
1171
- `;
1172
- }
1173
- function cosineSimilarity(a, b) {
1174
- if (a.length === 0 || b.length === 0 || a.length !== b.length) return 0;
1175
- let dot = 0;
1176
- let aNorm = 0;
1177
- let bNorm = 0;
1178
- for (let i = 0; i < a.length; i++) {
1179
- const ai = a[i] ?? 0;
1180
- const bi = b[i] ?? 0;
1181
- dot += ai * bi;
1182
- aNorm += ai * ai;
1183
- bNorm += bi * bi;
1184
- }
1185
- const denom = Math.sqrt(aNorm) * Math.sqrt(bNorm);
1186
- return denom === 0 ? 0 : dot / denom;
1187
- }
1188
- function findRoot(parents, i) {
1189
- let root = i;
1190
- while (parents[root] !== root) {
1191
- const next = parents[root] ?? root;
1192
- if (next === root) break;
1193
- root = next;
1194
- }
1195
- parents[i] = root;
1196
- return root;
1197
- }
1198
- function unifyClusters(parents, a, b) {
1199
- const rootA = findRoot(parents, a);
1200
- const rootB = findRoot(parents, b);
1201
- if (rootA !== rootB) parents[rootB] = rootA;
1202
- }
1203
- function runDreamingSweep(options) {
1204
- return persistence.withCwdMutex(`dream:${options.cwd}`, () => runInner(options));
1205
- }
1206
- async function runInner(options) {
1207
- const now = options.now ?? Date.now;
1208
- const timestampMs = now();
1209
- try {
1210
- const facts = await memoryStore.readFactsFromMarkdown(options.cwd);
1211
- if (facts.length === 0) {
1212
- return emptyResult("skipped");
1213
- }
1214
- const dedup = await lightPhase(facts, options.embedding, options.dedupThreshold);
1215
- const rem = await remPhase(dedup.kept, options.embedding, options.clusterThreshold);
1216
- const notesWritten = await writeConsolidatedNotes(options.cwd, rem.clusters, timestampMs);
1217
- const result = {
1218
- status: "ok",
1219
- factsBefore: facts.length,
1220
- factsAfter: dedup.kept.length,
1221
- duplicatesRemoved: dedup.duplicatesRemoved,
1222
- clustersCreated: rem.clusters.length,
1223
- notesWritten,
1224
- diaryEntryHash: void 0,
1225
- factsLeftOut: rem.factsLeftOut
1226
- };
1227
- await memoryStore.appendDiaryEntry(memoryStore.resolveMemoryRoot(options.cwd), {
1228
- timestampMs,
1229
- factsBefore: result.factsBefore,
1230
- factsAfter: result.factsAfter,
1231
- duplicatesRemoved: result.duplicatesRemoved,
1232
- clustersCreated: result.clustersCreated,
1233
- notesWritten: result.notesWritten
1234
- });
1235
- return result;
1236
- } catch (cause) {
1237
- const message = cause instanceof Error ? cause.message : String(cause);
1238
- process.stderr.write(`[theokit-sdk] dreaming sweep failed: ${message}
1239
- `);
1240
- return emptyResult("error");
1241
- }
1242
- }
1243
- async function writeConsolidatedNotes(cwd, clusters, timestampMs) {
1244
- if (clusters.length === 0) return 0;
1245
- const notesDir3 = path.join(memoryStore.resolveMemoryRoot(cwd), "notes");
1246
- await promises.mkdir(notesDir3, { recursive: true });
1247
- const isoSlug = new Date(timestampMs).toISOString().replace(/[^\dT]/g, "-");
1248
- const file = path.join(notesDir3, `dreamed-${isoSlug}.md`);
1249
- const body = deepPhase(clusters, timestampMs);
1250
- await persistence.replaceFileAtomic(file, body);
1251
- return 1;
1252
- }
1253
- function emptyResult(status) {
1254
- const result = {
1255
- status,
1256
- factsBefore: 0,
1257
- factsAfter: 0,
1258
- duplicatesRemoved: 0,
1259
- clustersCreated: 0,
1260
- notesWritten: 0,
1261
- diaryEntryHash: void 0
1262
- };
1263
- return status === "skipped" ? { ...result, factsLeftOut: 0 } : result;
1264
- }
1265
-
1266
- // src/internal/index/index-schema.ts
1267
- var SCHEMA_STATEMENTS = [
1268
- `CREATE TABLE IF NOT EXISTS files (
1269
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1270
- path TEXT UNIQUE NOT NULL,
1271
- rel_path TEXT NOT NULL,
1272
- mtime INTEGER NOT NULL,
1273
- hash TEXT NOT NULL,
1274
- source TEXT NOT NULL DEFAULT 'memory'
1275
- )`,
1276
- `CREATE TABLE IF NOT EXISTS chunks (
1277
- id INTEGER PRIMARY KEY AUTOINCREMENT,
1278
- file_id INTEGER NOT NULL REFERENCES files(id) ON DELETE CASCADE,
1279
- start_line INTEGER NOT NULL,
1280
- end_line INTEGER NOT NULL,
1281
- text TEXT NOT NULL,
1282
- hash TEXT NOT NULL,
1283
- session_key TEXT
1284
- )`,
1285
- `CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(
1286
- text,
1287
- content='chunks',
1288
- content_rowid='id'
1289
- )`,
1290
- `CREATE TRIGGER IF NOT EXISTS chunks_fts_insert AFTER INSERT ON chunks BEGIN
1291
- INSERT INTO chunks_fts(rowid, text) VALUES (new.id, new.text);
1292
- END`,
1293
- `CREATE TRIGGER IF NOT EXISTS chunks_fts_delete AFTER DELETE ON chunks BEGIN
1294
- INSERT INTO chunks_fts(chunks_fts, rowid, text) VALUES ('delete', old.id, old.text);
1295
- END`,
1296
- `CREATE TABLE IF NOT EXISTS meta (
1297
- key TEXT PRIMARY KEY,
1298
- value TEXT
1299
- )`,
1300
- `CREATE INDEX IF NOT EXISTS idx_chunks_file_id ON chunks(file_id)`
1301
- ];
1302
- var PRAGMA_STATEMENTS = [
1303
- "PRAGMA synchronous=NORMAL",
1304
- "PRAGMA foreign_keys=ON"
1305
- ];
1306
-
1307
- // src/internal/index/index-db.ts
1308
- async function openMemoryDb(opts) {
1309
- return persistence.openSqliteResilient({
1310
- filePath: opts.filePath,
1311
- label: "memory-index",
1312
- recoverCorrupt: opts.recoverCorrupt,
1313
- onOpen: (db) => {
1314
- for (const pragma of PRAGMA_STATEMENTS) db.exec(pragma);
1315
- for (const stmt of SCHEMA_STATEMENTS) db.exec(stmt);
1316
- }
1317
- });
1318
- }
1319
- var HEADING_RE = /^(#{1,6})\s+(.+?)\s*$/;
1320
- function chunkMarkdown(text, options = {}) {
1321
- const maxChars = options.maxChars ?? 800;
1322
- if (text.length === 0) return [];
1323
- const lines = text.split("\n");
1324
- const acc = { chunks: [], lines: [], start: 1, heading: void 0 };
1325
- for (let i = 0; i < lines.length; i++) {
1326
- const line = lines[i] ?? "";
1327
- const lineNumber = i + 1;
1328
- processLine(acc, line, lineNumber, maxChars);
1329
- }
1330
- flushAccumulator(acc, lines.length, maxChars);
1331
- return acc.chunks;
1332
- }
1333
- function processLine(acc, line, lineNumber, maxChars) {
1334
- const headingMatch = HEADING_RE.exec(line);
1335
- const isBlank = line.trim().length === 0;
1336
- if (headingMatch !== null && acc.lines.length > 0) {
1337
- flushAccumulator(acc, lineNumber - 1, maxChars);
1338
- }
1339
- if (headingMatch !== null) acc.heading = headingMatch[2];
1340
- acc.lines.push(line);
1341
- if (isBlank && acc.lines.length > 1) {
1342
- const joined = acc.lines.join("\n");
1343
- if (joined.trim().length > 0) flushAccumulator(acc, lineNumber, maxChars);
1344
- }
1345
- }
1346
- function flushAccumulator(acc, endLineExclusive, maxChars) {
1347
- if (acc.lines.length === 0) return;
1348
- const chunkText = acc.lines.join("\n");
1349
- if (chunkText.trim().length === 0) {
1350
- acc.lines = [];
1351
- acc.start = endLineExclusive + 1;
1352
- return;
1353
- }
1354
- if (chunkText.length > maxChars) {
1355
- pushOversizedSlices(acc.chunks, chunkText, acc.start, acc.heading, maxChars);
1356
- } else {
1357
- acc.chunks.push(buildChunk(chunkText, acc.start, endLineExclusive, acc.heading));
1358
- }
1359
- acc.lines = [];
1360
- acc.start = endLineExclusive + 1;
1361
- }
1362
- function buildChunk(text, startLine, endLine, heading) {
1363
- return {
1364
- startLine,
1365
- endLine,
1366
- text,
1367
- hash: crypto.createHash("sha256").update(text).digest("hex"),
1368
- ...heading !== void 0 ? { heading } : {}
1369
- };
1370
- }
1371
- function pushOversizedSlices(chunks, text, startLine, heading, maxChars) {
1372
- let remaining = text;
1373
- let lineCursor = startLine;
1374
- while (remaining.length > maxChars) {
1375
- const splitAt = findWordBoundarySplit(remaining, maxChars);
1376
- const slice = remaining.slice(0, splitAt);
1377
- const sliceLines = slice.split("\n").length;
1378
- chunks.push(buildChunk(slice, lineCursor, lineCursor + sliceLines - 1, heading));
1379
- remaining = remaining.slice(splitAt).replace(/^\s+/, "");
1380
- lineCursor += sliceLines - 1;
1381
- }
1382
- if (remaining.length > 0) {
1383
- const sliceLines = remaining.split("\n").length;
1384
- chunks.push(buildChunk(remaining, lineCursor, lineCursor + sliceLines - 1, heading));
1385
- }
1386
- }
1387
- function findWordBoundarySplit(text, maxChars) {
1388
- if (text.length <= maxChars) return text.length;
1389
- for (let i = maxChars; i > Math.max(0, maxChars - 200); i--) {
1390
- if (/\s/.test(text[i] ?? "x")) return i;
1391
- }
1392
- return maxChars;
1393
- }
1394
1086
  function requireLance() {
1395
1087
  try {
1396
1088
  const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
@@ -1516,14 +1208,6 @@ function isLanceAvailable() {
1516
1208
  }
1517
1209
  }
1518
1210
 
1519
- // src/internal/index/memory-index.ts
1520
- function parseSearchOptions(options = {}) {
1521
- return {
1522
- maxResults: Math.max(1, options.maxResults ?? 10),
1523
- minScore: options.minScore ?? 0
1524
- };
1525
- }
1526
-
1527
1211
  // src/internal/index/lance-memory-adapter.ts
1528
1212
  var DEFAULT_NAMESPACE = "default";
1529
1213
  var EMPTY_SYNC_RESULT = Object.freeze({
@@ -1549,7 +1233,7 @@ var LanceMemoryAdapter = class {
1549
1233
  // readability (the bodies diverge sharply right after).
1550
1234
  async search(query, options = {}) {
1551
1235
  if (query.trim().length === 0) return [];
1552
- const { maxResults, minScore } = parseSearchOptions(options);
1236
+ const { maxResults, minScore } = memoryStore.parseSearchOptions(options);
1553
1237
  const lanceHits = await this.inner.search(query, {
1554
1238
  namespace: DEFAULT_NAMESPACE,
1555
1239
  limit: maxResults * 2,
@@ -1613,22 +1297,6 @@ async function openLanceIndex(opts) {
1613
1297
  });
1614
1298
  return new LanceMemoryAdapter(lance);
1615
1299
  }
1616
- async function loadSqliteVecExtension(db) {
1617
- try {
1618
- const mod = await import('sqlite-vec');
1619
- const loadFn = mod.load;
1620
- if (typeof loadFn !== "function") {
1621
- throw new Error("sqlite-vec module exposes no `load` export");
1622
- }
1623
- loadFn(db);
1624
- } catch (cause) {
1625
- const message = cause instanceof Error ? cause.message : String(cause);
1626
- throw new errors.ConfigurationError(
1627
- `sqlite-vec extension unavailable. Install \`sqlite-vec\` and ensure the native binary matches your Node + OS. Cause: ${message}`,
1628
- { code: "sqlite_vec_unavailable", cause }
1629
- );
1630
- }
1631
- }
1632
1300
  function isSqliteVecLoaded(db) {
1633
1301
  try {
1634
1302
  const row = db.prepare("SELECT vec_version() as v").get();
@@ -1638,80 +1306,6 @@ function isSqliteVecLoaded(db) {
1638
1306
  }
1639
1307
  }
1640
1308
 
1641
- // src/internal/index/vec-index.ts
1642
- var META_KEY_PROVIDER_ID = "embedding.providerId";
1643
- var META_KEY_MODEL = "embedding.model";
1644
- var META_KEY_DIMENSION = "embedding.dimension";
1645
- function readEmbeddingIdentity(db) {
1646
- const get = (key) => {
1647
- const row = db.prepare("SELECT value FROM meta WHERE key = ?").get(key);
1648
- return row !== void 0 ? String(row.value) : void 0;
1649
- };
1650
- const providerId = get(META_KEY_PROVIDER_ID);
1651
- const model = get(META_KEY_MODEL);
1652
- const dimRaw = get(META_KEY_DIMENSION);
1653
- if (providerId === void 0 || model === void 0 || dimRaw === void 0) return void 0;
1654
- const dimension = Number(dimRaw);
1655
- if (!Number.isFinite(dimension) || dimension <= 0) return void 0;
1656
- return { providerId, model, dimension };
1657
- }
1658
- function writeEmbeddingIdentity(db, identity) {
1659
- const stmt = db.prepare(
1660
- "INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value"
1661
- );
1662
- stmt.run(META_KEY_PROVIDER_ID, identity.providerId);
1663
- stmt.run(META_KEY_MODEL, identity.model);
1664
- stmt.run(META_KEY_DIMENSION, String(identity.dimension));
1665
- }
1666
- function identityMatches(a, b) {
1667
- return a.providerId === b.providerId && a.model === b.model && a.dimension === b.dimension;
1668
- }
1669
- function dropVectorIndex(db) {
1670
- db.exec("DROP TABLE IF EXISTS embeddings");
1671
- }
1672
- function createVectorIndex(db, dimension) {
1673
- db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS embeddings USING vec0(
1674
- chunk_id INTEGER PRIMARY KEY,
1675
- vec FLOAT[${dimension}]
1676
- )`);
1677
- }
1678
- function packVector(vec) {
1679
- const f32 = new Float32Array(vec.length);
1680
- for (let i = 0; i < vec.length; i++) f32[i] = vec[i] ?? 0;
1681
- return Buffer.from(f32.buffer);
1682
- }
1683
- function upsertEmbedding(db, chunkId, vec) {
1684
- const id = BigInt(chunkId);
1685
- db.prepare("DELETE FROM embeddings WHERE chunk_id = ?").run(id);
1686
- db.prepare("INSERT INTO embeddings (chunk_id, vec) VALUES (?, ?)").run(id, packVector(vec));
1687
- }
1688
- function vectorSearch(db, query, k) {
1689
- const rows = db.prepare(
1690
- `SELECT chunk_id, distance FROM embeddings
1691
- WHERE vec MATCH ? AND k = ?
1692
- ORDER BY distance`
1693
- ).all(packVector(query), BigInt(k));
1694
- return rows.map((row) => ({ chunk_id: Number(row.chunk_id), distance: Number(row.distance) }));
1695
- }
1696
- async function embedMissingChunks(args) {
1697
- const rows = args.db.prepare(
1698
- `SELECT chunks.id as id, chunks.text as text
1699
- FROM chunks
1700
- LEFT JOIN embeddings ON embeddings.chunk_id = chunks.id
1701
- WHERE embeddings.chunk_id IS NULL`
1702
- ).all();
1703
- if (rows.length === 0) return 0;
1704
- const normalized = rows.map((row) => ({ id: Number(row.id), text: String(row.text ?? "") }));
1705
- const vectors = await args.runtime.embed(normalized.map((r) => r.text));
1706
- for (let i = 0; i < normalized.length; i++) {
1707
- const row = normalized[i];
1708
- const vector = vectors[i];
1709
- if (row === void 0 || vector === void 0) continue;
1710
- upsertEmbedding(args.db, row.id, vector);
1711
- }
1712
- return normalized.length;
1713
- }
1714
-
1715
1309
  // src/internal/index/index-manager.ts
1716
1310
  var IndexManager = class _IndexManager {
1717
1311
  constructor(memoryRoot, db, embedding) {
@@ -1734,24 +1328,24 @@ var IndexManager = class _IndexManager {
1734
1328
  static async openSqliteInternal(opts) {
1735
1329
  const memoryRoot = opts.memoryRoot ?? memoryStore.resolveMemoryRoot(opts.cwd);
1736
1330
  const filePath = opts.filePath ?? memoryStore.defaultIndexPath(memoryStore.projectMemoryDir(opts.cwd));
1737
- const db = await openMemoryDb({ filePath });
1331
+ const db = await memoryStore.openMemoryDb({ filePath });
1738
1332
  const manager = new _IndexManager(memoryRoot, db, opts.embedding);
1739
1333
  if (opts.embedding !== void 0) await manager.initVectorBackend(opts.embedding);
1740
1334
  return manager;
1741
1335
  }
1742
1336
  async initVectorBackend(runtime) {
1743
- await loadSqliteVecExtension(this.db);
1337
+ await memoryStore.loadSqliteVecExtension(this.db);
1744
1338
  const currentIdentity = {
1745
1339
  providerId: runtime.id,
1746
1340
  model: runtime.model,
1747
1341
  dimension: runtime.dimension
1748
1342
  };
1749
- const persisted = readEmbeddingIdentity(this.db);
1750
- if (persisted !== void 0 && !identityMatches(persisted, currentIdentity)) {
1751
- dropVectorIndex(this.db);
1343
+ const persisted = memoryStore.readEmbeddingIdentity(this.db);
1344
+ if (persisted !== void 0 && !memoryStore.identityMatches(persisted, currentIdentity)) {
1345
+ memoryStore.dropVectorIndex(this.db);
1752
1346
  }
1753
- createVectorIndex(this.db, runtime.dimension);
1754
- writeEmbeddingIdentity(this.db, currentIdentity);
1347
+ memoryStore.createVectorIndex(this.db, runtime.dimension);
1348
+ memoryStore.writeEmbeddingIdentity(this.db, currentIdentity);
1755
1349
  this.vectorReady = true;
1756
1350
  }
1757
1351
  /** Walk the memory corpus + (re)index changed files. */
@@ -1774,7 +1368,7 @@ var IndexManager = class _IndexManager {
1774
1368
  entry.source
1775
1369
  );
1776
1370
  this.deleteChunksForFile(fileId);
1777
- const chunks = chunkMarkdown(raw);
1371
+ const chunks = memoryStore.chunkMarkdown(raw);
1778
1372
  for (const chunk of chunks) {
1779
1373
  this.insertChunk(fileId, chunk.startLine, chunk.endLine, chunk.text, chunk.hash);
1780
1374
  }
@@ -1783,14 +1377,14 @@ var IndexManager = class _IndexManager {
1783
1377
  }
1784
1378
  let chunksEmbedded = 0;
1785
1379
  if (this.vectorReady && this.embedding !== void 0) {
1786
- chunksEmbedded = await embedMissingChunks({ db: this.db, runtime: this.embedding });
1380
+ chunksEmbedded = await memoryStore.embedMissingChunks({ db: this.db, runtime: this.embedding });
1787
1381
  }
1788
1382
  this.lastSyncMs = Date.now();
1789
1383
  return { filesScanned: files.length, filesUpdated, chunksWritten, chunksEmbedded };
1790
1384
  }
1791
1385
  async search(query, options = {}) {
1792
1386
  if (query.trim().length === 0) return [];
1793
- const { maxResults, minScore } = parseSearchOptions(options);
1387
+ const { maxResults, minScore } = memoryStore.parseSearchOptions(options);
1794
1388
  const textHits = this.ftsSearch(query, maxResults * 2);
1795
1389
  const vectorHitsById = await this.vectorSearchById(query, maxResults * 2);
1796
1390
  const combined = this.combineHybridScores(textHits, vectorHitsById, options);
@@ -1853,7 +1447,7 @@ var IndexManager = class _IndexManager {
1853
1447
  if (!this.vectorReady || this.embedding === void 0) return /* @__PURE__ */ new Map();
1854
1448
  const [queryVec] = await this.embedding.embed([query]);
1855
1449
  if (queryVec === void 0) return /* @__PURE__ */ new Map();
1856
- const rows = vectorSearch(this.db, queryVec, limit);
1450
+ const rows = memoryStore.vectorSearch(this.db, queryVec, limit);
1857
1451
  const out = /* @__PURE__ */ new Map();
1858
1452
  for (const row of rows) {
1859
1453
  const score = 1 / (1 + Math.max(0, row.distance));
@@ -2139,31 +1733,6 @@ async function migrateLegacyJson(cwd, config) {
2139
1733
  function resetMigrationStateForTests() {
2140
1734
  migrationRun.clear();
2141
1735
  }
2142
- var DEFAULT_MEMORY_READ_LINES = 200;
2143
- async function readMemoryFileBounded(opts) {
2144
- const absolutePath = path.resolve(opts.cwd, opts.relPath);
2145
- const raw = await promises.readFile(absolutePath, "utf8");
2146
- const allLines = raw.split("\n");
2147
- const trimmedLines = allLines.length > 0 && allLines[allLines.length - 1] === "" ? allLines.slice(0, -1) : allLines;
2148
- const totalLines = trimmedLines.length;
2149
- const requestedFrom = Math.max(1, opts.from ?? 1);
2150
- const requestedLines = Math.max(1, opts.lines ?? DEFAULT_MEMORY_READ_LINES);
2151
- const startIdx = requestedFrom - 1;
2152
- const endIdx = Math.min(totalLines, startIdx + requestedLines);
2153
- const slice = trimmedLines.slice(startIdx, endIdx);
2154
- const linesReturned = slice.length;
2155
- const remainingLines = Math.max(0, totalLines - endIdx);
2156
- const truncated = remainingLines > 0;
2157
- return {
2158
- path: opts.relPath,
2159
- from: requestedFrom,
2160
- linesReturned,
2161
- totalLines,
2162
- truncated,
2163
- remainingLines,
2164
- text: slice.join("\n")
2165
- };
2166
- }
2167
1736
  var SEARCH_DESCRIPTION = "Mandatory recall step: semantically search MEMORY.md + memory/notes/*.md (and optional wiki supplements) before answering questions about prior work, decisions, dates, people, preferences, or todos. `corpus=memory` (default) restricts to indexed memory files; `corpus=wiki` restricts to read-only wiki supplements; `corpus=all` returns both. Returns ranked `{ path, startLine, endLine, score, snippet, citation }` hits.";
2168
1737
  var GET_DESCRIPTION = "Safe exact excerpt read from MEMORY.md or memory/notes/*.md. Defaults to a bounded excerpt (200 lines). Returns `{ path, from, linesReturned, totalLines, truncated, remainingLines, text }`. Paths are resolved against the memory root \u2014 attempts to read outside `.theokit/memory/` are rejected.";
2169
1738
  var MEMORY_SEARCH_SCHEMA = {
@@ -2233,7 +1802,7 @@ function createMemoryGetTool(opts) {
2233
1802
  };
2234
1803
  if (from !== void 0) readArgs.from = from;
2235
1804
  if (lines !== void 0) readArgs.lines = lines;
2236
- const result = await readMemoryFileBounded(readArgs);
1805
+ const result = await memoryStore.readMemoryFileBounded(readArgs);
2237
1806
  return JSON.stringify(result);
2238
1807
  }
2239
1808
  };
@@ -2280,6 +1849,14 @@ function isPathInside(root, candidate) {
2280
1849
  return candidate === root || candidate.startsWith(normalizedRoot);
2281
1850
  }
2282
1851
 
1852
+ Object.defineProperty(exports, "ActiveMemoryCache", {
1853
+ enumerable: true,
1854
+ get: function () { return memoryStore.ActiveMemoryCache; }
1855
+ });
1856
+ Object.defineProperty(exports, "DEFAULT_MEMORY_READ_LINES", {
1857
+ enumerable: true,
1858
+ get: function () { return memoryStore.DEFAULT_MEMORY_READ_LINES; }
1859
+ });
2283
1860
  Object.defineProperty(exports, "MEMORY_INDEX_MAX_BYTES", {
2284
1861
  enumerable: true,
2285
1862
  get: function () { return memoryStore.MEMORY_INDEX_MAX_BYTES; }
@@ -2288,6 +1865,26 @@ Object.defineProperty(exports, "MEMORY_INDEX_MAX_LINES", {
2288
1865
  enumerable: true,
2289
1866
  get: function () { return memoryStore.MEMORY_INDEX_MAX_LINES; }
2290
1867
  });
1868
+ Object.defineProperty(exports, "META_KEY_DIMENSION", {
1869
+ enumerable: true,
1870
+ get: function () { return memoryStore.META_KEY_DIMENSION; }
1871
+ });
1872
+ Object.defineProperty(exports, "META_KEY_MODEL", {
1873
+ enumerable: true,
1874
+ get: function () { return memoryStore.META_KEY_MODEL; }
1875
+ });
1876
+ Object.defineProperty(exports, "META_KEY_PROVIDER_ID", {
1877
+ enumerable: true,
1878
+ get: function () { return memoryStore.META_KEY_PROVIDER_ID; }
1879
+ });
1880
+ Object.defineProperty(exports, "PRAGMA_STATEMENTS", {
1881
+ enumerable: true,
1882
+ get: function () { return memoryStore.PRAGMA_STATEMENTS; }
1883
+ });
1884
+ Object.defineProperty(exports, "SCHEMA_STATEMENTS", {
1885
+ enumerable: true,
1886
+ get: function () { return memoryStore.SCHEMA_STATEMENTS; }
1887
+ });
2291
1888
  Object.defineProperty(exports, "appendDiaryEntry", {
2292
1889
  enumerable: true,
2293
1890
  get: function () { return memoryStore.appendDiaryEntry; }
@@ -2308,6 +1905,10 @@ Object.defineProperty(exports, "ceilingReachedError", {
2308
1905
  enumerable: true,
2309
1906
  get: function () { return memoryStore.ceilingReachedError; }
2310
1907
  });
1908
+ Object.defineProperty(exports, "chunkMarkdown", {
1909
+ enumerable: true,
1910
+ get: function () { return memoryStore.chunkMarkdown; }
1911
+ });
2311
1912
  Object.defineProperty(exports, "claudeProjectMemoryDir", {
2312
1913
  enumerable: true,
2313
1914
  get: function () { return memoryStore.claudeProjectMemoryDir; }
@@ -2316,6 +1917,14 @@ Object.defineProperty(exports, "collectMarkdownFiles", {
2316
1917
  enumerable: true,
2317
1918
  get: function () { return memoryStore.collectMarkdownFiles; }
2318
1919
  });
1920
+ Object.defineProperty(exports, "createVectorIndex", {
1921
+ enumerable: true,
1922
+ get: function () { return memoryStore.createVectorIndex; }
1923
+ });
1924
+ Object.defineProperty(exports, "deepPhase", {
1925
+ enumerable: true,
1926
+ get: function () { return memoryStore.deepPhase; }
1927
+ });
2319
1928
  Object.defineProperty(exports, "defaultIndexPath", {
2320
1929
  enumerable: true,
2321
1930
  get: function () { return memoryStore.defaultIndexPath; }
@@ -2332,10 +1941,22 @@ Object.defineProperty(exports, "discoverWikiFiles", {
2332
1941
  enumerable: true,
2333
1942
  get: function () { return memoryStore.discoverWikiFiles; }
2334
1943
  });
1944
+ Object.defineProperty(exports, "dropVectorIndex", {
1945
+ enumerable: true,
1946
+ get: function () { return memoryStore.dropVectorIndex; }
1947
+ });
1948
+ Object.defineProperty(exports, "embedMissingChunks", {
1949
+ enumerable: true,
1950
+ get: function () { return memoryStore.embedMissingChunks; }
1951
+ });
2335
1952
  Object.defineProperty(exports, "entryHash", {
2336
1953
  enumerable: true,
2337
1954
  get: function () { return memoryStore.entryHash; }
2338
1955
  });
1956
+ Object.defineProperty(exports, "identityMatches", {
1957
+ enumerable: true,
1958
+ get: function () { return memoryStore.identityMatches; }
1959
+ });
2339
1960
  Object.defineProperty(exports, "indexBudgetWarning", {
2340
1961
  enumerable: true,
2341
1962
  get: function () { return memoryStore.indexBudgetWarning; }
@@ -2344,6 +1965,14 @@ Object.defineProperty(exports, "lanceStoragePath", {
2344
1965
  enumerable: true,
2345
1966
  get: function () { return memoryStore.lanceStoragePath; }
2346
1967
  });
1968
+ Object.defineProperty(exports, "lightPhase", {
1969
+ enumerable: true,
1970
+ get: function () { return memoryStore.lightPhase; }
1971
+ });
1972
+ Object.defineProperty(exports, "loadSqliteVecExtension", {
1973
+ enumerable: true,
1974
+ get: function () { return memoryStore.loadSqliteVecExtension; }
1975
+ });
2347
1976
  Object.defineProperty(exports, "memoryIndexRoot", {
2348
1977
  enumerable: true,
2349
1978
  get: function () { return memoryStore.memoryIndexRoot; }
@@ -2360,6 +1989,18 @@ Object.defineProperty(exports, "notesDir", {
2360
1989
  enumerable: true,
2361
1990
  get: function () { return memoryStore.notesDir; }
2362
1991
  });
1992
+ Object.defineProperty(exports, "openMemoryDb", {
1993
+ enumerable: true,
1994
+ get: function () { return memoryStore.openMemoryDb; }
1995
+ });
1996
+ Object.defineProperty(exports, "packVector", {
1997
+ enumerable: true,
1998
+ get: function () { return memoryStore.packVector; }
1999
+ });
2000
+ Object.defineProperty(exports, "parseSearchOptions", {
2001
+ enumerable: true,
2002
+ get: function () { return memoryStore.parseSearchOptions; }
2003
+ });
2363
2004
  Object.defineProperty(exports, "persistActiveMemoryTranscript", {
2364
2005
  enumerable: true,
2365
2006
  get: function () { return memoryStore.persistActiveMemoryTranscript; }
@@ -2372,6 +2013,10 @@ Object.defineProperty(exports, "readAllSqliteFacts", {
2372
2013
  enumerable: true,
2373
2014
  get: function () { return memoryStore.readAllSqliteFacts; }
2374
2015
  });
2016
+ Object.defineProperty(exports, "readEmbeddingIdentity", {
2017
+ enumerable: true,
2018
+ get: function () { return memoryStore.readEmbeddingIdentity; }
2019
+ });
2375
2020
  Object.defineProperty(exports, "readFacts", {
2376
2021
  enumerable: true,
2377
2022
  get: function () { return memoryStore.readFacts; }
@@ -2380,6 +2025,14 @@ Object.defineProperty(exports, "readFactsFromMarkdown", {
2380
2025
  enumerable: true,
2381
2026
  get: function () { return memoryStore.readFactsFromMarkdown; }
2382
2027
  });
2028
+ Object.defineProperty(exports, "readMemoryFileBounded", {
2029
+ enumerable: true,
2030
+ get: function () { return memoryStore.readMemoryFileBounded; }
2031
+ });
2032
+ Object.defineProperty(exports, "remPhase", {
2033
+ enumerable: true,
2034
+ get: function () { return memoryStore.remPhase; }
2035
+ });
2383
2036
  Object.defineProperty(exports, "renderDiaryEntry", {
2384
2037
  enumerable: true,
2385
2038
  get: function () { return memoryStore.renderDiaryEntry; }
@@ -2392,6 +2045,10 @@ Object.defineProperty(exports, "resolveMemoryRoot", {
2392
2045
  enumerable: true,
2393
2046
  get: function () { return memoryStore.resolveMemoryRoot; }
2394
2047
  });
2048
+ Object.defineProperty(exports, "runDreamingSweep", {
2049
+ enumerable: true,
2050
+ get: function () { return memoryStore.runDreamingSweep; }
2051
+ });
2395
2052
  Object.defineProperty(exports, "sessionSummaryPath", {
2396
2053
  enumerable: true,
2397
2054
  get: function () { return memoryStore.sessionSummaryPath; }
@@ -2400,10 +2057,22 @@ Object.defineProperty(exports, "sessionsDir", {
2400
2057
  enumerable: true,
2401
2058
  get: function () { return memoryStore.sessionsDir; }
2402
2059
  });
2060
+ Object.defineProperty(exports, "upsertEmbedding", {
2061
+ enumerable: true,
2062
+ get: function () { return memoryStore.upsertEmbedding; }
2063
+ });
2064
+ Object.defineProperty(exports, "vectorSearch", {
2065
+ enumerable: true,
2066
+ get: function () { return memoryStore.vectorSearch; }
2067
+ });
2403
2068
  Object.defineProperty(exports, "wikiDir", {
2404
2069
  enumerable: true,
2405
2070
  get: function () { return memoryStore.wikiDir; }
2406
2071
  });
2072
+ Object.defineProperty(exports, "writeEmbeddingIdentity", {
2073
+ enumerable: true,
2074
+ get: function () { return memoryStore.writeEmbeddingIdentity; }
2075
+ });
2407
2076
  Object.defineProperty(exports, "writeSessionSummary", {
2408
2077
  enumerable: true,
2409
2078
  get: function () { return memoryStore.writeSessionSummary; }
@@ -2412,14 +2081,12 @@ Object.defineProperty(exports, "createOpenAiCompatibleRuntime", {
2412
2081
  enumerable: true,
2413
2082
  get: function () { return memoryAdapters.createOpenAiCompatibleRuntime; }
2414
2083
  });
2415
- exports.ActiveMemoryCache = ActiveMemoryCache;
2416
2084
  exports.CircuitBreaker = CircuitBreaker;
2417
2085
  exports.DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL = DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL;
2418
2086
  exports.DEFAULT_COHERE_EMBEDDING_MODEL = DEFAULT_COHERE_EMBEDDING_MODEL;
2419
2087
  exports.DEFAULT_DEEPINFRA_EMBEDDING_MODEL = DEFAULT_DEEPINFRA_EMBEDDING_MODEL;
2420
2088
  exports.DEFAULT_GEMINI_EMBEDDING_MODEL = DEFAULT_GEMINI_EMBEDDING_MODEL;
2421
2089
  exports.DEFAULT_JINA_EMBEDDING_MODEL = DEFAULT_JINA_EMBEDDING_MODEL;
2422
- exports.DEFAULT_MEMORY_READ_LINES = DEFAULT_MEMORY_READ_LINES;
2423
2090
  exports.DEFAULT_MISTRAL_EMBEDDING_MODEL = DEFAULT_MISTRAL_EMBEDDING_MODEL;
2424
2091
  exports.DEFAULT_OLLAMA_EMBEDDING_MODEL = DEFAULT_OLLAMA_EMBEDDING_MODEL;
2425
2092
  exports.DEFAULT_OPENAI_EMBEDDING_MODEL = DEFAULT_OPENAI_EMBEDDING_MODEL;
@@ -2429,35 +2096,22 @@ exports.IndexManager = IndexManager;
2429
2096
  exports.LanceIndex = LanceIndex;
2430
2097
  exports.LanceMemoryAdapter = LanceMemoryAdapter;
2431
2098
  exports.MEMORY_EMBEDDING_ADAPTERS = MEMORY_EMBEDDING_ADAPTERS;
2432
- exports.META_KEY_DIMENSION = META_KEY_DIMENSION;
2433
- exports.META_KEY_MODEL = META_KEY_MODEL;
2434
- exports.META_KEY_PROVIDER_ID = META_KEY_PROVIDER_ID;
2435
- exports.PRAGMA_STATEMENTS = PRAGMA_STATEMENTS;
2436
- exports.SCHEMA_STATEMENTS = SCHEMA_STATEMENTS;
2437
2099
  exports.VALID_BACKENDS = VALID_BACKENDS;
2438
2100
  exports.assertValidBackend = assertValidBackend;
2439
2101
  exports.azureOpenAiMemoryEmbeddingProviderAdapter = azureOpenAiMemoryEmbeddingProviderAdapter;
2440
2102
  exports.buildErrorMetadata = buildErrorMetadata;
2441
- exports.chunkMarkdown = chunkMarkdown;
2442
2103
  exports.cohereMemoryEmbeddingProviderAdapter = cohereMemoryEmbeddingProviderAdapter;
2443
2104
  exports.createCategorizedMemory = createCategorizedMemory;
2444
2105
  exports.createInMemoryMarkdownProvider = createInMemoryMarkdownProvider;
2445
2106
  exports.createMemoryGetTool = createMemoryGetTool;
2446
2107
  exports.createMemorySearchTool = createMemorySearchTool;
2447
- exports.createVectorIndex = createVectorIndex;
2448
- exports.deepPhase = deepPhase;
2449
2108
  exports.deepinfraMemoryEmbeddingProviderAdapter = deepinfraMemoryEmbeddingProviderAdapter;
2450
- exports.dropVectorIndex = dropVectorIndex;
2451
- exports.embedMissingChunks = embedMissingChunks;
2452
2109
  exports.geminiMemoryEmbeddingProviderAdapter = geminiMemoryEmbeddingProviderAdapter;
2453
- exports.identityMatches = identityMatches;
2454
2110
  exports.isLanceAvailable = isLanceAvailable;
2455
2111
  exports.isSqliteVecLoaded = isSqliteVecLoaded;
2456
2112
  exports.jinaMemoryEmbeddingProviderAdapter = jinaMemoryEmbeddingProviderAdapter;
2457
2113
  exports.legacyMemoryJsonPath = legacyMemoryJsonPath;
2458
- exports.lightPhase = lightPhase;
2459
2114
  exports.listNotes = listNotes;
2460
- exports.loadSqliteVecExtension = loadSqliteVecExtension;
2461
2115
  exports.mapOpenAICompatibleError = mapOpenAICompatibleError;
2462
2116
  exports.migrateLegacyJson = migrateLegacyJson;
2463
2117
  exports.migrateSqliteToLance = migrateSqliteToLance;
@@ -2465,22 +2119,12 @@ exports.mistralMemoryEmbeddingProviderAdapter = mistralMemoryEmbeddingProviderAd
2465
2119
  exports.ollamaMemoryEmbeddingProviderAdapter = ollamaMemoryEmbeddingProviderAdapter;
2466
2120
  exports.openAiMemoryEmbeddingProviderAdapter = openAiMemoryEmbeddingProviderAdapter;
2467
2121
  exports.openLanceIndex = openLanceIndex;
2468
- exports.openMemoryDb = openMemoryDb;
2469
2122
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
2470
- exports.packVector = packVector;
2471
2123
  exports.parseRetryAfter = parseRetryAfter;
2472
- exports.parseSearchOptions = parseSearchOptions;
2473
- exports.readEmbeddingIdentity = readEmbeddingIdentity;
2474
- exports.readMemoryFileBounded = readMemoryFileBounded;
2475
2124
  exports.redactSecrets = redactSecrets;
2476
- exports.remPhase = remPhase;
2477
2125
  exports.resetMigrationStateForTests = resetMigrationStateForTests;
2478
2126
  exports.runActiveMemory = runActiveMemory;
2479
- exports.runDreamingSweep = runDreamingSweep;
2480
2127
  exports.truncateRaw = truncateRaw;
2481
- exports.upsertEmbedding = upsertEmbedding;
2482
- exports.vectorSearch = vectorSearch;
2483
2128
  exports.voyageMemoryEmbeddingProviderAdapter = voyageMemoryEmbeddingProviderAdapter;
2484
- exports.writeEmbeddingIdentity = writeEmbeddingIdentity;
2485
2129
  //# sourceMappingURL=index.cjs.map
2486
2130
  //# sourceMappingURL=index.cjs.map