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
|
@@ -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
|
};
|
|
@@ -8264,10 +8268,18 @@ __export(orama_store_exports, {
|
|
|
8264
8268
|
queueSemanticVector: () => queueSemanticVector,
|
|
8265
8269
|
removeObservation: () => removeObservation,
|
|
8266
8270
|
resetDb: () => resetDb,
|
|
8271
|
+
resolveSearchFuzzyTolerance: () => resolveSearchFuzzyTolerance,
|
|
8267
8272
|
searchObservations: () => searchObservations,
|
|
8268
8273
|
updateObservationMetadata: () => updateObservationMetadata
|
|
8269
8274
|
});
|
|
8270
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
|
+
}
|
|
8271
8283
|
function rememberSearchMode(key, value) {
|
|
8272
8284
|
if (!lastSearchModeByProject.has(key) && lastSearchModeByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
8273
8285
|
const oldest = lastSearchModeByProject.keys().next().value;
|
|
@@ -8913,7 +8925,10 @@ async function searchObservations(options) {
|
|
|
8913
8925
|
// Fuzzy tolerance: allow 1-char typos for short queries, 2 for longer
|
|
8914
8926
|
// Fuzzy matching is useful for ordinary recall, but grows sharply with
|
|
8915
8927
|
// corpus size. The fast profile deliberately uses exact lexical matching.
|
|
8916
|
-
...hasQuery
|
|
8928
|
+
...hasQuery ? (() => {
|
|
8929
|
+
const tolerance = resolveSearchFuzzyTolerance(originalQuery, quality);
|
|
8930
|
+
return tolerance === void 0 ? {} : { tolerance };
|
|
8931
|
+
})() : {}
|
|
8917
8932
|
};
|
|
8918
8933
|
let queryVector = null;
|
|
8919
8934
|
let embeddingProviderForSearch = null;
|
|
@@ -9144,14 +9159,16 @@ async function searchObservations(options) {
|
|
|
9144
9159
|
filesModified: doc.filesModified?.split?.("\n") ?? (Array.isArray(doc.filesModified) ? doc.filesModified : [])
|
|
9145
9160
|
});
|
|
9146
9161
|
}
|
|
9162
|
+
const topScore = Math.max(...intermediate.map((entry) => entry.score));
|
|
9163
|
+
const affinityTieWindow = topScore * 0.92;
|
|
9147
9164
|
intermediate = intermediate.map((entry) => {
|
|
9148
9165
|
const memory = memoryContentMap.get(entry.id);
|
|
9149
9166
|
if (!memory) return entry;
|
|
9150
9167
|
const { score: affinityScore } = calculateProjectAffinity(memory, affinityContext);
|
|
9168
|
+
if (entry.score < affinityTieWindow) return entry;
|
|
9151
9169
|
return {
|
|
9152
9170
|
...entry,
|
|
9153
|
-
score: entry.score * affinityScore
|
|
9154
|
-
// Apply affinity as multiplier
|
|
9171
|
+
score: entry.score * (0.98 + affinityScore * 0.02)
|
|
9155
9172
|
};
|
|
9156
9173
|
});
|
|
9157
9174
|
intermediate.sort((a, b) => b.score - a.score);
|
|
@@ -146849,6 +146866,7 @@ var init_store = __esm({
|
|
|
146849
146866
|
recordCodeStateSnapshot(input) {
|
|
146850
146867
|
const id = randomUUID11();
|
|
146851
146868
|
let snapshot;
|
|
146869
|
+
let compactNeeded = false;
|
|
146852
146870
|
const tx = this.db.transaction(() => {
|
|
146853
146871
|
const previous = this.db.prepare(
|
|
146854
146872
|
"SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1"
|
|
@@ -146892,6 +146910,26 @@ var init_store = __esm({
|
|
|
146892
146910
|
for (const file of snapshotFileRows) {
|
|
146893
146911
|
insertSnapshotFile.run(id, file.projectId, file.id, file.path, file.contentHash);
|
|
146894
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
|
+
}
|
|
146895
146933
|
snapshot = {
|
|
146896
146934
|
...input,
|
|
146897
146935
|
id,
|
|
@@ -146900,11 +146938,24 @@ var init_store = __esm({
|
|
|
146900
146938
|
};
|
|
146901
146939
|
});
|
|
146902
146940
|
tx();
|
|
146941
|
+
if (compactNeeded) this.compactStorage();
|
|
146903
146942
|
return snapshot;
|
|
146904
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
|
+
}
|
|
146905
146955
|
status(projectId) {
|
|
146906
146956
|
const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
|
|
146907
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;
|
|
146908
146959
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
146909
146960
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
146910
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;
|
|
@@ -146912,6 +146963,8 @@ var init_store = __esm({
|
|
|
146912
146963
|
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
146913
146964
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
146914
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;
|
|
146915
146968
|
return {
|
|
146916
146969
|
provider: "lite",
|
|
146917
146970
|
files,
|
|
@@ -146921,6 +146974,9 @@ var init_store = __esm({
|
|
|
146921
146974
|
semanticSymbols,
|
|
146922
146975
|
semanticEdges,
|
|
146923
146976
|
parserErrors,
|
|
146977
|
+
staleSymbols,
|
|
146978
|
+
snapshots,
|
|
146979
|
+
snapshotFiles,
|
|
146924
146980
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
146925
146981
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
146926
146982
|
};
|
|
@@ -151246,10 +151302,22 @@ function resetObservationRuntime() {
|
|
|
151246
151302
|
loadedObservationStore = null;
|
|
151247
151303
|
embeddingWriteMode = "background";
|
|
151248
151304
|
embeddingWorkerProjectRoot = void 0;
|
|
151249
|
-
|
|
151305
|
+
clearVectorMissingIds();
|
|
151250
151306
|
vectorSchemaUpgradePromise = null;
|
|
151251
151307
|
embeddingFailureLogTimestamps.clear();
|
|
151252
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
|
+
}
|
|
151253
151321
|
function logEmbeddingFailureOnce(key, message) {
|
|
151254
151322
|
const now3 = Date.now();
|
|
151255
151323
|
const last = embeddingFailureLogTimestamps.get(key) ?? 0;
|
|
@@ -151369,10 +151437,13 @@ function isVectorCompatibleWithCurrentIndex(embedding) {
|
|
|
151369
151437
|
}
|
|
151370
151438
|
async function upgradeVectorSchemaAfterFirstEmbedding(embedding) {
|
|
151371
151439
|
if (isVectorCompatibleWithCurrentIndex(embedding)) return true;
|
|
151372
|
-
if (
|
|
151440
|
+
if (!embedding.every(Number.isFinite)) return false;
|
|
151373
151441
|
const targetProjectDir = projectDir;
|
|
151374
151442
|
if (!vectorSchemaUpgradePromise) {
|
|
151375
|
-
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(() => {
|
|
151376
151447
|
vectorSchemaUpgradePromise = null;
|
|
151377
151448
|
});
|
|
151378
151449
|
}
|
|
@@ -151412,9 +151483,9 @@ async function initObservations(dir, options = {}) {
|
|
|
151412
151483
|
}
|
|
151413
151484
|
function scheduleObservationEmbedding(input) {
|
|
151414
151485
|
const { observationId: observationId2, projectId, searchableText, doc } = input;
|
|
151415
|
-
|
|
151486
|
+
markVectorMissing(observationId2, projectId);
|
|
151416
151487
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
151417
|
-
|
|
151488
|
+
clearVectorMissing(observationId2);
|
|
151418
151489
|
return;
|
|
151419
151490
|
}
|
|
151420
151491
|
if (embeddingWriteMode === "deferred") {
|
|
@@ -151449,13 +151520,13 @@ function scheduleObservationEmbedding(input) {
|
|
|
151449
151520
|
vector: embedding
|
|
151450
151521
|
});
|
|
151451
151522
|
}
|
|
151452
|
-
|
|
151523
|
+
clearVectorMissing(observationId2);
|
|
151453
151524
|
} catch {
|
|
151454
151525
|
console.error(`[memorix] Embedding index update failed for obs-${observationId2} (kept in backfill queue)`);
|
|
151455
151526
|
queueVectorBackfill(projectId);
|
|
151456
151527
|
}
|
|
151457
151528
|
} else if (isEmbeddingExplicitlyDisabled()) {
|
|
151458
|
-
|
|
151529
|
+
clearVectorMissing(observationId2);
|
|
151459
151530
|
} else {
|
|
151460
151531
|
queueVectorBackfill(projectId);
|
|
151461
151532
|
logEmbeddingFailureOnce(
|
|
@@ -152015,7 +152086,7 @@ async function reindexObservations() {
|
|
|
152015
152086
|
if (observations.length === 0) return 0;
|
|
152016
152087
|
await resetDb();
|
|
152017
152088
|
searchIndexPrepared = false;
|
|
152018
|
-
|
|
152089
|
+
clearVectorMissingIds();
|
|
152019
152090
|
let embeddings = observations.map(() => null);
|
|
152020
152091
|
const provider2 = await getEmbeddingProvider();
|
|
152021
152092
|
const canBatchEmbedAtStartup = provider2 !== null && !provider2.name.startsWith("api-");
|
|
@@ -152080,7 +152151,7 @@ async function reindexObservations() {
|
|
|
152080
152151
|
};
|
|
152081
152152
|
await insertObservation(doc);
|
|
152082
152153
|
if (!compatibleEmbedding && !isEmbeddingExplicitlyDisabled()) {
|
|
152083
|
-
|
|
152154
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
152084
152155
|
}
|
|
152085
152156
|
count2++;
|
|
152086
152157
|
} catch (err) {
|
|
@@ -152097,7 +152168,17 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152097
152168
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
152098
152169
|
const store = getObservationStore();
|
|
152099
152170
|
const projects = await store.listProjectIds?.() ?? [];
|
|
152100
|
-
|
|
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
|
+
}
|
|
152101
152182
|
}
|
|
152102
152183
|
return 0;
|
|
152103
152184
|
}
|
|
@@ -152111,13 +152192,13 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152111
152192
|
const hydratedProjectDir = projectDir;
|
|
152112
152193
|
const queueMissingVectors = async () => {
|
|
152113
152194
|
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
152114
|
-
|
|
152195
|
+
clearVectorMissingIds();
|
|
152115
152196
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
152116
152197
|
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
152117
152198
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
152118
152199
|
for (const obs of observations) {
|
|
152119
152200
|
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
152120
|
-
|
|
152201
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
152121
152202
|
projectsWithMissingVectors.add(obs.projectId);
|
|
152122
152203
|
}
|
|
152123
152204
|
}
|
|
@@ -152135,6 +152216,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152135
152216
|
}
|
|
152136
152217
|
function getVectorMissingIds(projectId) {
|
|
152137
152218
|
if (!projectId) return [...vectorMissingIds];
|
|
152219
|
+
if (!corpusLoaded) {
|
|
152220
|
+
return [...vectorMissingIds].filter((id) => vectorMissingProjectIds.get(id) === projectId);
|
|
152221
|
+
}
|
|
152138
152222
|
const observationById = new Map(observations.map((observation) => [observation.id, observation]));
|
|
152139
152223
|
return [...vectorMissingIds].filter((id) => observationById.get(id)?.projectId === projectId);
|
|
152140
152224
|
}
|
|
@@ -152172,7 +152256,8 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152172
152256
|
return { attempted: 0, succeeded: 0, failed: 0 };
|
|
152173
152257
|
}
|
|
152174
152258
|
vectorBackfillRunning = true;
|
|
152175
|
-
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]));
|
|
152176
152261
|
const limit2 = Number.isFinite(options.limit) ? Math.max(1, Math.floor(options.limit)) : Number.POSITIVE_INFINITY;
|
|
152177
152262
|
const ids = [...vectorMissingIds].filter((id) => !options.projectId || observationById.get(id)?.projectId === options.projectId).slice(0, limit2);
|
|
152178
152263
|
let succeeded = 0;
|
|
@@ -152185,7 +152270,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152185
152270
|
for (const id of ids) {
|
|
152186
152271
|
const observation = observationById.get(id);
|
|
152187
152272
|
if (!observation) {
|
|
152188
|
-
|
|
152273
|
+
clearVectorMissing(id);
|
|
152189
152274
|
continue;
|
|
152190
152275
|
}
|
|
152191
152276
|
candidates.push({
|
|
@@ -152203,7 +152288,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152203
152288
|
const provider2 = await getEmbeddingProvider();
|
|
152204
152289
|
if (!provider2) {
|
|
152205
152290
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
152206
|
-
for (const candidate of candidates)
|
|
152291
|
+
for (const candidate of candidates) clearVectorMissing(candidate.id);
|
|
152207
152292
|
} else {
|
|
152208
152293
|
recordFailure("embedding provider unavailable");
|
|
152209
152294
|
failed += candidates.length;
|
|
@@ -152280,7 +152365,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152280
152365
|
vector: embedding
|
|
152281
152366
|
});
|
|
152282
152367
|
}
|
|
152283
|
-
|
|
152368
|
+
clearVectorMissing(id);
|
|
152284
152369
|
succeeded++;
|
|
152285
152370
|
} catch (error) {
|
|
152286
152371
|
recordFailure(vectorBackfillError(error));
|
|
@@ -152305,7 +152390,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152305
152390
|
...lastFailure ? { lastError: lastFailure } : {}
|
|
152306
152391
|
};
|
|
152307
152392
|
}
|
|
152308
|
-
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;
|
|
152309
152394
|
var init_observations = __esm({
|
|
152310
152395
|
"src/memory/observations.ts"() {
|
|
152311
152396
|
"use strict";
|
|
@@ -152330,6 +152415,7 @@ var init_observations = __esm({
|
|
|
152330
152415
|
loadedObservationStore = null;
|
|
152331
152416
|
DEFAULT_ORAMA_HYDRATION_THRESHOLD = 1e4;
|
|
152332
152417
|
vectorMissingIds = /* @__PURE__ */ new Set();
|
|
152418
|
+
vectorMissingProjectIds = /* @__PURE__ */ new Map();
|
|
152333
152419
|
vectorBackfillRunning = false;
|
|
152334
152420
|
vectorSchemaUpgradePromise = null;
|
|
152335
152421
|
lastVectorBackfill = null;
|