agentfootprint 16.2.0 → 16.3.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 (494) hide show
  1. package/CAPABILITIES.md +1 -0
  2. package/dist/adapters/llm/AnthropicProvider.js +26 -0
  3. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  4. package/dist/adapters/llm/OllamaProvider.js +16 -61
  5. package/dist/adapters/llm/OllamaProvider.js.map +1 -1
  6. package/dist/adapters/llm/anthropicThinkingReplay.js +2 -24
  7. package/dist/adapters/llm/anthropicThinkingReplay.js.map +1 -1
  8. package/dist/adapters/llm/anthropicToolArguments.js +9 -3
  9. package/dist/adapters/llm/anthropicToolArguments.js.map +1 -1
  10. package/dist/adapters/llm/ollamaErrors.js +61 -0
  11. package/dist/adapters/llm/ollamaErrors.js.map +1 -0
  12. package/dist/adapters/observability/assessmentReasonWords.js +3 -0
  13. package/dist/adapters/observability/assessmentReasonWords.js.map +1 -1
  14. package/dist/adapters/observability/auditShapes/events/decisions.js +1 -0
  15. package/dist/adapters/observability/auditShapes/events/decisions.js.map +1 -1
  16. package/dist/adapters/observability/auditShapes/events/streaming.js +1 -0
  17. package/dist/adapters/observability/auditShapes/events/streaming.js.map +1 -1
  18. package/dist/answer-account/account.js +12 -12
  19. package/dist/answer-account/account.js.map +1 -1
  20. package/dist/answer-account/facts/standing.js +30 -4
  21. package/dist/answer-account/facts/standing.js.map +1 -1
  22. package/dist/answer-account/howSureReasonTemplates.js +5 -0
  23. package/dist/answer-account/howSureReasonTemplates.js.map +1 -1
  24. package/dist/answer-account/templates.js +1 -1
  25. package/dist/artifacts/fileArtifacts.js +2 -2
  26. package/dist/artifacts/fileArtifacts.js.map +1 -1
  27. package/dist/artifacts/gcsArtifacts.js +3 -5
  28. package/dist/artifacts/gcsArtifacts.js.map +1 -1
  29. package/dist/artifacts/inMemoryArtifacts.js +2 -2
  30. package/dist/artifacts/inMemoryArtifacts.js.map +1 -1
  31. package/dist/artifacts/minting.js +49 -29
  32. package/dist/artifacts/minting.js.map +1 -1
  33. package/dist/artifacts/naming.js +12 -2
  34. package/dist/artifacts/naming.js.map +1 -1
  35. package/dist/artifacts/payload.js +27 -13
  36. package/dist/artifacts/payload.js.map +1 -1
  37. package/dist/artifacts/s3Artifacts.js +3 -5
  38. package/dist/artifacts/s3Artifacts.js.map +1 -1
  39. package/dist/artifacts/sqliteArtifacts.js +13 -8
  40. package/dist/artifacts/sqliteArtifacts.js.map +1 -1
  41. package/dist/artifacts/types.js.map +1 -1
  42. package/dist/core/agent/assessment/assess.js +7 -57
  43. package/dist/core/agent/assessment/assess.js.map +1 -1
  44. package/dist/core/agent/assessment/compose.js +44 -41
  45. package/dist/core/agent/assessment/compose.js.map +1 -1
  46. package/dist/core/agent/assessment/conflicts.js +76 -0
  47. package/dist/core/agent/assessment/conflicts.js.map +1 -0
  48. package/dist/core/agent/assessment/entryEvidence.js +1 -1
  49. package/dist/core/agent/assessment/entryEvidence.js.map +1 -1
  50. package/dist/core/agent/assessment/gathered.js +2 -1
  51. package/dist/core/agent/assessment/gathered.js.map +1 -1
  52. package/dist/core/agent/assessment/reasonClasses.js +3 -0
  53. package/dist/core/agent/assessment/reasonClasses.js.map +1 -1
  54. package/dist/core/agent/assessment/reasons.js +23 -2
  55. package/dist/core/agent/assessment/reasons.js.map +1 -1
  56. package/dist/core/agent/assessment/results/library-did/stage.js +88 -0
  57. package/dist/core/agent/assessment/results/library-did/stage.js.map +1 -0
  58. package/dist/core/agent/assessment/sources.js +2 -2
  59. package/dist/core/agent/assessment/stage.js +3 -1
  60. package/dist/core/agent/assessment/stage.js.map +1 -1
  61. package/dist/core/agent/assessment/standingAdmission.js +24 -0
  62. package/dist/core/agent/assessment/standingAdmission.js.map +1 -1
  63. package/dist/core/agent/assessment/standingFacts.js +52 -0
  64. package/dist/core/agent/assessment/standingFacts.js.map +1 -0
  65. package/dist/core/agent/buildDynamicAgentChart.js +4 -64
  66. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  67. package/dist/core/agent/dynamicTurnSeed.js +71 -0
  68. package/dist/core/agent/dynamicTurnSeed.js.map +1 -0
  69. package/dist/core/agent/honesty/answerFoldReads.js +3 -0
  70. package/dist/core/agent/honesty/answerFoldReads.js.map +1 -1
  71. package/dist/core/agent/honesty/libraryResultLimits.js +140 -0
  72. package/dist/core/agent/honesty/libraryResultLimits.js.map +1 -0
  73. package/dist/core/agent/honesty/settledToolCalls.js +5 -0
  74. package/dist/core/agent/honesty/settledToolCalls.js.map +1 -1
  75. package/dist/core/agent/llmCallReads.js +12 -4
  76. package/dist/core/agent/llmCallReads.js.map +1 -1
  77. package/dist/core/agent/recordedCalls/toolTurnCheckpoint.js +41 -4
  78. package/dist/core/agent/recordedCalls/toolTurnCheckpoint.js.map +1 -1
  79. package/dist/core/agent/requestTurn/checkpoint.js +187 -0
  80. package/dist/core/agent/requestTurn/checkpoint.js.map +1 -0
  81. package/dist/core/agent/requestTurn/native.js +30 -0
  82. package/dist/core/agent/requestTurn/native.js.map +1 -0
  83. package/dist/core/agent/requestTurn/replayPrefix.js +100 -0
  84. package/dist/core/agent/requestTurn/replayPrefix.js.map +1 -0
  85. package/dist/core/agent/requestTurn/state.js +76 -0
  86. package/dist/core/agent/requestTurn/state.js.map +1 -0
  87. package/dist/core/agent/resultRowsets/resumed.js.map +1 -1
  88. package/dist/core/agent/runtime/chart/chartDependencies.js +2 -0
  89. package/dist/core/agent/runtime/chart/chartDependencies.js.map +1 -1
  90. package/dist/core/agent/runtime/conversation/owner.js +1 -0
  91. package/dist/core/agent/runtime/conversation/owner.js.map +1 -1
  92. package/dist/core/agent/runtime/conversation/seedHistory.js +11 -2
  93. package/dist/core/agent/runtime/conversation/seedHistory.js.map +1 -1
  94. package/dist/core/agent/stages/callLLM/groundedText.js +7 -2
  95. package/dist/core/agent/stages/callLLM/groundedText.js.map +1 -1
  96. package/dist/core/agent/stages/callLLM/liveChunks.js +74 -0
  97. package/dist/core/agent/stages/callLLM/liveChunks.js.map +1 -0
  98. package/dist/core/agent/stages/callLLM/requestOnly.js +84 -0
  99. package/dist/core/agent/stages/callLLM/requestOnly.js.map +1 -0
  100. package/dist/core/agent/stages/callLLM/requestProjection.js +26 -0
  101. package/dist/core/agent/stages/callLLM/requestProjection.js.map +1 -0
  102. package/dist/core/agent/stages/callLLM.js +67 -118
  103. package/dist/core/agent/stages/callLLM.js.map +1 -1
  104. package/dist/core/agent/stages/seed.js +1 -2
  105. package/dist/core/agent/stages/seed.js.map +1 -1
  106. package/dist/core/agent/stages/toolCalls/decorators/limitsOperations.js +7 -8
  107. package/dist/core/agent/stages/toolCalls/decorators/limitsOperations.js.map +1 -1
  108. package/dist/core/agent/stages/toolCalls/execution/artifactsOperations.js +2 -0
  109. package/dist/core/agent/stages/toolCalls/execution/artifactsOperations.js.map +1 -1
  110. package/dist/core/agent/stages/toolCalls/execution/contextOperations.js +21 -6
  111. package/dist/core/agent/stages/toolCalls/execution/contextOperations.js.map +1 -1
  112. package/dist/core/agent/stages/toolCalls/execution/dispatchCall.js +7 -0
  113. package/dist/core/agent/stages/toolCalls/execution/dispatchCall.js.map +1 -1
  114. package/dist/core/agent/stages/toolCalls/execution/initialInvocation.js +3 -1
  115. package/dist/core/agent/stages/toolCalls/execution/initialInvocation.js.map +1 -1
  116. package/dist/core/agent/stages/toolCalls/execution/resumedInvocation.js +4 -4
  117. package/dist/core/agent/stages/toolCalls/execution/resumedInvocation.js.map +1 -1
  118. package/dist/core/agent/stages/toolCalls/resume/ask.js +4 -1
  119. package/dist/core/agent/stages/toolCalls/resume/ask.js.map +1 -1
  120. package/dist/core/agent/stages/toolCalls/resume/checkIn.js +4 -1
  121. package/dist/core/agent/stages/toolCalls/resume/checkIn.js.map +1 -1
  122. package/dist/core/agent/stages/toolCalls/resume/credential.js +8 -1
  123. package/dist/core/agent/stages/toolCalls/resume/credential.js.map +1 -1
  124. package/dist/core/agent/stages/toolCalls/resume/plain.js +2 -0
  125. package/dist/core/agent/stages/toolCalls/resume/plain.js.map +1 -1
  126. package/dist/core/agent/toolResultCap.js +0 -0
  127. package/dist/core/agent/toolResultCap.js.map +1 -1
  128. package/dist/core/checkpointFailurePhase.js +38 -0
  129. package/dist/core/checkpointFailurePhase.js.map +1 -0
  130. package/dist/core/runCheckpoint.js +10 -36
  131. package/dist/core/runCheckpoint.js.map +1 -1
  132. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +5 -0
  133. package/dist/esm/adapters/llm/AnthropicProvider.js +26 -0
  134. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  135. package/dist/esm/adapters/llm/OllamaProvider.js +13 -58
  136. package/dist/esm/adapters/llm/OllamaProvider.js.map +1 -1
  137. package/dist/esm/adapters/llm/anthropicThinkingReplay.js +2 -24
  138. package/dist/esm/adapters/llm/anthropicThinkingReplay.js.map +1 -1
  139. package/dist/esm/adapters/llm/anthropicToolArguments.d.ts +3 -1
  140. package/dist/esm/adapters/llm/anthropicToolArguments.js +9 -3
  141. package/dist/esm/adapters/llm/anthropicToolArguments.js.map +1 -1
  142. package/dist/esm/adapters/llm/ollamaErrors.d.ts +23 -0
  143. package/dist/esm/adapters/llm/ollamaErrors.js +55 -0
  144. package/dist/esm/adapters/llm/ollamaErrors.js.map +1 -0
  145. package/dist/esm/adapters/observability/assessmentReasonWords.js +3 -0
  146. package/dist/esm/adapters/observability/assessmentReasonWords.js.map +1 -1
  147. package/dist/esm/adapters/observability/auditShapes/events/decisions.js +1 -0
  148. package/dist/esm/adapters/observability/auditShapes/events/decisions.js.map +1 -1
  149. package/dist/esm/adapters/observability/auditShapes/events/streaming.js +1 -0
  150. package/dist/esm/adapters/observability/auditShapes/events/streaming.js.map +1 -1
  151. package/dist/esm/answer-account/account.js +13 -13
  152. package/dist/esm/answer-account/account.js.map +1 -1
  153. package/dist/esm/answer-account/facts/standing.js +31 -5
  154. package/dist/esm/answer-account/facts/standing.js.map +1 -1
  155. package/dist/esm/answer-account/howSureReasonTemplates.d.ts +5 -0
  156. package/dist/esm/answer-account/howSureReasonTemplates.js +5 -0
  157. package/dist/esm/answer-account/howSureReasonTemplates.js.map +1 -1
  158. package/dist/esm/answer-account/templates.d.ts +6 -1
  159. package/dist/esm/answer-account/templates.js +1 -1
  160. package/dist/esm/artifacts/fileArtifacts.js +3 -3
  161. package/dist/esm/artifacts/fileArtifacts.js.map +1 -1
  162. package/dist/esm/artifacts/gcsArtifacts.js +4 -6
  163. package/dist/esm/artifacts/gcsArtifacts.js.map +1 -1
  164. package/dist/esm/artifacts/inMemoryArtifacts.js +3 -3
  165. package/dist/esm/artifacts/inMemoryArtifacts.js.map +1 -1
  166. package/dist/esm/artifacts/minting.d.ts +2 -1
  167. package/dist/esm/artifacts/minting.js +50 -30
  168. package/dist/esm/artifacts/minting.js.map +1 -1
  169. package/dist/esm/artifacts/naming.d.ts +2 -0
  170. package/dist/esm/artifacts/naming.js +10 -1
  171. package/dist/esm/artifacts/naming.js.map +1 -1
  172. package/dist/esm/artifacts/payload.d.ts +13 -0
  173. package/dist/esm/artifacts/payload.js +21 -10
  174. package/dist/esm/artifacts/payload.js.map +1 -1
  175. package/dist/esm/artifacts/s3Artifacts.js +4 -6
  176. package/dist/esm/artifacts/s3Artifacts.js.map +1 -1
  177. package/dist/esm/artifacts/sqliteArtifacts.js +14 -9
  178. package/dist/esm/artifacts/sqliteArtifacts.js.map +1 -1
  179. package/dist/esm/artifacts/types.d.ts +2 -0
  180. package/dist/esm/artifacts/types.js.map +1 -1
  181. package/dist/esm/core/agent/assessment/assess.d.ts +2 -4
  182. package/dist/esm/core/agent/assessment/assess.js +7 -57
  183. package/dist/esm/core/agent/assessment/assess.js.map +1 -1
  184. package/dist/esm/core/agent/assessment/compose.d.ts +10 -21
  185. package/dist/esm/core/agent/assessment/compose.js +40 -38
  186. package/dist/esm/core/agent/assessment/compose.js.map +1 -1
  187. package/dist/esm/core/agent/assessment/conflicts.d.ts +14 -0
  188. package/dist/esm/core/agent/assessment/conflicts.js +71 -0
  189. package/dist/esm/core/agent/assessment/conflicts.js.map +1 -0
  190. package/dist/esm/core/agent/assessment/entryEvidence.js +1 -1
  191. package/dist/esm/core/agent/assessment/entryEvidence.js.map +1 -1
  192. package/dist/esm/core/agent/assessment/gathered.d.ts +1 -1
  193. package/dist/esm/core/agent/assessment/gathered.js +2 -1
  194. package/dist/esm/core/agent/assessment/gathered.js.map +1 -1
  195. package/dist/esm/core/agent/assessment/reasonClasses.js +3 -0
  196. package/dist/esm/core/agent/assessment/reasonClasses.js.map +1 -1
  197. package/dist/esm/core/agent/assessment/reasons.js +23 -2
  198. package/dist/esm/core/agent/assessment/reasons.js.map +1 -1
  199. package/dist/esm/core/agent/assessment/results/library-did/stage.d.ts +16 -0
  200. package/dist/esm/core/agent/assessment/results/library-did/stage.js +82 -0
  201. package/dist/esm/core/agent/assessment/results/library-did/stage.js.map +1 -0
  202. package/dist/esm/core/agent/assessment/sources.d.ts +2 -2
  203. package/dist/esm/core/agent/assessment/sources.js +2 -2
  204. package/dist/esm/core/agent/assessment/stage.js +3 -1
  205. package/dist/esm/core/agent/assessment/stage.js.map +1 -1
  206. package/dist/esm/core/agent/assessment/standingAdmission.d.ts +1 -0
  207. package/dist/esm/core/agent/assessment/standingAdmission.js +24 -0
  208. package/dist/esm/core/agent/assessment/standingAdmission.js.map +1 -1
  209. package/dist/esm/core/agent/assessment/standingFacts.d.ts +30 -0
  210. package/dist/esm/core/agent/assessment/standingFacts.js +46 -0
  211. package/dist/esm/core/agent/assessment/standingFacts.js.map +1 -0
  212. package/dist/esm/core/agent/assessment/types.d.ts +5 -2
  213. package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -63
  214. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  215. package/dist/esm/core/agent/dynamicTurnSeed.d.ts +14 -0
  216. package/dist/esm/core/agent/dynamicTurnSeed.js +67 -0
  217. package/dist/esm/core/agent/dynamicTurnSeed.js.map +1 -0
  218. package/dist/esm/core/agent/honesty/answerFoldReads.d.ts +2 -1
  219. package/dist/esm/core/agent/honesty/answerFoldReads.js +3 -0
  220. package/dist/esm/core/agent/honesty/answerFoldReads.js.map +1 -1
  221. package/dist/esm/core/agent/honesty/libraryResultLimits.d.ts +44 -0
  222. package/dist/esm/core/agent/honesty/libraryResultLimits.js +131 -0
  223. package/dist/esm/core/agent/honesty/libraryResultLimits.js.map +1 -0
  224. package/dist/esm/core/agent/honesty/settledToolCalls.js +5 -0
  225. package/dist/esm/core/agent/honesty/settledToolCalls.js.map +1 -1
  226. package/dist/esm/core/agent/llmCallReads.d.ts +4 -2
  227. package/dist/esm/core/agent/llmCallReads.js +10 -2
  228. package/dist/esm/core/agent/llmCallReads.js.map +1 -1
  229. package/dist/esm/core/agent/recordedCalls/toolTurnCheckpoint.d.ts +3 -0
  230. package/dist/esm/core/agent/recordedCalls/toolTurnCheckpoint.js +41 -4
  231. package/dist/esm/core/agent/recordedCalls/toolTurnCheckpoint.js.map +1 -1
  232. package/dist/esm/core/agent/requestTurn/checkpoint.d.ts +6 -0
  233. package/dist/esm/core/agent/requestTurn/checkpoint.js +182 -0
  234. package/dist/esm/core/agent/requestTurn/checkpoint.js.map +1 -0
  235. package/dist/esm/core/agent/requestTurn/native.d.ts +4 -0
  236. package/dist/esm/core/agent/requestTurn/native.js +26 -0
  237. package/dist/esm/core/agent/requestTurn/native.js.map +1 -0
  238. package/dist/esm/core/agent/requestTurn/replayPrefix.d.ts +40 -0
  239. package/dist/esm/core/agent/requestTurn/replayPrefix.js +94 -0
  240. package/dist/esm/core/agent/requestTurn/replayPrefix.js.map +1 -0
  241. package/dist/esm/core/agent/requestTurn/state.d.ts +23 -0
  242. package/dist/esm/core/agent/requestTurn/state.js +68 -0
  243. package/dist/esm/core/agent/requestTurn/state.js.map +1 -0
  244. package/dist/esm/core/agent/resultRowsets/resumed.d.ts +4 -13
  245. package/dist/esm/core/agent/resultRowsets/resumed.js.map +1 -1
  246. package/dist/esm/core/agent/runtime/chart/chartDependencies.js +2 -0
  247. package/dist/esm/core/agent/runtime/chart/chartDependencies.js.map +1 -1
  248. package/dist/esm/core/agent/runtime/conversation/owner.js +1 -0
  249. package/dist/esm/core/agent/runtime/conversation/owner.js.map +1 -1
  250. package/dist/esm/core/agent/runtime/conversation/seedHistory.d.ts +4 -19
  251. package/dist/esm/core/agent/runtime/conversation/seedHistory.js +10 -1
  252. package/dist/esm/core/agent/runtime/conversation/seedHistory.js.map +1 -1
  253. package/dist/esm/core/agent/stages/callLLM/groundedText.d.ts +1 -1
  254. package/dist/esm/core/agent/stages/callLLM/groundedText.js +7 -2
  255. package/dist/esm/core/agent/stages/callLLM/groundedText.js.map +1 -1
  256. package/dist/esm/core/agent/stages/callLLM/liveChunks.d.ts +16 -0
  257. package/dist/esm/core/agent/stages/callLLM/liveChunks.js +70 -0
  258. package/dist/esm/core/agent/stages/callLLM/liveChunks.js.map +1 -0
  259. package/dist/esm/core/agent/stages/callLLM/requestOnly.d.ts +23 -0
  260. package/dist/esm/core/agent/stages/callLLM/requestOnly.js +78 -0
  261. package/dist/esm/core/agent/stages/callLLM/requestOnly.js.map +1 -0
  262. package/dist/esm/core/agent/stages/callLLM/requestProjection.d.ts +10 -0
  263. package/dist/esm/core/agent/stages/callLLM/requestProjection.js +22 -0
  264. package/dist/esm/core/agent/stages/callLLM/requestProjection.js.map +1 -0
  265. package/dist/esm/core/agent/stages/callLLM.js +68 -119
  266. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  267. package/dist/esm/core/agent/stages/seed.js +2 -3
  268. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  269. package/dist/esm/core/agent/stages/toolCalls/compose.d.ts +2 -5
  270. package/dist/esm/core/agent/stages/toolCalls/contracts/callCells.d.ts +2 -1
  271. package/dist/esm/core/agent/stages/toolCalls/contracts/callFacts.d.ts +2 -1
  272. package/dist/esm/core/agent/stages/toolCalls/contracts/operations/context.d.ts +2 -1
  273. package/dist/esm/core/agent/stages/toolCalls/contracts/operations/limits.d.ts +8 -4
  274. package/dist/esm/core/agent/stages/toolCalls/decorators/limitsOperations.js +7 -8
  275. package/dist/esm/core/agent/stages/toolCalls/decorators/limitsOperations.js.map +1 -1
  276. package/dist/esm/core/agent/stages/toolCalls/execution/artifactsOperations.js +2 -0
  277. package/dist/esm/core/agent/stages/toolCalls/execution/artifactsOperations.js.map +1 -1
  278. package/dist/esm/core/agent/stages/toolCalls/execution/contextOperations.js +21 -6
  279. package/dist/esm/core/agent/stages/toolCalls/execution/contextOperations.js.map +1 -1
  280. package/dist/esm/core/agent/stages/toolCalls/execution/dispatchCall.js +7 -0
  281. package/dist/esm/core/agent/stages/toolCalls/execution/dispatchCall.js.map +1 -1
  282. package/dist/esm/core/agent/stages/toolCalls/execution/finalizeCallResult.d.ts +1 -4
  283. package/dist/esm/core/agent/stages/toolCalls/execution/initialInvocation.js +3 -1
  284. package/dist/esm/core/agent/stages/toolCalls/execution/initialInvocation.js.map +1 -1
  285. package/dist/esm/core/agent/stages/toolCalls/execution/resumedInvocation.js +4 -4
  286. package/dist/esm/core/agent/stages/toolCalls/execution/resumedInvocation.js.map +1 -1
  287. package/dist/esm/core/agent/stages/toolCalls/resume/ask.js +4 -1
  288. package/dist/esm/core/agent/stages/toolCalls/resume/ask.js.map +1 -1
  289. package/dist/esm/core/agent/stages/toolCalls/resume/checkIn.js +4 -1
  290. package/dist/esm/core/agent/stages/toolCalls/resume/checkIn.js.map +1 -1
  291. package/dist/esm/core/agent/stages/toolCalls/resume/credential.js +8 -1
  292. package/dist/esm/core/agent/stages/toolCalls/resume/credential.js.map +1 -1
  293. package/dist/esm/core/agent/stages/toolCalls/resume/plain.js +2 -0
  294. package/dist/esm/core/agent/stages/toolCalls/resume/plain.js.map +1 -1
  295. package/dist/esm/core/agent/toolResultCap.d.ts +7 -0
  296. package/dist/esm/core/agent/toolResultCap.js +0 -0
  297. package/dist/esm/core/agent/toolResultCap.js.map +1 -1
  298. package/dist/esm/core/agent/types/state/honesty.d.ts +4 -0
  299. package/dist/esm/core/checkpointFailurePhase.d.ts +15 -0
  300. package/dist/esm/core/checkpointFailurePhase.js +34 -0
  301. package/dist/esm/core/checkpointFailurePhase.js.map +1 -0
  302. package/dist/esm/core/runCheckpoint.d.ts +1 -15
  303. package/dist/esm/core/runCheckpoint.js +8 -34
  304. package/dist/esm/core/runCheckpoint.js.map +1 -1
  305. package/dist/esm/core/runCheckpointTypes.d.ts +3 -0
  306. package/dist/esm/events/payloads/artifacts.d.ts +2 -0
  307. package/dist/esm/events/payloads/dependencyTypes.d.ts +1 -1
  308. package/dist/esm/events/payloads/thinking.d.ts +8 -21
  309. package/dist/esm/hosting/standingAgent/artifacts/facts.js +1 -0
  310. package/dist/esm/hosting/standingAgent/artifacts/facts.js.map +1 -1
  311. package/dist/esm/lib/saidByPerson.d.ts +2 -0
  312. package/dist/esm/lib/saidByPerson.js +3 -0
  313. package/dist/esm/lib/saidByPerson.js.map +1 -1
  314. package/dist/esm/provider-contract/types.d.ts +7 -15
  315. package/dist/esm/provider-contract/types.js.map +1 -1
  316. package/dist/esm/redaction/conversation.js +13 -1
  317. package/dist/esm/redaction/conversation.js.map +1 -1
  318. package/dist/esm/redaction/knownStrings/fields-1.d.ts +1 -1
  319. package/dist/esm/redaction/knownStrings/fields-1.js +1 -1
  320. package/dist/esm/redaction/knownStrings/fields-1.js.map +1 -1
  321. package/dist/esm/redaction/knownStrings/fields-2.d.ts +1 -0
  322. package/dist/esm/redaction/knownStrings/fields-2.js +1 -0
  323. package/dist/esm/redaction/knownStrings/fields-2.js.map +1 -1
  324. package/dist/esm/redaction/knownStrings/words-1.d.ts +4 -4
  325. package/dist/esm/redaction/knownStrings/words-1.js +4 -4
  326. package/dist/esm/redaction/knownStrings/words-1.js.map +1 -1
  327. package/dist/esm/redaction/knownStrings/words-2.d.ts +6 -0
  328. package/dist/esm/redaction/knownStrings/words-2.js +6 -0
  329. package/dist/esm/redaction/knownStrings/words-2.js.map +1 -1
  330. package/dist/esm/thinking/anthropicTurn.d.ts +12 -0
  331. package/dist/esm/thinking/anthropicTurn.js +24 -0
  332. package/dist/esm/thinking/anthropicTurn.js.map +1 -0
  333. package/dist/esm/thinking/types.d.ts +7 -9
  334. package/dist/esm/time-travel/servedView/gaps.d.ts +1 -1
  335. package/dist/esm/time-travel/servedView/gaps.js +28 -2
  336. package/dist/esm/time-travel/servedView/gaps.js.map +1 -1
  337. package/dist/hosting/standingAgent/artifacts/facts.js +1 -0
  338. package/dist/hosting/standingAgent/artifacts/facts.js.map +1 -1
  339. package/dist/lib/saidByPerson.js +4 -1
  340. package/dist/lib/saidByPerson.js.map +1 -1
  341. package/dist/provider-contract/types.js.map +1 -1
  342. package/dist/redaction/conversation.js +13 -1
  343. package/dist/redaction/conversation.js.map +1 -1
  344. package/dist/redaction/knownStrings/fields-1.js +1 -1
  345. package/dist/redaction/knownStrings/fields-1.js.map +1 -1
  346. package/dist/redaction/knownStrings/fields-2.js +1 -0
  347. package/dist/redaction/knownStrings/fields-2.js.map +1 -1
  348. package/dist/redaction/knownStrings/words-1.js +4 -4
  349. package/dist/redaction/knownStrings/words-1.js.map +1 -1
  350. package/dist/redaction/knownStrings/words-2.js +6 -0
  351. package/dist/redaction/knownStrings/words-2.js.map +1 -1
  352. package/dist/thinking/anthropicTurn.js +28 -0
  353. package/dist/thinking/anthropicTurn.js.map +1 -0
  354. package/dist/time-travel/servedView/gaps.js +28 -2
  355. package/dist/time-travel/servedView/gaps.js.map +1 -1
  356. package/dist/types/adapters/llm/AnthropicProvider.d.ts +5 -0
  357. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  358. package/dist/types/adapters/llm/OllamaProvider.d.ts.map +1 -1
  359. package/dist/types/adapters/llm/anthropicThinkingReplay.d.ts.map +1 -1
  360. package/dist/types/adapters/llm/anthropicToolArguments.d.ts +3 -1
  361. package/dist/types/adapters/llm/anthropicToolArguments.d.ts.map +1 -1
  362. package/dist/types/adapters/llm/ollamaErrors.d.ts +24 -0
  363. package/dist/types/adapters/llm/ollamaErrors.d.ts.map +1 -0
  364. package/dist/types/adapters/observability/assessmentReasonWords.d.ts.map +1 -1
  365. package/dist/types/adapters/observability/auditShapes/events/decisions.d.ts.map +1 -1
  366. package/dist/types/adapters/observability/auditShapes/events/streaming.d.ts.map +1 -1
  367. package/dist/types/answer-account/facts/standing.d.ts.map +1 -1
  368. package/dist/types/answer-account/howSureReasonTemplates.d.ts +5 -0
  369. package/dist/types/answer-account/howSureReasonTemplates.d.ts.map +1 -1
  370. package/dist/types/answer-account/templates.d.ts +6 -1
  371. package/dist/types/answer-account/templates.d.ts.map +1 -1
  372. package/dist/types/artifacts/gcsArtifacts.d.ts.map +1 -1
  373. package/dist/types/artifacts/minting.d.ts +2 -1
  374. package/dist/types/artifacts/minting.d.ts.map +1 -1
  375. package/dist/types/artifacts/naming.d.ts +2 -0
  376. package/dist/types/artifacts/naming.d.ts.map +1 -1
  377. package/dist/types/artifacts/payload.d.ts +13 -0
  378. package/dist/types/artifacts/payload.d.ts.map +1 -1
  379. package/dist/types/artifacts/s3Artifacts.d.ts.map +1 -1
  380. package/dist/types/artifacts/sqliteArtifacts.d.ts.map +1 -1
  381. package/dist/types/artifacts/types.d.ts +2 -0
  382. package/dist/types/artifacts/types.d.ts.map +1 -1
  383. package/dist/types/core/agent/assessment/assess.d.ts +2 -4
  384. package/dist/types/core/agent/assessment/assess.d.ts.map +1 -1
  385. package/dist/types/core/agent/assessment/compose.d.ts +10 -21
  386. package/dist/types/core/agent/assessment/compose.d.ts.map +1 -1
  387. package/dist/types/core/agent/assessment/conflicts.d.ts +15 -0
  388. package/dist/types/core/agent/assessment/conflicts.d.ts.map +1 -0
  389. package/dist/types/core/agent/assessment/gathered.d.ts +1 -1
  390. package/dist/types/core/agent/assessment/gathered.d.ts.map +1 -1
  391. package/dist/types/core/agent/assessment/reasonClasses.d.ts.map +1 -1
  392. package/dist/types/core/agent/assessment/reasons.d.ts.map +1 -1
  393. package/dist/types/core/agent/assessment/results/library-did/stage.d.ts +17 -0
  394. package/dist/types/core/agent/assessment/results/library-did/stage.d.ts.map +1 -0
  395. package/dist/types/core/agent/assessment/sources.d.ts +2 -2
  396. package/dist/types/core/agent/assessment/stage.d.ts.map +1 -1
  397. package/dist/types/core/agent/assessment/standingAdmission.d.ts +1 -0
  398. package/dist/types/core/agent/assessment/standingAdmission.d.ts.map +1 -1
  399. package/dist/types/core/agent/assessment/standingFacts.d.ts +31 -0
  400. package/dist/types/core/agent/assessment/standingFacts.d.ts.map +1 -0
  401. package/dist/types/core/agent/assessment/types.d.ts +5 -2
  402. package/dist/types/core/agent/assessment/types.d.ts.map +1 -1
  403. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  404. package/dist/types/core/agent/dynamicTurnSeed.d.ts +15 -0
  405. package/dist/types/core/agent/dynamicTurnSeed.d.ts.map +1 -0
  406. package/dist/types/core/agent/honesty/answerFoldReads.d.ts +2 -1
  407. package/dist/types/core/agent/honesty/answerFoldReads.d.ts.map +1 -1
  408. package/dist/types/core/agent/honesty/libraryResultLimits.d.ts +45 -0
  409. package/dist/types/core/agent/honesty/libraryResultLimits.d.ts.map +1 -0
  410. package/dist/types/core/agent/honesty/settledToolCalls.d.ts.map +1 -1
  411. package/dist/types/core/agent/llmCallReads.d.ts +4 -2
  412. package/dist/types/core/agent/llmCallReads.d.ts.map +1 -1
  413. package/dist/types/core/agent/recordedCalls/toolTurnCheckpoint.d.ts +3 -0
  414. package/dist/types/core/agent/recordedCalls/toolTurnCheckpoint.d.ts.map +1 -1
  415. package/dist/types/core/agent/requestTurn/checkpoint.d.ts +7 -0
  416. package/dist/types/core/agent/requestTurn/checkpoint.d.ts.map +1 -0
  417. package/dist/types/core/agent/requestTurn/native.d.ts +5 -0
  418. package/dist/types/core/agent/requestTurn/native.d.ts.map +1 -0
  419. package/dist/types/core/agent/requestTurn/replayPrefix.d.ts +41 -0
  420. package/dist/types/core/agent/requestTurn/replayPrefix.d.ts.map +1 -0
  421. package/dist/types/core/agent/requestTurn/state.d.ts +24 -0
  422. package/dist/types/core/agent/requestTurn/state.d.ts.map +1 -0
  423. package/dist/types/core/agent/resultRowsets/resumed.d.ts +4 -13
  424. package/dist/types/core/agent/resultRowsets/resumed.d.ts.map +1 -1
  425. package/dist/types/core/agent/runtime/chart/chartDependencies.d.ts.map +1 -1
  426. package/dist/types/core/agent/runtime/conversation/owner.d.ts.map +1 -1
  427. package/dist/types/core/agent/runtime/conversation/seedHistory.d.ts +4 -19
  428. package/dist/types/core/agent/runtime/conversation/seedHistory.d.ts.map +1 -1
  429. package/dist/types/core/agent/stages/callLLM/groundedText.d.ts +1 -1
  430. package/dist/types/core/agent/stages/callLLM/groundedText.d.ts.map +1 -1
  431. package/dist/types/core/agent/stages/callLLM/liveChunks.d.ts +17 -0
  432. package/dist/types/core/agent/stages/callLLM/liveChunks.d.ts.map +1 -0
  433. package/dist/types/core/agent/stages/callLLM/requestOnly.d.ts +24 -0
  434. package/dist/types/core/agent/stages/callLLM/requestOnly.d.ts.map +1 -0
  435. package/dist/types/core/agent/stages/callLLM/requestProjection.d.ts +11 -0
  436. package/dist/types/core/agent/stages/callLLM/requestProjection.d.ts.map +1 -0
  437. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  438. package/dist/types/core/agent/stages/toolCalls/compose.d.ts +2 -5
  439. package/dist/types/core/agent/stages/toolCalls/compose.d.ts.map +1 -1
  440. package/dist/types/core/agent/stages/toolCalls/contracts/callCells.d.ts +2 -1
  441. package/dist/types/core/agent/stages/toolCalls/contracts/callCells.d.ts.map +1 -1
  442. package/dist/types/core/agent/stages/toolCalls/contracts/callFacts.d.ts +2 -1
  443. package/dist/types/core/agent/stages/toolCalls/contracts/callFacts.d.ts.map +1 -1
  444. package/dist/types/core/agent/stages/toolCalls/contracts/operations/context.d.ts +2 -1
  445. package/dist/types/core/agent/stages/toolCalls/contracts/operations/context.d.ts.map +1 -1
  446. package/dist/types/core/agent/stages/toolCalls/contracts/operations/limits.d.ts +8 -4
  447. package/dist/types/core/agent/stages/toolCalls/contracts/operations/limits.d.ts.map +1 -1
  448. package/dist/types/core/agent/stages/toolCalls/decorators/limitsOperations.d.ts.map +1 -1
  449. package/dist/types/core/agent/stages/toolCalls/execution/artifactsOperations.d.ts.map +1 -1
  450. package/dist/types/core/agent/stages/toolCalls/execution/contextOperations.d.ts.map +1 -1
  451. package/dist/types/core/agent/stages/toolCalls/execution/dispatchCall.d.ts.map +1 -1
  452. package/dist/types/core/agent/stages/toolCalls/execution/finalizeCallResult.d.ts +1 -4
  453. package/dist/types/core/agent/stages/toolCalls/execution/finalizeCallResult.d.ts.map +1 -1
  454. package/dist/types/core/agent/stages/toolCalls/execution/initialInvocation.d.ts.map +1 -1
  455. package/dist/types/core/agent/stages/toolCalls/execution/resumedInvocation.d.ts.map +1 -1
  456. package/dist/types/core/agent/stages/toolCalls/resume/ask.d.ts.map +1 -1
  457. package/dist/types/core/agent/stages/toolCalls/resume/checkIn.d.ts.map +1 -1
  458. package/dist/types/core/agent/stages/toolCalls/resume/credential.d.ts.map +1 -1
  459. package/dist/types/core/agent/stages/toolCalls/resume/plain.d.ts.map +1 -1
  460. package/dist/types/core/agent/toolResultCap.d.ts +7 -0
  461. package/dist/types/core/agent/toolResultCap.d.ts.map +1 -1
  462. package/dist/types/core/agent/types/state/honesty.d.ts +4 -0
  463. package/dist/types/core/agent/types/state/honesty.d.ts.map +1 -1
  464. package/dist/types/core/checkpointFailurePhase.d.ts +16 -0
  465. package/dist/types/core/checkpointFailurePhase.d.ts.map +1 -0
  466. package/dist/types/core/runCheckpoint.d.ts +1 -15
  467. package/dist/types/core/runCheckpoint.d.ts.map +1 -1
  468. package/dist/types/core/runCheckpointTypes.d.ts +3 -0
  469. package/dist/types/core/runCheckpointTypes.d.ts.map +1 -1
  470. package/dist/types/events/payloads/artifacts.d.ts +2 -0
  471. package/dist/types/events/payloads/artifacts.d.ts.map +1 -1
  472. package/dist/types/events/payloads/dependencyTypes.d.ts +1 -1
  473. package/dist/types/events/payloads/dependencyTypes.d.ts.map +1 -1
  474. package/dist/types/events/payloads/thinking.d.ts +8 -21
  475. package/dist/types/events/payloads/thinking.d.ts.map +1 -1
  476. package/dist/types/hosting/standingAgent/artifacts/facts.d.ts.map +1 -1
  477. package/dist/types/lib/saidByPerson.d.ts +2 -0
  478. package/dist/types/lib/saidByPerson.d.ts.map +1 -1
  479. package/dist/types/provider-contract/types.d.ts +7 -15
  480. package/dist/types/provider-contract/types.d.ts.map +1 -1
  481. package/dist/types/redaction/conversation.d.ts.map +1 -1
  482. package/dist/types/redaction/knownStrings/fields-1.d.ts +1 -1
  483. package/dist/types/redaction/knownStrings/fields-2.d.ts +1 -0
  484. package/dist/types/redaction/knownStrings/fields-2.d.ts.map +1 -1
  485. package/dist/types/redaction/knownStrings/words-1.d.ts +4 -4
  486. package/dist/types/redaction/knownStrings/words-2.d.ts +6 -0
  487. package/dist/types/redaction/knownStrings/words-2.d.ts.map +1 -1
  488. package/dist/types/thinking/anthropicTurn.d.ts +13 -0
  489. package/dist/types/thinking/anthropicTurn.d.ts.map +1 -0
  490. package/dist/types/thinking/types.d.ts +7 -9
  491. package/dist/types/thinking/types.d.ts.map +1 -1
  492. package/dist/types/time-travel/servedView/gaps.d.ts +1 -1
  493. package/dist/types/time-travel/servedView/gaps.d.ts.map +1 -1
  494. package/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ import { throwIfAborted } from '../../../../lib/abort.js';
2
+ import { typedEmit } from '../../../../recorders/core/typedEmit.js';
3
+ /** One attempt's live output, subject to the call stage's cancellation signal. */
4
+ export function liveChunkEmitter(scope, signal, options) {
5
+ const { providerName, iteration, suppressDraftTokens, textFilter, onFirstChunk } = options;
6
+ let firstChunkFired = false;
7
+ let lastTokenIndex = -1;
8
+ return {
9
+ push(chunk) {
10
+ // A provider is a port anyone can implement, and a non-terminal
11
+ // chunk that carries no `content` used to die when checking its length,
12
+ // naming neither the provider nor the contract it missed. A provider
13
+ // that uses its own terminal marker instead of `done: true` hits this
14
+ // path, so the refusal names the terminal contract as well.
15
+ const visible = chunk.content;
16
+ if (typeof visible !== 'string') {
17
+ throw new TypeError(`provider '${providerName}' yielded a stream chunk whose \`content\` is ` +
18
+ `${visible === undefined ? 'missing' : `a ${typeof visible}`}. ` +
19
+ `Every chunk from LLMProvider.stream() is ` +
20
+ `{ tokenIndex: number, content: string, done: boolean }, and the LAST one is ` +
21
+ `{ content: '', done: true, response } — the response payload rides the ` +
22
+ `terminal chunk. A chunk that ends the stream any other way is not seen as ` +
23
+ `terminal, and its missing content stops the run here.`);
24
+ }
25
+ const tokenIndex = chunk.tokenIndex;
26
+ const thinking = suppressDraftTokens ? undefined : chunk.thinkingDelta;
27
+ const hasThinking = typeof thinking === 'string' && thinking.length > 0;
28
+ const hasText = visible.length > 0;
29
+ const kind = hasThinking ? chunk.thinkingKind : undefined;
30
+ throwIfAborted(signal);
31
+ if (!firstChunkFired && (hasThinking || hasText)) {
32
+ firstChunkFired = true;
33
+ onFirstChunk?.();
34
+ }
35
+ if (hasThinking) {
36
+ lastTokenIndex = tokenIndex;
37
+ typedEmit(scope, 'agentfootprint.stream.thinking_delta', {
38
+ iteration,
39
+ tokenIndex,
40
+ kind: kind === 'provider-summary' || kind === 'raw-reasoning' ? kind : 'unclassified',
41
+ content: thinking,
42
+ });
43
+ // An inline listener can cancel the run during delivery of this fragment.
44
+ throwIfAborted(signal);
45
+ }
46
+ if (hasText && !suppressDraftTokens) {
47
+ const content = textFilter === undefined ? visible : textFilter.push(visible);
48
+ lastTokenIndex = tokenIndex;
49
+ if (content.length > 0) {
50
+ typedEmit(scope, 'agentfootprint.stream.token', { iteration, tokenIndex, content });
51
+ }
52
+ }
53
+ },
54
+ finish() {
55
+ throwIfAborted(signal);
56
+ // The scanner can hold a trailing newline or partial key through EOF.
57
+ const content = textFilter?.end() ?? '';
58
+ if (content.length > 0) {
59
+ typedEmit(scope, 'agentfootprint.stream.token', {
60
+ iteration,
61
+ tokenIndex: lastTokenIndex + 1,
62
+ content,
63
+ });
64
+ // An abort here also prevents fallback completion on older streams.
65
+ throwIfAborted(signal);
66
+ }
67
+ },
68
+ };
69
+ }
70
+ //# sourceMappingURL=liveChunks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveChunks.js","sourceRoot":"","sources":["../../../../../../src/core/agent/stages/callLLM/liveChunks.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,23 @@
1
+ import type { TypedScope } from 'footprintjs';
2
+ import type { LLMMessage, LLMToolSchema } from '../../../../provider-contract/types.js';
3
+ import type { ToolsWithheld } from '../../composeRequest.js';
4
+ import type { FindingsLedger } from '../../findings/types.js';
5
+ import type { RequestOnlyMessage } from '../../requestTurn/replayPrefix.js';
6
+ import type { AgentState } from '../../types.js';
7
+ import type { CallLLMStageDeps } from './types.js';
8
+ interface RequestOnlyContext {
9
+ readonly iteration: number;
10
+ readonly committed: readonly LLMMessage[];
11
+ readonly messages: readonly LLMMessage[];
12
+ readonly ledger: FindingsLedger | undefined;
13
+ readonly registeredToolSchemas: readonly LLMToolSchema[];
14
+ readonly withheld: ToolsWithheld | null;
15
+ }
16
+ /** A pending turn cannot absorb a temporary change to its signed system prompt. */
17
+ export declare function recoveryFeedback(instruction: string): RequestOnlyMessage;
18
+ export declare function isRecoveryFeedback(message: LLMMessage): boolean;
19
+ /** Lines composed for THIS request and written to no history — each with
20
+ * the mechanism that composed it, so the receipt can say a line existed
21
+ * without saying what it said. */
22
+ export declare function requestOnlyMessages(scope: TypedScope<AgentState>, deps: CallLLMStageDeps, { iteration, committed, messages, ledger, registeredToolSchemas, withheld }: RequestOnlyContext): readonly RequestOnlyMessage[];
23
+ export {};
@@ -0,0 +1,78 @@
1
+ import { NATIVE_RECOVERY_FRAME_PREFIX } from '../../../../lib/saidByPerson.js';
2
+ import { evidenceConclusionLine } from '../../evidence/recovery.js';
3
+ import { FINDINGS_LAYOUT, findingsContext, findingsContextBytes } from '../../findings/context.js';
4
+ import { stagedRefsNudgeFor } from '../stagedRefsNudge.js';
5
+ const INTERNAL_RETRY = `${NATIVE_RECOVERY_FRAME_PREFIX} This is framework guidance, not a message from the person or evidence.]`;
6
+ /** A pending turn cannot absorb a temporary change to its signed system prompt. */
7
+ export function recoveryFeedback(instruction) {
8
+ return {
9
+ reason: 'native-turn-recovery',
10
+ message: {
11
+ role: 'user',
12
+ content: `${INTERNAL_RETRY}\n${instruction.replace('this is a system instruction, not a new user message', 'this feedback is not a new user message')}`,
13
+ },
14
+ };
15
+ }
16
+ export function isRecoveryFeedback(message) {
17
+ return message.role === 'user' && message.content.startsWith(INTERNAL_RETRY);
18
+ }
19
+ /** Lines composed for THIS request and written to no history — each with
20
+ * the mechanism that composed it, so the receipt can say a line existed
21
+ * without saying what it said. */
22
+ export function requestOnlyMessages(scope, deps, { iteration, committed, messages, ledger, registeredToolSchemas, withheld }) {
23
+ const requestOnly = [];
24
+ // THE STAGED-REFS NUDGE (`nudge: true` on the evidence gate). Judged on
25
+ // `registeredToolSchemas` — the tools REALLY served this call, so the
26
+ // wrap-up's withheld surface arms nothing and a synthetic schema tool is
27
+ // never named a spender. The line is request-only: `scope.history` is
28
+ // untouched, so it never enters the exempt corpus and never persists —
29
+ // recomposed each iteration, present exactly while both conditions hold.
30
+ const nudge = deps.toolWants === undefined
31
+ ? undefined
32
+ : stagedRefsNudgeFor(scope, messages, deps.toolWants, registeredToolSchemas, iteration);
33
+ if (nudge !== undefined) {
34
+ requestOnly.push({ message: nudge, reason: 'staged-refs-nudge' });
35
+ }
36
+ // THE TIME LINE (step T6b, `.time({ reader })` only) — the library's conclusion about the
37
+ // person's time words, LAST, at the decision point: a settled window with its source and each
38
+ // tool's values, or a quote not confirmed yet and the one move that asks the person. Composed
39
+ // by the tools slot from the tools it served (`agent/arguments/serve/windows.ts` · `timeWindowsLine`)
40
+ // and served only on the iteration that composed it — a slot that did not re-run (classic
41
+ // mode) leaves an older line, which is never served. Request-only like the nudge above; not
42
+ // on the wrap-up call, whose tools are withheld. `servedView` rebuilds it from the same key.
43
+ const timeLine = deps.timeLine === true ? scope.timeLine : undefined;
44
+ if (timeLine !== undefined &&
45
+ timeLine.iteration === iteration &&
46
+ timeLine.text.length > 0 &&
47
+ // `wrapUpAsked` is read here as it always was (an unarmed agent's reads
48
+ // are unchanged); `withheld` adds the revision's rule.
49
+ scope.wrapUpAsked !== true &&
50
+ withheld === null) {
51
+ const line = { role: 'user', content: timeLine.text };
52
+ requestOnly.push({ message: line, reason: 'time-window-line' });
53
+ }
54
+ // THE EVIDENCE CONCLUSION (the figures dial) — the library's finding about
55
+ // the numbers it flagged, LAST, on the one call that serves the revision
56
+ // instruction (`evidence/figures.ts` · `figuresConclusionLine`). Absent
57
+ // whenever the dial is off or no flagged value was a number.
58
+ const conclusion = deps.hasEvidenceRecovery === true
59
+ ? evidenceConclusionLine(scope.evidenceRecovery, scope.evidenceRecoveryUsed, iteration)
60
+ : undefined;
61
+ if (conclusion !== undefined) {
62
+ const line = { role: 'user', content: conclusion };
63
+ requestOnly.push({ message: line, reason: 'evidence-conclusion' });
64
+ }
65
+ if (deps.hasFindingsLedger === true) {
66
+ // A resumed leg can have a different host configuration from its checkpoint.
67
+ // Record the layout actually used by THIS call; replay reads its commit.
68
+ scope.findingsLayout = FINDINGS_LAYOUT;
69
+ scope.findingsContextBytes = findingsContextBytes(deps.findingsContextBytes);
70
+ const line = {
71
+ role: 'user',
72
+ content: findingsContext(committed, ledger, deps.findingsContextBytes),
73
+ };
74
+ requestOnly.push({ message: line, reason: 'findings-data' });
75
+ }
76
+ return requestOnly;
77
+ }
78
+ //# sourceMappingURL=requestOnly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestOnly.js","sourceRoot":"","sources":["../../../../../../src/core/agent/stages/callLLM/requestOnly.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ import type { TypedScope } from 'footprintjs';
2
+ import type { LLMMessage } from '../../../../provider-contract/types.js';
3
+ import type { AgentState } from '../../types.js';
4
+ /** Decide which native prefix is still live as the stage assembles this call. */
5
+ export declare function projectCallHistory(scope: TypedScope<AgentState>, history: readonly LLMMessage[], rendered: readonly LLMMessage[], needsPrivateClosure: boolean): {
6
+ replayFrames: readonly import("../../requestTurn/replayPrefix.js").ReplayPrefixFrame[] | undefined;
7
+ closure: import("../../requestTurn/replayPrefix.js").RequestOnlyMessage | undefined;
8
+ continuing: import("../../requestTurn/replayPrefix.js").ReplayPrefixProjection | undefined;
9
+ messages: readonly LLMMessage[];
10
+ };
@@ -0,0 +1,22 @@
1
+ import { openReplayProjection, privateTurnEnd, readRequestReplay, } from '../../requestTurn/state.js';
2
+ /** Decide which native prefix is still live as the stage assembles this call. */
3
+ export function projectCallHistory(scope, history, rendered, needsPrivateClosure) {
4
+ const stored = 'requestReplay' in scope
5
+ ? scope.$getValue('requestReplay')
6
+ : undefined;
7
+ const replayState = stored === undefined ? undefined : readRequestReplay(stored);
8
+ const prefix = openReplayProjection(replayState, history, rendered);
9
+ const closure = needsPrivateClosure && prefix !== undefined && replayState?.closing !== undefined
10
+ ? privateTurnEnd(history, replayState.closing, scope.$getArgs()
11
+ ?.priorReplayThinking ??
12
+ scope.$getValue('thinkingBlocks'))
13
+ : undefined;
14
+ const continuing = closure === undefined ? prefix : undefined;
15
+ return {
16
+ replayFrames: replayState?.frames,
17
+ closure,
18
+ continuing,
19
+ messages: continuing?.history ?? rendered,
20
+ };
21
+ }
22
+ //# sourceMappingURL=requestProjection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestProjection.js","sourceRoot":"","sources":["../../../../../../src/core/agent/stages/callLLM/requestProjection.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AAGpC,iFAAiF;AACjF,MAAM,UAAU,kBAAkB,CAChC,KAA6B,EAC7B,OAA8B,EAC9B,QAA+B,EAC/B,mBAA4B;IAE5B,MAAM,MAAM,GACV,eAAe,IAAI,KAAK;QACtB,CAAC,CAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAoC;QACtE,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,WAAW,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpE,MAAM,OAAO,GACX,mBAAmB,IAAI,MAAM,KAAK,SAAS,IAAI,WAAW,EAAE,OAAO,KAAK,SAAS;QAC/E,CAAC,CAAC,cAAc,CACZ,OAAO,EACP,WAAW,CAAC,OAAO,EACnB,KAAK,CAAC,QAAQ,EAAsD;YAClE,EAAE,mBAAmB;YACpB,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAkC,CACtE;QACH,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,UAAU,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9D,OAAO;QACL,YAAY,EAAE,WAAW,EAAE,MAAM;QACjC,OAAO;QACP,UAAU;QACV,QAAQ,EAAE,UAAU,EAAE,OAAO,IAAI,QAAQ;KAC1C,CAAC;AACJ,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { projectSourceInstructions } from '../sourceContract.js';
2
2
  import { recordModelContext } from '../../../recorders/core/recordModelContext.js';
3
3
  import { groundedTextOf } from './callLLM/groundedText.js';
4
- import { FINDINGS_LAYOUT, findingsContext, findingsContextBytes } from '../findings/context.js';
5
4
  import { captureFindingsRequest } from '../findings/admission.js';
6
5
  import { issuedTicketsOf } from '../placedTickets.js';
7
6
  import { completeObserved, observeCallRequests, servedRequestRecorder, streamObserved, } from './callLLM/servedRequest.js';
@@ -13,14 +12,15 @@ import { wireViolationsOf } from '../../../integrity/invariant-violation/wire.js
13
12
  import { danglingReferencesOf } from '../../../integrity/dangling-reference/check.js';
14
13
  import { declaredEnumValuesOf, unsupportedArgumentsOf, } from '../../../integrity/unsupported-argument/check.js';
15
14
  import { toolNameOfMessage } from '../window/toolNames.js';
16
- import { evidenceConclusionLine, evidenceRecoveryPiece } from '../evidence/recovery.js';
15
+ import { evidenceRecoveryPiece } from '../evidence/recovery.js';
17
16
  import { joinSystemPrompt, stripFrameworkFields, toolsWithheld } from '../composeRequest.js';
18
17
  import { readExternalGrounds } from './callLLM/externalGrounds.js';
19
18
  import { identifyAcceptedToolCalls } from './callLLM/acceptedCalls.js';
19
+ import { liveChunkEmitter } from './callLLM/liveChunks.js';
20
+ import { recoveryFeedback, requestOnlyMessages } from './callLLM/requestOnly.js';
20
21
  import { assertForcedRequestSupported, describeProviderDispatch, detachProviderInput, providerDispatchFor, receiptProviderRequest, selectOutputFormat, } from './callLLM/providerRequest.js';
21
22
  import { buildReceipt, receiptPieces } from '../receipt/receipt.js';
22
23
  import { RECEIPT_KEY } from '../../../lib/conventions.js';
23
- import { stagedRefsNudgeFor } from './stagedRefsNudge.js';
24
24
  import { fileIntegrityFindings } from '../integrityFindings.js';
25
25
  import { resilienceHooks } from '../../../recorders/core/resilienceHooks.js';
26
26
  import { replayAttempts } from '../../../resilience/replayAttempt.js';
@@ -30,6 +30,10 @@ import { emitCostTick } from '../../cost.js';
30
30
  import { applyOutputSchema } from '../../../answer-validation/outputSchema.js';
31
31
  import { carriesFindingsDecoration, splitFindings, withoutFindingsArgument, } from '../findings/reserved.js';
32
32
  import { collapseJudged } from '../findings/serve.js';
33
+ import { captureReplayPrefix, replayCacheMarkers } from '../requestTurn/replayPrefix.js';
34
+ import { afterReplayResponse, sameReplayProjection } from '../requestTurn/state.js';
35
+ import { writeRequestReplay } from '../requestTurn/native.js';
36
+ import { projectCallHistory } from './callLLM/requestProjection.js';
33
37
  import { readSchemaToolAnswer } from '../outputEnforcement.js';
34
38
  import { executeWithReliability, ValidationFailure, } from './reliabilityExecution.js';
35
39
  /** The wrap-up call's tool list (9.56.0). A frozen module constant so the
@@ -148,7 +152,7 @@ export function buildCallLLMStage(deps) {
148
152
  const collapsed = deps.hasFindingsLedger === true
149
153
  ? collapseJudged(committed, ledger, deps.findingsServe ?? 'ledger-and-facts')
150
154
  : committed;
151
- const messages = collapsed === committed ? history : stripFrameworkFields(collapsed, true);
155
+ const rendered = collapsed === committed ? history : stripFrameworkFields(collapsed, true);
152
156
  // ── the declared ontology, served (9.106.0) ──────────────────────────
153
157
  // ONE gated read of the run constant seed wrote; the piece is a pure
154
158
  // function of the spec and nothing else (no call number, no clock — the
@@ -208,80 +212,45 @@ export function buildCallLLMStage(deps) {
208
212
  const registeredToolSchemas = withheld !== null
209
213
  ? EMPTY_TOOL_SCHEMAS
210
214
  : scope.dynamicToolSchemas ?? deps.toolSchemas;
215
+ const { replayFrames, closure, continuing, messages } = projectCallHistory(scope, history, rendered, recoveryPiece !== undefined && withheld !== null);
211
216
  // The forced schema rides on the wire and in `llm_start`. Offered contracts
212
217
  // specialize the findings instruction in request-only copies that replay rebuilds.
213
- const systemPieces = projectSourceInstructions(recoveryPiece === undefined && ontologyPieceRecord === undefined
218
+ const recoveryNote = recoveryPiece !== undefined && continuing !== undefined && withheld === null
219
+ ? recoveryFeedback(recoveryPiece.rawContent)
220
+ : undefined;
221
+ const systemRecovery = recoveryNote === undefined ? recoveryPiece : undefined;
222
+ const systemPieces = projectSourceInstructions(systemRecovery === undefined && ontologyPieceRecord === undefined
214
223
  ? systemPromptInjections
215
224
  : [
216
225
  ...systemPromptInjections,
217
- ...(recoveryPiece === undefined ? [] : [recoveryPiece]),
226
+ ...(systemRecovery === undefined ? [] : [systemRecovery]),
218
227
  ...(ontologyPieceRecord === undefined ? [] : [ontologyPieceRecord]),
219
228
  ], registeredToolSchemas);
220
229
  const systemPrompt = joinSystemPrompt(systemPieces);
221
230
  const activeToolSchemas = deps.schemaTool
222
231
  ? [...registeredToolSchemas, deps.schemaTool]
223
232
  : registeredToolSchemas;
224
- // THE STAGED-REFS NUDGE (`nudge: true` on the evidence gate). Judged on
225
- // `registeredToolSchemas` — the tools REALLY served this call, so the
226
- // wrap-up's withheld surface arms nothing and a synthetic schema tool is
227
- // never named a spender. The line is request-only: `scope.history` is
228
- // untouched, so it never enters the exempt corpus and never persists —
229
- // recomposed each iteration, present exactly while both conditions hold.
230
- let wireMessages = messages;
231
- // Lines composed for THIS request and written to no history — each with
232
- // the mechanism that composed it, so the receipt can say a line existed
233
- // without saying what it said.
234
- const requestOnly = [];
235
- const nudge = deps.toolWants === undefined
236
- ? undefined
237
- : stagedRefsNudgeFor(scope, messages, deps.toolWants, registeredToolSchemas, iteration);
238
- if (nudge !== undefined) {
239
- requestOnly.push({ message: nudge, reason: 'staged-refs-nudge' });
240
- wireMessages = [...messages, nudge];
241
- }
242
- // THE TIME LINE (step T6b, `.time({ reader })` only) — the library's conclusion about the
243
- // person's time words, LAST, at the decision point: a settled window with its source and each
244
- // tool's values, or a quote not confirmed yet and the one move that asks the person. Composed
245
- // by the tools slot from the tools it served (`agent/arguments/serve/windows.ts` · `timeWindowsLine`)
246
- // and served only on the iteration that composed it — a slot that did not re-run (classic
247
- // mode) leaves an older line, which is never served. Request-only like the nudge above; not
248
- // on the wrap-up call, whose tools are withheld. `servedView` rebuilds it from the same key.
249
- const timeLine = deps.timeLine === true ? scope.timeLine : undefined;
250
- if (timeLine !== undefined &&
251
- timeLine.iteration === iteration &&
252
- timeLine.text.length > 0 &&
253
- // `wrapUpAsked` is read here as it always was (an unarmed agent's reads
254
- // are unchanged); `withheld` adds the revision's rule.
255
- scope.wrapUpAsked !== true &&
256
- withheld === null) {
257
- const line = { role: 'user', content: timeLine.text };
258
- requestOnly.push({ message: line, reason: 'time-window-line' });
259
- wireMessages = [...wireMessages, line];
260
- }
261
- // THE EVIDENCE CONCLUSION (the figures dial) — the library's finding about
262
- // the numbers it flagged, LAST, on the one call that serves the revision
263
- // instruction (`evidence/figures.ts` · `figuresConclusionLine`). Absent
264
- // whenever the dial is off or no flagged value was a number.
265
- const conclusion = deps.hasEvidenceRecovery === true
266
- ? evidenceConclusionLine(scope.evidenceRecovery, scope.evidenceRecoveryUsed, iteration)
267
- : undefined;
268
- if (conclusion !== undefined) {
269
- const line = { role: 'user', content: conclusion };
270
- requestOnly.push({ message: line, reason: 'evidence-conclusion' });
271
- wireMessages = [...wireMessages, line];
272
- }
273
- if (deps.hasFindingsLedger === true) {
274
- // A resumed leg can have a different host configuration from its checkpoint.
275
- // Record the layout actually used by THIS call; replay reads its commit.
276
- scope.findingsLayout = FINDINGS_LAYOUT;
277
- scope.findingsContextBytes = findingsContextBytes(deps.findingsContextBytes);
278
- const line = {
279
- role: 'user',
280
- content: findingsContext(committed, ledger, deps.findingsContextBytes),
281
- };
282
- requestOnly.push({ message: line, reason: 'findings-data' });
283
- wireMessages = [...wireMessages, line];
284
- }
233
+ const freshNotes = requestOnlyMessages(scope, deps, {
234
+ iteration,
235
+ committed,
236
+ messages,
237
+ ledger,
238
+ registeredToolSchemas,
239
+ withheld,
240
+ });
241
+ const recoveryContext = closure ?? recoveryNote;
242
+ const tail = recoveryContext === undefined ? freshNotes : [recoveryContext, ...freshNotes];
243
+ const prefixWire = continuing?.wire ?? messages;
244
+ const wireMessages = tail.length === 0 ? prefixWire : [...prefixWire, ...tail.map(({ message }) => message)];
245
+ const requestOnly = continuing === undefined
246
+ ? tail
247
+ : [
248
+ ...continuing.additions.map(({ message, reason, wireIndex }) => ({
249
+ message,
250
+ reason: `native-turn-prefix:${wireIndex}:${reason}`,
251
+ })),
252
+ ...tail,
253
+ ];
285
254
  typedEmit(scope, 'agentfootprint.stream.llm_start', {
286
255
  iteration,
287
256
  provider: provider.name,
@@ -333,7 +302,7 @@ export function buildCallLLMStage(deps) {
333
302
  // A custom strategy can create remote cache handles, so refuse a known
334
303
  // unsupported effective request before even that preparation does I/O.
335
304
  assertForcedRequestSupported(provider, baseRequest);
336
- const cacheMarkers = scope.cacheMarkers ?? [];
305
+ const cacheMarkers = replayCacheMarkers(scope.cacheMarkers ?? [], continuing);
337
306
  const detached = detachProviderInput(baseRequest, cacheMarkers, deps.outputFormat);
338
307
  const serving = deps.recordReceipt === false
339
308
  ? undefined
@@ -410,7 +379,7 @@ export function buildCallLLMStage(deps) {
410
379
  iteration,
411
380
  systemPieces,
412
381
  tools: activeToolSchemas,
413
- requestOnly,
382
+ requestOnly: freshNotes,
414
383
  }));
415
384
  // THE CLOSURE CHECK (9.60.0, dangling-reference). At assembly, BEFORE the
416
385
  // call — the composition defect exists whether or not the call lands. A
@@ -469,8 +438,8 @@ export function buildCallLLMStage(deps) {
469
438
  }
470
439
  // Streaming-first: when the provider implements `stream()` we
471
440
  // consume chunk-by-chunk so consumers see tokens as they arrive
472
- // instead of waiting for the full LLM call to finish. Each
473
- // non-terminal chunk fires `agentfootprint.stream.token`. The
441
+ // instead of waiting for the full LLM call to finish. Non-terminal
442
+ // chunks can carry thinking, visible text, or both. The
474
443
  // terminal chunk SHOULD carry the authoritative `LLMResponse`;
475
444
  // when it doesn't (older providers, partial implementations) we
476
445
  // fall back to `complete()` for the authoritative payload —
@@ -492,6 +461,11 @@ export function buildCallLLMStage(deps) {
492
461
  let answeredBy = { provider: provider.name, model, native: false };
493
462
  let localFallback = false;
494
463
  let acceptedFindingsRequest;
464
+ const preserveReplay = deps.hasEvidenceRecovery === true ||
465
+ deps.hasFindingsLedger === true ||
466
+ tail.length > 0 ||
467
+ continuing !== undefined;
468
+ let acceptedProjection = false;
495
469
  const issued = deps.findings === true ? issuedTicketsOf(scope.placedTickets) : undefined;
496
470
  const capture = (req) => captureFindingsRequest(req, committed, iteration, issued);
497
471
  // The run signal reaches the wire. See callLLM/README.md#dispatch-lifetime.
@@ -505,17 +479,19 @@ export function buildCallLLMStage(deps) {
505
479
  const attempts = replayAttempts(req, hooks.providerHooks ?? providerHooks);
506
480
  let dispatch = describeProviderDispatch(selectedProvider, req);
507
481
  let candidate = deps.findings === true ? capture(req) : undefined;
482
+ let stableProjection = preserveReplay && sameReplayProjection(wireMessages, req.messages);
508
483
  if (selectedProvider !== provider)
509
484
  serving?.discard();
510
- const attemptHooks = observeCallRequests(attempts.hooks, serving === undefined && deps.findings !== true
485
+ const attemptHooks = observeCallRequests(attempts.hooks, serving === undefined && deps.findings !== true && !preserveReplay
511
486
  ? undefined
512
487
  : (request) => {
513
488
  serving?.beforeRequest(request);
514
489
  if (deps.findings === true)
515
490
  candidate = capture(request);
491
+ if (preserveReplay)
492
+ stableProjection = sameReplayProjection(wireMessages, request.messages);
516
493
  }, serving?.discard);
517
494
  let resp;
518
- let firstChunkFired = false;
519
495
  // THE STREAM CARRIES WHAT STANDS (9.114.2, `.findings()`): each chunk
520
496
  // goes through the scanner the answer's peel uses, so a token never
521
497
  // carries the model's `_findings` notes — not even when a chunk ends
@@ -525,7 +501,13 @@ export function buildCallLLMStage(deps) {
525
501
  const shown = peel !== undefined && deps.suppressDraftTokens !== true
526
502
  ? peel.reservedMemberFilter()
527
503
  : undefined;
528
- let lastTokenIndex = -1;
504
+ const liveChunks = liveChunkEmitter(scope, runSignal, {
505
+ providerName: selectedProvider.name,
506
+ iteration,
507
+ suppressDraftTokens: deps.suppressDraftTokens === true,
508
+ textFilter: shown,
509
+ onFirstChunk: hooks.onFirstChunk,
510
+ });
529
511
  if (selectedProvider.stream) {
530
512
  for await (const chunk of streamObserved(selectedProvider, attempts.request, attemptHooks, runSignal)) {
531
513
  if (chunk.done) {
@@ -533,51 +515,10 @@ export function buildCallLLMStage(deps) {
533
515
  resp = chunk.response;
534
516
  break;
535
517
  }
536
- // A provider is a port anyone can implement, and a non-terminal
537
- // chunk that carries no `content` used to die on the next line as
538
- // `Cannot read properties of undefined (reading 'length')` —
539
- // naming neither the provider nor the contract it missed. The
540
- // commonest shape of the mistake is a chunk that ends the stream
541
- // with its own marker instead of `done: true`, which is why the
542
- // refusal says what the terminal chunk looks like.
543
- if (typeof chunk.content !== 'string') {
544
- throw new TypeError(`provider '${selectedProvider.name}' yielded a stream chunk whose \`content\` is ` +
545
- `${chunk.content === undefined ? 'missing' : `a ${typeof chunk.content}`}. ` +
546
- `Every chunk from LLMProvider.stream() is ` +
547
- `{ tokenIndex: number, content: string, done: boolean }, and the LAST one is ` +
548
- `{ content: '', done: true, response } — the response payload rides the ` +
549
- `terminal chunk. A chunk that ends the stream any other way is not seen as ` +
550
- `terminal, and its missing content stops the run here.`);
551
- }
552
- if (chunk.content.length > 0) {
553
- if (!firstChunkFired) {
554
- firstChunkFired = true;
555
- hooks.onFirstChunk?.();
556
- }
557
- if (deps.suppressDraftTokens !== true) {
558
- const content = shown === undefined ? chunk.content : shown.push(chunk.content);
559
- lastTokenIndex = chunk.tokenIndex;
560
- if (content.length > 0) {
561
- typedEmit(scope, 'agentfootprint.stream.token', {
562
- iteration,
563
- tokenIndex: chunk.tokenIndex,
564
- content,
565
- });
566
- }
567
- }
568
- }
518
+ liveChunks.push(chunk);
569
519
  }
570
520
  }
571
- // What the scanner still held when the stream ended goes out as one
572
- // last token (whitespace, a key it was reading, a `{`…).
573
- const held = shown?.end() ?? '';
574
- if (held.length > 0) {
575
- typedEmit(scope, 'agentfootprint.stream.token', {
576
- iteration,
577
- tokenIndex: lastTokenIndex + 1,
578
- content: held,
579
- });
580
- }
521
+ liveChunks.finish();
581
522
  if (!resp) {
582
523
  // No `stream()` OR stream finished without a response payload.
583
524
  // Raw errors propagate so the reliability loop can classify them;
@@ -594,6 +535,8 @@ export function buildCallLLMStage(deps) {
594
535
  dispatch = describeProviderDispatch(selectedProvider, completion);
595
536
  if (deps.findings === true)
596
537
  candidate = capture(completion);
538
+ if (preserveReplay)
539
+ stableProjection = sameReplayProjection(wireMessages, completion.messages);
597
540
  resp = await completeObserved(selectedProvider, completion, attemptHooks, runSignal);
598
541
  }
599
542
  // An answer that arrived after the abort is not an answer: refused here,
@@ -623,6 +566,7 @@ export function buildCallLLMStage(deps) {
623
566
  : tagThinkingResponse(resp, String(hooks.providerIndex));
624
567
  answeredBy = dispatch;
625
568
  acceptedFindingsRequest = candidate;
569
+ acceptedProjection = stableProjection;
626
570
  return attempts.response(answered);
627
571
  };
628
572
  // v2.13 — build the output-schema validator hook when both
@@ -750,6 +694,11 @@ export function buildCallLLMStage(deps) {
750
694
  if (response.replay !== undefined || 'llmLatestReplay' in scope) {
751
695
  scope.llmLatestReplay = response.replay === undefined ? undefined : [response.replay];
752
696
  }
697
+ const nextReplay = !localFallback && acceptedProjection
698
+ ? afterReplayResponse(response, continuing === undefined ? [] : replayFrames ?? [], (replay) => captureReplayPrefix(replay, history, messages, tail, continuing?.frozenBefore ?? 0), deps.toolsOffAfterRevision === true)
699
+ : undefined;
700
+ if (nextReplay !== undefined || replayFrames !== undefined)
701
+ writeRequestReplay(scope, nextReplay);
753
702
  // v2.14 — hand provider-specific raw thinking data to the
754
703
  // NormalizeThinking sub-subflow (the next stage in sf-call-llm
755
704
  // when a ThinkingHandler is configured). Undefined when the
@@ -855,7 +804,7 @@ export function buildCallLLMStage(deps) {
855
804
  // The recovery piece quotes the model's words; only the trusted
856
805
  // system injections count as grounds when that piece is present.
857
806
  // Findings DATA is a request-only message after history.
858
- ...(recoveryPiece === undefined
807
+ ...(systemRecovery === undefined
859
808
  ? llmRequest.systemPrompt === undefined
860
809
  ? []
861
810
  : [llmRequest.systemPrompt]
@@ -867,7 +816,7 @@ export function buildCallLLMStage(deps) {
867
816
  : []),
868
817
  // Every tool result as the TOOL's own bytes — the inputs layer's note
869
818
  // after a filled call's result is the library's words (`groundedTextOf`).
870
- ...groundedTextOf(frameMessages, committed),
819
+ ...groundedTextOf(frameMessages, committed, continuing?.historyPositions),
871
820
  ],
872
821
  assistant: frameMessages.filter((m) => m.role === 'assistant').map((m) => m.content),
873
822
  ...(external.length > 0 && { external }),