memorix 1.10.1 → 1.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/dist/cli/index.js +810 -379
- package/dist/cli/memcode.js +0 -0
- package/dist/index.js +380 -142
- package/dist/maintenance-runner.js +275 -79
- package/dist/media-audio-runner.js +247 -51
- package/dist/media-video-runner.js +274 -78
- package/dist/memcode-runtime/CHANGELOG.md +34 -0
- package/dist/sdk.js +431 -142
- package/dist/types.d.ts +1 -1
- package/dist/vector-backfill-runner.js +274 -78
- package/docs/CONFIGURATION.md +34 -0
- package/docs/DEVELOPMENT.md +3 -4
- package/docs/INTEGRATIONS.md +1 -1
- package/docs/PERFORMANCE.md +23 -0
- package/docs/README.md +3 -2
- package/docs/ROADMAP-1.9.12-2.0.md +2 -2
- package/docs/SETUP.md +19 -4
- package/package.json +1 -1
- package/plugins/antigravity/memorix/plugin.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
- package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/copilot/memorix/plugin.json +1 -1
- package/plugins/gemini/memorix/gemini-extension.json +1 -1
- package/plugins/hermes/memorix/__init__.py +1 -2
- package/plugins/hermes/memorix/plugin.yaml +1 -1
- package/plugins/omp/memorix/package.json +1 -1
- package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/agent-integrations.ts +1 -1
- package/src/cli/commands/background.ts +1 -1
- package/src/cli/commands/context.ts +3 -2
- package/src/cli/commands/doctor.ts +9 -0
- package/src/cli/commands/explain.ts +3 -2
- package/src/cli/commands/init.ts +6 -2
- package/src/cli/commands/repair.ts +17 -3
- package/src/cli/commands/setup.ts +9 -6
- package/src/cli/commands/uninstall.ts +15 -0
- package/src/cli/tui/App.tsx +9 -16
- package/src/cli/tui/ConfigureView.tsx +2 -0
- package/src/codegraph/auto-context.ts +1 -1
- package/src/codegraph/store.ts +37 -0
- package/src/codegraph/types.ts +3 -0
- package/src/compact/index-format.ts +1 -1
- package/src/config/dotenv-loader.ts +1 -0
- package/src/config/resolved-config.ts +7 -2
- package/src/config/toml-loader.ts +1 -0
- package/src/config/yaml-loader.ts +4 -2
- package/src/dashboard/server.ts +5 -6
- package/src/hooks/handler.ts +0 -1
- package/src/integrations/registry.ts +2 -1
- package/src/knowledge/context-receipt.ts +6 -3
- package/src/llm/provider.ts +2 -1
- package/src/memory/observations.ts +68 -22
- package/src/multimodal/image-loader.ts +2 -2
- package/src/runtime/open-browser.ts +25 -0
- package/src/search/derived-view-receipt.ts +40 -0
- package/src/search/semantic-index.ts +149 -1
- package/src/server.ts +20 -5
- package/src/store/orama-store.ts +59 -19
- package/src/types.ts +1 -1
- package/src/workspace/mcp-adapters/pi.ts +58 -0
- package/plugins/pi/memorix/skills/memorix-git-memory/SKILL.md +0 -26
- package/plugins/pi/memorix/skills/memorix-memory/SKILL.md +0 -51
- package/plugins/pi/memorix/skills/memorix-mini-skills/SKILL.md +0 -31
- package/plugins/pi/memorix/skills/memorix-orchestrate/SKILL.md +0 -28
- package/plugins/pi/memorix/skills/memorix-reasoning/SKILL.md +0 -30
- package/plugins/pi/memorix/skills/memorix-sessions/SKILL.md +0 -25
- package/plugins/pi/memorix/skills/memorix-troubleshooting/SKILL.md +0 -27
|
@@ -3396,7 +3396,8 @@ function getResolvedConfig(options = {}) {
|
|
|
3396
3396
|
const isRequesty = memoryLlmProvider === "requesty";
|
|
3397
3397
|
const isApiRoute = memoryLlmProvider === "apiroute";
|
|
3398
3398
|
const isCheaperInference = memoryLlmProvider === "cheaperinference";
|
|
3399
|
-
const
|
|
3399
|
+
const isRuncrate = memoryLlmProvider === "runcrate";
|
|
3400
|
+
const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference || isRuncrate;
|
|
3400
3401
|
const memoryLlmApiKey = first(
|
|
3401
3402
|
process.env.MEMORIX_LLM_API_KEY,
|
|
3402
3403
|
process.env.MEMORIX_API_KEY,
|
|
@@ -3404,7 +3405,7 @@ function getResolvedConfig(options = {}) {
|
|
|
3404
3405
|
yaml.llm?.apiKey,
|
|
3405
3406
|
legacy.llm?.apiKey,
|
|
3406
3407
|
// Never borrow another provider's credentials for these gateway presets.
|
|
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,
|
|
3408
|
+
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 : isRuncrate ? process.env.RUNCRATE_API_KEY : process.env.OPENAI_API_KEY,
|
|
3408
3409
|
usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
|
|
3409
3410
|
usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
|
|
3410
3411
|
);
|
|
@@ -3475,6 +3476,7 @@ function getResolvedConfig(options = {}) {
|
|
|
3475
3476
|
codegraph: {
|
|
3476
3477
|
excludePatterns: firstArray(toml.codegraph?.exclude_patterns, yaml.codegraph?.excludePatterns),
|
|
3477
3478
|
maxFileBytes: firstNumber(toml.codegraph?.max_file_bytes, yaml.codegraph?.maxFileBytes),
|
|
3479
|
+
autoRefresh: first(toml.codegraph?.auto_refresh, yaml.codegraph?.autoRefresh, "auto"),
|
|
3478
3480
|
externalContext: first(
|
|
3479
3481
|
normalizeExternalContext(process.env.MEMORIX_CODEGRAPH_EXTERNAL_CONTEXT),
|
|
3480
3482
|
toml.codegraph?.external_context,
|
|
@@ -3589,6 +3591,7 @@ function getEnvSourceNames() {
|
|
|
3589
3591
|
"REQUESTY_API_KEY",
|
|
3590
3592
|
"API_ROUTE_API_KEY",
|
|
3591
3593
|
"CHEAPER_INFERENCE_API_KEY",
|
|
3594
|
+
"RUNCRATE_API_KEY",
|
|
3592
3595
|
"ATLASCLOUD_API_KEY"
|
|
3593
3596
|
].filter((name) => process.env[name]);
|
|
3594
3597
|
}
|
|
@@ -6584,6 +6587,7 @@ var init_provider2 = __esm({
|
|
|
6584
6587
|
requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
|
|
6585
6588
|
apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
|
|
6586
6589
|
cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
|
|
6590
|
+
runcrate: { baseUrl: "https://api.runcrate.ai/v1", model: "deepseek-ai/DeepSeek-V4.1-Flash" },
|
|
6587
6591
|
atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
|
|
6588
6592
|
custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
|
|
6589
6593
|
};
|
|
@@ -7362,6 +7366,7 @@ var init_obs_store = __esm({
|
|
|
7362
7366
|
|
|
7363
7367
|
// src/search/semantic-index.ts
|
|
7364
7368
|
import { createHash as createHash4 } from "crypto";
|
|
7369
|
+
import { existsSync as existsSync8 } from "fs";
|
|
7365
7370
|
import { createRequire as createRequire3 } from "module";
|
|
7366
7371
|
import path8 from "path";
|
|
7367
7372
|
function createSemanticIndexProfile(provider2) {
|
|
@@ -7460,17 +7465,80 @@ function queueOperation(key, operation) {
|
|
|
7460
7465
|
writeQueues.set(key, run.catch(() => void 0));
|
|
7461
7466
|
return run;
|
|
7462
7467
|
}
|
|
7468
|
+
function positiveEnvInt(name, fallback) {
|
|
7469
|
+
const value = Number.parseInt(process.env[name] ?? "", 10);
|
|
7470
|
+
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
7471
|
+
}
|
|
7472
|
+
function semanticWriteBatchSize() {
|
|
7473
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_BATCH_SIZE", DEFAULT_WRITE_BATCH_SIZE);
|
|
7474
|
+
}
|
|
7475
|
+
function semanticWriteFlushMs() {
|
|
7476
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_FLUSH_MS", DEFAULT_WRITE_FLUSH_MS);
|
|
7477
|
+
}
|
|
7478
|
+
function semanticOptimizeEvery() {
|
|
7479
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_OPTIMIZE_EVERY", DEFAULT_OPTIMIZE_EVERY);
|
|
7480
|
+
}
|
|
7481
|
+
function semanticVersionRetentionMs() {
|
|
7482
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_VERSION_RETENTION_MS", DEFAULT_VERSION_RETENTION_MS);
|
|
7483
|
+
}
|
|
7484
|
+
async function optimizeState(state) {
|
|
7485
|
+
if (!state.table || typeof state.table.optimize !== "function") return;
|
|
7486
|
+
await state.table.optimize({
|
|
7487
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
7488
|
+
deleteUnverified: false
|
|
7489
|
+
});
|
|
7490
|
+
}
|
|
7463
7491
|
async function mergeVectors(dataDir, profile, records) {
|
|
7464
7492
|
if (records.length === 0) return;
|
|
7465
7493
|
const state = await getState(dataDir, profile, records);
|
|
7466
7494
|
if (!state?.table) return;
|
|
7467
7495
|
const rows = records.map(toLanceRow);
|
|
7468
7496
|
await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
7497
|
+
const key = stateKey(dataDir, profile);
|
|
7498
|
+
const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
|
|
7499
|
+
if (mutationCount >= semanticOptimizeEvery()) {
|
|
7500
|
+
mutationCounts.set(key, 0);
|
|
7501
|
+
await optimizeState(state).catch(() => void 0);
|
|
7502
|
+
} else {
|
|
7503
|
+
mutationCounts.set(key, mutationCount);
|
|
7504
|
+
}
|
|
7469
7505
|
void ensureSemanticIndex(dataDir, profile);
|
|
7470
7506
|
}
|
|
7507
|
+
function flushPendingVectorBatch(key) {
|
|
7508
|
+
const pending = pendingVectorBatches.get(key);
|
|
7509
|
+
if (!pending) return Promise.resolve();
|
|
7510
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
7511
|
+
pendingVectorBatches.delete(key);
|
|
7512
|
+
const records = [...pending.records.values()];
|
|
7513
|
+
const waiters = pending.waiters.splice(0);
|
|
7514
|
+
return queueOperation(key, () => mergeVectors(pending.dataDir, pending.profile, records)).then(() => waiters.forEach((waiter) => waiter.resolve())).catch((error) => {
|
|
7515
|
+
waiters.forEach((waiter) => waiter.reject(error));
|
|
7516
|
+
});
|
|
7517
|
+
}
|
|
7518
|
+
function upsertSemanticVector(dataDir, profile, record80) {
|
|
7519
|
+
const key = stateKey(dataDir, profile);
|
|
7520
|
+
let pending = pendingVectorBatches.get(key);
|
|
7521
|
+
if (!pending) {
|
|
7522
|
+
pending = { dataDir, profile, records: /* @__PURE__ */ new Map(), waiters: [] };
|
|
7523
|
+
pendingVectorBatches.set(key, pending);
|
|
7524
|
+
}
|
|
7525
|
+
pending.records.set(`${record80.projectId}:${record80.observationId}`, record80);
|
|
7526
|
+
const promise = new Promise((resolve2, reject) => pending.waiters.push({ resolve: resolve2, reject }));
|
|
7527
|
+
if (pending.records.size >= semanticWriteBatchSize()) void flushPendingVectorBatch(key);
|
|
7528
|
+
else if (!pending.timer) pending.timer = setTimeout(() => {
|
|
7529
|
+
void flushPendingVectorBatch(key);
|
|
7530
|
+
}, semanticWriteFlushMs());
|
|
7531
|
+
return promise;
|
|
7532
|
+
}
|
|
7471
7533
|
function upsertSemanticVectors(dataDir, profile, records) {
|
|
7472
7534
|
return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
|
|
7473
7535
|
}
|
|
7536
|
+
async function listSemanticVectorIds(dataDir, profile) {
|
|
7537
|
+
const state = await getState(dataDir, profile);
|
|
7538
|
+
if (!state?.table) return null;
|
|
7539
|
+
const rows = await state.table.query().select(["observation_id"]).toArray();
|
|
7540
|
+
return new Set(rows.map((row) => Number(row.observation_id)).filter(Number.isSafeInteger));
|
|
7541
|
+
}
|
|
7474
7542
|
function resolveIndexThreshold() {
|
|
7475
7543
|
const raw = Number.parseInt(process.env.MEMORIX_SEMANTIC_INDEX_THRESHOLD ?? "", 10);
|
|
7476
7544
|
return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_INDEX_THRESHOLD;
|
|
@@ -7522,7 +7590,7 @@ async function searchSemanticVectors(options) {
|
|
|
7522
7590
|
distance: Number(row._distance ?? Number.POSITIVE_INFINITY)
|
|
7523
7591
|
})).filter((row) => Number.isFinite(row.distance));
|
|
7524
7592
|
}
|
|
7525
|
-
var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, statePromises, writeQueues, indexBuilds, availability, requireFromHere2;
|
|
7593
|
+
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;
|
|
7526
7594
|
var init_semantic_index = __esm({
|
|
7527
7595
|
"src/search/semantic-index.ts"() {
|
|
7528
7596
|
"use strict";
|
|
@@ -7531,13 +7599,54 @@ var init_semantic_index = __esm({
|
|
|
7531
7599
|
TABLE_PREFIX = "observations_";
|
|
7532
7600
|
DEFAULT_INDEX_THRESHOLD = 1e4;
|
|
7533
7601
|
MAX_INDEX_PARTITIONS = 32;
|
|
7602
|
+
DEFAULT_WRITE_BATCH_SIZE = 100;
|
|
7603
|
+
DEFAULT_WRITE_FLUSH_MS = 50;
|
|
7604
|
+
DEFAULT_OPTIMIZE_EVERY = 20;
|
|
7605
|
+
DEFAULT_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
7534
7606
|
statePromises = /* @__PURE__ */ new Map();
|
|
7535
7607
|
writeQueues = /* @__PURE__ */ new Map();
|
|
7536
7608
|
indexBuilds = /* @__PURE__ */ new Map();
|
|
7609
|
+
mutationCounts = /* @__PURE__ */ new Map();
|
|
7610
|
+
pendingVectorBatches = /* @__PURE__ */ new Map();
|
|
7537
7611
|
requireFromHere2 = createRequire3(import.meta.url);
|
|
7538
7612
|
}
|
|
7539
7613
|
});
|
|
7540
7614
|
|
|
7615
|
+
// src/search/derived-view-receipt.ts
|
|
7616
|
+
function sanitizeDerivedViewFailureReason(reason) {
|
|
7617
|
+
const safe = sanitizeCredentials(reason).replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, "[path]").replace(/\s+/g, " ").trim();
|
|
7618
|
+
return safe.slice(0, 240) || "derived view failed";
|
|
7619
|
+
}
|
|
7620
|
+
function embeddingHealthReceipt(health, embeddingEnabled2) {
|
|
7621
|
+
if (health?.status === "disabled") {
|
|
7622
|
+
return { freshness: "current", rebuildStatus: "disabled" };
|
|
7623
|
+
}
|
|
7624
|
+
if (health?.status === "ready" || embeddingEnabled2) {
|
|
7625
|
+
return { freshness: "current", rebuildStatus: "idle" };
|
|
7626
|
+
}
|
|
7627
|
+
if (health?.status === "degraded") {
|
|
7628
|
+
return {
|
|
7629
|
+
freshness: "stale",
|
|
7630
|
+
rebuildStatus: "failed",
|
|
7631
|
+
...health.failure ? {
|
|
7632
|
+
failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`
|
|
7633
|
+
} : { failureReason: "embedding provider degraded" }
|
|
7634
|
+
};
|
|
7635
|
+
}
|
|
7636
|
+
return {
|
|
7637
|
+
freshness: "unknown",
|
|
7638
|
+
rebuildStatus: "unavailable",
|
|
7639
|
+
failureReason: "embedding provider is not initialized"
|
|
7640
|
+
};
|
|
7641
|
+
}
|
|
7642
|
+
var init_derived_view_receipt = __esm({
|
|
7643
|
+
"src/search/derived-view-receipt.ts"() {
|
|
7644
|
+
"use strict";
|
|
7645
|
+
init_esm_shims();
|
|
7646
|
+
init_secret_filter();
|
|
7647
|
+
}
|
|
7648
|
+
});
|
|
7649
|
+
|
|
7541
7650
|
// src/project/aliases.ts
|
|
7542
7651
|
var aliases_exports = {};
|
|
7543
7652
|
__export(aliases_exports, {
|
|
@@ -8146,6 +8255,7 @@ __export(orama_store_exports, {
|
|
|
8146
8255
|
getLastSearchMode: () => getLastSearchMode,
|
|
8147
8256
|
getObservationCount: () => getObservationCount,
|
|
8148
8257
|
getObservationsByIds: () => getObservationsByIds,
|
|
8258
|
+
getPersistentSemanticVectorIds: () => getPersistentSemanticVectorIds,
|
|
8149
8259
|
getSearchDerivedViews: () => getSearchDerivedViews,
|
|
8150
8260
|
getTimeline: () => getTimeline,
|
|
8151
8261
|
getVectorDimensions: () => getVectorDimensions,
|
|
@@ -8158,10 +8268,18 @@ __export(orama_store_exports, {
|
|
|
8158
8268
|
queueSemanticVector: () => queueSemanticVector,
|
|
8159
8269
|
removeObservation: () => removeObservation,
|
|
8160
8270
|
resetDb: () => resetDb,
|
|
8271
|
+
resolveSearchFuzzyTolerance: () => resolveSearchFuzzyTolerance,
|
|
8161
8272
|
searchObservations: () => searchObservations,
|
|
8162
8273
|
updateObservationMetadata: () => updateObservationMetadata
|
|
8163
8274
|
});
|
|
8164
8275
|
import { components, create, insert as insert2, insertMultiple, search, remove as remove2, update, count, getByID } from "@orama/orama";
|
|
8276
|
+
function resolveSearchFuzzyTolerance(query, quality) {
|
|
8277
|
+
if (quality === "fast") return void 0;
|
|
8278
|
+
const characters = [...query];
|
|
8279
|
+
const cjkCount = characters.filter((char) => /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]/u.test(char)).length;
|
|
8280
|
+
if (characters.length > 0 && cjkCount / characters.length > 0.3) return void 0;
|
|
8281
|
+
return query.length > 6 ? 2 : 1;
|
|
8282
|
+
}
|
|
8165
8283
|
function rememberSearchMode(key, value) {
|
|
8166
8284
|
if (!lastSearchModeByProject.has(key) && lastSearchModeByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
8167
8285
|
const oldest = lastSearchModeByProject.keys().next().value;
|
|
@@ -8190,14 +8308,16 @@ function getSearchDerivedViews() {
|
|
|
8190
8308
|
generation,
|
|
8191
8309
|
freshness: "unknown",
|
|
8192
8310
|
rebuildStatus: "unavailable",
|
|
8193
|
-
failureReason:
|
|
8311
|
+
failureReason: sanitizeDerivedViewFailureReason(
|
|
8312
|
+
store.getBackendReason?.() ?? "persistent lexical index unavailable"
|
|
8313
|
+
)
|
|
8194
8314
|
};
|
|
8195
8315
|
}
|
|
8196
8316
|
} catch (error) {
|
|
8197
8317
|
views.fts = {
|
|
8198
8318
|
freshness: "unknown",
|
|
8199
8319
|
rebuildStatus: "failed",
|
|
8200
|
-
failureReason: error instanceof Error ? error.message
|
|
8320
|
+
failureReason: sanitizeDerivedViewFailureReason(error instanceof Error ? error.message : String(error))
|
|
8201
8321
|
};
|
|
8202
8322
|
}
|
|
8203
8323
|
} else {
|
|
@@ -8213,18 +8333,12 @@ function getSearchDerivedViews() {
|
|
|
8213
8333
|
rebuildStatus: "unavailable",
|
|
8214
8334
|
failureReason: "Orama index is not initialized"
|
|
8215
8335
|
};
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
}
|
|
8220
|
-
views.embedding = { freshness: "current", rebuildStatus: "idle" };
|
|
8221
|
-
} else {
|
|
8222
|
-
views.embedding = {
|
|
8223
|
-
freshness: "unknown",
|
|
8224
|
-
rebuildStatus: "unavailable",
|
|
8225
|
-
failureReason: "embedding provider is not initialized"
|
|
8226
|
-
};
|
|
8336
|
+
let embeddingHealth;
|
|
8337
|
+
try {
|
|
8338
|
+
embeddingHealth = getEmbeddingRuntimeHealth?.();
|
|
8339
|
+
} catch {
|
|
8227
8340
|
}
|
|
8341
|
+
views.embedding = embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
|
|
8228
8342
|
return views;
|
|
8229
8343
|
}
|
|
8230
8344
|
function rememberSearchDiagnostics(key, value) {
|
|
@@ -8528,12 +8642,16 @@ function getVectorDimensions() {
|
|
|
8528
8642
|
function getActiveSemanticIndexProfile() {
|
|
8529
8643
|
return indexEmbeddingProvider ? createSemanticIndexProfile(indexEmbeddingProvider) : null;
|
|
8530
8644
|
}
|
|
8645
|
+
async function getPersistentSemanticVectorIds(dataDir) {
|
|
8646
|
+
if (!indexEmbeddingProvider) return null;
|
|
8647
|
+
return listSemanticVectorIds(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
|
|
8648
|
+
}
|
|
8531
8649
|
async function queueSemanticVector(dataDir, record80) {
|
|
8532
8650
|
const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
|
|
8533
8651
|
const profile = provider2 ? createSemanticIndexProfile(provider2) : null;
|
|
8534
8652
|
if (!profile) return;
|
|
8535
8653
|
try {
|
|
8536
|
-
await
|
|
8654
|
+
await upsertSemanticVector(dataDir, profile, record80);
|
|
8537
8655
|
} catch {
|
|
8538
8656
|
}
|
|
8539
8657
|
}
|
|
@@ -8595,6 +8713,7 @@ function isCompatibleCachedVector(vector) {
|
|
|
8595
8713
|
async function attachCachedVectors(database, observations2) {
|
|
8596
8714
|
const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
|
|
8597
8715
|
const semanticProfile = getActiveSemanticIndexProfile();
|
|
8716
|
+
const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorIds(semanticDataDir, semanticProfile).catch(() => null) : null;
|
|
8598
8717
|
const batchSize = 200;
|
|
8599
8718
|
for (let start = 0; start < observations2.length; start += batchSize) {
|
|
8600
8719
|
const batch = observations2.slice(start, start + batchSize);
|
|
@@ -8605,7 +8724,7 @@ async function attachCachedVectors(database, observations2) {
|
|
|
8605
8724
|
const vector = cachedVectors[index];
|
|
8606
8725
|
if (!isCompatibleCachedVector(vector)) continue;
|
|
8607
8726
|
const observation = batch[index];
|
|
8608
|
-
if (semanticDataDir && semanticProfile) {
|
|
8727
|
+
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
|
|
8609
8728
|
semanticRecords.push({
|
|
8610
8729
|
observationId: observation.id,
|
|
8611
8730
|
projectId: observation.projectId,
|
|
@@ -8806,7 +8925,10 @@ async function searchObservations(options) {
|
|
|
8806
8925
|
// Fuzzy tolerance: allow 1-char typos for short queries, 2 for longer
|
|
8807
8926
|
// Fuzzy matching is useful for ordinary recall, but grows sharply with
|
|
8808
8927
|
// corpus size. The fast profile deliberately uses exact lexical matching.
|
|
8809
|
-
...hasQuery
|
|
8928
|
+
...hasQuery ? (() => {
|
|
8929
|
+
const tolerance = resolveSearchFuzzyTolerance(originalQuery, quality);
|
|
8930
|
+
return tolerance === void 0 ? {} : { tolerance };
|
|
8931
|
+
})() : {}
|
|
8810
8932
|
};
|
|
8811
8933
|
let queryVector = null;
|
|
8812
8934
|
let embeddingProviderForSearch = null;
|
|
@@ -9037,14 +9159,16 @@ async function searchObservations(options) {
|
|
|
9037
9159
|
filesModified: doc.filesModified?.split?.("\n") ?? (Array.isArray(doc.filesModified) ? doc.filesModified : [])
|
|
9038
9160
|
});
|
|
9039
9161
|
}
|
|
9162
|
+
const topScore = Math.max(...intermediate.map((entry) => entry.score));
|
|
9163
|
+
const affinityTieWindow = topScore * 0.92;
|
|
9040
9164
|
intermediate = intermediate.map((entry) => {
|
|
9041
9165
|
const memory = memoryContentMap.get(entry.id);
|
|
9042
9166
|
if (!memory) return entry;
|
|
9043
9167
|
const { score: affinityScore } = calculateProjectAffinity(memory, affinityContext);
|
|
9168
|
+
if (entry.score < affinityTieWindow) return entry;
|
|
9044
9169
|
return {
|
|
9045
9170
|
...entry,
|
|
9046
|
-
score: entry.score * affinityScore
|
|
9047
|
-
// Apply affinity as multiplier
|
|
9171
|
+
score: entry.score * (0.98 + affinityScore * 0.02)
|
|
9048
9172
|
};
|
|
9049
9173
|
});
|
|
9050
9174
|
intermediate.sort((a, b) => b.score - a.score);
|
|
@@ -9378,6 +9502,7 @@ var init_orama_store = __esm({
|
|
|
9378
9502
|
init_mini_skills();
|
|
9379
9503
|
init_visibility();
|
|
9380
9504
|
init_provider();
|
|
9505
|
+
init_provider();
|
|
9381
9506
|
init_project_affinity();
|
|
9382
9507
|
init_intent_detector();
|
|
9383
9508
|
init_query_expansion();
|
|
@@ -9385,6 +9510,7 @@ var init_orama_store = __esm({
|
|
|
9385
9510
|
init_timeout();
|
|
9386
9511
|
init_obs_store();
|
|
9387
9512
|
init_semantic_index();
|
|
9513
|
+
init_derived_view_receipt();
|
|
9388
9514
|
db = null;
|
|
9389
9515
|
dbInitPromise = null;
|
|
9390
9516
|
dbGeneration = 0;
|
|
@@ -144081,7 +144207,7 @@ __export(video_jobs_exports, {
|
|
|
144081
144207
|
runMiniMaxVideoGenerationJob: () => runMiniMaxVideoGenerationJob
|
|
144082
144208
|
});
|
|
144083
144209
|
import { spawn } from "child_process";
|
|
144084
|
-
import { existsSync as
|
|
144210
|
+
import { existsSync as existsSync9 } from "fs";
|
|
144085
144211
|
import path15 from "path";
|
|
144086
144212
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
144087
144213
|
function safeError2(error) {
|
|
@@ -144329,7 +144455,7 @@ function resolveMediaVideoRunnerPath(moduleUrl = import.meta.url) {
|
|
|
144329
144455
|
}
|
|
144330
144456
|
function launchMediaVideoRunner(request, options = {}) {
|
|
144331
144457
|
const runnerPath = options.runnerPath ?? resolveMediaVideoRunnerPath();
|
|
144332
|
-
if (!
|
|
144458
|
+
if (!existsSync9(runnerPath)) {
|
|
144333
144459
|
return { launched: false, reason: "Media video runner is unavailable until Memorix is built or reinstalled." };
|
|
144334
144460
|
}
|
|
144335
144461
|
try {
|
|
@@ -146740,6 +146866,7 @@ var init_store = __esm({
|
|
|
146740
146866
|
recordCodeStateSnapshot(input) {
|
|
146741
146867
|
const id = randomUUID11();
|
|
146742
146868
|
let snapshot;
|
|
146869
|
+
let compactNeeded = false;
|
|
146743
146870
|
const tx = this.db.transaction(() => {
|
|
146744
146871
|
const previous = this.db.prepare(
|
|
146745
146872
|
"SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1"
|
|
@@ -146783,6 +146910,26 @@ var init_store = __esm({
|
|
|
146783
146910
|
for (const file of snapshotFileRows) {
|
|
146784
146911
|
insertSnapshotFile.run(id, file.projectId, file.id, file.path, file.contentHash);
|
|
146785
146912
|
}
|
|
146913
|
+
const staleSymbolIds = this.db.prepare(
|
|
146914
|
+
"SELECT id FROM code_symbols WHERE projectId = ? AND stale = 1"
|
|
146915
|
+
).all(input.projectId).map((row) => row.id);
|
|
146916
|
+
if (staleSymbolIds.length > 0) {
|
|
146917
|
+
const placeholders = staleSymbolIds.map(() => "?").join(", ");
|
|
146918
|
+
this.db.prepare(
|
|
146919
|
+
`DELETE FROM code_edges WHERE projectId = ? AND (fromSymbolId IN (${placeholders}) OR toSymbolId IN (${placeholders}))`
|
|
146920
|
+
).run(input.projectId, ...staleSymbolIds, ...staleSymbolIds);
|
|
146921
|
+
this.db.prepare("DELETE FROM code_symbols WHERE projectId = ? AND stale = 1").run(input.projectId);
|
|
146922
|
+
compactNeeded = true;
|
|
146923
|
+
}
|
|
146924
|
+
const oldSnapshots = this.db.prepare(
|
|
146925
|
+
"SELECT id FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT -1 OFFSET 2"
|
|
146926
|
+
).all(input.projectId).map((row) => row.id);
|
|
146927
|
+
if (oldSnapshots.length > 0) {
|
|
146928
|
+
const placeholders = oldSnapshots.map(() => "?").join(", ");
|
|
146929
|
+
this.db.prepare(`DELETE FROM code_state_snapshot_files WHERE snapshotId IN (${placeholders})`).run(...oldSnapshots);
|
|
146930
|
+
this.db.prepare(`DELETE FROM code_state_snapshots WHERE id IN (${placeholders})`).run(...oldSnapshots);
|
|
146931
|
+
compactNeeded = true;
|
|
146932
|
+
}
|
|
146786
146933
|
snapshot = {
|
|
146787
146934
|
...input,
|
|
146788
146935
|
id,
|
|
@@ -146791,11 +146938,24 @@ var init_store = __esm({
|
|
|
146791
146938
|
};
|
|
146792
146939
|
});
|
|
146793
146940
|
tx();
|
|
146941
|
+
if (compactNeeded) this.compactStorage();
|
|
146794
146942
|
return snapshot;
|
|
146795
146943
|
}
|
|
146944
|
+
/** Reclaim WAL/free pages after a derived codegraph sweep. */
|
|
146945
|
+
compactStorage() {
|
|
146946
|
+
try {
|
|
146947
|
+
this.db.pragma("wal_checkpoint(TRUNCATE)");
|
|
146948
|
+
} catch {
|
|
146949
|
+
}
|
|
146950
|
+
try {
|
|
146951
|
+
this.db.exec("VACUUM");
|
|
146952
|
+
} catch {
|
|
146953
|
+
}
|
|
146954
|
+
}
|
|
146796
146955
|
status(projectId) {
|
|
146797
146956
|
const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
|
|
146798
146957
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
146958
|
+
const staleSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 1`).get(projectId).count;
|
|
146799
146959
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
146800
146960
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
146801
146961
|
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
@@ -146803,6 +146963,8 @@ var init_store = __esm({
|
|
|
146803
146963
|
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
146804
146964
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
146805
146965
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
146966
|
+
const snapshots = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshots WHERE projectId = ?`).get(projectId).count;
|
|
146967
|
+
const snapshotFiles = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshot_files WHERE projectId = ?`).get(projectId).count;
|
|
146806
146968
|
return {
|
|
146807
146969
|
provider: "lite",
|
|
146808
146970
|
files,
|
|
@@ -146812,6 +146974,9 @@ var init_store = __esm({
|
|
|
146812
146974
|
semanticSymbols,
|
|
146813
146975
|
semanticEdges,
|
|
146814
146976
|
parserErrors,
|
|
146977
|
+
staleSymbols,
|
|
146978
|
+
snapshots,
|
|
146979
|
+
snapshotFiles,
|
|
146815
146980
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
146816
146981
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
146817
146982
|
};
|
|
@@ -147296,7 +147461,7 @@ __export(lite_provider_exports, {
|
|
|
147296
147461
|
refreshProjectLite: () => refreshProjectLite
|
|
147297
147462
|
});
|
|
147298
147463
|
import { createHash as createHash11 } from "crypto";
|
|
147299
|
-
import { existsSync as
|
|
147464
|
+
import { existsSync as existsSync11, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
147300
147465
|
import { join as join4, relative as relative2 } from "path";
|
|
147301
147466
|
function hashText2(text2) {
|
|
147302
147467
|
return createHash11("sha256").update(text2).digest("hex");
|
|
@@ -147314,7 +147479,7 @@ function resolveMaxFileBytes(value) {
|
|
|
147314
147479
|
return Math.max(1, Math.floor(value));
|
|
147315
147480
|
}
|
|
147316
147481
|
function isPythonVirtualenvDir(dir) {
|
|
147317
|
-
return
|
|
147482
|
+
return existsSync11(join4(dir, "pyvenv.cfg"));
|
|
147318
147483
|
}
|
|
147319
147484
|
function walk(root, exclude, maxFiles) {
|
|
147320
147485
|
const out = [];
|
|
@@ -150853,7 +151018,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
150853
151018
|
import { spawn as spawn2 } from "child_process";
|
|
150854
151019
|
import {
|
|
150855
151020
|
closeSync,
|
|
150856
|
-
existsSync as
|
|
151021
|
+
existsSync as existsSync12,
|
|
150857
151022
|
mkdirSync as mkdirSync2,
|
|
150858
151023
|
openSync,
|
|
150859
151024
|
readFileSync as readFileSync9,
|
|
@@ -150981,7 +151146,7 @@ function releaseVectorBackfillLock(lockPath = process.env.MEMORIX_VECTOR_BACKFIL
|
|
|
150981
151146
|
}
|
|
150982
151147
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
150983
151148
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
150984
|
-
const exists = options.exists ??
|
|
151149
|
+
const exists = options.exists ?? existsSync12;
|
|
150985
151150
|
if (!exists(runnerPath)) return false;
|
|
150986
151151
|
const lock = acquireVectorBackfillLock(request.dataDir, request.projectId, options.lockPath);
|
|
150987
151152
|
if (!lock) return false;
|
|
@@ -151137,10 +151302,22 @@ function resetObservationRuntime() {
|
|
|
151137
151302
|
loadedObservationStore = null;
|
|
151138
151303
|
embeddingWriteMode = "background";
|
|
151139
151304
|
embeddingWorkerProjectRoot = void 0;
|
|
151140
|
-
|
|
151305
|
+
clearVectorMissingIds();
|
|
151141
151306
|
vectorSchemaUpgradePromise = null;
|
|
151142
151307
|
embeddingFailureLogTimestamps.clear();
|
|
151143
151308
|
}
|
|
151309
|
+
function markVectorMissing(observationId2, projectId) {
|
|
151310
|
+
vectorMissingIds.add(observationId2);
|
|
151311
|
+
vectorMissingProjectIds.set(observationId2, projectId);
|
|
151312
|
+
}
|
|
151313
|
+
function clearVectorMissing(observationId2) {
|
|
151314
|
+
vectorMissingIds.delete(observationId2);
|
|
151315
|
+
vectorMissingProjectIds.delete(observationId2);
|
|
151316
|
+
}
|
|
151317
|
+
function clearVectorMissingIds() {
|
|
151318
|
+
vectorMissingIds.clear();
|
|
151319
|
+
vectorMissingProjectIds.clear();
|
|
151320
|
+
}
|
|
151144
151321
|
function logEmbeddingFailureOnce(key, message) {
|
|
151145
151322
|
const now3 = Date.now();
|
|
151146
151323
|
const last = embeddingFailureLogTimestamps.get(key) ?? 0;
|
|
@@ -151260,10 +151437,13 @@ function isVectorCompatibleWithCurrentIndex(embedding) {
|
|
|
151260
151437
|
}
|
|
151261
151438
|
async function upgradeVectorSchemaAfterFirstEmbedding(embedding) {
|
|
151262
151439
|
if (isVectorCompatibleWithCurrentIndex(embedding)) return true;
|
|
151263
|
-
if (
|
|
151440
|
+
if (!embedding.every(Number.isFinite)) return false;
|
|
151264
151441
|
const targetProjectDir = projectDir;
|
|
151265
151442
|
if (!vectorSchemaUpgradePromise) {
|
|
151266
|
-
vectorSchemaUpgradePromise =
|
|
151443
|
+
vectorSchemaUpgradePromise = getDb().then(async () => {
|
|
151444
|
+
if (getVectorDimensions() === null && observations.length > 0) await reindexObservations();
|
|
151445
|
+
return projectDir === targetProjectDir && isVectorCompatibleWithCurrentIndex(embedding);
|
|
151446
|
+
}).catch(() => false).finally(() => {
|
|
151267
151447
|
vectorSchemaUpgradePromise = null;
|
|
151268
151448
|
});
|
|
151269
151449
|
}
|
|
@@ -151303,9 +151483,9 @@ async function initObservations(dir, options = {}) {
|
|
|
151303
151483
|
}
|
|
151304
151484
|
function scheduleObservationEmbedding(input) {
|
|
151305
151485
|
const { observationId: observationId2, projectId, searchableText, doc } = input;
|
|
151306
|
-
|
|
151486
|
+
markVectorMissing(observationId2, projectId);
|
|
151307
151487
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
151308
|
-
|
|
151488
|
+
clearVectorMissing(observationId2);
|
|
151309
151489
|
return;
|
|
151310
151490
|
}
|
|
151311
151491
|
if (embeddingWriteMode === "deferred") {
|
|
@@ -151340,13 +151520,13 @@ function scheduleObservationEmbedding(input) {
|
|
|
151340
151520
|
vector: embedding
|
|
151341
151521
|
});
|
|
151342
151522
|
}
|
|
151343
|
-
|
|
151523
|
+
clearVectorMissing(observationId2);
|
|
151344
151524
|
} catch {
|
|
151345
151525
|
console.error(`[memorix] Embedding index update failed for obs-${observationId2} (kept in backfill queue)`);
|
|
151346
151526
|
queueVectorBackfill(projectId);
|
|
151347
151527
|
}
|
|
151348
151528
|
} else if (isEmbeddingExplicitlyDisabled()) {
|
|
151349
|
-
|
|
151529
|
+
clearVectorMissing(observationId2);
|
|
151350
151530
|
} else {
|
|
151351
151531
|
queueVectorBackfill(projectId);
|
|
151352
151532
|
logEmbeddingFailureOnce(
|
|
@@ -151906,7 +152086,7 @@ async function reindexObservations() {
|
|
|
151906
152086
|
if (observations.length === 0) return 0;
|
|
151907
152087
|
await resetDb();
|
|
151908
152088
|
searchIndexPrepared = false;
|
|
151909
|
-
|
|
152089
|
+
clearVectorMissingIds();
|
|
151910
152090
|
let embeddings = observations.map(() => null);
|
|
151911
152091
|
const provider2 = await getEmbeddingProvider();
|
|
151912
152092
|
const canBatchEmbedAtStartup = provider2 !== null && !provider2.name.startsWith("api-");
|
|
@@ -151971,7 +152151,7 @@ async function reindexObservations() {
|
|
|
151971
152151
|
};
|
|
151972
152152
|
await insertObservation(doc);
|
|
151973
152153
|
if (!compatibleEmbedding && !isEmbeddingExplicitlyDisabled()) {
|
|
151974
|
-
|
|
152154
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
151975
152155
|
}
|
|
151976
152156
|
count2++;
|
|
151977
152157
|
} catch (err) {
|
|
@@ -151988,7 +152168,17 @@ async function prepareSearchIndex(options = {}) {
|
|
|
151988
152168
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
151989
152169
|
const store = getObservationStore();
|
|
151990
152170
|
const projects = await store.listProjectIds?.() ?? [];
|
|
151991
|
-
|
|
152171
|
+
await getDb({ allowNetworkProbe: false }).catch(() => void 0);
|
|
152172
|
+
const persistedIds = projectDir ? await getPersistentSemanticVectorIds(projectDir).catch(() => null) : null;
|
|
152173
|
+
for (const projectId of projects) {
|
|
152174
|
+
const projectObservations = await store.loadByProject(projectId);
|
|
152175
|
+
for (const observation of projectObservations) {
|
|
152176
|
+
if (!persistedIds?.has(observation.id)) markVectorMissing(observation.id, observation.projectId);
|
|
152177
|
+
}
|
|
152178
|
+
if (projectObservations.some((observation) => !persistedIds?.has(observation.id))) {
|
|
152179
|
+
queueVectorBackfill(projectId);
|
|
152180
|
+
}
|
|
152181
|
+
}
|
|
151992
152182
|
}
|
|
151993
152183
|
return 0;
|
|
151994
152184
|
}
|
|
@@ -152000,14 +152190,15 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152000
152190
|
return 0;
|
|
152001
152191
|
}
|
|
152002
152192
|
const hydratedProjectDir = projectDir;
|
|
152003
|
-
const queueMissingVectors = () => {
|
|
152004
|
-
if (projectDir !== hydratedProjectDir) return;
|
|
152005
|
-
|
|
152193
|
+
const queueMissingVectors = async () => {
|
|
152194
|
+
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
152195
|
+
clearVectorMissingIds();
|
|
152006
152196
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
152197
|
+
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
152007
152198
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
152008
152199
|
for (const obs of observations) {
|
|
152009
|
-
if (!hasObservationVector(obs.projectId, obs.id)) {
|
|
152010
|
-
|
|
152200
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
152201
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
152011
152202
|
projectsWithMissingVectors.add(obs.projectId);
|
|
152012
152203
|
}
|
|
152013
152204
|
}
|
|
@@ -152016,15 +152207,18 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152016
152207
|
};
|
|
152017
152208
|
const cacheHydration = getDeferredCachedVectorHydration();
|
|
152018
152209
|
if (cacheHydration) {
|
|
152019
|
-
void cacheHydration.
|
|
152210
|
+
void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => void 0);
|
|
152020
152211
|
} else {
|
|
152021
|
-
queueMissingVectors();
|
|
152212
|
+
await queueMissingVectors();
|
|
152022
152213
|
}
|
|
152023
152214
|
searchIndexPrepared = true;
|
|
152024
152215
|
return count2;
|
|
152025
152216
|
}
|
|
152026
152217
|
function getVectorMissingIds(projectId) {
|
|
152027
152218
|
if (!projectId) return [...vectorMissingIds];
|
|
152219
|
+
if (!corpusLoaded) {
|
|
152220
|
+
return [...vectorMissingIds].filter((id) => vectorMissingProjectIds.get(id) === projectId);
|
|
152221
|
+
}
|
|
152028
152222
|
const observationById = new Map(observations.map((observation) => [observation.id, observation]));
|
|
152029
152223
|
return [...vectorMissingIds].filter((id) => observationById.get(id)?.projectId === projectId);
|
|
152030
152224
|
}
|
|
@@ -152062,7 +152256,8 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152062
152256
|
return { attempted: 0, succeeded: 0, failed: 0 };
|
|
152063
152257
|
}
|
|
152064
152258
|
vectorBackfillRunning = true;
|
|
152065
|
-
const
|
|
152259
|
+
const sourceObservations = corpusLoaded ? observations : options.projectId ? await getObservationStore().loadByProject(options.projectId, { status: "active" }) : await getObservationStore().loadAll();
|
|
152260
|
+
const observationById = new Map(sourceObservations.map((observation) => [observation.id, observation]));
|
|
152066
152261
|
const limit2 = Number.isFinite(options.limit) ? Math.max(1, Math.floor(options.limit)) : Number.POSITIVE_INFINITY;
|
|
152067
152262
|
const ids = [...vectorMissingIds].filter((id) => !options.projectId || observationById.get(id)?.projectId === options.projectId).slice(0, limit2);
|
|
152068
152263
|
let succeeded = 0;
|
|
@@ -152075,7 +152270,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152075
152270
|
for (const id of ids) {
|
|
152076
152271
|
const observation = observationById.get(id);
|
|
152077
152272
|
if (!observation) {
|
|
152078
|
-
|
|
152273
|
+
clearVectorMissing(id);
|
|
152079
152274
|
continue;
|
|
152080
152275
|
}
|
|
152081
152276
|
candidates.push({
|
|
@@ -152093,7 +152288,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152093
152288
|
const provider2 = await getEmbeddingProvider();
|
|
152094
152289
|
if (!provider2) {
|
|
152095
152290
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
152096
|
-
for (const candidate of candidates)
|
|
152291
|
+
for (const candidate of candidates) clearVectorMissing(candidate.id);
|
|
152097
152292
|
} else {
|
|
152098
152293
|
recordFailure("embedding provider unavailable");
|
|
152099
152294
|
failed += candidates.length;
|
|
@@ -152170,7 +152365,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152170
152365
|
vector: embedding
|
|
152171
152366
|
});
|
|
152172
152367
|
}
|
|
152173
|
-
|
|
152368
|
+
clearVectorMissing(id);
|
|
152174
152369
|
succeeded++;
|
|
152175
152370
|
} catch (error) {
|
|
152176
152371
|
recordFailure(vectorBackfillError(error));
|
|
@@ -152195,7 +152390,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152195
152390
|
...lastFailure ? { lastError: lastFailure } : {}
|
|
152196
152391
|
};
|
|
152197
152392
|
}
|
|
152198
|
-
var observations, nextId, projectDir, searchIndexPrepared, embeddingWriteMode, embeddingWorkerProjectRoot, corpusLoaded, largeCorpusLazyMode, loadedObservationStore, DEFAULT_ORAMA_HYDRATION_THRESHOLD, vectorMissingIds, vectorBackfillRunning, vectorSchemaUpgradePromise, lastVectorBackfill, embeddingFailureLogTimestamps, EMBEDDING_FAILURE_LOG_COOLDOWN_MS, MAX_EMBEDDING_FAILURE_KEYS;
|
|
152393
|
+
var observations, nextId, projectDir, searchIndexPrepared, embeddingWriteMode, embeddingWorkerProjectRoot, corpusLoaded, largeCorpusLazyMode, loadedObservationStore, DEFAULT_ORAMA_HYDRATION_THRESHOLD, vectorMissingIds, vectorMissingProjectIds, vectorBackfillRunning, vectorSchemaUpgradePromise, lastVectorBackfill, embeddingFailureLogTimestamps, EMBEDDING_FAILURE_LOG_COOLDOWN_MS, MAX_EMBEDDING_FAILURE_KEYS;
|
|
152199
152394
|
var init_observations = __esm({
|
|
152200
152395
|
"src/memory/observations.ts"() {
|
|
152201
152396
|
"use strict";
|
|
@@ -152220,6 +152415,7 @@ var init_observations = __esm({
|
|
|
152220
152415
|
loadedObservationStore = null;
|
|
152221
152416
|
DEFAULT_ORAMA_HYDRATION_THRESHOLD = 1e4;
|
|
152222
152417
|
vectorMissingIds = /* @__PURE__ */ new Set();
|
|
152418
|
+
vectorMissingProjectIds = /* @__PURE__ */ new Map();
|
|
152223
152419
|
vectorBackfillRunning = false;
|
|
152224
152420
|
vectorSchemaUpgradePromise = null;
|
|
152225
152421
|
lastVectorBackfill = null;
|
|
@@ -152286,7 +152482,7 @@ __export(audio_jobs_exports, {
|
|
|
152286
152482
|
transcribeAudio: () => transcribeAudio
|
|
152287
152483
|
});
|
|
152288
152484
|
import { spawn as spawn3 } from "child_process";
|
|
152289
|
-
import { existsSync as
|
|
152485
|
+
import { existsSync as existsSync13 } from "fs";
|
|
152290
152486
|
import path21 from "path";
|
|
152291
152487
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
152292
152488
|
function safeError3(error) {
|
|
@@ -152537,7 +152733,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
|
|
|
152537
152733
|
}
|
|
152538
152734
|
function launchMediaAudioRunner(request, options = {}) {
|
|
152539
152735
|
const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
|
|
152540
|
-
if (!
|
|
152736
|
+
if (!existsSync13(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
|
|
152541
152737
|
try {
|
|
152542
152738
|
const child = spawn3(process.execPath, [runnerPath, JSON.stringify(request)], {
|
|
152543
152739
|
cwd: request.projectRoot,
|