memorix 1.9.11 → 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 +29 -1
- package/dist/cli/index.js +550 -102
- package/dist/index.d.ts +46 -0
- package/dist/index.js +272 -28
- 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 +29 -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 +5 -4
- package/docs/ROADMAP-1.9.12-2.0.md +722 -0
- package/package.json +4 -2
- 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/cli/update-checker.ts +2 -1
- 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
package/dist/sdk.js
CHANGED
|
@@ -8672,6 +8672,7 @@ __export(orama_store_exports, {
|
|
|
8672
8672
|
getActiveSemanticIndexProfile: () => getActiveSemanticIndexProfile,
|
|
8673
8673
|
getDb: () => getDb,
|
|
8674
8674
|
getDeferredCachedVectorHydration: () => getDeferredCachedVectorHydration,
|
|
8675
|
+
getLastSearchDiagnostics: () => getLastSearchDiagnostics,
|
|
8675
8676
|
getLastSearchMode: () => getLastSearchMode,
|
|
8676
8677
|
getObservationCount: () => getObservationCount,
|
|
8677
8678
|
getObservationsByIds: () => getObservationsByIds,
|
|
@@ -8701,6 +8702,18 @@ function rememberSearchMode(key, value) {
|
|
|
8701
8702
|
function getLastSearchMode(projectId) {
|
|
8702
8703
|
return lastSearchModeByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY) ?? "fulltext";
|
|
8703
8704
|
}
|
|
8705
|
+
function getLastSearchDiagnostics(projectId) {
|
|
8706
|
+
const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
|
|
8707
|
+
return diagnostics ? { ...diagnostics } : void 0;
|
|
8708
|
+
}
|
|
8709
|
+
function rememberSearchDiagnostics(key, value) {
|
|
8710
|
+
if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
8711
|
+
const oldest = lastSearchDiagnosticsByProject.keys().next().value;
|
|
8712
|
+
if (oldest !== void 0) lastSearchDiagnosticsByProject.delete(oldest);
|
|
8713
|
+
}
|
|
8714
|
+
lastSearchDiagnosticsByProject.delete(key);
|
|
8715
|
+
lastSearchDiagnosticsByProject.set(key, value);
|
|
8716
|
+
}
|
|
8704
8717
|
function getOptionalObservationStore() {
|
|
8705
8718
|
try {
|
|
8706
8719
|
return getObservationStore();
|
|
@@ -8983,6 +8996,7 @@ async function resetDb() {
|
|
|
8983
8996
|
indexEmbeddingProvider = null;
|
|
8984
8997
|
deferredCachedVectorHydration = null;
|
|
8985
8998
|
lastSearchModeByProject.clear();
|
|
8999
|
+
lastSearchDiagnosticsByProject.clear();
|
|
8986
9000
|
}
|
|
8987
9001
|
function isEmbeddingEnabled() {
|
|
8988
9002
|
return embeddingEnabled;
|
|
@@ -9200,6 +9214,7 @@ async function removeObservation(oramaId) {
|
|
|
9200
9214
|
await remove2(database, oramaId);
|
|
9201
9215
|
}
|
|
9202
9216
|
async function searchObservations(options) {
|
|
9217
|
+
const searchStartedAt = Date.now();
|
|
9203
9218
|
const perf = !!process.env.MEMORIX_PERF;
|
|
9204
9219
|
const t0 = perf ? performance.now() : 0;
|
|
9205
9220
|
const mark = (label) => {
|
|
@@ -9275,6 +9290,8 @@ async function searchObservations(options) {
|
|
|
9275
9290
|
let queryVector = null;
|
|
9276
9291
|
let embeddingProviderForSearch = null;
|
|
9277
9292
|
let embeddingUnavailable = false;
|
|
9293
|
+
let fallbackUsed = false;
|
|
9294
|
+
let fallbackReason;
|
|
9278
9295
|
if (quality !== "fast" && embeddingEnabled && hasQuery && tier !== "fast") {
|
|
9279
9296
|
try {
|
|
9280
9297
|
const provider2 = await getEmbeddingProvider();
|
|
@@ -9283,6 +9300,8 @@ async function searchObservations(options) {
|
|
|
9283
9300
|
const activeVectorDimensions = getVectorDimensions();
|
|
9284
9301
|
if (activeVectorDimensions !== null && provider2.dimensions !== activeVectorDimensions) {
|
|
9285
9302
|
embeddingUnavailable = true;
|
|
9303
|
+
fallbackUsed = true;
|
|
9304
|
+
fallbackReason = "embedding dimension mismatch; lexical search used";
|
|
9286
9305
|
rememberSearchMode(
|
|
9287
9306
|
modeKey,
|
|
9288
9307
|
`fulltext (embedding dimension mismatch: provider ${provider2.dimensions}d vs index ${activeVectorDimensions}d)`
|
|
@@ -9324,9 +9343,13 @@ async function searchObservations(options) {
|
|
|
9324
9343
|
}
|
|
9325
9344
|
} else {
|
|
9326
9345
|
embeddingUnavailable = true;
|
|
9346
|
+
fallbackUsed = true;
|
|
9347
|
+
fallbackReason = "embedding provider unavailable; lexical search used";
|
|
9327
9348
|
}
|
|
9328
9349
|
} catch (error) {
|
|
9329
9350
|
embeddingUnavailable = true;
|
|
9351
|
+
fallbackUsed = true;
|
|
9352
|
+
fallbackReason = "embedding failed or timed out; lexical search used";
|
|
9330
9353
|
rememberSearchMode(modeKey, "fulltext (embedding unavailable)");
|
|
9331
9354
|
console.error("[memorix] Embedding failed or timed out, falling back to fulltext search");
|
|
9332
9355
|
}
|
|
@@ -9376,6 +9399,8 @@ async function searchObservations(options) {
|
|
|
9376
9399
|
similarity: 0.25
|
|
9377
9400
|
};
|
|
9378
9401
|
rememberSearchMode(modeKey, "vector-only (hybrid empty fallback)");
|
|
9402
|
+
fallbackUsed = true;
|
|
9403
|
+
fallbackReason = "hybrid search returned no results; vector-only fallback used";
|
|
9379
9404
|
results = await search(database, vectorOnlyParams);
|
|
9380
9405
|
} catch {
|
|
9381
9406
|
}
|
|
@@ -9649,6 +9674,7 @@ async function searchObservations(options) {
|
|
|
9649
9674
|
mark(`rerank(skipped,tier=${tier})`);
|
|
9650
9675
|
}
|
|
9651
9676
|
let entries = intermediate.map(({ rawTime: _, _isCommandLog: _c, ...rest }) => rest);
|
|
9677
|
+
const candidateCount = entries.length;
|
|
9652
9678
|
for (const hit of results.hits) {
|
|
9653
9679
|
const doc = hit.document;
|
|
9654
9680
|
if (canReadObservation(doc, options.reader, projectIds ?? void 0)) rememberObservationDoc(doc);
|
|
@@ -9691,9 +9717,22 @@ async function searchObservations(options) {
|
|
|
9691
9717
|
}
|
|
9692
9718
|
}
|
|
9693
9719
|
}
|
|
9720
|
+
const beforeTokenBudget = entries.length;
|
|
9694
9721
|
if (options.maxTokens && options.maxTokens > 0) {
|
|
9695
9722
|
entries = applyTokenBudget(entries, options.maxTokens);
|
|
9696
9723
|
}
|
|
9724
|
+
rememberSearchDiagnostics(modeKey, {
|
|
9725
|
+
version: "1",
|
|
9726
|
+
mode: getLastSearchMode(options.projectId),
|
|
9727
|
+
rawCandidateCount: results.hits.length,
|
|
9728
|
+
candidateCount,
|
|
9729
|
+
selectedCount: entries.length,
|
|
9730
|
+
omittedCount: Math.max(0, candidateCount - entries.length),
|
|
9731
|
+
omittedByTokenBudget: Math.max(0, beforeTokenBudget - entries.length),
|
|
9732
|
+
fallbackUsed,
|
|
9733
|
+
...fallbackReason ? { fallbackReason } : {},
|
|
9734
|
+
elapsedMs: Math.max(0, Date.now() - searchStartedAt)
|
|
9735
|
+
});
|
|
9697
9736
|
if (options.trackAccess !== false) {
|
|
9698
9737
|
const returnedKeys = new Set(entries.map((entry) => makeEntryKey(entry.projectId, entry.id)));
|
|
9699
9738
|
const hitDocs = results.hits.map((hit) => ({ id: hit.id, doc: hit.document })).filter(({ doc }) => returnedKeys.has(makeEntryKey(doc.projectId, doc.observationId)));
|
|
@@ -9809,7 +9848,7 @@ function formatTime(isoDate) {
|
|
|
9809
9848
|
return isoDate;
|
|
9810
9849
|
}
|
|
9811
9850
|
}
|
|
9812
|
-
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_TITLE2, COMMAND_STYLE_TITLE, COMMAND_LIKE_QUERY2, COMMAND_INTENT_QUERY, NATURAL_LANGUAGE_MARKERS;
|
|
9851
|
+
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;
|
|
9813
9852
|
var init_orama_store = __esm({
|
|
9814
9853
|
"src/store/orama-store.ts"() {
|
|
9815
9854
|
"use strict";
|
|
@@ -9835,6 +9874,7 @@ var init_orama_store = __esm({
|
|
|
9835
9874
|
NON_CJK_HYBRID_SIMILARITY = 0.45;
|
|
9836
9875
|
CJK_RUN = /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+/gu;
|
|
9837
9876
|
lastSearchModeByProject = /* @__PURE__ */ new Map();
|
|
9877
|
+
lastSearchDiagnosticsByProject = /* @__PURE__ */ new Map();
|
|
9838
9878
|
SEARCH_MODE_DEFAULT_KEY = "__global__";
|
|
9839
9879
|
MAX_SEARCH_MODE_KEYS = 4096;
|
|
9840
9880
|
COMMAND_LOG_TITLE2 = /^(Ran:|Command:|Executed:)\s/i;
|
|
@@ -35571,6 +35611,25 @@ var init_models_generated = __esm({
|
|
|
35571
35611
|
}
|
|
35572
35612
|
},
|
|
35573
35613
|
"minimax": {
|
|
35614
|
+
"MiniMax-M3.1-Flash": {
|
|
35615
|
+
id: "MiniMax-M3.1-Flash",
|
|
35616
|
+
name: "MiniMax-M3.1-Flash",
|
|
35617
|
+
api: "anthropic-messages",
|
|
35618
|
+
provider: "minimax",
|
|
35619
|
+
baseUrl: "https://api.minimax.io/anthropic",
|
|
35620
|
+
compat: { "forceAdaptiveThinking": true },
|
|
35621
|
+
reasoning: true,
|
|
35622
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
35623
|
+
input: ["text", "image", "video"],
|
|
35624
|
+
cost: {
|
|
35625
|
+
input: 0.15,
|
|
35626
|
+
output: 0.6,
|
|
35627
|
+
cacheRead: 0.015,
|
|
35628
|
+
cacheWrite: 0
|
|
35629
|
+
},
|
|
35630
|
+
contextWindow: 1e6,
|
|
35631
|
+
maxTokens: 524288
|
|
35632
|
+
},
|
|
35574
35633
|
"MiniMax-M2.7": {
|
|
35575
35634
|
id: "MiniMax-M2.7",
|
|
35576
35635
|
name: "MiniMax-M2.7",
|
|
@@ -35611,6 +35670,7 @@ var init_models_generated = __esm({
|
|
|
35611
35670
|
api: "anthropic-messages",
|
|
35612
35671
|
provider: "minimax",
|
|
35613
35672
|
baseUrl: "https://api.minimax.io/anthropic",
|
|
35673
|
+
compat: { "forceAdaptiveThinking": true },
|
|
35614
35674
|
reasoning: true,
|
|
35615
35675
|
input: ["text", "image", "video"],
|
|
35616
35676
|
cost: {
|
|
@@ -35620,10 +35680,29 @@ var init_models_generated = __esm({
|
|
|
35620
35680
|
cacheWrite: 0
|
|
35621
35681
|
},
|
|
35622
35682
|
contextWindow: 1e6,
|
|
35623
|
-
maxTokens:
|
|
35683
|
+
maxTokens: 524288
|
|
35624
35684
|
}
|
|
35625
35685
|
},
|
|
35626
35686
|
"minimax-cn": {
|
|
35687
|
+
"MiniMax-M3.1-Flash": {
|
|
35688
|
+
id: "MiniMax-M3.1-Flash",
|
|
35689
|
+
name: "MiniMax-M3.1-Flash",
|
|
35690
|
+
api: "anthropic-messages",
|
|
35691
|
+
provider: "minimax-cn",
|
|
35692
|
+
baseUrl: "https://api.minimaxi.com/anthropic",
|
|
35693
|
+
compat: { "forceAdaptiveThinking": true },
|
|
35694
|
+
reasoning: true,
|
|
35695
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
35696
|
+
input: ["text", "image", "video"],
|
|
35697
|
+
cost: {
|
|
35698
|
+
input: 0.15,
|
|
35699
|
+
output: 0.6,
|
|
35700
|
+
cacheRead: 0.015,
|
|
35701
|
+
cacheWrite: 0
|
|
35702
|
+
},
|
|
35703
|
+
contextWindow: 1e6,
|
|
35704
|
+
maxTokens: 524288
|
|
35705
|
+
},
|
|
35627
35706
|
"MiniMax-M2.7": {
|
|
35628
35707
|
id: "MiniMax-M2.7",
|
|
35629
35708
|
name: "MiniMax-M2.7",
|
|
@@ -35664,6 +35743,7 @@ var init_models_generated = __esm({
|
|
|
35664
35743
|
api: "anthropic-messages",
|
|
35665
35744
|
provider: "minimax-cn",
|
|
35666
35745
|
baseUrl: "https://api.minimaxi.com/anthropic",
|
|
35746
|
+
compat: { "forceAdaptiveThinking": true },
|
|
35667
35747
|
reasoning: true,
|
|
35668
35748
|
input: ["text", "image", "video"],
|
|
35669
35749
|
cost: {
|
|
@@ -35673,7 +35753,7 @@ var init_models_generated = __esm({
|
|
|
35673
35753
|
cacheWrite: 0
|
|
35674
35754
|
},
|
|
35675
35755
|
contextWindow: 1e6,
|
|
35676
|
-
maxTokens:
|
|
35756
|
+
maxTokens: 524288
|
|
35677
35757
|
}
|
|
35678
35758
|
},
|
|
35679
35759
|
"mistral": {
|
|
@@ -38794,6 +38874,24 @@ var init_models_generated = __esm({
|
|
|
38794
38874
|
}
|
|
38795
38875
|
},
|
|
38796
38876
|
"openrouter": {
|
|
38877
|
+
"minimax/minimax-m3.1-flash:free": {
|
|
38878
|
+
id: "minimax/minimax-m3.1-flash:free",
|
|
38879
|
+
name: "MiniMax: MiniMax M3.1 Flash (free)",
|
|
38880
|
+
api: "openai-completions",
|
|
38881
|
+
provider: "openrouter",
|
|
38882
|
+
baseUrl: "https://openrouter.ai/api/v1",
|
|
38883
|
+
reasoning: true,
|
|
38884
|
+
thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
|
|
38885
|
+
input: ["text", "image"],
|
|
38886
|
+
cost: {
|
|
38887
|
+
input: 0,
|
|
38888
|
+
output: 0,
|
|
38889
|
+
cacheRead: 0,
|
|
38890
|
+
cacheWrite: 0
|
|
38891
|
+
},
|
|
38892
|
+
contextWindow: 1e6,
|
|
38893
|
+
maxTokens: 524288
|
|
38894
|
+
},
|
|
38797
38895
|
"ai21/jamba-large-1.7": {
|
|
38798
38896
|
id: "ai21/jamba-large-1.7",
|
|
38799
38897
|
name: "AI21: Jamba Large 1.7",
|
|
@@ -47495,6 +47593,14 @@ var init_models_generated = __esm({
|
|
|
47495
47593
|
}
|
|
47496
47594
|
});
|
|
47497
47595
|
|
|
47596
|
+
// packages/ai/dist/minimax-models.js
|
|
47597
|
+
var init_minimax_models = __esm({
|
|
47598
|
+
"packages/ai/dist/minimax-models.js"() {
|
|
47599
|
+
"use strict";
|
|
47600
|
+
init_esm_shims();
|
|
47601
|
+
}
|
|
47602
|
+
});
|
|
47603
|
+
|
|
47498
47604
|
// packages/ai/dist/models.js
|
|
47499
47605
|
function calculateCost(model, usage) {
|
|
47500
47606
|
usage.cost.input = model.cost.input / 1e6 * usage.input;
|
|
@@ -47541,6 +47647,8 @@ var init_models2 = __esm({
|
|
|
47541
47647
|
"use strict";
|
|
47542
47648
|
init_esm_shims();
|
|
47543
47649
|
init_models_generated();
|
|
47650
|
+
init_minimax_models();
|
|
47651
|
+
init_minimax_models();
|
|
47544
47652
|
modelRegistry = /* @__PURE__ */ new Map();
|
|
47545
47653
|
for (const [provider2, models] of Object.entries(MODELS)) {
|
|
47546
47654
|
const providerModels = /* @__PURE__ */ new Map();
|
|
@@ -55494,6 +55602,25 @@ function buildParams2(model, context, isOAuthToken2, options) {
|
|
|
55494
55602
|
params.tool_choice = options.toolChoice;
|
|
55495
55603
|
}
|
|
55496
55604
|
}
|
|
55605
|
+
return normalizeMiniMaxParams(model, params, options);
|
|
55606
|
+
}
|
|
55607
|
+
function normalizeMiniMaxParams(model, params, options) {
|
|
55608
|
+
if (model.provider !== "minimax" && model.provider !== "minimax-cn")
|
|
55609
|
+
return params;
|
|
55610
|
+
if (params.model === "MiniMax-M3.1-Flash") {
|
|
55611
|
+
const effort = params.output_config?.effort ?? options?.effort ?? "max";
|
|
55612
|
+
const normalized = { ...params, thinking: { type: "adaptive" } };
|
|
55613
|
+
normalized.output_config = {
|
|
55614
|
+
...params.output_config,
|
|
55615
|
+
effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
|
|
55616
|
+
};
|
|
55617
|
+
delete normalized.service_tier;
|
|
55618
|
+
delete normalized.reasoning_split;
|
|
55619
|
+
return normalized;
|
|
55620
|
+
}
|
|
55621
|
+
if (params.model === "MiniMax-M3" && params.thinking) {
|
|
55622
|
+
return { ...params, thinking: { type: params.thinking.type === "disabled" ? "disabled" : "adaptive" } };
|
|
55623
|
+
}
|
|
55497
55624
|
return params;
|
|
55498
55625
|
}
|
|
55499
55626
|
function normalizeToolCallId(id) {
|
|
@@ -55800,6 +55927,7 @@ var init_anthropic = __esm({
|
|
|
55800
55927
|
if (nextParams !== void 0) {
|
|
55801
55928
|
params = nextParams;
|
|
55802
55929
|
}
|
|
55930
|
+
params = normalizeMiniMaxParams(model, params, options);
|
|
55803
55931
|
const requestOptions = {
|
|
55804
55932
|
...options?.signal ? { signal: options.signal } : {},
|
|
55805
55933
|
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
@@ -77901,7 +78029,7 @@ var require_websocket = __commonJS({
|
|
|
77901
78029
|
var http3 = __require("http");
|
|
77902
78030
|
var net = __require("net");
|
|
77903
78031
|
var tls = __require("tls");
|
|
77904
|
-
var { randomBytes: randomBytes2, createHash:
|
|
78032
|
+
var { randomBytes: randomBytes2, createHash: createHash21 } = __require("crypto");
|
|
77905
78033
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
77906
78034
|
var { URL: URL2 } = __require("url");
|
|
77907
78035
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -78569,7 +78697,7 @@ var require_websocket = __commonJS({
|
|
|
78569
78697
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
78570
78698
|
return;
|
|
78571
78699
|
}
|
|
78572
|
-
const digest2 =
|
|
78700
|
+
const digest2 = createHash21("sha1").update(key + GUID).digest("base64");
|
|
78573
78701
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
78574
78702
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
78575
78703
|
return;
|
|
@@ -78941,7 +79069,7 @@ var require_websocket_server = __commonJS({
|
|
|
78941
79069
|
var EventEmitter2 = __require("events");
|
|
78942
79070
|
var http3 = __require("http");
|
|
78943
79071
|
var { Duplex } = __require("stream");
|
|
78944
|
-
var { createHash:
|
|
79072
|
+
var { createHash: createHash21 } = __require("crypto");
|
|
78945
79073
|
var extension3 = require_extension();
|
|
78946
79074
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
78947
79075
|
var subprotocol2 = require_subprotocol();
|
|
@@ -79248,7 +79376,7 @@ var require_websocket_server = __commonJS({
|
|
|
79248
79376
|
);
|
|
79249
79377
|
}
|
|
79250
79378
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
79251
|
-
const digest2 =
|
|
79379
|
+
const digest2 = createHash21("sha1").update(key + GUID).digest("base64");
|
|
79252
79380
|
const headers = [
|
|
79253
79381
|
"HTTP/1.1 101 Switching Protocols",
|
|
79254
79382
|
"Upgrade: websocket",
|
|
@@ -138570,6 +138698,18 @@ var init_openai_completions = __esm({
|
|
|
138570
138698
|
if (nextParams !== void 0) {
|
|
138571
138699
|
params = nextParams;
|
|
138572
138700
|
}
|
|
138701
|
+
if (model.provider === "openrouter" && new URL(model.baseUrl).hostname === "openrouter.ai" && params.model === "minimax/minimax-m3.1-flash:free") {
|
|
138702
|
+
const flash = params;
|
|
138703
|
+
const effort = flash.reasoning?.effort ?? "max";
|
|
138704
|
+
flash.reasoning = {
|
|
138705
|
+
...flash.reasoning,
|
|
138706
|
+
enabled: true,
|
|
138707
|
+
effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
|
|
138708
|
+
};
|
|
138709
|
+
delete flash.reasoning_effort;
|
|
138710
|
+
delete flash.reasoning_split;
|
|
138711
|
+
delete flash.service_tier;
|
|
138712
|
+
}
|
|
138573
138713
|
const requestOptions = {
|
|
138574
138714
|
...options?.signal ? { signal: options.signal } : {},
|
|
138575
138715
|
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
@@ -156858,7 +156998,7 @@ function appendLine(lines, candidate, maxTokens, omitted, omittedKind, selected,
|
|
|
156858
156998
|
if (receiptSelection) selected?.push(receiptSelection);
|
|
156859
156999
|
return true;
|
|
156860
157000
|
}
|
|
156861
|
-
omitted.push(omittedKind);
|
|
157001
|
+
omitted.push(receiptSelection?.id ? `${omittedKind}|${receiptSelection.id}` : omittedKind);
|
|
156862
157002
|
return false;
|
|
156863
157003
|
}
|
|
156864
157004
|
function freshnessForMemory(status) {
|
|
@@ -156884,15 +157024,23 @@ function receiptOmissionKind(raw) {
|
|
|
156884
157024
|
}
|
|
156885
157025
|
function receiptOmissions(omitted, hiddenCautionMemoryCount) {
|
|
156886
157026
|
const counts = /* @__PURE__ */ new Map();
|
|
157027
|
+
const samples = /* @__PURE__ */ new Map();
|
|
156887
157028
|
for (const raw of omitted) {
|
|
156888
|
-
const
|
|
157029
|
+
const [omittedKind, sampleId] = raw.split("|", 2);
|
|
157030
|
+
const kind = receiptOmissionKind(omittedKind);
|
|
156889
157031
|
if (!kind || raw.endsWith("-heading")) continue;
|
|
156890
157032
|
counts.set(kind, (counts.get(kind) ?? 0) + 1);
|
|
157033
|
+
if (sampleId) {
|
|
157034
|
+
const values = samples.get(kind) ?? [];
|
|
157035
|
+
if (!values.includes(sampleId) && values.length < 3) values.push(sampleId);
|
|
157036
|
+
samples.set(kind, values);
|
|
157037
|
+
}
|
|
156891
157038
|
}
|
|
156892
157039
|
const receipt = [...counts.entries()].map(([kind, count2]) => ({
|
|
156893
157040
|
kind,
|
|
156894
157041
|
reason: "token-budget",
|
|
156895
|
-
count: count2
|
|
157042
|
+
count: count2,
|
|
157043
|
+
...samples.get(kind)?.length ? { sampleIds: samples.get(kind) } : {}
|
|
156896
157044
|
}));
|
|
156897
157045
|
if (hiddenCautionMemoryCount > 0) {
|
|
156898
157046
|
receipt.push({
|
|
@@ -157601,6 +157749,16 @@ async function buildTaskWorkset(input) {
|
|
|
157601
157749
|
...base,
|
|
157602
157750
|
budget: { maxTokens }
|
|
157603
157751
|
});
|
|
157752
|
+
const omittedReceipt = receiptOmissions(rendered.omittedItems, base.hiddenCautionMemoryCount);
|
|
157753
|
+
const retrieval = {
|
|
157754
|
+
mode: input.retrieval?.mode ?? (input.semanticCode ? "hybrid" : "unknown"),
|
|
157755
|
+
...input.retrieval?.codeProvider || input.providerQuality?.selected ? { codeProvider: input.retrieval?.codeProvider ?? input.providerQuality?.selected } : {},
|
|
157756
|
+
fallbackUsed: Boolean(input.retrieval?.fallbackReason),
|
|
157757
|
+
...input.retrieval?.fallbackReason ? { fallbackReason: input.retrieval.fallbackReason } : {},
|
|
157758
|
+
candidateCount: governed.plan.decisions.length,
|
|
157759
|
+
selectedCount: rendered.selected.length,
|
|
157760
|
+
omittedCount: omittedReceipt.reduce((total, omission) => total + omission.count, 0)
|
|
157761
|
+
};
|
|
157604
157762
|
const receipt = {
|
|
157605
157763
|
version: "1.3",
|
|
157606
157764
|
target: input.deliveryTarget ?? "project-context",
|
|
@@ -157609,8 +157767,9 @@ async function buildTaskWorkset(input) {
|
|
|
157609
157767
|
maxTokens,
|
|
157610
157768
|
tokenCount: rendered.tokenCount
|
|
157611
157769
|
},
|
|
157770
|
+
retrieval,
|
|
157612
157771
|
selected: rendered.selected,
|
|
157613
|
-
omitted:
|
|
157772
|
+
omitted: omittedReceipt,
|
|
157614
157773
|
governance: {
|
|
157615
157774
|
scope: "optional-evidence",
|
|
157616
157775
|
mode: governed.plan.mode,
|
|
@@ -157618,7 +157777,12 @@ async function buildTaskWorkset(input) {
|
|
|
157618
157777
|
kind: decision.candidate.kind,
|
|
157619
157778
|
...decision.candidate.id ? { id: decision.candidate.id } : {},
|
|
157620
157779
|
disposition: decision.disposition,
|
|
157621
|
-
reasons: decision.reasons
|
|
157780
|
+
reasons: decision.reasons,
|
|
157781
|
+
...decision.candidate.freshness ? { freshness: decision.candidate.freshness } : {},
|
|
157782
|
+
...decision.candidate.trust ? { trust: decision.candidate.trust } : {},
|
|
157783
|
+
...decision.candidate.quality ? { quality: decision.candidate.quality } : {},
|
|
157784
|
+
...decision.candidate.conflict ? { conflict: decision.candidate.conflict } : {},
|
|
157785
|
+
...decision.candidate.evidenceCount !== void 0 ? { evidenceCount: decision.candidate.evidenceCount } : {}
|
|
157622
157786
|
})),
|
|
157623
157787
|
cautions: governed.plan.cautions
|
|
157624
157788
|
},
|
|
@@ -158956,7 +159120,7 @@ var compaction_checkpoint_store_exports = {};
|
|
|
158956
159120
|
__export(compaction_checkpoint_store_exports, {
|
|
158957
159121
|
CompactionCheckpointStore: () => CompactionCheckpointStore
|
|
158958
159122
|
});
|
|
158959
|
-
import { createHash as
|
|
159123
|
+
import { createHash as createHash19, randomUUID as randomUUID16 } from "crypto";
|
|
158960
159124
|
function optionalText7(value) {
|
|
158961
159125
|
return typeof value === "string" && value ? value : void 0;
|
|
158962
159126
|
}
|
|
@@ -158998,7 +159162,7 @@ function sourceKeyFor(input, summary) {
|
|
|
158998
159162
|
input.tokensBefore ?? "",
|
|
158999
159163
|
input.firstKeptEntryId ?? ""
|
|
159000
159164
|
].join("\0");
|
|
159001
|
-
return `derived:${
|
|
159165
|
+
return `derived:${createHash19("sha256").update(material).digest("hex").slice(0, 32)}`;
|
|
159002
159166
|
}
|
|
159003
159167
|
function rowToCheckpoint(row) {
|
|
159004
159168
|
return {
|
|
@@ -159837,6 +160001,11 @@ async function buildAutoProjectContext(input) {
|
|
|
159837
160001
|
...alwaysOn.profile.length > 0 || alwaysOn.state || alwaysOn.durable.length > 0 ? { alwaysOn } : {},
|
|
159838
160002
|
...semanticOutline ? { semanticCode: semanticOutline } : {},
|
|
159839
160003
|
providerQuality: providerQuality2,
|
|
160004
|
+
retrieval: {
|
|
160005
|
+
mode: semanticOutline ? "hybrid" : "lexical",
|
|
160006
|
+
codeProvider: providerQuality2.selected,
|
|
160007
|
+
...externalCaution ? { fallbackReason: externalCaution } : {}
|
|
160008
|
+
},
|
|
159840
160009
|
currentFacts: worksetFactLines(currentFacts),
|
|
159841
160010
|
...continuation ? { continuation } : {},
|
|
159842
160011
|
...continuity ? { continuity } : {},
|
|
@@ -160382,6 +160551,10 @@ async function attachTaskWorkset(input) {
|
|
|
160382
160551
|
startHere: uniq2([...semanticStartHere, ...input.pack.suggestedReads]),
|
|
160383
160552
|
...semanticCode ? { semanticCode } : {},
|
|
160384
160553
|
...input.providerQuality ? { providerQuality: input.providerQuality } : {},
|
|
160554
|
+
retrieval: {
|
|
160555
|
+
mode: semanticCode ? "hybrid" : "unknown",
|
|
160556
|
+
...input.providerQuality?.selected ? { codeProvider: input.providerQuality.selected } : {}
|
|
160557
|
+
},
|
|
160385
160558
|
reliableMemory: input.pack.memories.filter((memory) => memory.status === "current").map((memory) => ({
|
|
160386
160559
|
id: memory.id,
|
|
160387
160560
|
title: memory.title,
|
|
@@ -167373,7 +167546,7 @@ init_freshness();
|
|
|
167373
167546
|
init_obs_store();
|
|
167374
167547
|
init_mini_skill_store();
|
|
167375
167548
|
init_session_store();
|
|
167376
|
-
import { createHash as
|
|
167549
|
+
import { createHash as createHash20 } from "crypto";
|
|
167377
167550
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
167378
167551
|
import { z as z627 } from "zod";
|
|
167379
167552
|
|
|
@@ -167890,6 +168063,7 @@ function normalizeMemoryBrowseQuery(query) {
|
|
|
167890
168063
|
return broadMemoryRequests.has(compact) ? "" : query;
|
|
167891
168064
|
}
|
|
167892
168065
|
async function compactSearch(options, surface = "mcp") {
|
|
168066
|
+
const startedAt = Date.now();
|
|
167893
168067
|
await ensureFreshIndex({ loadCorpus: false });
|
|
167894
168068
|
const searchOptions = { ...options, query: normalizeMemoryBrowseQuery(options.query) };
|
|
167895
168069
|
let entries = (await searchObservations(searchOptions)).map(
|
|
@@ -167943,7 +168117,25 @@ This project does have stored Memorix memories, but none matched the current que
|
|
|
167943
168117
|
}
|
|
167944
168118
|
}
|
|
167945
168119
|
const totalTokens = countTextTokens(formatted);
|
|
167946
|
-
|
|
168120
|
+
const diagnostics = getLastSearchDiagnostics(options.projectId);
|
|
168121
|
+
return {
|
|
168122
|
+
entries,
|
|
168123
|
+
formatted,
|
|
168124
|
+
totalTokens,
|
|
168125
|
+
receipt: {
|
|
168126
|
+
version: "1",
|
|
168127
|
+
mode: getLastSearchMode(options.projectId),
|
|
168128
|
+
resultCount: entries.length,
|
|
168129
|
+
candidateCount: diagnostics?.candidateCount ?? entries.length,
|
|
168130
|
+
selectedCount: diagnostics?.selectedCount ?? entries.length,
|
|
168131
|
+
omittedCount: diagnostics?.omittedCount ?? 0,
|
|
168132
|
+
omittedByTokenBudget: diagnostics?.omittedByTokenBudget ?? 0,
|
|
168133
|
+
fallbackUsed: diagnostics?.fallbackUsed ?? false,
|
|
168134
|
+
...diagnostics?.fallbackReason ? { fallbackReason: diagnostics.fallbackReason } : {},
|
|
168135
|
+
tokenCount: totalTokens,
|
|
168136
|
+
elapsedMs: Math.max(0, Date.now() - startedAt)
|
|
168137
|
+
}
|
|
168138
|
+
};
|
|
167947
168139
|
}
|
|
167948
168140
|
async function compactTimeline(anchorId, projectId, depthBefore = 3, depthAfter = 3, reader2, surface = "mcp") {
|
|
167949
168141
|
const result = await getTimeline(anchorId, projectId, depthBefore, depthAfter, reader2);
|
|
@@ -171120,12 +171312,27 @@ function recordSurfacedIds(key, ids) {
|
|
|
171120
171312
|
|
|
171121
171313
|
// src/server/request-context.ts
|
|
171122
171314
|
init_esm_shims();
|
|
171315
|
+
import { createHash as createHash18 } from "crypto";
|
|
171123
171316
|
import path28 from "path";
|
|
171124
171317
|
function resolveRoot(projectRoot) {
|
|
171125
171318
|
const value = projectRoot.trim();
|
|
171126
171319
|
if (!value) throw new Error("Project binding requires a non-empty project root");
|
|
171127
171320
|
return path28.resolve(value);
|
|
171128
171321
|
}
|
|
171322
|
+
function hashBindingValue(value) {
|
|
171323
|
+
return `sha256:${createHash18("sha256").update(value).digest("hex")}`;
|
|
171324
|
+
}
|
|
171325
|
+
function remoteHost(remote) {
|
|
171326
|
+
const trimmed = remote.trim();
|
|
171327
|
+
if (!trimmed) return void 0;
|
|
171328
|
+
const scpHost = trimmed.match(/^[^@/\s]+@([^:\s/]+):/);
|
|
171329
|
+
if (scpHost) return scpHost[1].toLowerCase();
|
|
171330
|
+
try {
|
|
171331
|
+
return new URL(trimmed).hostname.toLowerCase() || void 0;
|
|
171332
|
+
} catch {
|
|
171333
|
+
return void 0;
|
|
171334
|
+
}
|
|
171335
|
+
}
|
|
171129
171336
|
var ProjectBindingController = class {
|
|
171130
171337
|
current;
|
|
171131
171338
|
constructor(projectRoot) {
|
|
@@ -171144,6 +171351,38 @@ var ProjectBindingController = class {
|
|
|
171144
171351
|
...actorId ? { actorId } : {}
|
|
171145
171352
|
};
|
|
171146
171353
|
}
|
|
171354
|
+
/**
|
|
171355
|
+
* Return binding diagnostics without exposing local paths or transport IDs.
|
|
171356
|
+
* The hashes let operators compare two surfaces while keeping the receipt
|
|
171357
|
+
* safe to pass through MCP, logs, and agent handoffs.
|
|
171358
|
+
*/
|
|
171359
|
+
receipt(options = {}) {
|
|
171360
|
+
const snapshot = this.snapshot();
|
|
171361
|
+
const handle = options.handle;
|
|
171362
|
+
const handleState = !handle ? "absent" : handle.expiresAt && Date.parse(handle.expiresAt) <= Date.now() ? "expired" : "active";
|
|
171363
|
+
return {
|
|
171364
|
+
version: "1",
|
|
171365
|
+
state: snapshot.projectId ? "resolved" : "unresolved",
|
|
171366
|
+
source: snapshot.source,
|
|
171367
|
+
explicit: snapshot.explicit,
|
|
171368
|
+
...snapshot.projectId ? { projectId: snapshot.projectId } : {},
|
|
171369
|
+
projectRootHash: hashBindingValue(snapshot.projectRoot),
|
|
171370
|
+
...options.dataDir ? { dataDirHash: hashBindingValue(path28.resolve(options.dataDir)) } : {},
|
|
171371
|
+
gitRemote: options.gitRemote?.trim() ? {
|
|
171372
|
+
state: "verified",
|
|
171373
|
+
hash: hashBindingValue(options.gitRemote.trim()),
|
|
171374
|
+
...remoteHost(options.gitRemote) ? { host: remoteHost(options.gitRemote) } : {}
|
|
171375
|
+
} : { state: "unavailable" },
|
|
171376
|
+
handle: {
|
|
171377
|
+
state: handleState,
|
|
171378
|
+
...handle ? { idHash: hashBindingValue(handle.handleId) } : {},
|
|
171379
|
+
...handle?.createdAt ? { createdAt: handle.createdAt } : {},
|
|
171380
|
+
...handle?.lastUsedAt ? { lastUsedAt: handle.lastUsedAt } : {},
|
|
171381
|
+
...handle?.expiresAt ? { expiresAt: handle.expiresAt } : {}
|
|
171382
|
+
},
|
|
171383
|
+
transport: options.transport ?? "unknown"
|
|
171384
|
+
};
|
|
171385
|
+
}
|
|
171147
171386
|
isExplicit() {
|
|
171148
171387
|
return this.current.explicit;
|
|
171149
171388
|
}
|
|
@@ -171196,7 +171435,7 @@ var MCP_SERVER_INFO_META_KEY = "io.modelcontextprotocol/serverInfo";
|
|
|
171196
171435
|
function getMcpServerInfo() {
|
|
171197
171436
|
return {
|
|
171198
171437
|
name: "memorix",
|
|
171199
|
-
version: true ? "1.
|
|
171438
|
+
version: true ? "1.10.0" : "1.0.1"
|
|
171200
171439
|
};
|
|
171201
171440
|
}
|
|
171202
171441
|
function createMcpDiscoverResult(capabilities, serverInfo) {
|
|
@@ -171331,7 +171570,7 @@ function coerceObjectArray(val) {
|
|
|
171331
171570
|
return [];
|
|
171332
171571
|
}
|
|
171333
171572
|
function createDeterministicInstanceId(projectId, agentType, agentName) {
|
|
171334
|
-
const digest2 =
|
|
171573
|
+
const digest2 = createHash20("sha256").update(projectId).update("\n").update(agentType).update("\n").update(agentName ?? "").digest("hex").slice(0, 24);
|
|
171335
171574
|
return `auto-${digest2}`;
|
|
171336
171575
|
}
|
|
171337
171576
|
var BOOTSTRAP_SAFE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -172416,20 +172655,17 @@ Use this as the \`topicKey\` parameter in \`memorix_store\` to enable upsert beh
|
|
|
172416
172655
|
if (duplicate) return duplicate;
|
|
172417
172656
|
}
|
|
172418
172657
|
let text3 = result.formatted;
|
|
172419
|
-
|
|
172420
|
-
const { getLastSearchMode: getLastSearchMode2 } = await Promise.resolve().then(() => (init_orama_store(), orama_store_exports));
|
|
172421
|
-
text3 += `
|
|
172658
|
+
text3 += `
|
|
172422
172659
|
|
|
172423
|
-
_Search mode: ${
|
|
172424
|
-
} catch {
|
|
172425
|
-
}
|
|
172660
|
+
_Search mode: ${result.receipt.mode}_`;
|
|
172426
172661
|
return {
|
|
172427
172662
|
content: [
|
|
172428
172663
|
{
|
|
172429
172664
|
type: "text",
|
|
172430
172665
|
text: text3
|
|
172431
172666
|
}
|
|
172432
|
-
]
|
|
172667
|
+
],
|
|
172668
|
+
structuredContent: { retrieval: result.receipt }
|
|
172433
172669
|
};
|
|
172434
172670
|
}, { loadCorpus: false });
|
|
172435
172671
|
}
|
|
@@ -174414,9 +174650,16 @@ Ensure the path points to a directory containing a .git folder (or a subdirector
|
|
|
174414
174650
|
agent,
|
|
174415
174651
|
reader: getObservationReader()
|
|
174416
174652
|
});
|
|
174653
|
+
const bindingReceipt = projectBinding.receipt({
|
|
174654
|
+
dataDir: projectDir2,
|
|
174655
|
+
transport: options.bindingTransport,
|
|
174656
|
+
gitRemote: project.gitRemote,
|
|
174657
|
+
handle: options.bindingHandle
|
|
174658
|
+
});
|
|
174417
174659
|
const lines = [
|
|
174418
174660
|
`[OK] Session started: ${result.session.id}`,
|
|
174419
174661
|
`Project: ${project.name} (${project.id})`,
|
|
174662
|
+
`Binding: ${bindingReceipt.state} via ${bindingReceipt.source}`,
|
|
174420
174663
|
result.session.agent ? `Agent: ${result.session.agent}` : "",
|
|
174421
174664
|
registeredAgent ? `Agent ID: ${registeredAgent.agent_id} (instance: ${registeredAgent.instance_id})` : "",
|
|
174422
174665
|
!registeredAgent ? "Coordination identity: not joined (memory/session context only)" : "",
|
|
@@ -174491,7 +174734,8 @@ ${s2.instruction}`.toLowerCase();
|
|
|
174491
174734
|
} catch {
|
|
174492
174735
|
}
|
|
174493
174736
|
return {
|
|
174494
|
-
content: [{ type: "text", text: lines.filter(Boolean).join("\n") }]
|
|
174737
|
+
content: [{ type: "text", text: lines.filter(Boolean).join("\n") }],
|
|
174738
|
+
structuredContent: { binding: bindingReceipt }
|
|
174495
174739
|
};
|
|
174496
174740
|
}
|
|
174497
174741
|
);
|