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.
- package/CHANGELOG.md +25 -0
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/cli/index.js +575 -196
- package/dist/index.js +375 -134
- package/dist/maintenance-runner.js +210 -46
- package/dist/media-audio-runner.js +182 -18
- package/dist/media-video-runner.js +209 -45
- package/dist/memcode-runtime/CHANGELOG.md +25 -0
- package/dist/sdk.js +426 -134
- package/dist/vector-backfill-runner.js +209 -45
- package/docs/1.2.0-EVALUATION-HARNESS.md +18 -0
- package/docs/CONFIGURATION.md +25 -0
- package/docs/DEVELOPMENT.md +3 -3
- package/docs/PERFORMANCE.md +23 -0
- package/docs/README.md +2 -2
- package/docs/ROADMAP-1.9.12-2.0.md +13 -6
- 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/init.ts +6 -2
- package/src/cli/commands/repair.ts +17 -3
- package/src/cli/tui/ConfigureView.tsx +2 -0
- package/src/codegraph/auto-context.ts +17 -0
- package/src/codegraph/context-pack.ts +15 -0
- package/src/compact/engine.ts +11 -0
- package/src/compact/index-format.ts +1 -1
- package/src/config/dotenv-loader.ts +1 -0
- package/src/config/resolved-config.ts +5 -2
- package/src/config/yaml-loader.ts +2 -2
- package/src/dashboard/server.ts +3 -0
- package/src/knowledge/context-assembly.ts +13 -0
- package/src/knowledge/context-receipt.ts +35 -0
- package/src/knowledge/workset.ts +8 -0
- package/src/llm/provider.ts +2 -1
- package/src/memory/observations.ts +7 -5
- package/src/multimodal/image-loader.ts +2 -2
- package/src/search/derived-view-receipt.ts +62 -0
- package/src/search/semantic-index.ts +149 -1
- package/src/server.ts +18 -3
- package/src/store/orama-store.ts +80 -2
|
@@ -2407,7 +2407,8 @@ function getResolvedConfig(options = {}) {
|
|
|
2407
2407
|
const isAtlasCloud = memoryLlmProvider === "atlascloud";
|
|
2408
2408
|
const isRequesty = memoryLlmProvider === "requesty";
|
|
2409
2409
|
const isApiRoute = memoryLlmProvider === "apiroute";
|
|
2410
|
-
const
|
|
2410
|
+
const isCheaperInference = memoryLlmProvider === "cheaperinference";
|
|
2411
|
+
const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference;
|
|
2411
2412
|
const memoryLlmApiKey = first(
|
|
2412
2413
|
process.env.MEMORIX_LLM_API_KEY,
|
|
2413
2414
|
process.env.MEMORIX_API_KEY,
|
|
@@ -2415,7 +2416,7 @@ function getResolvedConfig(options = {}) {
|
|
|
2415
2416
|
yaml.llm?.apiKey,
|
|
2416
2417
|
legacy.llm?.apiKey,
|
|
2417
2418
|
// Never borrow another provider's credentials for these gateway presets.
|
|
2418
|
-
isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : process.env.OPENAI_API_KEY,
|
|
2419
|
+
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,
|
|
2419
2420
|
usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
|
|
2420
2421
|
usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
|
|
2421
2422
|
);
|
|
@@ -2599,6 +2600,7 @@ function getEnvSourceNames() {
|
|
|
2599
2600
|
"OPENROUTER_API_KEY",
|
|
2600
2601
|
"REQUESTY_API_KEY",
|
|
2601
2602
|
"API_ROUTE_API_KEY",
|
|
2603
|
+
"CHEAPER_INFERENCE_API_KEY",
|
|
2602
2604
|
"ATLASCLOUD_API_KEY"
|
|
2603
2605
|
].filter((name) => process.env[name]);
|
|
2604
2606
|
}
|
|
@@ -5593,6 +5595,7 @@ var init_provider2 = __esm({
|
|
|
5593
5595
|
openrouter: { baseUrl: "https://openrouter.ai/api/v1", model: "openai/gpt-4.1-nano" },
|
|
5594
5596
|
requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
|
|
5595
5597
|
apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
|
|
5598
|
+
cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
|
|
5596
5599
|
atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
|
|
5597
5600
|
custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
|
|
5598
5601
|
};
|
|
@@ -6371,6 +6374,7 @@ var init_obs_store = __esm({
|
|
|
6371
6374
|
|
|
6372
6375
|
// src/search/semantic-index.ts
|
|
6373
6376
|
import { createHash as createHash4 } from "crypto";
|
|
6377
|
+
import { existsSync as existsSync8 } from "fs";
|
|
6374
6378
|
import { createRequire as createRequire3 } from "module";
|
|
6375
6379
|
import path8 from "path";
|
|
6376
6380
|
function createSemanticIndexProfile(provider2) {
|
|
@@ -6469,17 +6473,80 @@ function queueOperation(key, operation) {
|
|
|
6469
6473
|
writeQueues.set(key, run.catch(() => void 0));
|
|
6470
6474
|
return run;
|
|
6471
6475
|
}
|
|
6476
|
+
function positiveEnvInt(name, fallback) {
|
|
6477
|
+
const value = Number.parseInt(process.env[name] ?? "", 10);
|
|
6478
|
+
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
6479
|
+
}
|
|
6480
|
+
function semanticWriteBatchSize() {
|
|
6481
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_BATCH_SIZE", DEFAULT_WRITE_BATCH_SIZE);
|
|
6482
|
+
}
|
|
6483
|
+
function semanticWriteFlushMs() {
|
|
6484
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_FLUSH_MS", DEFAULT_WRITE_FLUSH_MS);
|
|
6485
|
+
}
|
|
6486
|
+
function semanticOptimizeEvery() {
|
|
6487
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_OPTIMIZE_EVERY", DEFAULT_OPTIMIZE_EVERY);
|
|
6488
|
+
}
|
|
6489
|
+
function semanticVersionRetentionMs() {
|
|
6490
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_VERSION_RETENTION_MS", DEFAULT_VERSION_RETENTION_MS);
|
|
6491
|
+
}
|
|
6492
|
+
async function optimizeState(state) {
|
|
6493
|
+
if (!state.table || typeof state.table.optimize !== "function") return;
|
|
6494
|
+
await state.table.optimize({
|
|
6495
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
6496
|
+
deleteUnverified: false
|
|
6497
|
+
});
|
|
6498
|
+
}
|
|
6472
6499
|
async function mergeVectors(dataDir, profile, records) {
|
|
6473
6500
|
if (records.length === 0) return;
|
|
6474
6501
|
const state = await getState(dataDir, profile, records);
|
|
6475
6502
|
if (!state?.table) return;
|
|
6476
6503
|
const rows = records.map(toLanceRow);
|
|
6477
6504
|
await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
6505
|
+
const key = stateKey(dataDir, profile);
|
|
6506
|
+
const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
|
|
6507
|
+
if (mutationCount >= semanticOptimizeEvery()) {
|
|
6508
|
+
mutationCounts.set(key, 0);
|
|
6509
|
+
await optimizeState(state).catch(() => void 0);
|
|
6510
|
+
} else {
|
|
6511
|
+
mutationCounts.set(key, mutationCount);
|
|
6512
|
+
}
|
|
6478
6513
|
void ensureSemanticIndex(dataDir, profile);
|
|
6479
6514
|
}
|
|
6515
|
+
function flushPendingVectorBatch(key) {
|
|
6516
|
+
const pending = pendingVectorBatches.get(key);
|
|
6517
|
+
if (!pending) return Promise.resolve();
|
|
6518
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
6519
|
+
pendingVectorBatches.delete(key);
|
|
6520
|
+
const records = [...pending.records.values()];
|
|
6521
|
+
const waiters = pending.waiters.splice(0);
|
|
6522
|
+
return queueOperation(key, () => mergeVectors(pending.dataDir, pending.profile, records)).then(() => waiters.forEach((waiter) => waiter.resolve())).catch((error) => {
|
|
6523
|
+
waiters.forEach((waiter) => waiter.reject(error));
|
|
6524
|
+
});
|
|
6525
|
+
}
|
|
6526
|
+
function upsertSemanticVector(dataDir, profile, record80) {
|
|
6527
|
+
const key = stateKey(dataDir, profile);
|
|
6528
|
+
let pending = pendingVectorBatches.get(key);
|
|
6529
|
+
if (!pending) {
|
|
6530
|
+
pending = { dataDir, profile, records: /* @__PURE__ */ new Map(), waiters: [] };
|
|
6531
|
+
pendingVectorBatches.set(key, pending);
|
|
6532
|
+
}
|
|
6533
|
+
pending.records.set(`${record80.projectId}:${record80.observationId}`, record80);
|
|
6534
|
+
const promise = new Promise((resolve2, reject) => pending.waiters.push({ resolve: resolve2, reject }));
|
|
6535
|
+
if (pending.records.size >= semanticWriteBatchSize()) void flushPendingVectorBatch(key);
|
|
6536
|
+
else if (!pending.timer) pending.timer = setTimeout(() => {
|
|
6537
|
+
void flushPendingVectorBatch(key);
|
|
6538
|
+
}, semanticWriteFlushMs());
|
|
6539
|
+
return promise;
|
|
6540
|
+
}
|
|
6480
6541
|
function upsertSemanticVectors(dataDir, profile, records) {
|
|
6481
6542
|
return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
|
|
6482
6543
|
}
|
|
6544
|
+
async function listSemanticVectorIds(dataDir, profile) {
|
|
6545
|
+
const state = await getState(dataDir, profile);
|
|
6546
|
+
if (!state?.table) return null;
|
|
6547
|
+
const rows = await state.table.query().select(["observation_id"]).toArray();
|
|
6548
|
+
return new Set(rows.map((row) => Number(row.observation_id)).filter(Number.isSafeInteger));
|
|
6549
|
+
}
|
|
6483
6550
|
function resolveIndexThreshold() {
|
|
6484
6551
|
const raw = Number.parseInt(process.env.MEMORIX_SEMANTIC_INDEX_THRESHOLD ?? "", 10);
|
|
6485
6552
|
return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_INDEX_THRESHOLD;
|
|
@@ -6531,7 +6598,7 @@ async function searchSemanticVectors(options) {
|
|
|
6531
6598
|
distance: Number(row._distance ?? Number.POSITIVE_INFINITY)
|
|
6532
6599
|
})).filter((row) => Number.isFinite(row.distance));
|
|
6533
6600
|
}
|
|
6534
|
-
var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, statePromises, writeQueues, indexBuilds, availability, requireFromHere2;
|
|
6601
|
+
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;
|
|
6535
6602
|
var init_semantic_index = __esm({
|
|
6536
6603
|
"src/search/semantic-index.ts"() {
|
|
6537
6604
|
"use strict";
|
|
@@ -6540,13 +6607,81 @@ var init_semantic_index = __esm({
|
|
|
6540
6607
|
TABLE_PREFIX = "observations_";
|
|
6541
6608
|
DEFAULT_INDEX_THRESHOLD = 1e4;
|
|
6542
6609
|
MAX_INDEX_PARTITIONS = 32;
|
|
6610
|
+
DEFAULT_WRITE_BATCH_SIZE = 100;
|
|
6611
|
+
DEFAULT_WRITE_FLUSH_MS = 50;
|
|
6612
|
+
DEFAULT_OPTIMIZE_EVERY = 20;
|
|
6613
|
+
DEFAULT_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
6543
6614
|
statePromises = /* @__PURE__ */ new Map();
|
|
6544
6615
|
writeQueues = /* @__PURE__ */ new Map();
|
|
6545
6616
|
indexBuilds = /* @__PURE__ */ new Map();
|
|
6617
|
+
mutationCounts = /* @__PURE__ */ new Map();
|
|
6618
|
+
pendingVectorBatches = /* @__PURE__ */ new Map();
|
|
6546
6619
|
requireFromHere2 = createRequire3(import.meta.url);
|
|
6547
6620
|
}
|
|
6548
6621
|
});
|
|
6549
6622
|
|
|
6623
|
+
// src/memory/secret-filter.ts
|
|
6624
|
+
function applyRedaction(text2) {
|
|
6625
|
+
if (!text2) return text2;
|
|
6626
|
+
let out = text2;
|
|
6627
|
+
out = out.replace(
|
|
6628
|
+
/((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
|
|
6629
|
+
"$1[REDACTED]"
|
|
6630
|
+
);
|
|
6631
|
+
out = out.replace(
|
|
6632
|
+
/(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
|
|
6633
|
+
"$1[REDACTED]"
|
|
6634
|
+
);
|
|
6635
|
+
out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
|
|
6636
|
+
out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
|
|
6637
|
+
out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
|
|
6638
|
+
return out;
|
|
6639
|
+
}
|
|
6640
|
+
function sanitizeCredentials(text2) {
|
|
6641
|
+
return applyRedaction(text2);
|
|
6642
|
+
}
|
|
6643
|
+
var init_secret_filter = __esm({
|
|
6644
|
+
"src/memory/secret-filter.ts"() {
|
|
6645
|
+
"use strict";
|
|
6646
|
+
init_esm_shims();
|
|
6647
|
+
}
|
|
6648
|
+
});
|
|
6649
|
+
|
|
6650
|
+
// src/search/derived-view-receipt.ts
|
|
6651
|
+
function sanitizeDerivedViewFailureReason(reason) {
|
|
6652
|
+
const safe = sanitizeCredentials(reason).replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, "[path]").replace(/\s+/g, " ").trim();
|
|
6653
|
+
return safe.slice(0, 240) || "derived view failed";
|
|
6654
|
+
}
|
|
6655
|
+
function embeddingHealthReceipt(health, embeddingEnabled2) {
|
|
6656
|
+
if (health?.status === "disabled") {
|
|
6657
|
+
return { freshness: "current", rebuildStatus: "disabled" };
|
|
6658
|
+
}
|
|
6659
|
+
if (health?.status === "ready" || embeddingEnabled2) {
|
|
6660
|
+
return { freshness: "current", rebuildStatus: "idle" };
|
|
6661
|
+
}
|
|
6662
|
+
if (health?.status === "degraded") {
|
|
6663
|
+
return {
|
|
6664
|
+
freshness: "stale",
|
|
6665
|
+
rebuildStatus: "failed",
|
|
6666
|
+
...health.failure ? {
|
|
6667
|
+
failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`
|
|
6668
|
+
} : { failureReason: "embedding provider degraded" }
|
|
6669
|
+
};
|
|
6670
|
+
}
|
|
6671
|
+
return {
|
|
6672
|
+
freshness: "unknown",
|
|
6673
|
+
rebuildStatus: "unavailable",
|
|
6674
|
+
failureReason: "embedding provider is not initialized"
|
|
6675
|
+
};
|
|
6676
|
+
}
|
|
6677
|
+
var init_derived_view_receipt = __esm({
|
|
6678
|
+
"src/search/derived-view-receipt.ts"() {
|
|
6679
|
+
"use strict";
|
|
6680
|
+
init_esm_shims();
|
|
6681
|
+
init_secret_filter();
|
|
6682
|
+
}
|
|
6683
|
+
});
|
|
6684
|
+
|
|
6550
6685
|
// src/project/aliases.ts
|
|
6551
6686
|
var aliases_exports = {};
|
|
6552
6687
|
__export(aliases_exports, {
|
|
@@ -7155,6 +7290,8 @@ __export(orama_store_exports, {
|
|
|
7155
7290
|
getLastSearchMode: () => getLastSearchMode,
|
|
7156
7291
|
getObservationCount: () => getObservationCount,
|
|
7157
7292
|
getObservationsByIds: () => getObservationsByIds,
|
|
7293
|
+
getPersistentSemanticVectorIds: () => getPersistentSemanticVectorIds,
|
|
7294
|
+
getSearchDerivedViews: () => getSearchDerivedViews,
|
|
7158
7295
|
getTimeline: () => getTimeline,
|
|
7159
7296
|
getVectorDimensions: () => getVectorDimensions,
|
|
7160
7297
|
hasObservationVector: () => hasObservationVector,
|
|
@@ -7185,6 +7322,52 @@ function getLastSearchDiagnostics(projectId) {
|
|
|
7185
7322
|
const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
|
|
7186
7323
|
return diagnostics ? { ...diagnostics } : void 0;
|
|
7187
7324
|
}
|
|
7325
|
+
function getSearchDerivedViews() {
|
|
7326
|
+
const views = {};
|
|
7327
|
+
const store = getOptionalObservationStore();
|
|
7328
|
+
if (store) {
|
|
7329
|
+
try {
|
|
7330
|
+
const generation = store.getGeneration();
|
|
7331
|
+
if (store.hasLexicalIndex?.()) {
|
|
7332
|
+
views.fts = { generation, freshness: "current", rebuildStatus: "idle" };
|
|
7333
|
+
} else {
|
|
7334
|
+
views.fts = {
|
|
7335
|
+
generation,
|
|
7336
|
+
freshness: "unknown",
|
|
7337
|
+
rebuildStatus: "unavailable",
|
|
7338
|
+
failureReason: sanitizeDerivedViewFailureReason(
|
|
7339
|
+
store.getBackendReason?.() ?? "persistent lexical index unavailable"
|
|
7340
|
+
)
|
|
7341
|
+
};
|
|
7342
|
+
}
|
|
7343
|
+
} catch (error) {
|
|
7344
|
+
views.fts = {
|
|
7345
|
+
freshness: "unknown",
|
|
7346
|
+
rebuildStatus: "failed",
|
|
7347
|
+
failureReason: sanitizeDerivedViewFailureReason(error instanceof Error ? error.message : String(error))
|
|
7348
|
+
};
|
|
7349
|
+
}
|
|
7350
|
+
} else {
|
|
7351
|
+
views.fts = {
|
|
7352
|
+
freshness: "unknown",
|
|
7353
|
+
rebuildStatus: "unavailable",
|
|
7354
|
+
failureReason: "observation store is not initialized"
|
|
7355
|
+
};
|
|
7356
|
+
}
|
|
7357
|
+
views.orama = db ? { generation: dbGeneration, freshness: "current", rebuildStatus: "idle" } : {
|
|
7358
|
+
generation: dbGeneration,
|
|
7359
|
+
freshness: "unknown",
|
|
7360
|
+
rebuildStatus: "unavailable",
|
|
7361
|
+
failureReason: "Orama index is not initialized"
|
|
7362
|
+
};
|
|
7363
|
+
let embeddingHealth;
|
|
7364
|
+
try {
|
|
7365
|
+
embeddingHealth = getEmbeddingRuntimeHealth?.();
|
|
7366
|
+
} catch {
|
|
7367
|
+
}
|
|
7368
|
+
views.embedding = embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
|
|
7369
|
+
return views;
|
|
7370
|
+
}
|
|
7188
7371
|
function rememberSearchDiagnostics(key, value) {
|
|
7189
7372
|
if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
7190
7373
|
const oldest = lastSearchDiagnosticsByProject.keys().next().value;
|
|
@@ -7486,12 +7669,16 @@ function getVectorDimensions() {
|
|
|
7486
7669
|
function getActiveSemanticIndexProfile() {
|
|
7487
7670
|
return indexEmbeddingProvider ? createSemanticIndexProfile(indexEmbeddingProvider) : null;
|
|
7488
7671
|
}
|
|
7672
|
+
async function getPersistentSemanticVectorIds(dataDir) {
|
|
7673
|
+
if (!indexEmbeddingProvider) return null;
|
|
7674
|
+
return listSemanticVectorIds(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
|
|
7675
|
+
}
|
|
7489
7676
|
async function queueSemanticVector(dataDir, record80) {
|
|
7490
7677
|
const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
|
|
7491
7678
|
const profile = provider2 ? createSemanticIndexProfile(provider2) : null;
|
|
7492
7679
|
if (!profile) return;
|
|
7493
7680
|
try {
|
|
7494
|
-
await
|
|
7681
|
+
await upsertSemanticVector(dataDir, profile, record80);
|
|
7495
7682
|
} catch {
|
|
7496
7683
|
}
|
|
7497
7684
|
}
|
|
@@ -7553,6 +7740,7 @@ function isCompatibleCachedVector(vector) {
|
|
|
7553
7740
|
async function attachCachedVectors(database, observations2) {
|
|
7554
7741
|
const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
|
|
7555
7742
|
const semanticProfile = getActiveSemanticIndexProfile();
|
|
7743
|
+
const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorIds(semanticDataDir, semanticProfile).catch(() => null) : null;
|
|
7556
7744
|
const batchSize = 200;
|
|
7557
7745
|
for (let start = 0; start < observations2.length; start += batchSize) {
|
|
7558
7746
|
const batch = observations2.slice(start, start + batchSize);
|
|
@@ -7563,7 +7751,7 @@ async function attachCachedVectors(database, observations2) {
|
|
|
7563
7751
|
const vector = cachedVectors[index];
|
|
7564
7752
|
if (!isCompatibleCachedVector(vector)) continue;
|
|
7565
7753
|
const observation = batch[index];
|
|
7566
|
-
if (semanticDataDir && semanticProfile) {
|
|
7754
|
+
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
|
|
7567
7755
|
semanticRecords.push({
|
|
7568
7756
|
observationId: observation.id,
|
|
7569
7757
|
projectId: observation.projectId,
|
|
@@ -8336,6 +8524,7 @@ var init_orama_store = __esm({
|
|
|
8336
8524
|
init_mini_skills();
|
|
8337
8525
|
init_visibility();
|
|
8338
8526
|
init_provider();
|
|
8527
|
+
init_provider();
|
|
8339
8528
|
init_project_affinity();
|
|
8340
8529
|
init_intent_detector();
|
|
8341
8530
|
init_query_expansion();
|
|
@@ -8343,6 +8532,7 @@ var init_orama_store = __esm({
|
|
|
8343
8532
|
init_timeout();
|
|
8344
8533
|
init_obs_store();
|
|
8345
8534
|
init_semantic_index();
|
|
8535
|
+
init_derived_view_receipt();
|
|
8346
8536
|
db = null;
|
|
8347
8537
|
dbInitPromise = null;
|
|
8348
8538
|
dbGeneration = 0;
|
|
@@ -8467,33 +8657,6 @@ var init_entity_extractor = __esm({
|
|
|
8467
8657
|
}
|
|
8468
8658
|
});
|
|
8469
8659
|
|
|
8470
|
-
// src/memory/secret-filter.ts
|
|
8471
|
-
function applyRedaction(text2) {
|
|
8472
|
-
if (!text2) return text2;
|
|
8473
|
-
let out = text2;
|
|
8474
|
-
out = out.replace(
|
|
8475
|
-
/((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
|
|
8476
|
-
"$1[REDACTED]"
|
|
8477
|
-
);
|
|
8478
|
-
out = out.replace(
|
|
8479
|
-
/(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
|
|
8480
|
-
"$1[REDACTED]"
|
|
8481
|
-
);
|
|
8482
|
-
out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
|
|
8483
|
-
out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
|
|
8484
|
-
out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
|
|
8485
|
-
return out;
|
|
8486
|
-
}
|
|
8487
|
-
function sanitizeCredentials(text2) {
|
|
8488
|
-
return applyRedaction(text2);
|
|
8489
|
-
}
|
|
8490
|
-
var init_secret_filter = __esm({
|
|
8491
|
-
"src/memory/secret-filter.ts"() {
|
|
8492
|
-
"use strict";
|
|
8493
|
-
init_esm_shims();
|
|
8494
|
-
}
|
|
8495
|
-
});
|
|
8496
|
-
|
|
8497
8660
|
// src/runtime/maintenance-jobs.ts
|
|
8498
8661
|
var maintenance_jobs_exports = {};
|
|
8499
8662
|
__export(maintenance_jobs_exports, {
|
|
@@ -11369,13 +11532,14 @@ async function prepareSearchIndex(options = {}) {
|
|
|
11369
11532
|
return 0;
|
|
11370
11533
|
}
|
|
11371
11534
|
const hydratedProjectDir = projectDir;
|
|
11372
|
-
const queueMissingVectors = () => {
|
|
11373
|
-
if (projectDir !== hydratedProjectDir) return;
|
|
11535
|
+
const queueMissingVectors = async () => {
|
|
11536
|
+
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
11374
11537
|
vectorMissingIds.clear();
|
|
11375
11538
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
11539
|
+
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
11376
11540
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
11377
11541
|
for (const obs of observations) {
|
|
11378
|
-
if (!hasObservationVector(obs.projectId, obs.id)) {
|
|
11542
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
11379
11543
|
vectorMissingIds.add(obs.id);
|
|
11380
11544
|
projectsWithMissingVectors.add(obs.projectId);
|
|
11381
11545
|
}
|
|
@@ -11385,9 +11549,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
11385
11549
|
};
|
|
11386
11550
|
const cacheHydration = getDeferredCachedVectorHydration();
|
|
11387
11551
|
if (cacheHydration) {
|
|
11388
|
-
void cacheHydration.
|
|
11552
|
+
void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => void 0);
|
|
11389
11553
|
} else {
|
|
11390
|
-
queueMissingVectors();
|
|
11554
|
+
await queueMissingVectors();
|
|
11391
11555
|
}
|
|
11392
11556
|
searchIndexPrepared = true;
|
|
11393
11557
|
return count2;
|
|
@@ -146410,7 +146574,7 @@ __export(video_jobs_exports, {
|
|
|
146410
146574
|
runMiniMaxVideoGenerationJob: () => runMiniMaxVideoGenerationJob
|
|
146411
146575
|
});
|
|
146412
146576
|
import { spawn } from "child_process";
|
|
146413
|
-
import { existsSync as
|
|
146577
|
+
import { existsSync as existsSync9 } from "fs";
|
|
146414
146578
|
import path15 from "path";
|
|
146415
146579
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
146416
146580
|
function safeError2(error) {
|
|
@@ -146658,7 +146822,7 @@ function resolveMediaVideoRunnerPath(moduleUrl = import.meta.url) {
|
|
|
146658
146822
|
}
|
|
146659
146823
|
function launchMediaVideoRunner(request, options = {}) {
|
|
146660
146824
|
const runnerPath = options.runnerPath ?? resolveMediaVideoRunnerPath();
|
|
146661
|
-
if (!
|
|
146825
|
+
if (!existsSync9(runnerPath)) {
|
|
146662
146826
|
return { launched: false, reason: "Media video runner is unavailable until Memorix is built or reinstalled." };
|
|
146663
146827
|
}
|
|
146664
146828
|
try {
|
|
@@ -146703,7 +146867,7 @@ __export(audio_jobs_exports, {
|
|
|
146703
146867
|
transcribeAudio: () => transcribeAudio
|
|
146704
146868
|
});
|
|
146705
146869
|
import { spawn as spawn2 } from "child_process";
|
|
146706
|
-
import { existsSync as
|
|
146870
|
+
import { existsSync as existsSync10 } from "fs";
|
|
146707
146871
|
import path16 from "path";
|
|
146708
146872
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
146709
146873
|
function safeError3(error) {
|
|
@@ -146954,7 +147118,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
|
|
|
146954
147118
|
}
|
|
146955
147119
|
function launchMediaAudioRunner(request, options = {}) {
|
|
146956
147120
|
const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
|
|
146957
|
-
if (!
|
|
147121
|
+
if (!existsSync10(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
|
|
146958
147122
|
try {
|
|
146959
147123
|
const child = spawn2(process.execPath, [runnerPath, JSON.stringify(request)], {
|
|
146960
147124
|
cwd: request.projectRoot,
|
|
@@ -148870,7 +149034,7 @@ __export(lite_provider_exports, {
|
|
|
148870
149034
|
refreshProjectLite: () => refreshProjectLite
|
|
148871
149035
|
});
|
|
148872
149036
|
import { createHash as createHash11 } from "crypto";
|
|
148873
|
-
import { existsSync as
|
|
149037
|
+
import { existsSync as existsSync12, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
148874
149038
|
import { join as join4, relative as relative2 } from "path";
|
|
148875
149039
|
function hashText2(text2) {
|
|
148876
149040
|
return createHash11("sha256").update(text2).digest("hex");
|
|
@@ -148888,7 +149052,7 @@ function resolveMaxFileBytes(value) {
|
|
|
148888
149052
|
return Math.max(1, Math.floor(value));
|
|
148889
149053
|
}
|
|
148890
149054
|
function isPythonVirtualenvDir(dir) {
|
|
148891
|
-
return
|
|
149055
|
+
return existsSync12(join4(dir, "pyvenv.cfg"));
|
|
148892
149056
|
}
|
|
148893
149057
|
function walk(root, exclude, maxFiles) {
|
|
148894
149058
|
const out = [];
|
|
@@ -152270,7 +152434,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
152270
152434
|
import { spawn as spawn3 } from "child_process";
|
|
152271
152435
|
import {
|
|
152272
152436
|
closeSync,
|
|
152273
|
-
existsSync as
|
|
152437
|
+
existsSync as existsSync13,
|
|
152274
152438
|
mkdirSync as mkdirSync2,
|
|
152275
152439
|
openSync,
|
|
152276
152440
|
readFileSync as readFileSync9,
|
|
@@ -152398,7 +152562,7 @@ function releaseVectorBackfillLock(lockPath = process.env.MEMORIX_VECTOR_BACKFIL
|
|
|
152398
152562
|
}
|
|
152399
152563
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
152400
152564
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
152401
|
-
const exists = options.exists ??
|
|
152565
|
+
const exists = options.exists ?? existsSync13;
|
|
152402
152566
|
if (!exists(runnerPath)) return false;
|
|
152403
152567
|
const lock = acquireVectorBackfillLock(request.dataDir, request.projectId, options.lockPath);
|
|
152404
152568
|
if (!lock) return false;
|
|
@@ -133,7 +133,25 @@ engine, MCP `memorix_search`, and CLI `memory search --json`:
|
|
|
133
133
|
- `mode`, `resultCount`, `selectedCount`, and `tokenCount`;
|
|
134
134
|
- `candidateCount`, `omittedCount`, and `omittedByTokenBudget`;
|
|
135
135
|
- `fallbackUsed` and an optional bounded `fallbackReason`;
|
|
136
|
+
- `derivedViews` for FTS, Orama, embedding, and CodeGraph generation,
|
|
137
|
+
freshness, rebuild status, and bounded failure reason;
|
|
136
138
|
- request-level `elapsedMs`.
|
|
137
139
|
|
|
138
140
|
The receipt remains metadata-only: query text, raw memory narratives, and local
|
|
139
141
|
paths are not added to it.
|
|
142
|
+
|
|
143
|
+
### Reproducible 1.9.11 to 1.10 Comparison
|
|
144
|
+
|
|
145
|
+
The same `scripts/benchmark-retrieval.mjs --records 1000 --runs 20` command was
|
|
146
|
+
run from the `v1.9.11` tag and the current 1.10 main line on Windows Node
|
|
147
|
+
`v22.22.3`, with embeddings and LLM disabled:
|
|
148
|
+
|
|
149
|
+
| Version | Seed/index | Specific p95 | Broad p95 |
|
|
150
|
+
| --- | ---: | ---: | ---: |
|
|
151
|
+
| 1.9.11 | 1,221.509ms | 9.283ms | 12.301ms |
|
|
152
|
+
| 1.10 main | 1,245.802ms | 8.925ms | 12.298ms |
|
|
153
|
+
|
|
154
|
+
The benchmark is a hot in-process SDK lexical measurement, not a cross-platform
|
|
155
|
+
SLO. The specific path improved by about 3.9% in this run and the broad path was
|
|
156
|
+
effectively unchanged; the result is retained as a baseline rather than a claim
|
|
157
|
+
of statistically significant performance improvement.
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -219,6 +219,31 @@ keys. Setting the key alone does not enable paid background memory processing.
|
|
|
219
219
|
Embeddings and memcode's model registry are unchanged. Image analysis requires
|
|
220
220
|
explicitly selecting a vision-capable model; the default is for text memory.
|
|
221
221
|
|
|
222
|
+
### Cheaper Inference memory preset
|
|
223
|
+
|
|
224
|
+
[Cheaper Inference](https://cheaperinference.com) is available in `memorix init`
|
|
225
|
+
and the configuration TUI as an optional memory LLM preset:
|
|
226
|
+
|
|
227
|
+
```toml
|
|
228
|
+
[memory.llm]
|
|
229
|
+
provider = "cheaperinference"
|
|
230
|
+
model = "gpt-5.4-mini"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The preset uses `https://api.cheaperinference.com/v1` and the existing
|
|
234
|
+
OpenAI-compatible chat completion transport. Set `CHEAPER_INFERENCE_API_KEY` or
|
|
235
|
+
`MEMORIX_LLM_API_KEY`, or store `api_key` in your private global config. Keep
|
|
236
|
+
credentials out of project TOML. Explicit `model` and `base_url` overrides
|
|
237
|
+
still apply; use IDs from the endpoint's `/v1/models` catalog without adding
|
|
238
|
+
an extra vendor prefix.
|
|
239
|
+
|
|
240
|
+
`CHEAPER_INFERENCE_API_KEY` is used only when this memory preset is selected,
|
|
241
|
+
and the preset does not borrow OpenAI, Anthropic, OpenRouter, Requesty, API
|
|
242
|
+
Route, or Atlas Cloud keys. Setting the key alone does not enable paid
|
|
243
|
+
background memory processing. Embeddings and memcode's model registry are
|
|
244
|
+
unchanged. Image analysis requires explicitly selecting a vision-capable model;
|
|
245
|
+
the default is for text memory.
|
|
246
|
+
|
|
222
247
|
### OrcaRouter custom endpoint
|
|
223
248
|
|
|
224
249
|
OrcaRouter works through the generic OpenAI-compatible gateway path. Keep the
|
package/docs/DEVELOPMENT.md
CHANGED
|
@@ -13,9 +13,9 @@ Memorix is a TypeScript project built around:
|
|
|
13
13
|
|
|
14
14
|
## Current Development Baseline
|
|
15
15
|
|
|
16
|
-
The
|
|
17
|
-
with the root package and MCP Registry manifest.
|
|
18
|
-
|
|
16
|
+
The current release line is **1.10.2** and package metadata is kept
|
|
17
|
+
synchronized with the root package and MCP Registry manifest. The next larger
|
|
18
|
+
feature phase follows the 1.11 relay-preview plan.
|
|
19
19
|
|
|
20
20
|
Contributors should assume the following areas are part of the current release line:
|
|
21
21
|
|
package/docs/PERFORMANCE.md
CHANGED
|
@@ -112,6 +112,29 @@ Code Memory refresh are queued durably and run in an isolated child process.
|
|
|
112
112
|
Vector backfill updates the persistent semantic shadow index and keeps Orama as
|
|
113
113
|
the compatibility fallback.
|
|
114
114
|
|
|
115
|
+
### LanceDB semantic index maintenance
|
|
116
|
+
|
|
117
|
+
The persistent semantic index groups individual observation writes into batches
|
|
118
|
+
of up to 100 vectors, flushing after 50 ms. It compacts fragments and prunes
|
|
119
|
+
versions older than 24 hours after every 20 committed batches. Existing vectors
|
|
120
|
+
in LanceDB are not re-embedded merely because the disposable API embedding cache
|
|
121
|
+
evicted them. These controls are separate from SQLite observation retention.
|
|
122
|
+
|
|
123
|
+
For an index already inflated by older releases, stop processes using the
|
|
124
|
+
shared data directory, then run `memorix repair index` from any associated Git
|
|
125
|
+
project. This optimizes every Memorix semantic table without requiring the
|
|
126
|
+
original embedding provider. It retains the last 24 hours of table versions and
|
|
127
|
+
does not remove files that LanceDB considers unverified, because another process
|
|
128
|
+
may have an in-progress transaction. It can therefore leave some recent space
|
|
129
|
+
unreclaimed; rerun after the retention window if necessary. Do not manually
|
|
130
|
+
delete `_versions` or `data` files.
|
|
131
|
+
|
|
132
|
+
`MEMORIX_SEMANTIC_WRITE_BATCH_SIZE`, `MEMORIX_SEMANTIC_WRITE_FLUSH_MS`,
|
|
133
|
+
`MEMORIX_SEMANTIC_OPTIMIZE_EVERY`, and
|
|
134
|
+
`MEMORIX_SEMANTIC_VERSION_RETENTION_MS` tune these defaults. The batch size and
|
|
135
|
+
retention window trade commit frequency and disk use against write latency and
|
|
136
|
+
rollback history.
|
|
137
|
+
|
|
115
138
|
## What Is Lightweight
|
|
116
139
|
|
|
117
140
|
- `memorix_session_start` is lightweight by default. It opens a memory/session context and does not join orchestration coordination state unless `joinTeam: true` is explicitly set.
|
package/docs/README.md
CHANGED
|
@@ -127,8 +127,8 @@ Historical/deep-reference documents may describe older designs. If they conflict
|
|
|
127
127
|
|
|
128
128
|
## Current Product Line
|
|
129
129
|
|
|
130
|
-
The
|
|
131
|
-
|
|
130
|
+
The current product line is **1.10.2**; it includes the LanceDB semantic-index
|
|
131
|
+
growth fix, derived-view receipts, and the optional Cheaper Inference preset.
|
|
132
132
|
Multi-device store sync is opt-in and keeps local SQLite canonical; existing
|
|
133
133
|
users do not upload anything until they configure a relay provider explicitly.
|
|
134
134
|
The authoritative acceptance contract for the current implementation is
|
|
@@ -47,13 +47,13 @@ Memorix 已经超过“给 coding agent 加一个记忆工具”的阶段。当
|
|
|
47
47
|
|
|
48
48
|
### 1.1 当前事实
|
|
49
49
|
|
|
50
|
-
当前发布基线是 `v1.
|
|
51
|
-
|
|
52
|
-
provenance
|
|
50
|
+
当前发布基线是 `v1.10.2`。本补丁修复 LanceDB 语义索引无限增长;1.9.12 的 CJK 搜索、搜索回退、大库 alias 迁移、
|
|
51
|
+
Node 26 Pi hooks、Qwen hooks、API Route provider、session label、发布
|
|
52
|
+
provenance 收紧和后台更新脚本隔离,已经与 1.10 的可信上下文、检索收据、
|
|
53
|
+
真实矩阵评估和容量门禁一起发布。
|
|
53
54
|
|
|
54
|
-
`v1.
|
|
55
|
-
Release
|
|
56
|
-
当前工作区不再是 1.9.12 release preparation。
|
|
55
|
+
`v1.10.1` 已从提交 `7c51d34` 发布到 npm、官方 MCP Registry 和 GitHub
|
|
56
|
+
Release。后续 `main` 进入 1.11 的本地优先 relay 与协作预览准备阶段。
|
|
57
57
|
|
|
58
58
|
1.9.12 已完成:
|
|
59
59
|
|
|
@@ -216,6 +216,9 @@ search mode、candidate/selected/omitted counts、token budget omissions、fallb
|
|
|
216
216
|
reason、token count 和 elapsed time;查询文本与原始 memory 内容不进入 receipt。
|
|
217
217
|
底层 Orama/SQLite search 现在保留 request-level diagnostics,使这些字段来自
|
|
218
218
|
实际检索路径而不是调用方猜测。
|
|
219
|
+
Receipt 还通过 `derivedViews` 统一记录 FTS、Orama、embedding、CodeGraph 的
|
|
220
|
+
generation、freshness、rebuild status 和 bounded failure reason;这项补强已在
|
|
221
|
+
main 验证,但属于 1.10.0 之后的 Unreleased 增量。
|
|
219
222
|
|
|
220
223
|
1.10 的真实任务矩阵已执行完成:20/20 cases passed。Windows Node 22.22.3、
|
|
221
224
|
embeddings/LLM disabled 的基线为 memory hit precision/recall 1.00/1.00、
|
|
@@ -225,6 +228,10 @@ stale/conflict rejection 1.00/1.00、abstention precision 0.95,矩阵 p50/p95
|
|
|
225
228
|
518.983ms/6ms,100k 为 1,099.809ms/7ms,两个 gate 都没有 failed checks。
|
|
226
229
|
可复现入口为 `npm run gate:context-runtime`(20-case + 40k)以及
|
|
227
230
|
`node scripts/large-store-gate.mjs --records 100000`(100k 容量门禁)。
|
|
231
|
+
同一 `scripts/benchmark-retrieval.mjs --records 1000 --runs 20` 在 v1.9.11
|
|
232
|
+
和当前 1.10 main 上复跑:specific p95 为 9.283ms -> 8.925ms,broad p95
|
|
233
|
+
为 12.301ms -> 12.298ms;该结果证明热 lexical 路径没有回归,但不宣称
|
|
234
|
+
统计显著的性能提升。
|
|
228
235
|
|
|
229
236
|
### 3.1 版本定位
|
|
230
237
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memorix",
|
|
3
3
|
"mcpName": "io.github.AVIDS2/memorix",
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.2",
|
|
5
5
|
"description": "Local-first shared memory layer for AI coding agents across MCP clients, Git history, reasoning context, and project sessions.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|