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
package/dist/index.js
CHANGED
|
@@ -4585,6 +4585,96 @@ var init_transformers_provider = __esm({
|
|
|
4585
4585
|
}
|
|
4586
4586
|
});
|
|
4587
4587
|
|
|
4588
|
+
// src/embedding/ollama-embed.ts
|
|
4589
|
+
async function routeOllamaEmbedding(url, body, fetchImpl = fetch, probeOptions) {
|
|
4590
|
+
const parsed = parseUrl(url);
|
|
4591
|
+
if (!parsed) return { url, body, rewritten: false };
|
|
4592
|
+
const openAIRoute = parsed.pathname.endsWith("/v1/embeddings");
|
|
4593
|
+
const nativeRoute = parsed.pathname.endsWith("/api/embed");
|
|
4594
|
+
if (!openAIRoute && !nativeRoute) return { url, body, rewritten: false };
|
|
4595
|
+
if (!await originServesOllama(parsed.origin, fetchImpl, probeOptions)) return { url, body, rewritten: false };
|
|
4596
|
+
if (nativeRoute) return { url, body, rewritten: true };
|
|
4597
|
+
parsed.pathname = parsed.pathname.replace(/\/v1\/embeddings$/, "/api/embed");
|
|
4598
|
+
return { url: parsed.toString(), body: withEmbeddingKeepAlive(body), rewritten: true };
|
|
4599
|
+
}
|
|
4600
|
+
async function originServesOllama(origin, fetchImpl = fetch, probeOptions) {
|
|
4601
|
+
const cached = ollamaOrigins.get(origin);
|
|
4602
|
+
if (cached != null) return cached;
|
|
4603
|
+
if (probeOptions?.signal?.aborted) return false;
|
|
4604
|
+
try {
|
|
4605
|
+
const response = await fetchImpl(`${origin}/api/version`, {
|
|
4606
|
+
method: "GET",
|
|
4607
|
+
signal: buildProbeSignal(probeOptions)
|
|
4608
|
+
});
|
|
4609
|
+
if (!response.ok) {
|
|
4610
|
+
ollamaOrigins.set(origin, false);
|
|
4611
|
+
return false;
|
|
4612
|
+
}
|
|
4613
|
+
const detected = isOllamaVersionPayload(await response.json());
|
|
4614
|
+
ollamaOrigins.set(origin, detected);
|
|
4615
|
+
return detected;
|
|
4616
|
+
} catch (err) {
|
|
4617
|
+
if (isAbortError(err) || probeOptions?.signal?.aborted) return false;
|
|
4618
|
+
ollamaOrigins.set(origin, false);
|
|
4619
|
+
return false;
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
function mapOllamaEmbeddingResponse(payload) {
|
|
4623
|
+
if (!payload || typeof payload !== "object") return payload;
|
|
4624
|
+
const record80 = payload;
|
|
4625
|
+
if (Array.isArray(record80.data) || !Array.isArray(record80.embeddings)) return payload;
|
|
4626
|
+
const embeddings = record80.embeddings.filter((item) => Array.isArray(item));
|
|
4627
|
+
return {
|
|
4628
|
+
...record80,
|
|
4629
|
+
object: "list",
|
|
4630
|
+
data: embeddings.map((embedding, index) => ({
|
|
4631
|
+
object: "embedding",
|
|
4632
|
+
index,
|
|
4633
|
+
embedding
|
|
4634
|
+
}))
|
|
4635
|
+
};
|
|
4636
|
+
}
|
|
4637
|
+
function withEmbeddingKeepAlive(body) {
|
|
4638
|
+
if (body.keep_alive != null && body.keep_alive !== "") return body;
|
|
4639
|
+
return { ...body, keep_alive: OLLAMA_EMBED_KEEP_ALIVE };
|
|
4640
|
+
}
|
|
4641
|
+
function isOllamaVersionPayload(payload) {
|
|
4642
|
+
if (!payload || typeof payload !== "object") return false;
|
|
4643
|
+
const version = payload.version;
|
|
4644
|
+
return typeof version === "string" && /^\d+\.\d+\.\d+/.test(version);
|
|
4645
|
+
}
|
|
4646
|
+
function parseUrl(url) {
|
|
4647
|
+
try {
|
|
4648
|
+
return new URL(url);
|
|
4649
|
+
} catch {
|
|
4650
|
+
return null;
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
function buildProbeSignal(probeOptions) {
|
|
4654
|
+
const timeoutMs = Math.max(
|
|
4655
|
+
1,
|
|
4656
|
+
Math.min(
|
|
4657
|
+
typeof probeOptions?.probeTimeoutMs === "number" && Number.isFinite(probeOptions.probeTimeoutMs) ? Math.floor(probeOptions.probeTimeoutMs) : 1e3,
|
|
4658
|
+
6e4
|
|
4659
|
+
)
|
|
4660
|
+
);
|
|
4661
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
4662
|
+
if (probeOptions?.signal) return AbortSignal.any([probeOptions.signal, timeoutSignal]);
|
|
4663
|
+
return timeoutSignal;
|
|
4664
|
+
}
|
|
4665
|
+
function isAbortError(err) {
|
|
4666
|
+
return err instanceof Error && err.name === "AbortError";
|
|
4667
|
+
}
|
|
4668
|
+
var OLLAMA_EMBED_KEEP_ALIVE, ollamaOrigins;
|
|
4669
|
+
var init_ollama_embed = __esm({
|
|
4670
|
+
"src/embedding/ollama-embed.ts"() {
|
|
4671
|
+
"use strict";
|
|
4672
|
+
init_esm_shims();
|
|
4673
|
+
OLLAMA_EMBED_KEEP_ALIVE = "5m";
|
|
4674
|
+
ollamaOrigins = /* @__PURE__ */ new Map();
|
|
4675
|
+
}
|
|
4676
|
+
});
|
|
4677
|
+
|
|
4588
4678
|
// src/embedding/api-provider.ts
|
|
4589
4679
|
var api_provider_exports = {};
|
|
4590
4680
|
__export(api_provider_exports, {
|
|
@@ -5286,8 +5376,18 @@ function parseBatchLimit(error) {
|
|
|
5286
5376
|
return null;
|
|
5287
5377
|
}
|
|
5288
5378
|
async function fetchWithRetry(url, apiKey, body, options = {}, attempt = 0, nativeGemini = false) {
|
|
5289
|
-
const controller = new AbortController();
|
|
5290
5379
|
const timeoutMs = typeof options.timeoutMs === "number" && Number.isFinite(options.timeoutMs) ? Math.max(100, Math.min(Math.floor(options.timeoutMs), 6e4)) : 1e4;
|
|
5380
|
+
let rewritten = false;
|
|
5381
|
+
if (!nativeGemini) {
|
|
5382
|
+
const routed = await routeOllamaEmbedding(url, body, fetch, {
|
|
5383
|
+
signal: options.signal,
|
|
5384
|
+
probeTimeoutMs: Math.min(1e3, timeoutMs)
|
|
5385
|
+
});
|
|
5386
|
+
url = routed.url;
|
|
5387
|
+
body = routed.body;
|
|
5388
|
+
rewritten = routed.rewritten;
|
|
5389
|
+
}
|
|
5390
|
+
const controller = new AbortController();
|
|
5291
5391
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
5292
5392
|
const signal = options.signal ? AbortSignal.any([options.signal, controller.signal]) : controller.signal;
|
|
5293
5393
|
let response;
|
|
@@ -5313,10 +5413,11 @@ async function fetchWithRetry(url, apiKey, body, options = {}, attempt = 0, nati
|
|
|
5313
5413
|
}
|
|
5314
5414
|
try {
|
|
5315
5415
|
if (response.ok) {
|
|
5316
|
-
|
|
5416
|
+
const payload = await raceWithAbort(
|
|
5317
5417
|
response.json(),
|
|
5318
5418
|
signal
|
|
5319
5419
|
);
|
|
5420
|
+
return rewritten ? mapOllamaEmbeddingResponse(payload) : payload;
|
|
5320
5421
|
}
|
|
5321
5422
|
if (options.retry !== false && (response.status === 429 || response.status >= 500) && attempt < MAX_RETRIES2) {
|
|
5322
5423
|
const delay3 = BASE_DELAY_MS * Math.pow(2, attempt);
|
|
@@ -5393,6 +5494,7 @@ var init_api_provider = __esm({
|
|
|
5393
5494
|
"use strict";
|
|
5394
5495
|
init_esm_shims();
|
|
5395
5496
|
init_provider();
|
|
5497
|
+
init_ollama_embed();
|
|
5396
5498
|
cache3 = /* @__PURE__ */ new Map();
|
|
5397
5499
|
MAX_CACHE_ENTRIES = 2e5;
|
|
5398
5500
|
MAX_CACHE_PAYLOAD_BYTES = 256 * 1024 * 1024;
|
|
@@ -7968,6 +8070,9 @@ async function openState(dataDir, profile) {
|
|
|
7968
8070
|
const table = names.includes(name) ? await connection.openTable(name) : null;
|
|
7969
8071
|
return { key: stateKey(dataDir, profile), dataDir, profile, connection, table };
|
|
7970
8072
|
}
|
|
8073
|
+
function semanticVectorKey(projectId, observationId2) {
|
|
8074
|
+
return `${projectId}:${Math.trunc(observationId2)}`;
|
|
8075
|
+
}
|
|
7971
8076
|
function toLanceRow(record80) {
|
|
7972
8077
|
return {
|
|
7973
8078
|
observation_id: record80.observationId,
|
|
@@ -8038,7 +8143,7 @@ async function mergeVectors(dataDir, profile, records) {
|
|
|
8038
8143
|
const state = await getState(dataDir, profile, records);
|
|
8039
8144
|
if (!state?.table) return;
|
|
8040
8145
|
const rows = records.map(toLanceRow);
|
|
8041
|
-
await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
8146
|
+
await state.table.mergeInsert(["project_id", "observation_id"]).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
8042
8147
|
const key = stateKey(dataDir, profile);
|
|
8043
8148
|
const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
|
|
8044
8149
|
if (mutationCount >= semanticOptimizeEvery()) {
|
|
@@ -8078,11 +8183,18 @@ function upsertSemanticVector(dataDir, profile, record80) {
|
|
|
8078
8183
|
function upsertSemanticVectors(dataDir, profile, records) {
|
|
8079
8184
|
return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
|
|
8080
8185
|
}
|
|
8081
|
-
async function
|
|
8186
|
+
async function listSemanticVectorKeys(dataDir, profile) {
|
|
8082
8187
|
const state = await getState(dataDir, profile);
|
|
8083
8188
|
if (!state?.table) return null;
|
|
8084
|
-
const rows = await state.table.query().select(["observation_id"]).toArray();
|
|
8085
|
-
|
|
8189
|
+
const rows = await state.table.query().select(["observation_id", "project_id"]).toArray();
|
|
8190
|
+
const keys = /* @__PURE__ */ new Set();
|
|
8191
|
+
for (const row of rows) {
|
|
8192
|
+
const observationId2 = Number(row.observation_id);
|
|
8193
|
+
const projectId = String(row.project_id ?? "");
|
|
8194
|
+
if (!Number.isSafeInteger(observationId2) || !projectId) continue;
|
|
8195
|
+
keys.add(semanticVectorKey(projectId, observationId2));
|
|
8196
|
+
}
|
|
8197
|
+
return keys;
|
|
8086
8198
|
}
|
|
8087
8199
|
async function getSemanticIndexStats(dataDir, profile) {
|
|
8088
8200
|
const state = await getState(dataDir, profile);
|
|
@@ -8305,6 +8417,37 @@ var init_derived_view_receipt = __esm({
|
|
|
8305
8417
|
}
|
|
8306
8418
|
});
|
|
8307
8419
|
|
|
8420
|
+
// src/core/derived-view-registry.ts
|
|
8421
|
+
var DerivedViewRegistry;
|
|
8422
|
+
var init_derived_view_registry = __esm({
|
|
8423
|
+
"src/core/derived-view-registry.ts"() {
|
|
8424
|
+
"use strict";
|
|
8425
|
+
init_esm_shims();
|
|
8426
|
+
DerivedViewRegistry = class {
|
|
8427
|
+
readers = /* @__PURE__ */ new Map();
|
|
8428
|
+
register(name, reader2) {
|
|
8429
|
+
const normalized = name.trim();
|
|
8430
|
+
if (!normalized) throw new Error("Derived view name must not be empty");
|
|
8431
|
+
this.readers.set(normalized, reader2);
|
|
8432
|
+
return () => {
|
|
8433
|
+
if (this.readers.get(normalized) === reader2) this.readers.delete(normalized);
|
|
8434
|
+
};
|
|
8435
|
+
}
|
|
8436
|
+
snapshot() {
|
|
8437
|
+
const result = {};
|
|
8438
|
+
for (const [name, reader2] of this.readers) {
|
|
8439
|
+
try {
|
|
8440
|
+
result[name] = reader2();
|
|
8441
|
+
} catch {
|
|
8442
|
+
result[name] = { state: "degraded", reason: "derived view reader failed" };
|
|
8443
|
+
}
|
|
8444
|
+
}
|
|
8445
|
+
return result;
|
|
8446
|
+
}
|
|
8447
|
+
};
|
|
8448
|
+
}
|
|
8449
|
+
});
|
|
8450
|
+
|
|
8308
8451
|
// src/project/aliases.ts
|
|
8309
8452
|
var aliases_exports = {};
|
|
8310
8453
|
__export(aliases_exports, {
|
|
@@ -8956,15 +9099,17 @@ function getLastSearchDiagnostics(projectId) {
|
|
|
8956
9099
|
return diagnostics ? { ...diagnostics } : void 0;
|
|
8957
9100
|
}
|
|
8958
9101
|
function getSearchDerivedViews() {
|
|
8959
|
-
|
|
9102
|
+
return searchDerivedViewRegistry.snapshot();
|
|
9103
|
+
}
|
|
9104
|
+
function readFtsDerivedViewReceipt() {
|
|
8960
9105
|
const store = getOptionalObservationStore();
|
|
8961
9106
|
if (store) {
|
|
8962
9107
|
try {
|
|
8963
9108
|
const generation = store.getGeneration();
|
|
8964
9109
|
if (store.hasLexicalIndex?.()) {
|
|
8965
|
-
|
|
9110
|
+
return { generation, freshness: "current", rebuildStatus: "idle" };
|
|
8966
9111
|
} else {
|
|
8967
|
-
|
|
9112
|
+
return {
|
|
8968
9113
|
generation,
|
|
8969
9114
|
freshness: "unknown",
|
|
8970
9115
|
rebuildStatus: "unavailable",
|
|
@@ -8974,32 +9119,34 @@ function getSearchDerivedViews() {
|
|
|
8974
9119
|
};
|
|
8975
9120
|
}
|
|
8976
9121
|
} catch (error) {
|
|
8977
|
-
|
|
9122
|
+
return {
|
|
8978
9123
|
freshness: "unknown",
|
|
8979
9124
|
rebuildStatus: "failed",
|
|
8980
9125
|
failureReason: sanitizeDerivedViewFailureReason(error instanceof Error ? error.message : String(error))
|
|
8981
9126
|
};
|
|
8982
9127
|
}
|
|
8983
|
-
} else {
|
|
8984
|
-
views.fts = {
|
|
8985
|
-
freshness: "unknown",
|
|
8986
|
-
rebuildStatus: "unavailable",
|
|
8987
|
-
failureReason: "observation store is not initialized"
|
|
8988
|
-
};
|
|
8989
9128
|
}
|
|
8990
|
-
|
|
9129
|
+
return {
|
|
9130
|
+
freshness: "unknown",
|
|
9131
|
+
rebuildStatus: "unavailable",
|
|
9132
|
+
failureReason: "observation store is not initialized"
|
|
9133
|
+
};
|
|
9134
|
+
}
|
|
9135
|
+
function readOramaDerivedViewReceipt() {
|
|
9136
|
+
return db ? { generation: dbGeneration, freshness: "current", rebuildStatus: "idle" } : {
|
|
8991
9137
|
generation: dbGeneration,
|
|
8992
9138
|
freshness: "unknown",
|
|
8993
9139
|
rebuildStatus: "unavailable",
|
|
8994
9140
|
failureReason: "Orama index is not initialized"
|
|
8995
9141
|
};
|
|
9142
|
+
}
|
|
9143
|
+
function readEmbeddingDerivedViewReceipt() {
|
|
8996
9144
|
let embeddingHealth;
|
|
8997
9145
|
try {
|
|
8998
9146
|
embeddingHealth = getEmbeddingRuntimeHealth?.();
|
|
8999
9147
|
} catch {
|
|
9000
9148
|
}
|
|
9001
|
-
|
|
9002
|
-
return views;
|
|
9149
|
+
return embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
|
|
9003
9150
|
}
|
|
9004
9151
|
function rememberSearchDiagnostics(key, value) {
|
|
9005
9152
|
if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
@@ -9136,10 +9283,12 @@ async function searchLanceInVectorOrder(options, projectIds, limit2, queryVector
|
|
|
9136
9283
|
const hits = [];
|
|
9137
9284
|
const seen = /* @__PURE__ */ new Set();
|
|
9138
9285
|
for (const hit of vectorHits) {
|
|
9139
|
-
if (
|
|
9140
|
-
|
|
9286
|
+
if (projectIds ? !projectIds.includes(hit.projectId) : options.projectId && hit.projectId !== options.projectId) continue;
|
|
9287
|
+
const key = semanticVectorKey(hit.projectId, hit.observationId);
|
|
9288
|
+
if (seen.has(key)) continue;
|
|
9289
|
+
seen.add(key);
|
|
9141
9290
|
const observation = await store.getById(hit.observationId);
|
|
9142
|
-
if (!observation) continue;
|
|
9291
|
+
if (!observation || observation.projectId !== hit.projectId) continue;
|
|
9143
9292
|
if (projectIds && !projectIds.includes(observation.projectId)) continue;
|
|
9144
9293
|
if (options.status !== "all" && (observation.status ?? "active") !== (options.status ?? "active")) continue;
|
|
9145
9294
|
if (options.type && observation.type !== options.type) continue;
|
|
@@ -9185,14 +9334,15 @@ async function searchPersistentSemantically(options, projectIds, limit2, queryVe
|
|
|
9185
9334
|
documents.set(makeEntryKey(hit.document.projectId, hit.document.observationId), hit.document);
|
|
9186
9335
|
}
|
|
9187
9336
|
const vectorObservations = await Promise.all(vectorHits.map(async (hit) => {
|
|
9337
|
+
if (projectIds ? !projectIds.includes(hit.projectId) : options.projectId && hit.projectId !== options.projectId) return null;
|
|
9188
9338
|
const observation = await store.getById(hit.observationId);
|
|
9189
|
-
if (!observation) return null;
|
|
9339
|
+
if (!observation || observation.projectId !== hit.projectId) return null;
|
|
9190
9340
|
if (projectIds && !projectIds.includes(observation.projectId)) return null;
|
|
9191
9341
|
if (options.status !== "all" && (observation.status ?? "active") !== (options.status ?? "active")) return null;
|
|
9192
9342
|
if (options.type && observation.type !== options.type) return null;
|
|
9193
9343
|
if (options.source && observation.source !== options.source) return null;
|
|
9194
9344
|
addObservation(observation);
|
|
9195
|
-
vectorDocumentKeys.set(hit.observationId, makeEntryKey(observation.projectId, observation.id));
|
|
9345
|
+
vectorDocumentKeys.set(semanticVectorKey(hit.projectId, hit.observationId), makeEntryKey(observation.projectId, observation.id));
|
|
9196
9346
|
return observation;
|
|
9197
9347
|
}));
|
|
9198
9348
|
const RRF_K = 60;
|
|
@@ -9202,7 +9352,8 @@ async function searchPersistentSemantically(options, projectIds, limit2, queryVe
|
|
|
9202
9352
|
scores.set(key, (scores.get(key) ?? 0) + 0.6 / (RRF_K + index + 1));
|
|
9203
9353
|
}
|
|
9204
9354
|
for (const [index, hit] of vectorHits.entries()) {
|
|
9205
|
-
const key = vectorDocumentKeys.get(
|
|
9355
|
+
const key = vectorDocumentKeys.get(semanticVectorKey(hit.projectId, hit.observationId));
|
|
9356
|
+
if (!key) continue;
|
|
9206
9357
|
if (!documents.has(key)) continue;
|
|
9207
9358
|
scores.set(key, (scores.get(key) ?? 0) + 0.4 / (RRF_K + index + 1));
|
|
9208
9359
|
}
|
|
@@ -9215,8 +9366,8 @@ async function searchPersistentSemantically(options, projectIds, limit2, queryVe
|
|
|
9215
9366
|
return {
|
|
9216
9367
|
count: vectorHits.length,
|
|
9217
9368
|
hits: vectorHits.map((hit, index) => {
|
|
9218
|
-
const key = vectorDocumentKeys.get(
|
|
9219
|
-
const document2 = documents.get(key);
|
|
9369
|
+
const key = vectorDocumentKeys.get(semanticVectorKey(hit.projectId, hit.observationId));
|
|
9370
|
+
const document2 = key ? documents.get(key) : void 0;
|
|
9220
9371
|
return document2 ? { id: document2.id, score: 0.4 / (RRF_K + index + 1), document: document2 } : null;
|
|
9221
9372
|
}).filter((hit) => hit !== null).slice(0, limit2)
|
|
9222
9373
|
};
|
|
@@ -9347,7 +9498,7 @@ function getActiveSemanticIndexProfile() {
|
|
|
9347
9498
|
}
|
|
9348
9499
|
async function getPersistentSemanticVectorIds(dataDir) {
|
|
9349
9500
|
if (!indexEmbeddingProvider) return null;
|
|
9350
|
-
return
|
|
9501
|
+
return listSemanticVectorKeys(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
|
|
9351
9502
|
}
|
|
9352
9503
|
async function queueSemanticVector(dataDir, record80) {
|
|
9353
9504
|
const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
|
|
@@ -9416,7 +9567,7 @@ function isCompatibleCachedVector(vector) {
|
|
|
9416
9567
|
async function attachCachedVectors(database, observations2) {
|
|
9417
9568
|
const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
|
|
9418
9569
|
const semanticProfile = getActiveSemanticIndexProfile();
|
|
9419
|
-
const persistedSemanticIds = semanticDataDir && semanticProfile ? await
|
|
9570
|
+
const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorKeys(semanticDataDir, semanticProfile).catch(() => null) : null;
|
|
9420
9571
|
const batchSize = 200;
|
|
9421
9572
|
for (let start = 0; start < observations2.length; start += batchSize) {
|
|
9422
9573
|
const batch = observations2.slice(start, start + batchSize);
|
|
@@ -9427,7 +9578,7 @@ async function attachCachedVectors(database, observations2) {
|
|
|
9427
9578
|
const vector = cachedVectors[index];
|
|
9428
9579
|
if (!isCompatibleCachedVector(vector)) continue;
|
|
9429
9580
|
const observation = batch[index];
|
|
9430
|
-
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
|
|
9581
|
+
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(semanticVectorKey(observation.projectId, observation.id))) {
|
|
9431
9582
|
semanticRecords.push({
|
|
9432
9583
|
observationId: observation.id,
|
|
9433
9584
|
projectId: observation.projectId,
|
|
@@ -10217,7 +10368,7 @@ function formatTime(isoDate) {
|
|
|
10217
10368
|
return isoDate;
|
|
10218
10369
|
}
|
|
10219
10370
|
}
|
|
10220
|
-
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_TITLE2, COMMAND_STYLE_TITLE, COMMAND_LIKE_QUERY2, COMMAND_INTENT_QUERY, NATURAL_LANGUAGE_MARKERS;
|
|
10371
|
+
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_TITLE2, COMMAND_STYLE_TITLE, COMMAND_LIKE_QUERY2, COMMAND_INTENT_QUERY, NATURAL_LANGUAGE_MARKERS;
|
|
10221
10372
|
var init_orama_store = __esm({
|
|
10222
10373
|
"src/store/orama-store.ts"() {
|
|
10223
10374
|
"use strict";
|
|
@@ -10239,6 +10390,7 @@ var init_orama_store = __esm({
|
|
|
10239
10390
|
init_retrieval_contracts();
|
|
10240
10391
|
init_semantic_index();
|
|
10241
10392
|
init_derived_view_receipt();
|
|
10393
|
+
init_derived_view_registry();
|
|
10242
10394
|
db = null;
|
|
10243
10395
|
dbInitPromise = null;
|
|
10244
10396
|
dbGeneration = 0;
|
|
@@ -10250,8 +10402,12 @@ var init_orama_store = __esm({
|
|
|
10250
10402
|
CJK_RUN = /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+/gu;
|
|
10251
10403
|
lastSearchModeByProject = /* @__PURE__ */ new Map();
|
|
10252
10404
|
lastSearchDiagnosticsByProject = /* @__PURE__ */ new Map();
|
|
10405
|
+
searchDerivedViewRegistry = new DerivedViewRegistry();
|
|
10253
10406
|
SEARCH_MODE_DEFAULT_KEY = "__global__";
|
|
10254
10407
|
MAX_SEARCH_MODE_KEYS = 4096;
|
|
10408
|
+
searchDerivedViewRegistry.register("fts", readFtsDerivedViewReceipt);
|
|
10409
|
+
searchDerivedViewRegistry.register("orama", readOramaDerivedViewReceipt);
|
|
10410
|
+
searchDerivedViewRegistry.register("embedding", readEmbeddingDerivedViewReceipt);
|
|
10255
10411
|
COMMAND_LOG_TITLE2 = /^(Ran:|Command:|Executed:)\s/i;
|
|
10256
10412
|
COMMAND_STYLE_TITLE = /(\bfindstr\b|\bSelect-String\b|\bGet-Content\b|\bnpx\s+vitest\b|\bnpx\s+tsc\b|\b2>&1\b)/i;
|
|
10257
10413
|
COMMAND_LIKE_QUERY2 = /\b(git|npm|npx|pnpm|yarn|node|bash|powershell|curl|memorix)\b/i;
|
|
@@ -21385,7 +21541,7 @@ var init_uuid = __esm({
|
|
|
21385
21541
|
});
|
|
21386
21542
|
|
|
21387
21543
|
// node_modules/openai/internal/errors.mjs
|
|
21388
|
-
function
|
|
21544
|
+
function isAbortError2(err) {
|
|
21389
21545
|
return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
|
|
21390
21546
|
("name" in err && err.name === "AbortError" || // Expo fetch
|
|
21391
21547
|
"message" in err && String(err.message).includes("FetchRequestCanceledException"));
|
|
@@ -22565,7 +22721,7 @@ var init_streaming = __esm({
|
|
|
22565
22721
|
}
|
|
22566
22722
|
done = true;
|
|
22567
22723
|
} catch (e2) {
|
|
22568
|
-
if (
|
|
22724
|
+
if (isAbortError2(e2))
|
|
22569
22725
|
return;
|
|
22570
22726
|
throw e2;
|
|
22571
22727
|
} finally {
|
|
@@ -22608,7 +22764,7 @@ var init_streaming = __esm({
|
|
|
22608
22764
|
}
|
|
22609
22765
|
done = true;
|
|
22610
22766
|
} catch (e2) {
|
|
22611
|
-
if (
|
|
22767
|
+
if (isAbortError2(e2))
|
|
22612
22768
|
return;
|
|
22613
22769
|
throw e2;
|
|
22614
22770
|
} finally {
|
|
@@ -29157,7 +29313,7 @@ var init_client = __esm({
|
|
|
29157
29313
|
if (options.signal?.aborted) {
|
|
29158
29314
|
throw new APIUserAbortError();
|
|
29159
29315
|
}
|
|
29160
|
-
const isTimeout =
|
|
29316
|
+
const isTimeout = isAbortError2(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
|
|
29161
29317
|
if (retriesRemaining) {
|
|
29162
29318
|
loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
|
|
29163
29319
|
loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails({
|
|
@@ -48257,7 +48413,7 @@ var init_uuid2 = __esm({
|
|
|
48257
48413
|
});
|
|
48258
48414
|
|
|
48259
48415
|
// node_modules/@anthropic-ai/sdk/internal/errors.mjs
|
|
48260
|
-
function
|
|
48416
|
+
function isAbortError3(err) {
|
|
48261
48417
|
return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
|
|
48262
48418
|
("name" in err && err.name === "AbortError" || // Expo fetch
|
|
48263
48419
|
"message" in err && String(err.message).includes("FetchRequestCanceledException"));
|
|
@@ -49028,7 +49184,7 @@ var init_streaming3 = __esm({
|
|
|
49028
49184
|
}
|
|
49029
49185
|
done = true;
|
|
49030
49186
|
} catch (e2) {
|
|
49031
|
-
if (
|
|
49187
|
+
if (isAbortError3(e2))
|
|
49032
49188
|
return;
|
|
49033
49189
|
throw e2;
|
|
49034
49190
|
} finally {
|
|
@@ -49071,7 +49227,7 @@ var init_streaming3 = __esm({
|
|
|
49071
49227
|
}
|
|
49072
49228
|
done = true;
|
|
49073
49229
|
} catch (e2) {
|
|
49074
|
-
if (
|
|
49230
|
+
if (isAbortError3(e2))
|
|
49075
49231
|
return;
|
|
49076
49232
|
throw e2;
|
|
49077
49233
|
} finally {
|
|
@@ -51193,7 +51349,7 @@ var init_BetaMessageStream = __esm({
|
|
|
51193
51349
|
_BetaMessageStream_logger.set(this, void 0);
|
|
51194
51350
|
_BetaMessageStream_handleError.set(this, (error) => {
|
|
51195
51351
|
__classPrivateFieldSet2(this, _BetaMessageStream_errored, true, "f");
|
|
51196
|
-
if (
|
|
51352
|
+
if (isAbortError3(error)) {
|
|
51197
51353
|
error = new APIUserAbortError2();
|
|
51198
51354
|
}
|
|
51199
51355
|
if (error instanceof APIUserAbortError2) {
|
|
@@ -53654,7 +53810,7 @@ var init_MessageStream = __esm({
|
|
|
53654
53810
|
_MessageStream_logger.set(this, void 0);
|
|
53655
53811
|
_MessageStream_handleError.set(this, (error) => {
|
|
53656
53812
|
__classPrivateFieldSet2(this, _MessageStream_errored, true, "f");
|
|
53657
|
-
if (
|
|
53813
|
+
if (isAbortError3(error)) {
|
|
53658
53814
|
error = new APIUserAbortError2();
|
|
53659
53815
|
}
|
|
53660
53816
|
if (error instanceof APIUserAbortError2) {
|
|
@@ -54784,7 +54940,7 @@ var init_client2 = __esm({
|
|
|
54784
54940
|
if (options.signal?.aborted) {
|
|
54785
54941
|
throw new APIUserAbortError2();
|
|
54786
54942
|
}
|
|
54787
|
-
const isTimeout =
|
|
54943
|
+
const isTimeout = isAbortError3(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
|
|
54788
54944
|
if (retriesRemaining) {
|
|
54789
54945
|
loggerFor2(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
|
|
54790
54946
|
loggerFor2(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails2({
|
|
@@ -89292,7 +89448,7 @@ function listDocumentsResponseFromMldev(fromObject) {
|
|
|
89292
89448
|
}
|
|
89293
89449
|
return toObject;
|
|
89294
89450
|
}
|
|
89295
|
-
function
|
|
89451
|
+
function isAbortError4(err) {
|
|
89296
89452
|
return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
|
|
89297
89453
|
("name" in err && err.name === "AbortError" || // Expo fetch
|
|
89298
89454
|
"message" in err && String(err.message).includes("FetchRequestCanceledException"));
|
|
@@ -96506,7 +96662,7 @@ ${underline}`);
|
|
|
96506
96662
|
}
|
|
96507
96663
|
done = true;
|
|
96508
96664
|
} catch (e2) {
|
|
96509
|
-
if (
|
|
96665
|
+
if (isAbortError4(e2))
|
|
96510
96666
|
return yield __await(void 0);
|
|
96511
96667
|
throw e2;
|
|
96512
96668
|
} finally {
|
|
@@ -96581,7 +96737,7 @@ ${underline}`);
|
|
|
96581
96737
|
}
|
|
96582
96738
|
done = true;
|
|
96583
96739
|
} catch (e2) {
|
|
96584
|
-
if (
|
|
96740
|
+
if (isAbortError4(e2))
|
|
96585
96741
|
return yield __await(void 0);
|
|
96586
96742
|
throw e2;
|
|
96587
96743
|
} finally {
|
|
@@ -96957,7 +97113,7 @@ ${underline}`);
|
|
|
96957
97113
|
if ((_d = options.signal) === null || _d === void 0 ? void 0 : _d.aborted) {
|
|
96958
97114
|
throw new APIUserAbortError3();
|
|
96959
97115
|
}
|
|
96960
|
-
const isTimeout =
|
|
97116
|
+
const isTimeout = isAbortError4(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
|
|
96961
97117
|
if (retriesRemaining) {
|
|
96962
97118
|
loggerFor3(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
|
|
96963
97119
|
loggerFor3(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails3({
|
|
@@ -99181,7 +99337,7 @@ function isTimeoutError(err) {
|
|
|
99181
99337
|
const isGenericErr = "code" in err && typeof err.code === "string" && err.code.toLowerCase() === "econnaborted";
|
|
99182
99338
|
return isNative || isLegacyNative || isGenericErr;
|
|
99183
99339
|
}
|
|
99184
|
-
function
|
|
99340
|
+
function isAbortError5(err) {
|
|
99185
99341
|
if (typeof err !== "object" || err == null) {
|
|
99186
99342
|
return false;
|
|
99187
99343
|
}
|
|
@@ -100193,7 +100349,7 @@ var init_sdks = __esm({
|
|
|
100193
100349
|
return response;
|
|
100194
100350
|
}, { config: options.retryConfig, statusCodes: options.retryCodes }).then((r2) => OK(r2), (err) => {
|
|
100195
100351
|
switch (true) {
|
|
100196
|
-
case
|
|
100352
|
+
case isAbortError5(err):
|
|
100197
100353
|
return ERR(new RequestAbortedError("Request aborted by client", {
|
|
100198
100354
|
cause: err
|
|
100199
100355
|
}));
|
|
@@ -154595,13 +154751,17 @@ async function enqueueObservationDerivedWork(tx, observation) {
|
|
|
154595
154751
|
payload: { observationId: observation.id }
|
|
154596
154752
|
});
|
|
154597
154753
|
}
|
|
154754
|
+
await enqueueObservationProjectionWork(tx, observation);
|
|
154755
|
+
return true;
|
|
154756
|
+
}
|
|
154757
|
+
async function enqueueObservationProjectionWork(tx, observation) {
|
|
154758
|
+
if (!tx.enqueueMaintenanceJob) return;
|
|
154598
154759
|
await tx.enqueueMaintenanceJob({
|
|
154599
154760
|
projectId: observation.projectId,
|
|
154600
154761
|
kind: "observation-project",
|
|
154601
154762
|
dedupeKey: "observation-project:" + observation.id,
|
|
154602
154763
|
payload: { observationId: observation.id }
|
|
154603
154764
|
});
|
|
154604
|
-
return true;
|
|
154605
154765
|
}
|
|
154606
154766
|
function isVectorCompatibleWithCurrentIndex(embedding) {
|
|
154607
154767
|
if (!embedding) return false;
|
|
@@ -155135,6 +155295,7 @@ async function updateObservationAdmission(input) {
|
|
|
155135
155295
|
const next = apply(current);
|
|
155136
155296
|
if (!next) return;
|
|
155137
155297
|
await tx.update(next);
|
|
155298
|
+
await enqueueObservationProjectionWork(tx, next);
|
|
155138
155299
|
updated = next;
|
|
155139
155300
|
});
|
|
155140
155301
|
} else {
|
|
@@ -155152,6 +155313,9 @@ async function updateObservationAdmission(input) {
|
|
|
155152
155313
|
});
|
|
155153
155314
|
} catch {
|
|
155154
155315
|
}
|
|
155316
|
+
if (await persistEvidenceCard(updated)) {
|
|
155317
|
+
await acknowledgeObservationProjection(updated);
|
|
155318
|
+
}
|
|
155155
155319
|
if (updated.admissionState === "qualified" && resolveObservationVisibility(updated) === "project") {
|
|
155156
155320
|
queueClaimDerivation(updated);
|
|
155157
155321
|
}
|
|
@@ -155222,10 +155386,17 @@ async function resolveObservations(ids, status = "resolved") {
|
|
|
155222
155386
|
if (projectDir && resolved.length > 0) {
|
|
155223
155387
|
const store = getObservationStore();
|
|
155224
155388
|
await store.atomic(async (tx) => {
|
|
155225
|
-
await Promise.all(changed.map((observation) =>
|
|
155389
|
+
await Promise.all(changed.map(async (observation) => {
|
|
155390
|
+
await tx.update(observation);
|
|
155391
|
+
await enqueueObservationProjectionWork(tx, observation);
|
|
155392
|
+
}));
|
|
155226
155393
|
});
|
|
155227
155394
|
}
|
|
155228
|
-
for (const observation of changed)
|
|
155395
|
+
for (const observation of changed) {
|
|
155396
|
+
if (await persistEvidenceCard(observation)) {
|
|
155397
|
+
await acknowledgeObservationProjection(observation);
|
|
155398
|
+
}
|
|
155399
|
+
}
|
|
155229
155400
|
return { resolved, notFound };
|
|
155230
155401
|
}
|
|
155231
155402
|
function getProjectObservations(projectId) {
|
|
@@ -155378,9 +155549,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
155378
155549
|
for (const projectId of projects) {
|
|
155379
155550
|
const projectObservations = await store.loadByProject(projectId);
|
|
155380
155551
|
for (const observation of projectObservations) {
|
|
155381
|
-
if (!persistedIds?.has(observation.id)) markVectorMissing(observation.id, observation.projectId);
|
|
155552
|
+
if (!persistedIds?.has(semanticVectorKey(observation.projectId, observation.id))) markVectorMissing(observation.id, observation.projectId);
|
|
155382
155553
|
}
|
|
155383
|
-
if (projectObservations.some((observation) => !persistedIds?.has(observation.id))) {
|
|
155554
|
+
if (projectObservations.some((observation) => !persistedIds?.has(semanticVectorKey(observation.projectId, observation.id)))) {
|
|
155384
155555
|
queueVectorBackfill(projectId);
|
|
155385
155556
|
}
|
|
155386
155557
|
}
|
|
@@ -155402,7 +155573,7 @@ async function prepareSearchIndex(options = {}) {
|
|
|
155402
155573
|
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
155403
155574
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
155404
155575
|
for (const obs of observations) {
|
|
155405
|
-
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
155576
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(semanticVectorKey(obs.projectId, obs.id))) {
|
|
155406
155577
|
markVectorMissing(obs.id, obs.projectId);
|
|
155407
155578
|
projectsWithMissingVectors.add(obs.projectId);
|
|
155408
155579
|
}
|
|
@@ -155606,6 +155777,7 @@ var init_observations = __esm({
|
|
|
155606
155777
|
init_token_budget();
|
|
155607
155778
|
init_entity_extractor();
|
|
155608
155779
|
init_provider();
|
|
155780
|
+
init_semantic_index();
|
|
155609
155781
|
init_secret_filter();
|
|
155610
155782
|
init_lifecycle();
|
|
155611
155783
|
init_visibility();
|
|
@@ -161232,7 +161404,7 @@ var init_request_context = __esm({
|
|
|
161232
161404
|
function getMcpServerInfo() {
|
|
161233
161405
|
return {
|
|
161234
161406
|
name: "memorix",
|
|
161235
|
-
version: true ? "1.10.
|
|
161407
|
+
version: true ? "1.10.5" : "1.0.1"
|
|
161236
161408
|
};
|
|
161237
161409
|
}
|
|
161238
161410
|
function createMcpDiscoverResult(capabilities, serverInfo) {
|
|
@@ -178055,7 +178227,7 @@ var init_serve_shared = __esm({
|
|
|
178055
178227
|
|
|
178056
178228
|
// src/cli/version.ts
|
|
178057
178229
|
function getCliVersion() {
|
|
178058
|
-
return true ? "1.10.
|
|
178230
|
+
return true ? "1.10.5" : pkg.version;
|
|
178059
178231
|
}
|
|
178060
178232
|
var init_version3 = __esm({
|
|
178061
178233
|
"src/cli/version.ts"() {
|