agentfootprint 2.14.5 → 3.1.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 (314) hide show
  1. package/README.md +1 -1
  2. package/dist/cache/CacheDecisionSubflow.js +13 -16
  3. package/dist/cache/CacheDecisionSubflow.js.map +1 -1
  4. package/dist/cache/CacheGateDecider.js +18 -3
  5. package/dist/cache/CacheGateDecider.js.map +1 -1
  6. package/dist/cache/cacheRecorder.js +12 -3
  7. package/dist/cache/cacheRecorder.js.map +1 -1
  8. package/dist/conventions.js +155 -4
  9. package/dist/conventions.js.map +1 -1
  10. package/dist/core/Agent.js +115 -32
  11. package/dist/core/Agent.js.map +1 -1
  12. package/dist/core/LLMCall.js +213 -41
  13. package/dist/core/LLMCall.js.map +1 -1
  14. package/dist/core/RunnerBase.js +187 -0
  15. package/dist/core/RunnerBase.js.map +1 -1
  16. package/dist/core/agent/buildAgentChart.js +127 -48
  17. package/dist/core/agent/buildAgentChart.js.map +1 -1
  18. package/dist/core/agent/buildAgentMessageApiChart.js +201 -0
  19. package/dist/core/agent/buildAgentMessageApiChart.js.map +1 -0
  20. package/dist/core/agent/buildCacheSubflow.js +62 -0
  21. package/dist/core/agent/buildCacheSubflow.js.map +1 -0
  22. package/dist/core/agent/buildDynamicAgentChart.js +364 -0
  23. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -0
  24. package/dist/core/agent/buildMessageApiChart.js +154 -0
  25. package/dist/core/agent/buildMessageApiChart.js.map +1 -0
  26. package/dist/core/agent/stages/callLLM.js +11 -0
  27. package/dist/core/agent/stages/callLLM.js.map +1 -1
  28. package/dist/core/agent/stages/reliabilityExecution.js +64 -9
  29. package/dist/core/agent/stages/reliabilityExecution.js.map +1 -1
  30. package/dist/core/humanizeLLMError.js +66 -0
  31. package/dist/core/humanizeLLMError.js.map +1 -0
  32. package/dist/core/runner.js +4 -3
  33. package/dist/core/runner.js.map +1 -1
  34. package/dist/core/slots/buildMessagesSlot.js +2 -2
  35. package/dist/core/slots/buildMessagesSlot.js.map +1 -1
  36. package/dist/core/slots/buildSystemPromptSlot.js +1 -1
  37. package/dist/core/slots/buildSystemPromptSlot.js.map +1 -1
  38. package/dist/core/slots/buildThinkingSubflow.js +1 -1
  39. package/dist/core/slots/buildThinkingSubflow.js.map +1 -1
  40. package/dist/core/slots/buildToolsSlot.js +3 -1
  41. package/dist/core/slots/buildToolsSlot.js.map +1 -1
  42. package/dist/core/translator.js +32 -0
  43. package/dist/core/translator.js.map +1 -0
  44. package/dist/core-flow/Conditional.js +72 -10
  45. package/dist/core-flow/Conditional.js.map +1 -1
  46. package/dist/core-flow/Loop.js +59 -16
  47. package/dist/core-flow/Loop.js.map +1 -1
  48. package/dist/core-flow/Parallel.js +239 -92
  49. package/dist/core-flow/Parallel.js.map +1 -1
  50. package/dist/core-flow/Sequence.js +50 -8
  51. package/dist/core-flow/Sequence.js.map +1 -1
  52. package/dist/esm/cache/CacheDecisionSubflow.js +11 -15
  53. package/dist/esm/cache/CacheDecisionSubflow.js.map +1 -1
  54. package/dist/esm/cache/CacheGateDecider.js +18 -3
  55. package/dist/esm/cache/CacheGateDecider.js.map +1 -1
  56. package/dist/esm/cache/cacheRecorder.js +12 -3
  57. package/dist/esm/cache/cacheRecorder.js.map +1 -1
  58. package/dist/esm/conventions.js +151 -3
  59. package/dist/esm/conventions.js.map +1 -1
  60. package/dist/esm/core/Agent.js +116 -33
  61. package/dist/esm/core/Agent.js.map +1 -1
  62. package/dist/esm/core/LLMCall.js +213 -41
  63. package/dist/esm/core/LLMCall.js.map +1 -1
  64. package/dist/esm/core/RunnerBase.js +187 -0
  65. package/dist/esm/core/RunnerBase.js.map +1 -1
  66. package/dist/esm/core/agent/buildAgentChart.js +128 -49
  67. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  68. package/dist/esm/core/agent/buildAgentMessageApiChart.js +197 -0
  69. package/dist/esm/core/agent/buildAgentMessageApiChart.js.map +1 -0
  70. package/dist/esm/core/agent/buildCacheSubflow.js +58 -0
  71. package/dist/esm/core/agent/buildCacheSubflow.js.map +1 -0
  72. package/dist/esm/core/agent/buildDynamicAgentChart.js +360 -0
  73. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -0
  74. package/dist/esm/core/agent/buildMessageApiChart.js +150 -0
  75. package/dist/esm/core/agent/buildMessageApiChart.js.map +1 -0
  76. package/dist/esm/core/agent/stages/callLLM.js +11 -0
  77. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  78. package/dist/esm/core/agent/stages/reliabilityExecution.js +64 -9
  79. package/dist/esm/core/agent/stages/reliabilityExecution.js.map +1 -1
  80. package/dist/esm/core/humanizeLLMError.js +61 -0
  81. package/dist/esm/core/humanizeLLMError.js.map +1 -0
  82. package/dist/esm/core/runner.js +4 -3
  83. package/dist/esm/core/runner.js.map +1 -1
  84. package/dist/esm/core/slots/buildMessagesSlot.js +2 -2
  85. package/dist/esm/core/slots/buildMessagesSlot.js.map +1 -1
  86. package/dist/esm/core/slots/buildSystemPromptSlot.js +1 -1
  87. package/dist/esm/core/slots/buildSystemPromptSlot.js.map +1 -1
  88. package/dist/esm/core/slots/buildThinkingSubflow.js +1 -1
  89. package/dist/esm/core/slots/buildThinkingSubflow.js.map +1 -1
  90. package/dist/esm/core/slots/buildToolsSlot.js +3 -1
  91. package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
  92. package/dist/esm/core/translator.js +31 -0
  93. package/dist/esm/core/translator.js.map +1 -0
  94. package/dist/esm/core-flow/Conditional.js +72 -10
  95. package/dist/esm/core-flow/Conditional.js.map +1 -1
  96. package/dist/esm/core-flow/Loop.js +59 -16
  97. package/dist/esm/core-flow/Loop.js.map +1 -1
  98. package/dist/esm/core-flow/Parallel.js +240 -93
  99. package/dist/esm/core-flow/Parallel.js.map +1 -1
  100. package/dist/esm/core-flow/Sequence.js +50 -8
  101. package/dist/esm/core-flow/Sequence.js.map +1 -1
  102. package/dist/esm/events/registry.js +10 -0
  103. package/dist/esm/events/registry.js.map +1 -1
  104. package/dist/esm/index.js +22 -1
  105. package/dist/esm/index.js.map +1 -1
  106. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +16 -9
  107. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  108. package/dist/esm/memory/causal/snapshotPipeline.js +6 -2
  109. package/dist/esm/memory/causal/snapshotPipeline.js.map +1 -1
  110. package/dist/esm/memory/pipeline/auto.js +2 -2
  111. package/dist/esm/memory/pipeline/auto.js.map +1 -1
  112. package/dist/esm/memory/pipeline/default.js +4 -2
  113. package/dist/esm/memory/pipeline/default.js.map +1 -1
  114. package/dist/esm/memory/pipeline/ephemeral.js +3 -1
  115. package/dist/esm/memory/pipeline/ephemeral.js.map +1 -1
  116. package/dist/esm/memory/pipeline/fact.js +4 -2
  117. package/dist/esm/memory/pipeline/fact.js.map +1 -1
  118. package/dist/esm/memory/pipeline/narrative.js +4 -2
  119. package/dist/esm/memory/pipeline/narrative.js.map +1 -1
  120. package/dist/esm/memory/pipeline/semantic.js +2 -2
  121. package/dist/esm/memory/pipeline/semantic.js.map +1 -1
  122. package/dist/esm/observe.js +1 -1
  123. package/dist/esm/observe.js.map +1 -1
  124. package/dist/esm/patterns/MapReduce.js +5 -5
  125. package/dist/esm/patterns/MapReduce.js.map +1 -1
  126. package/dist/esm/patterns/Swarm.js +1 -1
  127. package/dist/esm/patterns/Swarm.js.map +1 -1
  128. package/dist/esm/recorders/core/ContextEvaluatedRecorder.js +31 -0
  129. package/dist/esm/recorders/core/ContextEvaluatedRecorder.js.map +1 -0
  130. package/dist/esm/recorders/core/ContextRecorder.js +12 -14
  131. package/dist/esm/recorders/core/ContextRecorder.js.map +1 -1
  132. package/dist/esm/recorders/core/ErrorBridge.js +59 -0
  133. package/dist/esm/recorders/core/ErrorBridge.js.map +1 -0
  134. package/dist/esm/recorders/core/ReliabilityRecorder.js +29 -0
  135. package/dist/esm/recorders/core/ReliabilityRecorder.js.map +1 -0
  136. package/dist/esm/recorders/observability/BoundaryRecorder.js +338 -36
  137. package/dist/esm/recorders/observability/BoundaryRecorder.js.map +1 -1
  138. package/dist/esm/recorders/observability/FlowchartRecorder.js +10 -0
  139. package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
  140. package/dist/esm/recorders/observability/LiveStateRecorder.js +120 -21
  141. package/dist/esm/recorders/observability/LiveStateRecorder.js.map +1 -1
  142. package/dist/esm/recorders/observability/RunStepRecorder.js +652 -0
  143. package/dist/esm/recorders/observability/RunStepRecorder.js.map +1 -0
  144. package/dist/esm/recorders/observability/commentary/commentaryTemplates.js +1 -0
  145. package/dist/esm/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
  146. package/dist/esm/recorders/observability/internal/ActorArrowClassifier.js +34 -0
  147. package/dist/esm/recorders/observability/internal/ActorArrowClassifier.js.map +1 -0
  148. package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.js +32 -0
  149. package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.js.map +1 -0
  150. package/dist/esm/recorders/observability/internal/ForkTracker.js +84 -0
  151. package/dist/esm/recorders/observability/internal/ForkTracker.js.map +1 -0
  152. package/dist/esm/recorders/observability/internal/RootInferrer.js +114 -0
  153. package/dist/esm/recorders/observability/internal/RootInferrer.js.map +1 -0
  154. package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.js +31 -0
  155. package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.js.map +1 -0
  156. package/dist/esm/recorders/observability/observeRunId.js +21 -0
  157. package/dist/esm/recorders/observability/observeRunId.js.map +1 -0
  158. package/dist/esm/reliability/buildReliabilityGateChart.js +11 -5
  159. package/dist/esm/reliability/buildReliabilityGateChart.js.map +1 -1
  160. package/dist/events/registry.js +10 -0
  161. package/dist/events/registry.js.map +1 -1
  162. package/dist/index.js +30 -3
  163. package/dist/index.js.map +1 -1
  164. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +16 -9
  165. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  166. package/dist/memory/causal/snapshotPipeline.js +6 -2
  167. package/dist/memory/causal/snapshotPipeline.js.map +1 -1
  168. package/dist/memory/pipeline/auto.js +2 -2
  169. package/dist/memory/pipeline/auto.js.map +1 -1
  170. package/dist/memory/pipeline/default.js +4 -2
  171. package/dist/memory/pipeline/default.js.map +1 -1
  172. package/dist/memory/pipeline/ephemeral.js +3 -1
  173. package/dist/memory/pipeline/ephemeral.js.map +1 -1
  174. package/dist/memory/pipeline/fact.js +4 -2
  175. package/dist/memory/pipeline/fact.js.map +1 -1
  176. package/dist/memory/pipeline/narrative.js +4 -2
  177. package/dist/memory/pipeline/narrative.js.map +1 -1
  178. package/dist/memory/pipeline/semantic.js +2 -2
  179. package/dist/memory/pipeline/semantic.js.map +1 -1
  180. package/dist/observe.js +1 -1
  181. package/dist/observe.js.map +1 -1
  182. package/dist/patterns/MapReduce.js +5 -5
  183. package/dist/patterns/MapReduce.js.map +1 -1
  184. package/dist/patterns/Swarm.js +1 -1
  185. package/dist/patterns/Swarm.js.map +1 -1
  186. package/dist/recorders/core/ContextEvaluatedRecorder.js +35 -0
  187. package/dist/recorders/core/ContextEvaluatedRecorder.js.map +1 -0
  188. package/dist/recorders/core/ContextRecorder.js +11 -13
  189. package/dist/recorders/core/ContextRecorder.js.map +1 -1
  190. package/dist/recorders/core/ErrorBridge.js +64 -0
  191. package/dist/recorders/core/ErrorBridge.js.map +1 -0
  192. package/dist/recorders/core/ReliabilityRecorder.js +33 -0
  193. package/dist/recorders/core/ReliabilityRecorder.js.map +1 -0
  194. package/dist/recorders/observability/BoundaryRecorder.js +337 -35
  195. package/dist/recorders/observability/BoundaryRecorder.js.map +1 -1
  196. package/dist/recorders/observability/FlowchartRecorder.js +10 -0
  197. package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
  198. package/dist/recorders/observability/LiveStateRecorder.js +119 -20
  199. package/dist/recorders/observability/LiveStateRecorder.js.map +1 -1
  200. package/dist/recorders/observability/RunStepRecorder.js +658 -0
  201. package/dist/recorders/observability/RunStepRecorder.js.map +1 -0
  202. package/dist/recorders/observability/commentary/commentaryTemplates.js +1 -0
  203. package/dist/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
  204. package/dist/recorders/observability/internal/ActorArrowClassifier.js +38 -0
  205. package/dist/recorders/observability/internal/ActorArrowClassifier.js.map +1 -0
  206. package/dist/recorders/observability/internal/CandidateAnswerBuffer.js +36 -0
  207. package/dist/recorders/observability/internal/CandidateAnswerBuffer.js.map +1 -0
  208. package/dist/recorders/observability/internal/ForkTracker.js +88 -0
  209. package/dist/recorders/observability/internal/ForkTracker.js.map +1 -0
  210. package/dist/recorders/observability/internal/RootInferrer.js +118 -0
  211. package/dist/recorders/observability/internal/RootInferrer.js.map +1 -0
  212. package/dist/recorders/observability/internal/SequenceSiblingTracker.js +35 -0
  213. package/dist/recorders/observability/internal/SequenceSiblingTracker.js.map +1 -0
  214. package/dist/recorders/observability/observeRunId.js +25 -0
  215. package/dist/recorders/observability/observeRunId.js.map +1 -0
  216. package/dist/reliability/buildReliabilityGateChart.js +11 -5
  217. package/dist/reliability/buildReliabilityGateChart.js.map +1 -1
  218. package/dist/types/cache/CacheDecisionSubflow.d.ts +7 -10
  219. package/dist/types/cache/CacheDecisionSubflow.d.ts.map +1 -1
  220. package/dist/types/cache/CacheGateDecider.d.ts +16 -2
  221. package/dist/types/cache/CacheGateDecider.d.ts.map +1 -1
  222. package/dist/types/cache/cacheRecorder.d.ts.map +1 -1
  223. package/dist/types/conventions.d.ts +101 -1
  224. package/dist/types/conventions.d.ts.map +1 -1
  225. package/dist/types/core/Agent.d.ts +28 -18
  226. package/dist/types/core/Agent.d.ts.map +1 -1
  227. package/dist/types/core/LLMCall.d.ts +73 -11
  228. package/dist/types/core/LLMCall.d.ts.map +1 -1
  229. package/dist/types/core/RunnerBase.d.ts +136 -4
  230. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  231. package/dist/types/core/agent/buildAgentChart.d.ts +38 -19
  232. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  233. package/dist/types/core/agent/buildAgentMessageApiChart.d.ts +41 -0
  234. package/dist/types/core/agent/buildAgentMessageApiChart.d.ts.map +1 -0
  235. package/dist/types/core/agent/buildCacheSubflow.d.ts +36 -0
  236. package/dist/types/core/agent/buildCacheSubflow.d.ts.map +1 -0
  237. package/dist/types/core/agent/buildDynamicAgentChart.d.ts +57 -0
  238. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -0
  239. package/dist/types/core/agent/buildMessageApiChart.d.ts +48 -0
  240. package/dist/types/core/agent/buildMessageApiChart.d.ts.map +1 -0
  241. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  242. package/dist/types/core/agent/stages/reliabilityExecution.d.ts.map +1 -1
  243. package/dist/types/core/agent/types.d.ts +96 -0
  244. package/dist/types/core/agent/types.d.ts.map +1 -1
  245. package/dist/types/core/humanizeLLMError.d.ts +24 -0
  246. package/dist/types/core/humanizeLLMError.d.ts.map +1 -0
  247. package/dist/types/core/runner.d.ts +51 -5
  248. package/dist/types/core/runner.d.ts.map +1 -1
  249. package/dist/types/core/slots/buildMessagesSlot.d.ts.map +1 -1
  250. package/dist/types/core/slots/buildSystemPromptSlot.d.ts.map +1 -1
  251. package/dist/types/core/slots/buildThinkingSubflow.d.ts.map +1 -1
  252. package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
  253. package/dist/types/core/translator.d.ts +95 -0
  254. package/dist/types/core/translator.d.ts.map +1 -0
  255. package/dist/types/core-flow/Conditional.d.ts +48 -4
  256. package/dist/types/core-flow/Conditional.d.ts.map +1 -1
  257. package/dist/types/core-flow/Loop.d.ts +42 -3
  258. package/dist/types/core-flow/Loop.d.ts.map +1 -1
  259. package/dist/types/core-flow/Parallel.d.ts +99 -4
  260. package/dist/types/core-flow/Parallel.d.ts.map +1 -1
  261. package/dist/types/core-flow/Sequence.d.ts +49 -3
  262. package/dist/types/core-flow/Sequence.d.ts.map +1 -1
  263. package/dist/types/events/payloads.d.ts +99 -1
  264. package/dist/types/events/payloads.d.ts.map +1 -1
  265. package/dist/types/events/registry.d.ts +11 -1
  266. package/dist/types/events/registry.d.ts.map +1 -1
  267. package/dist/types/index.d.ts +8 -3
  268. package/dist/types/index.d.ts.map +1 -1
  269. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  270. package/dist/types/memory/causal/snapshotPipeline.d.ts.map +1 -1
  271. package/dist/types/memory/pipeline/auto.d.ts.map +1 -1
  272. package/dist/types/memory/pipeline/default.d.ts.map +1 -1
  273. package/dist/types/memory/pipeline/ephemeral.d.ts.map +1 -1
  274. package/dist/types/memory/pipeline/fact.d.ts.map +1 -1
  275. package/dist/types/memory/pipeline/narrative.d.ts.map +1 -1
  276. package/dist/types/memory/pipeline/semantic.d.ts.map +1 -1
  277. package/dist/types/observe.d.ts +2 -2
  278. package/dist/types/observe.d.ts.map +1 -1
  279. package/dist/types/recorders/core/ContextEvaluatedRecorder.d.ts +24 -0
  280. package/dist/types/recorders/core/ContextEvaluatedRecorder.d.ts.map +1 -0
  281. package/dist/types/recorders/core/ContextRecorder.d.ts +0 -2
  282. package/dist/types/recorders/core/ContextRecorder.d.ts.map +1 -1
  283. package/dist/types/recorders/core/ErrorBridge.d.ts +39 -0
  284. package/dist/types/recorders/core/ErrorBridge.d.ts.map +1 -0
  285. package/dist/types/recorders/core/ReliabilityRecorder.d.ts +25 -0
  286. package/dist/types/recorders/core/ReliabilityRecorder.d.ts.map +1 -0
  287. package/dist/types/recorders/observability/BoundaryRecorder.d.ts +167 -6
  288. package/dist/types/recorders/observability/BoundaryRecorder.d.ts.map +1 -1
  289. package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
  290. package/dist/types/recorders/observability/LiveStateRecorder.d.ts +42 -6
  291. package/dist/types/recorders/observability/LiveStateRecorder.d.ts.map +1 -1
  292. package/dist/types/recorders/observability/RunStepRecorder.d.ts +232 -0
  293. package/dist/types/recorders/observability/RunStepRecorder.d.ts.map +1 -0
  294. package/dist/types/recorders/observability/commentary/commentaryTemplates.d.ts.map +1 -1
  295. package/dist/types/recorders/observability/internal/ActorArrowClassifier.d.ts +26 -0
  296. package/dist/types/recorders/observability/internal/ActorArrowClassifier.d.ts.map +1 -0
  297. package/dist/types/recorders/observability/internal/CandidateAnswerBuffer.d.ts +29 -0
  298. package/dist/types/recorders/observability/internal/CandidateAnswerBuffer.d.ts.map +1 -0
  299. package/dist/types/recorders/observability/internal/ForkTracker.d.ts +61 -0
  300. package/dist/types/recorders/observability/internal/ForkTracker.d.ts.map +1 -0
  301. package/dist/types/recorders/observability/internal/RootInferrer.d.ts +52 -0
  302. package/dist/types/recorders/observability/internal/RootInferrer.d.ts.map +1 -0
  303. package/dist/types/recorders/observability/internal/SequenceSiblingTracker.d.ts +25 -0
  304. package/dist/types/recorders/observability/internal/SequenceSiblingTracker.d.ts.map +1 -0
  305. package/dist/types/recorders/observability/observeRunId.d.ts +37 -0
  306. package/dist/types/recorders/observability/observeRunId.d.ts.map +1 -0
  307. package/dist/types/reliability/buildReliabilityGateChart.d.ts.map +1 -1
  308. package/package.json +6 -5
  309. package/dist/core/agent/stages/iterationStart.js +0 -24
  310. package/dist/core/agent/stages/iterationStart.js.map +0 -1
  311. package/dist/esm/core/agent/stages/iterationStart.js +0 -20
  312. package/dist/esm/core/agent/stages/iterationStart.js.map +0 -1
  313. package/dist/types/core/agent/stages/iterationStart.d.ts +0 -16
  314. package/dist/types/core/agent/stages/iterationStart.d.ts.map +0 -1
@@ -15,45 +15,55 @@
15
15
  *
16
16
  * Chart shape:
17
17
  *
18
- * Seed
18
+ * Initialize
19
19
  * → [memory READ subflows for each .memory()]
20
- * → InjectionEngine (subflow)
21
- * → SystemPrompt (slot subflow)
22
- * Messages (slot subflow)
23
- * Tools (slot subflow)
24
- * → CacheDecision (subflow)
20
+ * → InjectionEngine (subflow) ← loop target (tool-calls loops here)
21
+ * → Context (selector, PARALLEL fan-out, failFast)
22
+ * {System Prompt ‖ Messages ‖ Tools} (slot subflows)
23
+ * converge
25
24
  * → UpdateSkillHistory
26
- * → CacheGate (decider) ApplyMarkers / SkipCaching
27
- * IterationStart
28
- * → CallLLM
29
- * → Route (decider) tool-calls (pausable) / final (subflow)
30
- * |
31
- * ┌────── PrepareFinal ▼
25
+ * → Cache (sf-cache subflow: decideCacheMarkers CacheGate
26
+ * ApplyMarkers / SkipCaching)
27
+ * → CallLLM (also emits the per-iteration iteration_start marker)
28
+ * → [NormalizeThinking] (subflow, only when a ThinkingHandler resolved)
29
+ * → Route (decider)
30
+ * ├─ tool-calls (pausable) → loopTo(InjectionEngine) ← branch-sourced loop
31
+ * └─ final (subflow) → terminal leaf
32
+ * ┌────── PrepareFinal
32
33
  * ├──── [memory WRITE subflows]
33
34
  * └──── BreakFinal ($break)
34
- * loopTo(InjectionEngine)
35
35
  *
36
36
  * (When v2.11.x reliability is configured, the reliability gate chart
37
- * mounts as a subflow between IterationStart and CallLLM with a
38
- * TranslateFailFast stage after it. Lands in the next commit.)
37
+ * mounts as a subflow before CallLLM with a TranslateFailFast stage
38
+ * after it. Lands in the next commit.)
39
39
  */
40
40
  import { ArrayMergeMode } from 'footprintjs/advanced';
41
- import { flowChart } from 'footprintjs';
41
+ import { flowChart, select } from 'footprintjs';
42
42
  import { STAGE_IDS, SUBFLOW_IDS } from '../../conventions.js';
43
43
  import { memoryInjectionKey } from '../../memory/define.types.js';
44
44
  import { unwrapMemoryFlowChart } from '../../memory/define.js';
45
45
  import { mountMemoryRead, mountMemoryWrite } from '../../memory/wire/mountMemoryPipeline.js';
46
46
  import { breakFinalStage } from './stages/breakFinal.js';
47
47
  import { prepareFinalStage } from './stages/prepareFinal.js';
48
+ import { buildCacheSubflow } from './buildCacheSubflow.js';
48
49
  /**
49
50
  * Build the agent's complete FlowChart from the supplied deps.
50
51
  */
51
52
  export function buildAgentChart(deps) {
53
+ // ReAct loop semantics. 'classic' caches the static slots (engineer
54
+ // system-prompt + tools only on the first turn); 'dynamic' (default)
55
+ // re-engineers all 3 slots every turn. Drives the Context selector below.
56
+ const reactMode = deps.reactMode ?? 'dynamic';
52
57
  // ── Final-branch subflow ─────────────────────────────────────
53
58
  // Split so memory-write subflows can mount BETWEEN setting
54
59
  // finalContent and breaking the ReAct loop. PrepareFinal captures
55
60
  // the turn payload; BreakFinal terminates the loop.
56
- let finalBranchBuilder = flowChart('PrepareFinal', prepareFinalStage, 'prepare-final', undefined, 'Capture turn payload (finalContent + newMessages)');
61
+ let finalBranchBuilder = flowChart('PrepareFinal', prepareFinalStage, 'prepare-final', {
62
+ ...(deps.structureRecorders !== undefined && {
63
+ structureRecorders: [...deps.structureRecorders],
64
+ }),
65
+ description: 'Capture turn payload (finalContent + newMessages)',
66
+ });
57
67
  for (const m of deps.memories) {
58
68
  if (m.write) {
59
69
  finalBranchBuilder = mountMemoryWrite(finalBranchBuilder, {
@@ -77,8 +87,16 @@ export function buildAgentChart(deps) {
77
87
  // (Lens + FlowchartRecorder) detect Agent-primitive subflows via
78
88
  // this prefix and flag them as true agent boundaries (separate
79
89
  // from LLMCall subflows which use `LLMCall:` prefix).
80
- let builder = flowChart('Seed', deps.seed, STAGE_IDS.SEED, undefined, 'Agent: ReAct loop');
81
- // Memory READ subflows — mounted between Seed and InjectionEngine
90
+ let builder = flowChart('Initialize', deps.seed, STAGE_IDS.SEED, {
91
+ ...(deps.structureRecorders !== undefined && {
92
+ structureRecorders: [...deps.structureRecorders],
93
+ }),
94
+ // Tag the mode so the Lens can label the run. Keep the `Agent:` taxonomy
95
+ // prefix (consumers detect Agent boundaries by it). Dynamic keeps the
96
+ // historical 'Agent: ReAct loop' string for byte-stability.
97
+ description: reactMode === 'classic' ? 'Agent: Classic ReAct loop' : 'Agent: ReAct loop',
98
+ });
99
+ // Memory READ subflows — mounted between Initialize and InjectionEngine
82
100
  // for TURN_START timing (default). Each memory writes to its own
83
101
  // scope key (`memoryInjection_${id}`) so multiple `.memory()`
84
102
  // registrations layer without colliding.
@@ -118,7 +136,48 @@ export function buildAgentChart(deps) {
118
136
  // 8 → 16 → 24 → 32 cumulative injections per turn.
119
137
  arrayMerge: ArrayMergeMode.Replace,
120
138
  })
121
- .addSubFlowChartNext(SUBFLOW_IDS.SYSTEM_PROMPT, deps.systemPromptSubflow, 'System Prompt', {
139
+ // ── Context assembly: the 3 slots run in PARALLEL (selector fan-out) ──
140
+ // The slots are genuinely INDEPENDENT — each reads ONLY InjectionEngine's
141
+ // activeInjections + seed state, and each writes a DISJOINT output key
142
+ // (systemPromptInjections / messagesInjections / toolsInjections +
143
+ // dynamicToolSchemas). None reads another slot's output. Running them
144
+ // sequentially was an accident of chaining; the fork makes the execution
145
+ // tree tell the truth (and the Lens merge-tree renders the real shape).
146
+ // The selector picks ALL 3 every iteration (unconditional fan-out).
147
+ // failFast: true — a REQUIRED slot that throws aborts the whole turn,
148
+ // matching the old sequential-throw behavior. WITHOUT it the default
149
+ // Promise.allSettled would SWALLOW a failing slot and call the LLM with a
150
+ // half-built request (the documented request-assembly footgun).
151
+ // ── Context selector — THE one place Classic and Dynamic differ ──────
152
+ // The 3 slots are always selector BRANCHES (so they stay drawn in the
153
+ // chart in both modes); WHICH ones get selected per turn is the whole
154
+ // Classic-vs-Dynamic difference:
155
+ // • dynamic — pick all 3 EVERY turn (activations can change per turn:
156
+ // a skill fires, a rule matches, a tool-return steers the next turn).
157
+ // • classic — pick all 3 on the FIRST turn, then ONLY messages. The
158
+ // static slots aren't re-selected, so their turn-1 outputs persist in
159
+ // scope (that IS the cache — the flat builder has no per-turn reset),
160
+ // and only the message list rebuilds each iteration. The Lens shows
161
+ // this directly: after turn 1 only the Messages branch lights up.
162
+ .addSelectorFunction('Context', ((scope) => {
163
+ const firstTurn = (scope.iteration ?? 1) <= 1;
164
+ const includeStatic = reactMode === 'dynamic' || firstTurn;
165
+ return select(scope, [
166
+ {
167
+ when: () => includeStatic,
168
+ then: SUBFLOW_IDS.SYSTEM_PROMPT,
169
+ label: 'engineer system-prompt',
170
+ },
171
+ { when: () => true, then: SUBFLOW_IDS.MESSAGES, label: 'engineer messages' },
172
+ { when: () => includeStatic, then: SUBFLOW_IDS.TOOLS, label: 'engineer tools' },
173
+ ]);
174
+ }), STAGE_IDS.CONTEXT, reactMode === 'classic'
175
+ ? 'Assemble request context: messages every turn; system-prompt + tools cached after turn 1'
176
+ : 'Assemble request context: system-prompt + messages + tools (parallel)', { failFast: true })
177
+ // Each branch keeps its inputMapper + outputMapper + arrayMerge:Replace
178
+ // VERBATIM from the former sequential mounts. Replace (not concat) is
179
+ // load-bearing: the loopTo would otherwise accumulate injections/tools.
180
+ .addSubFlowChartBranch(SUBFLOW_IDS.SYSTEM_PROMPT, deps.systemPromptSubflow, 'System Prompt', {
122
181
  inputMapper: (parent) => ({
123
182
  userMessage: parent.userMessage,
124
183
  iteration: parent.iteration,
@@ -127,7 +186,7 @@ export function buildAgentChart(deps) {
127
186
  outputMapper: (sf) => ({ systemPromptInjections: sf.systemPromptInjections }),
128
187
  arrayMerge: ArrayMergeMode.Replace,
129
188
  })
130
- .addSubFlowChartNext(SUBFLOW_IDS.MESSAGES, deps.messagesSubflow, 'Messages', {
189
+ .addSubFlowChartBranch(SUBFLOW_IDS.MESSAGES, deps.messagesSubflow, 'Messages', {
131
190
  inputMapper: (parent) => ({
132
191
  messages: parent.history,
133
192
  iteration: parent.iteration,
@@ -136,7 +195,7 @@ export function buildAgentChart(deps) {
136
195
  outputMapper: (sf) => ({ messagesInjections: sf.messagesInjections }),
137
196
  arrayMerge: ArrayMergeMode.Replace,
138
197
  })
139
- .addSubFlowChartNext(SUBFLOW_IDS.TOOLS, deps.toolsSubflow, 'Tools', {
198
+ .addSubFlowChartBranch(SUBFLOW_IDS.TOOLS, deps.toolsSubflow, 'Tools', {
140
199
  inputMapper: (parent) => ({
141
200
  iteration: parent.iteration,
142
201
  activeInjections: parent.activeInjections,
@@ -158,9 +217,30 @@ export function buildAgentChart(deps) {
158
217
  // duplicates that providers reject.
159
218
  arrayMerge: ArrayMergeMode.Replace,
160
219
  })
161
- // ── Cache layer (v2.6) ─────────────────────────────────────
162
- .addSubFlowChartNext(SUBFLOW_IDS.CACHE_DECISION, deps.cacheDecisionSubflow, 'CacheDecision', {
220
+ .end();
221
+ // ── Skill-churn window (cache concern) ──────────────────────────
222
+ // UpdateSkillHistory stays in the MAIN loop (NOT inside sf-cache): the
223
+ // skillHistory rolling window must persist across iterations, so keeping
224
+ // it here lets it live in parent scope without round-tripping through the
225
+ // subflow. It feeds sf-cache's CacheGate churn check, and sits right where
226
+ // the tool-driven skill activation flows into it.
227
+ //
228
+ // CONDITIONAL MOUNT: only when skills are registered. With no skills the
229
+ // window records "no skill" every iteration and CacheGate's churn rule can
230
+ // never fire — so the stage is omitted entirely (no dead weight, no
231
+ // misleading box). Mirrors the read_skill auto-attach + NormalizeThinking.
232
+ if (deps.hasSkills) {
233
+ builder = builder.addFunction('UpdateSkillHistory', deps.updateSkillHistoryStage, STAGE_IDS.UPDATE_SKILL_HISTORY, 'Update skill-history rolling window for CacheGate churn detection');
234
+ }
235
+ builder = builder
236
+ // sf-cache: decideCacheMarkers → CacheGate → apply/skip, collapsed into
237
+ // ONE box. Pure provider-agnostic DECISION layer — reads the turn's state,
238
+ // outputs only the gated cacheMarkers (Replace, not concat, across the
239
+ // loop). The attached provider's CacheStrategy turns markers into wire
240
+ // format later. See buildCacheSubflow.ts.
241
+ .addSubFlowChartNext(SUBFLOW_IDS.CACHE, buildCacheSubflow(), 'Cache', {
163
242
  inputMapper: (parent) => ({
243
+ // decideCacheMarkers inputs
164
244
  activeInjections: parent.activeInjections ?? [],
165
245
  iteration: parent.iteration ?? 1,
166
246
  maxIterations: parent.maxIterations ?? deps.maxIterations,
@@ -171,24 +251,16 @@ export function buildAgentChart(deps) {
171
251
  cumulativeInputTokens: parent.totalInputTokens ?? 0,
172
252
  systemPromptCachePolicy: deps.systemPromptCachePolicy,
173
253
  cachingDisabled: parent.cachingDisabled ?? false,
254
+ // CacheGate inputs (read-only: skillHistory is updated in the main
255
+ // loop above, so it is NOT mapped back out)
256
+ recentHitRate: parent.recentHitRate,
257
+ skillHistory: parent.skillHistory ?? [],
174
258
  }),
175
259
  outputMapper: (sf) => ({ cacheMarkers: sf.cacheMarkers }),
176
260
  arrayMerge: ArrayMergeMode.Replace,
177
261
  })
178
- .addFunction('UpdateSkillHistory', deps.updateSkillHistoryStage, STAGE_IDS.UPDATE_SKILL_HISTORY, 'Update skill-history rolling window for CacheGate churn detection')
179
- .addDeciderFunction('CacheGate', deps.cacheGateDecide, STAGE_IDS.CACHE_GATE, 'Gate cache-marker application: kill switch / hit-rate / skill-churn')
180
- .addFunctionBranch(STAGE_IDS.APPLY_MARKERS, 'ApplyMarkers',
181
- // Pass-through stage — markers stay in scope as-is.
182
- // BuildLLMRequest (Phase 7+) reads them on the next stage.
183
- () => undefined, 'Proceed with cache markers from CacheDecision')
184
- .addFunctionBranch(STAGE_IDS.SKIP_CACHING, 'SkipCaching',
185
- // Clear markers so BuildLLMRequest sees an empty list and
186
- // makes the request unmodified.
187
- (scope) => {
188
- scope.cacheMarkers = [];
189
- }, 'Skip caching this iteration')
190
- .end()
191
- .addFunction('IterationStart', deps.iterationStart, 'iteration-start', 'Iteration begin marker')
262
+ // CallLLM emits the per-iteration `iteration_start` marker itself (no
263
+ // dedicated IterationStart stage emitting is passive observability).
192
264
  .addFunction('CallLLM', deps.callLLM, STAGE_IDS.CALL_LLM, 'LLM invocation');
193
265
  // v2.14 — conditional NormalizeThinking sub-subflow. Mounted ONLY
194
266
  // when a ThinkingHandler resolved (auto-wired by provider.name OR
@@ -210,7 +282,15 @@ export function buildAgentChart(deps) {
210
282
  }
211
283
  builder = builder
212
284
  .addDeciderFunction('Route', deps.routeDecider, SUBFLOW_IDS.ROUTE, 'ReAct routing')
213
- .addPausableFunctionBranch('tool-calls', 'ToolCalls', deps.toolCallsHandler, 'Tool execution (pausable via pauseHere)')
285
+ .addPausableFunctionBranch('tool-calls', 'ToolCalls', deps.toolCallsHandler, 'Tool execution (pausable via pauseHere)',
286
+ // Branch-sourced loop: tool-calls loops back to the InjectionEngine so
287
+ // EVERY iteration re-evaluates triggers against the freshest context (the
288
+ // just-appended tool result). Sourced from the BRANCH (not the decider) so
289
+ // the chart reads honestly — `ToolCalls → InjectionEngine` loops, `Final`
290
+ // terminates. Survives pause/resume (human-in-the-loop tool approval): the
291
+ // engine resolves the subflow loop target on resume — footprintjs
292
+ // FlowChartExecutor.resume + test/lib/pause/resume-branch-loop-subflow.
293
+ { loopTo: SUBFLOW_IDS.INJECTION_ENGINE })
214
294
  .addSubFlowChartBranch(SUBFLOW_IDS.FINAL, finalBranchChart, 'Final', {
215
295
  // Pass through the read-only state the sub-chart needs;
216
296
  // OMIT keys the sub-chart writes (finalContent, newMessages)
@@ -224,19 +304,18 @@ export function buildAgentChart(deps) {
224
304
  outputMapper: (sf) => ({
225
305
  finalContent: sf.finalContent,
226
306
  }),
227
- // BreakFinal's $break() must reach the outer loopTo so the
228
- // ReAct iteration terminates; without this the inner break
229
- // only exits the sub-chart and the outer loop continues.
307
+ // With the branch-sourced loop, `final` is a terminal LEAF — it ends the
308
+ // run on its own (no decider `next` to suppress). propagateBreak is kept
309
+ // so BreakFinal's $break() still surfaces a terminal onBreak signal to the
310
+ // parent (observability) and stays correct if a decider-level `next` is
311
+ // ever reintroduced.
230
312
  propagateBreak: true,
231
313
  })
232
314
  .setDefault(SUBFLOW_IDS.FINAL)
233
- .end()
234
- // Dynamic ReAct: loop back to the InjectionEngine so EVERY iteration
235
- // re-evaluates triggers (rule predicates, on-tool-return,
236
- // llm-activated) against the freshest context (the just-appended
237
- // tool result). Without this, the InjectionEngine runs ONCE per
238
- // turn — quietly breaking the framework's "Dynamic ReAct" claim.
239
- .loopTo(SUBFLOW_IDS.INJECTION_ENGINE);
315
+ .end();
316
+ // The ReAct loop is now sourced from the `tool-calls` branch (the
317
+ // `{ loopTo }` above), not the decider — so `Final` is a plain terminal leaf
318
+ // and the chart draws `ToolCalls → InjectionEngine` for the loop edge.
240
319
  return builder.build();
241
320
  }
242
321
  //# sourceMappingURL=buildAgentChart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildAgentChart.js","sourceRoot":"","sources":["../../../../src/core/agent/buildAgentChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA+C7D;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAoB;IAClD,gEAAgE;IAChE,2DAA2D;IAC3D,kEAAkE;IAClE,oDAAoD;IACpD,IAAI,kBAAkB,GAAG,SAAS,CAChC,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,mDAAmD,CACpD,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;YACZ,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,EAAE;gBACxD,QAAQ,EAAE;oBACR,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAU;oBAC5C,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,CAAU;iBAC/C;gBACD,WAAW,EAAE,aAAa;gBAC1B,aAAa,E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,gBAAgB,EAAE,OAAO,EAAE;QACnE,wDAAwD;QACxD,6DAA6D;QAC7D,6DAA6D;QAC7D,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE;YACtB,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;YAC/D,KAAK,EAAE,CAAC;YACR,KAAK,GAAG,CAAC;YACT,OAAO,IAAI,CAAC;QACd,CAAC;QACD,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACrB,YAAY,EAAE,EAAE,CAAC,YAAsB;SACxC,CAAC;QACF,yEAAyE;QACzE,yEAAyE;QACzE,2EAA2E;QAC3E,wEAAwE;QACxE,qBAAqB;QACrB,cAAc,EAAE,IAAI;KACrB,CAAC;SACD,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC;SAC7B,GAAG,EAAE,CAAC;IACT,kEAAkE;IAClE,6EAA6E;IAC7E,uEAAuE;IAEvE,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * buildAgentMessageApiChart — the Agent (ReAct) form of the messageAPI
3
+ * merge-tree, as ONE FLAT main chart (no inner LLM-call sub-box).
4
+ *
5
+ * The whole ReAct cycle lives directly in the single Agent chart:
6
+ *
7
+ * Context (ROOT selector — inits + picks which context slots to engineer)
8
+ * ├─ system-prompt ┐
9
+ * ├─ messages ─────┼─→ messageAPI → Call-LLM
10
+ * └─ tools ────────┘
11
+ * → Route (decider) → [ ToolCalls (execute) → loop ] / Final (response)
12
+ * loopTo(Context)
13
+ *
14
+ * WHY flat (the user's call): the entire agent — context engineering, the LLM
15
+ * call, routing, tool execution, the loop, and the final response — is ONE
16
+ * visible flowchart in ONE Agent box. No nested LLM-call box: Lens wraps the
17
+ * whole chart in the Agent main-box and renders the slots as pills. This is
18
+ * simpler than the composed (sf-llm-call subflow) shape and avoids box-in-box
19
+ * nesting entirely.
20
+ *
21
+ * The three context slots are DIRECT children of Context; all converge at
22
+ * messageAPI (which assembles system-prompt + messages); Call-LLM then sends
23
+ * the assembled payload plus the tool schemas. Route decides tool-calls (loop)
24
+ * vs final (terminate). The same chart serves Static and Dynamic agents — only
25
+ * which slots the Context selector lights per iteration differs.
26
+ */
27
+ import { flowChartSelector, select } from 'footprintjs';
28
+ import { SUBFLOW_IDS } from '../../conventions.js';
29
+ import { typedEmit } from '../../recorders/core/typedEmit.js';
30
+ import { buildSystemPromptSlot } from '../slots/buildSystemPromptSlot.js';
31
+ import { buildMessagesSlot } from '../slots/buildMessagesSlot.js';
32
+ import { buildToolsSlot } from '../slots/buildToolsSlot.js';
33
+ /** Route branch ids. */
34
+ const ROUTE_TOOL_CALLS = 'tool-calls';
35
+ const ROUTE_FINAL = SUBFLOW_IDS.FINAL;
36
+ /**
37
+ * Build the Agent merge-tree chart as one flat ReAct flowchart.
38
+ */
39
+ export function buildAgentMessageApiChart(deps) {
40
+ const { provider, model, systemPrompt, tools } = deps;
41
+ const maxIterations = deps.maxIterations ?? 5;
42
+ // ── Context: ROOT selector. Inits per-call state on the first turn (the
43
+ // folded-in seed — Context is the chart's first node); on ReAct loop re-entry
44
+ // it leaves state intact (the iteration was bumped by ToolCalls). Returns the
45
+ // three context slots to engineer. ──
46
+ const contextSelector = (scope) => {
47
+ if (scope.iteration === undefined) {
48
+ const args = scope.$getArgs();
49
+ scope.userMessage = args.message;
50
+ scope.history = [{ role: 'user', content: args.message }];
51
+ scope.iteration = 1;
52
+ scope.systemPromptInjections = [];
53
+ scope.messagesInjections = [];
54
+ scope.toolSchemas = [];
55
+ scope.assembledSystem = '';
56
+ scope.assembledMessages = [];
57
+ scope.answer = '';
58
+ scope.toolCalls = [];
59
+ scope.finalContent = '';
60
+ }
61
+ return select(scope, [
62
+ { when: () => true, then: SUBFLOW_IDS.SYSTEM_PROMPT, label: 'engineer system-prompt' },
63
+ { when: () => true, then: SUBFLOW_IDS.MESSAGES, label: 'engineer messages' },
64
+ { when: () => true, then: SUBFLOW_IDS.TOOLS, label: 'engineer tools' },
65
+ ]);
66
+ };
67
+ // ── messageAPI: assemble system-prompt + messages (the join after the slots
68
+ // converge). tools is a separate field Call-LLM reads directly. ──
69
+ const messageApiStage = (scope) => {
70
+ const sysInjections = (scope.systemPromptInjections ?? []);
71
+ scope.assembledSystem = sysInjections
72
+ .map((r) => r.rawContent ?? '')
73
+ .filter((s) => s.length > 0)
74
+ .join('\n\n');
75
+ scope.assembledMessages = [...(scope.history ?? [])];
76
+ };
77
+ // ── Call-LLM: send the assembled payload + the tool schemas. ──
78
+ const callLLM = async (scope) => {
79
+ const system = scope.assembledSystem;
80
+ const messages = (scope.assembledMessages ?? []);
81
+ const toolSchemas = (scope.toolSchemas ?? []);
82
+ typedEmit(scope, 'agentfootprint.stream.llm_start', {
83
+ iteration: scope.iteration,
84
+ provider: provider.name,
85
+ model,
86
+ systemPromptChars: system.length,
87
+ messagesCount: messages.length,
88
+ toolsCount: toolSchemas.length,
89
+ });
90
+ const startMs = Date.now();
91
+ const response = await provider.complete({
92
+ ...(system.length > 0 && { systemPrompt: system }),
93
+ messages,
94
+ ...(toolSchemas.length > 0 && { tools: toolSchemas }),
95
+ model,
96
+ });
97
+ scope.answer = response.content;
98
+ scope.toolCalls = response.toolCalls;
99
+ typedEmit(scope, 'agentfootprint.stream.llm_end', {
100
+ iteration: scope.iteration,
101
+ content: response.content,
102
+ toolCallCount: response.toolCalls.length,
103
+ usage: response.usage,
104
+ stopReason: response.stopReason,
105
+ durationMs: Date.now() - startMs,
106
+ });
107
+ };
108
+ // ── Route: ReAct decider — tool-calls (loop) vs final (terminate). ──
109
+ const routeDecider = (scope) => {
110
+ const calls = (scope.toolCalls ?? []);
111
+ if (calls.length > 0 && scope.iteration < maxIterations)
112
+ return ROUTE_TOOL_CALLS;
113
+ return ROUTE_FINAL;
114
+ };
115
+ // ── ToolCalls: execute the LLM's requested tools, append results, bump the
116
+ // iteration, loop. ──
117
+ const toolExec = async (scope) => {
118
+ const calls = (scope.toolCalls ?? []);
119
+ const newHistory = [...(scope.history ?? [])];
120
+ for (const call of calls) {
121
+ typedEmit(scope, 'agentfootprint.stream.tool_start', {
122
+ toolCallId: call.id,
123
+ toolName: call.name,
124
+ args: call.args,
125
+ });
126
+ const result = `[${call.name} result]`; // demo executor — real agents wire a registry
127
+ newHistory.push({ role: 'tool', content: result, toolCallId: call.id });
128
+ typedEmit(scope, 'agentfootprint.stream.tool_end', {
129
+ toolCallId: call.id,
130
+ result,
131
+ durationMs: 0,
132
+ });
133
+ }
134
+ scope.history = newHistory;
135
+ scope.toolCalls = [];
136
+ scope.iteration = scope.iteration + 1;
137
+ };
138
+ // ── Final: the agent's response — terminate the loop, capture the answer. ──
139
+ const finalStage = (scope) => {
140
+ scope.finalContent = scope.answer;
141
+ scope.$break('agent reached final answer');
142
+ };
143
+ // ── Build ONE flat chart: Context(root) → 3 slots → messageAPI → Call-LLM
144
+ // → Route → [ToolCalls → loop] / Final. ──
145
+ return (flowChartSelector('Context', contextSelector, 'context', {
146
+ ...(deps.structureRecorders !== undefined && {
147
+ structureRecorders: [...deps.structureRecorders],
148
+ }),
149
+ // 'Agent:' taxonomy marker → Lens renders this as an Agent group.
150
+ description: 'Agent: ReAct loop',
151
+ })
152
+ // Three DIRECT context slots — all converge at messageAPI.
153
+ .addSubFlowChartBranch(SUBFLOW_IDS.SYSTEM_PROMPT, buildSystemPromptSlot({ prompt: systemPrompt, reason: 'agent messageAPI' }), 'System Prompt', {
154
+ inputMapper: (parent) => ({
155
+ userMessage: parent.userMessage,
156
+ iteration: parent.iteration,
157
+ }),
158
+ outputMapper: (sf) => ({
159
+ systemPromptInjections: sf.systemPromptInjections,
160
+ }),
161
+ })
162
+ .addSubFlowChartBranch(SUBFLOW_IDS.MESSAGES, buildMessagesSlot(), 'Messages', {
163
+ inputMapper: (parent) => ({
164
+ messages: parent.history,
165
+ iteration: parent.iteration,
166
+ }),
167
+ outputMapper: (sf) => ({ messagesInjections: sf.messagesInjections }),
168
+ })
169
+ .addSubFlowChartBranch(SUBFLOW_IDS.TOOLS, buildToolsSlot({ tools }), 'Tools', {
170
+ inputMapper: (parent) => ({ iteration: parent.iteration }),
171
+ outputMapper: (sf) => ({ toolSchemas: sf.toolSchemas }),
172
+ // tools is a SEPARATE Anthropic wire field — it BYPASSES messageAPI
173
+ // (which assembles only system+messages) and pairs with its output at
174
+ // Call-LLM. `convergeAt` makes the structure edge `sf-tools → call-llm`
175
+ // instead of the default `sf-tools → message-api`, so Call-LLM reads as a
176
+ // true 2-parent merge {messageAPI, tools}. (toolSchemas already rides
177
+ // shared scope; this only makes the diagram faithful.)
178
+ convergeAt: 'call-llm',
179
+ })
180
+ .end()
181
+ // messageAPI assembles ONLY system+messages; Call-LLM then sends that
182
+ // payload + the tool schemas (the 2-parent merge above).
183
+ .addFunction('messageAPI', messageApiStage, 'message-api', 'Assemble system + messages into the LLM request')
184
+ .addFunction('CallLLM', callLLM, 'call-llm', 'Send the assembled request + tools to the LLM')
185
+ // Route → [ToolCalls → loop back to Context] / [Final → terminate].
186
+ .addDeciderFunction('Route', routeDecider, SUBFLOW_IDS.ROUTE, 'ReAct routing')
187
+ .addFunctionBranch(ROUTE_TOOL_CALLS, 'ToolCalls', toolExec, 'Execute tool calls')
188
+ // ReAct: the loop is sourced from the TOOL-CALLS branch (after executing
189
+ // tools, re-engineer context next turn) — NOT from the Route decider. Final
190
+ // terminates as a leaf (its $break is the terminal boundary signal).
191
+ .loopTo('context')
192
+ .addFunctionBranch(ROUTE_FINAL, 'Final', finalStage, 'Terminate the ReAct loop (response)')
193
+ .setDefault(ROUTE_FINAL)
194
+ .end()
195
+ .build());
196
+ }
197
+ //# sourceMappingURL=buildAgentMessageApiChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAgentMessageApiChart.js","sourceRoot":"","sources":["../../../../src/core/agent/buildAgentMessageApiChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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AAC,kBAAkB,EAAE,CAAC;KAC5F,CAAC;SACD,qBAAqB,CAAC,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE;QAC5E,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAG,MAA2B,CAAC,SAAS,EAAE,CAAC;QAChF,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAG,EAAuB,CAAC,WAAW,EAAE,CAAC;QAC7E,oEAAoE;QACpE,sEAAsE;QACtE,wEAAwE;QACxE,0EAA0E;QAC1E,sEAAsE;QACtE,uDAAuD;QACvD,UAAU,EAAE,UAAU;KACvB,CAAC;SACD,GAAG,EAAE;QACN,sEAAsE;QACtE,yDAAyD;SACxD,WAAW,CACV,YAAY,EACZ,eAAwB,EACxB,aAAa,EACb,iDAAiD,CAClD;SACA,WAAW,CACV,SAAS,EACT,OAAgB,EAChB,UAAU,EACV,+CAA+C,CAChD;QACD,oEAAoE;SACnE,kBAAkB,CAAC,OAAO,EAAE,YAAqB,EAAE,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC;SACtF,iBAAiB,CAAC,gBAAgB,EAAE,WAAW,EAAE,QAAiB,EAAE,oBAAoB,CAAC;QAC1F,yEAAyE;QACzE,4EAA4E;QAC5E,qEAAqE;SACpE,MAAM,CAAC,SAAS,CAAC;SACjB,iBAAiB,CAChB,WAAW,EACX,OAAO,EACP,UAAmB,EACnB,qCAAqC,CACtC;SACA,UAAU,CAAC,WAAW,CAAC;SACvB,GAAG,EAAE;SACL,KAAK,EAAE,CACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * buildCacheSubflow — the per-turn prompt-cache decision, as ONE subflow.
3
+ *
4
+ * Collapses the cache machinery into a single `sf-cache` boundary so the
5
+ * agent chart reads cleanly (one "Cache" box you can drill into) while the
6
+ * execution tree stays honest:
7
+ *
8
+ * decideCacheMarkers → CacheGate (decider) → ApplyMarkers / SkipCaching
9
+ *
10
+ * Layering (see src/cache/types.ts):
11
+ * - This subflow is the provider-AGNOSTIC DECISION layer — it only computes
12
+ * and gates provider-neutral `CacheMarker[]`. It knows nothing about any
13
+ * provider.
14
+ * - The provider-SPECIFIC MECHANISM (Anthropic `cache_control`, OpenAI
15
+ * automatic, …) is the attached provider's `CacheStrategy`, selected by
16
+ * `provider.name`, applied later when the request is built.
17
+ *
18
+ * Why `UpdateSkillHistory` is NOT in here: the `skillHistory` rolling window
19
+ * must persist across loop iterations. Keeping `UpdateSkillHistory` in the
20
+ * main loop (just before this subflow) lets `skillHistory` live in the parent
21
+ * scope without round-tripping through this subflow's in/out mappers — the
22
+ * subflow stays pure (reads the turn's state, writes only `cacheMarkers`).
23
+ *
24
+ * Deps-free: every input (`activeInjections`, `iteration`, `skillHistory`,
25
+ * `recentHitRate`, `systemPromptCachePolicy`, …) is supplied by the PARENT's
26
+ * `inputMapper` at the mount site; the output is just `cacheMarkers`.
27
+ */
28
+ import { flowChart } from 'footprintjs';
29
+ import { decideCacheMarkers } from '../../cache/CacheDecisionSubflow.js';
30
+ import { cacheGateDecide } from '../../cache/CacheGateDecider.js';
31
+ import { STAGE_IDS } from '../../conventions.js';
32
+ /**
33
+ * Build the `sf-cache` subflow chart. Called by `buildAgentChart` and
34
+ * `buildDynamicAgentChart` and mounted via `addSubFlowChartNext(
35
+ * SUBFLOW_IDS.CACHE, buildCacheSubflow(), 'Cache', { inputMapper,
36
+ * outputMapper, arrayMerge: Replace })`.
37
+ */
38
+ export function buildCacheSubflow() {
39
+ return flowChart('CacheDecision',
40
+ // Root stage = the cache-decision function (a chart cannot start with a
41
+ // nested subflow). Exported from CacheDecisionSubflow.ts and reused here —
42
+ // the cache decision is the root of sf-cache, no logic duplication.
43
+ decideCacheMarkers, 'decide-cache-markers', {
44
+ description: 'CacheDecision: walk activeInjections, evaluate cache directives, emit CacheMarker[]',
45
+ })
46
+ .addDeciderFunction('CacheGate', cacheGateDecide, STAGE_IDS.CACHE_GATE, 'Gate cache-marker application: kill switch / hit-rate / skill-churn')
47
+ .addFunctionBranch(STAGE_IDS.APPLY_MARKERS, 'ApplyMarkers',
48
+ // Pass-through — markers stay in scope; the request build reads them.
49
+ () => undefined, 'Proceed with cache markers from CacheDecision')
50
+ .addFunctionBranch(STAGE_IDS.SKIP_CACHING, 'SkipCaching',
51
+ // Clear markers so the request is built unmodified this iteration.
52
+ (scope) => {
53
+ scope.cacheMarkers = [];
54
+ }, 'Skip caching this iteration')
55
+ .end()
56
+ .build();
57
+ }
58
+ //# sourceMappingURL=buildCacheSubflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildCacheSubflow.js","sourceRoot":"","sources":["../../../../src/core/agent/buildCacheSubflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,SAAS,CACd,eAAe;IACf,wEAAwE;IACxE,2EAA2E;IAC3E,oEAAoE;IACpE,kBAA2B,EAC3B,sBAAsB,EACtB;QACE,WAAW,EACT,qFAAqF;KACxF,CACF;SACE,kBAAkB,CACjB,WAAW,EACX,eAAwB,EACxB,SAAS,CAAC,UAAU,EACpB,qEAAqE,CACtE;SACA,iBAAiB,CAChB,SAAS,CAAC,aAAa,EACvB,cAAc;IACd,sEAAsE;IACtE,GAAG,EAAE,CAAC,SAAS,EACf,+CAA+C,CAChD;SACA,iBAAiB,CAChB,SAAS,CAAC,YAAY,EACtB,aAAa;IACb,mEAAmE;IACnE,CAAC,KAAK,EAAE,EAAE;QACP,KAA8C,CAAC,YAAY,GAAG,EAAE,CAAC;IACpE,CAAC,EACD,6BAA6B,CAC9B;SACA,GAAG,EAAE;SACL,KAAK,EAAE,CAAC;AACb,CAAC"}