memorix 1.9.12 → 1.10.0
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 -1
- package/dist/cli/index.js +549 -101
- package/dist/index.d.ts +46 -0
- package/dist/index.js +271 -27
- package/dist/maintenance-runner.js +143 -3
- package/dist/media-audio-runner.js +143 -3
- package/dist/media-video-runner.js +143 -3
- package/dist/memcode/index.js +124 -8
- package/dist/memcode-runtime/CHANGELOG.md +20 -1
- package/dist/sdk.js +270 -26
- package/dist/vector-backfill-runner.js +143 -3
- package/docs/1.2.0-EVALUATION-HARNESS.md +88 -0
- package/docs/1.3-MEMORY-ARCHITECTURE.md +31 -0
- package/docs/API_REFERENCE.md +19 -0
- package/docs/DEVELOPMENT.md +16 -3
- package/docs/INTEGRATIONS.md +25 -0
- package/docs/PERFORMANCE.md +21 -6
- package/docs/README.md +4 -4
- package/docs/ROADMAP-1.9.12-2.0.md +92 -7
- package/package.json +3 -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 +164 -7
- package/src/cli/commands/memory.ts +1 -1
- package/src/cli/commands/serve-http.ts +30 -1
- package/src/cli/commands/setup.ts +5 -21
- package/src/codegraph/auto-context.ts +5 -0
- package/src/codegraph/context-pack.ts +4 -0
- package/src/compact/engine.ts +43 -2
- package/src/evaluation/context-task-matrix.ts +247 -0
- package/src/evaluation/context-task-runner.ts +175 -0
- package/src/integrations/registry.ts +191 -4
- package/src/knowledge/context-assembly.ts +33 -2
- package/src/knowledge/workset.ts +35 -3
- package/src/server/request-context.ts +96 -0
- package/src/server.ts +16 -4
- package/src/store/orama-store.ts +54 -0
|
@@ -7151,6 +7151,7 @@ __export(orama_store_exports, {
|
|
|
7151
7151
|
getActiveSemanticIndexProfile: () => getActiveSemanticIndexProfile,
|
|
7152
7152
|
getDb: () => getDb,
|
|
7153
7153
|
getDeferredCachedVectorHydration: () => getDeferredCachedVectorHydration,
|
|
7154
|
+
getLastSearchDiagnostics: () => getLastSearchDiagnostics,
|
|
7154
7155
|
getLastSearchMode: () => getLastSearchMode,
|
|
7155
7156
|
getObservationCount: () => getObservationCount,
|
|
7156
7157
|
getObservationsByIds: () => getObservationsByIds,
|
|
@@ -7180,6 +7181,18 @@ function rememberSearchMode(key, value) {
|
|
|
7180
7181
|
function getLastSearchMode(projectId) {
|
|
7181
7182
|
return lastSearchModeByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY) ?? "fulltext";
|
|
7182
7183
|
}
|
|
7184
|
+
function getLastSearchDiagnostics(projectId) {
|
|
7185
|
+
const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
|
|
7186
|
+
return diagnostics ? { ...diagnostics } : void 0;
|
|
7187
|
+
}
|
|
7188
|
+
function rememberSearchDiagnostics(key, value) {
|
|
7189
|
+
if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
7190
|
+
const oldest = lastSearchDiagnosticsByProject.keys().next().value;
|
|
7191
|
+
if (oldest !== void 0) lastSearchDiagnosticsByProject.delete(oldest);
|
|
7192
|
+
}
|
|
7193
|
+
lastSearchDiagnosticsByProject.delete(key);
|
|
7194
|
+
lastSearchDiagnosticsByProject.set(key, value);
|
|
7195
|
+
}
|
|
7183
7196
|
function getOptionalObservationStore() {
|
|
7184
7197
|
try {
|
|
7185
7198
|
return getObservationStore();
|
|
@@ -7462,6 +7475,7 @@ async function resetDb() {
|
|
|
7462
7475
|
indexEmbeddingProvider = null;
|
|
7463
7476
|
deferredCachedVectorHydration = null;
|
|
7464
7477
|
lastSearchModeByProject.clear();
|
|
7478
|
+
lastSearchDiagnosticsByProject.clear();
|
|
7465
7479
|
}
|
|
7466
7480
|
function isEmbeddingEnabled() {
|
|
7467
7481
|
return embeddingEnabled;
|
|
@@ -7679,6 +7693,7 @@ async function removeObservation(oramaId) {
|
|
|
7679
7693
|
await remove2(database, oramaId);
|
|
7680
7694
|
}
|
|
7681
7695
|
async function searchObservations(options) {
|
|
7696
|
+
const searchStartedAt = Date.now();
|
|
7682
7697
|
const perf = !!process.env.MEMORIX_PERF;
|
|
7683
7698
|
const t0 = perf ? performance.now() : 0;
|
|
7684
7699
|
const mark = (label) => {
|
|
@@ -7754,6 +7769,8 @@ async function searchObservations(options) {
|
|
|
7754
7769
|
let queryVector = null;
|
|
7755
7770
|
let embeddingProviderForSearch = null;
|
|
7756
7771
|
let embeddingUnavailable = false;
|
|
7772
|
+
let fallbackUsed = false;
|
|
7773
|
+
let fallbackReason;
|
|
7757
7774
|
if (quality !== "fast" && embeddingEnabled && hasQuery && tier !== "fast") {
|
|
7758
7775
|
try {
|
|
7759
7776
|
const provider2 = await getEmbeddingProvider();
|
|
@@ -7762,6 +7779,8 @@ async function searchObservations(options) {
|
|
|
7762
7779
|
const activeVectorDimensions = getVectorDimensions();
|
|
7763
7780
|
if (activeVectorDimensions !== null && provider2.dimensions !== activeVectorDimensions) {
|
|
7764
7781
|
embeddingUnavailable = true;
|
|
7782
|
+
fallbackUsed = true;
|
|
7783
|
+
fallbackReason = "embedding dimension mismatch; lexical search used";
|
|
7765
7784
|
rememberSearchMode(
|
|
7766
7785
|
modeKey,
|
|
7767
7786
|
`fulltext (embedding dimension mismatch: provider ${provider2.dimensions}d vs index ${activeVectorDimensions}d)`
|
|
@@ -7803,9 +7822,13 @@ async function searchObservations(options) {
|
|
|
7803
7822
|
}
|
|
7804
7823
|
} else {
|
|
7805
7824
|
embeddingUnavailable = true;
|
|
7825
|
+
fallbackUsed = true;
|
|
7826
|
+
fallbackReason = "embedding provider unavailable; lexical search used";
|
|
7806
7827
|
}
|
|
7807
7828
|
} catch (error) {
|
|
7808
7829
|
embeddingUnavailable = true;
|
|
7830
|
+
fallbackUsed = true;
|
|
7831
|
+
fallbackReason = "embedding failed or timed out; lexical search used";
|
|
7809
7832
|
rememberSearchMode(modeKey, "fulltext (embedding unavailable)");
|
|
7810
7833
|
console.error("[memorix] Embedding failed or timed out, falling back to fulltext search");
|
|
7811
7834
|
}
|
|
@@ -7855,6 +7878,8 @@ async function searchObservations(options) {
|
|
|
7855
7878
|
similarity: 0.25
|
|
7856
7879
|
};
|
|
7857
7880
|
rememberSearchMode(modeKey, "vector-only (hybrid empty fallback)");
|
|
7881
|
+
fallbackUsed = true;
|
|
7882
|
+
fallbackReason = "hybrid search returned no results; vector-only fallback used";
|
|
7858
7883
|
results = await search(database, vectorOnlyParams);
|
|
7859
7884
|
} catch {
|
|
7860
7885
|
}
|
|
@@ -8128,6 +8153,7 @@ async function searchObservations(options) {
|
|
|
8128
8153
|
mark(`rerank(skipped,tier=${tier})`);
|
|
8129
8154
|
}
|
|
8130
8155
|
let entries = intermediate.map(({ rawTime: _, _isCommandLog: _c, ...rest }) => rest);
|
|
8156
|
+
const candidateCount = entries.length;
|
|
8131
8157
|
for (const hit of results.hits) {
|
|
8132
8158
|
const doc = hit.document;
|
|
8133
8159
|
if (canReadObservation(doc, options.reader, projectIds ?? void 0)) rememberObservationDoc(doc);
|
|
@@ -8170,9 +8196,22 @@ async function searchObservations(options) {
|
|
|
8170
8196
|
}
|
|
8171
8197
|
}
|
|
8172
8198
|
}
|
|
8199
|
+
const beforeTokenBudget = entries.length;
|
|
8173
8200
|
if (options.maxTokens && options.maxTokens > 0) {
|
|
8174
8201
|
entries = applyTokenBudget(entries, options.maxTokens);
|
|
8175
8202
|
}
|
|
8203
|
+
rememberSearchDiagnostics(modeKey, {
|
|
8204
|
+
version: "1",
|
|
8205
|
+
mode: getLastSearchMode(options.projectId),
|
|
8206
|
+
rawCandidateCount: results.hits.length,
|
|
8207
|
+
candidateCount,
|
|
8208
|
+
selectedCount: entries.length,
|
|
8209
|
+
omittedCount: Math.max(0, candidateCount - entries.length),
|
|
8210
|
+
omittedByTokenBudget: Math.max(0, beforeTokenBudget - entries.length),
|
|
8211
|
+
fallbackUsed,
|
|
8212
|
+
...fallbackReason ? { fallbackReason } : {},
|
|
8213
|
+
elapsedMs: Math.max(0, Date.now() - searchStartedAt)
|
|
8214
|
+
});
|
|
8176
8215
|
if (options.trackAccess !== false) {
|
|
8177
8216
|
const returnedKeys = new Set(entries.map((entry) => makeEntryKey(entry.projectId, entry.id)));
|
|
8178
8217
|
const hitDocs = results.hits.map((hit) => ({ id: hit.id, doc: hit.document })).filter(({ doc }) => returnedKeys.has(makeEntryKey(doc.projectId, doc.observationId)));
|
|
@@ -8288,7 +8327,7 @@ function formatTime(isoDate) {
|
|
|
8288
8327
|
return isoDate;
|
|
8289
8328
|
}
|
|
8290
8329
|
}
|
|
8291
|
-
var db, dbInitPromise, dbGeneration, embeddingEnabled, embeddingDimensions, indexEmbeddingProvider, deferredCachedVectorHydration, NON_CJK_HYBRID_SIMILARITY, CJK_RUN, lastSearchModeByProject, SEARCH_MODE_DEFAULT_KEY, MAX_SEARCH_MODE_KEYS, COMMAND_LOG_TITLE, COMMAND_STYLE_TITLE, COMMAND_LIKE_QUERY2, COMMAND_INTENT_QUERY, NATURAL_LANGUAGE_MARKERS;
|
|
8330
|
+
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;
|
|
8292
8331
|
var init_orama_store = __esm({
|
|
8293
8332
|
"src/store/orama-store.ts"() {
|
|
8294
8333
|
"use strict";
|
|
@@ -8314,6 +8353,7 @@ var init_orama_store = __esm({
|
|
|
8314
8353
|
NON_CJK_HYBRID_SIMILARITY = 0.45;
|
|
8315
8354
|
CJK_RUN = /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+/gu;
|
|
8316
8355
|
lastSearchModeByProject = /* @__PURE__ */ new Map();
|
|
8356
|
+
lastSearchDiagnosticsByProject = /* @__PURE__ */ new Map();
|
|
8317
8357
|
SEARCH_MODE_DEFAULT_KEY = "__global__";
|
|
8318
8358
|
MAX_SEARCH_MODE_KEYS = 4096;
|
|
8319
8359
|
COMMAND_LOG_TITLE = /^(Ran:|Command:|Executed:)\s/i;
|
|
@@ -33691,6 +33731,25 @@ var init_models_generated = __esm({
|
|
|
33691
33731
|
}
|
|
33692
33732
|
},
|
|
33693
33733
|
"minimax": {
|
|
33734
|
+
"MiniMax-M3.1-Flash": {
|
|
33735
|
+
id: "MiniMax-M3.1-Flash",
|
|
33736
|
+
name: "MiniMax-M3.1-Flash",
|
|
33737
|
+
api: "anthropic-messages",
|
|
33738
|
+
provider: "minimax",
|
|
33739
|
+
baseUrl: "https://api.minimax.io/anthropic",
|
|
33740
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33741
|
+
reasoning: true,
|
|
33742
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
33743
|
+
input: ["text", "image", "video"],
|
|
33744
|
+
cost: {
|
|
33745
|
+
input: 0.15,
|
|
33746
|
+
output: 0.6,
|
|
33747
|
+
cacheRead: 0.015,
|
|
33748
|
+
cacheWrite: 0
|
|
33749
|
+
},
|
|
33750
|
+
contextWindow: 1e6,
|
|
33751
|
+
maxTokens: 524288
|
|
33752
|
+
},
|
|
33694
33753
|
"MiniMax-M2.7": {
|
|
33695
33754
|
id: "MiniMax-M2.7",
|
|
33696
33755
|
name: "MiniMax-M2.7",
|
|
@@ -33731,6 +33790,7 @@ var init_models_generated = __esm({
|
|
|
33731
33790
|
api: "anthropic-messages",
|
|
33732
33791
|
provider: "minimax",
|
|
33733
33792
|
baseUrl: "https://api.minimax.io/anthropic",
|
|
33793
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33734
33794
|
reasoning: true,
|
|
33735
33795
|
input: ["text", "image", "video"],
|
|
33736
33796
|
cost: {
|
|
@@ -33740,10 +33800,29 @@ var init_models_generated = __esm({
|
|
|
33740
33800
|
cacheWrite: 0
|
|
33741
33801
|
},
|
|
33742
33802
|
contextWindow: 1e6,
|
|
33743
|
-
maxTokens:
|
|
33803
|
+
maxTokens: 524288
|
|
33744
33804
|
}
|
|
33745
33805
|
},
|
|
33746
33806
|
"minimax-cn": {
|
|
33807
|
+
"MiniMax-M3.1-Flash": {
|
|
33808
|
+
id: "MiniMax-M3.1-Flash",
|
|
33809
|
+
name: "MiniMax-M3.1-Flash",
|
|
33810
|
+
api: "anthropic-messages",
|
|
33811
|
+
provider: "minimax-cn",
|
|
33812
|
+
baseUrl: "https://api.minimaxi.com/anthropic",
|
|
33813
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33814
|
+
reasoning: true,
|
|
33815
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
33816
|
+
input: ["text", "image", "video"],
|
|
33817
|
+
cost: {
|
|
33818
|
+
input: 0.15,
|
|
33819
|
+
output: 0.6,
|
|
33820
|
+
cacheRead: 0.015,
|
|
33821
|
+
cacheWrite: 0
|
|
33822
|
+
},
|
|
33823
|
+
contextWindow: 1e6,
|
|
33824
|
+
maxTokens: 524288
|
|
33825
|
+
},
|
|
33747
33826
|
"MiniMax-M2.7": {
|
|
33748
33827
|
id: "MiniMax-M2.7",
|
|
33749
33828
|
name: "MiniMax-M2.7",
|
|
@@ -33784,6 +33863,7 @@ var init_models_generated = __esm({
|
|
|
33784
33863
|
api: "anthropic-messages",
|
|
33785
33864
|
provider: "minimax-cn",
|
|
33786
33865
|
baseUrl: "https://api.minimaxi.com/anthropic",
|
|
33866
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33787
33867
|
reasoning: true,
|
|
33788
33868
|
input: ["text", "image", "video"],
|
|
33789
33869
|
cost: {
|
|
@@ -33793,7 +33873,7 @@ var init_models_generated = __esm({
|
|
|
33793
33873
|
cacheWrite: 0
|
|
33794
33874
|
},
|
|
33795
33875
|
contextWindow: 1e6,
|
|
33796
|
-
maxTokens:
|
|
33876
|
+
maxTokens: 524288
|
|
33797
33877
|
}
|
|
33798
33878
|
},
|
|
33799
33879
|
"mistral": {
|
|
@@ -36914,6 +36994,24 @@ var init_models_generated = __esm({
|
|
|
36914
36994
|
}
|
|
36915
36995
|
},
|
|
36916
36996
|
"openrouter": {
|
|
36997
|
+
"minimax/minimax-m3.1-flash:free": {
|
|
36998
|
+
id: "minimax/minimax-m3.1-flash:free",
|
|
36999
|
+
name: "MiniMax: MiniMax M3.1 Flash (free)",
|
|
37000
|
+
api: "openai-completions",
|
|
37001
|
+
provider: "openrouter",
|
|
37002
|
+
baseUrl: "https://openrouter.ai/api/v1",
|
|
37003
|
+
reasoning: true,
|
|
37004
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
37005
|
+
input: ["text", "image"],
|
|
37006
|
+
cost: {
|
|
37007
|
+
input: 0,
|
|
37008
|
+
output: 0,
|
|
37009
|
+
cacheRead: 0,
|
|
37010
|
+
cacheWrite: 0
|
|
37011
|
+
},
|
|
37012
|
+
contextWindow: 1e6,
|
|
37013
|
+
maxTokens: 524288
|
|
37014
|
+
},
|
|
36917
37015
|
"ai21/jamba-large-1.7": {
|
|
36918
37016
|
id: "ai21/jamba-large-1.7",
|
|
36919
37017
|
name: "AI21: Jamba Large 1.7",
|
|
@@ -45615,6 +45713,14 @@ var init_models_generated = __esm({
|
|
|
45615
45713
|
}
|
|
45616
45714
|
});
|
|
45617
45715
|
|
|
45716
|
+
// packages/ai/dist/minimax-models.js
|
|
45717
|
+
var init_minimax_models = __esm({
|
|
45718
|
+
"packages/ai/dist/minimax-models.js"() {
|
|
45719
|
+
"use strict";
|
|
45720
|
+
init_esm_shims();
|
|
45721
|
+
}
|
|
45722
|
+
});
|
|
45723
|
+
|
|
45618
45724
|
// packages/ai/dist/models.js
|
|
45619
45725
|
function calculateCost(model, usage) {
|
|
45620
45726
|
usage.cost.input = model.cost.input / 1e6 * usage.input;
|
|
@@ -45661,6 +45767,8 @@ var init_models2 = __esm({
|
|
|
45661
45767
|
"use strict";
|
|
45662
45768
|
init_esm_shims();
|
|
45663
45769
|
init_models_generated();
|
|
45770
|
+
init_minimax_models();
|
|
45771
|
+
init_minimax_models();
|
|
45664
45772
|
modelRegistry = /* @__PURE__ */ new Map();
|
|
45665
45773
|
for (const [provider2, models] of Object.entries(MODELS)) {
|
|
45666
45774
|
const providerModels = /* @__PURE__ */ new Map();
|
|
@@ -53614,6 +53722,25 @@ function buildParams2(model, context, isOAuthToken2, options) {
|
|
|
53614
53722
|
params.tool_choice = options.toolChoice;
|
|
53615
53723
|
}
|
|
53616
53724
|
}
|
|
53725
|
+
return normalizeMiniMaxParams(model, params, options);
|
|
53726
|
+
}
|
|
53727
|
+
function normalizeMiniMaxParams(model, params, options) {
|
|
53728
|
+
if (model.provider !== "minimax" && model.provider !== "minimax-cn")
|
|
53729
|
+
return params;
|
|
53730
|
+
if (params.model === "MiniMax-M3.1-Flash") {
|
|
53731
|
+
const effort = params.output_config?.effort ?? options?.effort ?? "max";
|
|
53732
|
+
const normalized = { ...params, thinking: { type: "adaptive" } };
|
|
53733
|
+
normalized.output_config = {
|
|
53734
|
+
...params.output_config,
|
|
53735
|
+
effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
|
|
53736
|
+
};
|
|
53737
|
+
delete normalized.service_tier;
|
|
53738
|
+
delete normalized.reasoning_split;
|
|
53739
|
+
return normalized;
|
|
53740
|
+
}
|
|
53741
|
+
if (params.model === "MiniMax-M3" && params.thinking) {
|
|
53742
|
+
return { ...params, thinking: { type: params.thinking.type === "disabled" ? "disabled" : "adaptive" } };
|
|
53743
|
+
}
|
|
53617
53744
|
return params;
|
|
53618
53745
|
}
|
|
53619
53746
|
function normalizeToolCallId(id) {
|
|
@@ -53920,6 +54047,7 @@ var init_anthropic = __esm({
|
|
|
53920
54047
|
if (nextParams !== void 0) {
|
|
53921
54048
|
params = nextParams;
|
|
53922
54049
|
}
|
|
54050
|
+
params = normalizeMiniMaxParams(model, params, options);
|
|
53923
54051
|
const requestOptions = {
|
|
53924
54052
|
...options?.signal ? { signal: options.signal } : {},
|
|
53925
54053
|
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
@@ -136690,6 +136818,18 @@ var init_openai_completions = __esm({
|
|
|
136690
136818
|
if (nextParams !== void 0) {
|
|
136691
136819
|
params = nextParams;
|
|
136692
136820
|
}
|
|
136821
|
+
if (model.provider === "openrouter" && new URL(model.baseUrl).hostname === "openrouter.ai" && params.model === "minimax/minimax-m3.1-flash:free") {
|
|
136822
|
+
const flash = params;
|
|
136823
|
+
const effort = flash.reasoning?.effort ?? "max";
|
|
136824
|
+
flash.reasoning = {
|
|
136825
|
+
...flash.reasoning,
|
|
136826
|
+
enabled: true,
|
|
136827
|
+
effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
|
|
136828
|
+
};
|
|
136829
|
+
delete flash.reasoning_effort;
|
|
136830
|
+
delete flash.reasoning_split;
|
|
136831
|
+
delete flash.service_tier;
|
|
136832
|
+
}
|
|
136693
136833
|
const requestOptions = {
|
|
136694
136834
|
...options?.signal ? { signal: options.signal } : {},
|
|
136695
136835
|
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
@@ -8139,6 +8139,7 @@ __export(orama_store_exports, {
|
|
|
8139
8139
|
getActiveSemanticIndexProfile: () => getActiveSemanticIndexProfile,
|
|
8140
8140
|
getDb: () => getDb,
|
|
8141
8141
|
getDeferredCachedVectorHydration: () => getDeferredCachedVectorHydration,
|
|
8142
|
+
getLastSearchDiagnostics: () => getLastSearchDiagnostics,
|
|
8142
8143
|
getLastSearchMode: () => getLastSearchMode,
|
|
8143
8144
|
getObservationCount: () => getObservationCount,
|
|
8144
8145
|
getObservationsByIds: () => getObservationsByIds,
|
|
@@ -8168,6 +8169,18 @@ function rememberSearchMode(key, value) {
|
|
|
8168
8169
|
function getLastSearchMode(projectId) {
|
|
8169
8170
|
return lastSearchModeByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY) ?? "fulltext";
|
|
8170
8171
|
}
|
|
8172
|
+
function getLastSearchDiagnostics(projectId) {
|
|
8173
|
+
const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
|
|
8174
|
+
return diagnostics ? { ...diagnostics } : void 0;
|
|
8175
|
+
}
|
|
8176
|
+
function rememberSearchDiagnostics(key, value) {
|
|
8177
|
+
if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
8178
|
+
const oldest = lastSearchDiagnosticsByProject.keys().next().value;
|
|
8179
|
+
if (oldest !== void 0) lastSearchDiagnosticsByProject.delete(oldest);
|
|
8180
|
+
}
|
|
8181
|
+
lastSearchDiagnosticsByProject.delete(key);
|
|
8182
|
+
lastSearchDiagnosticsByProject.set(key, value);
|
|
8183
|
+
}
|
|
8171
8184
|
function getOptionalObservationStore() {
|
|
8172
8185
|
try {
|
|
8173
8186
|
return getObservationStore();
|
|
@@ -8450,6 +8463,7 @@ async function resetDb() {
|
|
|
8450
8463
|
indexEmbeddingProvider = null;
|
|
8451
8464
|
deferredCachedVectorHydration = null;
|
|
8452
8465
|
lastSearchModeByProject.clear();
|
|
8466
|
+
lastSearchDiagnosticsByProject.clear();
|
|
8453
8467
|
}
|
|
8454
8468
|
function isEmbeddingEnabled() {
|
|
8455
8469
|
return embeddingEnabled;
|
|
@@ -8667,6 +8681,7 @@ async function removeObservation(oramaId) {
|
|
|
8667
8681
|
await remove2(database, oramaId);
|
|
8668
8682
|
}
|
|
8669
8683
|
async function searchObservations(options) {
|
|
8684
|
+
const searchStartedAt = Date.now();
|
|
8670
8685
|
const perf = !!process.env.MEMORIX_PERF;
|
|
8671
8686
|
const t0 = perf ? performance.now() : 0;
|
|
8672
8687
|
const mark = (label) => {
|
|
@@ -8742,6 +8757,8 @@ async function searchObservations(options) {
|
|
|
8742
8757
|
let queryVector = null;
|
|
8743
8758
|
let embeddingProviderForSearch = null;
|
|
8744
8759
|
let embeddingUnavailable = false;
|
|
8760
|
+
let fallbackUsed = false;
|
|
8761
|
+
let fallbackReason;
|
|
8745
8762
|
if (quality !== "fast" && embeddingEnabled && hasQuery && tier !== "fast") {
|
|
8746
8763
|
try {
|
|
8747
8764
|
const provider2 = await getEmbeddingProvider();
|
|
@@ -8750,6 +8767,8 @@ async function searchObservations(options) {
|
|
|
8750
8767
|
const activeVectorDimensions = getVectorDimensions();
|
|
8751
8768
|
if (activeVectorDimensions !== null && provider2.dimensions !== activeVectorDimensions) {
|
|
8752
8769
|
embeddingUnavailable = true;
|
|
8770
|
+
fallbackUsed = true;
|
|
8771
|
+
fallbackReason = "embedding dimension mismatch; lexical search used";
|
|
8753
8772
|
rememberSearchMode(
|
|
8754
8773
|
modeKey,
|
|
8755
8774
|
`fulltext (embedding dimension mismatch: provider ${provider2.dimensions}d vs index ${activeVectorDimensions}d)`
|
|
@@ -8791,9 +8810,13 @@ async function searchObservations(options) {
|
|
|
8791
8810
|
}
|
|
8792
8811
|
} else {
|
|
8793
8812
|
embeddingUnavailable = true;
|
|
8813
|
+
fallbackUsed = true;
|
|
8814
|
+
fallbackReason = "embedding provider unavailable; lexical search used";
|
|
8794
8815
|
}
|
|
8795
8816
|
} catch (error) {
|
|
8796
8817
|
embeddingUnavailable = true;
|
|
8818
|
+
fallbackUsed = true;
|
|
8819
|
+
fallbackReason = "embedding failed or timed out; lexical search used";
|
|
8797
8820
|
rememberSearchMode(modeKey, "fulltext (embedding unavailable)");
|
|
8798
8821
|
console.error("[memorix] Embedding failed or timed out, falling back to fulltext search");
|
|
8799
8822
|
}
|
|
@@ -8843,6 +8866,8 @@ async function searchObservations(options) {
|
|
|
8843
8866
|
similarity: 0.25
|
|
8844
8867
|
};
|
|
8845
8868
|
rememberSearchMode(modeKey, "vector-only (hybrid empty fallback)");
|
|
8869
|
+
fallbackUsed = true;
|
|
8870
|
+
fallbackReason = "hybrid search returned no results; vector-only fallback used";
|
|
8846
8871
|
results = await search(database, vectorOnlyParams);
|
|
8847
8872
|
} catch {
|
|
8848
8873
|
}
|
|
@@ -9116,6 +9141,7 @@ async function searchObservations(options) {
|
|
|
9116
9141
|
mark(`rerank(skipped,tier=${tier})`);
|
|
9117
9142
|
}
|
|
9118
9143
|
let entries = intermediate.map(({ rawTime: _, _isCommandLog: _c, ...rest }) => rest);
|
|
9144
|
+
const candidateCount = entries.length;
|
|
9119
9145
|
for (const hit of results.hits) {
|
|
9120
9146
|
const doc = hit.document;
|
|
9121
9147
|
if (canReadObservation(doc, options.reader, projectIds ?? void 0)) rememberObservationDoc(doc);
|
|
@@ -9158,9 +9184,22 @@ async function searchObservations(options) {
|
|
|
9158
9184
|
}
|
|
9159
9185
|
}
|
|
9160
9186
|
}
|
|
9187
|
+
const beforeTokenBudget = entries.length;
|
|
9161
9188
|
if (options.maxTokens && options.maxTokens > 0) {
|
|
9162
9189
|
entries = applyTokenBudget(entries, options.maxTokens);
|
|
9163
9190
|
}
|
|
9191
|
+
rememberSearchDiagnostics(modeKey, {
|
|
9192
|
+
version: "1",
|
|
9193
|
+
mode: getLastSearchMode(options.projectId),
|
|
9194
|
+
rawCandidateCount: results.hits.length,
|
|
9195
|
+
candidateCount,
|
|
9196
|
+
selectedCount: entries.length,
|
|
9197
|
+
omittedCount: Math.max(0, candidateCount - entries.length),
|
|
9198
|
+
omittedByTokenBudget: Math.max(0, beforeTokenBudget - entries.length),
|
|
9199
|
+
fallbackUsed,
|
|
9200
|
+
...fallbackReason ? { fallbackReason } : {},
|
|
9201
|
+
elapsedMs: Math.max(0, Date.now() - searchStartedAt)
|
|
9202
|
+
});
|
|
9164
9203
|
if (options.trackAccess !== false) {
|
|
9165
9204
|
const returnedKeys = new Set(entries.map((entry) => makeEntryKey(entry.projectId, entry.id)));
|
|
9166
9205
|
const hitDocs = results.hits.map((hit) => ({ id: hit.id, doc: hit.document })).filter(({ doc }) => returnedKeys.has(makeEntryKey(doc.projectId, doc.observationId)));
|
|
@@ -9276,7 +9315,7 @@ function formatTime(isoDate) {
|
|
|
9276
9315
|
return isoDate;
|
|
9277
9316
|
}
|
|
9278
9317
|
}
|
|
9279
|
-
var db, dbInitPromise, dbGeneration, embeddingEnabled, embeddingDimensions, indexEmbeddingProvider, deferredCachedVectorHydration, NON_CJK_HYBRID_SIMILARITY, CJK_RUN, lastSearchModeByProject, SEARCH_MODE_DEFAULT_KEY, MAX_SEARCH_MODE_KEYS, COMMAND_LOG_TITLE, COMMAND_STYLE_TITLE, COMMAND_LIKE_QUERY2, COMMAND_INTENT_QUERY, NATURAL_LANGUAGE_MARKERS;
|
|
9318
|
+
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;
|
|
9280
9319
|
var init_orama_store = __esm({
|
|
9281
9320
|
"src/store/orama-store.ts"() {
|
|
9282
9321
|
"use strict";
|
|
@@ -9302,6 +9341,7 @@ var init_orama_store = __esm({
|
|
|
9302
9341
|
NON_CJK_HYBRID_SIMILARITY = 0.45;
|
|
9303
9342
|
CJK_RUN = /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+/gu;
|
|
9304
9343
|
lastSearchModeByProject = /* @__PURE__ */ new Map();
|
|
9344
|
+
lastSearchDiagnosticsByProject = /* @__PURE__ */ new Map();
|
|
9305
9345
|
SEARCH_MODE_DEFAULT_KEY = "__global__";
|
|
9306
9346
|
MAX_SEARCH_MODE_KEYS = 4096;
|
|
9307
9347
|
COMMAND_LOG_TITLE = /^(Ran:|Command:|Executed:)\s/i;
|
|
@@ -33616,6 +33656,25 @@ var init_models_generated = __esm({
|
|
|
33616
33656
|
}
|
|
33617
33657
|
},
|
|
33618
33658
|
"minimax": {
|
|
33659
|
+
"MiniMax-M3.1-Flash": {
|
|
33660
|
+
id: "MiniMax-M3.1-Flash",
|
|
33661
|
+
name: "MiniMax-M3.1-Flash",
|
|
33662
|
+
api: "anthropic-messages",
|
|
33663
|
+
provider: "minimax",
|
|
33664
|
+
baseUrl: "https://api.minimax.io/anthropic",
|
|
33665
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33666
|
+
reasoning: true,
|
|
33667
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
33668
|
+
input: ["text", "image", "video"],
|
|
33669
|
+
cost: {
|
|
33670
|
+
input: 0.15,
|
|
33671
|
+
output: 0.6,
|
|
33672
|
+
cacheRead: 0.015,
|
|
33673
|
+
cacheWrite: 0
|
|
33674
|
+
},
|
|
33675
|
+
contextWindow: 1e6,
|
|
33676
|
+
maxTokens: 524288
|
|
33677
|
+
},
|
|
33619
33678
|
"MiniMax-M2.7": {
|
|
33620
33679
|
id: "MiniMax-M2.7",
|
|
33621
33680
|
name: "MiniMax-M2.7",
|
|
@@ -33656,6 +33715,7 @@ var init_models_generated = __esm({
|
|
|
33656
33715
|
api: "anthropic-messages",
|
|
33657
33716
|
provider: "minimax",
|
|
33658
33717
|
baseUrl: "https://api.minimax.io/anthropic",
|
|
33718
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33659
33719
|
reasoning: true,
|
|
33660
33720
|
input: ["text", "image", "video"],
|
|
33661
33721
|
cost: {
|
|
@@ -33665,10 +33725,29 @@ var init_models_generated = __esm({
|
|
|
33665
33725
|
cacheWrite: 0
|
|
33666
33726
|
},
|
|
33667
33727
|
contextWindow: 1e6,
|
|
33668
|
-
maxTokens:
|
|
33728
|
+
maxTokens: 524288
|
|
33669
33729
|
}
|
|
33670
33730
|
},
|
|
33671
33731
|
"minimax-cn": {
|
|
33732
|
+
"MiniMax-M3.1-Flash": {
|
|
33733
|
+
id: "MiniMax-M3.1-Flash",
|
|
33734
|
+
name: "MiniMax-M3.1-Flash",
|
|
33735
|
+
api: "anthropic-messages",
|
|
33736
|
+
provider: "minimax-cn",
|
|
33737
|
+
baseUrl: "https://api.minimaxi.com/anthropic",
|
|
33738
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33739
|
+
reasoning: true,
|
|
33740
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
33741
|
+
input: ["text", "image", "video"],
|
|
33742
|
+
cost: {
|
|
33743
|
+
input: 0.15,
|
|
33744
|
+
output: 0.6,
|
|
33745
|
+
cacheRead: 0.015,
|
|
33746
|
+
cacheWrite: 0
|
|
33747
|
+
},
|
|
33748
|
+
contextWindow: 1e6,
|
|
33749
|
+
maxTokens: 524288
|
|
33750
|
+
},
|
|
33672
33751
|
"MiniMax-M2.7": {
|
|
33673
33752
|
id: "MiniMax-M2.7",
|
|
33674
33753
|
name: "MiniMax-M2.7",
|
|
@@ -33709,6 +33788,7 @@ var init_models_generated = __esm({
|
|
|
33709
33788
|
api: "anthropic-messages",
|
|
33710
33789
|
provider: "minimax-cn",
|
|
33711
33790
|
baseUrl: "https://api.minimaxi.com/anthropic",
|
|
33791
|
+
compat: { "forceAdaptiveThinking": true },
|
|
33712
33792
|
reasoning: true,
|
|
33713
33793
|
input: ["text", "image", "video"],
|
|
33714
33794
|
cost: {
|
|
@@ -33718,7 +33798,7 @@ var init_models_generated = __esm({
|
|
|
33718
33798
|
cacheWrite: 0
|
|
33719
33799
|
},
|
|
33720
33800
|
contextWindow: 1e6,
|
|
33721
|
-
maxTokens:
|
|
33801
|
+
maxTokens: 524288
|
|
33722
33802
|
}
|
|
33723
33803
|
},
|
|
33724
33804
|
"mistral": {
|
|
@@ -36839,6 +36919,24 @@ var init_models_generated = __esm({
|
|
|
36839
36919
|
}
|
|
36840
36920
|
},
|
|
36841
36921
|
"openrouter": {
|
|
36922
|
+
"minimax/minimax-m3.1-flash:free": {
|
|
36923
|
+
id: "minimax/minimax-m3.1-flash:free",
|
|
36924
|
+
name: "MiniMax: MiniMax M3.1 Flash (free)",
|
|
36925
|
+
api: "openai-completions",
|
|
36926
|
+
provider: "openrouter",
|
|
36927
|
+
baseUrl: "https://openrouter.ai/api/v1",
|
|
36928
|
+
reasoning: true,
|
|
36929
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
36930
|
+
input: ["text", "image"],
|
|
36931
|
+
cost: {
|
|
36932
|
+
input: 0,
|
|
36933
|
+
output: 0,
|
|
36934
|
+
cacheRead: 0,
|
|
36935
|
+
cacheWrite: 0
|
|
36936
|
+
},
|
|
36937
|
+
contextWindow: 1e6,
|
|
36938
|
+
maxTokens: 524288
|
|
36939
|
+
},
|
|
36842
36940
|
"ai21/jamba-large-1.7": {
|
|
36843
36941
|
id: "ai21/jamba-large-1.7",
|
|
36844
36942
|
name: "AI21: Jamba Large 1.7",
|
|
@@ -45540,6 +45638,14 @@ var init_models_generated = __esm({
|
|
|
45540
45638
|
}
|
|
45541
45639
|
});
|
|
45542
45640
|
|
|
45641
|
+
// packages/ai/dist/minimax-models.js
|
|
45642
|
+
var init_minimax_models = __esm({
|
|
45643
|
+
"packages/ai/dist/minimax-models.js"() {
|
|
45644
|
+
"use strict";
|
|
45645
|
+
init_esm_shims();
|
|
45646
|
+
}
|
|
45647
|
+
});
|
|
45648
|
+
|
|
45543
45649
|
// packages/ai/dist/models.js
|
|
45544
45650
|
function calculateCost(model, usage) {
|
|
45545
45651
|
usage.cost.input = model.cost.input / 1e6 * usage.input;
|
|
@@ -45586,6 +45692,8 @@ var init_models2 = __esm({
|
|
|
45586
45692
|
"use strict";
|
|
45587
45693
|
init_esm_shims();
|
|
45588
45694
|
init_models_generated();
|
|
45695
|
+
init_minimax_models();
|
|
45696
|
+
init_minimax_models();
|
|
45589
45697
|
modelRegistry = /* @__PURE__ */ new Map();
|
|
45590
45698
|
for (const [provider2, models] of Object.entries(MODELS)) {
|
|
45591
45699
|
const providerModels = /* @__PURE__ */ new Map();
|
|
@@ -53539,6 +53647,25 @@ function buildParams2(model, context, isOAuthToken2, options) {
|
|
|
53539
53647
|
params.tool_choice = options.toolChoice;
|
|
53540
53648
|
}
|
|
53541
53649
|
}
|
|
53650
|
+
return normalizeMiniMaxParams(model, params, options);
|
|
53651
|
+
}
|
|
53652
|
+
function normalizeMiniMaxParams(model, params, options) {
|
|
53653
|
+
if (model.provider !== "minimax" && model.provider !== "minimax-cn")
|
|
53654
|
+
return params;
|
|
53655
|
+
if (params.model === "MiniMax-M3.1-Flash") {
|
|
53656
|
+
const effort = params.output_config?.effort ?? options?.effort ?? "max";
|
|
53657
|
+
const normalized = { ...params, thinking: { type: "adaptive" } };
|
|
53658
|
+
normalized.output_config = {
|
|
53659
|
+
...params.output_config,
|
|
53660
|
+
effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
|
|
53661
|
+
};
|
|
53662
|
+
delete normalized.service_tier;
|
|
53663
|
+
delete normalized.reasoning_split;
|
|
53664
|
+
return normalized;
|
|
53665
|
+
}
|
|
53666
|
+
if (params.model === "MiniMax-M3" && params.thinking) {
|
|
53667
|
+
return { ...params, thinking: { type: params.thinking.type === "disabled" ? "disabled" : "adaptive" } };
|
|
53668
|
+
}
|
|
53542
53669
|
return params;
|
|
53543
53670
|
}
|
|
53544
53671
|
function normalizeToolCallId(id) {
|
|
@@ -53845,6 +53972,7 @@ var init_anthropic = __esm({
|
|
|
53845
53972
|
if (nextParams !== void 0) {
|
|
53846
53973
|
params = nextParams;
|
|
53847
53974
|
}
|
|
53975
|
+
params = normalizeMiniMaxParams(model, params, options);
|
|
53848
53976
|
const requestOptions = {
|
|
53849
53977
|
...options?.signal ? { signal: options.signal } : {},
|
|
53850
53978
|
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
@@ -136615,6 +136743,18 @@ var init_openai_completions = __esm({
|
|
|
136615
136743
|
if (nextParams !== void 0) {
|
|
136616
136744
|
params = nextParams;
|
|
136617
136745
|
}
|
|
136746
|
+
if (model.provider === "openrouter" && new URL(model.baseUrl).hostname === "openrouter.ai" && params.model === "minimax/minimax-m3.1-flash:free") {
|
|
136747
|
+
const flash = params;
|
|
136748
|
+
const effort = flash.reasoning?.effort ?? "max";
|
|
136749
|
+
flash.reasoning = {
|
|
136750
|
+
...flash.reasoning,
|
|
136751
|
+
enabled: true,
|
|
136752
|
+
effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
|
|
136753
|
+
};
|
|
136754
|
+
delete flash.reasoning_effort;
|
|
136755
|
+
delete flash.reasoning_split;
|
|
136756
|
+
delete flash.service_tier;
|
|
136757
|
+
}
|
|
136618
136758
|
const requestOptions = {
|
|
136619
136759
|
...options?.signal ? { signal: options.signal } : {},
|
|
136620
136760
|
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|