memorix 1.9.12 → 1.10.1

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +2 -0
  3. package/README.zh-CN.md +2 -0
  4. package/dist/cli/index.js +720 -142
  5. package/dist/index.d.ts +46 -0
  6. package/dist/index.js +426 -67
  7. package/dist/maintenance-runner.js +199 -5
  8. package/dist/media-audio-runner.js +199 -5
  9. package/dist/media-video-runner.js +199 -5
  10. package/dist/memcode/index.js +124 -8
  11. package/dist/memcode-runtime/CHANGELOG.md +31 -1
  12. package/dist/sdk.js +425 -66
  13. package/dist/vector-backfill-runner.js +199 -5
  14. package/docs/1.2.0-EVALUATION-HARNESS.md +106 -0
  15. package/docs/1.3-MEMORY-ARCHITECTURE.md +31 -0
  16. package/docs/API_REFERENCE.md +19 -0
  17. package/docs/CONFIGURATION.md +25 -0
  18. package/docs/DEVELOPMENT.md +17 -3
  19. package/docs/INTEGRATIONS.md +25 -0
  20. package/docs/PERFORMANCE.md +21 -6
  21. package/docs/README.md +4 -4
  22. package/docs/ROADMAP-1.9.12-2.0.md +99 -7
  23. package/package.json +3 -1
  24. package/plugins/antigravity/memorix/plugin.json +1 -1
  25. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  26. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  27. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  28. package/plugins/copilot/memorix/plugin.json +1 -1
  29. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  30. package/plugins/hermes/memorix/plugin.yaml +1 -1
  31. package/plugins/omp/memorix/package.json +1 -1
  32. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  33. package/plugins/pi/memorix/package.json +1 -1
  34. package/server.json +2 -2
  35. package/src/cli/commands/agent-integrations.ts +164 -7
  36. package/src/cli/commands/init.ts +6 -2
  37. package/src/cli/commands/memory.ts +1 -1
  38. package/src/cli/commands/serve-http.ts +30 -1
  39. package/src/cli/commands/setup.ts +5 -21
  40. package/src/cli/tui/ConfigureView.tsx +2 -0
  41. package/src/codegraph/auto-context.ts +22 -0
  42. package/src/codegraph/context-pack.ts +19 -0
  43. package/src/compact/engine.ts +54 -2
  44. package/src/config/dotenv-loader.ts +1 -0
  45. package/src/config/resolved-config.ts +5 -2
  46. package/src/config/yaml-loader.ts +2 -2
  47. package/src/dashboard/server.ts +3 -0
  48. package/src/evaluation/context-task-matrix.ts +247 -0
  49. package/src/evaluation/context-task-runner.ts +175 -0
  50. package/src/integrations/registry.ts +191 -4
  51. package/src/knowledge/context-assembly.ts +46 -2
  52. package/src/knowledge/context-receipt.ts +32 -0
  53. package/src/knowledge/workset.ts +43 -3
  54. package/src/llm/provider.ts +2 -1
  55. package/src/multimodal/image-loader.ts +2 -2
  56. package/src/search/derived-view-receipt.ts +22 -0
  57. package/src/server/request-context.ts +96 -0
  58. package/src/server.ts +16 -4
  59. package/src/store/orama-store.ts +116 -0
package/dist/sdk.js CHANGED
@@ -3870,7 +3870,8 @@ function getResolvedConfig(options = {}) {
3870
3870
  const isAtlasCloud = memoryLlmProvider === "atlascloud";
3871
3871
  const isRequesty = memoryLlmProvider === "requesty";
3872
3872
  const isApiRoute = memoryLlmProvider === "apiroute";
3873
- const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute;
3873
+ const isCheaperInference = memoryLlmProvider === "cheaperinference";
3874
+ const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference;
3874
3875
  const memoryLlmApiKey = first(
3875
3876
  process.env.MEMORIX_LLM_API_KEY,
3876
3877
  process.env.MEMORIX_API_KEY,
@@ -3878,7 +3879,7 @@ function getResolvedConfig(options = {}) {
3878
3879
  yaml.llm?.apiKey,
3879
3880
  legacy.llm?.apiKey,
3880
3881
  // Never borrow another provider's credentials for these gateway presets.
3881
- isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : process.env.OPENAI_API_KEY,
3882
+ isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : isCheaperInference ? process.env.CHEAPER_INFERENCE_API_KEY : process.env.OPENAI_API_KEY,
3882
3883
  usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
3883
3884
  usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
3884
3885
  );
@@ -4062,6 +4063,7 @@ function getEnvSourceNames() {
4062
4063
  "OPENROUTER_API_KEY",
4063
4064
  "REQUESTY_API_KEY",
4064
4065
  "API_ROUTE_API_KEY",
4066
+ "CHEAPER_INFERENCE_API_KEY",
4065
4067
  "ATLASCLOUD_API_KEY"
4066
4068
  ].filter((name) => process.env[name]);
4067
4069
  }
@@ -7056,6 +7058,7 @@ var init_provider2 = __esm({
7056
7058
  openrouter: { baseUrl: "https://openrouter.ai/api/v1", model: "openai/gpt-4.1-nano" },
7057
7059
  requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
7058
7060
  apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
7061
+ cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
7059
7062
  atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
7060
7063
  custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
7061
7064
  };
@@ -8672,9 +8675,11 @@ __export(orama_store_exports, {
8672
8675
  getActiveSemanticIndexProfile: () => getActiveSemanticIndexProfile,
8673
8676
  getDb: () => getDb,
8674
8677
  getDeferredCachedVectorHydration: () => getDeferredCachedVectorHydration,
8678
+ getLastSearchDiagnostics: () => getLastSearchDiagnostics,
8675
8679
  getLastSearchMode: () => getLastSearchMode,
8676
8680
  getObservationCount: () => getObservationCount,
8677
8681
  getObservationsByIds: () => getObservationsByIds,
8682
+ getSearchDerivedViews: () => getSearchDerivedViews,
8678
8683
  getTimeline: () => getTimeline,
8679
8684
  getVectorDimensions: () => getVectorDimensions,
8680
8685
  hasObservationVector: () => hasObservationVector,
@@ -8701,6 +8706,68 @@ function rememberSearchMode(key, value) {
8701
8706
  function getLastSearchMode(projectId) {
8702
8707
  return lastSearchModeByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY) ?? "fulltext";
8703
8708
  }
8709
+ function getLastSearchDiagnostics(projectId) {
8710
+ const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
8711
+ return diagnostics ? { ...diagnostics } : void 0;
8712
+ }
8713
+ function getSearchDerivedViews() {
8714
+ const views = {};
8715
+ const store = getOptionalObservationStore();
8716
+ if (store) {
8717
+ try {
8718
+ const generation = store.getGeneration();
8719
+ if (store.hasLexicalIndex?.()) {
8720
+ views.fts = { generation, freshness: "current", rebuildStatus: "idle" };
8721
+ } else {
8722
+ views.fts = {
8723
+ generation,
8724
+ freshness: "unknown",
8725
+ rebuildStatus: "unavailable",
8726
+ failureReason: store.getBackendReason?.() ?? "persistent lexical index unavailable"
8727
+ };
8728
+ }
8729
+ } catch (error) {
8730
+ views.fts = {
8731
+ freshness: "unknown",
8732
+ rebuildStatus: "failed",
8733
+ failureReason: error instanceof Error ? error.message.slice(0, 240) : String(error).slice(0, 240)
8734
+ };
8735
+ }
8736
+ } else {
8737
+ views.fts = {
8738
+ freshness: "unknown",
8739
+ rebuildStatus: "unavailable",
8740
+ failureReason: "observation store is not initialized"
8741
+ };
8742
+ }
8743
+ views.orama = db ? { generation: dbGeneration, freshness: "current", rebuildStatus: "idle" } : {
8744
+ generation: dbGeneration,
8745
+ freshness: "unknown",
8746
+ rebuildStatus: "unavailable",
8747
+ failureReason: "Orama index is not initialized"
8748
+ };
8749
+ const configuredEmbeddingMode = process.env.MEMORIX_EMBEDDING?.trim().toLowerCase();
8750
+ if (configuredEmbeddingMode === "off") {
8751
+ views.embedding = { freshness: "current", rebuildStatus: "disabled" };
8752
+ } else if (embeddingEnabled) {
8753
+ views.embedding = { freshness: "current", rebuildStatus: "idle" };
8754
+ } else {
8755
+ views.embedding = {
8756
+ freshness: "unknown",
8757
+ rebuildStatus: "unavailable",
8758
+ failureReason: "embedding provider is not initialized"
8759
+ };
8760
+ }
8761
+ return views;
8762
+ }
8763
+ function rememberSearchDiagnostics(key, value) {
8764
+ if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
8765
+ const oldest = lastSearchDiagnosticsByProject.keys().next().value;
8766
+ if (oldest !== void 0) lastSearchDiagnosticsByProject.delete(oldest);
8767
+ }
8768
+ lastSearchDiagnosticsByProject.delete(key);
8769
+ lastSearchDiagnosticsByProject.set(key, value);
8770
+ }
8704
8771
  function getOptionalObservationStore() {
8705
8772
  try {
8706
8773
  return getObservationStore();
@@ -8983,6 +9050,7 @@ async function resetDb() {
8983
9050
  indexEmbeddingProvider = null;
8984
9051
  deferredCachedVectorHydration = null;
8985
9052
  lastSearchModeByProject.clear();
9053
+ lastSearchDiagnosticsByProject.clear();
8986
9054
  }
8987
9055
  function isEmbeddingEnabled() {
8988
9056
  return embeddingEnabled;
@@ -9200,6 +9268,7 @@ async function removeObservation(oramaId) {
9200
9268
  await remove2(database, oramaId);
9201
9269
  }
9202
9270
  async function searchObservations(options) {
9271
+ const searchStartedAt = Date.now();
9203
9272
  const perf = !!process.env.MEMORIX_PERF;
9204
9273
  const t0 = perf ? performance.now() : 0;
9205
9274
  const mark = (label) => {
@@ -9275,6 +9344,8 @@ async function searchObservations(options) {
9275
9344
  let queryVector = null;
9276
9345
  let embeddingProviderForSearch = null;
9277
9346
  let embeddingUnavailable = false;
9347
+ let fallbackUsed = false;
9348
+ let fallbackReason;
9278
9349
  if (quality !== "fast" && embeddingEnabled && hasQuery && tier !== "fast") {
9279
9350
  try {
9280
9351
  const provider2 = await getEmbeddingProvider();
@@ -9283,6 +9354,8 @@ async function searchObservations(options) {
9283
9354
  const activeVectorDimensions = getVectorDimensions();
9284
9355
  if (activeVectorDimensions !== null && provider2.dimensions !== activeVectorDimensions) {
9285
9356
  embeddingUnavailable = true;
9357
+ fallbackUsed = true;
9358
+ fallbackReason = "embedding dimension mismatch; lexical search used";
9286
9359
  rememberSearchMode(
9287
9360
  modeKey,
9288
9361
  `fulltext (embedding dimension mismatch: provider ${provider2.dimensions}d vs index ${activeVectorDimensions}d)`
@@ -9324,9 +9397,13 @@ async function searchObservations(options) {
9324
9397
  }
9325
9398
  } else {
9326
9399
  embeddingUnavailable = true;
9400
+ fallbackUsed = true;
9401
+ fallbackReason = "embedding provider unavailable; lexical search used";
9327
9402
  }
9328
9403
  } catch (error) {
9329
9404
  embeddingUnavailable = true;
9405
+ fallbackUsed = true;
9406
+ fallbackReason = "embedding failed or timed out; lexical search used";
9330
9407
  rememberSearchMode(modeKey, "fulltext (embedding unavailable)");
9331
9408
  console.error("[memorix] Embedding failed or timed out, falling back to fulltext search");
9332
9409
  }
@@ -9376,6 +9453,8 @@ async function searchObservations(options) {
9376
9453
  similarity: 0.25
9377
9454
  };
9378
9455
  rememberSearchMode(modeKey, "vector-only (hybrid empty fallback)");
9456
+ fallbackUsed = true;
9457
+ fallbackReason = "hybrid search returned no results; vector-only fallback used";
9379
9458
  results = await search(database, vectorOnlyParams);
9380
9459
  } catch {
9381
9460
  }
@@ -9649,6 +9728,7 @@ async function searchObservations(options) {
9649
9728
  mark(`rerank(skipped,tier=${tier})`);
9650
9729
  }
9651
9730
  let entries = intermediate.map(({ rawTime: _, _isCommandLog: _c, ...rest }) => rest);
9731
+ const candidateCount = entries.length;
9652
9732
  for (const hit of results.hits) {
9653
9733
  const doc = hit.document;
9654
9734
  if (canReadObservation(doc, options.reader, projectIds ?? void 0)) rememberObservationDoc(doc);
@@ -9691,9 +9771,22 @@ async function searchObservations(options) {
9691
9771
  }
9692
9772
  }
9693
9773
  }
9774
+ const beforeTokenBudget = entries.length;
9694
9775
  if (options.maxTokens && options.maxTokens > 0) {
9695
9776
  entries = applyTokenBudget(entries, options.maxTokens);
9696
9777
  }
9778
+ rememberSearchDiagnostics(modeKey, {
9779
+ version: "1",
9780
+ mode: getLastSearchMode(options.projectId),
9781
+ rawCandidateCount: results.hits.length,
9782
+ candidateCount,
9783
+ selectedCount: entries.length,
9784
+ omittedCount: Math.max(0, candidateCount - entries.length),
9785
+ omittedByTokenBudget: Math.max(0, beforeTokenBudget - entries.length),
9786
+ fallbackUsed,
9787
+ ...fallbackReason ? { fallbackReason } : {},
9788
+ elapsedMs: Math.max(0, Date.now() - searchStartedAt)
9789
+ });
9697
9790
  if (options.trackAccess !== false) {
9698
9791
  const returnedKeys = new Set(entries.map((entry) => makeEntryKey(entry.projectId, entry.id)));
9699
9792
  const hitDocs = results.hits.map((hit) => ({ id: hit.id, doc: hit.document })).filter(({ doc }) => returnedKeys.has(makeEntryKey(doc.projectId, doc.observationId)));
@@ -9809,7 +9902,7 @@ function formatTime(isoDate) {
9809
9902
  return isoDate;
9810
9903
  }
9811
9904
  }
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;
9905
+ 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
9906
  var init_orama_store = __esm({
9814
9907
  "src/store/orama-store.ts"() {
9815
9908
  "use strict";
@@ -9835,6 +9928,7 @@ var init_orama_store = __esm({
9835
9928
  NON_CJK_HYBRID_SIMILARITY = 0.45;
9836
9929
  CJK_RUN = /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+/gu;
9837
9930
  lastSearchModeByProject = /* @__PURE__ */ new Map();
9931
+ lastSearchDiagnosticsByProject = /* @__PURE__ */ new Map();
9838
9932
  SEARCH_MODE_DEFAULT_KEY = "__global__";
9839
9933
  MAX_SEARCH_MODE_KEYS = 4096;
9840
9934
  COMMAND_LOG_TITLE2 = /^(Ran:|Command:|Executed:)\s/i;
@@ -35571,6 +35665,25 @@ var init_models_generated = __esm({
35571
35665
  }
35572
35666
  },
35573
35667
  "minimax": {
35668
+ "MiniMax-M3.1-Flash": {
35669
+ id: "MiniMax-M3.1-Flash",
35670
+ name: "MiniMax-M3.1-Flash",
35671
+ api: "anthropic-messages",
35672
+ provider: "minimax",
35673
+ baseUrl: "https://api.minimax.io/anthropic",
35674
+ compat: { "forceAdaptiveThinking": true },
35675
+ reasoning: true,
35676
+ thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
35677
+ input: ["text", "image", "video"],
35678
+ cost: {
35679
+ input: 0.15,
35680
+ output: 0.6,
35681
+ cacheRead: 0.015,
35682
+ cacheWrite: 0
35683
+ },
35684
+ contextWindow: 1e6,
35685
+ maxTokens: 524288
35686
+ },
35574
35687
  "MiniMax-M2.7": {
35575
35688
  id: "MiniMax-M2.7",
35576
35689
  name: "MiniMax-M2.7",
@@ -35611,6 +35724,7 @@ var init_models_generated = __esm({
35611
35724
  api: "anthropic-messages",
35612
35725
  provider: "minimax",
35613
35726
  baseUrl: "https://api.minimax.io/anthropic",
35727
+ compat: { "forceAdaptiveThinking": true },
35614
35728
  reasoning: true,
35615
35729
  input: ["text", "image", "video"],
35616
35730
  cost: {
@@ -35620,10 +35734,29 @@ var init_models_generated = __esm({
35620
35734
  cacheWrite: 0
35621
35735
  },
35622
35736
  contextWindow: 1e6,
35623
- maxTokens: 128e3
35737
+ maxTokens: 524288
35624
35738
  }
35625
35739
  },
35626
35740
  "minimax-cn": {
35741
+ "MiniMax-M3.1-Flash": {
35742
+ id: "MiniMax-M3.1-Flash",
35743
+ name: "MiniMax-M3.1-Flash",
35744
+ api: "anthropic-messages",
35745
+ provider: "minimax-cn",
35746
+ baseUrl: "https://api.minimaxi.com/anthropic",
35747
+ compat: { "forceAdaptiveThinking": true },
35748
+ reasoning: true,
35749
+ thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
35750
+ input: ["text", "image", "video"],
35751
+ cost: {
35752
+ input: 0.15,
35753
+ output: 0.6,
35754
+ cacheRead: 0.015,
35755
+ cacheWrite: 0
35756
+ },
35757
+ contextWindow: 1e6,
35758
+ maxTokens: 524288
35759
+ },
35627
35760
  "MiniMax-M2.7": {
35628
35761
  id: "MiniMax-M2.7",
35629
35762
  name: "MiniMax-M2.7",
@@ -35664,6 +35797,7 @@ var init_models_generated = __esm({
35664
35797
  api: "anthropic-messages",
35665
35798
  provider: "minimax-cn",
35666
35799
  baseUrl: "https://api.minimaxi.com/anthropic",
35800
+ compat: { "forceAdaptiveThinking": true },
35667
35801
  reasoning: true,
35668
35802
  input: ["text", "image", "video"],
35669
35803
  cost: {
@@ -35673,7 +35807,7 @@ var init_models_generated = __esm({
35673
35807
  cacheWrite: 0
35674
35808
  },
35675
35809
  contextWindow: 1e6,
35676
- maxTokens: 128e3
35810
+ maxTokens: 524288
35677
35811
  }
35678
35812
  },
35679
35813
  "mistral": {
@@ -38794,6 +38928,24 @@ var init_models_generated = __esm({
38794
38928
  }
38795
38929
  },
38796
38930
  "openrouter": {
38931
+ "minimax/minimax-m3.1-flash:free": {
38932
+ id: "minimax/minimax-m3.1-flash:free",
38933
+ name: "MiniMax: MiniMax M3.1 Flash (free)",
38934
+ api: "openai-completions",
38935
+ provider: "openrouter",
38936
+ baseUrl: "https://openrouter.ai/api/v1",
38937
+ reasoning: true,
38938
+ thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
38939
+ input: ["text", "image"],
38940
+ cost: {
38941
+ input: 0,
38942
+ output: 0,
38943
+ cacheRead: 0,
38944
+ cacheWrite: 0
38945
+ },
38946
+ contextWindow: 1e6,
38947
+ maxTokens: 524288
38948
+ },
38797
38949
  "ai21/jamba-large-1.7": {
38798
38950
  id: "ai21/jamba-large-1.7",
38799
38951
  name: "AI21: Jamba Large 1.7",
@@ -47495,6 +47647,14 @@ var init_models_generated = __esm({
47495
47647
  }
47496
47648
  });
47497
47649
 
47650
+ // packages/ai/dist/minimax-models.js
47651
+ var init_minimax_models = __esm({
47652
+ "packages/ai/dist/minimax-models.js"() {
47653
+ "use strict";
47654
+ init_esm_shims();
47655
+ }
47656
+ });
47657
+
47498
47658
  // packages/ai/dist/models.js
47499
47659
  function calculateCost(model, usage) {
47500
47660
  usage.cost.input = model.cost.input / 1e6 * usage.input;
@@ -47541,6 +47701,8 @@ var init_models2 = __esm({
47541
47701
  "use strict";
47542
47702
  init_esm_shims();
47543
47703
  init_models_generated();
47704
+ init_minimax_models();
47705
+ init_minimax_models();
47544
47706
  modelRegistry = /* @__PURE__ */ new Map();
47545
47707
  for (const [provider2, models] of Object.entries(MODELS)) {
47546
47708
  const providerModels = /* @__PURE__ */ new Map();
@@ -55494,6 +55656,25 @@ function buildParams2(model, context, isOAuthToken2, options) {
55494
55656
  params.tool_choice = options.toolChoice;
55495
55657
  }
55496
55658
  }
55659
+ return normalizeMiniMaxParams(model, params, options);
55660
+ }
55661
+ function normalizeMiniMaxParams(model, params, options) {
55662
+ if (model.provider !== "minimax" && model.provider !== "minimax-cn")
55663
+ return params;
55664
+ if (params.model === "MiniMax-M3.1-Flash") {
55665
+ const effort = params.output_config?.effort ?? options?.effort ?? "max";
55666
+ const normalized = { ...params, thinking: { type: "adaptive" } };
55667
+ normalized.output_config = {
55668
+ ...params.output_config,
55669
+ effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
55670
+ };
55671
+ delete normalized.service_tier;
55672
+ delete normalized.reasoning_split;
55673
+ return normalized;
55674
+ }
55675
+ if (params.model === "MiniMax-M3" && params.thinking) {
55676
+ return { ...params, thinking: { type: params.thinking.type === "disabled" ? "disabled" : "adaptive" } };
55677
+ }
55497
55678
  return params;
55498
55679
  }
55499
55680
  function normalizeToolCallId(id) {
@@ -55800,6 +55981,7 @@ var init_anthropic = __esm({
55800
55981
  if (nextParams !== void 0) {
55801
55982
  params = nextParams;
55802
55983
  }
55984
+ params = normalizeMiniMaxParams(model, params, options);
55803
55985
  const requestOptions = {
55804
55986
  ...options?.signal ? { signal: options.signal } : {},
55805
55987
  ...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
@@ -77901,7 +78083,7 @@ var require_websocket = __commonJS({
77901
78083
  var http3 = __require("http");
77902
78084
  var net = __require("net");
77903
78085
  var tls = __require("tls");
77904
- var { randomBytes: randomBytes2, createHash: createHash20 } = __require("crypto");
78086
+ var { randomBytes: randomBytes2, createHash: createHash21 } = __require("crypto");
77905
78087
  var { Duplex, Readable: Readable2 } = __require("stream");
77906
78088
  var { URL: URL2 } = __require("url");
77907
78089
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -78569,7 +78751,7 @@ var require_websocket = __commonJS({
78569
78751
  abortHandshake(websocket, socket, "Invalid Upgrade header");
78570
78752
  return;
78571
78753
  }
78572
- const digest2 = createHash20("sha1").update(key + GUID).digest("base64");
78754
+ const digest2 = createHash21("sha1").update(key + GUID).digest("base64");
78573
78755
  if (res.headers["sec-websocket-accept"] !== digest2) {
78574
78756
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
78575
78757
  return;
@@ -78941,7 +79123,7 @@ var require_websocket_server = __commonJS({
78941
79123
  var EventEmitter2 = __require("events");
78942
79124
  var http3 = __require("http");
78943
79125
  var { Duplex } = __require("stream");
78944
- var { createHash: createHash20 } = __require("crypto");
79126
+ var { createHash: createHash21 } = __require("crypto");
78945
79127
  var extension3 = require_extension();
78946
79128
  var PerMessageDeflate2 = require_permessage_deflate();
78947
79129
  var subprotocol2 = require_subprotocol();
@@ -79248,7 +79430,7 @@ var require_websocket_server = __commonJS({
79248
79430
  );
79249
79431
  }
79250
79432
  if (this._state > RUNNING) return abortHandshake(socket, 503);
79251
- const digest2 = createHash20("sha1").update(key + GUID).digest("base64");
79433
+ const digest2 = createHash21("sha1").update(key + GUID).digest("base64");
79252
79434
  const headers = [
79253
79435
  "HTTP/1.1 101 Switching Protocols",
79254
79436
  "Upgrade: websocket",
@@ -138570,6 +138752,18 @@ var init_openai_completions = __esm({
138570
138752
  if (nextParams !== void 0) {
138571
138753
  params = nextParams;
138572
138754
  }
138755
+ if (model.provider === "openrouter" && new URL(model.baseUrl).hostname === "openrouter.ai" && params.model === "minimax/minimax-m3.1-flash:free") {
138756
+ const flash = params;
138757
+ const effort = flash.reasoning?.effort ?? "max";
138758
+ flash.reasoning = {
138759
+ ...flash.reasoning,
138760
+ enabled: true,
138761
+ effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
138762
+ };
138763
+ delete flash.reasoning_effort;
138764
+ delete flash.reasoning_split;
138765
+ delete flash.service_tier;
138766
+ }
138573
138767
  const requestOptions = {
138574
138768
  ...options?.signal ? { signal: options.signal } : {},
138575
138769
  ...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
@@ -156858,7 +157052,7 @@ function appendLine(lines, candidate, maxTokens, omitted, omittedKind, selected,
156858
157052
  if (receiptSelection) selected?.push(receiptSelection);
156859
157053
  return true;
156860
157054
  }
156861
- omitted.push(omittedKind);
157055
+ omitted.push(receiptSelection?.id ? `${omittedKind}|${receiptSelection.id}` : omittedKind);
156862
157056
  return false;
156863
157057
  }
156864
157058
  function freshnessForMemory(status) {
@@ -156884,15 +157078,23 @@ function receiptOmissionKind(raw) {
156884
157078
  }
156885
157079
  function receiptOmissions(omitted, hiddenCautionMemoryCount) {
156886
157080
  const counts = /* @__PURE__ */ new Map();
157081
+ const samples = /* @__PURE__ */ new Map();
156887
157082
  for (const raw of omitted) {
156888
- const kind = receiptOmissionKind(raw);
157083
+ const [omittedKind, sampleId] = raw.split("|", 2);
157084
+ const kind = receiptOmissionKind(omittedKind);
156889
157085
  if (!kind || raw.endsWith("-heading")) continue;
156890
157086
  counts.set(kind, (counts.get(kind) ?? 0) + 1);
157087
+ if (sampleId) {
157088
+ const values = samples.get(kind) ?? [];
157089
+ if (!values.includes(sampleId) && values.length < 3) values.push(sampleId);
157090
+ samples.set(kind, values);
157091
+ }
156891
157092
  }
156892
157093
  const receipt = [...counts.entries()].map(([kind, count2]) => ({
156893
157094
  kind,
156894
157095
  reason: "token-budget",
156895
- count: count2
157096
+ count: count2,
157097
+ ...samples.get(kind)?.length ? { sampleIds: samples.get(kind) } : {}
156896
157098
  }));
156897
157099
  if (hiddenCautionMemoryCount > 0) {
156898
157100
  receipt.push({
@@ -157601,6 +157803,21 @@ async function buildTaskWorkset(input) {
157601
157803
  ...base,
157602
157804
  budget: { maxTokens }
157603
157805
  });
157806
+ const omittedReceipt = receiptOmissions(rendered.omittedItems, base.hiddenCautionMemoryCount);
157807
+ const derivedViews = {
157808
+ ...getSearchDerivedViews(),
157809
+ ...input.retrieval?.derivedViews ?? {}
157810
+ };
157811
+ const retrieval = {
157812
+ mode: input.retrieval?.mode ?? (input.semanticCode ? "hybrid" : "unknown"),
157813
+ ...input.retrieval?.codeProvider || input.providerQuality?.selected ? { codeProvider: input.retrieval?.codeProvider ?? input.providerQuality?.selected } : {},
157814
+ fallbackUsed: Boolean(input.retrieval?.fallbackReason),
157815
+ ...input.retrieval?.fallbackReason ? { fallbackReason: input.retrieval.fallbackReason } : {},
157816
+ candidateCount: governed.plan.decisions.length,
157817
+ selectedCount: rendered.selected.length,
157818
+ omittedCount: omittedReceipt.reduce((total, omission) => total + omission.count, 0),
157819
+ derivedViews
157820
+ };
157604
157821
  const receipt = {
157605
157822
  version: "1.3",
157606
157823
  target: input.deliveryTarget ?? "project-context",
@@ -157609,8 +157826,9 @@ async function buildTaskWorkset(input) {
157609
157826
  maxTokens,
157610
157827
  tokenCount: rendered.tokenCount
157611
157828
  },
157829
+ retrieval,
157612
157830
  selected: rendered.selected,
157613
- omitted: receiptOmissions(rendered.omittedItems, base.hiddenCautionMemoryCount),
157831
+ omitted: omittedReceipt,
157614
157832
  governance: {
157615
157833
  scope: "optional-evidence",
157616
157834
  mode: governed.plan.mode,
@@ -157618,7 +157836,12 @@ async function buildTaskWorkset(input) {
157618
157836
  kind: decision.candidate.kind,
157619
157837
  ...decision.candidate.id ? { id: decision.candidate.id } : {},
157620
157838
  disposition: decision.disposition,
157621
- reasons: decision.reasons
157839
+ reasons: decision.reasons,
157840
+ ...decision.candidate.freshness ? { freshness: decision.candidate.freshness } : {},
157841
+ ...decision.candidate.trust ? { trust: decision.candidate.trust } : {},
157842
+ ...decision.candidate.quality ? { quality: decision.candidate.quality } : {},
157843
+ ...decision.candidate.conflict ? { conflict: decision.candidate.conflict } : {},
157844
+ ...decision.candidate.evidenceCount !== void 0 ? { evidenceCount: decision.candidate.evidenceCount } : {}
157622
157845
  })),
157623
157846
  cautions: governed.plan.cautions
157624
157847
  },
@@ -157652,6 +157875,7 @@ var init_workset = __esm({
157652
157875
  init_workflows2();
157653
157876
  init_long_term();
157654
157877
  init_governor();
157878
+ init_orama_store();
157655
157879
  CONTINUATION_DETAIL_TOKEN_BUDGET = 20;
157656
157880
  }
157657
157881
  });
@@ -158951,12 +159175,66 @@ var init_project_context = __esm({
158951
159175
  }
158952
159176
  });
158953
159177
 
159178
+ // src/knowledge/context-receipt.ts
159179
+ var context_receipt_exports = {};
159180
+ __export(context_receipt_exports, {
159181
+ buildBoundedContextReceipt: () => buildBoundedContextReceipt,
159182
+ buildCodeGraphDerivedView: () => buildCodeGraphDerivedView
159183
+ });
159184
+ function buildCodeGraphDerivedView(input) {
159185
+ const provider2 = input.providerQuality;
159186
+ const snapshot = input.snapshot;
159187
+ const externalFailure = provider2?.external.state !== void 0 && !["ready", "disabled", "not-detected"].includes(provider2.external.state);
159188
+ if (snapshot?.id) {
159189
+ return {
159190
+ ...snapshot.sourceEpoch !== void 0 ? { generation: snapshot.sourceEpoch } : {},
159191
+ freshness: snapshot.incomplete ? "stale" : "current",
159192
+ rebuildStatus: snapshot.incomplete ? "failed" : "idle",
159193
+ ...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: provider2.external.reason.slice(0, 240) } : {}
159194
+ };
159195
+ }
159196
+ return {
159197
+ freshness: "unknown",
159198
+ rebuildStatus: externalFailure ? "failed" : "unavailable",
159199
+ ...provider2?.external.reason ? { failureReason: provider2.external.reason.slice(0, 240) } : { failureReason: "CodeGraph snapshot is not initialized" }
159200
+ };
159201
+ }
159202
+ function buildBoundedContextReceipt(input) {
159203
+ const provider2 = input.providerQuality ?? input.workset.provenance.codeProvider;
159204
+ return {
159205
+ schemaVersion: "1",
159206
+ task: input.workset.task,
159207
+ brief: input.workset.prompt,
159208
+ receipt: input.workset.receipt,
159209
+ code: {
159210
+ selected: provider2?.selected ?? "lite",
159211
+ quality: provider2?.selectedQuality ?? "heuristic",
159212
+ externalState: provider2?.external.state ?? "not-detected",
159213
+ ...input.workset.provenance.snapshotId ? { snapshotId: input.workset.provenance.snapshotId } : {}
159214
+ },
159215
+ ...input.workset.agentLoadout ? { loadout: input.workset.agentLoadout } : {},
159216
+ ...input.workset.continuity ? {
159217
+ continuity: {
159218
+ taskId: input.workset.continuity.taskId,
159219
+ status: input.workset.continuity.status,
159220
+ outcome: input.workset.continuity.outcome
159221
+ }
159222
+ } : {}
159223
+ };
159224
+ }
159225
+ var init_context_receipt = __esm({
159226
+ "src/knowledge/context-receipt.ts"() {
159227
+ "use strict";
159228
+ init_esm_shims();
159229
+ }
159230
+ });
159231
+
158954
159232
  // src/store/compaction-checkpoint-store.ts
158955
159233
  var compaction_checkpoint_store_exports = {};
158956
159234
  __export(compaction_checkpoint_store_exports, {
158957
159235
  CompactionCheckpointStore: () => CompactionCheckpointStore
158958
159236
  });
158959
- import { createHash as createHash18, randomUUID as randomUUID16 } from "crypto";
159237
+ import { createHash as createHash19, randomUUID as randomUUID16 } from "crypto";
158960
159238
  function optionalText7(value) {
158961
159239
  return typeof value === "string" && value ? value : void 0;
158962
159240
  }
@@ -158998,7 +159276,7 @@ function sourceKeyFor(input, summary) {
158998
159276
  input.tokensBefore ?? "",
158999
159277
  input.firstKeptEntryId ?? ""
159000
159278
  ].join("\0");
159001
- return `derived:${createHash18("sha256").update(material).digest("hex").slice(0, 32)}`;
159279
+ return `derived:${createHash19("sha256").update(material).digest("hex").slice(0, 32)}`;
159002
159280
  }
159003
159281
  function rowToCheckpoint(row) {
159004
159282
  return {
@@ -159837,6 +160115,23 @@ async function buildAutoProjectContext(input) {
159837
160115
  ...alwaysOn.profile.length > 0 || alwaysOn.state || alwaysOn.durable.length > 0 ? { alwaysOn } : {},
159838
160116
  ...semanticOutline ? { semanticCode: semanticOutline } : {},
159839
160117
  providerQuality: providerQuality2,
160118
+ retrieval: {
160119
+ mode: semanticOutline ? "hybrid" : "lexical",
160120
+ codeProvider: providerQuality2.selected,
160121
+ ...externalCaution ? { fallbackReason: externalCaution } : {},
160122
+ derivedViews: {
160123
+ graph: buildCodeGraphDerivedView({
160124
+ providerQuality: providerQuality2,
160125
+ ...latestSnapshot ? {
160126
+ snapshot: {
160127
+ id: latestSnapshot.id,
160128
+ sourceEpoch: latestSnapshot.sourceEpoch,
160129
+ incomplete: latestSnapshot.completeness.skippedOversizedFiles > 0 || (latestSnapshot.completeness.unreadableFiles ?? 0) > 0 || latestSnapshot.completeness.removalScanDeferred
160130
+ }
160131
+ } : {}
160132
+ })
160133
+ }
160134
+ },
159840
160135
  currentFacts: worksetFactLines(currentFacts),
159841
160136
  ...continuation ? { continuation } : {},
159842
160137
  ...continuity ? { continuity } : {},
@@ -160165,47 +160460,13 @@ var init_auto_context = __esm({
160165
160460
  init_long_term();
160166
160461
  init_visibility();
160167
160462
  init_session_store();
160463
+ init_context_receipt();
160168
160464
  init_task_lens();
160169
160465
  DEFAULT_MAX_AGE_MS = 10 * 60 * 1e3;
160170
160466
  COMPACT_CHECKPOINT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
160171
160467
  }
160172
160468
  });
160173
160469
 
160174
- // src/knowledge/context-receipt.ts
160175
- var context_receipt_exports = {};
160176
- __export(context_receipt_exports, {
160177
- buildBoundedContextReceipt: () => buildBoundedContextReceipt
160178
- });
160179
- function buildBoundedContextReceipt(input) {
160180
- const provider2 = input.providerQuality ?? input.workset.provenance.codeProvider;
160181
- return {
160182
- schemaVersion: "1",
160183
- task: input.workset.task,
160184
- brief: input.workset.prompt,
160185
- receipt: input.workset.receipt,
160186
- code: {
160187
- selected: provider2?.selected ?? "lite",
160188
- quality: provider2?.selectedQuality ?? "heuristic",
160189
- externalState: provider2?.external.state ?? "not-detected",
160190
- ...input.workset.provenance.snapshotId ? { snapshotId: input.workset.provenance.snapshotId } : {}
160191
- },
160192
- ...input.workset.agentLoadout ? { loadout: input.workset.agentLoadout } : {},
160193
- ...input.workset.continuity ? {
160194
- continuity: {
160195
- taskId: input.workset.continuity.taskId,
160196
- status: input.workset.continuity.status,
160197
- outcome: input.workset.continuity.outcome
160198
- }
160199
- } : {}
160200
- };
160201
- }
160202
- var init_context_receipt = __esm({
160203
- "src/knowledge/context-receipt.ts"() {
160204
- "use strict";
160205
- init_esm_shims();
160206
- }
160207
- });
160208
-
160209
160470
  // src/codegraph/context-pack.ts
160210
160471
  var context_pack_exports = {};
160211
160472
  __export(context_pack_exports, {
@@ -160382,6 +160643,22 @@ async function attachTaskWorkset(input) {
160382
160643
  startHere: uniq2([...semanticStartHere, ...input.pack.suggestedReads]),
160383
160644
  ...semanticCode ? { semanticCode } : {},
160384
160645
  ...input.providerQuality ? { providerQuality: input.providerQuality } : {},
160646
+ retrieval: {
160647
+ mode: semanticCode ? "hybrid" : "unknown",
160648
+ ...input.providerQuality?.selected ? { codeProvider: input.providerQuality.selected } : {},
160649
+ derivedViews: {
160650
+ graph: buildCodeGraphDerivedView({
160651
+ providerQuality: input.providerQuality,
160652
+ ...input.snapshot ? {
160653
+ snapshot: {
160654
+ id: input.snapshot.id,
160655
+ sourceEpoch: input.snapshot.sourceEpoch,
160656
+ incomplete: input.snapshot.incomplete
160657
+ }
160658
+ } : {}
160659
+ })
160660
+ }
160661
+ },
160385
160662
  reliableMemory: input.pack.memories.filter((memory) => memory.status === "current").map((memory) => ({
160386
160663
  id: memory.id,
160387
160664
  title: memory.title,
@@ -160452,6 +160729,7 @@ var init_context_pack = __esm({
160452
160729
  "use strict";
160453
160730
  init_esm_shims();
160454
160731
  init_freshness2();
160732
+ init_context_receipt();
160455
160733
  init_workset();
160456
160734
  init_exclude3();
160457
160735
  init_semantic_context();
@@ -163628,7 +163906,8 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
163628
163906
  "ANTHROPIC_API_KEY",
163629
163907
  ...resolved.memory.llm.provider === "openrouter" || resolved.memory.llm.baseUrl?.includes("openrouter.ai") ? ["OPENROUTER_API_KEY"] : [],
163630
163908
  ...resolved.memory.llm.provider === "requesty" ? ["REQUESTY_API_KEY"] : [],
163631
- ...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : []
163909
+ ...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : [],
163910
+ ...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : []
163632
163911
  ];
163633
163912
  if (llmKey) {
163634
163913
  const src = resolveDashboardKeySource({ value: llmKey, envKeys: memoryKeyEnv, configSource });
@@ -165214,7 +165493,7 @@ async function analyzeImage(input) {
165214
165493
  const config = getLLMConfig();
165215
165494
  if (!OPENAI_COMPATIBLE_PROVIDERS.has(config.provider)) {
165216
165495
  throw new Error(
165217
- `Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, or custom). Current provider "${config.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
165496
+ `Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, or custom). Current provider "${config.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
165218
165497
  );
165219
165498
  }
165220
165499
  const bytes = decodeBase64ImagePayload(input.base64, MAX_VISION_IMAGE_BYTES);
@@ -165253,7 +165532,7 @@ var init_image_loader = __esm({
165253
165532
  init_provider2();
165254
165533
  init_secret_filter();
165255
165534
  init_image_payload();
165256
- OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "custom"]);
165535
+ OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "custom"]);
165257
165536
  MAX_VISION_PROMPT_CHARS = 12e3;
165258
165537
  MAX_VISION_DESCRIPTION_CHARS = 12e3;
165259
165538
  MAX_VISION_LABELS = 50;
@@ -167373,7 +167652,7 @@ init_freshness();
167373
167652
  init_obs_store();
167374
167653
  init_mini_skill_store();
167375
167654
  init_session_store();
167376
- import { createHash as createHash19 } from "crypto";
167655
+ import { createHash as createHash20 } from "crypto";
167377
167656
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
167378
167657
  import { z as z627 } from "zod";
167379
167658
 
@@ -167890,6 +168169,7 @@ function normalizeMemoryBrowseQuery(query) {
167890
168169
  return broadMemoryRequests.has(compact) ? "" : query;
167891
168170
  }
167892
168171
  async function compactSearch(options, surface = "mcp") {
168172
+ const startedAt = Date.now();
167893
168173
  await ensureFreshIndex({ loadCorpus: false });
167894
168174
  const searchOptions = { ...options, query: normalizeMemoryBrowseQuery(options.query) };
167895
168175
  let entries = (await searchObservations(searchOptions)).map(
@@ -167943,7 +168223,34 @@ This project does have stored Memorix memories, but none matched the current que
167943
168223
  }
167944
168224
  }
167945
168225
  const totalTokens = countTextTokens(formatted);
167946
- return { entries, formatted, totalTokens };
168226
+ const diagnostics = getLastSearchDiagnostics(options.projectId);
168227
+ const derivedViews = getSearchDerivedViews();
168228
+ if (diagnostics?.fallbackUsed && diagnostics.fallbackReason) {
168229
+ derivedViews.embedding = {
168230
+ freshness: "stale",
168231
+ rebuildStatus: "failed",
168232
+ failureReason: diagnostics.fallbackReason
168233
+ };
168234
+ }
168235
+ return {
168236
+ entries,
168237
+ formatted,
168238
+ totalTokens,
168239
+ receipt: {
168240
+ version: "1",
168241
+ mode: getLastSearchMode(options.projectId),
168242
+ resultCount: entries.length,
168243
+ candidateCount: diagnostics?.candidateCount ?? entries.length,
168244
+ selectedCount: diagnostics?.selectedCount ?? entries.length,
168245
+ omittedCount: diagnostics?.omittedCount ?? 0,
168246
+ omittedByTokenBudget: diagnostics?.omittedByTokenBudget ?? 0,
168247
+ fallbackUsed: diagnostics?.fallbackUsed ?? false,
168248
+ ...diagnostics?.fallbackReason ? { fallbackReason: diagnostics.fallbackReason } : {},
168249
+ derivedViews,
168250
+ tokenCount: totalTokens,
168251
+ elapsedMs: Math.max(0, Date.now() - startedAt)
168252
+ }
168253
+ };
167947
168254
  }
167948
168255
  async function compactTimeline(anchorId, projectId, depthBefore = 3, depthAfter = 3, reader2, surface = "mcp") {
167949
168256
  const result = await getTimeline(anchorId, projectId, depthBefore, depthAfter, reader2);
@@ -171120,12 +171427,27 @@ function recordSurfacedIds(key, ids) {
171120
171427
 
171121
171428
  // src/server/request-context.ts
171122
171429
  init_esm_shims();
171430
+ import { createHash as createHash18 } from "crypto";
171123
171431
  import path28 from "path";
171124
171432
  function resolveRoot(projectRoot) {
171125
171433
  const value = projectRoot.trim();
171126
171434
  if (!value) throw new Error("Project binding requires a non-empty project root");
171127
171435
  return path28.resolve(value);
171128
171436
  }
171437
+ function hashBindingValue(value) {
171438
+ return `sha256:${createHash18("sha256").update(value).digest("hex")}`;
171439
+ }
171440
+ function remoteHost(remote) {
171441
+ const trimmed = remote.trim();
171442
+ if (!trimmed) return void 0;
171443
+ const scpHost = trimmed.match(/^[^@/\s]+@([^:\s/]+):/);
171444
+ if (scpHost) return scpHost[1].toLowerCase();
171445
+ try {
171446
+ return new URL(trimmed).hostname.toLowerCase() || void 0;
171447
+ } catch {
171448
+ return void 0;
171449
+ }
171450
+ }
171129
171451
  var ProjectBindingController = class {
171130
171452
  current;
171131
171453
  constructor(projectRoot) {
@@ -171144,6 +171466,38 @@ var ProjectBindingController = class {
171144
171466
  ...actorId ? { actorId } : {}
171145
171467
  };
171146
171468
  }
171469
+ /**
171470
+ * Return binding diagnostics without exposing local paths or transport IDs.
171471
+ * The hashes let operators compare two surfaces while keeping the receipt
171472
+ * safe to pass through MCP, logs, and agent handoffs.
171473
+ */
171474
+ receipt(options = {}) {
171475
+ const snapshot = this.snapshot();
171476
+ const handle = options.handle;
171477
+ const handleState = !handle ? "absent" : handle.expiresAt && Date.parse(handle.expiresAt) <= Date.now() ? "expired" : "active";
171478
+ return {
171479
+ version: "1",
171480
+ state: snapshot.projectId ? "resolved" : "unresolved",
171481
+ source: snapshot.source,
171482
+ explicit: snapshot.explicit,
171483
+ ...snapshot.projectId ? { projectId: snapshot.projectId } : {},
171484
+ projectRootHash: hashBindingValue(snapshot.projectRoot),
171485
+ ...options.dataDir ? { dataDirHash: hashBindingValue(path28.resolve(options.dataDir)) } : {},
171486
+ gitRemote: options.gitRemote?.trim() ? {
171487
+ state: "verified",
171488
+ hash: hashBindingValue(options.gitRemote.trim()),
171489
+ ...remoteHost(options.gitRemote) ? { host: remoteHost(options.gitRemote) } : {}
171490
+ } : { state: "unavailable" },
171491
+ handle: {
171492
+ state: handleState,
171493
+ ...handle ? { idHash: hashBindingValue(handle.handleId) } : {},
171494
+ ...handle?.createdAt ? { createdAt: handle.createdAt } : {},
171495
+ ...handle?.lastUsedAt ? { lastUsedAt: handle.lastUsedAt } : {},
171496
+ ...handle?.expiresAt ? { expiresAt: handle.expiresAt } : {}
171497
+ },
171498
+ transport: options.transport ?? "unknown"
171499
+ };
171500
+ }
171147
171501
  isExplicit() {
171148
171502
  return this.current.explicit;
171149
171503
  }
@@ -171196,7 +171550,7 @@ var MCP_SERVER_INFO_META_KEY = "io.modelcontextprotocol/serverInfo";
171196
171550
  function getMcpServerInfo() {
171197
171551
  return {
171198
171552
  name: "memorix",
171199
- version: true ? "1.9.12" : "1.0.1"
171553
+ version: true ? "1.10.1" : "1.0.1"
171200
171554
  };
171201
171555
  }
171202
171556
  function createMcpDiscoverResult(capabilities, serverInfo) {
@@ -171331,7 +171685,7 @@ function coerceObjectArray(val) {
171331
171685
  return [];
171332
171686
  }
171333
171687
  function createDeterministicInstanceId(projectId, agentType, agentName) {
171334
- const digest2 = createHash19("sha256").update(projectId).update("\n").update(agentType).update("\n").update(agentName ?? "").digest("hex").slice(0, 24);
171688
+ const digest2 = createHash20("sha256").update(projectId).update("\n").update(agentType).update("\n").update(agentName ?? "").digest("hex").slice(0, 24);
171335
171689
  return `auto-${digest2}`;
171336
171690
  }
171337
171691
  var BOOTSTRAP_SAFE_TOOL_NAMES = /* @__PURE__ */ new Set([
@@ -172416,20 +172770,17 @@ Use this as the \`topicKey\` parameter in \`memorix_store\` to enable upsert beh
172416
172770
  if (duplicate) return duplicate;
172417
172771
  }
172418
172772
  let text3 = result.formatted;
172419
- try {
172420
- const { getLastSearchMode: getLastSearchMode2 } = await Promise.resolve().then(() => (init_orama_store(), orama_store_exports));
172421
- text3 += `
172773
+ text3 += `
172422
172774
 
172423
- _Search mode: ${getLastSearchMode2(project.id)}_`;
172424
- } catch {
172425
- }
172775
+ _Search mode: ${result.receipt.mode}_`;
172426
172776
  return {
172427
172777
  content: [
172428
172778
  {
172429
172779
  type: "text",
172430
172780
  text: text3
172431
172781
  }
172432
- ]
172782
+ ],
172783
+ structuredContent: { retrieval: result.receipt }
172433
172784
  };
172434
172785
  }, { loadCorpus: false });
172435
172786
  }
@@ -174414,9 +174765,16 @@ Ensure the path points to a directory containing a .git folder (or a subdirector
174414
174765
  agent,
174415
174766
  reader: getObservationReader()
174416
174767
  });
174768
+ const bindingReceipt = projectBinding.receipt({
174769
+ dataDir: projectDir2,
174770
+ transport: options.bindingTransport,
174771
+ gitRemote: project.gitRemote,
174772
+ handle: options.bindingHandle
174773
+ });
174417
174774
  const lines = [
174418
174775
  `[OK] Session started: ${result.session.id}`,
174419
174776
  `Project: ${project.name} (${project.id})`,
174777
+ `Binding: ${bindingReceipt.state} via ${bindingReceipt.source}`,
174420
174778
  result.session.agent ? `Agent: ${result.session.agent}` : "",
174421
174779
  registeredAgent ? `Agent ID: ${registeredAgent.agent_id} (instance: ${registeredAgent.instance_id})` : "",
174422
174780
  !registeredAgent ? "Coordination identity: not joined (memory/session context only)" : "",
@@ -174491,7 +174849,8 @@ ${s2.instruction}`.toLowerCase();
174491
174849
  } catch {
174492
174850
  }
174493
174851
  return {
174494
- content: [{ type: "text", text: lines.filter(Boolean).join("\n") }]
174852
+ content: [{ type: "text", text: lines.filter(Boolean).join("\n") }],
174853
+ structuredContent: { binding: bindingReceipt }
174495
174854
  };
174496
174855
  }
174497
174856
  );