memorix 1.10.4 → 1.10.5
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 +26 -0
- package/dist/cli/index.js +418 -74
- package/dist/index.js +227 -55
- package/dist/maintenance-runner.js +225 -53
- package/dist/media-audio-runner.js +225 -53
- package/dist/media-video-runner.js +225 -53
- package/dist/memcode-runtime/CHANGELOG.md +44 -0
- package/dist/sdk.js +242 -56
- package/dist/vector-backfill-runner.js +225 -53
- package/docs/AGENT_OPERATOR_PLAYBOOK.md +7 -0
- package/docs/ARCHITECTURE.md +19 -0
- package/docs/CONFIGURATION.md +2 -0
- package/docs/DEVELOPMENT.md +8 -1
- package/docs/MODULES.md +1 -1
- package/docs/PERFORMANCE.md +7 -0
- package/docs/README.md +3 -1
- package/docs/ROADMAP-1.9.12-2.0.md +1 -1
- 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/command-guide.ts +3 -1
- package/src/cli/commands/http-session-stream-watch.ts +138 -0
- package/src/cli/commands/memory.ts +3 -1
- package/src/cli/commands/project-detection-cache.ts +61 -0
- package/src/cli/commands/serve-http.ts +63 -13
- package/src/cli/index.ts +1 -1
- package/src/core/derived-view-registry.ts +33 -0
- package/src/embedding/api-provider.ts +14 -2
- package/src/embedding/ollama-embed.ts +118 -0
- package/src/memory/observations.ts +28 -6
- package/src/search/semantic-index.ts +38 -6
- package/src/store/orama-store.ts +46 -30
|
@@ -3151,6 +3151,96 @@ var init_transformers_provider = __esm({
|
|
|
3151
3151
|
}
|
|
3152
3152
|
});
|
|
3153
3153
|
|
|
3154
|
+
// src/embedding/ollama-embed.ts
|
|
3155
|
+
async function routeOllamaEmbedding(url, body, fetchImpl = fetch, probeOptions) {
|
|
3156
|
+
const parsed = parseUrl(url);
|
|
3157
|
+
if (!parsed) return { url, body, rewritten: false };
|
|
3158
|
+
const openAIRoute = parsed.pathname.endsWith("/v1/embeddings");
|
|
3159
|
+
const nativeRoute = parsed.pathname.endsWith("/api/embed");
|
|
3160
|
+
if (!openAIRoute && !nativeRoute) return { url, body, rewritten: false };
|
|
3161
|
+
if (!await originServesOllama(parsed.origin, fetchImpl, probeOptions)) return { url, body, rewritten: false };
|
|
3162
|
+
if (nativeRoute) return { url, body, rewritten: true };
|
|
3163
|
+
parsed.pathname = parsed.pathname.replace(/\/v1\/embeddings$/, "/api/embed");
|
|
3164
|
+
return { url: parsed.toString(), body: withEmbeddingKeepAlive(body), rewritten: true };
|
|
3165
|
+
}
|
|
3166
|
+
async function originServesOllama(origin, fetchImpl = fetch, probeOptions) {
|
|
3167
|
+
const cached = ollamaOrigins.get(origin);
|
|
3168
|
+
if (cached != null) return cached;
|
|
3169
|
+
if (probeOptions?.signal?.aborted) return false;
|
|
3170
|
+
try {
|
|
3171
|
+
const response = await fetchImpl(`${origin}/api/version`, {
|
|
3172
|
+
method: "GET",
|
|
3173
|
+
signal: buildProbeSignal(probeOptions)
|
|
3174
|
+
});
|
|
3175
|
+
if (!response.ok) {
|
|
3176
|
+
ollamaOrigins.set(origin, false);
|
|
3177
|
+
return false;
|
|
3178
|
+
}
|
|
3179
|
+
const detected = isOllamaVersionPayload(await response.json());
|
|
3180
|
+
ollamaOrigins.set(origin, detected);
|
|
3181
|
+
return detected;
|
|
3182
|
+
} catch (err) {
|
|
3183
|
+
if (isAbortError(err) || probeOptions?.signal?.aborted) return false;
|
|
3184
|
+
ollamaOrigins.set(origin, false);
|
|
3185
|
+
return false;
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
function mapOllamaEmbeddingResponse(payload) {
|
|
3189
|
+
if (!payload || typeof payload !== "object") return payload;
|
|
3190
|
+
const record80 = payload;
|
|
3191
|
+
if (Array.isArray(record80.data) || !Array.isArray(record80.embeddings)) return payload;
|
|
3192
|
+
const embeddings = record80.embeddings.filter((item) => Array.isArray(item));
|
|
3193
|
+
return {
|
|
3194
|
+
...record80,
|
|
3195
|
+
object: "list",
|
|
3196
|
+
data: embeddings.map((embedding, index) => ({
|
|
3197
|
+
object: "embedding",
|
|
3198
|
+
index,
|
|
3199
|
+
embedding
|
|
3200
|
+
}))
|
|
3201
|
+
};
|
|
3202
|
+
}
|
|
3203
|
+
function withEmbeddingKeepAlive(body) {
|
|
3204
|
+
if (body.keep_alive != null && body.keep_alive !== "") return body;
|
|
3205
|
+
return { ...body, keep_alive: OLLAMA_EMBED_KEEP_ALIVE };
|
|
3206
|
+
}
|
|
3207
|
+
function isOllamaVersionPayload(payload) {
|
|
3208
|
+
if (!payload || typeof payload !== "object") return false;
|
|
3209
|
+
const version = payload.version;
|
|
3210
|
+
return typeof version === "string" && /^\d+\.\d+\.\d+/.test(version);
|
|
3211
|
+
}
|
|
3212
|
+
function parseUrl(url) {
|
|
3213
|
+
try {
|
|
3214
|
+
return new URL(url);
|
|
3215
|
+
} catch {
|
|
3216
|
+
return null;
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
function buildProbeSignal(probeOptions) {
|
|
3220
|
+
const timeoutMs = Math.max(
|
|
3221
|
+
1,
|
|
3222
|
+
Math.min(
|
|
3223
|
+
typeof probeOptions?.probeTimeoutMs === "number" && Number.isFinite(probeOptions.probeTimeoutMs) ? Math.floor(probeOptions.probeTimeoutMs) : 1e3,
|
|
3224
|
+
6e4
|
|
3225
|
+
)
|
|
3226
|
+
);
|
|
3227
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
3228
|
+
if (probeOptions?.signal) return AbortSignal.any([probeOptions.signal, timeoutSignal]);
|
|
3229
|
+
return timeoutSignal;
|
|
3230
|
+
}
|
|
3231
|
+
function isAbortError(err) {
|
|
3232
|
+
return err instanceof Error && err.name === "AbortError";
|
|
3233
|
+
}
|
|
3234
|
+
var OLLAMA_EMBED_KEEP_ALIVE, ollamaOrigins;
|
|
3235
|
+
var init_ollama_embed = __esm({
|
|
3236
|
+
"src/embedding/ollama-embed.ts"() {
|
|
3237
|
+
"use strict";
|
|
3238
|
+
init_esm_shims();
|
|
3239
|
+
OLLAMA_EMBED_KEEP_ALIVE = "5m";
|
|
3240
|
+
ollamaOrigins = /* @__PURE__ */ new Map();
|
|
3241
|
+
}
|
|
3242
|
+
});
|
|
3243
|
+
|
|
3154
3244
|
// src/embedding/api-provider.ts
|
|
3155
3245
|
var api_provider_exports = {};
|
|
3156
3246
|
__export(api_provider_exports, {
|
|
@@ -3852,8 +3942,18 @@ function parseBatchLimit(error) {
|
|
|
3852
3942
|
return null;
|
|
3853
3943
|
}
|
|
3854
3944
|
async function fetchWithRetry(url, apiKey, body, options = {}, attempt = 0, nativeGemini = false) {
|
|
3855
|
-
const controller = new AbortController();
|
|
3856
3945
|
const timeoutMs = typeof options.timeoutMs === "number" && Number.isFinite(options.timeoutMs) ? Math.max(100, Math.min(Math.floor(options.timeoutMs), 6e4)) : 1e4;
|
|
3946
|
+
let rewritten = false;
|
|
3947
|
+
if (!nativeGemini) {
|
|
3948
|
+
const routed = await routeOllamaEmbedding(url, body, fetch, {
|
|
3949
|
+
signal: options.signal,
|
|
3950
|
+
probeTimeoutMs: Math.min(1e3, timeoutMs)
|
|
3951
|
+
});
|
|
3952
|
+
url = routed.url;
|
|
3953
|
+
body = routed.body;
|
|
3954
|
+
rewritten = routed.rewritten;
|
|
3955
|
+
}
|
|
3956
|
+
const controller = new AbortController();
|
|
3857
3957
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
3858
3958
|
const signal = options.signal ? AbortSignal.any([options.signal, controller.signal]) : controller.signal;
|
|
3859
3959
|
let response;
|
|
@@ -3879,10 +3979,11 @@ async function fetchWithRetry(url, apiKey, body, options = {}, attempt = 0, nati
|
|
|
3879
3979
|
}
|
|
3880
3980
|
try {
|
|
3881
3981
|
if (response.ok) {
|
|
3882
|
-
|
|
3982
|
+
const payload = await raceWithAbort(
|
|
3883
3983
|
response.json(),
|
|
3884
3984
|
signal
|
|
3885
3985
|
);
|
|
3986
|
+
return rewritten ? mapOllamaEmbeddingResponse(payload) : payload;
|
|
3886
3987
|
}
|
|
3887
3988
|
if (options.retry !== false && (response.status === 429 || response.status >= 500) && attempt < MAX_RETRIES2) {
|
|
3888
3989
|
const delay3 = BASE_DELAY_MS * Math.pow(2, attempt);
|
|
@@ -3959,6 +4060,7 @@ var init_api_provider = __esm({
|
|
|
3959
4060
|
"use strict";
|
|
3960
4061
|
init_esm_shims();
|
|
3961
4062
|
init_provider();
|
|
4063
|
+
init_ollama_embed();
|
|
3962
4064
|
cache3 = /* @__PURE__ */ new Map();
|
|
3963
4065
|
MAX_CACHE_ENTRIES = 2e5;
|
|
3964
4066
|
MAX_CACHE_PAYLOAD_BYTES = 256 * 1024 * 1024;
|
|
@@ -6534,6 +6636,9 @@ async function openState(dataDir, profile) {
|
|
|
6534
6636
|
const table = names.includes(name) ? await connection.openTable(name) : null;
|
|
6535
6637
|
return { key: stateKey(dataDir, profile), dataDir, profile, connection, table };
|
|
6536
6638
|
}
|
|
6639
|
+
function semanticVectorKey(projectId, observationId2) {
|
|
6640
|
+
return `${projectId}:${Math.trunc(observationId2)}`;
|
|
6641
|
+
}
|
|
6537
6642
|
function toLanceRow(record80) {
|
|
6538
6643
|
return {
|
|
6539
6644
|
observation_id: record80.observationId,
|
|
@@ -6604,7 +6709,7 @@ async function mergeVectors(dataDir, profile, records) {
|
|
|
6604
6709
|
const state = await getState(dataDir, profile, records);
|
|
6605
6710
|
if (!state?.table) return;
|
|
6606
6711
|
const rows = records.map(toLanceRow);
|
|
6607
|
-
await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
6712
|
+
await state.table.mergeInsert(["project_id", "observation_id"]).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
6608
6713
|
const key = stateKey(dataDir, profile);
|
|
6609
6714
|
const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
|
|
6610
6715
|
if (mutationCount >= semanticOptimizeEvery()) {
|
|
@@ -6644,11 +6749,18 @@ function upsertSemanticVector(dataDir, profile, record80) {
|
|
|
6644
6749
|
function upsertSemanticVectors(dataDir, profile, records) {
|
|
6645
6750
|
return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
|
|
6646
6751
|
}
|
|
6647
|
-
async function
|
|
6752
|
+
async function listSemanticVectorKeys(dataDir, profile) {
|
|
6648
6753
|
const state = await getState(dataDir, profile);
|
|
6649
6754
|
if (!state?.table) return null;
|
|
6650
|
-
const rows = await state.table.query().select(["observation_id"]).toArray();
|
|
6651
|
-
|
|
6755
|
+
const rows = await state.table.query().select(["observation_id", "project_id"]).toArray();
|
|
6756
|
+
const keys = /* @__PURE__ */ new Set();
|
|
6757
|
+
for (const row of rows) {
|
|
6758
|
+
const observationId2 = Number(row.observation_id);
|
|
6759
|
+
const projectId = String(row.project_id ?? "");
|
|
6760
|
+
if (!Number.isSafeInteger(observationId2) || !projectId) continue;
|
|
6761
|
+
keys.add(semanticVectorKey(projectId, observationId2));
|
|
6762
|
+
}
|
|
6763
|
+
return keys;
|
|
6652
6764
|
}
|
|
6653
6765
|
async function getSemanticIndexStats(dataDir, profile) {
|
|
6654
6766
|
const state = await getState(dataDir, profile);
|
|
@@ -6868,6 +6980,37 @@ var init_derived_view_receipt = __esm({
|
|
|
6868
6980
|
}
|
|
6869
6981
|
});
|
|
6870
6982
|
|
|
6983
|
+
// src/core/derived-view-registry.ts
|
|
6984
|
+
var DerivedViewRegistry;
|
|
6985
|
+
var init_derived_view_registry = __esm({
|
|
6986
|
+
"src/core/derived-view-registry.ts"() {
|
|
6987
|
+
"use strict";
|
|
6988
|
+
init_esm_shims();
|
|
6989
|
+
DerivedViewRegistry = class {
|
|
6990
|
+
readers = /* @__PURE__ */ new Map();
|
|
6991
|
+
register(name, reader) {
|
|
6992
|
+
const normalized = name.trim();
|
|
6993
|
+
if (!normalized) throw new Error("Derived view name must not be empty");
|
|
6994
|
+
this.readers.set(normalized, reader);
|
|
6995
|
+
return () => {
|
|
6996
|
+
if (this.readers.get(normalized) === reader) this.readers.delete(normalized);
|
|
6997
|
+
};
|
|
6998
|
+
}
|
|
6999
|
+
snapshot() {
|
|
7000
|
+
const result = {};
|
|
7001
|
+
for (const [name, reader] of this.readers) {
|
|
7002
|
+
try {
|
|
7003
|
+
result[name] = reader();
|
|
7004
|
+
} catch {
|
|
7005
|
+
result[name] = { state: "degraded", reason: "derived view reader failed" };
|
|
7006
|
+
}
|
|
7007
|
+
}
|
|
7008
|
+
return result;
|
|
7009
|
+
}
|
|
7010
|
+
};
|
|
7011
|
+
}
|
|
7012
|
+
});
|
|
7013
|
+
|
|
6871
7014
|
// src/project/aliases.ts
|
|
6872
7015
|
var aliases_exports = {};
|
|
6873
7016
|
__export(aliases_exports, {
|
|
@@ -7519,15 +7662,17 @@ function getLastSearchDiagnostics(projectId) {
|
|
|
7519
7662
|
return diagnostics ? { ...diagnostics } : void 0;
|
|
7520
7663
|
}
|
|
7521
7664
|
function getSearchDerivedViews() {
|
|
7522
|
-
|
|
7665
|
+
return searchDerivedViewRegistry.snapshot();
|
|
7666
|
+
}
|
|
7667
|
+
function readFtsDerivedViewReceipt() {
|
|
7523
7668
|
const store = getOptionalObservationStore();
|
|
7524
7669
|
if (store) {
|
|
7525
7670
|
try {
|
|
7526
7671
|
const generation = store.getGeneration();
|
|
7527
7672
|
if (store.hasLexicalIndex?.()) {
|
|
7528
|
-
|
|
7673
|
+
return { generation, freshness: "current", rebuildStatus: "idle" };
|
|
7529
7674
|
} else {
|
|
7530
|
-
|
|
7675
|
+
return {
|
|
7531
7676
|
generation,
|
|
7532
7677
|
freshness: "unknown",
|
|
7533
7678
|
rebuildStatus: "unavailable",
|
|
@@ -7537,32 +7682,34 @@ function getSearchDerivedViews() {
|
|
|
7537
7682
|
};
|
|
7538
7683
|
}
|
|
7539
7684
|
} catch (error) {
|
|
7540
|
-
|
|
7685
|
+
return {
|
|
7541
7686
|
freshness: "unknown",
|
|
7542
7687
|
rebuildStatus: "failed",
|
|
7543
7688
|
failureReason: sanitizeDerivedViewFailureReason(error instanceof Error ? error.message : String(error))
|
|
7544
7689
|
};
|
|
7545
7690
|
}
|
|
7546
|
-
} else {
|
|
7547
|
-
views.fts = {
|
|
7548
|
-
freshness: "unknown",
|
|
7549
|
-
rebuildStatus: "unavailable",
|
|
7550
|
-
failureReason: "observation store is not initialized"
|
|
7551
|
-
};
|
|
7552
7691
|
}
|
|
7553
|
-
|
|
7692
|
+
return {
|
|
7693
|
+
freshness: "unknown",
|
|
7694
|
+
rebuildStatus: "unavailable",
|
|
7695
|
+
failureReason: "observation store is not initialized"
|
|
7696
|
+
};
|
|
7697
|
+
}
|
|
7698
|
+
function readOramaDerivedViewReceipt() {
|
|
7699
|
+
return db ? { generation: dbGeneration, freshness: "current", rebuildStatus: "idle" } : {
|
|
7554
7700
|
generation: dbGeneration,
|
|
7555
7701
|
freshness: "unknown",
|
|
7556
7702
|
rebuildStatus: "unavailable",
|
|
7557
7703
|
failureReason: "Orama index is not initialized"
|
|
7558
7704
|
};
|
|
7705
|
+
}
|
|
7706
|
+
function readEmbeddingDerivedViewReceipt() {
|
|
7559
7707
|
let embeddingHealth;
|
|
7560
7708
|
try {
|
|
7561
7709
|
embeddingHealth = getEmbeddingRuntimeHealth?.();
|
|
7562
7710
|
} catch {
|
|
7563
7711
|
}
|
|
7564
|
-
|
|
7565
|
-
return views;
|
|
7712
|
+
return embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
|
|
7566
7713
|
}
|
|
7567
7714
|
function rememberSearchDiagnostics(key, value) {
|
|
7568
7715
|
if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
@@ -7699,10 +7846,12 @@ async function searchLanceInVectorOrder(options, projectIds, limit2, queryVector
|
|
|
7699
7846
|
const hits = [];
|
|
7700
7847
|
const seen = /* @__PURE__ */ new Set();
|
|
7701
7848
|
for (const hit of vectorHits) {
|
|
7702
|
-
if (
|
|
7703
|
-
|
|
7849
|
+
if (projectIds ? !projectIds.includes(hit.projectId) : options.projectId && hit.projectId !== options.projectId) continue;
|
|
7850
|
+
const key = semanticVectorKey(hit.projectId, hit.observationId);
|
|
7851
|
+
if (seen.has(key)) continue;
|
|
7852
|
+
seen.add(key);
|
|
7704
7853
|
const observation = await store.getById(hit.observationId);
|
|
7705
|
-
if (!observation) continue;
|
|
7854
|
+
if (!observation || observation.projectId !== hit.projectId) continue;
|
|
7706
7855
|
if (projectIds && !projectIds.includes(observation.projectId)) continue;
|
|
7707
7856
|
if (options.status !== "all" && (observation.status ?? "active") !== (options.status ?? "active")) continue;
|
|
7708
7857
|
if (options.type && observation.type !== options.type) continue;
|
|
@@ -7748,14 +7897,15 @@ async function searchPersistentSemantically(options, projectIds, limit2, queryVe
|
|
|
7748
7897
|
documents.set(makeEntryKey(hit.document.projectId, hit.document.observationId), hit.document);
|
|
7749
7898
|
}
|
|
7750
7899
|
const vectorObservations = await Promise.all(vectorHits.map(async (hit) => {
|
|
7900
|
+
if (projectIds ? !projectIds.includes(hit.projectId) : options.projectId && hit.projectId !== options.projectId) return null;
|
|
7751
7901
|
const observation = await store.getById(hit.observationId);
|
|
7752
|
-
if (!observation) return null;
|
|
7902
|
+
if (!observation || observation.projectId !== hit.projectId) return null;
|
|
7753
7903
|
if (projectIds && !projectIds.includes(observation.projectId)) return null;
|
|
7754
7904
|
if (options.status !== "all" && (observation.status ?? "active") !== (options.status ?? "active")) return null;
|
|
7755
7905
|
if (options.type && observation.type !== options.type) return null;
|
|
7756
7906
|
if (options.source && observation.source !== options.source) return null;
|
|
7757
7907
|
addObservation(observation);
|
|
7758
|
-
vectorDocumentKeys.set(hit.observationId, makeEntryKey(observation.projectId, observation.id));
|
|
7908
|
+
vectorDocumentKeys.set(semanticVectorKey(hit.projectId, hit.observationId), makeEntryKey(observation.projectId, observation.id));
|
|
7759
7909
|
return observation;
|
|
7760
7910
|
}));
|
|
7761
7911
|
const RRF_K = 60;
|
|
@@ -7765,7 +7915,8 @@ async function searchPersistentSemantically(options, projectIds, limit2, queryVe
|
|
|
7765
7915
|
scores.set(key, (scores.get(key) ?? 0) + 0.6 / (RRF_K + index + 1));
|
|
7766
7916
|
}
|
|
7767
7917
|
for (const [index, hit] of vectorHits.entries()) {
|
|
7768
|
-
const key = vectorDocumentKeys.get(
|
|
7918
|
+
const key = vectorDocumentKeys.get(semanticVectorKey(hit.projectId, hit.observationId));
|
|
7919
|
+
if (!key) continue;
|
|
7769
7920
|
if (!documents.has(key)) continue;
|
|
7770
7921
|
scores.set(key, (scores.get(key) ?? 0) + 0.4 / (RRF_K + index + 1));
|
|
7771
7922
|
}
|
|
@@ -7778,8 +7929,8 @@ async function searchPersistentSemantically(options, projectIds, limit2, queryVe
|
|
|
7778
7929
|
return {
|
|
7779
7930
|
count: vectorHits.length,
|
|
7780
7931
|
hits: vectorHits.map((hit, index) => {
|
|
7781
|
-
const key = vectorDocumentKeys.get(
|
|
7782
|
-
const document2 = documents.get(key);
|
|
7932
|
+
const key = vectorDocumentKeys.get(semanticVectorKey(hit.projectId, hit.observationId));
|
|
7933
|
+
const document2 = key ? documents.get(key) : void 0;
|
|
7783
7934
|
return document2 ? { id: document2.id, score: 0.4 / (RRF_K + index + 1), document: document2 } : null;
|
|
7784
7935
|
}).filter((hit) => hit !== null).slice(0, limit2)
|
|
7785
7936
|
};
|
|
@@ -7910,7 +8061,7 @@ function getActiveSemanticIndexProfile() {
|
|
|
7910
8061
|
}
|
|
7911
8062
|
async function getPersistentSemanticVectorIds(dataDir) {
|
|
7912
8063
|
if (!indexEmbeddingProvider) return null;
|
|
7913
|
-
return
|
|
8064
|
+
return listSemanticVectorKeys(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
|
|
7914
8065
|
}
|
|
7915
8066
|
async function queueSemanticVector(dataDir, record80) {
|
|
7916
8067
|
const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
|
|
@@ -7979,7 +8130,7 @@ function isCompatibleCachedVector(vector) {
|
|
|
7979
8130
|
async function attachCachedVectors(database, observations2) {
|
|
7980
8131
|
const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
|
|
7981
8132
|
const semanticProfile = getActiveSemanticIndexProfile();
|
|
7982
|
-
const persistedSemanticIds = semanticDataDir && semanticProfile ? await
|
|
8133
|
+
const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorKeys(semanticDataDir, semanticProfile).catch(() => null) : null;
|
|
7983
8134
|
const batchSize = 200;
|
|
7984
8135
|
for (let start = 0; start < observations2.length; start += batchSize) {
|
|
7985
8136
|
const batch = observations2.slice(start, start + batchSize);
|
|
@@ -7990,7 +8141,7 @@ async function attachCachedVectors(database, observations2) {
|
|
|
7990
8141
|
const vector = cachedVectors[index];
|
|
7991
8142
|
if (!isCompatibleCachedVector(vector)) continue;
|
|
7992
8143
|
const observation = batch[index];
|
|
7993
|
-
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
|
|
8144
|
+
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(semanticVectorKey(observation.projectId, observation.id))) {
|
|
7994
8145
|
semanticRecords.push({
|
|
7995
8146
|
observationId: observation.id,
|
|
7996
8147
|
projectId: observation.projectId,
|
|
@@ -8780,7 +8931,7 @@ function formatTime(isoDate) {
|
|
|
8780
8931
|
return isoDate;
|
|
8781
8932
|
}
|
|
8782
8933
|
}
|
|
8783
|
-
var db, dbInitPromise, dbGeneration, embeddingEnabled, embeddingDimensions, indexEmbeddingProvider, deferredCachedVectorHydration, NON_CJK_HYBRID_SIMILARITY, CJK_RUN, lastSearchModeByProject, lastSearchDiagnosticsByProject, SEARCH_MODE_DEFAULT_KEY, MAX_SEARCH_MODE_KEYS, COMMAND_LOG_TITLE, COMMAND_STYLE_TITLE, COMMAND_LIKE_QUERY2, COMMAND_INTENT_QUERY, NATURAL_LANGUAGE_MARKERS;
|
|
8934
|
+
var db, dbInitPromise, dbGeneration, embeddingEnabled, embeddingDimensions, indexEmbeddingProvider, deferredCachedVectorHydration, NON_CJK_HYBRID_SIMILARITY, CJK_RUN, lastSearchModeByProject, lastSearchDiagnosticsByProject, searchDerivedViewRegistry, SEARCH_MODE_DEFAULT_KEY, MAX_SEARCH_MODE_KEYS, COMMAND_LOG_TITLE, COMMAND_STYLE_TITLE, COMMAND_LIKE_QUERY2, COMMAND_INTENT_QUERY, NATURAL_LANGUAGE_MARKERS;
|
|
8784
8935
|
var init_orama_store = __esm({
|
|
8785
8936
|
"src/store/orama-store.ts"() {
|
|
8786
8937
|
"use strict";
|
|
@@ -8802,6 +8953,7 @@ var init_orama_store = __esm({
|
|
|
8802
8953
|
init_retrieval_contracts();
|
|
8803
8954
|
init_semantic_index();
|
|
8804
8955
|
init_derived_view_receipt();
|
|
8956
|
+
init_derived_view_registry();
|
|
8805
8957
|
db = null;
|
|
8806
8958
|
dbInitPromise = null;
|
|
8807
8959
|
dbGeneration = 0;
|
|
@@ -8813,8 +8965,12 @@ var init_orama_store = __esm({
|
|
|
8813
8965
|
CJK_RUN = /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+/gu;
|
|
8814
8966
|
lastSearchModeByProject = /* @__PURE__ */ new Map();
|
|
8815
8967
|
lastSearchDiagnosticsByProject = /* @__PURE__ */ new Map();
|
|
8968
|
+
searchDerivedViewRegistry = new DerivedViewRegistry();
|
|
8816
8969
|
SEARCH_MODE_DEFAULT_KEY = "__global__";
|
|
8817
8970
|
MAX_SEARCH_MODE_KEYS = 4096;
|
|
8971
|
+
searchDerivedViewRegistry.register("fts", readFtsDerivedViewReceipt);
|
|
8972
|
+
searchDerivedViewRegistry.register("orama", readOramaDerivedViewReceipt);
|
|
8973
|
+
searchDerivedViewRegistry.register("embedding", readEmbeddingDerivedViewReceipt);
|
|
8818
8974
|
COMMAND_LOG_TITLE = /^(Ran:|Command:|Executed:)\s/i;
|
|
8819
8975
|
COMMAND_STYLE_TITLE = /(\bfindstr\b|\bSelect-String\b|\bGet-Content\b|\bnpx\s+vitest\b|\bnpx\s+tsc\b|\b2>&1\b)/i;
|
|
8820
8976
|
COMMAND_LIKE_QUERY2 = /\b(git|npm|npx|pnpm|yarn|node|bash|powershell|curl|memorix)\b/i;
|
|
@@ -19572,7 +19728,7 @@ var init_uuid = __esm({
|
|
|
19572
19728
|
});
|
|
19573
19729
|
|
|
19574
19730
|
// node_modules/openai/internal/errors.mjs
|
|
19575
|
-
function
|
|
19731
|
+
function isAbortError2(err) {
|
|
19576
19732
|
return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
|
|
19577
19733
|
("name" in err && err.name === "AbortError" || // Expo fetch
|
|
19578
19734
|
"message" in err && String(err.message).includes("FetchRequestCanceledException"));
|
|
@@ -20752,7 +20908,7 @@ var init_streaming = __esm({
|
|
|
20752
20908
|
}
|
|
20753
20909
|
done = true;
|
|
20754
20910
|
} catch (e2) {
|
|
20755
|
-
if (
|
|
20911
|
+
if (isAbortError2(e2))
|
|
20756
20912
|
return;
|
|
20757
20913
|
throw e2;
|
|
20758
20914
|
} finally {
|
|
@@ -20795,7 +20951,7 @@ var init_streaming = __esm({
|
|
|
20795
20951
|
}
|
|
20796
20952
|
done = true;
|
|
20797
20953
|
} catch (e2) {
|
|
20798
|
-
if (
|
|
20954
|
+
if (isAbortError2(e2))
|
|
20799
20955
|
return;
|
|
20800
20956
|
throw e2;
|
|
20801
20957
|
} finally {
|
|
@@ -27344,7 +27500,7 @@ var init_client = __esm({
|
|
|
27344
27500
|
if (options.signal?.aborted) {
|
|
27345
27501
|
throw new APIUserAbortError();
|
|
27346
27502
|
}
|
|
27347
|
-
const isTimeout =
|
|
27503
|
+
const isTimeout = isAbortError2(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
|
|
27348
27504
|
if (retriesRemaining) {
|
|
27349
27505
|
loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
|
|
27350
27506
|
loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails({
|
|
@@ -46433,7 +46589,7 @@ var init_uuid2 = __esm({
|
|
|
46433
46589
|
});
|
|
46434
46590
|
|
|
46435
46591
|
// node_modules/@anthropic-ai/sdk/internal/errors.mjs
|
|
46436
|
-
function
|
|
46592
|
+
function isAbortError3(err) {
|
|
46437
46593
|
return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
|
|
46438
46594
|
("name" in err && err.name === "AbortError" || // Expo fetch
|
|
46439
46595
|
"message" in err && String(err.message).includes("FetchRequestCanceledException"));
|
|
@@ -47204,7 +47360,7 @@ var init_streaming3 = __esm({
|
|
|
47204
47360
|
}
|
|
47205
47361
|
done = true;
|
|
47206
47362
|
} catch (e2) {
|
|
47207
|
-
if (
|
|
47363
|
+
if (isAbortError3(e2))
|
|
47208
47364
|
return;
|
|
47209
47365
|
throw e2;
|
|
47210
47366
|
} finally {
|
|
@@ -47247,7 +47403,7 @@ var init_streaming3 = __esm({
|
|
|
47247
47403
|
}
|
|
47248
47404
|
done = true;
|
|
47249
47405
|
} catch (e2) {
|
|
47250
|
-
if (
|
|
47406
|
+
if (isAbortError3(e2))
|
|
47251
47407
|
return;
|
|
47252
47408
|
throw e2;
|
|
47253
47409
|
} finally {
|
|
@@ -49369,7 +49525,7 @@ var init_BetaMessageStream = __esm({
|
|
|
49369
49525
|
_BetaMessageStream_logger.set(this, void 0);
|
|
49370
49526
|
_BetaMessageStream_handleError.set(this, (error) => {
|
|
49371
49527
|
__classPrivateFieldSet2(this, _BetaMessageStream_errored, true, "f");
|
|
49372
|
-
if (
|
|
49528
|
+
if (isAbortError3(error)) {
|
|
49373
49529
|
error = new APIUserAbortError2();
|
|
49374
49530
|
}
|
|
49375
49531
|
if (error instanceof APIUserAbortError2) {
|
|
@@ -51830,7 +51986,7 @@ var init_MessageStream = __esm({
|
|
|
51830
51986
|
_MessageStream_logger.set(this, void 0);
|
|
51831
51987
|
_MessageStream_handleError.set(this, (error) => {
|
|
51832
51988
|
__classPrivateFieldSet2(this, _MessageStream_errored, true, "f");
|
|
51833
|
-
if (
|
|
51989
|
+
if (isAbortError3(error)) {
|
|
51834
51990
|
error = new APIUserAbortError2();
|
|
51835
51991
|
}
|
|
51836
51992
|
if (error instanceof APIUserAbortError2) {
|
|
@@ -52960,7 +53116,7 @@ var init_client2 = __esm({
|
|
|
52960
53116
|
if (options.signal?.aborted) {
|
|
52961
53117
|
throw new APIUserAbortError2();
|
|
52962
53118
|
}
|
|
52963
|
-
const isTimeout =
|
|
53119
|
+
const isTimeout = isAbortError3(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
|
|
52964
53120
|
if (retriesRemaining) {
|
|
52965
53121
|
loggerFor2(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
|
|
52966
53122
|
loggerFor2(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails2({
|
|
@@ -87468,7 +87624,7 @@ function listDocumentsResponseFromMldev(fromObject) {
|
|
|
87468
87624
|
}
|
|
87469
87625
|
return toObject;
|
|
87470
87626
|
}
|
|
87471
|
-
function
|
|
87627
|
+
function isAbortError4(err) {
|
|
87472
87628
|
return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
|
|
87473
87629
|
("name" in err && err.name === "AbortError" || // Expo fetch
|
|
87474
87630
|
"message" in err && String(err.message).includes("FetchRequestCanceledException"));
|
|
@@ -94682,7 +94838,7 @@ ${underline}`);
|
|
|
94682
94838
|
}
|
|
94683
94839
|
done = true;
|
|
94684
94840
|
} catch (e2) {
|
|
94685
|
-
if (
|
|
94841
|
+
if (isAbortError4(e2))
|
|
94686
94842
|
return yield __await(void 0);
|
|
94687
94843
|
throw e2;
|
|
94688
94844
|
} finally {
|
|
@@ -94757,7 +94913,7 @@ ${underline}`);
|
|
|
94757
94913
|
}
|
|
94758
94914
|
done = true;
|
|
94759
94915
|
} catch (e2) {
|
|
94760
|
-
if (
|
|
94916
|
+
if (isAbortError4(e2))
|
|
94761
94917
|
return yield __await(void 0);
|
|
94762
94918
|
throw e2;
|
|
94763
94919
|
} finally {
|
|
@@ -95133,7 +95289,7 @@ ${underline}`);
|
|
|
95133
95289
|
if ((_d = options.signal) === null || _d === void 0 ? void 0 : _d.aborted) {
|
|
95134
95290
|
throw new APIUserAbortError3();
|
|
95135
95291
|
}
|
|
95136
|
-
const isTimeout =
|
|
95292
|
+
const isTimeout = isAbortError4(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
|
|
95137
95293
|
if (retriesRemaining) {
|
|
95138
95294
|
loggerFor3(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
|
|
95139
95295
|
loggerFor3(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails3({
|
|
@@ -97357,7 +97513,7 @@ function isTimeoutError(err) {
|
|
|
97357
97513
|
const isGenericErr = "code" in err && typeof err.code === "string" && err.code.toLowerCase() === "econnaborted";
|
|
97358
97514
|
return isNative || isLegacyNative || isGenericErr;
|
|
97359
97515
|
}
|
|
97360
|
-
function
|
|
97516
|
+
function isAbortError5(err) {
|
|
97361
97517
|
if (typeof err !== "object" || err == null) {
|
|
97362
97518
|
return false;
|
|
97363
97519
|
}
|
|
@@ -98369,7 +98525,7 @@ var init_sdks = __esm({
|
|
|
98369
98525
|
return response;
|
|
98370
98526
|
}, { config: options.retryConfig, statusCodes: options.retryCodes }).then((r2) => OK(r2), (err) => {
|
|
98371
98527
|
switch (true) {
|
|
98372
|
-
case
|
|
98528
|
+
case isAbortError5(err):
|
|
98373
98529
|
return ERR(new RequestAbortedError("Request aborted by client", {
|
|
98374
98530
|
cause: err
|
|
98375
98531
|
}));
|
|
@@ -152250,13 +152406,17 @@ async function enqueueObservationDerivedWork(tx, observation) {
|
|
|
152250
152406
|
payload: { observationId: observation.id }
|
|
152251
152407
|
});
|
|
152252
152408
|
}
|
|
152409
|
+
await enqueueObservationProjectionWork(tx, observation);
|
|
152410
|
+
return true;
|
|
152411
|
+
}
|
|
152412
|
+
async function enqueueObservationProjectionWork(tx, observation) {
|
|
152413
|
+
if (!tx.enqueueMaintenanceJob) return;
|
|
152253
152414
|
await tx.enqueueMaintenanceJob({
|
|
152254
152415
|
projectId: observation.projectId,
|
|
152255
152416
|
kind: "observation-project",
|
|
152256
152417
|
dedupeKey: "observation-project:" + observation.id,
|
|
152257
152418
|
payload: { observationId: observation.id }
|
|
152258
152419
|
});
|
|
152259
|
-
return true;
|
|
152260
152420
|
}
|
|
152261
152421
|
function isVectorCompatibleWithCurrentIndex(embedding) {
|
|
152262
152422
|
if (!embedding) return false;
|
|
@@ -152790,6 +152950,7 @@ async function updateObservationAdmission(input) {
|
|
|
152790
152950
|
const next = apply(current);
|
|
152791
152951
|
if (!next) return;
|
|
152792
152952
|
await tx.update(next);
|
|
152953
|
+
await enqueueObservationProjectionWork(tx, next);
|
|
152793
152954
|
updated = next;
|
|
152794
152955
|
});
|
|
152795
152956
|
} else {
|
|
@@ -152807,6 +152968,9 @@ async function updateObservationAdmission(input) {
|
|
|
152807
152968
|
});
|
|
152808
152969
|
} catch {
|
|
152809
152970
|
}
|
|
152971
|
+
if (await persistEvidenceCard(updated)) {
|
|
152972
|
+
await acknowledgeObservationProjection(updated);
|
|
152973
|
+
}
|
|
152810
152974
|
if (updated.admissionState === "qualified" && resolveObservationVisibility(updated) === "project") {
|
|
152811
152975
|
queueClaimDerivation(updated);
|
|
152812
152976
|
}
|
|
@@ -152877,10 +153041,17 @@ async function resolveObservations(ids, status = "resolved") {
|
|
|
152877
153041
|
if (projectDir && resolved.length > 0) {
|
|
152878
153042
|
const store = getObservationStore();
|
|
152879
153043
|
await store.atomic(async (tx) => {
|
|
152880
|
-
await Promise.all(changed.map((observation) =>
|
|
153044
|
+
await Promise.all(changed.map(async (observation) => {
|
|
153045
|
+
await tx.update(observation);
|
|
153046
|
+
await enqueueObservationProjectionWork(tx, observation);
|
|
153047
|
+
}));
|
|
152881
153048
|
});
|
|
152882
153049
|
}
|
|
152883
|
-
for (const observation of changed)
|
|
153050
|
+
for (const observation of changed) {
|
|
153051
|
+
if (await persistEvidenceCard(observation)) {
|
|
153052
|
+
await acknowledgeObservationProjection(observation);
|
|
153053
|
+
}
|
|
153054
|
+
}
|
|
152884
153055
|
return { resolved, notFound };
|
|
152885
153056
|
}
|
|
152886
153057
|
function getProjectObservations(projectId) {
|
|
@@ -153033,9 +153204,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
153033
153204
|
for (const projectId of projects) {
|
|
153034
153205
|
const projectObservations = await store.loadByProject(projectId);
|
|
153035
153206
|
for (const observation of projectObservations) {
|
|
153036
|
-
if (!persistedIds?.has(observation.id)) markVectorMissing(observation.id, observation.projectId);
|
|
153207
|
+
if (!persistedIds?.has(semanticVectorKey(observation.projectId, observation.id))) markVectorMissing(observation.id, observation.projectId);
|
|
153037
153208
|
}
|
|
153038
|
-
if (projectObservations.some((observation) => !persistedIds?.has(observation.id))) {
|
|
153209
|
+
if (projectObservations.some((observation) => !persistedIds?.has(semanticVectorKey(observation.projectId, observation.id)))) {
|
|
153039
153210
|
queueVectorBackfill(projectId);
|
|
153040
153211
|
}
|
|
153041
153212
|
}
|
|
@@ -153057,7 +153228,7 @@ async function prepareSearchIndex(options = {}) {
|
|
|
153057
153228
|
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
153058
153229
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
153059
153230
|
for (const obs of observations) {
|
|
153060
|
-
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
153231
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(semanticVectorKey(obs.projectId, obs.id))) {
|
|
153061
153232
|
markVectorMissing(obs.id, obs.projectId);
|
|
153062
153233
|
projectsWithMissingVectors.add(obs.projectId);
|
|
153063
153234
|
}
|
|
@@ -153261,6 +153432,7 @@ var init_observations = __esm({
|
|
|
153261
153432
|
init_token_budget();
|
|
153262
153433
|
init_entity_extractor();
|
|
153263
153434
|
init_provider();
|
|
153435
|
+
init_semantic_index();
|
|
153264
153436
|
init_secret_filter();
|
|
153265
153437
|
init_lifecycle();
|
|
153266
153438
|
init_visibility();
|
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
7
|
### Fixed
|
|
8
|
+
- Lifecycle changes that resolve or qualify an observation now enqueue their
|
|
9
|
+
evidence/CodeGraph projection in the same canonical transaction. Successful
|
|
10
|
+
projection acknowledges the durable job, while failures remain pending for
|
|
11
|
+
maintenance retry.
|
|
12
|
+
- Derived-view retrieval receipts now use a kernel-owned registry with stable
|
|
13
|
+
names, replacement, snapshot creation, and isolated reader failures. New
|
|
14
|
+
FTS, Orama, Lance, or CodeGraph adapters can share the same health boundary.
|
|
8
15
|
- Embedding API requests now retry transport-level failures such as stale
|
|
9
16
|
keep-alive sockets, while preserving timeout, cancellation, and `retry = false`
|
|
10
17
|
behavior (#397).
|
|
@@ -49,6 +56,43 @@ All notable changes to this project will be documented in this file.
|
|
|
49
56
|
on Windows/Node 22 with embeddings disabled. This is offline fixture evidence,
|
|
50
57
|
not a claim about remote embedding quality.
|
|
51
58
|
|
|
59
|
+
## [1.10.5] - 2026-11-26
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
- Preserve project scope in Lance merge keys and cache/backfill checks, and
|
|
64
|
+
validate semantic hits against canonical SQLite. Upserts preserve other
|
|
65
|
+
projects' vectors; scoped deletion only removes the requested project (#410).
|
|
66
|
+
- Release silently disconnected legacy HTTP sessions after a configurable
|
|
67
|
+
two-minute grace, while preserving reconnections, POST-only clients, and
|
|
68
|
+
queued/running requests (#408).
|
|
69
|
+
- Cache positive and negative stateless HTTP project detection results for
|
|
70
|
+
five minutes with a 256-path limit (#409).
|
|
71
|
+
- Show topic-key and structured memory store flags in CLI help, including
|
|
72
|
+
the limitations of the `remember` shortcut (#406).
|
|
73
|
+
- Make binding lease fixtures relative to the current clock (#407).
|
|
74
|
+
- Include the Ollama native embedding adapter (#396/#402), derived-view
|
|
75
|
+
receipt registry (#403), and lifecycle projection outbox (#405) merged
|
|
76
|
+
after 1.10.4. These are incremental reliability changes toward 1.11.
|
|
77
|
+
|
|
78
|
+
## [1.10.4] - 2026-11-18
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- Embedding API requests retry transport-level failures such as stale
|
|
83
|
+
keep-alive sockets while preserving request deadlines, cancellation, and the
|
|
84
|
+
explicit retry opt-out (#397).
|
|
85
|
+
- Large API embedding-cache restores yield through the timer phase in bounded
|
|
86
|
+
batches and start after provider initialization, preventing cache recovery
|
|
87
|
+
from delaying formation deadlines (#398).
|
|
88
|
+
|
|
89
|
+
### Changed
|
|
90
|
+
|
|
91
|
+
- CJK-heavy queries can use Lance neighbor order by default, with configuration
|
|
92
|
+
overrides and a hybrid fallback when the vector index is unavailable (#395).
|
|
93
|
+
- npm 1.10.4 release metadata is synchronized across agent plugins and MCP
|
|
94
|
+
Registry metadata.
|
|
95
|
+
|
|
52
96
|
## [1.10.3] - 2026-11-05
|
|
53
97
|
|
|
54
98
|
### Added
|