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
|
@@ -2113,7 +2113,8 @@ function getResolvedConfig(options = {}) {
|
|
|
2113
2113
|
const isRequesty = memoryLlmProvider === "requesty";
|
|
2114
2114
|
const isApiRoute = memoryLlmProvider === "apiroute";
|
|
2115
2115
|
const isCheaperInference = memoryLlmProvider === "cheaperinference";
|
|
2116
|
-
const
|
|
2116
|
+
const isRuncrate = memoryLlmProvider === "runcrate";
|
|
2117
|
+
const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference || isRuncrate;
|
|
2117
2118
|
const memoryLlmApiKey = first(
|
|
2118
2119
|
process.env.MEMORIX_LLM_API_KEY,
|
|
2119
2120
|
process.env.MEMORIX_API_KEY,
|
|
@@ -2121,7 +2122,7 @@ function getResolvedConfig(options = {}) {
|
|
|
2121
2122
|
yaml.llm?.apiKey,
|
|
2122
2123
|
legacy.llm?.apiKey,
|
|
2123
2124
|
// Never borrow another provider's credentials for these gateway presets.
|
|
2124
|
-
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,
|
|
2125
|
+
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,
|
|
2125
2126
|
usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
|
|
2126
2127
|
usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
|
|
2127
2128
|
);
|
|
@@ -2192,6 +2193,7 @@ function getResolvedConfig(options = {}) {
|
|
|
2192
2193
|
codegraph: {
|
|
2193
2194
|
excludePatterns: firstArray(toml.codegraph?.exclude_patterns, yaml.codegraph?.excludePatterns),
|
|
2194
2195
|
maxFileBytes: firstNumber(toml.codegraph?.max_file_bytes, yaml.codegraph?.maxFileBytes),
|
|
2196
|
+
autoRefresh: first(toml.codegraph?.auto_refresh, yaml.codegraph?.autoRefresh, "auto"),
|
|
2195
2197
|
externalContext: first(
|
|
2196
2198
|
normalizeExternalContext(process.env.MEMORIX_CODEGRAPH_EXTERNAL_CONTEXT),
|
|
2197
2199
|
toml.codegraph?.external_context,
|
|
@@ -2306,6 +2308,7 @@ function getEnvSourceNames() {
|
|
|
2306
2308
|
"REQUESTY_API_KEY",
|
|
2307
2309
|
"API_ROUTE_API_KEY",
|
|
2308
2310
|
"CHEAPER_INFERENCE_API_KEY",
|
|
2311
|
+
"RUNCRATE_API_KEY",
|
|
2309
2312
|
"ATLASCLOUD_API_KEY"
|
|
2310
2313
|
].filter((name) => process.env[name]);
|
|
2311
2314
|
}
|
|
@@ -3152,6 +3155,7 @@ var init_provider = __esm({
|
|
|
3152
3155
|
requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
|
|
3153
3156
|
apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
|
|
3154
3157
|
cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
|
|
3158
|
+
runcrate: { baseUrl: "https://api.runcrate.ai/v1", model: "deepseek-ai/DeepSeek-V4.1-Flash" },
|
|
3155
3159
|
atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
|
|
3156
3160
|
custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
|
|
3157
3161
|
};
|
|
@@ -7303,10 +7307,18 @@ __export(orama_store_exports, {
|
|
|
7303
7307
|
queueSemanticVector: () => queueSemanticVector,
|
|
7304
7308
|
removeObservation: () => removeObservation,
|
|
7305
7309
|
resetDb: () => resetDb,
|
|
7310
|
+
resolveSearchFuzzyTolerance: () => resolveSearchFuzzyTolerance,
|
|
7306
7311
|
searchObservations: () => searchObservations,
|
|
7307
7312
|
updateObservationMetadata: () => updateObservationMetadata
|
|
7308
7313
|
});
|
|
7309
7314
|
import { components, create, insert as insert2, insertMultiple, search, remove as remove2, update, count, getByID } from "@orama/orama";
|
|
7315
|
+
function resolveSearchFuzzyTolerance(query, quality) {
|
|
7316
|
+
if (quality === "fast") return void 0;
|
|
7317
|
+
const characters = [...query];
|
|
7318
|
+
const cjkCount = characters.filter((char) => /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]/u.test(char)).length;
|
|
7319
|
+
if (characters.length > 0 && cjkCount / characters.length > 0.3) return void 0;
|
|
7320
|
+
return query.length > 6 ? 2 : 1;
|
|
7321
|
+
}
|
|
7310
7322
|
function rememberSearchMode(key, value) {
|
|
7311
7323
|
if (!lastSearchModeByProject.has(key) && lastSearchModeByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
7312
7324
|
const oldest = lastSearchModeByProject.keys().next().value;
|
|
@@ -7952,7 +7964,10 @@ async function searchObservations(options) {
|
|
|
7952
7964
|
// Fuzzy tolerance: allow 1-char typos for short queries, 2 for longer
|
|
7953
7965
|
// Fuzzy matching is useful for ordinary recall, but grows sharply with
|
|
7954
7966
|
// corpus size. The fast profile deliberately uses exact lexical matching.
|
|
7955
|
-
...hasQuery
|
|
7967
|
+
...hasQuery ? (() => {
|
|
7968
|
+
const tolerance = resolveSearchFuzzyTolerance(originalQuery, quality);
|
|
7969
|
+
return tolerance === void 0 ? {} : { tolerance };
|
|
7970
|
+
})() : {}
|
|
7956
7971
|
};
|
|
7957
7972
|
let queryVector = null;
|
|
7958
7973
|
let embeddingProviderForSearch = null;
|
|
@@ -8183,14 +8198,16 @@ async function searchObservations(options) {
|
|
|
8183
8198
|
filesModified: doc.filesModified?.split?.("\n") ?? (Array.isArray(doc.filesModified) ? doc.filesModified : [])
|
|
8184
8199
|
});
|
|
8185
8200
|
}
|
|
8201
|
+
const topScore = Math.max(...intermediate.map((entry) => entry.score));
|
|
8202
|
+
const affinityTieWindow = topScore * 0.92;
|
|
8186
8203
|
intermediate = intermediate.map((entry) => {
|
|
8187
8204
|
const memory = memoryContentMap.get(entry.id);
|
|
8188
8205
|
if (!memory) return entry;
|
|
8189
8206
|
const { score: affinityScore } = calculateProjectAffinity(memory, affinityContext);
|
|
8207
|
+
if (entry.score < affinityTieWindow) return entry;
|
|
8190
8208
|
return {
|
|
8191
8209
|
...entry,
|
|
8192
|
-
score: entry.score * affinityScore
|
|
8193
|
-
// Apply affinity as multiplier
|
|
8210
|
+
score: entry.score * (0.98 + affinityScore * 0.02)
|
|
8194
8211
|
};
|
|
8195
8212
|
});
|
|
8196
8213
|
intermediate.sort((a, b) => b.score - a.score);
|
|
@@ -147218,6 +147235,7 @@ var init_store = __esm({
|
|
|
147218
147235
|
recordCodeStateSnapshot(input) {
|
|
147219
147236
|
const id = randomUUID11();
|
|
147220
147237
|
let snapshot;
|
|
147238
|
+
let compactNeeded = false;
|
|
147221
147239
|
const tx = this.db.transaction(() => {
|
|
147222
147240
|
const previous = this.db.prepare(
|
|
147223
147241
|
"SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1"
|
|
@@ -147261,6 +147279,26 @@ var init_store = __esm({
|
|
|
147261
147279
|
for (const file of snapshotFileRows) {
|
|
147262
147280
|
insertSnapshotFile.run(id, file.projectId, file.id, file.path, file.contentHash);
|
|
147263
147281
|
}
|
|
147282
|
+
const staleSymbolIds = this.db.prepare(
|
|
147283
|
+
"SELECT id FROM code_symbols WHERE projectId = ? AND stale = 1"
|
|
147284
|
+
).all(input.projectId).map((row) => row.id);
|
|
147285
|
+
if (staleSymbolIds.length > 0) {
|
|
147286
|
+
const placeholders = staleSymbolIds.map(() => "?").join(", ");
|
|
147287
|
+
this.db.prepare(
|
|
147288
|
+
`DELETE FROM code_edges WHERE projectId = ? AND (fromSymbolId IN (${placeholders}) OR toSymbolId IN (${placeholders}))`
|
|
147289
|
+
).run(input.projectId, ...staleSymbolIds, ...staleSymbolIds);
|
|
147290
|
+
this.db.prepare("DELETE FROM code_symbols WHERE projectId = ? AND stale = 1").run(input.projectId);
|
|
147291
|
+
compactNeeded = true;
|
|
147292
|
+
}
|
|
147293
|
+
const oldSnapshots = this.db.prepare(
|
|
147294
|
+
"SELECT id FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT -1 OFFSET 2"
|
|
147295
|
+
).all(input.projectId).map((row) => row.id);
|
|
147296
|
+
if (oldSnapshots.length > 0) {
|
|
147297
|
+
const placeholders = oldSnapshots.map(() => "?").join(", ");
|
|
147298
|
+
this.db.prepare(`DELETE FROM code_state_snapshot_files WHERE snapshotId IN (${placeholders})`).run(...oldSnapshots);
|
|
147299
|
+
this.db.prepare(`DELETE FROM code_state_snapshots WHERE id IN (${placeholders})`).run(...oldSnapshots);
|
|
147300
|
+
compactNeeded = true;
|
|
147301
|
+
}
|
|
147264
147302
|
snapshot = {
|
|
147265
147303
|
...input,
|
|
147266
147304
|
id,
|
|
@@ -147269,11 +147307,24 @@ var init_store = __esm({
|
|
|
147269
147307
|
};
|
|
147270
147308
|
});
|
|
147271
147309
|
tx();
|
|
147310
|
+
if (compactNeeded) this.compactStorage();
|
|
147272
147311
|
return snapshot;
|
|
147273
147312
|
}
|
|
147313
|
+
/** Reclaim WAL/free pages after a derived codegraph sweep. */
|
|
147314
|
+
compactStorage() {
|
|
147315
|
+
try {
|
|
147316
|
+
this.db.pragma("wal_checkpoint(TRUNCATE)");
|
|
147317
|
+
} catch {
|
|
147318
|
+
}
|
|
147319
|
+
try {
|
|
147320
|
+
this.db.exec("VACUUM");
|
|
147321
|
+
} catch {
|
|
147322
|
+
}
|
|
147323
|
+
}
|
|
147274
147324
|
status(projectId) {
|
|
147275
147325
|
const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
|
|
147276
147326
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
147327
|
+
const staleSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 1`).get(projectId).count;
|
|
147277
147328
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
147278
147329
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
147279
147330
|
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
@@ -147281,6 +147332,8 @@ var init_store = __esm({
|
|
|
147281
147332
|
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
147282
147333
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
147283
147334
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
147335
|
+
const snapshots = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshots WHERE projectId = ?`).get(projectId).count;
|
|
147336
|
+
const snapshotFiles = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshot_files WHERE projectId = ?`).get(projectId).count;
|
|
147284
147337
|
return {
|
|
147285
147338
|
provider: "lite",
|
|
147286
147339
|
files,
|
|
@@ -147290,6 +147343,9 @@ var init_store = __esm({
|
|
|
147290
147343
|
semanticSymbols,
|
|
147291
147344
|
semanticEdges,
|
|
147292
147345
|
parserErrors,
|
|
147346
|
+
staleSymbols,
|
|
147347
|
+
snapshots,
|
|
147348
|
+
snapshotFiles,
|
|
147293
147349
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
147294
147350
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
147295
147351
|
};
|
|
@@ -151615,10 +151671,22 @@ function resetObservationRuntime() {
|
|
|
151615
151671
|
loadedObservationStore = null;
|
|
151616
151672
|
embeddingWriteMode = "background";
|
|
151617
151673
|
embeddingWorkerProjectRoot = void 0;
|
|
151618
|
-
|
|
151674
|
+
clearVectorMissingIds();
|
|
151619
151675
|
vectorSchemaUpgradePromise = null;
|
|
151620
151676
|
embeddingFailureLogTimestamps.clear();
|
|
151621
151677
|
}
|
|
151678
|
+
function markVectorMissing(observationId2, projectId) {
|
|
151679
|
+
vectorMissingIds.add(observationId2);
|
|
151680
|
+
vectorMissingProjectIds.set(observationId2, projectId);
|
|
151681
|
+
}
|
|
151682
|
+
function clearVectorMissing(observationId2) {
|
|
151683
|
+
vectorMissingIds.delete(observationId2);
|
|
151684
|
+
vectorMissingProjectIds.delete(observationId2);
|
|
151685
|
+
}
|
|
151686
|
+
function clearVectorMissingIds() {
|
|
151687
|
+
vectorMissingIds.clear();
|
|
151688
|
+
vectorMissingProjectIds.clear();
|
|
151689
|
+
}
|
|
151622
151690
|
function logEmbeddingFailureOnce(key, message) {
|
|
151623
151691
|
const now3 = Date.now();
|
|
151624
151692
|
const last = embeddingFailureLogTimestamps.get(key) ?? 0;
|
|
@@ -151738,10 +151806,13 @@ function isVectorCompatibleWithCurrentIndex(embedding) {
|
|
|
151738
151806
|
}
|
|
151739
151807
|
async function upgradeVectorSchemaAfterFirstEmbedding(embedding) {
|
|
151740
151808
|
if (isVectorCompatibleWithCurrentIndex(embedding)) return true;
|
|
151741
|
-
if (
|
|
151809
|
+
if (!embedding.every(Number.isFinite)) return false;
|
|
151742
151810
|
const targetProjectDir = projectDir;
|
|
151743
151811
|
if (!vectorSchemaUpgradePromise) {
|
|
151744
|
-
vectorSchemaUpgradePromise =
|
|
151812
|
+
vectorSchemaUpgradePromise = getDb().then(async () => {
|
|
151813
|
+
if (getVectorDimensions() === null && observations.length > 0) await reindexObservations();
|
|
151814
|
+
return projectDir === targetProjectDir && isVectorCompatibleWithCurrentIndex(embedding);
|
|
151815
|
+
}).catch(() => false).finally(() => {
|
|
151745
151816
|
vectorSchemaUpgradePromise = null;
|
|
151746
151817
|
});
|
|
151747
151818
|
}
|
|
@@ -151781,9 +151852,9 @@ async function initObservations(dir, options = {}) {
|
|
|
151781
151852
|
}
|
|
151782
151853
|
function scheduleObservationEmbedding(input) {
|
|
151783
151854
|
const { observationId: observationId2, projectId, searchableText, doc } = input;
|
|
151784
|
-
|
|
151855
|
+
markVectorMissing(observationId2, projectId);
|
|
151785
151856
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
151786
|
-
|
|
151857
|
+
clearVectorMissing(observationId2);
|
|
151787
151858
|
return;
|
|
151788
151859
|
}
|
|
151789
151860
|
if (embeddingWriteMode === "deferred") {
|
|
@@ -151818,13 +151889,13 @@ function scheduleObservationEmbedding(input) {
|
|
|
151818
151889
|
vector: embedding
|
|
151819
151890
|
});
|
|
151820
151891
|
}
|
|
151821
|
-
|
|
151892
|
+
clearVectorMissing(observationId2);
|
|
151822
151893
|
} catch {
|
|
151823
151894
|
console.error(`[memorix] Embedding index update failed for obs-${observationId2} (kept in backfill queue)`);
|
|
151824
151895
|
queueVectorBackfill(projectId);
|
|
151825
151896
|
}
|
|
151826
151897
|
} else if (isEmbeddingExplicitlyDisabled()) {
|
|
151827
|
-
|
|
151898
|
+
clearVectorMissing(observationId2);
|
|
151828
151899
|
} else {
|
|
151829
151900
|
queueVectorBackfill(projectId);
|
|
151830
151901
|
logEmbeddingFailureOnce(
|
|
@@ -152384,7 +152455,7 @@ async function reindexObservations() {
|
|
|
152384
152455
|
if (observations.length === 0) return 0;
|
|
152385
152456
|
await resetDb();
|
|
152386
152457
|
searchIndexPrepared = false;
|
|
152387
|
-
|
|
152458
|
+
clearVectorMissingIds();
|
|
152388
152459
|
let embeddings = observations.map(() => null);
|
|
152389
152460
|
const provider2 = await getEmbeddingProvider();
|
|
152390
152461
|
const canBatchEmbedAtStartup = provider2 !== null && !provider2.name.startsWith("api-");
|
|
@@ -152449,7 +152520,7 @@ async function reindexObservations() {
|
|
|
152449
152520
|
};
|
|
152450
152521
|
await insertObservation(doc);
|
|
152451
152522
|
if (!compatibleEmbedding && !isEmbeddingExplicitlyDisabled()) {
|
|
152452
|
-
|
|
152523
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
152453
152524
|
}
|
|
152454
152525
|
count2++;
|
|
152455
152526
|
} catch (err) {
|
|
@@ -152466,7 +152537,17 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152466
152537
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
152467
152538
|
const store = getObservationStore();
|
|
152468
152539
|
const projects = await store.listProjectIds?.() ?? [];
|
|
152469
|
-
|
|
152540
|
+
await getDb({ allowNetworkProbe: false }).catch(() => void 0);
|
|
152541
|
+
const persistedIds = projectDir ? await getPersistentSemanticVectorIds(projectDir).catch(() => null) : null;
|
|
152542
|
+
for (const projectId of projects) {
|
|
152543
|
+
const projectObservations = await store.loadByProject(projectId);
|
|
152544
|
+
for (const observation of projectObservations) {
|
|
152545
|
+
if (!persistedIds?.has(observation.id)) markVectorMissing(observation.id, observation.projectId);
|
|
152546
|
+
}
|
|
152547
|
+
if (projectObservations.some((observation) => !persistedIds?.has(observation.id))) {
|
|
152548
|
+
queueVectorBackfill(projectId);
|
|
152549
|
+
}
|
|
152550
|
+
}
|
|
152470
152551
|
}
|
|
152471
152552
|
return 0;
|
|
152472
152553
|
}
|
|
@@ -152480,13 +152561,13 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152480
152561
|
const hydratedProjectDir = projectDir;
|
|
152481
152562
|
const queueMissingVectors = async () => {
|
|
152482
152563
|
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
152483
|
-
|
|
152564
|
+
clearVectorMissingIds();
|
|
152484
152565
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
152485
152566
|
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
152486
152567
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
152487
152568
|
for (const obs of observations) {
|
|
152488
152569
|
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
152489
|
-
|
|
152570
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
152490
152571
|
projectsWithMissingVectors.add(obs.projectId);
|
|
152491
152572
|
}
|
|
152492
152573
|
}
|
|
@@ -152504,6 +152585,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
152504
152585
|
}
|
|
152505
152586
|
function getVectorMissingIds(projectId) {
|
|
152506
152587
|
if (!projectId) return [...vectorMissingIds];
|
|
152588
|
+
if (!corpusLoaded) {
|
|
152589
|
+
return [...vectorMissingIds].filter((id) => vectorMissingProjectIds.get(id) === projectId);
|
|
152590
|
+
}
|
|
152507
152591
|
const observationById = new Map(observations.map((observation) => [observation.id, observation]));
|
|
152508
152592
|
return [...vectorMissingIds].filter((id) => observationById.get(id)?.projectId === projectId);
|
|
152509
152593
|
}
|
|
@@ -152541,7 +152625,8 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152541
152625
|
return { attempted: 0, succeeded: 0, failed: 0 };
|
|
152542
152626
|
}
|
|
152543
152627
|
vectorBackfillRunning = true;
|
|
152544
|
-
const
|
|
152628
|
+
const sourceObservations = corpusLoaded ? observations : options.projectId ? await getObservationStore().loadByProject(options.projectId, { status: "active" }) : await getObservationStore().loadAll();
|
|
152629
|
+
const observationById = new Map(sourceObservations.map((observation) => [observation.id, observation]));
|
|
152545
152630
|
const limit2 = Number.isFinite(options.limit) ? Math.max(1, Math.floor(options.limit)) : Number.POSITIVE_INFINITY;
|
|
152546
152631
|
const ids = [...vectorMissingIds].filter((id) => !options.projectId || observationById.get(id)?.projectId === options.projectId).slice(0, limit2);
|
|
152547
152632
|
let succeeded = 0;
|
|
@@ -152554,7 +152639,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152554
152639
|
for (const id of ids) {
|
|
152555
152640
|
const observation = observationById.get(id);
|
|
152556
152641
|
if (!observation) {
|
|
152557
|
-
|
|
152642
|
+
clearVectorMissing(id);
|
|
152558
152643
|
continue;
|
|
152559
152644
|
}
|
|
152560
152645
|
candidates.push({
|
|
@@ -152572,7 +152657,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152572
152657
|
const provider2 = await getEmbeddingProvider();
|
|
152573
152658
|
if (!provider2) {
|
|
152574
152659
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
152575
|
-
for (const candidate of candidates)
|
|
152660
|
+
for (const candidate of candidates) clearVectorMissing(candidate.id);
|
|
152576
152661
|
} else {
|
|
152577
152662
|
recordFailure("embedding provider unavailable");
|
|
152578
152663
|
failed += candidates.length;
|
|
@@ -152649,7 +152734,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152649
152734
|
vector: embedding
|
|
152650
152735
|
});
|
|
152651
152736
|
}
|
|
152652
|
-
|
|
152737
|
+
clearVectorMissing(id);
|
|
152653
152738
|
succeeded++;
|
|
152654
152739
|
} catch (error) {
|
|
152655
152740
|
recordFailure(vectorBackfillError(error));
|
|
@@ -152674,7 +152759,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
152674
152759
|
...lastFailure ? { lastError: lastFailure } : {}
|
|
152675
152760
|
};
|
|
152676
152761
|
}
|
|
152677
|
-
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;
|
|
152762
|
+
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;
|
|
152678
152763
|
var init_observations = __esm({
|
|
152679
152764
|
"src/memory/observations.ts"() {
|
|
152680
152765
|
"use strict";
|
|
@@ -152699,6 +152784,7 @@ var init_observations = __esm({
|
|
|
152699
152784
|
loadedObservationStore = null;
|
|
152700
152785
|
DEFAULT_ORAMA_HYDRATION_THRESHOLD = 1e4;
|
|
152701
152786
|
vectorMissingIds = /* @__PURE__ */ new Set();
|
|
152787
|
+
vectorMissingProjectIds = /* @__PURE__ */ new Map();
|
|
152702
152788
|
vectorBackfillRunning = false;
|
|
152703
152789
|
vectorSchemaUpgradePromise = null;
|
|
152704
152790
|
lastVectorBackfill = null;
|