memorix 1.10.2 → 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 +20 -0
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/dist/cli/index.js +397 -215
- package/dist/cli/memcode.js +0 -0
- package/dist/index.js +150 -38
- package/dist/maintenance-runner.js +108 -22
- package/dist/media-audio-runner.js +108 -22
- package/dist/media-video-runner.js +108 -22
- package/dist/memcode-runtime/CHANGELOG.md +20 -0
- package/dist/sdk.js +149 -37
- package/dist/types.d.ts +1 -1
- package/dist/vector-backfill-runner.js +108 -22
- package/docs/CONFIGURATION.md +34 -0
- package/docs/DEVELOPMENT.md +1 -1
- package/docs/INTEGRATIONS.md +1 -1
- package/docs/README.md +2 -1
- package/docs/ROADMAP-1.9.12-2.0.md +1 -1
- 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/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/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/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/llm/provider.ts +2 -1
- package/src/memory/observations.ts +61 -17
- package/src/multimodal/image-loader.ts +2 -2
- package/src/runtime/open-browser.ts +25 -0
- package/src/server.ts +2 -2
- package/src/store/orama-store.ts +27 -3
- 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
package/dist/sdk.js
CHANGED
|
@@ -3871,7 +3871,8 @@ function getResolvedConfig(options = {}) {
|
|
|
3871
3871
|
const isRequesty = memoryLlmProvider === "requesty";
|
|
3872
3872
|
const isApiRoute = memoryLlmProvider === "apiroute";
|
|
3873
3873
|
const isCheaperInference = memoryLlmProvider === "cheaperinference";
|
|
3874
|
-
const
|
|
3874
|
+
const isRuncrate = memoryLlmProvider === "runcrate";
|
|
3875
|
+
const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference || isRuncrate;
|
|
3875
3876
|
const memoryLlmApiKey = first(
|
|
3876
3877
|
process.env.MEMORIX_LLM_API_KEY,
|
|
3877
3878
|
process.env.MEMORIX_API_KEY,
|
|
@@ -3879,7 +3880,7 @@ function getResolvedConfig(options = {}) {
|
|
|
3879
3880
|
yaml.llm?.apiKey,
|
|
3880
3881
|
legacy.llm?.apiKey,
|
|
3881
3882
|
// Never borrow another provider's credentials for these gateway presets.
|
|
3882
|
-
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,
|
|
3883
|
+
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,
|
|
3883
3884
|
usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
|
|
3884
3885
|
usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
|
|
3885
3886
|
);
|
|
@@ -3950,6 +3951,7 @@ function getResolvedConfig(options = {}) {
|
|
|
3950
3951
|
codegraph: {
|
|
3951
3952
|
excludePatterns: firstArray(toml.codegraph?.exclude_patterns, yaml.codegraph?.excludePatterns),
|
|
3952
3953
|
maxFileBytes: firstNumber(toml.codegraph?.max_file_bytes, yaml.codegraph?.maxFileBytes),
|
|
3954
|
+
autoRefresh: first(toml.codegraph?.auto_refresh, yaml.codegraph?.autoRefresh, "auto"),
|
|
3953
3955
|
externalContext: first(
|
|
3954
3956
|
normalizeExternalContext(process.env.MEMORIX_CODEGRAPH_EXTERNAL_CONTEXT),
|
|
3955
3957
|
toml.codegraph?.external_context,
|
|
@@ -4064,6 +4066,7 @@ function getEnvSourceNames() {
|
|
|
4064
4066
|
"REQUESTY_API_KEY",
|
|
4065
4067
|
"API_ROUTE_API_KEY",
|
|
4066
4068
|
"CHEAPER_INFERENCE_API_KEY",
|
|
4069
|
+
"RUNCRATE_API_KEY",
|
|
4067
4070
|
"ATLASCLOUD_API_KEY"
|
|
4068
4071
|
].filter((name) => process.env[name]);
|
|
4069
4072
|
}
|
|
@@ -7059,6 +7062,7 @@ var init_provider2 = __esm({
|
|
|
7059
7062
|
requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
|
|
7060
7063
|
apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
|
|
7061
7064
|
cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
|
|
7065
|
+
runcrate: { baseUrl: "https://api.runcrate.ai/v1", model: "deepseek-ai/DeepSeek-V4.1-Flash" },
|
|
7062
7066
|
atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
|
|
7063
7067
|
custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
|
|
7064
7068
|
};
|
|
@@ -8879,10 +8883,18 @@ __export(orama_store_exports, {
|
|
|
8879
8883
|
queueSemanticVector: () => queueSemanticVector,
|
|
8880
8884
|
removeObservation: () => removeObservation,
|
|
8881
8885
|
resetDb: () => resetDb,
|
|
8886
|
+
resolveSearchFuzzyTolerance: () => resolveSearchFuzzyTolerance,
|
|
8882
8887
|
searchObservations: () => searchObservations,
|
|
8883
8888
|
updateObservationMetadata: () => updateObservationMetadata
|
|
8884
8889
|
});
|
|
8885
8890
|
import { components, create, insert as insert2, insertMultiple, search, remove as remove2, update, count, getByID } from "@orama/orama";
|
|
8891
|
+
function resolveSearchFuzzyTolerance(query, quality) {
|
|
8892
|
+
if (quality === "fast") return void 0;
|
|
8893
|
+
const characters = [...query];
|
|
8894
|
+
const cjkCount = characters.filter((char) => /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]/u.test(char)).length;
|
|
8895
|
+
if (characters.length > 0 && cjkCount / characters.length > 0.3) return void 0;
|
|
8896
|
+
return query.length > 6 ? 2 : 1;
|
|
8897
|
+
}
|
|
8886
8898
|
function rememberSearchMode(key, value) {
|
|
8887
8899
|
if (!lastSearchModeByProject.has(key) && lastSearchModeByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
8888
8900
|
const oldest = lastSearchModeByProject.keys().next().value;
|
|
@@ -9528,7 +9540,10 @@ async function searchObservations(options) {
|
|
|
9528
9540
|
// Fuzzy tolerance: allow 1-char typos for short queries, 2 for longer
|
|
9529
9541
|
// Fuzzy matching is useful for ordinary recall, but grows sharply with
|
|
9530
9542
|
// corpus size. The fast profile deliberately uses exact lexical matching.
|
|
9531
|
-
...hasQuery
|
|
9543
|
+
...hasQuery ? (() => {
|
|
9544
|
+
const tolerance = resolveSearchFuzzyTolerance(originalQuery, quality);
|
|
9545
|
+
return tolerance === void 0 ? {} : { tolerance };
|
|
9546
|
+
})() : {}
|
|
9532
9547
|
};
|
|
9533
9548
|
let queryVector = null;
|
|
9534
9549
|
let embeddingProviderForSearch = null;
|
|
@@ -9759,14 +9774,16 @@ async function searchObservations(options) {
|
|
|
9759
9774
|
filesModified: doc.filesModified?.split?.("\n") ?? (Array.isArray(doc.filesModified) ? doc.filesModified : [])
|
|
9760
9775
|
});
|
|
9761
9776
|
}
|
|
9777
|
+
const topScore = Math.max(...intermediate.map((entry) => entry.score));
|
|
9778
|
+
const affinityTieWindow = topScore * 0.92;
|
|
9762
9779
|
intermediate = intermediate.map((entry) => {
|
|
9763
9780
|
const memory = memoryContentMap.get(entry.id);
|
|
9764
9781
|
if (!memory) return entry;
|
|
9765
9782
|
const { score: affinityScore } = calculateProjectAffinity(memory, affinityContext);
|
|
9783
|
+
if (entry.score < affinityTieWindow) return entry;
|
|
9766
9784
|
return {
|
|
9767
9785
|
...entry,
|
|
9768
|
-
score: entry.score * affinityScore
|
|
9769
|
-
// Apply affinity as multiplier
|
|
9786
|
+
score: entry.score * (0.98 + affinityScore * 0.02)
|
|
9770
9787
|
};
|
|
9771
9788
|
});
|
|
9772
9789
|
intermediate.sort((a, b) => b.score - a.score);
|
|
@@ -149270,6 +149287,7 @@ var init_store = __esm({
|
|
|
149270
149287
|
recordCodeStateSnapshot(input) {
|
|
149271
149288
|
const id = randomUUID11();
|
|
149272
149289
|
let snapshot;
|
|
149290
|
+
let compactNeeded = false;
|
|
149273
149291
|
const tx = this.db.transaction(() => {
|
|
149274
149292
|
const previous = this.db.prepare(
|
|
149275
149293
|
"SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1"
|
|
@@ -149313,6 +149331,26 @@ var init_store = __esm({
|
|
|
149313
149331
|
for (const file of snapshotFileRows) {
|
|
149314
149332
|
insertSnapshotFile.run(id, file.projectId, file.id, file.path, file.contentHash);
|
|
149315
149333
|
}
|
|
149334
|
+
const staleSymbolIds = this.db.prepare(
|
|
149335
|
+
"SELECT id FROM code_symbols WHERE projectId = ? AND stale = 1"
|
|
149336
|
+
).all(input.projectId).map((row) => row.id);
|
|
149337
|
+
if (staleSymbolIds.length > 0) {
|
|
149338
|
+
const placeholders = staleSymbolIds.map(() => "?").join(", ");
|
|
149339
|
+
this.db.prepare(
|
|
149340
|
+
`DELETE FROM code_edges WHERE projectId = ? AND (fromSymbolId IN (${placeholders}) OR toSymbolId IN (${placeholders}))`
|
|
149341
|
+
).run(input.projectId, ...staleSymbolIds, ...staleSymbolIds);
|
|
149342
|
+
this.db.prepare("DELETE FROM code_symbols WHERE projectId = ? AND stale = 1").run(input.projectId);
|
|
149343
|
+
compactNeeded = true;
|
|
149344
|
+
}
|
|
149345
|
+
const oldSnapshots = this.db.prepare(
|
|
149346
|
+
"SELECT id FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT -1 OFFSET 2"
|
|
149347
|
+
).all(input.projectId).map((row) => row.id);
|
|
149348
|
+
if (oldSnapshots.length > 0) {
|
|
149349
|
+
const placeholders = oldSnapshots.map(() => "?").join(", ");
|
|
149350
|
+
this.db.prepare(`DELETE FROM code_state_snapshot_files WHERE snapshotId IN (${placeholders})`).run(...oldSnapshots);
|
|
149351
|
+
this.db.prepare(`DELETE FROM code_state_snapshots WHERE id IN (${placeholders})`).run(...oldSnapshots);
|
|
149352
|
+
compactNeeded = true;
|
|
149353
|
+
}
|
|
149316
149354
|
snapshot = {
|
|
149317
149355
|
...input,
|
|
149318
149356
|
id,
|
|
@@ -149321,11 +149359,24 @@ var init_store = __esm({
|
|
|
149321
149359
|
};
|
|
149322
149360
|
});
|
|
149323
149361
|
tx();
|
|
149362
|
+
if (compactNeeded) this.compactStorage();
|
|
149324
149363
|
return snapshot;
|
|
149325
149364
|
}
|
|
149365
|
+
/** Reclaim WAL/free pages after a derived codegraph sweep. */
|
|
149366
|
+
compactStorage() {
|
|
149367
|
+
try {
|
|
149368
|
+
this.db.pragma("wal_checkpoint(TRUNCATE)");
|
|
149369
|
+
} catch {
|
|
149370
|
+
}
|
|
149371
|
+
try {
|
|
149372
|
+
this.db.exec("VACUUM");
|
|
149373
|
+
} catch {
|
|
149374
|
+
}
|
|
149375
|
+
}
|
|
149326
149376
|
status(projectId) {
|
|
149327
149377
|
const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
|
|
149328
149378
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
149379
|
+
const staleSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 1`).get(projectId).count;
|
|
149329
149380
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
149330
149381
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
149331
149382
|
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
@@ -149333,6 +149384,8 @@ var init_store = __esm({
|
|
|
149333
149384
|
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
149334
149385
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
149335
149386
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
149387
|
+
const snapshots = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshots WHERE projectId = ?`).get(projectId).count;
|
|
149388
|
+
const snapshotFiles = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshot_files WHERE projectId = ?`).get(projectId).count;
|
|
149336
149389
|
return {
|
|
149337
149390
|
provider: "lite",
|
|
149338
149391
|
files,
|
|
@@ -149342,6 +149395,9 @@ var init_store = __esm({
|
|
|
149342
149395
|
semanticSymbols,
|
|
149343
149396
|
semanticEdges,
|
|
149344
149397
|
parserErrors,
|
|
149398
|
+
staleSymbols,
|
|
149399
|
+
snapshots,
|
|
149400
|
+
snapshotFiles,
|
|
149345
149401
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
149346
149402
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
149347
149403
|
};
|
|
@@ -154044,10 +154100,22 @@ function resetObservationRuntime() {
|
|
|
154044
154100
|
loadedObservationStore = null;
|
|
154045
154101
|
embeddingWriteMode = "background";
|
|
154046
154102
|
embeddingWorkerProjectRoot = void 0;
|
|
154047
|
-
|
|
154103
|
+
clearVectorMissingIds();
|
|
154048
154104
|
vectorSchemaUpgradePromise = null;
|
|
154049
154105
|
embeddingFailureLogTimestamps.clear();
|
|
154050
154106
|
}
|
|
154107
|
+
function markVectorMissing(observationId2, projectId) {
|
|
154108
|
+
vectorMissingIds.add(observationId2);
|
|
154109
|
+
vectorMissingProjectIds.set(observationId2, projectId);
|
|
154110
|
+
}
|
|
154111
|
+
function clearVectorMissing(observationId2) {
|
|
154112
|
+
vectorMissingIds.delete(observationId2);
|
|
154113
|
+
vectorMissingProjectIds.delete(observationId2);
|
|
154114
|
+
}
|
|
154115
|
+
function clearVectorMissingIds() {
|
|
154116
|
+
vectorMissingIds.clear();
|
|
154117
|
+
vectorMissingProjectIds.clear();
|
|
154118
|
+
}
|
|
154051
154119
|
function logEmbeddingFailureOnce(key, message) {
|
|
154052
154120
|
const now3 = Date.now();
|
|
154053
154121
|
const last = embeddingFailureLogTimestamps.get(key) ?? 0;
|
|
@@ -154167,10 +154235,13 @@ function isVectorCompatibleWithCurrentIndex(embedding) {
|
|
|
154167
154235
|
}
|
|
154168
154236
|
async function upgradeVectorSchemaAfterFirstEmbedding(embedding) {
|
|
154169
154237
|
if (isVectorCompatibleWithCurrentIndex(embedding)) return true;
|
|
154170
|
-
if (
|
|
154238
|
+
if (!embedding.every(Number.isFinite)) return false;
|
|
154171
154239
|
const targetProjectDir = projectDir;
|
|
154172
154240
|
if (!vectorSchemaUpgradePromise) {
|
|
154173
|
-
vectorSchemaUpgradePromise =
|
|
154241
|
+
vectorSchemaUpgradePromise = getDb().then(async () => {
|
|
154242
|
+
if (getVectorDimensions() === null && observations.length > 0) await reindexObservations();
|
|
154243
|
+
return projectDir === targetProjectDir && isVectorCompatibleWithCurrentIndex(embedding);
|
|
154244
|
+
}).catch(() => false).finally(() => {
|
|
154174
154245
|
vectorSchemaUpgradePromise = null;
|
|
154175
154246
|
});
|
|
154176
154247
|
}
|
|
@@ -154210,9 +154281,9 @@ async function initObservations(dir, options = {}) {
|
|
|
154210
154281
|
}
|
|
154211
154282
|
function scheduleObservationEmbedding(input) {
|
|
154212
154283
|
const { observationId: observationId2, projectId, searchableText, doc } = input;
|
|
154213
|
-
|
|
154284
|
+
markVectorMissing(observationId2, projectId);
|
|
154214
154285
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
154215
|
-
|
|
154286
|
+
clearVectorMissing(observationId2);
|
|
154216
154287
|
return;
|
|
154217
154288
|
}
|
|
154218
154289
|
if (embeddingWriteMode === "deferred") {
|
|
@@ -154247,13 +154318,13 @@ function scheduleObservationEmbedding(input) {
|
|
|
154247
154318
|
vector: embedding
|
|
154248
154319
|
});
|
|
154249
154320
|
}
|
|
154250
|
-
|
|
154321
|
+
clearVectorMissing(observationId2);
|
|
154251
154322
|
} catch {
|
|
154252
154323
|
console.error(`[memorix] Embedding index update failed for obs-${observationId2} (kept in backfill queue)`);
|
|
154253
154324
|
queueVectorBackfill(projectId);
|
|
154254
154325
|
}
|
|
154255
154326
|
} else if (isEmbeddingExplicitlyDisabled()) {
|
|
154256
|
-
|
|
154327
|
+
clearVectorMissing(observationId2);
|
|
154257
154328
|
} else {
|
|
154258
154329
|
queueVectorBackfill(projectId);
|
|
154259
154330
|
logEmbeddingFailureOnce(
|
|
@@ -154813,7 +154884,7 @@ async function reindexObservations() {
|
|
|
154813
154884
|
if (observations.length === 0) return 0;
|
|
154814
154885
|
await resetDb();
|
|
154815
154886
|
searchIndexPrepared = false;
|
|
154816
|
-
|
|
154887
|
+
clearVectorMissingIds();
|
|
154817
154888
|
let embeddings = observations.map(() => null);
|
|
154818
154889
|
const provider2 = await getEmbeddingProvider();
|
|
154819
154890
|
const canBatchEmbedAtStartup = provider2 !== null && !provider2.name.startsWith("api-");
|
|
@@ -154878,7 +154949,7 @@ async function reindexObservations() {
|
|
|
154878
154949
|
};
|
|
154879
154950
|
await insertObservation(doc);
|
|
154880
154951
|
if (!compatibleEmbedding && !isEmbeddingExplicitlyDisabled()) {
|
|
154881
|
-
|
|
154952
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
154882
154953
|
}
|
|
154883
154954
|
count2++;
|
|
154884
154955
|
} catch (err) {
|
|
@@ -154895,7 +154966,17 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154895
154966
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
154896
154967
|
const store = getObservationStore();
|
|
154897
154968
|
const projects = await store.listProjectIds?.() ?? [];
|
|
154898
|
-
|
|
154969
|
+
await getDb({ allowNetworkProbe: false }).catch(() => void 0);
|
|
154970
|
+
const persistedIds = projectDir ? await getPersistentSemanticVectorIds(projectDir).catch(() => null) : null;
|
|
154971
|
+
for (const projectId of projects) {
|
|
154972
|
+
const projectObservations = await store.loadByProject(projectId);
|
|
154973
|
+
for (const observation of projectObservations) {
|
|
154974
|
+
if (!persistedIds?.has(observation.id)) markVectorMissing(observation.id, observation.projectId);
|
|
154975
|
+
}
|
|
154976
|
+
if (projectObservations.some((observation) => !persistedIds?.has(observation.id))) {
|
|
154977
|
+
queueVectorBackfill(projectId);
|
|
154978
|
+
}
|
|
154979
|
+
}
|
|
154899
154980
|
}
|
|
154900
154981
|
return 0;
|
|
154901
154982
|
}
|
|
@@ -154909,13 +154990,13 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154909
154990
|
const hydratedProjectDir = projectDir;
|
|
154910
154991
|
const queueMissingVectors = async () => {
|
|
154911
154992
|
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
154912
|
-
|
|
154993
|
+
clearVectorMissingIds();
|
|
154913
154994
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
154914
154995
|
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
154915
154996
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
154916
154997
|
for (const obs of observations) {
|
|
154917
154998
|
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
154918
|
-
|
|
154999
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
154919
155000
|
projectsWithMissingVectors.add(obs.projectId);
|
|
154920
155001
|
}
|
|
154921
155002
|
}
|
|
@@ -154933,6 +155014,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154933
155014
|
}
|
|
154934
155015
|
function getVectorMissingIds(projectId) {
|
|
154935
155016
|
if (!projectId) return [...vectorMissingIds];
|
|
155017
|
+
if (!corpusLoaded) {
|
|
155018
|
+
return [...vectorMissingIds].filter((id) => vectorMissingProjectIds.get(id) === projectId);
|
|
155019
|
+
}
|
|
154936
155020
|
const observationById = new Map(observations.map((observation) => [observation.id, observation]));
|
|
154937
155021
|
return [...vectorMissingIds].filter((id) => observationById.get(id)?.projectId === projectId);
|
|
154938
155022
|
}
|
|
@@ -154970,7 +155054,8 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
154970
155054
|
return { attempted: 0, succeeded: 0, failed: 0 };
|
|
154971
155055
|
}
|
|
154972
155056
|
vectorBackfillRunning = true;
|
|
154973
|
-
const
|
|
155057
|
+
const sourceObservations = corpusLoaded ? observations : options.projectId ? await getObservationStore().loadByProject(options.projectId, { status: "active" }) : await getObservationStore().loadAll();
|
|
155058
|
+
const observationById = new Map(sourceObservations.map((observation) => [observation.id, observation]));
|
|
154974
155059
|
const limit2 = Number.isFinite(options.limit) ? Math.max(1, Math.floor(options.limit)) : Number.POSITIVE_INFINITY;
|
|
154975
155060
|
const ids = [...vectorMissingIds].filter((id) => !options.projectId || observationById.get(id)?.projectId === options.projectId).slice(0, limit2);
|
|
154976
155061
|
let succeeded = 0;
|
|
@@ -154983,7 +155068,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
154983
155068
|
for (const id of ids) {
|
|
154984
155069
|
const observation = observationById.get(id);
|
|
154985
155070
|
if (!observation) {
|
|
154986
|
-
|
|
155071
|
+
clearVectorMissing(id);
|
|
154987
155072
|
continue;
|
|
154988
155073
|
}
|
|
154989
155074
|
candidates.push({
|
|
@@ -155001,7 +155086,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
155001
155086
|
const provider2 = await getEmbeddingProvider();
|
|
155002
155087
|
if (!provider2) {
|
|
155003
155088
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
155004
|
-
for (const candidate of candidates)
|
|
155089
|
+
for (const candidate of candidates) clearVectorMissing(candidate.id);
|
|
155005
155090
|
} else {
|
|
155006
155091
|
recordFailure("embedding provider unavailable");
|
|
155007
155092
|
failed += candidates.length;
|
|
@@ -155078,7 +155163,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
155078
155163
|
vector: embedding
|
|
155079
155164
|
});
|
|
155080
155165
|
}
|
|
155081
|
-
|
|
155166
|
+
clearVectorMissing(id);
|
|
155082
155167
|
succeeded++;
|
|
155083
155168
|
} catch (error) {
|
|
155084
155169
|
recordFailure(vectorBackfillError(error));
|
|
@@ -155103,7 +155188,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
155103
155188
|
...lastFailure ? { lastError: lastFailure } : {}
|
|
155104
155189
|
};
|
|
155105
155190
|
}
|
|
155106
|
-
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;
|
|
155191
|
+
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;
|
|
155107
155192
|
var init_observations = __esm({
|
|
155108
155193
|
"src/memory/observations.ts"() {
|
|
155109
155194
|
"use strict";
|
|
@@ -155128,6 +155213,7 @@ var init_observations = __esm({
|
|
|
155128
155213
|
loadedObservationStore = null;
|
|
155129
155214
|
DEFAULT_ORAMA_HYDRATION_THRESHOLD = 1e4;
|
|
155130
155215
|
vectorMissingIds = /* @__PURE__ */ new Set();
|
|
155216
|
+
vectorMissingProjectIds = /* @__PURE__ */ new Map();
|
|
155131
155217
|
vectorBackfillRunning = false;
|
|
155132
155218
|
vectorSchemaUpgradePromise = null;
|
|
155133
155219
|
lastVectorBackfill = null;
|
|
@@ -160063,12 +160149,12 @@ function decideRefresh(input) {
|
|
|
160063
160149
|
return { performed: false, reason: "fresh-enough", message: "Existing project scan is fresh enough." };
|
|
160064
160150
|
}
|
|
160065
160151
|
async function buildAutoProjectContext(input) {
|
|
160066
|
-
const refreshMode = input.refresh ?? "auto";
|
|
160067
160152
|
const now3 = input.now ?? /* @__PURE__ */ new Date();
|
|
160068
160153
|
const task = input.task?.trim();
|
|
160069
160154
|
const lens = resolveTaskLens(task);
|
|
160070
160155
|
const continuationRequested = input.continuation === "always" || input.continuation !== "never" && isContinuationTask(task);
|
|
160071
160156
|
const codegraphConfig = getResolvedConfig({ projectRoot: input.project.rootPath }).codegraph;
|
|
160157
|
+
const refreshMode = input.refresh ?? codegraphConfig.autoRefresh ?? "auto";
|
|
160072
160158
|
const exclude = input.exclude ?? codegraphConfig.excludePatterns;
|
|
160073
160159
|
const maxFileBytes = input.maxFileBytes ?? codegraphConfig.maxFileBytes;
|
|
160074
160160
|
const store = new CodeGraphStore();
|
|
@@ -162572,6 +162658,30 @@ var init_export_import = __esm({
|
|
|
162572
162658
|
}
|
|
162573
162659
|
});
|
|
162574
162660
|
|
|
162661
|
+
// src/runtime/open-browser.ts
|
|
162662
|
+
import { spawn as spawn6 } from "child_process";
|
|
162663
|
+
function resolveLocalBrowserCommand(target, platform = process.platform) {
|
|
162664
|
+
const url = new URL(target);
|
|
162665
|
+
if (url.protocol !== "http:" || !LOCAL_HTTP_HOSTS.has(url.hostname) || !url.port || url.username || url.password) {
|
|
162666
|
+
throw new Error("Only unauthenticated loopback HTTP URLs can be opened automatically");
|
|
162667
|
+
}
|
|
162668
|
+
return platform === "win32" ? { command: "explorer.exe", args: [url.toString()] } : platform === "darwin" ? { command: "open", args: [url.toString()] } : { command: "xdg-open", args: [url.toString()] };
|
|
162669
|
+
}
|
|
162670
|
+
function openLocalBrowser(target) {
|
|
162671
|
+
const { command, args } = resolveLocalBrowserCommand(target);
|
|
162672
|
+
const child = spawn6(command, args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
162673
|
+
child.once("error", () => void 0);
|
|
162674
|
+
child.unref();
|
|
162675
|
+
}
|
|
162676
|
+
var LOCAL_HTTP_HOSTS;
|
|
162677
|
+
var init_open_browser = __esm({
|
|
162678
|
+
"src/runtime/open-browser.ts"() {
|
|
162679
|
+
"use strict";
|
|
162680
|
+
init_esm_shims();
|
|
162681
|
+
LOCAL_HTTP_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
162682
|
+
}
|
|
162683
|
+
});
|
|
162684
|
+
|
|
162575
162685
|
// src/memory/cleanup.ts
|
|
162576
162686
|
function isLowQualityObservation(title) {
|
|
162577
162687
|
return LOW_QUALITY_PATTERNS.some((pattern) => pattern.test(title.trim()));
|
|
@@ -163580,7 +163690,6 @@ __export(server_exports, {
|
|
|
163580
163690
|
import { createServer } from "http";
|
|
163581
163691
|
import { promises as fs19 } from "fs";
|
|
163582
163692
|
import path32 from "path";
|
|
163583
|
-
import { exec } from "child_process";
|
|
163584
163693
|
function sendJson(res, data, status = 200) {
|
|
163585
163694
|
res.writeHead(status, {
|
|
163586
163695
|
"Content-Type": "application/json; charset=utf-8"
|
|
@@ -164070,7 +164179,8 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
164070
164179
|
...resolved.memory.llm.provider === "openrouter" || resolved.memory.llm.baseUrl?.includes("openrouter.ai") ? ["OPENROUTER_API_KEY"] : [],
|
|
164071
164180
|
...resolved.memory.llm.provider === "requesty" ? ["REQUESTY_API_KEY"] : [],
|
|
164072
164181
|
...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : [],
|
|
164073
|
-
...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : []
|
|
164182
|
+
...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : [],
|
|
164183
|
+
...resolved.memory.llm.provider === "runcrate" ? ["RUNCRATE_API_KEY"] : []
|
|
164074
164184
|
];
|
|
164075
164185
|
if (llmKey) {
|
|
164076
164186
|
const src = resolveDashboardKeySource({ value: llmKey, envKeys: memoryKeyEnv, configSource });
|
|
@@ -164285,9 +164395,10 @@ async function serveStatic(req, res, staticDir) {
|
|
|
164285
164395
|
}
|
|
164286
164396
|
}
|
|
164287
164397
|
function openBrowser(url) {
|
|
164288
|
-
|
|
164289
|
-
|
|
164290
|
-
}
|
|
164398
|
+
try {
|
|
164399
|
+
openLocalBrowser(url);
|
|
164400
|
+
} catch {
|
|
164401
|
+
}
|
|
164291
164402
|
}
|
|
164292
164403
|
function parseJsonField(value, fallback) {
|
|
164293
164404
|
if (typeof value !== "string") return value ?? fallback;
|
|
@@ -164523,6 +164634,7 @@ var init_server = __esm({
|
|
|
164523
164634
|
"src/dashboard/server.ts"() {
|
|
164524
164635
|
"use strict";
|
|
164525
164636
|
init_esm_shims();
|
|
164637
|
+
init_open_browser();
|
|
164526
164638
|
init_persistence();
|
|
164527
164639
|
init_obs_store();
|
|
164528
164640
|
init_session_store();
|
|
@@ -165656,7 +165768,7 @@ async function analyzeImage(input) {
|
|
|
165656
165768
|
const config = getLLMConfig();
|
|
165657
165769
|
if (!OPENAI_COMPATIBLE_PROVIDERS.has(config.provider)) {
|
|
165658
165770
|
throw new Error(
|
|
165659
|
-
`Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, or custom). Current provider "${config.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
|
|
165771
|
+
`Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, runcrate, or custom). Current provider "${config.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
|
|
165660
165772
|
);
|
|
165661
165773
|
}
|
|
165662
165774
|
const bytes = decodeBase64ImagePayload(input.base64, MAX_VISION_IMAGE_BYTES);
|
|
@@ -165695,7 +165807,7 @@ var init_image_loader = __esm({
|
|
|
165695
165807
|
init_provider2();
|
|
165696
165808
|
init_secret_filter();
|
|
165697
165809
|
init_image_payload();
|
|
165698
|
-
OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "custom"]);
|
|
165810
|
+
OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "runcrate", "custom"]);
|
|
165699
165811
|
MAX_VISION_PROMPT_CHARS = 12e3;
|
|
165700
165812
|
MAX_VISION_DESCRIPTION_CHARS = 12e3;
|
|
165701
165813
|
MAX_VISION_LABELS = 50;
|
|
@@ -171713,7 +171825,7 @@ var MCP_SERVER_INFO_META_KEY = "io.modelcontextprotocol/serverInfo";
|
|
|
171713
171825
|
function getMcpServerInfo() {
|
|
171714
171826
|
return {
|
|
171715
171827
|
name: "memorix",
|
|
171716
|
-
version: true ? "1.10.
|
|
171828
|
+
version: true ? "1.10.3" : "1.0.1"
|
|
171717
171829
|
};
|
|
171718
171830
|
}
|
|
171719
171831
|
function createMcpDiscoverResult(capabilities, serverInfo) {
|
|
@@ -173004,7 +173116,7 @@ _Search mode: ${result.receipt.mode}_`;
|
|
|
173004
173116
|
inputSchema: {
|
|
173005
173117
|
task: z627.string().optional().describe("Current coding task or question"),
|
|
173006
173118
|
taskId: z627.string().max(120).optional().describe("Optional task continuity ledger id to include in the brief"),
|
|
173007
|
-
refresh: z627.enum(["auto", "always", "never"]).optional().
|
|
173119
|
+
refresh: z627.enum(["auto", "always", "never"]).optional().describe(
|
|
173008
173120
|
"Code Memory refresh policy. auto refreshes only when missing or stale."
|
|
173009
173121
|
),
|
|
173010
173122
|
format: z627.enum(["prompt", "summary", "json", "receipt"]).optional().default("prompt").describe(
|
|
@@ -173060,7 +173172,7 @@ _Search mode: ${result.receipt.mode}_`;
|
|
|
173060
173172
|
task,
|
|
173061
173173
|
taskId,
|
|
173062
173174
|
agent,
|
|
173063
|
-
refresh
|
|
173175
|
+
...refresh ? { refresh } : {},
|
|
173064
173176
|
reader: getObservationReader(),
|
|
173065
173177
|
enqueueRefresh: () => {
|
|
173066
173178
|
enqueueCodegraphRefresh2({
|
|
@@ -175253,9 +175365,9 @@ ${json2}
|
|
|
175253
175365
|
req.end();
|
|
175254
175366
|
});
|
|
175255
175367
|
const projectUrl = `${url}?project=${encodeURIComponent(project.id)}`;
|
|
175256
|
-
const { exec
|
|
175368
|
+
const { exec } = await import("child_process");
|
|
175257
175369
|
const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
|
|
175258
|
-
|
|
175370
|
+
exec(cmd, { windowsHide: true }, () => {
|
|
175259
175371
|
});
|
|
175260
175372
|
return {
|
|
175261
175373
|
content: [{
|
|
@@ -175304,9 +175416,9 @@ ${json2}
|
|
|
175304
175416
|
req.end();
|
|
175305
175417
|
});
|
|
175306
175418
|
const projectUrl = `${url}?project=${encodeURIComponent(project.id)}`;
|
|
175307
|
-
const { exec
|
|
175419
|
+
const { exec } = await import("child_process");
|
|
175308
175420
|
const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
|
|
175309
|
-
|
|
175421
|
+
exec(cmd, { windowsHide: true }, () => {
|
|
175310
175422
|
});
|
|
175311
175423
|
return {
|
|
175312
175424
|
content: [{ type: "text", text: `Dashboard is already running at ${url}. Switched to project: ${project.name} (${project.id}).` }]
|
package/dist/types.d.ts
CHANGED
|
@@ -608,7 +608,7 @@ interface MemoryRef {
|
|
|
608
608
|
/** MCP config format adapter interface */
|
|
609
609
|
interface MCPConfigAdapter {
|
|
610
610
|
/** Setup-only adapters may support a host that does not participate in workspace sync. */
|
|
611
|
-
readonly source: AgentTarget | 'codebuddy' | 'dsh' | 'workbuddy' | 'grok';
|
|
611
|
+
readonly source: AgentTarget | 'codebuddy' | 'dsh' | 'workbuddy' | 'grok' | 'pi';
|
|
612
612
|
/** Parse MCP server entries from a config file */
|
|
613
613
|
parse(content: string): MCPServerEntry[];
|
|
614
614
|
/** Generate config file content from MCP server entries */
|