memorix 1.10.0 → 1.10.2

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 (51) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +2 -0
  3. package/README.zh-CN.md +2 -0
  4. package/dist/cli/index.js +575 -196
  5. package/dist/index.js +375 -134
  6. package/dist/maintenance-runner.js +210 -46
  7. package/dist/media-audio-runner.js +182 -18
  8. package/dist/media-video-runner.js +209 -45
  9. package/dist/memcode-runtime/CHANGELOG.md +25 -0
  10. package/dist/sdk.js +426 -134
  11. package/dist/vector-backfill-runner.js +209 -45
  12. package/docs/1.2.0-EVALUATION-HARNESS.md +18 -0
  13. package/docs/CONFIGURATION.md +25 -0
  14. package/docs/DEVELOPMENT.md +3 -3
  15. package/docs/PERFORMANCE.md +23 -0
  16. package/docs/README.md +2 -2
  17. package/docs/ROADMAP-1.9.12-2.0.md +13 -6
  18. package/package.json +1 -1
  19. package/plugins/antigravity/memorix/plugin.json +1 -1
  20. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  21. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  22. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  23. package/plugins/copilot/memorix/plugin.json +1 -1
  24. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  25. package/plugins/hermes/memorix/__init__.py +1 -2
  26. package/plugins/hermes/memorix/plugin.yaml +1 -1
  27. package/plugins/omp/memorix/package.json +1 -1
  28. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  29. package/plugins/pi/memorix/package.json +1 -1
  30. package/server.json +2 -2
  31. package/src/cli/commands/init.ts +6 -2
  32. package/src/cli/commands/repair.ts +17 -3
  33. package/src/cli/tui/ConfigureView.tsx +2 -0
  34. package/src/codegraph/auto-context.ts +17 -0
  35. package/src/codegraph/context-pack.ts +15 -0
  36. package/src/compact/engine.ts +11 -0
  37. package/src/compact/index-format.ts +1 -1
  38. package/src/config/dotenv-loader.ts +1 -0
  39. package/src/config/resolved-config.ts +5 -2
  40. package/src/config/yaml-loader.ts +2 -2
  41. package/src/dashboard/server.ts +3 -0
  42. package/src/knowledge/context-assembly.ts +13 -0
  43. package/src/knowledge/context-receipt.ts +35 -0
  44. package/src/knowledge/workset.ts +8 -0
  45. package/src/llm/provider.ts +2 -1
  46. package/src/memory/observations.ts +7 -5
  47. package/src/multimodal/image-loader.ts +2 -2
  48. package/src/search/derived-view-receipt.ts +62 -0
  49. package/src/search/semantic-index.ts +149 -1
  50. package/src/server.ts +18 -3
  51. package/src/store/orama-store.ts +80 -2
@@ -3395,7 +3395,8 @@ function getResolvedConfig(options = {}) {
3395
3395
  const isAtlasCloud = memoryLlmProvider === "atlascloud";
3396
3396
  const isRequesty = memoryLlmProvider === "requesty";
3397
3397
  const isApiRoute = memoryLlmProvider === "apiroute";
3398
- const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute;
3398
+ const isCheaperInference = memoryLlmProvider === "cheaperinference";
3399
+ const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference;
3399
3400
  const memoryLlmApiKey = first(
3400
3401
  process.env.MEMORIX_LLM_API_KEY,
3401
3402
  process.env.MEMORIX_API_KEY,
@@ -3403,7 +3404,7 @@ function getResolvedConfig(options = {}) {
3403
3404
  yaml.llm?.apiKey,
3404
3405
  legacy.llm?.apiKey,
3405
3406
  // Never borrow another provider's credentials for these gateway presets.
3406
- isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : process.env.OPENAI_API_KEY,
3407
+ isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : isCheaperInference ? process.env.CHEAPER_INFERENCE_API_KEY : process.env.OPENAI_API_KEY,
3407
3408
  usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
3408
3409
  usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
3409
3410
  );
@@ -3587,6 +3588,7 @@ function getEnvSourceNames() {
3587
3588
  "OPENROUTER_API_KEY",
3588
3589
  "REQUESTY_API_KEY",
3589
3590
  "API_ROUTE_API_KEY",
3591
+ "CHEAPER_INFERENCE_API_KEY",
3590
3592
  "ATLASCLOUD_API_KEY"
3591
3593
  ].filter((name) => process.env[name]);
3592
3594
  }
@@ -6581,6 +6583,7 @@ var init_provider2 = __esm({
6581
6583
  openrouter: { baseUrl: "https://openrouter.ai/api/v1", model: "openai/gpt-4.1-nano" },
6582
6584
  requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
6583
6585
  apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
6586
+ cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
6584
6587
  atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
6585
6588
  custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
6586
6589
  };
@@ -7359,6 +7362,7 @@ var init_obs_store = __esm({
7359
7362
 
7360
7363
  // src/search/semantic-index.ts
7361
7364
  import { createHash as createHash4 } from "crypto";
7365
+ import { existsSync as existsSync8 } from "fs";
7362
7366
  import { createRequire as createRequire3 } from "module";
7363
7367
  import path8 from "path";
7364
7368
  function createSemanticIndexProfile(provider2) {
@@ -7457,17 +7461,80 @@ function queueOperation(key, operation) {
7457
7461
  writeQueues.set(key, run.catch(() => void 0));
7458
7462
  return run;
7459
7463
  }
7464
+ function positiveEnvInt(name, fallback) {
7465
+ const value = Number.parseInt(process.env[name] ?? "", 10);
7466
+ return Number.isSafeInteger(value) && value > 0 ? value : fallback;
7467
+ }
7468
+ function semanticWriteBatchSize() {
7469
+ return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_BATCH_SIZE", DEFAULT_WRITE_BATCH_SIZE);
7470
+ }
7471
+ function semanticWriteFlushMs() {
7472
+ return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_FLUSH_MS", DEFAULT_WRITE_FLUSH_MS);
7473
+ }
7474
+ function semanticOptimizeEvery() {
7475
+ return positiveEnvInt("MEMORIX_SEMANTIC_OPTIMIZE_EVERY", DEFAULT_OPTIMIZE_EVERY);
7476
+ }
7477
+ function semanticVersionRetentionMs() {
7478
+ return positiveEnvInt("MEMORIX_SEMANTIC_VERSION_RETENTION_MS", DEFAULT_VERSION_RETENTION_MS);
7479
+ }
7480
+ async function optimizeState(state) {
7481
+ if (!state.table || typeof state.table.optimize !== "function") return;
7482
+ await state.table.optimize({
7483
+ cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
7484
+ deleteUnverified: false
7485
+ });
7486
+ }
7460
7487
  async function mergeVectors(dataDir, profile, records) {
7461
7488
  if (records.length === 0) return;
7462
7489
  const state = await getState(dataDir, profile, records);
7463
7490
  if (!state?.table) return;
7464
7491
  const rows = records.map(toLanceRow);
7465
7492
  await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
7493
+ const key = stateKey(dataDir, profile);
7494
+ const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
7495
+ if (mutationCount >= semanticOptimizeEvery()) {
7496
+ mutationCounts.set(key, 0);
7497
+ await optimizeState(state).catch(() => void 0);
7498
+ } else {
7499
+ mutationCounts.set(key, mutationCount);
7500
+ }
7466
7501
  void ensureSemanticIndex(dataDir, profile);
7467
7502
  }
7503
+ function flushPendingVectorBatch(key) {
7504
+ const pending = pendingVectorBatches.get(key);
7505
+ if (!pending) return Promise.resolve();
7506
+ if (pending.timer) clearTimeout(pending.timer);
7507
+ pendingVectorBatches.delete(key);
7508
+ const records = [...pending.records.values()];
7509
+ const waiters = pending.waiters.splice(0);
7510
+ return queueOperation(key, () => mergeVectors(pending.dataDir, pending.profile, records)).then(() => waiters.forEach((waiter) => waiter.resolve())).catch((error) => {
7511
+ waiters.forEach((waiter) => waiter.reject(error));
7512
+ });
7513
+ }
7514
+ function upsertSemanticVector(dataDir, profile, record80) {
7515
+ const key = stateKey(dataDir, profile);
7516
+ let pending = pendingVectorBatches.get(key);
7517
+ if (!pending) {
7518
+ pending = { dataDir, profile, records: /* @__PURE__ */ new Map(), waiters: [] };
7519
+ pendingVectorBatches.set(key, pending);
7520
+ }
7521
+ pending.records.set(`${record80.projectId}:${record80.observationId}`, record80);
7522
+ const promise = new Promise((resolve2, reject) => pending.waiters.push({ resolve: resolve2, reject }));
7523
+ if (pending.records.size >= semanticWriteBatchSize()) void flushPendingVectorBatch(key);
7524
+ else if (!pending.timer) pending.timer = setTimeout(() => {
7525
+ void flushPendingVectorBatch(key);
7526
+ }, semanticWriteFlushMs());
7527
+ return promise;
7528
+ }
7468
7529
  function upsertSemanticVectors(dataDir, profile, records) {
7469
7530
  return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
7470
7531
  }
7532
+ async function listSemanticVectorIds(dataDir, profile) {
7533
+ const state = await getState(dataDir, profile);
7534
+ if (!state?.table) return null;
7535
+ const rows = await state.table.query().select(["observation_id"]).toArray();
7536
+ return new Set(rows.map((row) => Number(row.observation_id)).filter(Number.isSafeInteger));
7537
+ }
7471
7538
  function resolveIndexThreshold() {
7472
7539
  const raw = Number.parseInt(process.env.MEMORIX_SEMANTIC_INDEX_THRESHOLD ?? "", 10);
7473
7540
  return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_INDEX_THRESHOLD;
@@ -7519,7 +7586,7 @@ async function searchSemanticVectors(options) {
7519
7586
  distance: Number(row._distance ?? Number.POSITIVE_INFINITY)
7520
7587
  })).filter((row) => Number.isFinite(row.distance));
7521
7588
  }
7522
- var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, statePromises, writeQueues, indexBuilds, availability, requireFromHere2;
7589
+ var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, DEFAULT_WRITE_BATCH_SIZE, DEFAULT_WRITE_FLUSH_MS, DEFAULT_OPTIMIZE_EVERY, DEFAULT_VERSION_RETENTION_MS, statePromises, writeQueues, indexBuilds, mutationCounts, pendingVectorBatches, availability, requireFromHere2;
7523
7590
  var init_semantic_index = __esm({
7524
7591
  "src/search/semantic-index.ts"() {
7525
7592
  "use strict";
@@ -7528,13 +7595,54 @@ var init_semantic_index = __esm({
7528
7595
  TABLE_PREFIX = "observations_";
7529
7596
  DEFAULT_INDEX_THRESHOLD = 1e4;
7530
7597
  MAX_INDEX_PARTITIONS = 32;
7598
+ DEFAULT_WRITE_BATCH_SIZE = 100;
7599
+ DEFAULT_WRITE_FLUSH_MS = 50;
7600
+ DEFAULT_OPTIMIZE_EVERY = 20;
7601
+ DEFAULT_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
7531
7602
  statePromises = /* @__PURE__ */ new Map();
7532
7603
  writeQueues = /* @__PURE__ */ new Map();
7533
7604
  indexBuilds = /* @__PURE__ */ new Map();
7605
+ mutationCounts = /* @__PURE__ */ new Map();
7606
+ pendingVectorBatches = /* @__PURE__ */ new Map();
7534
7607
  requireFromHere2 = createRequire3(import.meta.url);
7535
7608
  }
7536
7609
  });
7537
7610
 
7611
+ // src/search/derived-view-receipt.ts
7612
+ function sanitizeDerivedViewFailureReason(reason) {
7613
+ const safe = sanitizeCredentials(reason).replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, "[path]").replace(/\s+/g, " ").trim();
7614
+ return safe.slice(0, 240) || "derived view failed";
7615
+ }
7616
+ function embeddingHealthReceipt(health, embeddingEnabled2) {
7617
+ if (health?.status === "disabled") {
7618
+ return { freshness: "current", rebuildStatus: "disabled" };
7619
+ }
7620
+ if (health?.status === "ready" || embeddingEnabled2) {
7621
+ return { freshness: "current", rebuildStatus: "idle" };
7622
+ }
7623
+ if (health?.status === "degraded") {
7624
+ return {
7625
+ freshness: "stale",
7626
+ rebuildStatus: "failed",
7627
+ ...health.failure ? {
7628
+ failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`
7629
+ } : { failureReason: "embedding provider degraded" }
7630
+ };
7631
+ }
7632
+ return {
7633
+ freshness: "unknown",
7634
+ rebuildStatus: "unavailable",
7635
+ failureReason: "embedding provider is not initialized"
7636
+ };
7637
+ }
7638
+ var init_derived_view_receipt = __esm({
7639
+ "src/search/derived-view-receipt.ts"() {
7640
+ "use strict";
7641
+ init_esm_shims();
7642
+ init_secret_filter();
7643
+ }
7644
+ });
7645
+
7538
7646
  // src/project/aliases.ts
7539
7647
  var aliases_exports = {};
7540
7648
  __export(aliases_exports, {
@@ -8143,6 +8251,8 @@ __export(orama_store_exports, {
8143
8251
  getLastSearchMode: () => getLastSearchMode,
8144
8252
  getObservationCount: () => getObservationCount,
8145
8253
  getObservationsByIds: () => getObservationsByIds,
8254
+ getPersistentSemanticVectorIds: () => getPersistentSemanticVectorIds,
8255
+ getSearchDerivedViews: () => getSearchDerivedViews,
8146
8256
  getTimeline: () => getTimeline,
8147
8257
  getVectorDimensions: () => getVectorDimensions,
8148
8258
  hasObservationVector: () => hasObservationVector,
@@ -8173,6 +8283,52 @@ function getLastSearchDiagnostics(projectId) {
8173
8283
  const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
8174
8284
  return diagnostics ? { ...diagnostics } : void 0;
8175
8285
  }
8286
+ function getSearchDerivedViews() {
8287
+ const views = {};
8288
+ const store = getOptionalObservationStore();
8289
+ if (store) {
8290
+ try {
8291
+ const generation = store.getGeneration();
8292
+ if (store.hasLexicalIndex?.()) {
8293
+ views.fts = { generation, freshness: "current", rebuildStatus: "idle" };
8294
+ } else {
8295
+ views.fts = {
8296
+ generation,
8297
+ freshness: "unknown",
8298
+ rebuildStatus: "unavailable",
8299
+ failureReason: sanitizeDerivedViewFailureReason(
8300
+ store.getBackendReason?.() ?? "persistent lexical index unavailable"
8301
+ )
8302
+ };
8303
+ }
8304
+ } catch (error) {
8305
+ views.fts = {
8306
+ freshness: "unknown",
8307
+ rebuildStatus: "failed",
8308
+ failureReason: sanitizeDerivedViewFailureReason(error instanceof Error ? error.message : String(error))
8309
+ };
8310
+ }
8311
+ } else {
8312
+ views.fts = {
8313
+ freshness: "unknown",
8314
+ rebuildStatus: "unavailable",
8315
+ failureReason: "observation store is not initialized"
8316
+ };
8317
+ }
8318
+ views.orama = db ? { generation: dbGeneration, freshness: "current", rebuildStatus: "idle" } : {
8319
+ generation: dbGeneration,
8320
+ freshness: "unknown",
8321
+ rebuildStatus: "unavailable",
8322
+ failureReason: "Orama index is not initialized"
8323
+ };
8324
+ let embeddingHealth;
8325
+ try {
8326
+ embeddingHealth = getEmbeddingRuntimeHealth?.();
8327
+ } catch {
8328
+ }
8329
+ views.embedding = embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
8330
+ return views;
8331
+ }
8176
8332
  function rememberSearchDiagnostics(key, value) {
8177
8333
  if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
8178
8334
  const oldest = lastSearchDiagnosticsByProject.keys().next().value;
@@ -8474,12 +8630,16 @@ function getVectorDimensions() {
8474
8630
  function getActiveSemanticIndexProfile() {
8475
8631
  return indexEmbeddingProvider ? createSemanticIndexProfile(indexEmbeddingProvider) : null;
8476
8632
  }
8633
+ async function getPersistentSemanticVectorIds(dataDir) {
8634
+ if (!indexEmbeddingProvider) return null;
8635
+ return listSemanticVectorIds(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
8636
+ }
8477
8637
  async function queueSemanticVector(dataDir, record80) {
8478
8638
  const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
8479
8639
  const profile = provider2 ? createSemanticIndexProfile(provider2) : null;
8480
8640
  if (!profile) return;
8481
8641
  try {
8482
- await upsertSemanticVectors(dataDir, profile, [record80]);
8642
+ await upsertSemanticVector(dataDir, profile, record80);
8483
8643
  } catch {
8484
8644
  }
8485
8645
  }
@@ -8541,6 +8701,7 @@ function isCompatibleCachedVector(vector) {
8541
8701
  async function attachCachedVectors(database, observations2) {
8542
8702
  const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
8543
8703
  const semanticProfile = getActiveSemanticIndexProfile();
8704
+ const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorIds(semanticDataDir, semanticProfile).catch(() => null) : null;
8544
8705
  const batchSize = 200;
8545
8706
  for (let start = 0; start < observations2.length; start += batchSize) {
8546
8707
  const batch = observations2.slice(start, start + batchSize);
@@ -8551,7 +8712,7 @@ async function attachCachedVectors(database, observations2) {
8551
8712
  const vector = cachedVectors[index];
8552
8713
  if (!isCompatibleCachedVector(vector)) continue;
8553
8714
  const observation = batch[index];
8554
- if (semanticDataDir && semanticProfile) {
8715
+ if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
8555
8716
  semanticRecords.push({
8556
8717
  observationId: observation.id,
8557
8718
  projectId: observation.projectId,
@@ -9324,6 +9485,7 @@ var init_orama_store = __esm({
9324
9485
  init_mini_skills();
9325
9486
  init_visibility();
9326
9487
  init_provider();
9488
+ init_provider();
9327
9489
  init_project_affinity();
9328
9490
  init_intent_detector();
9329
9491
  init_query_expansion();
@@ -9331,6 +9493,7 @@ var init_orama_store = __esm({
9331
9493
  init_timeout();
9332
9494
  init_obs_store();
9333
9495
  init_semantic_index();
9496
+ init_derived_view_receipt();
9334
9497
  db = null;
9335
9498
  dbInitPromise = null;
9336
9499
  dbGeneration = 0;
@@ -144027,7 +144190,7 @@ __export(video_jobs_exports, {
144027
144190
  runMiniMaxVideoGenerationJob: () => runMiniMaxVideoGenerationJob
144028
144191
  });
144029
144192
  import { spawn } from "child_process";
144030
- import { existsSync as existsSync8 } from "fs";
144193
+ import { existsSync as existsSync9 } from "fs";
144031
144194
  import path15 from "path";
144032
144195
  import { fileURLToPath as fileURLToPath2 } from "url";
144033
144196
  function safeError2(error) {
@@ -144275,7 +144438,7 @@ function resolveMediaVideoRunnerPath(moduleUrl = import.meta.url) {
144275
144438
  }
144276
144439
  function launchMediaVideoRunner(request, options = {}) {
144277
144440
  const runnerPath = options.runnerPath ?? resolveMediaVideoRunnerPath();
144278
- if (!existsSync8(runnerPath)) {
144441
+ if (!existsSync9(runnerPath)) {
144279
144442
  return { launched: false, reason: "Media video runner is unavailable until Memorix is built or reinstalled." };
144280
144443
  }
144281
144444
  try {
@@ -147242,7 +147405,7 @@ __export(lite_provider_exports, {
147242
147405
  refreshProjectLite: () => refreshProjectLite
147243
147406
  });
147244
147407
  import { createHash as createHash11 } from "crypto";
147245
- import { existsSync as existsSync10, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
147408
+ import { existsSync as existsSync11, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
147246
147409
  import { join as join4, relative as relative2 } from "path";
147247
147410
  function hashText2(text2) {
147248
147411
  return createHash11("sha256").update(text2).digest("hex");
@@ -147260,7 +147423,7 @@ function resolveMaxFileBytes(value) {
147260
147423
  return Math.max(1, Math.floor(value));
147261
147424
  }
147262
147425
  function isPythonVirtualenvDir(dir) {
147263
- return existsSync10(join4(dir, "pyvenv.cfg"));
147426
+ return existsSync11(join4(dir, "pyvenv.cfg"));
147264
147427
  }
147265
147428
  function walk(root, exclude, maxFiles) {
147266
147429
  const out = [];
@@ -150799,7 +150962,7 @@ __export(vector_backfill_runner_exports, {
150799
150962
  import { spawn as spawn2 } from "child_process";
150800
150963
  import {
150801
150964
  closeSync,
150802
- existsSync as existsSync11,
150965
+ existsSync as existsSync12,
150803
150966
  mkdirSync as mkdirSync2,
150804
150967
  openSync,
150805
150968
  readFileSync as readFileSync9,
@@ -150927,7 +151090,7 @@ function releaseVectorBackfillLock(lockPath = process.env.MEMORIX_VECTOR_BACKFIL
150927
151090
  }
150928
151091
  function launchDetachedVectorBackfill(request, options = {}) {
150929
151092
  const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
150930
- const exists = options.exists ?? existsSync11;
151093
+ const exists = options.exists ?? existsSync12;
150931
151094
  if (!exists(runnerPath)) return false;
150932
151095
  const lock = acquireVectorBackfillLock(request.dataDir, request.projectId, options.lockPath);
150933
151096
  if (!lock) return false;
@@ -151946,13 +152109,14 @@ async function prepareSearchIndex(options = {}) {
151946
152109
  return 0;
151947
152110
  }
151948
152111
  const hydratedProjectDir = projectDir;
151949
- const queueMissingVectors = () => {
151950
- if (projectDir !== hydratedProjectDir) return;
152112
+ const queueMissingVectors = async () => {
152113
+ if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
151951
152114
  vectorMissingIds.clear();
151952
152115
  if (!isEmbeddingExplicitlyDisabled()) {
152116
+ const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
151953
152117
  const projectsWithMissingVectors = /* @__PURE__ */ new Set();
151954
152118
  for (const obs of observations) {
151955
- if (!hasObservationVector(obs.projectId, obs.id)) {
152119
+ if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
151956
152120
  vectorMissingIds.add(obs.id);
151957
152121
  projectsWithMissingVectors.add(obs.projectId);
151958
152122
  }
@@ -151962,9 +152126,9 @@ async function prepareSearchIndex(options = {}) {
151962
152126
  };
151963
152127
  const cacheHydration = getDeferredCachedVectorHydration();
151964
152128
  if (cacheHydration) {
151965
- void cacheHydration.finally(queueMissingVectors);
152129
+ void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => void 0);
151966
152130
  } else {
151967
- queueMissingVectors();
152131
+ await queueMissingVectors();
151968
152132
  }
151969
152133
  searchIndexPrepared = true;
151970
152134
  return count2;
@@ -152232,7 +152396,7 @@ __export(audio_jobs_exports, {
152232
152396
  transcribeAudio: () => transcribeAudio
152233
152397
  });
152234
152398
  import { spawn as spawn3 } from "child_process";
152235
- import { existsSync as existsSync12 } from "fs";
152399
+ import { existsSync as existsSync13 } from "fs";
152236
152400
  import path21 from "path";
152237
152401
  import { fileURLToPath as fileURLToPath4 } from "url";
152238
152402
  function safeError3(error) {
@@ -152483,7 +152647,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
152483
152647
  }
152484
152648
  function launchMediaAudioRunner(request, options = {}) {
152485
152649
  const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
152486
- if (!existsSync12(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
152650
+ if (!existsSync13(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
152487
152651
  try {
152488
152652
  const child = spawn3(process.execPath, [runnerPath, JSON.stringify(request)], {
152489
152653
  cwd: request.projectRoot,