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.
Files changed (46) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/dist/cli/index.js +549 -101
  3. package/dist/index.d.ts +46 -0
  4. package/dist/index.js +271 -27
  5. package/dist/maintenance-runner.js +143 -3
  6. package/dist/media-audio-runner.js +143 -3
  7. package/dist/media-video-runner.js +143 -3
  8. package/dist/memcode/index.js +124 -8
  9. package/dist/memcode-runtime/CHANGELOG.md +20 -1
  10. package/dist/sdk.js +270 -26
  11. package/dist/vector-backfill-runner.js +143 -3
  12. package/docs/1.2.0-EVALUATION-HARNESS.md +88 -0
  13. package/docs/1.3-MEMORY-ARCHITECTURE.md +31 -0
  14. package/docs/API_REFERENCE.md +19 -0
  15. package/docs/DEVELOPMENT.md +16 -3
  16. package/docs/INTEGRATIONS.md +25 -0
  17. package/docs/PERFORMANCE.md +21 -6
  18. package/docs/README.md +4 -4
  19. package/docs/ROADMAP-1.9.12-2.0.md +92 -7
  20. package/package.json +3 -1
  21. package/plugins/antigravity/memorix/plugin.json +1 -1
  22. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  23. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  24. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  25. package/plugins/copilot/memorix/plugin.json +1 -1
  26. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  27. package/plugins/hermes/memorix/plugin.yaml +1 -1
  28. package/plugins/omp/memorix/package.json +1 -1
  29. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  30. package/plugins/pi/memorix/package.json +1 -1
  31. package/server.json +2 -2
  32. package/src/cli/commands/agent-integrations.ts +164 -7
  33. package/src/cli/commands/memory.ts +1 -1
  34. package/src/cli/commands/serve-http.ts +30 -1
  35. package/src/cli/commands/setup.ts +5 -21
  36. package/src/codegraph/auto-context.ts +5 -0
  37. package/src/codegraph/context-pack.ts +4 -0
  38. package/src/compact/engine.ts +43 -2
  39. package/src/evaluation/context-task-matrix.ts +247 -0
  40. package/src/evaluation/context-task-runner.ts +175 -0
  41. package/src/integrations/registry.ts +191 -4
  42. package/src/knowledge/context-assembly.ts +33 -2
  43. package/src/knowledge/workset.ts +35 -3
  44. package/src/server/request-context.ts +96 -0
  45. package/src/server.ts +16 -4
  46. package/src/store/orama-store.ts +54 -0
package/dist/index.js CHANGED
@@ -8585,6 +8585,7 @@ __export(orama_store_exports, {
8585
8585
  getActiveSemanticIndexProfile: () => getActiveSemanticIndexProfile,
8586
8586
  getDb: () => getDb,
8587
8587
  getDeferredCachedVectorHydration: () => getDeferredCachedVectorHydration,
8588
+ getLastSearchDiagnostics: () => getLastSearchDiagnostics,
8588
8589
  getLastSearchMode: () => getLastSearchMode,
8589
8590
  getObservationCount: () => getObservationCount,
8590
8591
  getObservationsByIds: () => getObservationsByIds,
@@ -8614,6 +8615,18 @@ function rememberSearchMode(key, value) {
8614
8615
  function getLastSearchMode(projectId) {
8615
8616
  return lastSearchModeByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY) ?? "fulltext";
8616
8617
  }
8618
+ function getLastSearchDiagnostics(projectId) {
8619
+ const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
8620
+ return diagnostics ? { ...diagnostics } : void 0;
8621
+ }
8622
+ function rememberSearchDiagnostics(key, value) {
8623
+ if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
8624
+ const oldest = lastSearchDiagnosticsByProject.keys().next().value;
8625
+ if (oldest !== void 0) lastSearchDiagnosticsByProject.delete(oldest);
8626
+ }
8627
+ lastSearchDiagnosticsByProject.delete(key);
8628
+ lastSearchDiagnosticsByProject.set(key, value);
8629
+ }
8617
8630
  function getOptionalObservationStore() {
8618
8631
  try {
8619
8632
  return getObservationStore();
@@ -8896,6 +8909,7 @@ async function resetDb() {
8896
8909
  indexEmbeddingProvider = null;
8897
8910
  deferredCachedVectorHydration = null;
8898
8911
  lastSearchModeByProject.clear();
8912
+ lastSearchDiagnosticsByProject.clear();
8899
8913
  }
8900
8914
  function isEmbeddingEnabled() {
8901
8915
  return embeddingEnabled;
@@ -9113,6 +9127,7 @@ async function removeObservation(oramaId) {
9113
9127
  await remove2(database, oramaId);
9114
9128
  }
9115
9129
  async function searchObservations(options) {
9130
+ const searchStartedAt = Date.now();
9116
9131
  const perf = !!process.env.MEMORIX_PERF;
9117
9132
  const t0 = perf ? performance.now() : 0;
9118
9133
  const mark = (label) => {
@@ -9188,6 +9203,8 @@ async function searchObservations(options) {
9188
9203
  let queryVector = null;
9189
9204
  let embeddingProviderForSearch = null;
9190
9205
  let embeddingUnavailable = false;
9206
+ let fallbackUsed = false;
9207
+ let fallbackReason;
9191
9208
  if (quality !== "fast" && embeddingEnabled && hasQuery && tier !== "fast") {
9192
9209
  try {
9193
9210
  const provider2 = await getEmbeddingProvider();
@@ -9196,6 +9213,8 @@ async function searchObservations(options) {
9196
9213
  const activeVectorDimensions = getVectorDimensions();
9197
9214
  if (activeVectorDimensions !== null && provider2.dimensions !== activeVectorDimensions) {
9198
9215
  embeddingUnavailable = true;
9216
+ fallbackUsed = true;
9217
+ fallbackReason = "embedding dimension mismatch; lexical search used";
9199
9218
  rememberSearchMode(
9200
9219
  modeKey,
9201
9220
  `fulltext (embedding dimension mismatch: provider ${provider2.dimensions}d vs index ${activeVectorDimensions}d)`
@@ -9237,9 +9256,13 @@ async function searchObservations(options) {
9237
9256
  }
9238
9257
  } else {
9239
9258
  embeddingUnavailable = true;
9259
+ fallbackUsed = true;
9260
+ fallbackReason = "embedding provider unavailable; lexical search used";
9240
9261
  }
9241
9262
  } catch (error) {
9242
9263
  embeddingUnavailable = true;
9264
+ fallbackUsed = true;
9265
+ fallbackReason = "embedding failed or timed out; lexical search used";
9243
9266
  rememberSearchMode(modeKey, "fulltext (embedding unavailable)");
9244
9267
  console.error("[memorix] Embedding failed or timed out, falling back to fulltext search");
9245
9268
  }
@@ -9289,6 +9312,8 @@ async function searchObservations(options) {
9289
9312
  similarity: 0.25
9290
9313
  };
9291
9314
  rememberSearchMode(modeKey, "vector-only (hybrid empty fallback)");
9315
+ fallbackUsed = true;
9316
+ fallbackReason = "hybrid search returned no results; vector-only fallback used";
9292
9317
  results = await search(database, vectorOnlyParams);
9293
9318
  } catch {
9294
9319
  }
@@ -9562,6 +9587,7 @@ async function searchObservations(options) {
9562
9587
  mark(`rerank(skipped,tier=${tier})`);
9563
9588
  }
9564
9589
  let entries = intermediate.map(({ rawTime: _, _isCommandLog: _c, ...rest }) => rest);
9590
+ const candidateCount = entries.length;
9565
9591
  for (const hit of results.hits) {
9566
9592
  const doc = hit.document;
9567
9593
  if (canReadObservation(doc, options.reader, projectIds ?? void 0)) rememberObservationDoc(doc);
@@ -9604,9 +9630,22 @@ async function searchObservations(options) {
9604
9630
  }
9605
9631
  }
9606
9632
  }
9633
+ const beforeTokenBudget = entries.length;
9607
9634
  if (options.maxTokens && options.maxTokens > 0) {
9608
9635
  entries = applyTokenBudget(entries, options.maxTokens);
9609
9636
  }
9637
+ rememberSearchDiagnostics(modeKey, {
9638
+ version: "1",
9639
+ mode: getLastSearchMode(options.projectId),
9640
+ rawCandidateCount: results.hits.length,
9641
+ candidateCount,
9642
+ selectedCount: entries.length,
9643
+ omittedCount: Math.max(0, candidateCount - entries.length),
9644
+ omittedByTokenBudget: Math.max(0, beforeTokenBudget - entries.length),
9645
+ fallbackUsed,
9646
+ ...fallbackReason ? { fallbackReason } : {},
9647
+ elapsedMs: Math.max(0, Date.now() - searchStartedAt)
9648
+ });
9610
9649
  if (options.trackAccess !== false) {
9611
9650
  const returnedKeys = new Set(entries.map((entry) => makeEntryKey(entry.projectId, entry.id)));
9612
9651
  const hitDocs = results.hits.map((hit) => ({ id: hit.id, doc: hit.document })).filter(({ doc }) => returnedKeys.has(makeEntryKey(doc.projectId, doc.observationId)));
@@ -9722,7 +9761,7 @@ function formatTime(isoDate) {
9722
9761
  return isoDate;
9723
9762
  }
9724
9763
  }
9725
- 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;
9764
+ 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;
9726
9765
  var init_orama_store = __esm({
9727
9766
  "src/store/orama-store.ts"() {
9728
9767
  "use strict";
@@ -9748,6 +9787,7 @@ var init_orama_store = __esm({
9748
9787
  NON_CJK_HYBRID_SIMILARITY = 0.45;
9749
9788
  CJK_RUN = /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+/gu;
9750
9789
  lastSearchModeByProject = /* @__PURE__ */ new Map();
9790
+ lastSearchDiagnosticsByProject = /* @__PURE__ */ new Map();
9751
9791
  SEARCH_MODE_DEFAULT_KEY = "__global__";
9752
9792
  MAX_SEARCH_MODE_KEYS = 4096;
9753
9793
  COMMAND_LOG_TITLE2 = /^(Ran:|Command:|Executed:)\s/i;
@@ -35484,6 +35524,25 @@ var init_models_generated = __esm({
35484
35524
  }
35485
35525
  },
35486
35526
  "minimax": {
35527
+ "MiniMax-M3.1-Flash": {
35528
+ id: "MiniMax-M3.1-Flash",
35529
+ name: "MiniMax-M3.1-Flash",
35530
+ api: "anthropic-messages",
35531
+ provider: "minimax",
35532
+ baseUrl: "https://api.minimax.io/anthropic",
35533
+ compat: { "forceAdaptiveThinking": true },
35534
+ reasoning: true,
35535
+ thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
35536
+ input: ["text", "image", "video"],
35537
+ cost: {
35538
+ input: 0.15,
35539
+ output: 0.6,
35540
+ cacheRead: 0.015,
35541
+ cacheWrite: 0
35542
+ },
35543
+ contextWindow: 1e6,
35544
+ maxTokens: 524288
35545
+ },
35487
35546
  "MiniMax-M2.7": {
35488
35547
  id: "MiniMax-M2.7",
35489
35548
  name: "MiniMax-M2.7",
@@ -35524,6 +35583,7 @@ var init_models_generated = __esm({
35524
35583
  api: "anthropic-messages",
35525
35584
  provider: "minimax",
35526
35585
  baseUrl: "https://api.minimax.io/anthropic",
35586
+ compat: { "forceAdaptiveThinking": true },
35527
35587
  reasoning: true,
35528
35588
  input: ["text", "image", "video"],
35529
35589
  cost: {
@@ -35533,10 +35593,29 @@ var init_models_generated = __esm({
35533
35593
  cacheWrite: 0
35534
35594
  },
35535
35595
  contextWindow: 1e6,
35536
- maxTokens: 128e3
35596
+ maxTokens: 524288
35537
35597
  }
35538
35598
  },
35539
35599
  "minimax-cn": {
35600
+ "MiniMax-M3.1-Flash": {
35601
+ id: "MiniMax-M3.1-Flash",
35602
+ name: "MiniMax-M3.1-Flash",
35603
+ api: "anthropic-messages",
35604
+ provider: "minimax-cn",
35605
+ baseUrl: "https://api.minimaxi.com/anthropic",
35606
+ compat: { "forceAdaptiveThinking": true },
35607
+ reasoning: true,
35608
+ thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
35609
+ input: ["text", "image", "video"],
35610
+ cost: {
35611
+ input: 0.15,
35612
+ output: 0.6,
35613
+ cacheRead: 0.015,
35614
+ cacheWrite: 0
35615
+ },
35616
+ contextWindow: 1e6,
35617
+ maxTokens: 524288
35618
+ },
35540
35619
  "MiniMax-M2.7": {
35541
35620
  id: "MiniMax-M2.7",
35542
35621
  name: "MiniMax-M2.7",
@@ -35577,6 +35656,7 @@ var init_models_generated = __esm({
35577
35656
  api: "anthropic-messages",
35578
35657
  provider: "minimax-cn",
35579
35658
  baseUrl: "https://api.minimaxi.com/anthropic",
35659
+ compat: { "forceAdaptiveThinking": true },
35580
35660
  reasoning: true,
35581
35661
  input: ["text", "image", "video"],
35582
35662
  cost: {
@@ -35586,7 +35666,7 @@ var init_models_generated = __esm({
35586
35666
  cacheWrite: 0
35587
35667
  },
35588
35668
  contextWindow: 1e6,
35589
- maxTokens: 128e3
35669
+ maxTokens: 524288
35590
35670
  }
35591
35671
  },
35592
35672
  "mistral": {
@@ -38707,6 +38787,24 @@ var init_models_generated = __esm({
38707
38787
  }
38708
38788
  },
38709
38789
  "openrouter": {
38790
+ "minimax/minimax-m3.1-flash:free": {
38791
+ id: "minimax/minimax-m3.1-flash:free",
38792
+ name: "MiniMax: MiniMax M3.1 Flash (free)",
38793
+ api: "openai-completions",
38794
+ provider: "openrouter",
38795
+ baseUrl: "https://openrouter.ai/api/v1",
38796
+ reasoning: true,
38797
+ thinkingLevelMap: { "off": null, "minimal": null, "low": "low", "medium": "medium", "high": "high", "xhigh": "xhigh" },
38798
+ input: ["text", "image"],
38799
+ cost: {
38800
+ input: 0,
38801
+ output: 0,
38802
+ cacheRead: 0,
38803
+ cacheWrite: 0
38804
+ },
38805
+ contextWindow: 1e6,
38806
+ maxTokens: 524288
38807
+ },
38710
38808
  "ai21/jamba-large-1.7": {
38711
38809
  id: "ai21/jamba-large-1.7",
38712
38810
  name: "AI21: Jamba Large 1.7",
@@ -47408,6 +47506,14 @@ var init_models_generated = __esm({
47408
47506
  }
47409
47507
  });
47410
47508
 
47509
+ // packages/ai/dist/minimax-models.js
47510
+ var init_minimax_models = __esm({
47511
+ "packages/ai/dist/minimax-models.js"() {
47512
+ "use strict";
47513
+ init_esm_shims();
47514
+ }
47515
+ });
47516
+
47411
47517
  // packages/ai/dist/models.js
47412
47518
  function calculateCost(model, usage) {
47413
47519
  usage.cost.input = model.cost.input / 1e6 * usage.input;
@@ -47454,6 +47560,8 @@ var init_models2 = __esm({
47454
47560
  "use strict";
47455
47561
  init_esm_shims();
47456
47562
  init_models_generated();
47563
+ init_minimax_models();
47564
+ init_minimax_models();
47457
47565
  modelRegistry = /* @__PURE__ */ new Map();
47458
47566
  for (const [provider2, models] of Object.entries(MODELS)) {
47459
47567
  const providerModels = /* @__PURE__ */ new Map();
@@ -55407,6 +55515,25 @@ function buildParams2(model, context, isOAuthToken2, options) {
55407
55515
  params.tool_choice = options.toolChoice;
55408
55516
  }
55409
55517
  }
55518
+ return normalizeMiniMaxParams(model, params, options);
55519
+ }
55520
+ function normalizeMiniMaxParams(model, params, options) {
55521
+ if (model.provider !== "minimax" && model.provider !== "minimax-cn")
55522
+ return params;
55523
+ if (params.model === "MiniMax-M3.1-Flash") {
55524
+ const effort = params.output_config?.effort ?? options?.effort ?? "max";
55525
+ const normalized = { ...params, thinking: { type: "adaptive" } };
55526
+ normalized.output_config = {
55527
+ ...params.output_config,
55528
+ effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
55529
+ };
55530
+ delete normalized.service_tier;
55531
+ delete normalized.reasoning_split;
55532
+ return normalized;
55533
+ }
55534
+ if (params.model === "MiniMax-M3" && params.thinking) {
55535
+ return { ...params, thinking: { type: params.thinking.type === "disabled" ? "disabled" : "adaptive" } };
55536
+ }
55410
55537
  return params;
55411
55538
  }
55412
55539
  function normalizeToolCallId(id) {
@@ -55713,6 +55840,7 @@ var init_anthropic = __esm({
55713
55840
  if (nextParams !== void 0) {
55714
55841
  params = nextParams;
55715
55842
  }
55843
+ params = normalizeMiniMaxParams(model, params, options);
55716
55844
  const requestOptions = {
55717
55845
  ...options?.signal ? { signal: options.signal } : {},
55718
55846
  ...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
@@ -77814,7 +77942,7 @@ var require_websocket = __commonJS({
77814
77942
  var http3 = __require("http");
77815
77943
  var net = __require("net");
77816
77944
  var tls = __require("tls");
77817
- var { randomBytes: randomBytes2, createHash: createHash20 } = __require("crypto");
77945
+ var { randomBytes: randomBytes2, createHash: createHash21 } = __require("crypto");
77818
77946
  var { Duplex, Readable: Readable2 } = __require("stream");
77819
77947
  var { URL: URL2 } = __require("url");
77820
77948
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -78482,7 +78610,7 @@ var require_websocket = __commonJS({
78482
78610
  abortHandshake(websocket, socket, "Invalid Upgrade header");
78483
78611
  return;
78484
78612
  }
78485
- const digest2 = createHash20("sha1").update(key + GUID).digest("base64");
78613
+ const digest2 = createHash21("sha1").update(key + GUID).digest("base64");
78486
78614
  if (res.headers["sec-websocket-accept"] !== digest2) {
78487
78615
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
78488
78616
  return;
@@ -78854,7 +78982,7 @@ var require_websocket_server = __commonJS({
78854
78982
  var EventEmitter2 = __require("events");
78855
78983
  var http3 = __require("http");
78856
78984
  var { Duplex } = __require("stream");
78857
- var { createHash: createHash20 } = __require("crypto");
78985
+ var { createHash: createHash21 } = __require("crypto");
78858
78986
  var extension3 = require_extension();
78859
78987
  var PerMessageDeflate2 = require_permessage_deflate();
78860
78988
  var subprotocol2 = require_subprotocol();
@@ -79161,7 +79289,7 @@ var require_websocket_server = __commonJS({
79161
79289
  );
79162
79290
  }
79163
79291
  if (this._state > RUNNING) return abortHandshake(socket, 503);
79164
- const digest2 = createHash20("sha1").update(key + GUID).digest("base64");
79292
+ const digest2 = createHash21("sha1").update(key + GUID).digest("base64");
79165
79293
  const headers = [
79166
79294
  "HTTP/1.1 101 Switching Protocols",
79167
79295
  "Upgrade: websocket",
@@ -138483,6 +138611,18 @@ var init_openai_completions = __esm({
138483
138611
  if (nextParams !== void 0) {
138484
138612
  params = nextParams;
138485
138613
  }
138614
+ if (model.provider === "openrouter" && new URL(model.baseUrl).hostname === "openrouter.ai" && params.model === "minimax/minimax-m3.1-flash:free") {
138615
+ const flash = params;
138616
+ const effort = flash.reasoning?.effort ?? "max";
138617
+ flash.reasoning = {
138618
+ ...flash.reasoning,
138619
+ enabled: true,
138620
+ effort: ["low", "medium", "high", "xhigh", "max"].includes(effort) ? effort : "max"
138621
+ };
138622
+ delete flash.reasoning_effort;
138623
+ delete flash.reasoning_split;
138624
+ delete flash.service_tier;
138625
+ }
138486
138626
  const requestOptions = {
138487
138627
  ...options?.signal ? { signal: options.signal } : {},
138488
138628
  ...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
@@ -155522,6 +155662,7 @@ function normalizeMemoryBrowseQuery(query) {
155522
155662
  return broadMemoryRequests.has(compact) ? "" : query;
155523
155663
  }
155524
155664
  async function compactSearch(options, surface = "mcp") {
155665
+ const startedAt = Date.now();
155525
155666
  await ensureFreshIndex({ loadCorpus: false });
155526
155667
  const searchOptions = { ...options, query: normalizeMemoryBrowseQuery(options.query) };
155527
155668
  let entries = (await searchObservations(searchOptions)).map(
@@ -155575,7 +155716,25 @@ This project does have stored Memorix memories, but none matched the current que
155575
155716
  }
155576
155717
  }
155577
155718
  const totalTokens = countTextTokens(formatted);
155578
- return { entries, formatted, totalTokens };
155719
+ const diagnostics = getLastSearchDiagnostics(options.projectId);
155720
+ return {
155721
+ entries,
155722
+ formatted,
155723
+ totalTokens,
155724
+ receipt: {
155725
+ version: "1",
155726
+ mode: getLastSearchMode(options.projectId),
155727
+ resultCount: entries.length,
155728
+ candidateCount: diagnostics?.candidateCount ?? entries.length,
155729
+ selectedCount: diagnostics?.selectedCount ?? entries.length,
155730
+ omittedCount: diagnostics?.omittedCount ?? 0,
155731
+ omittedByTokenBudget: diagnostics?.omittedByTokenBudget ?? 0,
155732
+ fallbackUsed: diagnostics?.fallbackUsed ?? false,
155733
+ ...diagnostics?.fallbackReason ? { fallbackReason: diagnostics.fallbackReason } : {},
155734
+ tokenCount: totalTokens,
155735
+ elapsedMs: Math.max(0, Date.now() - startedAt)
155736
+ }
155737
+ };
155579
155738
  }
155580
155739
  async function compactTimeline(anchorId, projectId, depthBefore = 3, depthAfter = 3, reader2, surface = "mcp") {
155581
155740
  const result = await getTimeline(anchorId, projectId, depthBefore, depthAfter, reader2);
@@ -160102,12 +160261,27 @@ var init_surfaced_registry = __esm({
160102
160261
  });
160103
160262
 
160104
160263
  // src/server/request-context.ts
160264
+ import { createHash as createHash18 } from "crypto";
160105
160265
  import path28 from "path";
160106
160266
  function resolveRoot(projectRoot) {
160107
160267
  const value = projectRoot.trim();
160108
160268
  if (!value) throw new Error("Project binding requires a non-empty project root");
160109
160269
  return path28.resolve(value);
160110
160270
  }
160271
+ function hashBindingValue(value) {
160272
+ return `sha256:${createHash18("sha256").update(value).digest("hex")}`;
160273
+ }
160274
+ function remoteHost(remote) {
160275
+ const trimmed = remote.trim();
160276
+ if (!trimmed) return void 0;
160277
+ const scpHost = trimmed.match(/^[^@/\s]+@([^:\s/]+):/);
160278
+ if (scpHost) return scpHost[1].toLowerCase();
160279
+ try {
160280
+ return new URL(trimmed).hostname.toLowerCase() || void 0;
160281
+ } catch {
160282
+ return void 0;
160283
+ }
160284
+ }
160111
160285
  function createProjectBindingController(projectRoot) {
160112
160286
  return new ProjectBindingController(projectRoot);
160113
160287
  }
@@ -160134,6 +160308,38 @@ var init_request_context = __esm({
160134
160308
  ...actorId ? { actorId } : {}
160135
160309
  };
160136
160310
  }
160311
+ /**
160312
+ * Return binding diagnostics without exposing local paths or transport IDs.
160313
+ * The hashes let operators compare two surfaces while keeping the receipt
160314
+ * safe to pass through MCP, logs, and agent handoffs.
160315
+ */
160316
+ receipt(options = {}) {
160317
+ const snapshot = this.snapshot();
160318
+ const handle = options.handle;
160319
+ const handleState = !handle ? "absent" : handle.expiresAt && Date.parse(handle.expiresAt) <= Date.now() ? "expired" : "active";
160320
+ return {
160321
+ version: "1",
160322
+ state: snapshot.projectId ? "resolved" : "unresolved",
160323
+ source: snapshot.source,
160324
+ explicit: snapshot.explicit,
160325
+ ...snapshot.projectId ? { projectId: snapshot.projectId } : {},
160326
+ projectRootHash: hashBindingValue(snapshot.projectRoot),
160327
+ ...options.dataDir ? { dataDirHash: hashBindingValue(path28.resolve(options.dataDir)) } : {},
160328
+ gitRemote: options.gitRemote?.trim() ? {
160329
+ state: "verified",
160330
+ hash: hashBindingValue(options.gitRemote.trim()),
160331
+ ...remoteHost(options.gitRemote) ? { host: remoteHost(options.gitRemote) } : {}
160332
+ } : { state: "unavailable" },
160333
+ handle: {
160334
+ state: handleState,
160335
+ ...handle ? { idHash: hashBindingValue(handle.handleId) } : {},
160336
+ ...handle?.createdAt ? { createdAt: handle.createdAt } : {},
160337
+ ...handle?.lastUsedAt ? { lastUsedAt: handle.lastUsedAt } : {},
160338
+ ...handle?.expiresAt ? { expiresAt: handle.expiresAt } : {}
160339
+ },
160340
+ transport: options.transport ?? "unknown"
160341
+ };
160342
+ }
160137
160343
  isExplicit() {
160138
160344
  return this.current.explicit;
160139
160345
  }
@@ -160175,7 +160381,7 @@ var init_request_context = __esm({
160175
160381
  function getMcpServerInfo() {
160176
160382
  return {
160177
160383
  name: "memorix",
160178
- version: true ? "1.9.12" : "1.0.1"
160384
+ version: true ? "1.10.0" : "1.0.1"
160179
160385
  };
160180
160386
  }
160181
160387
  function createMcpDiscoverResult(capabilities, serverInfo) {
@@ -160865,7 +161071,7 @@ function appendLine(lines, candidate, maxTokens, omitted, omittedKind, selected,
160865
161071
  if (receiptSelection) selected?.push(receiptSelection);
160866
161072
  return true;
160867
161073
  }
160868
- omitted.push(omittedKind);
161074
+ omitted.push(receiptSelection?.id ? `${omittedKind}|${receiptSelection.id}` : omittedKind);
160869
161075
  return false;
160870
161076
  }
160871
161077
  function freshnessForMemory(status) {
@@ -160891,15 +161097,23 @@ function receiptOmissionKind(raw) {
160891
161097
  }
160892
161098
  function receiptOmissions(omitted, hiddenCautionMemoryCount) {
160893
161099
  const counts = /* @__PURE__ */ new Map();
161100
+ const samples = /* @__PURE__ */ new Map();
160894
161101
  for (const raw of omitted) {
160895
- const kind = receiptOmissionKind(raw);
161102
+ const [omittedKind, sampleId] = raw.split("|", 2);
161103
+ const kind = receiptOmissionKind(omittedKind);
160896
161104
  if (!kind || raw.endsWith("-heading")) continue;
160897
161105
  counts.set(kind, (counts.get(kind) ?? 0) + 1);
161106
+ if (sampleId) {
161107
+ const values = samples.get(kind) ?? [];
161108
+ if (!values.includes(sampleId) && values.length < 3) values.push(sampleId);
161109
+ samples.set(kind, values);
161110
+ }
160898
161111
  }
160899
161112
  const receipt = [...counts.entries()].map(([kind, count2]) => ({
160900
161113
  kind,
160901
161114
  reason: "token-budget",
160902
- count: count2
161115
+ count: count2,
161116
+ ...samples.get(kind)?.length ? { sampleIds: samples.get(kind) } : {}
160903
161117
  }));
160904
161118
  if (hiddenCautionMemoryCount > 0) {
160905
161119
  receipt.push({
@@ -161608,6 +161822,16 @@ async function buildTaskWorkset(input) {
161608
161822
  ...base,
161609
161823
  budget: { maxTokens }
161610
161824
  });
161825
+ const omittedReceipt = receiptOmissions(rendered.omittedItems, base.hiddenCautionMemoryCount);
161826
+ const retrieval = {
161827
+ mode: input.retrieval?.mode ?? (input.semanticCode ? "hybrid" : "unknown"),
161828
+ ...input.retrieval?.codeProvider || input.providerQuality?.selected ? { codeProvider: input.retrieval?.codeProvider ?? input.providerQuality?.selected } : {},
161829
+ fallbackUsed: Boolean(input.retrieval?.fallbackReason),
161830
+ ...input.retrieval?.fallbackReason ? { fallbackReason: input.retrieval.fallbackReason } : {},
161831
+ candidateCount: governed.plan.decisions.length,
161832
+ selectedCount: rendered.selected.length,
161833
+ omittedCount: omittedReceipt.reduce((total, omission) => total + omission.count, 0)
161834
+ };
161611
161835
  const receipt = {
161612
161836
  version: "1.3",
161613
161837
  target: input.deliveryTarget ?? "project-context",
@@ -161616,8 +161840,9 @@ async function buildTaskWorkset(input) {
161616
161840
  maxTokens,
161617
161841
  tokenCount: rendered.tokenCount
161618
161842
  },
161843
+ retrieval,
161619
161844
  selected: rendered.selected,
161620
- omitted: receiptOmissions(rendered.omittedItems, base.hiddenCautionMemoryCount),
161845
+ omitted: omittedReceipt,
161621
161846
  governance: {
161622
161847
  scope: "optional-evidence",
161623
161848
  mode: governed.plan.mode,
@@ -161625,7 +161850,12 @@ async function buildTaskWorkset(input) {
161625
161850
  kind: decision.candidate.kind,
161626
161851
  ...decision.candidate.id ? { id: decision.candidate.id } : {},
161627
161852
  disposition: decision.disposition,
161628
- reasons: decision.reasons
161853
+ reasons: decision.reasons,
161854
+ ...decision.candidate.freshness ? { freshness: decision.candidate.freshness } : {},
161855
+ ...decision.candidate.trust ? { trust: decision.candidate.trust } : {},
161856
+ ...decision.candidate.quality ? { quality: decision.candidate.quality } : {},
161857
+ ...decision.candidate.conflict ? { conflict: decision.candidate.conflict } : {},
161858
+ ...decision.candidate.evidenceCount !== void 0 ? { evidenceCount: decision.candidate.evidenceCount } : {}
161629
161859
  })),
161630
161860
  cautions: governed.plan.cautions
161631
161861
  },
@@ -162963,7 +163193,7 @@ var compaction_checkpoint_store_exports = {};
162963
163193
  __export(compaction_checkpoint_store_exports, {
162964
163194
  CompactionCheckpointStore: () => CompactionCheckpointStore
162965
163195
  });
162966
- import { createHash as createHash18, randomUUID as randomUUID16 } from "crypto";
163196
+ import { createHash as createHash19, randomUUID as randomUUID16 } from "crypto";
162967
163197
  function optionalText7(value) {
162968
163198
  return typeof value === "string" && value ? value : void 0;
162969
163199
  }
@@ -163005,7 +163235,7 @@ function sourceKeyFor(input, summary) {
163005
163235
  input.tokensBefore ?? "",
163006
163236
  input.firstKeptEntryId ?? ""
163007
163237
  ].join("\0");
163008
- return `derived:${createHash18("sha256").update(material).digest("hex").slice(0, 32)}`;
163238
+ return `derived:${createHash19("sha256").update(material).digest("hex").slice(0, 32)}`;
163009
163239
  }
163010
163240
  function rowToCheckpoint(row) {
163011
163241
  return {
@@ -163844,6 +164074,11 @@ async function buildAutoProjectContext(input) {
163844
164074
  ...alwaysOn.profile.length > 0 || alwaysOn.state || alwaysOn.durable.length > 0 ? { alwaysOn } : {},
163845
164075
  ...semanticOutline ? { semanticCode: semanticOutline } : {},
163846
164076
  providerQuality: providerQuality2,
164077
+ retrieval: {
164078
+ mode: semanticOutline ? "hybrid" : "lexical",
164079
+ codeProvider: providerQuality2.selected,
164080
+ ...externalCaution ? { fallbackReason: externalCaution } : {}
164081
+ },
163847
164082
  currentFacts: worksetFactLines(currentFacts),
163848
164083
  ...continuation ? { continuation } : {},
163849
164084
  ...continuity ? { continuity } : {},
@@ -164389,6 +164624,10 @@ async function attachTaskWorkset(input) {
164389
164624
  startHere: uniq2([...semanticStartHere, ...input.pack.suggestedReads]),
164390
164625
  ...semanticCode ? { semanticCode } : {},
164391
164626
  ...input.providerQuality ? { providerQuality: input.providerQuality } : {},
164627
+ retrieval: {
164628
+ mode: semanticCode ? "hybrid" : "unknown",
164629
+ ...input.providerQuality?.selected ? { codeProvider: input.providerQuality.selected } : {}
164630
+ },
164392
164631
  reliableMemory: input.pack.memories.filter((memory) => memory.status === "current").map((memory) => ({
164393
164632
  id: memory.id,
164394
164633
  title: memory.title,
@@ -171374,7 +171613,7 @@ __export(server_exports2, {
171374
171613
  createMemorixServer: () => createMemorixServer,
171375
171614
  shouldAwaitProjectRuntime: () => shouldAwaitProjectRuntime
171376
171615
  });
171377
- import { createHash as createHash19 } from "crypto";
171616
+ import { createHash as createHash20 } from "crypto";
171378
171617
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
171379
171618
  import { z as z627 } from "zod";
171380
171619
  function formatFormationStageDurations(stageDurationsMs) {
@@ -171458,7 +171697,7 @@ function coerceObjectArray(val) {
171458
171697
  return [];
171459
171698
  }
171460
171699
  function createDeterministicInstanceId(projectId, agentType, agentName) {
171461
- const digest2 = createHash19("sha256").update(projectId).update("\n").update(agentType).update("\n").update(agentName ?? "").digest("hex").slice(0, 24);
171700
+ const digest2 = createHash20("sha256").update(projectId).update("\n").update(agentType).update("\n").update(agentName ?? "").digest("hex").slice(0, 24);
171462
171701
  return `auto-${digest2}`;
171463
171702
  }
171464
171703
  function shouldAwaitProjectRuntime(toolName) {
@@ -172534,20 +172773,17 @@ Use this as the \`topicKey\` parameter in \`memorix_store\` to enable upsert beh
172534
172773
  if (duplicate) return duplicate;
172535
172774
  }
172536
172775
  let text3 = result.formatted;
172537
- try {
172538
- const { getLastSearchMode: getLastSearchMode2 } = await Promise.resolve().then(() => (init_orama_store(), orama_store_exports));
172539
- text3 += `
172776
+ text3 += `
172540
172777
 
172541
- _Search mode: ${getLastSearchMode2(project.id)}_`;
172542
- } catch {
172543
- }
172778
+ _Search mode: ${result.receipt.mode}_`;
172544
172779
  return {
172545
172780
  content: [
172546
172781
  {
172547
172782
  type: "text",
172548
172783
  text: text3
172549
172784
  }
172550
- ]
172785
+ ],
172786
+ structuredContent: { retrieval: result.receipt }
172551
172787
  };
172552
172788
  }, { loadCorpus: false });
172553
172789
  }
@@ -174532,9 +174768,16 @@ Ensure the path points to a directory containing a .git folder (or a subdirector
174532
174768
  agent,
174533
174769
  reader: getObservationReader()
174534
174770
  });
174771
+ const bindingReceipt = projectBinding.receipt({
174772
+ dataDir: projectDir2,
174773
+ transport: options.bindingTransport,
174774
+ gitRemote: project.gitRemote,
174775
+ handle: options.bindingHandle
174776
+ });
174535
174777
  const lines = [
174536
174778
  `[OK] Session started: ${result.session.id}`,
174537
174779
  `Project: ${project.name} (${project.id})`,
174780
+ `Binding: ${bindingReceipt.state} via ${bindingReceipt.source}`,
174538
174781
  result.session.agent ? `Agent: ${result.session.agent}` : "",
174539
174782
  registeredAgent ? `Agent ID: ${registeredAgent.agent_id} (instance: ${registeredAgent.instance_id})` : "",
174540
174783
  !registeredAgent ? "Coordination identity: not joined (memory/session context only)" : "",
@@ -174609,7 +174852,8 @@ ${s2.instruction}`.toLowerCase();
174609
174852
  } catch {
174610
174853
  }
174611
174854
  return {
174612
- content: [{ type: "text", text: lines.filter(Boolean).join("\n") }]
174855
+ content: [{ type: "text", text: lines.filter(Boolean).join("\n") }],
174856
+ structuredContent: { binding: bindingReceipt }
174613
174857
  };
174614
174858
  }
174615
174859
  );
@@ -176822,7 +177066,7 @@ var init_serve_shared = __esm({
176822
177066
 
176823
177067
  // src/cli/version.ts
176824
177068
  function getCliVersion() {
176825
- return true ? "1.9.12" : pkg.version;
177069
+ return true ? "1.10.0" : pkg.version;
176826
177070
  }
176827
177071
  var init_version3 = __esm({
176828
177072
  "src/cli/version.ts"() {