@remnic/core 9.6.29 → 9.6.31

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 (118) hide show
  1. package/dist/access-admin-ops-surface.d.ts +1 -0
  2. package/dist/access-admin-ops-surface.js +2 -1
  3. package/dist/access-boundary.d.ts +1 -0
  4. package/dist/access-boundary.js +3 -2
  5. package/dist/access-cli.js +18 -17
  6. package/dist/access-cli.js.map +1 -1
  7. package/dist/access-http.d.ts +1 -0
  8. package/dist/access-http.js +7 -6
  9. package/dist/access-identity-continuity-surface.d.ts +1 -0
  10. package/dist/access-identity-continuity-surface.js +2 -1
  11. package/dist/access-lcm-surface.d.ts +1 -0
  12. package/dist/access-lcm-surface.js +2 -1
  13. package/dist/access-mcp.d.ts +1 -0
  14. package/dist/access-mcp.js +6 -5
  15. package/dist/access-observe-write-surface.d.ts +1 -0
  16. package/dist/access-observe-write-surface.js +2 -1
  17. package/dist/access-operations-batch.js +4 -3
  18. package/dist/access-operations.d.ts +1 -0
  19. package/dist/access-operations.js +5 -4
  20. package/dist/access-recall-surface.d.ts +1 -0
  21. package/dist/access-recall-surface.js +2 -1
  22. package/dist/access-service.d.ts +1 -0
  23. package/dist/access-service.js +2 -1
  24. package/dist/access-surface-catalog.d.ts +1 -0
  25. package/dist/bootstrap.d.ts +1 -0
  26. package/dist/causal-behavior.d.ts +1 -0
  27. package/dist/{chunk-L6W77GWW.js → chunk-6TCXIRP5.js} +25 -13
  28. package/dist/chunk-6TCXIRP5.js.map +1 -0
  29. package/dist/chunk-C37ZRXX7.js +36 -0
  30. package/dist/chunk-C37ZRXX7.js.map +1 -0
  31. package/dist/{chunk-SGYTQKC2.js → chunk-C6TKSI35.js} +3 -3
  32. package/dist/{chunk-C2SEH754.js → chunk-DAAJUA6Q.js} +4 -4
  33. package/dist/{chunk-FV5FVO2J.js → chunk-DEOYTFA6.js} +9 -5
  34. package/dist/chunk-DEOYTFA6.js.map +1 -0
  35. package/dist/{chunk-PYPOFEMK.js → chunk-DGFU5MSX.js} +16 -1
  36. package/dist/chunk-DGFU5MSX.js.map +1 -0
  37. package/dist/{chunk-EAREADWV.js → chunk-GQURC4B7.js} +2 -2
  38. package/dist/{chunk-XA4PWKBW.js → chunk-MXAGJHTA.js} +3 -3
  39. package/dist/{chunk-LZTFCAKE.js → chunk-OH7QLI6W.js} +28 -15
  40. package/dist/chunk-OH7QLI6W.js.map +1 -0
  41. package/dist/{chunk-5BHIGBHQ.js → chunk-OXVKR5OU.js} +6 -3
  42. package/dist/{chunk-5BHIGBHQ.js.map → chunk-OXVKR5OU.js.map} +1 -1
  43. package/dist/{chunk-IF7THCGJ.js → chunk-PUQZIS6A.js} +3 -3
  44. package/dist/{chunk-4SBW47WK.js → chunk-T67LUYCR.js} +28 -15
  45. package/dist/chunk-T67LUYCR.js.map +1 -0
  46. package/dist/{chunk-4463LUIE.js → chunk-TVIVY7KU.js} +180 -70
  47. package/dist/chunk-TVIVY7KU.js.map +1 -0
  48. package/dist/{chunk-KCYE2MZM.js → chunk-UXPUUL3G.js} +29 -8
  49. package/dist/chunk-UXPUUL3G.js.map +1 -0
  50. package/dist/chunk-VDC6RZI4.js +1 -0
  51. package/dist/{chunk-3RROR5KV.js → chunk-VJRJTRYF.js} +4 -4
  52. package/dist/{chunk-5WJ4LBFR.js → chunk-WSOEYOHN.js} +8 -8
  53. package/dist/{chunk-5AJIDEFT.js → chunk-XFTPUXCE.js} +11 -7
  54. package/dist/chunk-XFTPUXCE.js.map +1 -0
  55. package/dist/cli.d.ts +1 -0
  56. package/dist/cli.js +8 -7
  57. package/dist/compounding/preference-consolidator.d.ts +1 -0
  58. package/dist/event-order-recall.d.ts +1 -0
  59. package/dist/event-order-recall.js +3 -2
  60. package/dist/evidence-pack.d.ts +18 -1
  61. package/dist/evidence-pack.js +1 -1
  62. package/dist/explicit-capture.d.ts +1 -0
  63. package/dist/explicit-cue-recall.d.ts +19 -1
  64. package/dist/explicit-cue-recall.js +3 -2
  65. package/dist/focused-list-recall.d.ts +1 -0
  66. package/dist/focused-list-recall.js +3 -2
  67. package/dist/index.d.ts +3 -2
  68. package/dist/index.js +18 -17
  69. package/dist/lcm/engine.d.ts +3 -0
  70. package/dist/lcm/engine.js +2 -2
  71. package/dist/lcm/index.d.ts +23 -1
  72. package/dist/lcm/index.js +14 -4
  73. package/dist/lcm/recall.d.ts +15 -1
  74. package/dist/lcm/recall.js +5 -3
  75. package/dist/lcm/tools.d.ts +1 -0
  76. package/dist/mcp-memory-inspector-app.d.ts +1 -0
  77. package/dist/orchestrator.d.ts +1 -0
  78. package/dist/orchestrator.js +18 -17
  79. package/dist/response-guidance-recall.d.ts +1 -0
  80. package/dist/response-guidance-recall.js +3 -2
  81. package/dist/targeted-fact-recall.d.ts +1 -0
  82. package/dist/targeted-fact-recall.js +3 -2
  83. package/package.json +2 -2
  84. package/src/access-lcm-surface.ts +20 -5
  85. package/src/access-recall-surface.ts +2 -1
  86. package/src/event-order-recall.ts +5 -3
  87. package/src/evidence-pack.test.ts +66 -1
  88. package/src/evidence-pack.ts +41 -0
  89. package/src/explicit-cue-recall.ts +291 -133
  90. package/src/focused-list-recall.ts +25 -16
  91. package/src/index.ts +3 -0
  92. package/src/lcm/engine.ts +17 -5
  93. package/src/lcm/evidence-identity.ts +59 -0
  94. package/src/lcm/index.ts +13 -1
  95. package/src/lcm/recall.ts +48 -5
  96. package/src/lcm-engine.test.ts +46 -0
  97. package/src/lcm-recall.test.ts +48 -1
  98. package/src/lcm-retrieval-lineage.test.ts +236 -0
  99. package/src/recall-trace-receipts.test.ts +380 -0
  100. package/src/response-guidance-recall.ts +22 -14
  101. package/src/targeted-fact-recall.ts +25 -16
  102. package/dist/chunk-4463LUIE.js.map +0 -1
  103. package/dist/chunk-4SBW47WK.js.map +0 -1
  104. package/dist/chunk-5AJIDEFT.js.map +0 -1
  105. package/dist/chunk-FV5FVO2J.js.map +0 -1
  106. package/dist/chunk-HHLLAQGZ.js +0 -1
  107. package/dist/chunk-KCYE2MZM.js.map +0 -1
  108. package/dist/chunk-L6W77GWW.js.map +0 -1
  109. package/dist/chunk-LZTFCAKE.js.map +0 -1
  110. package/dist/chunk-PYPOFEMK.js.map +0 -1
  111. /package/dist/{chunk-SGYTQKC2.js.map → chunk-C6TKSI35.js.map} +0 -0
  112. /package/dist/{chunk-C2SEH754.js.map → chunk-DAAJUA6Q.js.map} +0 -0
  113. /package/dist/{chunk-EAREADWV.js.map → chunk-GQURC4B7.js.map} +0 -0
  114. /package/dist/{chunk-XA4PWKBW.js.map → chunk-MXAGJHTA.js.map} +0 -0
  115. /package/dist/{chunk-IF7THCGJ.js.map → chunk-PUQZIS6A.js.map} +0 -0
  116. /package/dist/{chunk-HHLLAQGZ.js.map → chunk-VDC6RZI4.js.map} +0 -0
  117. /package/dist/{chunk-3RROR5KV.js.map → chunk-VJRJTRYF.js.map} +0 -0
  118. /package/dist/{chunk-5WJ4LBFR.js.map → chunk-WSOEYOHN.js.map} +0 -0
@@ -7,7 +7,11 @@ import {
7
7
  } from "./chunk-LUPVCGYK.js";
8
8
  import {
9
9
  buildEvidencePack
10
- } from "./chunk-PYPOFEMK.js";
10
+ } from "./chunk-DGFU5MSX.js";
11
+ import {
12
+ lcmArchiveRowId,
13
+ lcmEvidenceIdentity
14
+ } from "./chunk-C37ZRXX7.js";
11
15
 
12
16
  // src/explicit-cue-recall.ts
13
17
  var DEFAULT_MAX_CHARS = 2400;
@@ -339,7 +343,8 @@ async function buildExplicitCueRecallSection(options) {
339
343
  maxItemChars: normalizePositiveInteger(
340
344
  options.maxItemChars,
341
345
  DEFAULT_MAX_ITEM_CHARS
342
- )
346
+ ),
347
+ ...options.onEvidenceSelected ? { onSelection: options.onEvidenceSelected } : {}
343
348
  });
344
349
  }
345
350
  function buildEvidenceFocusQuery(query, options) {
@@ -388,8 +393,29 @@ async function buildTrajectoryAnalysisRecallSection(options) {
388
393
  return "";
389
394
  }
390
395
  const clipped = truncateTrajectoryAnalysisLines(lines, bodyBudget);
391
- return clipped.length === 0 ? "" : `${header}
392
- ${clipped.join("\n")}`;
396
+ if (clipped.length === 0) return "";
397
+ const text = `${header}
398
+ ${clipped.map((line) => line.text).join("\n")}`;
399
+ if (options.onLineSelected) {
400
+ let lineStart = header.length + 1;
401
+ for (const line of clipped) {
402
+ const lineEnd = lineStart + line.text.length;
403
+ options.onLineSelected({
404
+ lineStart,
405
+ lineEnd,
406
+ lineageStatus: line.lineageStatus,
407
+ actionArchiveRowIds: [...line.actionArchiveRowIds],
408
+ observationArchiveRowIds: [...line.observationArchiveRowIds]
409
+ });
410
+ lineStart = lineEnd + 1;
411
+ }
412
+ }
413
+ return text;
414
+ }
415
+ function uniqueSortedArchiveRowIds(values) {
416
+ return [...new Set(values.filter(
417
+ (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0
418
+ ))].sort((left, right) => left - right);
393
419
  }
394
420
  async function collectTurnReferenceEvidence(options) {
395
421
  if (!options.sessionId) {
@@ -463,8 +489,8 @@ async function collectFocusedTranscriptCueEvidence(options) {
463
489
  continue;
464
490
  }
465
491
  appendEvidenceItem(options.evidenceItems, options.seenTurns, {
466
- id: `${options.sessionId}:${message.turn_index}`,
467
- sessionId: options.sessionId,
492
+ ...lcmEvidenceIdentity(message, options.sessionId),
493
+ sessionId: message.session_id ?? options.sessionId,
468
494
  turnIndex: message.turn_index,
469
495
  role: message.role,
470
496
  content: message.content
@@ -617,7 +643,7 @@ async function collectContentLabelReferenceEvidence(options) {
617
643
  }
618
644
  if (expanded.length === 0) {
619
645
  appendEvidenceItem(options.evidenceItems, options.seenTurns, {
620
- id: `${hit.session_id}:${hit.turn_index}`,
646
+ ...lcmEvidenceIdentity(hit, hit.session_id),
621
647
  sessionId: hit.session_id,
622
648
  turnIndex: hit.turn_index,
623
649
  role: hit.role,
@@ -650,7 +676,8 @@ async function searchReferenceContentLabels(engine, referenceNumber, sessionId)
650
676
  if (!isReferenceLabelRole(result.role, labelKind) || !contentHasReferenceLabel(result.content, labelKind, referenceNumber)) {
651
677
  continue;
652
678
  }
653
- hits.set(`${result.session_id}:${result.turn_index}:${labelKind}`, {
679
+ hits.set(`${lcmEvidenceIdentity(result, result.session_id).id}:${labelKind}`, {
680
+ ...typeof result.id === "number" ? { id: result.id } : {},
654
681
  turn_index: result.turn_index,
655
682
  role: result.role,
656
683
  content: result.content,
@@ -813,7 +840,7 @@ async function collectLexicalCueEvidence(options) {
813
840
  );
814
841
  if (expanded.length === 0) {
815
842
  appendEvidenceItem(options.evidenceItems, options.seenTurns, {
816
- id: `${result.session_id}:${result.turn_index}`,
843
+ ...lcmEvidenceIdentity(result, result.session_id),
817
844
  sessionId: result.session_id,
818
845
  turnIndex: result.turn_index,
819
846
  role: result.role,
@@ -824,7 +851,7 @@ async function collectLexicalCueEvidence(options) {
824
851
  }
825
852
  if (exactHitFirst) {
826
853
  appendEvidenceItem(options.evidenceItems, options.seenTurns, {
827
- id: `${result.session_id}:${result.turn_index}`,
854
+ ...lcmEvidenceIdentity(result, result.session_id),
828
855
  sessionId: result.session_id,
829
856
  turnIndex: result.turn_index,
830
857
  role: result.role,
@@ -841,6 +868,40 @@ async function collectLexicalCueEvidence(options) {
841
868
  }
842
869
  }
843
870
  }
871
+ var TrajectoryAnalysisLines = class extends Array {
872
+ sources = /* @__PURE__ */ new Map();
873
+ pushWithSources(text, actionSteps = [], observationSteps = []) {
874
+ const index = this.length;
875
+ const length = super.push(text);
876
+ const hasUnavailableSource = actionSteps.some(
877
+ (step) => lcmArchiveRowId({ id: step.actionArchiveRowId }) === void 0
878
+ ) || observationSteps.some(
879
+ (step) => lcmArchiveRowId({ id: step.observationArchiveRowId }) === void 0
880
+ );
881
+ this.sources.set(index, {
882
+ lineageStatus: hasUnavailableSource ? "unavailable" : "exact",
883
+ actionArchiveRowIds: hasUnavailableSource ? [] : uniqueSortedArchiveRowIds(
884
+ actionSteps.map((step) => step.actionArchiveRowId)
885
+ ),
886
+ observationArchiveRowIds: hasUnavailableSource ? [] : uniqueSortedArchiveRowIds(
887
+ observationSteps.map((step) => step.observationArchiveRowId)
888
+ )
889
+ });
890
+ return length;
891
+ }
892
+ sourceAt(index) {
893
+ const source = this.sources.get(index);
894
+ return source ? {
895
+ lineageStatus: source.lineageStatus,
896
+ actionArchiveRowIds: [...source.actionArchiveRowIds],
897
+ observationArchiveRowIds: [...source.observationArchiveRowIds]
898
+ } : {
899
+ lineageStatus: "unavailable",
900
+ actionArchiveRowIds: [],
901
+ observationArchiveRowIds: []
902
+ };
903
+ }
904
+ };
844
905
  function hasTrajectoryAnalysisIntent(query) {
845
906
  const normalized = normalizeTrajectoryQuery(query);
846
907
  if (collectExplicitTurnReferences(query).length > 0) {
@@ -869,6 +930,8 @@ function parseLabeledTrajectory(messages) {
869
930
  const step = getOrCreateTrajectoryStep(byStep, action.step);
870
931
  step.action = action.value;
871
932
  step.actionTurnIndex = message.turn_index;
933
+ const archiveRowId = lcmArchiveRowId(message);
934
+ if (archiveRowId !== void 0) step.actionArchiveRowId = archiveRowId;
872
935
  continue;
873
936
  }
874
937
  const observation = parseTrajectoryLabel(message.content, "Observation");
@@ -876,6 +939,10 @@ function parseLabeledTrajectory(messages) {
876
939
  const step = getOrCreateTrajectoryStep(byStep, observation.step);
877
940
  step.observation = observation.value;
878
941
  step.observationTurnIndex = message.turn_index;
942
+ const archiveRowId = lcmArchiveRowId(message);
943
+ if (archiveRowId !== void 0) {
944
+ step.observationArchiveRowId = archiveRowId;
945
+ }
879
946
  }
880
947
  }
881
948
  return [...byStep.values()].sort((left, right) => left.step - right.step);
@@ -957,9 +1024,10 @@ function inferTrajectoryBounds(query, trajectory) {
957
1024
  function buildTrajectoryAnalysisLines(query, trajectory, bounds) {
958
1025
  const normalized = normalizeTrajectoryQuery(query);
959
1026
  const explicitReferences = collectExplicitTurnReferences(query);
960
- const lines = [
1027
+ const lines = new TrajectoryAnalysisLines();
1028
+ lines.pushWithSources(
961
1029
  `Analyzed labeled action/observation transcript window: steps ${bounds.start}-${bounds.end} (${bounds.reason}).`
962
- ];
1030
+ );
963
1031
  const hasQuotedObservationPair = extractQuotedObservations(query).length >= 2;
964
1032
  const transition = findObservationTransition(query, trajectory);
965
1033
  const entities = extractNumberedEntities(query);
@@ -972,8 +1040,14 @@ function buildTrajectoryAnalysisLines(query, trajectory, bounds) {
972
1040
  const asksEntityState = /\bstate\b/.test(normalized) || /\bchanges?\s+history\b/.test(normalized) || /\bwhole\s+changes?\s+history\b/.test(normalized);
973
1041
  const asksResultingObservation = /\bresulting\s+state\b/.test(normalized) || /\bprovide\s+the\s+full\s+observation\b/.test(normalized) || /\bwhat\s+will\s+be\s+the\s+resulting\b/.test(normalized);
974
1042
  if (transition) {
975
- lines.push(
976
- `Matched quoted observations: Observation ${transition.fromStep} -> Observation ${transition.toStep}.`
1043
+ const fromStep = trajectory.find((step) => step.step === transition.fromStep);
1044
+ const toStep = trajectory.find((step) => step.step === transition.toStep);
1045
+ lines.pushWithSources(
1046
+ `Matched quoted observations: Observation ${transition.fromStep} -> Observation ${transition.toStep}.`,
1047
+ [],
1048
+ [fromStep, toStep].filter(
1049
+ (step) => step !== void 0
1050
+ )
977
1051
  );
978
1052
  appendActionSequenceSummary(
979
1053
  lines,
@@ -1037,7 +1111,7 @@ function buildTrajectoryAnalysisLines(query, trajectory, bounds) {
1037
1111
  });
1038
1112
  }
1039
1113
  }
1040
- return lines.length === 1 ? [] : lines;
1114
+ return lines.length === 1 ? new TrajectoryAnalysisLines() : lines;
1041
1115
  }
1042
1116
  function appendReferencedTrajectoryLines(lines, trajectory, references, options) {
1043
1117
  const byStep = new Map(trajectory.map((step) => [step.step, step]));
@@ -1045,13 +1119,17 @@ function appendReferencedTrajectoryLines(lines, trajectory, references, options)
1045
1119
  if (window.length === 0) {
1046
1120
  return;
1047
1121
  }
1048
- lines.push(options.heading);
1122
+ lines.pushWithSources(options.heading);
1049
1123
  for (const step of window) {
1050
1124
  if (step.action) {
1051
- lines.push(`[Action ${step.step}]: ${step.action}`);
1125
+ lines.pushWithSources(`[Action ${step.step}]: ${step.action}`, [step]);
1052
1126
  }
1053
1127
  if (options.includeObservations && step.observation) {
1054
- lines.push(`[Observation ${step.step}]: ${oneLine(step.observation)}`);
1128
+ lines.pushWithSources(
1129
+ `[Observation ${step.step}]: ${oneLine(step.observation)}`,
1130
+ [],
1131
+ [step]
1132
+ );
1055
1133
  }
1056
1134
  }
1057
1135
  }
@@ -1066,31 +1144,40 @@ function appendActionRangeLines(lines, trajectory, start, end, options) {
1066
1144
  if (window.length === 0) {
1067
1145
  return;
1068
1146
  }
1069
- lines.push(options.heading);
1147
+ lines.pushWithSources(options.heading);
1070
1148
  for (const step of window) {
1071
1149
  if (step.action) {
1072
- lines.push(`[Action ${step.step}]: ${step.action}`);
1150
+ lines.pushWithSources(`[Action ${step.step}]: ${step.action}`, [step]);
1073
1151
  }
1074
1152
  if (options.includeObservations && step.observation) {
1075
- lines.push(`[Observation ${step.step}]: ${oneLine(step.observation)}`);
1153
+ lines.pushWithSources(
1154
+ `[Observation ${step.step}]: ${oneLine(step.observation)}`,
1155
+ [],
1156
+ [step]
1157
+ );
1076
1158
  }
1077
1159
  }
1078
1160
  }
1079
1161
  function appendActionSequenceSummary(lines, trajectory, start, end, heading) {
1080
1162
  const low = Math.min(start, end);
1081
1163
  const high = Math.max(start, end);
1082
- const actions = trajectory.filter((step) => step.step >= low && step.step <= high && step.action).map((step) => `step ${step.step}: ${step.action}`);
1164
+ const actionSteps = trajectory.filter((step) => step.step >= low && step.step <= high && step.action);
1165
+ const actions = actionSteps.map((step) => `step ${step.step}: ${step.action}`);
1083
1166
  if (actions.length === 0) {
1084
1167
  return;
1085
1168
  }
1086
- lines.push(`${heading} ${actions.join("; ")}.`);
1169
+ lines.pushWithSources(`${heading} ${actions.join("; ")}.`, actionSteps);
1087
1170
  }
1088
1171
  function appendResultingObservationLine(lines, trajectory, stepNumber) {
1089
1172
  const step = trajectory.find((candidate) => candidate.step === stepNumber);
1090
1173
  if (!step?.observation) {
1091
1174
  return;
1092
1175
  }
1093
- lines.push(`Resulting observation after Action ${step.step}: ${oneLine(step.observation)}`);
1176
+ lines.pushWithSources(
1177
+ `Resulting observation after Action ${step.step}: ${oneLine(step.observation)}`,
1178
+ [],
1179
+ [step]
1180
+ );
1094
1181
  }
1095
1182
  function appendSpatialTrajectoryInferenceLines(lines, query, trajectory, bounds) {
1096
1183
  const normalized = normalizeTrajectoryQuery(query);
@@ -1108,22 +1195,22 @@ function appendSpatialTrajectoryInferenceLines(lines, query, trajectory, bounds)
1108
1195
  const window = spatialTrajectoryWindowForQuery(query, trajectory, bounds);
1109
1196
  const counterfactualContactLines = collectCounterfactualContactLines(query, trajectory, normalized);
1110
1197
  if (counterfactualContactLines.length > 0) {
1111
- lines.push("Counterfactual contact cues:");
1198
+ lines.pushWithSources("Counterfactual contact cues:");
1112
1199
  lines.push(...counterfactualContactLines);
1113
1200
  }
1114
1201
  const selfReversingLines = collectSelfReversingProgressLines(query, window, normalized);
1115
1202
  if (selfReversingLines.length > 0) {
1116
- lines.push("Self-reversing sequence cues:");
1203
+ lines.pushWithSources("Self-reversing sequence cues:");
1117
1204
  lines.push(...selfReversingLines);
1118
1205
  }
1119
1206
  const onlyEffectiveActionLines = collectOnlyEffectiveActionLines(window, normalized);
1120
1207
  if (onlyEffectiveActionLines.length > 0) {
1121
- lines.push("Only-effective action cues:");
1208
+ lines.pushWithSources("Only-effective action cues:");
1122
1209
  lines.push(...onlyEffectiveActionLines);
1123
1210
  }
1124
1211
  const pushedPhraseGroupLines = collectPushedPhraseGroupShiftLines(query, window, normalized);
1125
1212
  if (pushedPhraseGroupLines.length > 0) {
1126
- lines.push("Pushed phrase-group shift cues:");
1213
+ lines.pushWithSources("Pushed phrase-group shift cues:");
1127
1214
  lines.push(...pushedPhraseGroupLines);
1128
1215
  }
1129
1216
  const suppressMovementProgressEvidence = onlyEffectiveActionLines.length > 0 || selfReversingLines.some(
@@ -1131,12 +1218,12 @@ function appendSpatialTrajectoryInferenceLines(lines, query, trajectory, bounds)
1131
1218
  ) || pushedPhraseGroupLines.length > 0;
1132
1219
  const actionMovementLines = suppressMovementProgressEvidence ? [] : collectActionMovementSummaryLines(query, window, bounds);
1133
1220
  if (actionMovementLines.length > 0) {
1134
- lines.push("Action movement summary cues:");
1221
+ lines.pushWithSources("Action movement summary cues:");
1135
1222
  lines.push(...actionMovementLines);
1136
1223
  }
1137
1224
  const movementLines = suppressMovementProgressEvidence ? [] : collectMovementDeltaLines(query, window);
1138
1225
  if (movementLines.length > 0) {
1139
- lines.push("Relative-position movement cues:");
1226
+ lines.pushWithSources("Relative-position movement cues:");
1140
1227
  lines.push(...movementLines);
1141
1228
  }
1142
1229
  const objectAlignmentWindow = objectAlignmentWindowForQuery(query, trajectory, bounds);
@@ -1146,77 +1233,77 @@ function appendSpatialTrajectoryInferenceLines(lines, query, trajectory, bounds)
1146
1233
  normalized
1147
1234
  );
1148
1235
  if (objectAlignmentLines.length > 0) {
1149
- lines.push("Object alignment cues:");
1236
+ lines.pushWithSources("Object alignment cues:");
1150
1237
  lines.push(...objectAlignmentLines);
1151
1238
  }
1152
1239
  const alternativeActionLines = collectAlternativeActionLines(query, trajectory);
1153
1240
  if (alternativeActionLines.length > 0) {
1154
- lines.push("Counterfactual action cues:");
1241
+ lines.pushWithSources("Counterfactual action cues:");
1155
1242
  lines.push(...alternativeActionLines);
1156
1243
  }
1157
1244
  const adjacentRuleSetupLines = collectAdjacentRuleSetupLines(window, normalized);
1158
1245
  if (adjacentRuleSetupLines.length > 0) {
1159
- lines.push("Adjacent rule-block setup cues:");
1246
+ lines.pushWithSources("Adjacent rule-block setup cues:");
1160
1247
  lines.push(...adjacentRuleSetupLines);
1161
1248
  }
1162
1249
  const blockedMoveLines = collectBlockedMoveLines(query, window, normalized);
1163
1250
  if (blockedMoveLines.length > 0) {
1164
- lines.push("Blocked-move cues:");
1251
+ lines.pushWithSources("Blocked-move cues:");
1165
1252
  lines.push(...blockedMoveLines);
1166
1253
  }
1167
1254
  const failedEscapeLines = collectFailedEscapeLines(query, trajectory, normalized);
1168
1255
  if (failedEscapeLines.length > 0) {
1169
- lines.push("Failed-move escape cues:");
1256
+ lines.pushWithSources("Failed-move escape cues:");
1170
1257
  lines.push(...failedEscapeLines);
1171
1258
  }
1172
1259
  const sameRelativeTextPushLines = collectSameRelativeTextPushLines(window, normalized);
1173
1260
  if (sameRelativeTextPushLines.length > 0) {
1174
- lines.push("Same-relative text-push cues:");
1261
+ lines.pushWithSources("Same-relative text-push cues:");
1175
1262
  lines.push(...sameRelativeTextPushLines);
1176
1263
  }
1177
1264
  const failedContactLines = sameRelativeTextPushLines.length > 0 ? [] : collectFailedContactBoundaryLines(window, normalized);
1178
1265
  if (failedContactLines.length > 0) {
1179
- lines.push("Failed-push boundary cues:");
1266
+ lines.pushWithSources("Failed-push boundary cues:");
1180
1267
  lines.push(...failedContactLines);
1181
1268
  }
1182
1269
  const transformationLines = collectTemporaryRuleTransformationLines(window, normalized);
1183
1270
  if (transformationLines.length > 0) {
1184
- lines.push("Temporary transformation cues:");
1271
+ lines.pushWithSources("Temporary transformation cues:");
1185
1272
  lines.push(...transformationLines);
1186
1273
  }
1187
1274
  const wholeConfigurationShiftLines = collectWholeConfigurationShiftLines(window, normalized);
1188
1275
  if (wholeConfigurationShiftLines.length > 0) {
1189
- lines.push("Whole-configuration shift cues:");
1276
+ lines.pushWithSources("Whole-configuration shift cues:");
1190
1277
  lines.push(...wholeConfigurationShiftLines);
1191
1278
  }
1192
1279
  const ruleInterventionLines = collectRuleInterventionStrategyLines(window, normalized);
1193
1280
  if (ruleInterventionLines.length > 0) {
1194
- lines.push("Rule-intervention strategy cues:");
1281
+ lines.pushWithSources("Rule-intervention strategy cues:");
1195
1282
  lines.push(...ruleInterventionLines);
1196
1283
  }
1197
1284
  const missingPushTargetLines = collectMissingPushTargetLines(window, normalized);
1198
1285
  if (missingPushTargetLines.length > 0) {
1199
- lines.push("Missing-interaction cues:");
1286
+ lines.pushWithSources("Missing-interaction cues:");
1200
1287
  lines.push(...missingPushTargetLines);
1201
1288
  }
1202
1289
  const rulePhraseAlignmentLines = collectRulePhraseAlignmentLines(window, normalized);
1203
1290
  if (rulePhraseAlignmentLines.length > 0) {
1204
- lines.push("Rule-phrase alignment cues:");
1291
+ lines.pushWithSources("Rule-phrase alignment cues:");
1205
1292
  lines.push(...rulePhraseAlignmentLines);
1206
1293
  }
1207
1294
  const controlRuleInteractionLines = collectControlRuleInteractionLines(window, normalized);
1208
1295
  if (controlRuleInteractionLines.length > 0) {
1209
- lines.push("Control-rule interaction cues:");
1296
+ lines.pushWithSources("Control-rule interaction cues:");
1210
1297
  lines.push(...controlRuleInteractionLines);
1211
1298
  }
1212
1299
  const ruleTextPositionLines = suppressMovementProgressEvidence ? [] : collectRuleTextPositionLines(window, normalized);
1213
1300
  if (ruleTextPositionLines.length > 0) {
1214
- lines.push("Rule-text positioning cues:");
1301
+ lines.pushWithSources("Rule-text positioning cues:");
1215
1302
  lines.push(...ruleTextPositionLines);
1216
1303
  }
1217
1304
  const ruleLines = collectRuleStateLines(window, normalized);
1218
1305
  if (ruleLines.length > 0) {
1219
- lines.push("Rule-state cues:");
1306
+ lines.pushWithSources("Rule-state cues:");
1220
1307
  lines.push(...ruleLines);
1221
1308
  }
1222
1309
  }
@@ -2516,8 +2603,11 @@ function uniqueLines(lines) {
2516
2603
  return [...new Set(lines)];
2517
2604
  }
2518
2605
  function appendActionFrequencyLines(lines, trajectory, bounds) {
2606
+ const actionSteps = boundedTrajectory(trajectory, bounds).filter(
2607
+ (step) => step.action !== void 0
2608
+ );
2519
2609
  const counts = /* @__PURE__ */ new Map();
2520
- for (const step of boundedTrajectory(trajectory, bounds)) {
2610
+ for (const step of actionSteps) {
2521
2611
  if (!step.action) continue;
2522
2612
  const verb = normalizeActionVerb(step.action);
2523
2613
  if (!verb) continue;
@@ -2529,8 +2619,9 @@ function appendActionFrequencyLines(lines, trajectory, bounds) {
2529
2619
  const frequencies = [...counts.entries()].sort(
2530
2620
  (left, right) => right[1] - left[1] || left[0].localeCompare(right[0])
2531
2621
  );
2532
- lines.push(
2533
- `Action frequency through requested window: ${frequencies.map(([verb, count]) => `${verb}=${count}`).join(", ")}.`
2622
+ lines.pushWithSources(
2623
+ `Action frequency through requested window: ${frequencies.map(([verb, count]) => `${verb}=${count}`).join(", ")}.`,
2624
+ actionSteps
2534
2625
  );
2535
2626
  }
2536
2627
  function appendInventoryChangeLines(lines, trajectory, bounds) {
@@ -2546,13 +2637,16 @@ function appendInventoryChangeLines(lines, trajectory, bounds) {
2546
2637
  if (changes.length === 0) {
2547
2638
  return;
2548
2639
  }
2549
- lines.push("Inventory changes from action transcript:");
2640
+ const changeSteps = changes.map((change) => trajectory.find((step) => step.step === change.step)).filter((step) => step !== void 0);
2641
+ lines.pushWithSources("Inventory changes from action transcript:");
2550
2642
  if (changes.length > 5) {
2551
- lines.push(
2552
- `First five inventory changes: ${formatInventoryChangeSummary(changes.slice(0, 5))}.`
2643
+ lines.pushWithSources(
2644
+ `First five inventory changes: ${formatInventoryChangeSummary(changes.slice(0, 5))}.`,
2645
+ changeSteps.slice(0, 5)
2553
2646
  );
2554
- lines.push(
2555
- `Complete inventory changes: ${formatInventoryChangeSummary(changes)}.`
2647
+ lines.pushWithSources(
2648
+ `Complete inventory changes: ${formatInventoryChangeSummary(changes)}.`,
2649
+ changeSteps
2556
2650
  );
2557
2651
  }
2558
2652
  for (const change of changes) {
@@ -2578,9 +2672,13 @@ function appendContainerStateChangeLines(lines, trajectory, bounds) {
2578
2672
  if (changes.length === 0) {
2579
2673
  return;
2580
2674
  }
2581
- lines.push("Container open/close state changes:");
2675
+ lines.pushWithSources("Container open/close state changes:");
2582
2676
  for (const change of changes) {
2583
- lines.push(`[Action ${change.step}]: ${change.action} => ${change.entity} ${change.state}`);
2677
+ const step = trajectory.find((candidate) => candidate.step === change.step);
2678
+ lines.pushWithSources(
2679
+ `[Action ${change.step}]: ${change.action} => ${change.entity} ${change.state}`,
2680
+ step ? [step] : []
2681
+ );
2584
2682
  }
2585
2683
  }
2586
2684
  function appendEntityTimelineLines(lines, trajectory, bounds, entities, options) {
@@ -2598,26 +2696,33 @@ function appendEntityTimelineLines(lines, trajectory, bounds, entities, options)
2598
2696
  if (directActions.length === 0 && stateChanges.length === 0 && objectTransfers.length === 0) {
2599
2697
  continue;
2600
2698
  }
2601
- lines.push(`Timeline for ${entity}:`);
2699
+ lines.pushWithSources(`Timeline for ${entity}:`);
2602
2700
  for (const step of directActions) {
2603
- lines.push(`[Action ${step.step}]: ${step.action}`);
2701
+ lines.pushWithSources(`[Action ${step.step}]: ${step.action}`, [step]);
2604
2702
  }
2605
2703
  if (objectTransfers.length > 0) {
2606
- lines.push(`Object transfers involving ${entity}:`);
2704
+ lines.pushWithSources(`Object transfers involving ${entity}:`);
2607
2705
  for (const transfer of objectTransfers) {
2608
- lines.push(`[Action ${transfer.step}]: ${transfer.action} => ${formatContainerTransfer(transfer)}`);
2706
+ const step = trajectory.find((candidate) => candidate.step === transfer.step);
2707
+ lines.pushWithSources(
2708
+ `[Action ${transfer.step}]: ${transfer.action} => ${formatContainerTransfer(transfer)}`,
2709
+ step ? [step] : []
2710
+ );
2609
2711
  }
2610
2712
  }
2611
2713
  const inferredLocation = inferEntityLocation(trajectory, bounds, entity);
2612
2714
  if (inferredLocation) {
2613
- lines.push(
2614
- `Inferred ${entity} location at step ${bounds.end}: ${inferredLocation}.`
2715
+ lines.pushWithSources(
2716
+ `Inferred ${entity} location at step ${bounds.end}: ${inferredLocation.location}.`,
2717
+ [inferredLocation.sourceStep]
2615
2718
  );
2616
2719
  }
2617
2720
  if (stateChanges.length > 0) {
2618
2721
  const latest = stateChanges[stateChanges.length - 1];
2619
- lines.push(
2620
- `Latest ${entity} state at step ${bounds.end}: ${latest.state}; state changes: ${stateChanges.map((change) => `${change.step}:${change.state}`).join(", ")}.`
2722
+ const stateSteps = stateChanges.map((change) => trajectory.find((step) => step.step === change.step)).filter((step) => step !== void 0);
2723
+ lines.pushWithSources(
2724
+ `Latest ${entity} state at step ${bounds.end}: ${latest.state}; state changes: ${stateChanges.map((change) => `${change.step}:${change.state}`).join(", ")}.`,
2725
+ stateSteps
2621
2726
  );
2622
2727
  }
2623
2728
  }
@@ -2876,12 +2981,14 @@ function isLikelyContainerEntity(entity) {
2876
2981
  function inferEntityLocation(trajectory, bounds, entity) {
2877
2982
  const normalizedEntity = normalizeEntity(entity);
2878
2983
  let location;
2984
+ let sourceStep;
2879
2985
  for (const step of boundedTrajectory(trajectory, bounds)) {
2880
2986
  if (!step.action) continue;
2881
2987
  const action = step.action.trim();
2882
2988
  const take = /^take\s+(.+?)\s+from\s+(.+)$/i.exec(action);
2883
2989
  if (take && normalizeEntity(take[1]) === normalizedEntity) {
2884
2990
  location = "inventory";
2991
+ sourceStep = step;
2885
2992
  continue;
2886
2993
  }
2887
2994
  const move = /^(?:move|put|place|insert)\s+(.+?)\s+(?:to|in|into|on)\s+(.+)$/i.exec(
@@ -2889,9 +2996,10 @@ function inferEntityLocation(trajectory, bounds, entity) {
2889
2996
  );
2890
2997
  if (move && normalizeEntity(move[1]) === normalizedEntity) {
2891
2998
  location = move[2].trim();
2999
+ sourceStep = step;
2892
3000
  }
2893
3001
  }
2894
- return location;
3002
+ return location && sourceStep ? { location, sourceStep } : void 0;
2895
3003
  }
2896
3004
  function normalizeActionVerb(action) {
2897
3005
  const match = /^([a-z][a-z0-9_-]*)\b/i.exec(action.trim());
@@ -2920,7 +3028,9 @@ function normalizeTurnExpansionEnd(stats) {
2920
3028
  function truncateTrajectoryAnalysisLines(lines, maxChars) {
2921
3029
  const result = [];
2922
3030
  let used = 0;
2923
- for (const line of lines.slice(0, TRAJECTORY_ANALYSIS_MAX_LINES)) {
3031
+ const limit = Math.min(lines.length, TRAJECTORY_ANALYSIS_MAX_LINES);
3032
+ for (let index = 0; index < limit; index += 1) {
3033
+ const line = lines[index];
2924
3034
  const separator = result.length === 0 ? 0 : 1;
2925
3035
  const remaining = maxChars - used - separator;
2926
3036
  if (remaining <= 0) {
@@ -2930,7 +3040,7 @@ function truncateTrajectoryAnalysisLines(lines, maxChars) {
2930
3040
  if (clipped.length === 0) {
2931
3041
  break;
2932
3042
  }
2933
- result.push(clipped);
3043
+ result.push({ text: clipped, ...lines.sourceAt(index) });
2934
3044
  used += separator + clipped.length;
2935
3045
  }
2936
3046
  return result;
@@ -3335,8 +3445,8 @@ function normalizeTrajectoryQuery(value) {
3335
3445
  function appendExpandedEvidence(evidenceItems, seenTurns, sessionId, expanded) {
3336
3446
  for (const message of expanded) {
3337
3447
  appendEvidenceItem(evidenceItems, seenTurns, {
3338
- id: `${sessionId}:${message.turn_index}`,
3339
- sessionId,
3448
+ ...lcmEvidenceIdentity(message, sessionId),
3449
+ sessionId: message.session_id ?? sessionId,
3340
3450
  turnIndex: message.turn_index,
3341
3451
  role: message.role,
3342
3452
  content: message.content
@@ -3451,7 +3561,7 @@ async function collectNamedMeetingFactEvidence(options) {
3451
3561
  for (const result of results) {
3452
3562
  if (!isNamedMeetingFactEvidence(result.content, options.query)) continue;
3453
3563
  appendEvidenceItem(options.evidenceItems, options.seenTurns, {
3454
- id: `${result.session_id}:${result.turn_index}`,
3564
+ ...lcmEvidenceIdentity(result, result.session_id),
3455
3565
  sessionId: result.session_id,
3456
3566
  turnIndex: result.turn_index,
3457
3567
  role: result.role,
@@ -4148,4 +4258,4 @@ export {
4148
4258
  collectStructuredPlanCues,
4149
4259
  collectTemporalLexicalCues
4150
4260
  };
4151
- //# sourceMappingURL=chunk-4463LUIE.js.map
4261
+ //# sourceMappingURL=chunk-TVIVY7KU.js.map