agentfootprint 3.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/AGENTS.md +66 -47
  2. package/CLAUDE.md +47 -37
  3. package/README.md +28 -13
  4. package/dist/adapters/llm/createProvider.js +3 -2
  5. package/dist/adapters/llm/createProvider.js.map +1 -1
  6. package/dist/adapters/observability/agentcore.js +1 -0
  7. package/dist/adapters/observability/agentcore.js.map +1 -1
  8. package/dist/cache/CacheDecisionSubflow.js +13 -18
  9. package/dist/cache/CacheDecisionSubflow.js.map +1 -1
  10. package/dist/cache/CacheGateDecider.js +18 -3
  11. package/dist/cache/CacheGateDecider.js.map +1 -1
  12. package/dist/cache/cacheRecorder.js +12 -3
  13. package/dist/cache/cacheRecorder.js.map +1 -1
  14. package/dist/conventions.js +152 -2
  15. package/dist/conventions.js.map +1 -1
  16. package/dist/core/Agent.js +46 -9
  17. package/dist/core/Agent.js.map +1 -1
  18. package/dist/core/LLMCall.js +177 -44
  19. package/dist/core/LLMCall.js.map +1 -1
  20. package/dist/core/RunnerBase.js +14 -0
  21. package/dist/core/RunnerBase.js.map +1 -1
  22. package/dist/core/agent/buildAgentChart.js +117 -48
  23. package/dist/core/agent/buildAgentChart.js.map +1 -1
  24. package/dist/core/agent/buildAgentMessageApiChart.js +201 -0
  25. package/dist/core/agent/buildAgentMessageApiChart.js.map +1 -0
  26. package/dist/core/agent/buildCacheSubflow.js +62 -0
  27. package/dist/core/agent/buildCacheSubflow.js.map +1 -0
  28. package/dist/core/agent/buildDynamicAgentChart.js +364 -0
  29. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -0
  30. package/dist/core/agent/buildMessageApiChart.js +154 -0
  31. package/dist/core/agent/buildMessageApiChart.js.map +1 -0
  32. package/dist/core/agent/stages/callLLM.js +11 -0
  33. package/dist/core/agent/stages/callLLM.js.map +1 -1
  34. package/dist/core/agent/stages/reliabilityExecution.js +64 -9
  35. package/dist/core/agent/stages/reliabilityExecution.js.map +1 -1
  36. package/dist/core/flowchartAsTool.js +5 -5
  37. package/dist/core/humanizeLLMError.js +66 -0
  38. package/dist/core/humanizeLLMError.js.map +1 -0
  39. package/dist/core/slots/buildMessagesSlot.js +1 -1
  40. package/dist/core/slots/buildMessagesSlot.js.map +1 -1
  41. package/dist/core/slots/buildToolsSlot.js.map +1 -1
  42. package/dist/core-flow/Conditional.js +1 -1
  43. package/dist/core-flow/Conditional.js.map +1 -1
  44. package/dist/core-flow/Loop.js +1 -1
  45. package/dist/core-flow/Loop.js.map +1 -1
  46. package/dist/core-flow/Parallel.js +1 -1
  47. package/dist/core-flow/Parallel.js.map +1 -1
  48. package/dist/esm/adapters/llm/createProvider.js +3 -2
  49. package/dist/esm/adapters/llm/createProvider.js.map +1 -1
  50. package/dist/esm/adapters/observability/agentcore.js +1 -0
  51. package/dist/esm/adapters/observability/agentcore.js.map +1 -1
  52. package/dist/esm/cache/CacheDecisionSubflow.js +11 -17
  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 +148 -1
  59. package/dist/esm/conventions.js.map +1 -1
  60. package/dist/esm/core/Agent.js +47 -10
  61. package/dist/esm/core/Agent.js.map +1 -1
  62. package/dist/esm/core/LLMCall.js +177 -44
  63. package/dist/esm/core/LLMCall.js.map +1 -1
  64. package/dist/esm/core/RunnerBase.js +14 -0
  65. package/dist/esm/core/RunnerBase.js.map +1 -1
  66. package/dist/esm/core/agent/buildAgentChart.js +118 -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/flowchartAsTool.js +5 -5
  81. package/dist/esm/core/humanizeLLMError.js +61 -0
  82. package/dist/esm/core/humanizeLLMError.js.map +1 -0
  83. package/dist/esm/core/slots/buildMessagesSlot.js +1 -1
  84. package/dist/esm/core/slots/buildMessagesSlot.js.map +1 -1
  85. package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
  86. package/dist/esm/core-flow/Conditional.js +1 -1
  87. package/dist/esm/core-flow/Conditional.js.map +1 -1
  88. package/dist/esm/core-flow/Loop.js +1 -1
  89. package/dist/esm/core-flow/Loop.js.map +1 -1
  90. package/dist/esm/core-flow/Parallel.js +1 -1
  91. package/dist/esm/core-flow/Parallel.js.map +1 -1
  92. package/dist/esm/events/registry.js +10 -0
  93. package/dist/esm/events/registry.js.map +1 -1
  94. package/dist/esm/index.js +21 -1
  95. package/dist/esm/index.js.map +1 -1
  96. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +15 -8
  97. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  98. package/dist/esm/lib/lazyRequire.js +2 -30
  99. package/dist/esm/lib/lazyRequire.js.map +1 -1
  100. package/dist/esm/lib/rag/defineRAG.js +4 -2
  101. package/dist/esm/lib/rag/defineRAG.js.map +1 -1
  102. package/dist/esm/lib/rag/indexDocuments.js +2 -2
  103. package/dist/esm/locales/index.js +3 -3
  104. package/dist/esm/memory/beats/heuristicExtractor.js +1 -1
  105. package/dist/esm/memory/beats/heuristicExtractor.js.map +1 -1
  106. package/dist/esm/memory/beats/index.js +6 -6
  107. package/dist/esm/memory/beats/index.js.map +1 -1
  108. package/dist/esm/memory/beats/llmExtractor.js +1 -1
  109. package/dist/esm/memory/beats/llmExtractor.js.map +1 -1
  110. package/dist/esm/memory/embedding/index.js +4 -4
  111. package/dist/esm/memory/embedding/index.js.map +1 -1
  112. package/dist/esm/memory/entry/index.js +1 -1
  113. package/dist/esm/memory/entry/index.js.map +1 -1
  114. package/dist/esm/memory/facts/extractFacts.js +1 -1
  115. package/dist/esm/memory/facts/extractFacts.js.map +1 -1
  116. package/dist/esm/memory/facts/index.js +7 -7
  117. package/dist/esm/memory/facts/index.js.map +1 -1
  118. package/dist/esm/memory/facts/llmFactExtractor.js +1 -1
  119. package/dist/esm/memory/facts/llmFactExtractor.js.map +1 -1
  120. package/dist/esm/memory/facts/loadFacts.js +1 -1
  121. package/dist/esm/memory/facts/loadFacts.js.map +1 -1
  122. package/dist/esm/memory/facts/patternFactExtractor.js +1 -1
  123. package/dist/esm/memory/facts/patternFactExtractor.js.map +1 -1
  124. package/dist/esm/memory/identity/index.js +1 -1
  125. package/dist/esm/memory/identity/index.js.map +1 -1
  126. package/dist/esm/memory/pipeline/auto.js +2 -2
  127. package/dist/esm/memory/pipeline/auto.js.map +1 -1
  128. package/dist/esm/memory/pipeline/default.js +4 -4
  129. package/dist/esm/memory/pipeline/default.js.map +1 -1
  130. package/dist/esm/memory/pipeline/ephemeral.js +3 -3
  131. package/dist/esm/memory/pipeline/ephemeral.js.map +1 -1
  132. package/dist/esm/memory/pipeline/fact.js +5 -5
  133. package/dist/esm/memory/pipeline/fact.js.map +1 -1
  134. package/dist/esm/memory/pipeline/index.js +6 -6
  135. package/dist/esm/memory/pipeline/index.js.map +1 -1
  136. package/dist/esm/memory/pipeline/narrative.js +6 -6
  137. package/dist/esm/memory/pipeline/narrative.js.map +1 -1
  138. package/dist/esm/memory/pipeline/semantic.js +5 -5
  139. package/dist/esm/memory/pipeline/semantic.js.map +1 -1
  140. package/dist/esm/memory/stages/index.js +6 -6
  141. package/dist/esm/memory/stages/index.js.map +1 -1
  142. package/dist/esm/memory/stages/pickByBudget.js +1 -1
  143. package/dist/esm/memory/stages/pickByBudget.js.map +1 -1
  144. package/dist/esm/memory/store/InMemoryStore.js +2 -2
  145. package/dist/esm/memory/store/InMemoryStore.js.map +1 -1
  146. package/dist/esm/memory/store/index.js +1 -1
  147. package/dist/esm/memory/store/index.js.map +1 -1
  148. package/dist/esm/memory/wire/index.js +1 -1
  149. package/dist/esm/memory/wire/index.js.map +1 -1
  150. package/dist/esm/package.json +1 -0
  151. package/dist/esm/recorders/core/ContextEvaluatedRecorder.js +31 -0
  152. package/dist/esm/recorders/core/ContextEvaluatedRecorder.js.map +1 -0
  153. package/dist/esm/recorders/core/ContextRecorder.js +12 -14
  154. package/dist/esm/recorders/core/ContextRecorder.js.map +1 -1
  155. package/dist/esm/recorders/core/ErrorBridge.js +59 -0
  156. package/dist/esm/recorders/core/ErrorBridge.js.map +1 -0
  157. package/dist/esm/recorders/core/ReliabilityRecorder.js +29 -0
  158. package/dist/esm/recorders/core/ReliabilityRecorder.js.map +1 -0
  159. package/dist/esm/recorders/core/typedEmit.js +1 -1
  160. package/dist/esm/recorders/observability/BoundaryRecorder.js +26 -2
  161. package/dist/esm/recorders/observability/BoundaryRecorder.js.map +1 -1
  162. package/dist/esm/recorders/observability/LiveStateRecorder.js +8 -0
  163. package/dist/esm/recorders/observability/LiveStateRecorder.js.map +1 -1
  164. package/dist/esm/recorders/observability/commentary/commentaryTemplates.js +1 -0
  165. package/dist/esm/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
  166. package/dist/esm/reliability/buildReliabilityGateChart.js +10 -4
  167. package/dist/esm/reliability/buildReliabilityGateChart.js.map +1 -1
  168. package/dist/esm/resilience/withRetry.js +3 -0
  169. package/dist/esm/resilience/withRetry.js.map +1 -1
  170. package/dist/esm/strategies/compose.js +2 -2
  171. package/dist/esm/tool-providers/skillScopedTools.js +3 -3
  172. package/dist/events/registry.js +10 -0
  173. package/dist/events/registry.js.map +1 -1
  174. package/dist/index.js +26 -3
  175. package/dist/index.js.map +1 -1
  176. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +15 -8
  177. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  178. package/dist/lib/lazyRequire.js +6 -0
  179. package/dist/lib/lazyRequire.js.map +1 -1
  180. package/dist/lib/rag/defineRAG.js +4 -2
  181. package/dist/lib/rag/defineRAG.js.map +1 -1
  182. package/dist/lib/rag/indexDocuments.js +2 -2
  183. package/dist/locales/index.js +3 -3
  184. package/dist/memory/beats/heuristicExtractor.js +4 -4
  185. package/dist/memory/beats/heuristicExtractor.js.map +1 -1
  186. package/dist/memory/beats/index.js +13 -13
  187. package/dist/memory/beats/index.js.map +1 -1
  188. package/dist/memory/beats/llmExtractor.js +2 -2
  189. package/dist/memory/beats/llmExtractor.js.map +1 -1
  190. package/dist/memory/embedding/index.js +8 -8
  191. package/dist/memory/embedding/index.js.map +1 -1
  192. package/dist/memory/entry/index.js +3 -3
  193. package/dist/memory/entry/index.js.map +1 -1
  194. package/dist/memory/facts/extractFacts.js +2 -2
  195. package/dist/memory/facts/extractFacts.js.map +1 -1
  196. package/dist/memory/facts/index.js +17 -17
  197. package/dist/memory/facts/index.js.map +1 -1
  198. package/dist/memory/facts/llmFactExtractor.js +2 -2
  199. package/dist/memory/facts/llmFactExtractor.js.map +1 -1
  200. package/dist/memory/facts/loadFacts.js +2 -2
  201. package/dist/memory/facts/loadFacts.js.map +1 -1
  202. package/dist/memory/facts/patternFactExtractor.js +2 -2
  203. package/dist/memory/facts/patternFactExtractor.js.map +1 -1
  204. package/dist/memory/identity/index.js +2 -2
  205. package/dist/memory/identity/index.js.map +1 -1
  206. package/dist/memory/pipeline/auto.js +11 -11
  207. package/dist/memory/pipeline/auto.js.map +1 -1
  208. package/dist/memory/pipeline/default.js +8 -8
  209. package/dist/memory/pipeline/default.js.map +1 -1
  210. package/dist/memory/pipeline/ephemeral.js +6 -6
  211. package/dist/memory/pipeline/ephemeral.js.map +1 -1
  212. package/dist/memory/pipeline/fact.js +11 -11
  213. package/dist/memory/pipeline/fact.js.map +1 -1
  214. package/dist/memory/pipeline/index.js +12 -12
  215. package/dist/memory/pipeline/index.js.map +1 -1
  216. package/dist/memory/pipeline/narrative.js +12 -12
  217. package/dist/memory/pipeline/narrative.js.map +1 -1
  218. package/dist/memory/pipeline/semantic.js +10 -10
  219. package/dist/memory/pipeline/semantic.js.map +1 -1
  220. package/dist/memory/stages/index.js +13 -13
  221. package/dist/memory/stages/index.js.map +1 -1
  222. package/dist/memory/stages/pickByBudget.js +3 -3
  223. package/dist/memory/stages/pickByBudget.js.map +1 -1
  224. package/dist/memory/store/InMemoryStore.js +5 -5
  225. package/dist/memory/store/InMemoryStore.js.map +1 -1
  226. package/dist/memory/store/index.js +2 -2
  227. package/dist/memory/store/index.js.map +1 -1
  228. package/dist/memory/wire/index.js +4 -4
  229. package/dist/memory/wire/index.js.map +1 -1
  230. package/dist/recorders/core/ContextEvaluatedRecorder.js +35 -0
  231. package/dist/recorders/core/ContextEvaluatedRecorder.js.map +1 -0
  232. package/dist/recorders/core/ContextRecorder.js +11 -13
  233. package/dist/recorders/core/ContextRecorder.js.map +1 -1
  234. package/dist/recorders/core/ErrorBridge.js +64 -0
  235. package/dist/recorders/core/ErrorBridge.js.map +1 -0
  236. package/dist/recorders/core/ReliabilityRecorder.js +33 -0
  237. package/dist/recorders/core/ReliabilityRecorder.js.map +1 -0
  238. package/dist/recorders/core/typedEmit.js +1 -1
  239. package/dist/recorders/observability/BoundaryRecorder.js +26 -2
  240. package/dist/recorders/observability/BoundaryRecorder.js.map +1 -1
  241. package/dist/recorders/observability/LiveStateRecorder.js +8 -0
  242. package/dist/recorders/observability/LiveStateRecorder.js.map +1 -1
  243. package/dist/recorders/observability/commentary/commentaryTemplates.js +1 -0
  244. package/dist/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
  245. package/dist/reliability/buildReliabilityGateChart.js +10 -4
  246. package/dist/reliability/buildReliabilityGateChart.js.map +1 -1
  247. package/dist/resilience/withRetry.js +3 -0
  248. package/dist/resilience/withRetry.js.map +1 -1
  249. package/dist/strategies/compose.js +2 -2
  250. package/dist/tool-providers/skillScopedTools.js +3 -3
  251. package/dist/types/adapters/llm/createProvider.d.ts +3 -2
  252. package/dist/types/adapters/llm/createProvider.d.ts.map +1 -1
  253. package/dist/types/adapters/observability/agentcore.d.ts +1 -0
  254. package/dist/types/adapters/observability/agentcore.d.ts.map +1 -1
  255. package/dist/types/cache/CacheDecisionSubflow.d.ts +7 -10
  256. package/dist/types/cache/CacheDecisionSubflow.d.ts.map +1 -1
  257. package/dist/types/cache/CacheGateDecider.d.ts +16 -2
  258. package/dist/types/cache/CacheGateDecider.d.ts.map +1 -1
  259. package/dist/types/cache/cacheRecorder.d.ts.map +1 -1
  260. package/dist/types/conventions.d.ts +101 -1
  261. package/dist/types/conventions.d.ts.map +1 -1
  262. package/dist/types/core/Agent.d.ts +8 -0
  263. package/dist/types/core/Agent.d.ts.map +1 -1
  264. package/dist/types/core/LLMCall.d.ts +48 -12
  265. package/dist/types/core/LLMCall.d.ts.map +1 -1
  266. package/dist/types/core/RunnerBase.d.ts +12 -0
  267. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  268. package/dist/types/core/agent/buildAgentChart.d.ts +31 -18
  269. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  270. package/dist/types/core/agent/buildAgentMessageApiChart.d.ts +41 -0
  271. package/dist/types/core/agent/buildAgentMessageApiChart.d.ts.map +1 -0
  272. package/dist/types/core/agent/buildCacheSubflow.d.ts +36 -0
  273. package/dist/types/core/agent/buildCacheSubflow.d.ts.map +1 -0
  274. package/dist/types/core/agent/buildDynamicAgentChart.d.ts +57 -0
  275. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -0
  276. package/dist/types/core/agent/buildMessageApiChart.d.ts +48 -0
  277. package/dist/types/core/agent/buildMessageApiChart.d.ts.map +1 -0
  278. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  279. package/dist/types/core/agent/stages/reliabilityExecution.d.ts.map +1 -1
  280. package/dist/types/core/agent/types.d.ts +69 -2
  281. package/dist/types/core/agent/types.d.ts.map +1 -1
  282. package/dist/types/core/flowchartAsTool.d.ts +5 -5
  283. package/dist/types/core/humanizeLLMError.d.ts +24 -0
  284. package/dist/types/core/humanizeLLMError.d.ts.map +1 -0
  285. package/dist/types/core/slots/buildMessagesSlot.d.ts.map +1 -1
  286. package/dist/types/events/payloads.d.ts +84 -0
  287. package/dist/types/events/payloads.d.ts.map +1 -1
  288. package/dist/types/events/registry.d.ts +11 -1
  289. package/dist/types/events/registry.d.ts.map +1 -1
  290. package/dist/types/index.d.ts +4 -1
  291. package/dist/types/index.d.ts.map +1 -1
  292. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  293. package/dist/types/lib/lazyRequire.d.ts.map +1 -1
  294. package/dist/types/lib/rag/defineRAG.d.ts +4 -2
  295. package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
  296. package/dist/types/lib/rag/indexDocuments.d.ts +2 -2
  297. package/dist/types/locales/index.d.ts +3 -3
  298. package/dist/types/memory/beats/extractBeats.d.ts +4 -4
  299. package/dist/types/memory/beats/extractBeats.d.ts.map +1 -1
  300. package/dist/types/memory/beats/extractor.d.ts +2 -2
  301. package/dist/types/memory/beats/extractor.d.ts.map +1 -1
  302. package/dist/types/memory/beats/formatAsNarrative.d.ts +1 -1
  303. package/dist/types/memory/beats/formatAsNarrative.d.ts.map +1 -1
  304. package/dist/types/memory/beats/heuristicExtractor.d.ts +1 -1
  305. package/dist/types/memory/beats/heuristicExtractor.d.ts.map +1 -1
  306. package/dist/types/memory/beats/index.d.ts +12 -12
  307. package/dist/types/memory/beats/index.d.ts.map +1 -1
  308. package/dist/types/memory/beats/llmExtractor.d.ts +2 -2
  309. package/dist/types/memory/beats/llmExtractor.d.ts.map +1 -1
  310. package/dist/types/memory/beats/writeBeats.d.ts +2 -2
  311. package/dist/types/memory/beats/writeBeats.d.ts.map +1 -1
  312. package/dist/types/memory/embedding/embedMessages.d.ts +3 -3
  313. package/dist/types/memory/embedding/embedMessages.d.ts.map +1 -1
  314. package/dist/types/memory/embedding/index.d.ts +8 -8
  315. package/dist/types/memory/embedding/index.d.ts.map +1 -1
  316. package/dist/types/memory/embedding/loadRelevant.d.ts +3 -3
  317. package/dist/types/memory/embedding/loadRelevant.d.ts.map +1 -1
  318. package/dist/types/memory/embedding/mockEmbedder.d.ts +1 -1
  319. package/dist/types/memory/embedding/mockEmbedder.d.ts.map +1 -1
  320. package/dist/types/memory/entry/decay.d.ts +1 -1
  321. package/dist/types/memory/entry/decay.d.ts.map +1 -1
  322. package/dist/types/memory/entry/index.d.ts +2 -2
  323. package/dist/types/memory/entry/index.d.ts.map +1 -1
  324. package/dist/types/memory/entry/types.d.ts +1 -1
  325. package/dist/types/memory/entry/types.d.ts.map +1 -1
  326. package/dist/types/memory/facts/extractFacts.d.ts +4 -4
  327. package/dist/types/memory/facts/extractFacts.d.ts.map +1 -1
  328. package/dist/types/memory/facts/extractor.d.ts +2 -2
  329. package/dist/types/memory/facts/extractor.d.ts.map +1 -1
  330. package/dist/types/memory/facts/formatFacts.d.ts +3 -3
  331. package/dist/types/memory/facts/formatFacts.d.ts.map +1 -1
  332. package/dist/types/memory/facts/index.d.ts +14 -14
  333. package/dist/types/memory/facts/index.d.ts.map +1 -1
  334. package/dist/types/memory/facts/llmFactExtractor.d.ts +2 -2
  335. package/dist/types/memory/facts/llmFactExtractor.d.ts.map +1 -1
  336. package/dist/types/memory/facts/loadFacts.d.ts +2 -2
  337. package/dist/types/memory/facts/loadFacts.d.ts.map +1 -1
  338. package/dist/types/memory/facts/patternFactExtractor.d.ts +1 -1
  339. package/dist/types/memory/facts/patternFactExtractor.d.ts.map +1 -1
  340. package/dist/types/memory/facts/writeFacts.d.ts +2 -2
  341. package/dist/types/memory/facts/writeFacts.d.ts.map +1 -1
  342. package/dist/types/memory/identity/index.d.ts +2 -2
  343. package/dist/types/memory/identity/index.d.ts.map +1 -1
  344. package/dist/types/memory/pipeline/auto.d.ts +6 -6
  345. package/dist/types/memory/pipeline/auto.d.ts.map +1 -1
  346. package/dist/types/memory/pipeline/default.d.ts +2 -2
  347. package/dist/types/memory/pipeline/default.d.ts.map +1 -1
  348. package/dist/types/memory/pipeline/ephemeral.d.ts +2 -2
  349. package/dist/types/memory/pipeline/ephemeral.d.ts.map +1 -1
  350. package/dist/types/memory/pipeline/fact.d.ts +3 -3
  351. package/dist/types/memory/pipeline/fact.d.ts.map +1 -1
  352. package/dist/types/memory/pipeline/index.d.ts +13 -13
  353. package/dist/types/memory/pipeline/index.d.ts.map +1 -1
  354. package/dist/types/memory/pipeline/narrative.d.ts +3 -3
  355. package/dist/types/memory/pipeline/narrative.d.ts.map +1 -1
  356. package/dist/types/memory/pipeline/semantic.d.ts +3 -3
  357. package/dist/types/memory/pipeline/semantic.d.ts.map +1 -1
  358. package/dist/types/memory/pipeline/types.d.ts +1 -1
  359. package/dist/types/memory/pipeline/types.d.ts.map +1 -1
  360. package/dist/types/memory/stages/formatDefault.d.ts +3 -3
  361. package/dist/types/memory/stages/formatDefault.d.ts.map +1 -1
  362. package/dist/types/memory/stages/index.d.ts +13 -13
  363. package/dist/types/memory/stages/index.d.ts.map +1 -1
  364. package/dist/types/memory/stages/loadRecent.d.ts +2 -2
  365. package/dist/types/memory/stages/loadRecent.d.ts.map +1 -1
  366. package/dist/types/memory/stages/pickByBudget.d.ts +2 -2
  367. package/dist/types/memory/stages/pickByBudget.d.ts.map +1 -1
  368. package/dist/types/memory/stages/summarize.d.ts +2 -2
  369. package/dist/types/memory/stages/summarize.d.ts.map +1 -1
  370. package/dist/types/memory/stages/tokenize.d.ts +1 -1
  371. package/dist/types/memory/stages/tokenize.d.ts.map +1 -1
  372. package/dist/types/memory/stages/types.d.ts +3 -3
  373. package/dist/types/memory/stages/types.d.ts.map +1 -1
  374. package/dist/types/memory/stages/writeMessages.d.ts +3 -3
  375. package/dist/types/memory/stages/writeMessages.d.ts.map +1 -1
  376. package/dist/types/memory/store/InMemoryStore.d.ts +3 -3
  377. package/dist/types/memory/store/InMemoryStore.d.ts.map +1 -1
  378. package/dist/types/memory/store/index.d.ts +2 -2
  379. package/dist/types/memory/store/index.d.ts.map +1 -1
  380. package/dist/types/memory/store/types.d.ts +2 -2
  381. package/dist/types/memory/store/types.d.ts.map +1 -1
  382. package/dist/types/memory/wire/index.d.ts +2 -2
  383. package/dist/types/memory/wire/index.d.ts.map +1 -1
  384. package/dist/types/memory/wire/mountMemoryPipeline.d.ts +1 -1
  385. package/dist/types/memory/wire/mountMemoryPipeline.d.ts.map +1 -1
  386. package/dist/types/recorders/core/ContextEvaluatedRecorder.d.ts +24 -0
  387. package/dist/types/recorders/core/ContextEvaluatedRecorder.d.ts.map +1 -0
  388. package/dist/types/recorders/core/ContextRecorder.d.ts +0 -2
  389. package/dist/types/recorders/core/ContextRecorder.d.ts.map +1 -1
  390. package/dist/types/recorders/core/ErrorBridge.d.ts +39 -0
  391. package/dist/types/recorders/core/ErrorBridge.d.ts.map +1 -0
  392. package/dist/types/recorders/core/ReliabilityRecorder.d.ts +25 -0
  393. package/dist/types/recorders/core/ReliabilityRecorder.d.ts.map +1 -0
  394. package/dist/types/recorders/core/typedEmit.d.ts +1 -1
  395. package/dist/types/recorders/observability/BoundaryRecorder.d.ts +10 -2
  396. package/dist/types/recorders/observability/BoundaryRecorder.d.ts.map +1 -1
  397. package/dist/types/recorders/observability/LiveStateRecorder.d.ts.map +1 -1
  398. package/dist/types/recorders/observability/commentary/commentaryTemplates.d.ts.map +1 -1
  399. package/dist/types/recorders/observability/observeRunId.d.ts +1 -1
  400. package/dist/types/reliability/buildReliabilityGateChart.d.ts.map +1 -1
  401. package/dist/types/resilience/withRetry.d.ts +3 -0
  402. package/dist/types/resilience/withRetry.d.ts.map +1 -1
  403. package/dist/types/strategies/compose.d.ts +2 -2
  404. package/dist/types/tool-providers/skillScopedTools.d.ts +3 -3
  405. package/package.json +10 -5
  406. package/dist/core/agent/stages/iterationStart.js +0 -24
  407. package/dist/core/agent/stages/iterationStart.js.map +0 -1
  408. package/dist/esm/core/agent/stages/iterationStart.js +0 -20
  409. package/dist/esm/core/agent/stages/iterationStart.js.map +0 -1
  410. package/dist/types/core/agent/stages/iterationStart.d.ts +0 -16
  411. package/dist/types/core/agent/stages/iterationStart.d.ts.map +0 -1
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ /**
3
+ * buildDynamicAgentChart — the Dynamic-ReAct agent chart, where the
4
+ * whole LLM turn (context engineering + the call) is ONE `sf-llm-call`
5
+ * subflow, exactly like the `LLMCall` primitive produces.
6
+ *
7
+ * WHY a second builder (vs `buildAgentChart`)
8
+ * ───────────────────────────────────────────
9
+ * `buildAgentChart` mounts the LLM as a flat `call-llm` STAGE with the
10
+ * slot subflows as its siblings. That renders as nothing in Lens — a
11
+ * bare stage is dropped by the subflow-level collapser, so the slots
12
+ * have no LLM card to fold into and the chart comes up empty.
13
+ *
14
+ * This builder wraps that same region in an `sf-llm-call` SUBFLOW. The
15
+ * payoff is purely structural — Lens already maps `sf-llm-call → LLM
16
+ * group` (same boundary `LLMCall` produces), so the Dynamic agent
17
+ * renders as an LLM group with its slots inside, a peer Tool node, and
18
+ * the loop arc, with ZERO Lens-specific special-casing.
19
+ *
20
+ * The data flow is IDENTICAL to `buildAgentChart` — every stage handler
21
+ * + slot subflow is reused verbatim from the same `AgentChartDeps`. The
22
+ * ONLY new thing is the subflow boundary, which means:
23
+ *
24
+ * • A small inner seed (`dynamicTurnSeed`) initialises the per-turn
25
+ * working keys the OUTER seed used to set, since the inner subflow
26
+ * gets a fresh scope each loop re-entry.
27
+ * • Cross-iteration accumulators (token totals, cost counters,
28
+ * skill-history) round-trip out→in: the boundary `outputMapper`
29
+ * bubbles them to the outer scope, and the next iteration's
30
+ * `inputMapper` feeds them back under `prior*` aliases (because
31
+ * keys passed via `inputMapper` are FROZEN inside the subflow —
32
+ * `ScopeFacade.setValue` throws on them — so the writable working
33
+ * key must have a different name from the read-only input).
34
+ *
35
+ * Chart shape (mirrors the diagram the team locked):
36
+ *
37
+ * Initialize
38
+ * → [memory READ subflows]
39
+ * → sf-llm-call (SUBFLOW — same boundary LLMCall produces)
40
+ * dynamicTurnSeed → InjectionEngine
41
+ * → Context (selector, PARALLEL fan-out, failFast)
42
+ * ⇉ {System Prompt ‖ Messages ‖ Tools} → converge
43
+ * → UpdateSkillHistory → Cache (sf-cache subflow)
44
+ * → CallLLM (emits iteration_start) → [NormalizeThinking]
45
+ * → Route (decider)
46
+ * ├─ tool-calls (pausable) → loopTo(sf-llm-call) ← branch-sourced loop
47
+ * └─ sf-final (the answer) → terminal leaf
48
+ *
49
+ * Classic ReAct keeps using `buildAgentChart` until its own shape is
50
+ * designed — this builder is Dynamic-only.
51
+ */
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.buildDynamicAgentChart = void 0;
54
+ const advanced_1 = require("footprintjs/advanced");
55
+ const footprintjs_1 = require("footprintjs");
56
+ const conventions_js_1 = require("../../conventions.js");
57
+ const define_types_js_1 = require("../../memory/define.types.js");
58
+ const define_js_1 = require("../../memory/define.js");
59
+ const mountMemoryPipeline_js_1 = require("../../memory/wire/mountMemoryPipeline.js");
60
+ const breakFinal_js_1 = require("./stages/breakFinal.js");
61
+ const prepareFinal_js_1 = require("./stages/prepareFinal.js");
62
+ const buildCacheSubflow_js_1 = require("./buildCacheSubflow.js");
63
+ /**
64
+ * Inner seed for the `sf-llm-call` subflow. Initialises the per-turn
65
+ * working keys (the ones the OUTER seed set on the flat chart) and
66
+ * copies the cross-iteration accumulators from their read-only `prior*`
67
+ * inputs into the writable working keys.
68
+ *
69
+ * Why the `prior*` indirection: `inputMapper` values are frozen inside
70
+ * the subflow (any `scope.set` on them throws). callLLM does
71
+ * `scope.totalInputTokens += usage` — so `totalInputTokens` must be a
72
+ * writable working key, seeded here from the frozen `priorTotalInputTokens`.
73
+ */
74
+ function dynamicTurnSeed(scope) {
75
+ const args = scope.$getArgs();
76
+ // Cross-iteration accumulators — seed working keys from prior totals
77
+ // so they continue to accumulate across loop re-entries.
78
+ scope.totalInputTokens = args.priorTotalInputTokens ?? 0;
79
+ scope.totalOutputTokens = args.priorTotalOutputTokens ?? 0;
80
+ scope.cumTokensInput = args.priorCumTokensInput ?? 0;
81
+ scope.cumTokensOutput = args.priorCumTokensOutput ?? 0;
82
+ scope.cumEstimatedUsd = args.priorCumEstimatedUsd ?? 0;
83
+ scope.costBudgetHit = args.priorCostBudgetHit ?? false;
84
+ scope.skillHistory = args.priorSkillHistory ?? [];
85
+ // Per-iteration working keys — fresh each turn (slots + cache + callLLM
86
+ // populate these inside the subflow; nothing outside reads the
87
+ // injection arrays, so they stay subflow-internal).
88
+ scope.activeInjections = [];
89
+ scope.systemPromptInjections = [];
90
+ scope.messagesInjections = [];
91
+ scope.toolsInjections = [];
92
+ scope.cacheMarkers = [];
93
+ scope.llmLatestContent = '';
94
+ scope.llmLatestToolCalls = [];
95
+ scope.thinkingBlocks = [];
96
+ }
97
+ /**
98
+ * Build the Dynamic-ReAct agent chart from the shared `AgentChartDeps`.
99
+ */
100
+ function buildDynamicAgentChart(deps) {
101
+ // ── Final-branch subflow ─────────────────────────────────────
102
+ // Identical to buildAgentChart: PrepareFinal captures the turn
103
+ // payload, memory-write subflows persist it, BreakFinal terminates
104
+ // the ReAct loop. Lives in the OUTER chart (the final answer is a
105
+ // peer of the LLM turn, not part of it).
106
+ let finalBranchBuilder = (0, footprintjs_1.flowChart)('PrepareFinal', prepareFinal_js_1.prepareFinalStage, 'prepare-final', {
107
+ ...(deps.structureRecorders !== undefined && {
108
+ structureRecorders: [...deps.structureRecorders],
109
+ }),
110
+ description: 'Capture turn payload (finalContent + newMessages)',
111
+ });
112
+ for (const m of deps.memories) {
113
+ if (m.write) {
114
+ finalBranchBuilder = (0, mountMemoryPipeline_js_1.mountMemoryWrite)(finalBranchBuilder, {
115
+ pipeline: {
116
+ read: (0, define_js_1.unwrapMemoryFlowChart)(m.read),
117
+ write: (0, define_js_1.unwrapMemoryFlowChart)(m.write),
118
+ },
119
+ identityKey: 'runIdentity',
120
+ turnNumberKey: 'turnNumber',
121
+ contextTokensKey: 'contextTokensRemaining',
122
+ newMessagesKey: 'newMessages',
123
+ writeSubflowId: `sf-memory-write-${m.id}`,
124
+ });
125
+ }
126
+ }
127
+ const finalBranchChart = finalBranchBuilder
128
+ .addFunction('BreakFinal', breakFinal_js_1.breakFinalStage, 'break-final', 'Terminate the ReAct loop')
129
+ .build();
130
+ // ── Inner sf-llm-call subflow ────────────────────────────────
131
+ // The full context-engineering + call region. Every mount below is
132
+ // copied verbatim from buildAgentChart — only the PARENT scope is
133
+ // now the sf-llm-call scope instead of the flat agent scope, and
134
+ // the keys those mappers read are all present there (read-only keys
135
+ // via the boundary inputMapper, working keys via dynamicTurnSeed).
136
+ let inner = (0, footprintjs_1.flowChart)('TurnSeed', dynamicTurnSeed, 'turn-seed', {
137
+ ...(deps.structureRecorders !== undefined && {
138
+ structureRecorders: [...deps.structureRecorders],
139
+ }),
140
+ // The `LLMCall:` prefix is DELIBERATE and load-bearing: Lens reads it
141
+ // to render this subflow as an LLM group (the keystone goal), mirroring
142
+ // the marker LLMCall.ts emits. The agent-ness is carried by the OUTER
143
+ // chart's `Agent: ReAct loop` description — so this does NOT mislabel
144
+ // the agent boundary (confirmed in the proposal's 7-person review).
145
+ description: 'LLMCall: invocation internals',
146
+ })
147
+ .addSubFlowChartNext(conventions_js_1.SUBFLOW_IDS.INJECTION_ENGINE, deps.injectionEngineSubflow, 'Injection Engine', {
148
+ inputMapper: (parent) => ({
149
+ iteration: parent.iteration,
150
+ userMessage: parent.userMessage,
151
+ history: parent.history,
152
+ lastToolResult: parent.lastToolResult,
153
+ activatedInjectionIds: parent.activatedInjectionIds ?? [],
154
+ }),
155
+ outputMapper: (sf) => ({ activeInjections: sf.activeInjections }),
156
+ arrayMerge: advanced_1.ArrayMergeMode.Replace,
157
+ })
158
+ // ── Context assembly: the 3 slots run in PARALLEL (selector fan-out) ──
159
+ // Identical to buildAgentChart's fork, just nested inside the sf-llm-call
160
+ // inner chart. The slots are independent (each reads only InjectionEngine's
161
+ // activeInjections + turn-seed state, each writes a disjoint output key),
162
+ // so concurrent execution is faithful. failFast: true — a required slot
163
+ // that throws aborts the turn (the default allSettled would swallow it).
164
+ .addSelectorFunction('Context', ((scope) => (0, footprintjs_1.select)(scope, [
165
+ { when: () => true, then: conventions_js_1.SUBFLOW_IDS.SYSTEM_PROMPT, label: 'engineer system-prompt' },
166
+ { when: () => true, then: conventions_js_1.SUBFLOW_IDS.MESSAGES, label: 'engineer messages' },
167
+ { when: () => true, then: conventions_js_1.SUBFLOW_IDS.TOOLS, label: 'engineer tools' },
168
+ ])), conventions_js_1.STAGE_IDS.CONTEXT, 'Assemble request context: system-prompt + messages + tools (parallel)', { failFast: true })
169
+ // Branch mappers + arrayMerge:Replace VERBATIM from the former sequential
170
+ // mounts (Replace is load-bearing — loopTo would otherwise accumulate).
171
+ .addSubFlowChartBranch(conventions_js_1.SUBFLOW_IDS.SYSTEM_PROMPT, deps.systemPromptSubflow, 'System Prompt', {
172
+ inputMapper: (parent) => ({
173
+ userMessage: parent.userMessage,
174
+ iteration: parent.iteration,
175
+ activeInjections: parent.activeInjections,
176
+ }),
177
+ outputMapper: (sf) => ({ systemPromptInjections: sf.systemPromptInjections }),
178
+ arrayMerge: advanced_1.ArrayMergeMode.Replace,
179
+ })
180
+ .addSubFlowChartBranch(conventions_js_1.SUBFLOW_IDS.MESSAGES, deps.messagesSubflow, 'Messages', {
181
+ inputMapper: (parent) => ({
182
+ messages: parent.history,
183
+ iteration: parent.iteration,
184
+ activeInjections: parent.activeInjections,
185
+ }),
186
+ outputMapper: (sf) => ({ messagesInjections: sf.messagesInjections }),
187
+ arrayMerge: advanced_1.ArrayMergeMode.Replace,
188
+ })
189
+ .addSubFlowChartBranch(conventions_js_1.SUBFLOW_IDS.TOOLS, deps.toolsSubflow, 'Tools', {
190
+ inputMapper: (parent) => ({
191
+ iteration: parent.iteration,
192
+ activeInjections: parent.activeInjections,
193
+ activatedInjectionIds: parent.activatedInjectionIds,
194
+ runIdentity: parent.runIdentity,
195
+ }),
196
+ outputMapper: (sf) => ({
197
+ toolsInjections: sf.toolsInjections,
198
+ dynamicToolSchemas: sf.toolSchemas,
199
+ }),
200
+ arrayMerge: advanced_1.ArrayMergeMode.Replace,
201
+ // STRUCTURE-ONLY merge target. When skills are off, UpdateSkillHistory
202
+ // is omitted, so the fan-out must converge onto sf-cache instead — the
203
+ // convergeAt target has to be a node that actually exists.
204
+ convergeAt: deps.hasSkills ? conventions_js_1.STAGE_IDS.UPDATE_SKILL_HISTORY : conventions_js_1.SUBFLOW_IDS.CACHE,
205
+ })
206
+ .end();
207
+ // ── Skill-churn window (cache concern) — conditional mount ───────
208
+ // Mounted only when skills are registered (see buildAgentChart for the full
209
+ // rationale: with no skills the window can never show churn, so the stage is
210
+ // dead weight). UpdateSkillHistory stays in the loop (skillHistory must
211
+ // persist across iterations); sf-cache is the pure decision layer.
212
+ if (deps.hasSkills) {
213
+ inner = inner.addFunction('UpdateSkillHistory', deps.updateSkillHistoryStage, conventions_js_1.STAGE_IDS.UPDATE_SKILL_HISTORY, 'Update skill-history rolling window for CacheGate churn detection');
214
+ }
215
+ inner = inner
216
+ .addSubFlowChartNext(conventions_js_1.SUBFLOW_IDS.CACHE, (0, buildCacheSubflow_js_1.buildCacheSubflow)(), 'Cache', {
217
+ inputMapper: (parent) => ({
218
+ activeInjections: parent.activeInjections ?? [],
219
+ iteration: parent.iteration ?? 1,
220
+ maxIterations: parent.maxIterations ?? deps.maxIterations,
221
+ userMessage: parent.userMessage ?? '',
222
+ ...(parent.lastToolResult !== undefined && {
223
+ lastToolName: parent.lastToolResult?.toolName,
224
+ }),
225
+ cumulativeInputTokens: parent.totalInputTokens ?? 0,
226
+ systemPromptCachePolicy: deps.systemPromptCachePolicy,
227
+ cachingDisabled: parent.cachingDisabled ?? false,
228
+ recentHitRate: parent.recentHitRate,
229
+ skillHistory: parent.skillHistory ?? [],
230
+ }),
231
+ outputMapper: (sf) => ({ cacheMarkers: sf.cacheMarkers }),
232
+ arrayMerge: advanced_1.ArrayMergeMode.Replace,
233
+ })
234
+ // CallLLM emits the per-iteration `iteration_start` marker itself (no
235
+ // dedicated IterationStart stage — emitting is passive observability).
236
+ .addFunction('CallLLM', deps.callLLM, conventions_js_1.STAGE_IDS.CALL_LLM, 'LLM invocation');
237
+ if (deps.thinkingSubflow) {
238
+ inner = inner.addSubFlowChartNext(conventions_js_1.SUBFLOW_IDS.THINKING, deps.thinkingSubflow, 'NormalizeThinking', {
239
+ inputMapper: (parent) => ({
240
+ rawThinking: parent.rawThinking,
241
+ iteration: parent.iteration,
242
+ }),
243
+ outputMapper: (sf) => ({ thinkingBlocks: sf.thinkingBlocks }),
244
+ arrayMerge: advanced_1.ArrayMergeMode.Replace,
245
+ });
246
+ }
247
+ const llmCallSubflow = inner.build();
248
+ // ── Outer chart ──────────────────────────────────────────────
249
+ // Description prefix `Agent:` is the taxonomy marker Lens reads to
250
+ // flag this as a true agent boundary.
251
+ let builder = (0, footprintjs_1.flowChart)('Initialize', deps.seed, conventions_js_1.STAGE_IDS.SEED, {
252
+ ...(deps.structureRecorders !== undefined && {
253
+ structureRecorders: [...deps.structureRecorders],
254
+ }),
255
+ description: 'Agent: ReAct loop',
256
+ });
257
+ // Memory READ subflows — TURN_START timing (once per turn, OUTSIDE
258
+ // the LLM-call loop body). Each writes `memoryInjection_${id}` to the
259
+ // outer scope; the boundary inputMapper below threads those into the
260
+ // subflow so the slots consume them.
261
+ for (const m of deps.memories) {
262
+ builder = (0, mountMemoryPipeline_js_1.mountMemoryRead)(builder, {
263
+ pipeline: {
264
+ read: (0, define_js_1.unwrapMemoryFlowChart)(m.read),
265
+ ...(m.write !== undefined && { write: (0, define_js_1.unwrapMemoryFlowChart)(m.write) }),
266
+ },
267
+ identityKey: 'runIdentity',
268
+ turnNumberKey: 'turnNumber',
269
+ contextTokensKey: 'contextTokensRemaining',
270
+ injectionKey: (0, define_types_js_1.memoryInjectionKey)(m.id),
271
+ readSubflowId: `sf-memory-read-${m.id}`,
272
+ });
273
+ }
274
+ builder = builder
275
+ .addSubFlowChartNext(conventions_js_1.SUBFLOW_IDS.LLM_CALL, llmCallSubflow, 'LLM', {
276
+ inputMapper: (parent) => {
277
+ const p = parent;
278
+ // Per-memory injection content the slots consume inside.
279
+ const memoryKeys = {};
280
+ for (const m of deps.memories) {
281
+ const key = (0, define_types_js_1.memoryInjectionKey)(m.id);
282
+ memoryKeys[key] = p[key];
283
+ }
284
+ return {
285
+ // Read-only working inputs (stages read, never write these).
286
+ userMessage: p.userMessage,
287
+ iteration: p.iteration,
288
+ history: p.history,
289
+ maxIterations: p.maxIterations,
290
+ runIdentity: p.runIdentity,
291
+ cachingDisabled: p.cachingDisabled,
292
+ recentHitRate: p.recentHitRate,
293
+ activatedInjectionIds: p.activatedInjectionIds,
294
+ lastToolResult: p.lastToolResult,
295
+ ...memoryKeys,
296
+ // Cross-iteration accumulators under prior* aliases — frozen
297
+ // here, copied to writable working keys by dynamicTurnSeed.
298
+ priorTotalInputTokens: p.totalInputTokens,
299
+ priorTotalOutputTokens: p.totalOutputTokens,
300
+ priorCumTokensInput: p.cumTokensInput,
301
+ priorCumTokensOutput: p.cumTokensOutput,
302
+ priorCumEstimatedUsd: p.cumEstimatedUsd,
303
+ priorCostBudgetHit: p.costBudgetHit,
304
+ priorSkillHistory: p.skillHistory,
305
+ };
306
+ },
307
+ outputMapper: (sf) => {
308
+ const s = sf;
309
+ return {
310
+ // LLM result the outer Route / tool-calls / final read.
311
+ llmLatestContent: s.llmLatestContent,
312
+ llmLatestToolCalls: s.llmLatestToolCalls,
313
+ thinkingBlocks: s.thinkingBlocks,
314
+ // NOTE: dynamicToolSchemas is intentionally NOT bubbled out — it
315
+ // is written by the Tools slot and read ONLY by callLLM, both
316
+ // inside sf-llm-call. The outer Route reads llmLatestToolCalls
317
+ // (which IS bubbled above), not the schemas.
318
+ // Accumulators bubbled back for the next iteration's inputMapper.
319
+ totalInputTokens: s.totalInputTokens,
320
+ totalOutputTokens: s.totalOutputTokens,
321
+ cumTokensInput: s.cumTokensInput,
322
+ cumTokensOutput: s.cumTokensOutput,
323
+ cumEstimatedUsd: s.cumEstimatedUsd,
324
+ costBudgetHit: s.costBudgetHit,
325
+ skillHistory: s.skillHistory,
326
+ };
327
+ },
328
+ // llmLatestToolCalls / thinkingBlocks / skillHistory are arrays —
329
+ // REPLACE (not concat) so each turn overwrites the prior value.
330
+ arrayMerge: advanced_1.ArrayMergeMode.Replace,
331
+ })
332
+ .addDeciderFunction('Route', deps.routeDecider, conventions_js_1.SUBFLOW_IDS.ROUTE, 'ReAct routing')
333
+ .addPausableFunctionBranch('tool-calls', 'ToolCalls', deps.toolCallsHandler, 'Tool execution (pausable via pauseHere)',
334
+ // Branch-sourced loop: tool-calls loops back to the LLM-call subflow so
335
+ // every iteration re-runs the full context-engineering + call against the
336
+ // freshest outer state. Sourced from the BRANCH (not the decider) so the
337
+ // chart reads honestly — `ToolCalls → LLM` loops, `Final` terminates.
338
+ // Survives pause/resume (human-in-the-loop tool approval): the engine
339
+ // resolves the subflow loop target on resume — footprintjs
340
+ // FlowChartExecutor.resume + test/lib/pause/resume-branch-loop-subflow.
341
+ { loopTo: conventions_js_1.SUBFLOW_IDS.LLM_CALL })
342
+ .addSubFlowChartBranch(conventions_js_1.SUBFLOW_IDS.FINAL, finalBranchChart, 'Final', {
343
+ inputMapper: (parent) => {
344
+ const { finalContent: _f, newMessages: _nm, ...rest } = parent;
345
+ void _f;
346
+ void _nm;
347
+ return rest;
348
+ },
349
+ outputMapper: (sf) => ({
350
+ finalContent: sf.finalContent,
351
+ }),
352
+ // `final` is a terminal LEAF under the branch-sourced loop; propagateBreak
353
+ // is kept for the terminal onBreak signal (observability), not loop control.
354
+ propagateBreak: true,
355
+ })
356
+ .setDefault(conventions_js_1.SUBFLOW_IDS.FINAL)
357
+ .end();
358
+ // The ReAct loop is now sourced from the `tool-calls` branch (the
359
+ // `{ loopTo }` above), not the decider — so `Final` is a plain terminal leaf
360
+ // and the chart draws `ToolCalls → LLM` for the loop edge.
361
+ return builder.build();
362
+ }
363
+ exports.buildDynamicAgentChart = buildDynamicAgentChart;
364
+ //# sourceMappingURL=buildDynamicAgentChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildDynamicAgentChart.js","sourceRoot":"","sources":["../../../src/core/agent/buildDynamicAgentChart.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;;;AAEH,mDAAsD;AACtD,6CAAgD;AAGhD,yDAA8D;AAE9D,kEAAkE;AAClE,sDAA+D;AAC/D,qFAA6F;AAC7F,0DAAyD;AACzD,8DAA6D;AAC7D,iEAA2D;AAI3D;;;;;;;;;;GAUG;AACH,SAAS,eAAe,CAAC,KAA6B;IACpD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAQvB,CAAC;IAEL,qEAAqE;IACrE,yDAAyD;IACzD,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,IAAI,CAAC,CAAC;IACzD,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC,sBAAsB,IAAI,CAAC,CAAC;IAC3D,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,IAAI,CAAC,CAAC;IACrD,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,oBAAoB,IAAI,CAAC,CAAC;IACvD,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,oBAAoB,IAAI,CAAC,CAAC;IACvD,KAA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AAI,CAAC;QACd,CAAC;QACD,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACrB,YAAY,EAAE,EAAE,CAAC,YAAsB;SACxC,CAAC;QACF,2EAA2E;QAC3E,6EAA6E;QAC7E,cAAc,EAAE,IAAI;KACrB,CAAC;SACD,UAAU,CAAC,4BAAW,CAAC,KAAK,CAAC;SAC7B,GAAG,EAAE,CAAC;IACT,kEAAkE;IAClE,6EAA6E;IAC7E,2DAA2D;IAE3D,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAlTD,wDAkTC"}
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ /**
3
+ * buildMessageApiChart — PROOF of the locked "messageAPI merge-tree" shape
4
+ * (MENTAL_MODEL.md ★ LOCKED DESIGN), LLM-only (no tools subflow yet).
5
+ *
6
+ * This is Step 1 of the agreed build order: prove the Context-selector →
7
+ * slot subflows → messageAPI stage → Call-LLM tree works + renders, BEFORE
8
+ * bringing it to the Agent (Step 2 adds the tools subflow + the loop).
9
+ *
10
+ * Chart shape (LLM-only):
11
+ *
12
+ * Seed
13
+ * → Context (SELECTOR stage — picks which slots to engineer)
14
+ * ├─ sf-system-prompt ┐ (selected branches run in parallel)
15
+ * └─ sf-messages ──────┴─→ messageAPI stage (the join point)
16
+ * → Call-LLM
17
+ *
18
+ * WHY a selector (not a plain fork): "Context = Selector stage" — it RETURNS
19
+ * the list of slot branch ids to engineer this iteration, and `select()`
20
+ * captures evidence (which slots + why). That is what will unify Static and
21
+ * Dynamic agent in ONE chart later: Static picks only `messages` per loop;
22
+ * Dynamic also picks `system-prompt` (and `tools`) when they re-engineer.
23
+ * The picked-set IS the lit/unlit-pill signal. For this LLM-only proof the
24
+ * selector picks BOTH slots (a one-shot call engineers everything once).
25
+ *
26
+ * WHY messageAPI is a REAL stage: it assembles the LLM request bulk that the
27
+ * agent's `callLLM` builds invisibly today (callLLM.ts:132) — `systemPrompt`
28
+ * (separate field) + `messages` (the conversation, incl. tool-results) → the
29
+ * message-API payload. Making it a stage makes that assembly visible +
30
+ * inspectable in Lens/Trace. (Tools is a separate field added at Call-LLM —
31
+ * it joins in Step 2.)
32
+ *
33
+ * Slots are REAL subflows (reused verbatim: buildSystemPromptSlot /
34
+ * buildMessagesSlot) writing the convention INJECTION_KEYS, so ContextRecorder
35
+ * emits context.injected and Lens renders them — no bespoke collapser.
36
+ */
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.buildMessageApiChart = void 0;
39
+ const footprintjs_1 = require("footprintjs");
40
+ const conventions_js_1 = require("../../conventions.js");
41
+ const typedEmit_js_1 = require("../../recorders/core/typedEmit.js");
42
+ const buildSystemPromptSlot_js_1 = require("../slots/buildSystemPromptSlot.js");
43
+ const buildMessagesSlot_js_1 = require("../slots/buildMessagesSlot.js");
44
+ /**
45
+ * Build the LLM-only messageAPI merge-tree chart.
46
+ */
47
+ function buildMessageApiChart(deps) {
48
+ const { provider, model, systemPrompt } = deps;
49
+ // ── Context: the ROOT SELECTOR. It runs FIRST — initialising the per-call
50
+ // state from the run input (the old "seed" work, now folded in: there is no
51
+ // separate seed stage), then returning which slot branches to engineer.
52
+ //
53
+ // select() collects one `then` PER matching rule, so multi-select = one rule
54
+ // per slot (a single `then` array would be coerced to one bogus id). For a
55
+ // one-shot LLM call both slots match → both branches run. select() captures
56
+ // evidence so a consumer sees WHICH slots were chosen + why (the lit/unlit-
57
+ // pill source that later distinguishes Static vs Dynamic). ──
58
+ const contextSelector = (scope) => {
59
+ // Init (formerly the seed stage) — Context is the chart's first node.
60
+ const args = scope.$getArgs();
61
+ scope.userMessage = args.message;
62
+ scope.history = [{ role: 'user', content: args.message }];
63
+ scope.iteration = 1;
64
+ scope.systemPromptInjections = [];
65
+ scope.messagesInjections = [];
66
+ scope.assembledSystem = '';
67
+ scope.assembledMessages = [];
68
+ scope.answer = '';
69
+ return (0, footprintjs_1.select)(scope, [
70
+ { when: () => true, then: conventions_js_1.SUBFLOW_IDS.SYSTEM_PROMPT, label: 'engineer system-prompt' },
71
+ { when: () => true, then: conventions_js_1.SUBFLOW_IDS.MESSAGES, label: 'engineer messages' },
72
+ ]);
73
+ };
74
+ // ── messageAPI: assemble the request bulk (system + messages). This is
75
+ // the assembly callLLM does invisibly today, surfaced as a real stage. ──
76
+ const messageApiStage = (scope) => {
77
+ const sysInjections = (scope.systemPromptInjections ?? []);
78
+ scope.assembledSystem = sysInjections
79
+ .map((r) => r.rawContent ?? '')
80
+ .filter((s) => s.length > 0)
81
+ .join('\n\n');
82
+ // The conversation (incl. any tool-result messages) IS the message
83
+ // stream — read from history directly (same as the agent's callLLM).
84
+ // Materialise a plain array (history is a reactive proxy ref).
85
+ scope.assembledMessages = [...(scope.history ?? [])];
86
+ (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.context.slot_composed', {
87
+ slot: 'messages',
88
+ iteration: scope.iteration,
89
+ budget: { cap: 0, used: 0, headroomChars: 0 },
90
+ sourceBreakdown: {},
91
+ droppedCount: 0,
92
+ droppedSummaries: [],
93
+ });
94
+ };
95
+ // ── Call-LLM: send the assembled payload, write the answer. ──
96
+ const callLLM = async (scope) => {
97
+ const system = scope.assembledSystem;
98
+ const messages = (scope.assembledMessages ?? []);
99
+ (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.stream.llm_start', {
100
+ iteration: scope.iteration,
101
+ provider: provider.name,
102
+ model,
103
+ systemPromptChars: system.length,
104
+ messagesCount: messages.length,
105
+ toolsCount: 0,
106
+ });
107
+ const startMs = Date.now();
108
+ const response = await provider.complete({
109
+ ...(system.length > 0 && { systemPrompt: system }),
110
+ messages,
111
+ model,
112
+ });
113
+ scope.answer = response.content;
114
+ (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.stream.llm_end', {
115
+ iteration: scope.iteration,
116
+ content: response.content,
117
+ toolCallCount: response.toolCalls.length,
118
+ usage: response.usage,
119
+ stopReason: response.stopReason,
120
+ durationMs: Date.now() - startMs,
121
+ });
122
+ };
123
+ // ── Build the tree — Context is the ROOT selector (no seed stage). ──
124
+ const builder = (0, footprintjs_1.flowChartSelector)('Context', contextSelector, 'context', {
125
+ ...(deps.structureRecorders !== undefined && {
126
+ structureRecorders: [...deps.structureRecorders],
127
+ }),
128
+ // 'LLMCall:' taxonomy marker → Lens renders this as an LLM group.
129
+ description: 'LLMCall: messageAPI merge-tree',
130
+ })
131
+ .addSubFlowChartBranch(conventions_js_1.SUBFLOW_IDS.SYSTEM_PROMPT, (0, buildSystemPromptSlot_js_1.buildSystemPromptSlot)({ prompt: systemPrompt, reason: 'messageAPI proof' }), 'System Prompt', {
132
+ inputMapper: (parent) => ({
133
+ userMessage: parent.userMessage,
134
+ iteration: parent.iteration,
135
+ }),
136
+ outputMapper: (sf) => ({
137
+ systemPromptInjections: sf.systemPromptInjections,
138
+ }),
139
+ })
140
+ .addSubFlowChartBranch(conventions_js_1.SUBFLOW_IDS.MESSAGES, (0, buildMessagesSlot_js_1.buildMessagesSlot)(), 'Messages', {
141
+ inputMapper: (parent) => ({
142
+ messages: parent.history,
143
+ iteration: parent.iteration,
144
+ }),
145
+ outputMapper: (sf) => ({ messagesInjections: sf.messagesInjections }),
146
+ })
147
+ .end()
148
+ // Join point — runs after the selected slot branches converge.
149
+ .addFunction('messageAPI', messageApiStage, 'message-api', 'Assemble system + messages into the LLM request')
150
+ .addFunction('CallLLM', callLLM, 'call-llm', 'Send the assembled request to the LLM');
151
+ return builder.build();
152
+ }
153
+ exports.buildMessageApiChart = buildMessageApiChart;
154
+ //# sourceMappingURL=buildMessageApiChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildMessageApiChart.js","sourceRoot":"","sources":["../../../src/core/agent/buildMessageApiChart.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAEH,6CAAwD;AAGxD,yDAAmD;AAEnD,oEAA8D;AAC9D,gFAA0E;AAC1E,wEAAkE;AAyBlE;;GAEG;AACH,SAAgB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sB,CAAC,sBAAsB;SACvE,CAAC;KACH,CACF;SACA,qBAAqB,CAAC,4BAAW,CAAC,QAAQ,EAAE,IAAA,wCAAiB,GAAE,EAAE,UAAU,EAAE;QAC5E,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACxB,QAAQ,EAAG,MAA0B,CAAC,OAAO;YAC7C,SAAS,EAAG,MAA0B,CAAC,SAAS;SACjD,CAAC;QACF,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,kBAAkB,EAAG,EAAsB,CAAC,kBAAkB,EAAE,CAAC;KAC3F,CAAC;SACD,GAAG,EAAE;QACN,+DAA+D;SAC9D,WAAW,CACV,YAAY,EACZ,eAAwB,EACxB,aAAa,EACb,iDAAiD,CAClD;SACA,WAAW,CAAC,SAAS,EAAE,OAAgB,EAAE,UAAU,EAAE,uCAAuC,CAAC,CAAC;IAEjG,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AA9HD,oDA8HC"}
@@ -36,6 +36,15 @@ function buildCallLLMStage(deps) {
36
36
  // `scope.messagesInjections` is read by ContextRecorder for
37
37
  // observability; the LLM-wire path now reads scope.history directly.
38
38
  const iteration = scope.iteration;
39
+ // Per-iteration boundary marker (was a dedicated `IterationStart` stage —
40
+ // folded here since emitting is passive observability, not work that needs
41
+ // its own execution stage). Fires FIRST, before the LLM call, so recorders
42
+ // still bracket each ReAct iteration. Payload unchanged (turnIndex reserved
43
+ // for future multi-turn; iterIndex is the per-iteration counter).
44
+ (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.agent.iteration_start', {
45
+ turnIndex: 0,
46
+ iterIndex: iteration,
47
+ });
39
48
  const systemPrompt = systemPromptInjections
40
49
  .map((r) => r.rawContent ?? '')
41
50
  .filter((s) => s.length > 0)
@@ -123,6 +132,8 @@ function buildCallLLMStage(deps) {
123
132
  }
124
133
  if (!resp) {
125
134
  // No `stream()` OR stream finished without a response payload.
135
+ // Raw errors propagate so the reliability loop can classify them;
136
+ // friendly translation happens at the terminal ErrorBridge.
126
137
  resp = await deps.provider.complete(req);
127
138
  }
128
139
  return resp;
@@ -1 +1 @@
1
- {"version":3,"file":"callLLM.js","sourceRoot":"","sources":["../../../../src/core/agent/stages/callLLM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAYH,uEAAiE;AAEjE,2CAA6C;AAE7C,2DAAmF;AACnF,uEAImC;AA8CnC;;;;GAIG;AACH,SAAgB,iBAAiB,CAC/B,IAAsB;IAEtB,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,MAAM,sBAAsB,GACzB,KAAK,CAAC,sBAAqD,IAAI,EAAE,CAAC;QACrE,4DAA4D;QAC5D,qEAAqE;QACrE,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QAElC,MAAM,YAAY,GAAG,sBAAsB;aACxC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC;aAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;aAC3B,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhB,iEAAiE;QACjE,4DAA4D;QAC5D,kEAAkE;QAClE,mEAAmE;QACnE,gEAAgE;QAChE,qEAAqE;QACrE,MAAM,QAAQ,GAAI,KAAK,CAAC,OAA6C,IAAI,EAAE,CAAC;QAE5E,IAAA,wBAAS,EAAC,KAAK,EAAE,iCAAiC,EAAE;YAClD,SAAS;YACT,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;YAC5B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,iBAAiB,EAAE,YAAY,CAAC,MAAM;YACtC,aAAa,EAAE,QAAQ,CAAC,MAAM;YAC9B,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM;YACnC,GAAG,CAAC,IAAI,CAAC,WAAW,KA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