agentfootprint 9.136.0 → 9.138.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 (576) hide show
  1. package/AGENTS.md +1 -1
  2. package/CAPABILITIES.md +5 -0
  3. package/ai-instructions/claude-code/SKILL.md +1 -1
  4. package/dist/adapters/llm/AnthropicProvider.js +10 -2
  5. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  6. package/dist/adapters/llm/BrowserAnthropicProvider.js +8 -0
  7. package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  8. package/dist/adapters/llm/BrowserOpenAIProvider.js +30 -0
  9. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  10. package/dist/adapters/llm/FoundryProvider.js +2 -0
  11. package/dist/adapters/llm/FoundryProvider.js.map +1 -1
  12. package/dist/adapters/llm/InvokeModelGatewayProvider.js +16 -0
  13. package/dist/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
  14. package/dist/adapters/llm/MockProvider.js +3 -0
  15. package/dist/adapters/llm/MockProvider.js.map +1 -1
  16. package/dist/adapters/llm/OllamaProvider.js +7 -0
  17. package/dist/adapters/llm/OllamaProvider.js.map +1 -1
  18. package/dist/adapters/llm/OpenAIProvider.js +25 -0
  19. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  20. package/dist/adapters/llm/anthropicCacheWire.js +32 -10
  21. package/dist/adapters/llm/anthropicCacheWire.js.map +1 -1
  22. package/dist/adapters/llm/anthropicMessagesWire.js +12 -11
  23. package/dist/adapters/llm/anthropicMessagesWire.js.map +1 -1
  24. package/dist/adapters/types.js.map +1 -1
  25. package/dist/bridge/eventMeta.js +5 -1
  26. package/dist/bridge/eventMeta.js.map +1 -1
  27. package/dist/bridge/eventSourcePosition.js +63 -0
  28. package/dist/bridge/eventSourcePosition.js.map +1 -0
  29. package/dist/cache/CacheDecisionSubflow.js +79 -21
  30. package/dist/cache/CacheDecisionSubflow.js.map +1 -1
  31. package/dist/cache/cacheStrategyFor.js +77 -0
  32. package/dist/cache/cacheStrategyFor.js.map +1 -0
  33. package/dist/cache/index.js +26 -38
  34. package/dist/cache/index.js.map +1 -1
  35. package/dist/cache/strategies/AutomaticCacheStrategy.js +47 -0
  36. package/dist/cache/strategies/AutomaticCacheStrategy.js.map +1 -0
  37. package/dist/cache/strategies/BreakpointCacheStrategy.js +60 -0
  38. package/dist/cache/strategies/BreakpointCacheStrategy.js.map +1 -0
  39. package/dist/cache/strategies/NoOpCacheStrategy.js +9 -25
  40. package/dist/cache/strategies/NoOpCacheStrategy.js.map +1 -1
  41. package/dist/cache/types.js +5 -4
  42. package/dist/cache/types.js.map +1 -1
  43. package/dist/core/Agent.js +209 -146
  44. package/dist/core/Agent.js.map +1 -1
  45. package/dist/core/LLMCall.js +14 -17
  46. package/dist/core/LLMCall.js.map +1 -1
  47. package/dist/core/RunnerBase.js +17 -1
  48. package/dist/core/RunnerBase.js.map +1 -1
  49. package/dist/core/agent/AgentBuilder.js +24 -33
  50. package/dist/core/agent/AgentBuilder.js.map +1 -1
  51. package/dist/core/agent/act.js +3 -19
  52. package/dist/core/agent/act.js.map +1 -1
  53. package/dist/core/agent/assessment/stage.js +8 -0
  54. package/dist/core/agent/assessment/stage.js.map +1 -1
  55. package/dist/core/agent/buildAgentChart.js +8 -9
  56. package/dist/core/agent/buildAgentChart.js.map +1 -1
  57. package/dist/core/agent/buildCacheSubflow.js +4 -3
  58. package/dist/core/agent/buildCacheSubflow.js.map +1 -1
  59. package/dist/core/agent/buildDynamicAgentChart.js +16 -8
  60. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  61. package/dist/core/agent/honesty/mounts.js.map +1 -1
  62. package/dist/core/agent/middleware/ledger.js +1 -1
  63. package/dist/core/agent/middleware/messagePhase.js +24 -0
  64. package/dist/core/agent/middleware/messagePhase.js.map +1 -0
  65. package/dist/core/agent/skillBrains.js +3 -3
  66. package/dist/core/agent/skillBrains.js.map +1 -1
  67. package/dist/core/agent/stages/answerValidation.js +6 -3
  68. package/dist/core/agent/stages/answerValidation.js.map +1 -1
  69. package/dist/core/agent/stages/breakFinal.js +30 -1
  70. package/dist/core/agent/stages/breakFinal.js.map +1 -1
  71. package/dist/core/agent/stages/callLLM.js +15 -9
  72. package/dist/core/agent/stages/callLLM.js.map +1 -1
  73. package/dist/core/agent/stages/outputAdmission.js +14 -0
  74. package/dist/core/agent/stages/outputAdmission.js.map +1 -0
  75. package/dist/core/agent/stages/prepareFinal.js +96 -27
  76. package/dist/core/agent/stages/prepareFinal.js.map +1 -1
  77. package/dist/core/agent/stages/reliabilityExecution.js +46 -7
  78. package/dist/core/agent/stages/reliabilityExecution.js.map +1 -1
  79. package/dist/core/agent/stages/seed.js +8 -10
  80. package/dist/core/agent/stages/seed.js.map +1 -1
  81. package/dist/core/agent/stages/toolCalls.js +63 -42
  82. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  83. package/dist/core/agent/toolArgsValidation.js +35 -11
  84. package/dist/core/agent/toolArgsValidation.js.map +1 -1
  85. package/dist/core/agent/toolDispatch.js +8 -2
  86. package/dist/core/agent/toolDispatch.js.map +1 -1
  87. package/dist/core/agent/toolSecurityEvents.js +23 -0
  88. package/dist/core/agent/toolSecurityEvents.js.map +1 -0
  89. package/dist/core/codeRunnerTool.js +1 -0
  90. package/dist/core/codeRunnerTool.js.map +1 -1
  91. package/dist/core/conversation.js +21 -6
  92. package/dist/core/conversation.js.map +1 -1
  93. package/dist/core/slots/buildThinkingSubflow.js +2 -3
  94. package/dist/core/slots/buildThinkingSubflow.js.map +1 -1
  95. package/dist/core/terminalVerdict.js +48 -0
  96. package/dist/core/terminalVerdict.js.map +1 -0
  97. package/dist/core-flow/Conditional.js +14 -5
  98. package/dist/core-flow/Conditional.js.map +1 -1
  99. package/dist/core-flow/Graph.js +20 -3
  100. package/dist/core-flow/Graph.js.map +1 -1
  101. package/dist/core-flow/Loop.js +13 -6
  102. package/dist/core-flow/Loop.js.map +1 -1
  103. package/dist/core-flow/Parallel.js +16 -7
  104. package/dist/core-flow/Parallel.js.map +1 -1
  105. package/dist/core-flow/Sequence.js +16 -5
  106. package/dist/core-flow/Sequence.js.map +1 -1
  107. package/dist/core-flow/Workflow.js +20 -3
  108. package/dist/core-flow/Workflow.js.map +1 -1
  109. package/dist/core-flow/childOutcome.js +64 -0
  110. package/dist/core-flow/childOutcome.js.map +1 -0
  111. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +3 -1
  112. package/dist/esm/adapters/llm/AnthropicProvider.js +11 -3
  113. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  114. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +2 -0
  115. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +8 -0
  116. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  117. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +8 -0
  118. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +30 -0
  119. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  120. package/dist/esm/adapters/llm/FoundryProvider.js +2 -0
  121. package/dist/esm/adapters/llm/FoundryProvider.js.map +1 -1
  122. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.d.ts +1 -0
  123. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js +16 -0
  124. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
  125. package/dist/esm/adapters/llm/MockProvider.d.ts +2 -0
  126. package/dist/esm/adapters/llm/MockProvider.js +3 -0
  127. package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
  128. package/dist/esm/adapters/llm/OllamaProvider.d.ts +1 -0
  129. package/dist/esm/adapters/llm/OllamaProvider.js +7 -0
  130. package/dist/esm/adapters/llm/OllamaProvider.js.map +1 -1
  131. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +5 -0
  132. package/dist/esm/adapters/llm/OpenAIProvider.js +25 -0
  133. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  134. package/dist/esm/adapters/llm/anthropicCacheWire.d.ts +27 -9
  135. package/dist/esm/adapters/llm/anthropicCacheWire.js +31 -9
  136. package/dist/esm/adapters/llm/anthropicCacheWire.js.map +1 -1
  137. package/dist/esm/adapters/llm/anthropicMessagesWire.d.ts +1 -1
  138. package/dist/esm/adapters/llm/anthropicMessagesWire.js +12 -11
  139. package/dist/esm/adapters/llm/anthropicMessagesWire.js.map +1 -1
  140. package/dist/esm/adapters/types.d.ts +13 -0
  141. package/dist/esm/adapters/types.js.map +1 -1
  142. package/dist/esm/bridge/eventMeta.d.ts +5 -1
  143. package/dist/esm/bridge/eventMeta.js +5 -1
  144. package/dist/esm/bridge/eventMeta.js.map +1 -1
  145. package/dist/esm/bridge/eventSourcePosition.d.ts +10 -0
  146. package/dist/esm/bridge/eventSourcePosition.js +59 -0
  147. package/dist/esm/bridge/eventSourcePosition.js.map +1 -0
  148. package/dist/esm/cache/CacheDecisionSubflow.d.ts +44 -8
  149. package/dist/esm/cache/CacheDecisionSubflow.js +77 -19
  150. package/dist/esm/cache/CacheDecisionSubflow.js.map +1 -1
  151. package/dist/esm/cache/cacheStrategyFor.d.ts +42 -0
  152. package/dist/esm/cache/cacheStrategyFor.js +73 -0
  153. package/dist/esm/cache/cacheStrategyFor.js.map +1 -0
  154. package/dist/esm/cache/index.d.ts +20 -29
  155. package/dist/esm/cache/index.js +22 -31
  156. package/dist/esm/cache/index.js.map +1 -1
  157. package/dist/esm/cache/strategies/AutomaticCacheStrategy.d.ts +37 -0
  158. package/dist/esm/cache/strategies/AutomaticCacheStrategy.js +43 -0
  159. package/dist/esm/cache/strategies/AutomaticCacheStrategy.js.map +1 -0
  160. package/dist/esm/cache/strategies/BreakpointCacheStrategy.d.ts +40 -0
  161. package/dist/esm/cache/strategies/BreakpointCacheStrategy.js +56 -0
  162. package/dist/esm/cache/strategies/BreakpointCacheStrategy.js.map +1 -0
  163. package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +8 -18
  164. package/dist/esm/cache/strategies/NoOpCacheStrategy.js +9 -25
  165. package/dist/esm/cache/strategies/NoOpCacheStrategy.js.map +1 -1
  166. package/dist/esm/cache/types.d.ts +79 -78
  167. package/dist/esm/cache/types.js +5 -4
  168. package/dist/esm/cache/types.js.map +1 -1
  169. package/dist/esm/core/Agent.d.ts +36 -10
  170. package/dist/esm/core/Agent.js +210 -147
  171. package/dist/esm/core/Agent.js.map +1 -1
  172. package/dist/esm/core/LLMCall.d.ts +3 -4
  173. package/dist/esm/core/LLMCall.js +15 -18
  174. package/dist/esm/core/LLMCall.js.map +1 -1
  175. package/dist/esm/core/RunnerBase.d.ts +11 -0
  176. package/dist/esm/core/RunnerBase.js +15 -0
  177. package/dist/esm/core/RunnerBase.js.map +1 -1
  178. package/dist/esm/core/agent/AgentBuilder.d.ts +24 -33
  179. package/dist/esm/core/agent/AgentBuilder.js +24 -33
  180. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  181. package/dist/esm/core/agent/act.d.ts +5 -2
  182. package/dist/esm/core/agent/act.js +3 -19
  183. package/dist/esm/core/agent/act.js.map +1 -1
  184. package/dist/esm/core/agent/assessment/stage.d.ts +2 -0
  185. package/dist/esm/core/agent/assessment/stage.js +8 -0
  186. package/dist/esm/core/agent/assessment/stage.js.map +1 -1
  187. package/dist/esm/core/agent/buildAgentChart.d.ts +5 -1
  188. package/dist/esm/core/agent/buildAgentChart.js +9 -10
  189. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  190. package/dist/esm/core/agent/buildCacheSubflow.d.ts +4 -2
  191. package/dist/esm/core/agent/buildCacheSubflow.js +5 -4
  192. package/dist/esm/core/agent/buildCacheSubflow.js.map +1 -1
  193. package/dist/esm/core/agent/buildDynamicAgentChart.js +17 -9
  194. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  195. package/dist/esm/core/agent/honesty/mounts.d.ts +2 -0
  196. package/dist/esm/core/agent/honesty/mounts.js.map +1 -1
  197. package/dist/esm/core/agent/middleware/ledger.d.ts +1 -1
  198. package/dist/esm/core/agent/middleware/ledger.js +1 -1
  199. package/dist/esm/core/agent/middleware/messagePhase.d.ts +5 -0
  200. package/dist/esm/core/agent/middleware/messagePhase.js +19 -0
  201. package/dist/esm/core/agent/middleware/messagePhase.js.map +1 -0
  202. package/dist/esm/core/agent/skillBrains.d.ts +5 -3
  203. package/dist/esm/core/agent/skillBrains.js +3 -3
  204. package/dist/esm/core/agent/skillBrains.js.map +1 -1
  205. package/dist/esm/core/agent/stages/answerValidation.d.ts +6 -1
  206. package/dist/esm/core/agent/stages/answerValidation.js +6 -3
  207. package/dist/esm/core/agent/stages/answerValidation.js.map +1 -1
  208. package/dist/esm/core/agent/stages/breakFinal.d.ts +16 -0
  209. package/dist/esm/core/agent/stages/breakFinal.js +27 -0
  210. package/dist/esm/core/agent/stages/breakFinal.js.map +1 -1
  211. package/dist/esm/core/agent/stages/callLLM.d.ts +3 -1
  212. package/dist/esm/core/agent/stages/callLLM.js +15 -9
  213. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  214. package/dist/esm/core/agent/stages/outputAdmission.d.ts +6 -0
  215. package/dist/esm/core/agent/stages/outputAdmission.js +10 -0
  216. package/dist/esm/core/agent/stages/outputAdmission.js.map +1 -0
  217. package/dist/esm/core/agent/stages/prepareFinal.d.ts +18 -41
  218. package/dist/esm/core/agent/stages/prepareFinal.js +93 -25
  219. package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -1
  220. package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +8 -1
  221. package/dist/esm/core/agent/stages/reliabilityExecution.js +46 -7
  222. package/dist/esm/core/agent/stages/reliabilityExecution.js.map +1 -1
  223. package/dist/esm/core/agent/stages/seed.js +8 -10
  224. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  225. package/dist/esm/core/agent/stages/toolCalls.js +63 -42
  226. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  227. package/dist/esm/core/agent/toolArgsValidation.d.ts +9 -5
  228. package/dist/esm/core/agent/toolArgsValidation.js +35 -11
  229. package/dist/esm/core/agent/toolArgsValidation.js.map +1 -1
  230. package/dist/esm/core/agent/toolDispatch.d.ts +3 -2
  231. package/dist/esm/core/agent/toolDispatch.js +8 -2
  232. package/dist/esm/core/agent/toolDispatch.js.map +1 -1
  233. package/dist/esm/core/agent/toolSecurityEvents.d.ts +18 -0
  234. package/dist/esm/core/agent/toolSecurityEvents.js +19 -0
  235. package/dist/esm/core/agent/toolSecurityEvents.js.map +1 -0
  236. package/dist/esm/core/agent/types.d.ts +4 -4
  237. package/dist/esm/core/codeRunnerTool.js +1 -0
  238. package/dist/esm/core/codeRunnerTool.js.map +1 -1
  239. package/dist/esm/core/conversation.d.ts +16 -1
  240. package/dist/esm/core/conversation.js +20 -5
  241. package/dist/esm/core/conversation.js.map +1 -1
  242. package/dist/esm/core/slots/buildThinkingSubflow.d.ts +2 -2
  243. package/dist/esm/core/slots/buildThinkingSubflow.js +2 -3
  244. package/dist/esm/core/slots/buildThinkingSubflow.js.map +1 -1
  245. package/dist/esm/core/terminalVerdict.d.ts +56 -0
  246. package/dist/esm/core/terminalVerdict.js +43 -0
  247. package/dist/esm/core/terminalVerdict.js.map +1 -0
  248. package/dist/esm/core-flow/Conditional.js +15 -6
  249. package/dist/esm/core-flow/Conditional.js.map +1 -1
  250. package/dist/esm/core-flow/Graph.js +21 -4
  251. package/dist/esm/core-flow/Graph.js.map +1 -1
  252. package/dist/esm/core-flow/Loop.js +14 -7
  253. package/dist/esm/core-flow/Loop.js.map +1 -1
  254. package/dist/esm/core-flow/Parallel.js +17 -8
  255. package/dist/esm/core-flow/Parallel.js.map +1 -1
  256. package/dist/esm/core-flow/Sequence.js +17 -6
  257. package/dist/esm/core-flow/Sequence.js.map +1 -1
  258. package/dist/esm/core-flow/Workflow.js +21 -4
  259. package/dist/esm/core-flow/Workflow.js.map +1 -1
  260. package/dist/esm/core-flow/childOutcome.d.ts +47 -0
  261. package/dist/esm/core-flow/childOutcome.js +57 -0
  262. package/dist/esm/core-flow/childOutcome.js.map +1 -0
  263. package/dist/esm/events/payloads.d.ts +33 -11
  264. package/dist/esm/events/types.d.ts +32 -2
  265. package/dist/esm/index.d.ts +1 -11
  266. package/dist/esm/index.js +5 -10
  267. package/dist/esm/index.js.map +1 -1
  268. package/dist/esm/lib/injection-engine/skillToolDescriptors.js +1 -0
  269. package/dist/esm/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  270. package/dist/esm/lib/mcp/mcpServe.js +11 -4
  271. package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
  272. package/dist/esm/lib/time-travel/receipt.d.ts +5 -5
  273. package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +1 -1
  274. package/dist/esm/lib/trace-toolpack/debugPrompt.js +1 -0
  275. package/dist/esm/lib/trace-toolpack/debugPrompt.js.map +1 -1
  276. package/dist/esm/lib/trace-toolpack/innerDescent.d.ts +58 -0
  277. package/dist/esm/lib/trace-toolpack/innerDescent.js +68 -0
  278. package/dist/esm/lib/trace-toolpack/innerDescent.js.map +1 -0
  279. package/dist/esm/lib/trace-toolpack/subflowRecords.d.ts +55 -0
  280. package/dist/esm/lib/trace-toolpack/subflowRecords.js +124 -0
  281. package/dist/esm/lib/trace-toolpack/subflowRecords.js.map +1 -0
  282. package/dist/esm/lib/trace-toolpack/traceToolNames.d.ts +1 -1
  283. package/dist/esm/lib/trace-toolpack/traceToolNames.js +1 -0
  284. package/dist/esm/lib/trace-toolpack/traceToolNames.js.map +1 -1
  285. package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +1 -0
  286. package/dist/esm/lib/trace-toolpack/traceToolpack.js +282 -56
  287. package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -1
  288. package/dist/esm/lib/trust-boundaries/capture.d.ts +6 -0
  289. package/dist/esm/lib/trust-boundaries/capture.js +161 -0
  290. package/dist/esm/lib/trust-boundaries/capture.js.map +1 -0
  291. package/dist/esm/lib/trust-boundaries/index.d.ts +2 -0
  292. package/dist/esm/lib/trust-boundaries/index.js +2 -0
  293. package/dist/esm/lib/trust-boundaries/index.js.map +1 -0
  294. package/dist/esm/lib/trust-boundaries/project.d.ts +13 -0
  295. package/dist/esm/lib/trust-boundaries/project.js +170 -0
  296. package/dist/esm/lib/trust-boundaries/project.js.map +1 -0
  297. package/dist/esm/lib/trust-boundaries/types.d.ts +81 -0
  298. package/dist/esm/lib/trust-boundaries/types.js +2 -0
  299. package/dist/esm/lib/trust-boundaries/types.js.map +1 -0
  300. package/dist/esm/observe.d.ts +1 -0
  301. package/dist/esm/observe.js +3 -0
  302. package/dist/esm/observe.js.map +1 -1
  303. package/dist/esm/package.json +1 -1
  304. package/dist/esm/patterns/LlmRouter.js +6 -3
  305. package/dist/esm/patterns/LlmRouter.js.map +1 -1
  306. package/dist/esm/recorders/core/EmitBridge.js +7 -1
  307. package/dist/esm/recorders/core/EmitBridge.js.map +1 -1
  308. package/dist/esm/recorders/observability/recordRun.d.ts +29 -4
  309. package/dist/esm/recorders/observability/recordRun.js +144 -70
  310. package/dist/esm/recorders/observability/recordRun.js.map +1 -1
  311. package/dist/esm/recorders/observability/recordingEnvelope.js +5 -3
  312. package/dist/esm/recorders/observability/recordingEnvelope.js.map +1 -1
  313. package/dist/esm/reliability/failFastRecord.d.ts +28 -0
  314. package/dist/esm/reliability/failFastRecord.js +45 -0
  315. package/dist/esm/reliability/failFastRecord.js.map +1 -0
  316. package/dist/esm/resilience/withCircuitBreaker.js +3 -0
  317. package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
  318. package/dist/esm/resilience/withFallback.js +101 -11
  319. package/dist/esm/resilience/withFallback.js.map +1 -1
  320. package/dist/esm/resilience/withRetry.js +8 -0
  321. package/dist/esm/resilience/withRetry.js.map +1 -1
  322. package/dist/esm/thinking/AnthropicThinkingHandler.js +5 -5
  323. package/dist/esm/thinking/AnthropicThinkingHandler.js.map +1 -1
  324. package/dist/esm/thinking/MockThinkingHandler.js +2 -3
  325. package/dist/esm/thinking/MockThinkingHandler.js.map +1 -1
  326. package/dist/esm/thinking/OllamaThinkingHandler.js +0 -1
  327. package/dist/esm/thinking/OllamaThinkingHandler.js.map +1 -1
  328. package/dist/esm/thinking/OpenAIThinkingHandler.js +0 -1
  329. package/dist/esm/thinking/OpenAIThinkingHandler.js.map +1 -1
  330. package/dist/esm/thinking/index.d.ts +8 -7
  331. package/dist/esm/thinking/index.js +8 -7
  332. package/dist/esm/thinking/index.js.map +1 -1
  333. package/dist/esm/thinking/registry.d.ts +13 -23
  334. package/dist/esm/thinking/registry.js +13 -29
  335. package/dist/esm/thinking/registry.js.map +1 -1
  336. package/dist/esm/thinking/thinkingHandlerFor.d.ts +27 -0
  337. package/dist/esm/thinking/thinkingHandlerFor.js +36 -0
  338. package/dist/esm/thinking/thinkingHandlerFor.js.map +1 -0
  339. package/dist/esm/thinking/types.d.ts +7 -15
  340. package/dist/esm/thinking/types.js +3 -3
  341. package/dist/index.js +5 -10
  342. package/dist/index.js.map +1 -1
  343. package/dist/lib/injection-engine/skillToolDescriptors.js +1 -0
  344. package/dist/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  345. package/dist/lib/mcp/mcpServe.js +11 -4
  346. package/dist/lib/mcp/mcpServe.js.map +1 -1
  347. package/dist/lib/trace-toolpack/debugPrompt.js +1 -0
  348. package/dist/lib/trace-toolpack/debugPrompt.js.map +1 -1
  349. package/dist/lib/trace-toolpack/innerDescent.js +74 -0
  350. package/dist/lib/trace-toolpack/innerDescent.js.map +1 -0
  351. package/dist/lib/trace-toolpack/subflowRecords.js +134 -0
  352. package/dist/lib/trace-toolpack/subflowRecords.js.map +1 -0
  353. package/dist/lib/trace-toolpack/traceToolNames.js +1 -0
  354. package/dist/lib/trace-toolpack/traceToolNames.js.map +1 -1
  355. package/dist/lib/trace-toolpack/traceToolpack.js +282 -56
  356. package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -1
  357. package/dist/lib/trust-boundaries/capture.js +165 -0
  358. package/dist/lib/trust-boundaries/capture.js.map +1 -0
  359. package/dist/lib/trust-boundaries/index.js +6 -0
  360. package/dist/lib/trust-boundaries/index.js.map +1 -0
  361. package/dist/lib/trust-boundaries/project.js +174 -0
  362. package/dist/lib/trust-boundaries/project.js.map +1 -0
  363. package/dist/lib/trust-boundaries/types.js +3 -0
  364. package/dist/lib/trust-boundaries/types.js.map +1 -0
  365. package/dist/observe.js +17 -13
  366. package/dist/observe.js.map +1 -1
  367. package/dist/patterns/LlmRouter.js +5 -2
  368. package/dist/patterns/LlmRouter.js.map +1 -1
  369. package/dist/recorders/core/EmitBridge.js +7 -1
  370. package/dist/recorders/core/EmitBridge.js.map +1 -1
  371. package/dist/recorders/observability/recordRun.js +144 -70
  372. package/dist/recorders/observability/recordRun.js.map +1 -1
  373. package/dist/recorders/observability/recordingEnvelope.js +5 -3
  374. package/dist/recorders/observability/recordingEnvelope.js.map +1 -1
  375. package/dist/reliability/failFastRecord.js +50 -0
  376. package/dist/reliability/failFastRecord.js.map +1 -0
  377. package/dist/resilience/withCircuitBreaker.js +3 -0
  378. package/dist/resilience/withCircuitBreaker.js.map +1 -1
  379. package/dist/resilience/withFallback.js +101 -11
  380. package/dist/resilience/withFallback.js.map +1 -1
  381. package/dist/resilience/withRetry.js +8 -0
  382. package/dist/resilience/withRetry.js.map +1 -1
  383. package/dist/thinking/AnthropicThinkingHandler.js +5 -5
  384. package/dist/thinking/AnthropicThinkingHandler.js.map +1 -1
  385. package/dist/thinking/MockThinkingHandler.js +2 -3
  386. package/dist/thinking/MockThinkingHandler.js.map +1 -1
  387. package/dist/thinking/OllamaThinkingHandler.js +0 -1
  388. package/dist/thinking/OllamaThinkingHandler.js.map +1 -1
  389. package/dist/thinking/OpenAIThinkingHandler.js +0 -1
  390. package/dist/thinking/OpenAIThinkingHandler.js.map +1 -1
  391. package/dist/thinking/index.js +9 -8
  392. package/dist/thinking/index.js.map +1 -1
  393. package/dist/thinking/registry.js +14 -31
  394. package/dist/thinking/registry.js.map +1 -1
  395. package/dist/thinking/thinkingHandlerFor.js +40 -0
  396. package/dist/thinking/thinkingHandlerFor.js.map +1 -0
  397. package/dist/thinking/types.js +3 -3
  398. package/dist/types/adapters/llm/AnthropicProvider.d.ts +3 -1
  399. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  400. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +2 -0
  401. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
  402. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +8 -0
  403. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  404. package/dist/types/adapters/llm/FoundryProvider.d.ts.map +1 -1
  405. package/dist/types/adapters/llm/InvokeModelGatewayProvider.d.ts +1 -0
  406. package/dist/types/adapters/llm/InvokeModelGatewayProvider.d.ts.map +1 -1
  407. package/dist/types/adapters/llm/MockProvider.d.ts +2 -0
  408. package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
  409. package/dist/types/adapters/llm/OllamaProvider.d.ts +1 -0
  410. package/dist/types/adapters/llm/OllamaProvider.d.ts.map +1 -1
  411. package/dist/types/adapters/llm/OpenAIProvider.d.ts +5 -0
  412. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  413. package/dist/types/adapters/llm/anthropicCacheWire.d.ts +27 -9
  414. package/dist/types/adapters/llm/anthropicCacheWire.d.ts.map +1 -1
  415. package/dist/types/adapters/llm/anthropicMessagesWire.d.ts +1 -1
  416. package/dist/types/adapters/llm/anthropicMessagesWire.d.ts.map +1 -1
  417. package/dist/types/adapters/types.d.ts +13 -0
  418. package/dist/types/adapters/types.d.ts.map +1 -1
  419. package/dist/types/bridge/eventMeta.d.ts +5 -1
  420. package/dist/types/bridge/eventMeta.d.ts.map +1 -1
  421. package/dist/types/bridge/eventSourcePosition.d.ts +11 -0
  422. package/dist/types/bridge/eventSourcePosition.d.ts.map +1 -0
  423. package/dist/types/cache/CacheDecisionSubflow.d.ts +44 -8
  424. package/dist/types/cache/CacheDecisionSubflow.d.ts.map +1 -1
  425. package/dist/types/cache/cacheStrategyFor.d.ts +43 -0
  426. package/dist/types/cache/cacheStrategyFor.d.ts.map +1 -0
  427. package/dist/types/cache/index.d.ts +20 -29
  428. package/dist/types/cache/index.d.ts.map +1 -1
  429. package/dist/types/cache/strategies/AutomaticCacheStrategy.d.ts +38 -0
  430. package/dist/types/cache/strategies/AutomaticCacheStrategy.d.ts.map +1 -0
  431. package/dist/types/cache/strategies/BreakpointCacheStrategy.d.ts +41 -0
  432. package/dist/types/cache/strategies/BreakpointCacheStrategy.d.ts.map +1 -0
  433. package/dist/types/cache/strategies/NoOpCacheStrategy.d.ts +8 -18
  434. package/dist/types/cache/strategies/NoOpCacheStrategy.d.ts.map +1 -1
  435. package/dist/types/cache/types.d.ts +79 -78
  436. package/dist/types/cache/types.d.ts.map +1 -1
  437. package/dist/types/core/Agent.d.ts +36 -10
  438. package/dist/types/core/Agent.d.ts.map +1 -1
  439. package/dist/types/core/LLMCall.d.ts +3 -4
  440. package/dist/types/core/LLMCall.d.ts.map +1 -1
  441. package/dist/types/core/RunnerBase.d.ts +11 -0
  442. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  443. package/dist/types/core/agent/AgentBuilder.d.ts +24 -33
  444. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  445. package/dist/types/core/agent/act.d.ts +5 -2
  446. package/dist/types/core/agent/act.d.ts.map +1 -1
  447. package/dist/types/core/agent/assessment/stage.d.ts +2 -0
  448. package/dist/types/core/agent/assessment/stage.d.ts.map +1 -1
  449. package/dist/types/core/agent/buildAgentChart.d.ts +5 -1
  450. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  451. package/dist/types/core/agent/buildCacheSubflow.d.ts +4 -2
  452. package/dist/types/core/agent/buildCacheSubflow.d.ts.map +1 -1
  453. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  454. package/dist/types/core/agent/honesty/mounts.d.ts +2 -0
  455. package/dist/types/core/agent/honesty/mounts.d.ts.map +1 -1
  456. package/dist/types/core/agent/middleware/ledger.d.ts +1 -1
  457. package/dist/types/core/agent/middleware/messagePhase.d.ts +6 -0
  458. package/dist/types/core/agent/middleware/messagePhase.d.ts.map +1 -0
  459. package/dist/types/core/agent/skillBrains.d.ts +5 -3
  460. package/dist/types/core/agent/skillBrains.d.ts.map +1 -1
  461. package/dist/types/core/agent/stages/answerValidation.d.ts +6 -1
  462. package/dist/types/core/agent/stages/answerValidation.d.ts.map +1 -1
  463. package/dist/types/core/agent/stages/breakFinal.d.ts +16 -0
  464. package/dist/types/core/agent/stages/breakFinal.d.ts.map +1 -1
  465. package/dist/types/core/agent/stages/callLLM.d.ts +3 -1
  466. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  467. package/dist/types/core/agent/stages/outputAdmission.d.ts +7 -0
  468. package/dist/types/core/agent/stages/outputAdmission.d.ts.map +1 -0
  469. package/dist/types/core/agent/stages/prepareFinal.d.ts +18 -41
  470. package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -1
  471. package/dist/types/core/agent/stages/reliabilityExecution.d.ts +8 -1
  472. package/dist/types/core/agent/stages/reliabilityExecution.d.ts.map +1 -1
  473. package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
  474. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  475. package/dist/types/core/agent/toolArgsValidation.d.ts +9 -5
  476. package/dist/types/core/agent/toolArgsValidation.d.ts.map +1 -1
  477. package/dist/types/core/agent/toolDispatch.d.ts +3 -2
  478. package/dist/types/core/agent/toolDispatch.d.ts.map +1 -1
  479. package/dist/types/core/agent/toolSecurityEvents.d.ts +19 -0
  480. package/dist/types/core/agent/toolSecurityEvents.d.ts.map +1 -0
  481. package/dist/types/core/agent/types.d.ts +4 -4
  482. package/dist/types/core/codeRunnerTool.d.ts.map +1 -1
  483. package/dist/types/core/conversation.d.ts +16 -1
  484. package/dist/types/core/conversation.d.ts.map +1 -1
  485. package/dist/types/core/slots/buildThinkingSubflow.d.ts +2 -2
  486. package/dist/types/core/slots/buildThinkingSubflow.d.ts.map +1 -1
  487. package/dist/types/core/terminalVerdict.d.ts +57 -0
  488. package/dist/types/core/terminalVerdict.d.ts.map +1 -0
  489. package/dist/types/core-flow/Conditional.d.ts.map +1 -1
  490. package/dist/types/core-flow/Graph.d.ts.map +1 -1
  491. package/dist/types/core-flow/Loop.d.ts.map +1 -1
  492. package/dist/types/core-flow/Parallel.d.ts.map +1 -1
  493. package/dist/types/core-flow/Sequence.d.ts.map +1 -1
  494. package/dist/types/core-flow/Workflow.d.ts.map +1 -1
  495. package/dist/types/core-flow/childOutcome.d.ts +48 -0
  496. package/dist/types/core-flow/childOutcome.d.ts.map +1 -0
  497. package/dist/types/events/payloads.d.ts +33 -11
  498. package/dist/types/events/payloads.d.ts.map +1 -1
  499. package/dist/types/events/types.d.ts +32 -2
  500. package/dist/types/events/types.d.ts.map +1 -1
  501. package/dist/types/index.d.ts +1 -11
  502. package/dist/types/index.d.ts.map +1 -1
  503. package/dist/types/lib/injection-engine/skillToolDescriptors.d.ts.map +1 -1
  504. package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
  505. package/dist/types/lib/time-travel/receipt.d.ts +5 -5
  506. package/dist/types/lib/trace-toolpack/debugPrompt.d.ts +1 -1
  507. package/dist/types/lib/trace-toolpack/debugPrompt.d.ts.map +1 -1
  508. package/dist/types/lib/trace-toolpack/innerDescent.d.ts +59 -0
  509. package/dist/types/lib/trace-toolpack/innerDescent.d.ts.map +1 -0
  510. package/dist/types/lib/trace-toolpack/subflowRecords.d.ts +56 -0
  511. package/dist/types/lib/trace-toolpack/subflowRecords.d.ts.map +1 -0
  512. package/dist/types/lib/trace-toolpack/traceToolNames.d.ts +1 -1
  513. package/dist/types/lib/trace-toolpack/traceToolNames.d.ts.map +1 -1
  514. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts +1 -0
  515. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -1
  516. package/dist/types/lib/trust-boundaries/capture.d.ts +7 -0
  517. package/dist/types/lib/trust-boundaries/capture.d.ts.map +1 -0
  518. package/dist/types/lib/trust-boundaries/index.d.ts +3 -0
  519. package/dist/types/lib/trust-boundaries/index.d.ts.map +1 -0
  520. package/dist/types/lib/trust-boundaries/project.d.ts +14 -0
  521. package/dist/types/lib/trust-boundaries/project.d.ts.map +1 -0
  522. package/dist/types/lib/trust-boundaries/types.d.ts +82 -0
  523. package/dist/types/lib/trust-boundaries/types.d.ts.map +1 -0
  524. package/dist/types/observe.d.ts +1 -0
  525. package/dist/types/observe.d.ts.map +1 -1
  526. package/dist/types/patterns/LlmRouter.d.ts.map +1 -1
  527. package/dist/types/recorders/core/EmitBridge.d.ts.map +1 -1
  528. package/dist/types/recorders/observability/recordRun.d.ts +29 -4
  529. package/dist/types/recorders/observability/recordRun.d.ts.map +1 -1
  530. package/dist/types/recorders/observability/recordingEnvelope.d.ts.map +1 -1
  531. package/dist/types/reliability/failFastRecord.d.ts +29 -0
  532. package/dist/types/reliability/failFastRecord.d.ts.map +1 -0
  533. package/dist/types/resilience/withCircuitBreaker.d.ts.map +1 -1
  534. package/dist/types/resilience/withFallback.d.ts.map +1 -1
  535. package/dist/types/resilience/withRetry.d.ts.map +1 -1
  536. package/dist/types/thinking/AnthropicThinkingHandler.d.ts.map +1 -1
  537. package/dist/types/thinking/MockThinkingHandler.d.ts.map +1 -1
  538. package/dist/types/thinking/OllamaThinkingHandler.d.ts.map +1 -1
  539. package/dist/types/thinking/OpenAIThinkingHandler.d.ts.map +1 -1
  540. package/dist/types/thinking/index.d.ts +8 -7
  541. package/dist/types/thinking/index.d.ts.map +1 -1
  542. package/dist/types/thinking/registry.d.ts +13 -23
  543. package/dist/types/thinking/registry.d.ts.map +1 -1
  544. package/dist/types/thinking/thinkingHandlerFor.d.ts +28 -0
  545. package/dist/types/thinking/thinkingHandlerFor.d.ts.map +1 -0
  546. package/dist/types/thinking/types.d.ts +7 -15
  547. package/dist/types/thinking/types.d.ts.map +1 -1
  548. package/package.json +1 -5
  549. package/dist/cache/strategies/AnthropicCacheStrategy.js +0 -90
  550. package/dist/cache/strategies/AnthropicCacheStrategy.js.map +0 -1
  551. package/dist/cache/strategies/BedrockCacheStrategy.js +0 -97
  552. package/dist/cache/strategies/BedrockCacheStrategy.js.map +0 -1
  553. package/dist/cache/strategies/OpenAICacheStrategy.js +0 -76
  554. package/dist/cache/strategies/OpenAICacheStrategy.js.map +0 -1
  555. package/dist/cache/strategyRegistry.js +0 -81
  556. package/dist/cache/strategyRegistry.js.map +0 -1
  557. package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +0 -41
  558. package/dist/esm/cache/strategies/AnthropicCacheStrategy.js +0 -86
  559. package/dist/esm/cache/strategies/AnthropicCacheStrategy.js.map +0 -1
  560. package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +0 -62
  561. package/dist/esm/cache/strategies/BedrockCacheStrategy.js +0 -93
  562. package/dist/esm/cache/strategies/BedrockCacheStrategy.js.map +0 -1
  563. package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +0 -47
  564. package/dist/esm/cache/strategies/OpenAICacheStrategy.js +0 -72
  565. package/dist/esm/cache/strategies/OpenAICacheStrategy.js.map +0 -1
  566. package/dist/esm/cache/strategyRegistry.d.ts +0 -45
  567. package/dist/esm/cache/strategyRegistry.js +0 -74
  568. package/dist/esm/cache/strategyRegistry.js.map +0 -1
  569. package/dist/types/cache/strategies/AnthropicCacheStrategy.d.ts +0 -42
  570. package/dist/types/cache/strategies/AnthropicCacheStrategy.d.ts.map +0 -1
  571. package/dist/types/cache/strategies/BedrockCacheStrategy.d.ts +0 -63
  572. package/dist/types/cache/strategies/BedrockCacheStrategy.d.ts.map +0 -1
  573. package/dist/types/cache/strategies/OpenAICacheStrategy.d.ts +0 -48
  574. package/dist/types/cache/strategies/OpenAICacheStrategy.d.ts.map +0 -1
  575. package/dist/types/cache/strategyRegistry.d.ts +0 -46
  576. package/dist/types/cache/strategyRegistry.d.ts.map +0 -1
@@ -40,7 +40,9 @@ import { defineTool } from '../../core/tools.js';
40
40
  import { unconfiguredCredentialProvider } from '../../identity/types.js';
41
41
  import { unconfiguredArtifacts } from '../../artifacts/capability.js';
42
42
  import { boundedPreview, clampParam, displayKey, displayText, normalizeKey, renderPreview, safeStringify, } from './bounded.js';
43
+ import { askInner, framed, innerPackSlot } from './innerDescent.js';
43
44
  import { openRecording } from './openRecording.js';
45
+ import { homeMountOf, innerCommitCount, mountChain, openSubflow, opensWithSeed, subflowResultsOf, subflowWrote, } from './subflowRecords.js';
44
46
  import { resolveToolpackOptions, TOOLPACK_HARD_CAPS, } from './types.js';
45
47
  // ── Display caps that are structural (not consumer-tunable) ───────────────
46
48
  const OVERVIEW_STAGE_CAP = 40;
@@ -81,6 +83,12 @@ const TOOL_RESULT_PREVIEW_CHARS = 400;
81
83
  /** Schemas embed an `enum` of valid ids/keys only when the set is small —
82
84
  * free #9 validation without bloating the tools block on long runs. */
83
85
  const SCHEMA_ENUM_CAP = 48;
86
+ /**
87
+ * Artifact bags whose pack must not name `inspect_subflow` — the inner packs
88
+ * `inspect_tool_run` opens. Module-private on purpose: not an option a
89
+ * consumer sets, a fact about how the pack is reached.
90
+ */
91
+ const WITHOUT_SUBFLOW_DOOR = new WeakSet();
84
92
  function stagePartOf(runtimeStageId) {
85
93
  const hash = runtimeStageId.lastIndexOf('#');
86
94
  return hash > 0 ? runtimeStageId.slice(0, hash) : runtimeStageId;
@@ -109,6 +117,9 @@ function buildIndex(artifacts) {
109
117
  for (const entry of bundle.trace)
110
118
  knownPaths.add(entry.path);
111
119
  }
120
+ const subflowDoor = !WITHOUT_SUBFLOW_DOOR.has(artifacts);
121
+ const subflowResults = subflowDoor ? subflowResultsOf(artifacts.snapshot) : undefined;
122
+ const homes = new Map();
112
123
  // Walk the execution tree: node → children → next (≈ execution order).
113
124
  const nodes = new Map();
114
125
  const orderedIds = [];
@@ -132,11 +143,20 @@ function buildIndex(artifacts) {
132
143
  visit(node.next);
133
144
  };
134
145
  visit(artifacts.snapshot.executionTree);
135
- // Steps present in the commit log but missing from the tree (defensive).
146
+ // Steps present in the commit log but missing from the tree. A subflow's own
147
+ // log opens with its MOUNT's seed commit, which its tree does not hold — so
148
+ // an id that committed before the tree's first step goes FIRST, not last.
149
+ const treeFirstIdx = firstIdxOf.get(orderedIds[0] ?? '') ?? Infinity;
150
+ const before = [];
136
151
  for (const id of bundlesOf.keys()) {
137
- if (!nodes.has(id))
152
+ if (nodes.has(id))
153
+ continue;
154
+ if ((firstIdxOf.get(id) ?? Infinity) < treeFirstIdx)
155
+ before.push(id);
156
+ else
138
157
  orderedIds.push(id);
139
158
  }
159
+ orderedIds.unshift(...before);
140
160
  const idsByStagePart = new Map();
141
161
  const groupsByStagePart = new Map();
142
162
  const groups = [];
@@ -189,10 +209,22 @@ function buildIndex(artifacts) {
189
209
  untrackedStepCount,
190
210
  initialState: artifacts.snapshot.initialState,
191
211
  explained: new Set(),
212
+ subflowResults,
213
+ subflowDoor,
214
+ homeMountOf: (id) => {
215
+ if (subflowResults === undefined)
216
+ return undefined;
217
+ if (!homes.has(id))
218
+ homes.set(id, homeMountOf(subflowResults, id));
219
+ return homes.get(id);
220
+ },
192
221
  };
193
222
  }
194
223
  // ── Shared message helpers ─────────────────────────────────────────────────
195
224
  function unknownIdMessage(id, index) {
225
+ const home = index.homeMountOf(id);
226
+ if (home !== undefined)
227
+ return innerIdMessage(id, home);
196
228
  const stagePart = stagePartOf(id);
197
229
  const siblings = index.idsByStagePart.get(stagePart);
198
230
  if (siblings && siblings.length > 0) {
@@ -208,6 +240,17 @@ function unknownIdMessage(id, index) {
208
240
  : '') +
209
241
  `. Call run_overview to list every stage.`);
210
242
  }
243
+ /** An id from a subflow's OWN log, pasted into a tool over the log above it. */
244
+ function innerIdMessage(id, mount) {
245
+ return (`'${id}' is a step INSIDE subflow mount ${mount} — an id of that subflow's own log, not ` +
246
+ `of this one. Open it there: inspect_subflow({ mount: '${mount}', runtimeStageId: '${id}' }).`);
247
+ }
248
+ /** The one line a subflow mount carries: it can be opened, and how. */
249
+ function mountLine(index, id) {
250
+ return index.subflowResults !== undefined && id in index.subflowResults
251
+ ? `inside: inspect_subflow({ mount: '${id}' }) opens this subflow's own log.`
252
+ : `inside: no own log kept for this mount — inspect_subflow({ mount: '${id}' }) says why.`;
253
+ }
211
254
  function unknownKeySuffix(index) {
212
255
  if (index.knownPaths.size === 0)
213
256
  return '';
@@ -298,6 +341,7 @@ function matchWindow(text, needleLower, radius) {
298
341
  * | `get_value` | The full value of K as of step X (capped, truncation-marked) |
299
342
  * | `inspect_tool_call` | One tool call end to end: proposed args → ran-with args → result → outcome |
300
343
  * | `inspect_tool_run` | INSIDE one tool call — the chart it ran, when that tool kept its record |
344
+ * | `inspect_subflow` | INSIDE one subflow mount — the subflow's own log, one level at a time |
301
345
  * | `read_narrative` | The human-readable story, paginated (only when narrative provided) |
302
346
  *
303
347
  * Mount on an Agent (`Agent.create({...}).tool(...tools)`) or drive scripted
@@ -330,6 +374,7 @@ export function traceToolpack(artifacts, options) {
330
374
  buildGetValue(index, opts),
331
375
  buildInspectToolCall(artifacts, calls),
332
376
  buildInspectToolRun(artifacts, calls, options),
377
+ buildInspectSubflow(artifacts, index, options),
333
378
  ];
334
379
  if (artifacts.narrative !== undefined) {
335
380
  tools.push(buildReadNarrative(artifacts.narrative));
@@ -346,11 +391,21 @@ export { TRACE_TOOL_NAMES } from './traceToolNames.js';
346
391
  // ── Schema fragments ───────────────────────────────────────────────────────
347
392
  function idProperty(index, description) {
348
393
  const property = { type: 'string', description };
349
- if (index.orderedIds.length > 0 && index.orderedIds.length <= SCHEMA_ENUM_CAP) {
394
+ // No enum when subflows kept their own logs: the model may then hold an
395
+ // INNER id, and it is owed the correction toward `inspect_subflow` that only
396
+ // `execute` can give — a schema refusal would read as "no such step".
397
+ if (index.orderedIds.length > 0 &&
398
+ index.orderedIds.length <= SCHEMA_ENUM_CAP &&
399
+ !hasMountLogs(index)) {
350
400
  property.enum = index.orderedIds;
351
401
  }
352
402
  return property;
353
403
  }
404
+ /** True when at least one subflow mount kept its own log in this snapshot. */
405
+ function hasMountLogs(index) {
406
+ const results = index.subflowResults;
407
+ return (results !== undefined && Object.keys(results).some((key) => innerCommitCount(results, key) > 0));
408
+ }
354
409
  /**
355
410
  * Key params get guidance (known keys in the description) but NO enum:
356
411
  * unlike step ids — whose universe is complete — a key OUTSIDE the commit
@@ -365,6 +420,23 @@ function keyProperty(index, description) {
365
420
  return { type: 'string', description: `${description}${hint}` };
366
421
  }
367
422
  // ── run_overview ───────────────────────────────────────────────────────────
423
+ /**
424
+ * ONE line, only when the run mounted subflows: their inner steps are not in
425
+ * this log, and here is the door. By reference — nothing from inside a
426
+ * subflow is printed until the model asks for it.
427
+ */
428
+ function overviewSubflowLine(index) {
429
+ if (!index.subflowDoor)
430
+ return undefined;
431
+ const mounts = index.groups.filter((group) => group.isSubflow).flatMap((group) => group.ids);
432
+ if (mounts.length === 0)
433
+ return undefined;
434
+ const results = index.subflowResults;
435
+ const openable = mounts.find((id) => results !== undefined && id in results);
436
+ return openable !== undefined
437
+ ? `[subflow] steps ran their own log: inspect_subflow({ mount: '${openable}' }) opens one.`
438
+ : `[subflow] steps kept no own log here — inspect_subflow({ mount }) says why.`;
439
+ }
368
440
  function buildRunOverview(artifacts, index) {
369
441
  return defineTool({
370
442
  name: 'run_overview',
@@ -401,6 +473,9 @@ function buildRunOverview(artifacts, index) {
401
473
  if (index.groups.length > OVERVIEW_STAGE_CAP) {
402
474
  lines.push(`…and ${index.groups.length - OVERVIEW_STAGE_CAP} more stages (output capped)`);
403
475
  }
476
+ const subflowHint = overviewSubflowLine(index);
477
+ if (subflowHint !== undefined)
478
+ lines.push(subflowHint);
404
479
  const loops = index.groups.filter((g) => g.ids.length > 1);
405
480
  if (loops.length > 0) {
406
481
  const top = [...loops]
@@ -1158,6 +1233,8 @@ function buildTraceNode(artifacts, index, opts) {
1158
1233
  lines.push(`STEP ${runtimeStageId} — "${name}"${flags}`);
1159
1234
  if (node?.description)
1160
1235
  lines.push(`description: ${node.description}`);
1236
+ if (node?.subflowId && index.subflowDoor)
1237
+ lines.push(mountLine(index, runtimeStageId));
1161
1238
  // Writes — verb-aware values via commitValueAt (delta-mode safe).
1162
1239
  const writes = new Map(); // path → verb (last wins)
1163
1240
  for (const bundle of bundles ?? []) {
@@ -1484,7 +1561,8 @@ function buildWhoWrote(index, opts) {
1484
1561
  (beforeStageId !== undefined ? ` before ${beforeStageId}` : '') +
1485
1562
  ` in the commit log.` +
1486
1563
  (index.knownPaths.has(path) ? '' : unknownKeySuffix(index)) +
1487
- basisLines(index, basis));
1564
+ basisLines(index, basis) +
1565
+ writtenInsideLine(index, path, beforeIdx));
1488
1566
  }
1489
1567
  const writerIdx = index.commitLog.indexOf(writer);
1490
1568
  const verb = writer.trace.find((entry) => entry.path === path)?.verb ?? 'set';
@@ -1498,10 +1576,49 @@ function buildWhoWrote(index, opts) {
1498
1576
  basisLines(index, [...basis, ...read.basis]) +
1499
1577
  (untracked.length > 0
1500
1578
  ? `\n⚠ that step also consumed ${untracked.join('/')}. ${honestyLine(index, 'incomplete-sources')}`
1501
- : ''));
1579
+ : '') +
1580
+ mergeBackLine(index, writer.runtimeStageId, path));
1502
1581
  },
1503
1582
  });
1504
1583
  }
1584
+ /**
1585
+ * A write by a subflow MOUNT is its merge-back: the value was made inside. One
1586
+ * line names the question that reaches the inner writer; '' otherwise.
1587
+ */
1588
+ function mergeBackLine(index, writerId, path) {
1589
+ if (!index.subflowDoor || index.nodes.get(writerId)?.subflowId === undefined)
1590
+ return '';
1591
+ // The outputMapper may rename or compute the key: claim a writer inside only
1592
+ // when the mount's own log wrote this very path. Otherwise name the mount.
1593
+ if (!subflowWrote(index.subflowResults?.[writerId], path)) {
1594
+ return `\n↳ ${writerId} is a subflow mount — ${mountLine(index, writerId)}`;
1595
+ }
1596
+ return (`\n↳ ${writerId} is a subflow mount — this write is its merge-back. ` +
1597
+ `inspect_subflow({ mount: '${writerId}', key: '${displayKey(path)}' }) names the writer ` +
1598
+ `inside.`);
1599
+ }
1600
+ /**
1601
+ * A key this log never wrote may still be written INSIDE a subflow mounted at
1602
+ * this level — its own log never merged it back. One line naming the latest
1603
+ * such mount; '' when none did (asked only on a miss).
1604
+ */
1605
+ function writtenInsideLine(index, path, beforeIdx) {
1606
+ const results = index.subflowResults;
1607
+ if (!index.subflowDoor || results === undefined)
1608
+ return '';
1609
+ // Only mounts that ran BEFORE the anchor answer "who wrote it before X".
1610
+ const mounts = [...index.orderedIds]
1611
+ .reverse()
1612
+ .filter((id) => index.nodes.get(id)?.subflowId !== undefined)
1613
+ .filter((id) => beforeIdx === undefined || (index.lastIdxOf.get(id) ?? Infinity) < beforeIdx);
1614
+ const inside = mounts.find((id) => subflowWrote(results[id], path));
1615
+ if (inside === undefined)
1616
+ return '';
1617
+ // "Not merged back" is a claim about THIS log: true only if it never wrote the key.
1618
+ const where = index.knownPaths.has(path) ? '' : ' (not merged back here)';
1619
+ return (`\n↳ but subflow ${inside} wrote '${displayKey(path)}' in its OWN log${where}: ` +
1620
+ `inspect_subflow({ mount: '${inside}', key: '${displayKey(path)}' }) names the writer.`);
1621
+ }
1505
1622
  // ── get_value ──────────────────────────────────────────────────────────────
1506
1623
  function buildGetValue(index, opts) {
1507
1624
  return defineTool({
@@ -1967,23 +2084,18 @@ function buildInspectToolCall(artifacts, reader) {
1967
2084
  * that just says "nothing" teaches the model the tool is broken.
1968
2085
  */
1969
2086
  function buildInspectToolRun(artifacts, reader, options) {
1970
- // One inner pack at a time, memoized by call id: three drills into one
1971
- // inner run build one index, and the memo pins at most ONE inner run's
1972
- // index beyond the record the store is already holding.
1973
- let memoId;
1974
- let memoTools;
1975
- const innerToolsFor = (record) => {
1976
- if (memoTools !== undefined && memoId === record.toolCallId)
1977
- return memoTools;
2087
+ // One inner pack at a time, memoized by call id (`innerDescent`): three
2088
+ // drills into one inner run build one index.
2089
+ const slot = innerPackSlot((inner) => traceToolpack(inner, options));
2090
+ const openRecord = (record) => {
1978
2091
  if (record.recording === undefined) {
1979
2092
  return (`tool call '${record.toolCallId}' ran '${record.toolName}', which keeps records — but ` +
1980
2093
  `THIS one could not be captured: ${record.problem ?? 'reason not recorded'}. The call ` +
1981
2094
  `itself was unaffected; inspect_tool_call('${record.toolCallId}') still has the ` +
1982
2095
  `envelope (arguments in, result out).`);
1983
2096
  }
1984
- let inner;
1985
2097
  try {
1986
- inner = {
2098
+ const inner = {
1987
2099
  // `openRecording` is the adapter, not a copy of it: same lift, same
1988
2100
  // two teaching refusals if the bag is malformed. The two fields it
1989
2101
  // cannot lift from JSON — control edges, and a narrative nobody
@@ -1992,14 +2104,13 @@ function buildInspectToolRun(artifacts, reader, options) {
1992
2104
  ...(record.controlDeps !== undefined && { controlDeps: record.controlDeps }),
1993
2105
  ...(record.narrative !== undefined && { narrative: record.narrative }),
1994
2106
  };
2107
+ WITHOUT_SUBFLOW_DOOR.add(inner);
2108
+ return inner;
1995
2109
  }
1996
2110
  catch (e) {
1997
2111
  return (`the retained record for '${record.toolCallId}' could not be opened: ` +
1998
2112
  `${e instanceof Error ? e.message : String(e)}`);
1999
2113
  }
2000
- memoId = record.toolCallId;
2001
- memoTools = traceToolpack(inner, options);
2002
- return memoTools;
2003
2114
  };
2004
2115
  return defineTool({
2005
2116
  name: 'inspect_tool_run',
@@ -2007,8 +2118,8 @@ function buildInspectToolRun(artifacts, reader, options) {
2007
2118
  'record of what they ran; this opens it. Called with just a toolCallId it returns a ' +
2008
2119
  'bounded overview of the inner run (its stages, its errors, its state keys). Add ' +
2009
2120
  "'find' to search that inner run in free text, 'variable' to ask why an inner value is " +
2010
- "what it is, 'runtimeStageId' to open one inner step, or both 'runtimeStageId' and " +
2011
- "'key' for an inner value in full. The ids it returns are the INNER chart's — the " +
2121
+ "what it is, 'key' alone for who last wrote an inner key, 'runtimeStageId' to open one " +
2122
+ "inner step, or both 'runtimeStageId' and 'key' for an inner value in full. The ids it returns are the INNER chart's — the " +
2012
2123
  'outer trace tools do not accept them. Reach for it when inspect_tool_call says a ' +
2013
2124
  'record was kept and the question is about what the tool DID, not what it returned.',
2014
2125
  inputSchema: {
@@ -2025,7 +2136,8 @@ function buildInspectToolRun(artifacts, reader, options) {
2025
2136
  },
2026
2137
  key: {
2027
2138
  type: 'string',
2028
- description: "Optional, with runtimeStageId: the inner state key to fetch in full, e.g. 'forecast'.",
2139
+ description: "Optional: an inner state key, e.g. 'forecast' — alone, who last wrote it inside; " +
2140
+ 'with runtimeStageId, its value in full as of that step.',
2029
2141
  },
2030
2142
  variable: {
2031
2143
  type: 'string',
@@ -2047,49 +2159,163 @@ function buildInspectToolRun(artifacts, reader, options) {
2047
2159
  const record = lookup.get(toolCallId);
2048
2160
  if (record === undefined)
2049
2161
  return unknownInnerRunMessage(toolCallId, lookup, reader);
2050
- const inner = innerToolsFor(record);
2162
+ const inner = slot(record.toolCallId, () => openRecord(record));
2051
2163
  if (typeof inner === 'string')
2052
2164
  return inner;
2053
- // Param-shaped dispatch (the `backtrack({ element })` precedent): the
2054
- // narrowest question the caller asked wins, and the default — no
2055
- // extra params at all — is the entry point, exactly as run_overview
2056
- // is the entry point one level up.
2057
- let body;
2058
- if (find !== undefined) {
2059
- body = await callTraceTool(inner, 'find_in_trace', { query: find });
2060
- }
2061
- else if (variable !== undefined) {
2062
- body = await callTraceTool(inner, 'backtrack', { variable });
2063
- }
2064
- else if (runtimeStageId !== undefined && key !== undefined) {
2065
- body = await callTraceTool(inner, 'get_value', { runtimeStageId, key });
2066
- }
2067
- else if (runtimeStageId !== undefined) {
2068
- body = await callTraceTool(inner, 'trace_node', { runtimeStageId });
2069
- }
2070
- else if (key !== undefined) {
2071
- body =
2072
- `'key' names a value AS OF a step, so it needs a step: pass runtimeStageId too, or ` +
2073
- `use 'variable' to ask why '${displayKey(key)}' is what it is across the whole inner ` +
2074
- `run.`;
2075
- }
2076
- else {
2077
- body = await callTraceTool(inner, 'run_overview', {});
2078
- }
2079
- return [
2080
- `INSIDE TOOL CALL ${toolCallId} — '${record.toolName}' ran a recorded flowchart ` +
2165
+ const body = await askInner(inner, { runtimeStageId, key, variable, find }, callTraceTool);
2166
+ return framed({
2167
+ header: `INSIDE TOOL CALL ${toolCallId} — '${record.toolName}' ran a recorded flowchart ` +
2081
2168
  `(${record.steps} committed step(s), ${record.outcome}).`,
2082
- body,
2083
- `next inside call '${toolCallId}': inspect_tool_run({ toolCallId: '${toolCallId}', ` +
2169
+ next: `next inside call '${toolCallId}': inspect_tool_run({ toolCallId: '${toolCallId}', ` +
2084
2170
  `runtimeStageId: '<inner id>' }) opens a step · add 'key' for a value in full · ` +
2085
2171
  `'variable' asks why an inner value is what it is · 'find' searches this inner run.`,
2086
- `⚠ the ids above are INNER ids — they name steps of ${record.toolName}'s own chart, not ` +
2087
- `of the run that called it. trace_node / get_value / trace_slice do not accept them; ` +
2088
- `come back through inspect_tool_run.`,
2089
- ].join('\n');
2172
+ namespace: `⚠ the ids above are INNER ids — they name steps of ${record.toolName}'s own chart, ` +
2173
+ `not of the run that called it. trace_node / get_value / trace_slice do not accept ` +
2174
+ `them; come back through inspect_tool_run.`,
2175
+ }, body);
2176
+ },
2177
+ });
2178
+ }
2179
+ // ── inspect_subflow ────────────────────────────────────────────────────────
2180
+ /** How many mounts a correction names. */
2181
+ const MOUNT_SUGGESTION_CAP = 8;
2182
+ /**
2183
+ * INSIDE a subflow mount — the subflow's OWN log, opened.
2184
+ *
2185
+ * A subflow runs in an isolated runtime and commits to its own log, so this
2186
+ * run's log holds only the mount boundary: what went in, what came back. The
2187
+ * evidence of who wrote a value IN there was always recorded (footprintjs keeps
2188
+ * it in `subflowResults`) — no tool served it. This one does, through the same
2189
+ * descent `inspect_tool_run` uses (`innerDescent`): the inner views are the
2190
+ * pack's own tools over the mount's own record, so the inner answers carry the
2191
+ * same reason codes, folded from the SUBFLOW's own `initialState`.
2192
+ *
2193
+ * - BY REFERENCE. Nothing from inside a subflow is printed until the model
2194
+ * asks; the outer views carry one line naming the door.
2195
+ * - ONE LEVEL AT A TIME. A mount nested inside a subflow is opened through
2196
+ * its parent's pack — this tool walks the chain (`mountChain`), each level
2197
+ * answering only for its own log.
2198
+ * - ITS OWN NAMESPACE. Inner ids are said to be inner on every answer, and
2199
+ * an outer tool handed one corrects toward here (`innerIdMessage`).
2200
+ */
2201
+ function buildInspectSubflow(artifacts, index, options) {
2202
+ const slot = innerPackSlot((inner) => traceToolpack(inner, options));
2203
+ const isStep = (id) => index.nodes.has(id) || index.firstIdxOf.has(id);
2204
+ const mountIds = () => index.orderedIds.filter((id) => index.nodes.get(id)?.subflowId);
2205
+ const notAMount = (mount) => {
2206
+ if (isStep(mount)) {
2207
+ return `'${mount}' is an outer step, not a subflow mount — trace_node('${mount}') opens it.`;
2208
+ }
2209
+ const mounts = mountIds();
2210
+ const sameStage = mounts.filter((id) => stagePartOf(id) === mount);
2211
+ if (sameStage.length > 0) {
2212
+ return (`'${mount}' ran ${sameStage.length} time(s); a mount is ONE execution: ` +
2213
+ `${sameStage.slice(0, MOUNT_SUGGESTION_CAP).join(', ')}` +
2214
+ `${sameStage.length > MOUNT_SUGGESTION_CAP ? ', …' : ''}. Retry with one of those ids.`);
2215
+ }
2216
+ if (mounts.length === 0)
2217
+ return `the traced run mounted no subflows — there is no inner log to open.`;
2218
+ return (`unknown mount '${mount}'. Subflow mounts in the traced run: ` +
2219
+ `${mounts.slice(0, MOUNT_SUGGESTION_CAP).join(', ')}` +
2220
+ `${mounts.length > MOUNT_SUGGESTION_CAP ? ', …' : ''}.`);
2221
+ };
2222
+ return defineTool({
2223
+ name: 'inspect_subflow',
2224
+ description: "Open a [subflow] step's OWN log (the run's log holds only its boundary). Mount id alone: " +
2225
+ "inner overview. 'key': its last writer inside. 'variable': why it is what it is. " +
2226
+ "'find': search. 'runtimeStageId' (+'key'): one inner step (value). Inner ids go back here.",
2227
+ inputSchema: {
2228
+ type: 'object',
2229
+ properties: {
2230
+ mount: { type: 'string', description: "The mount step, e.g. 'sf-tools#11'." },
2231
+ runtimeStageId: { type: 'string', description: 'Optional: an inner step id.' },
2232
+ key: { type: 'string', description: 'Optional: an inner state key.' },
2233
+ variable: { type: 'string', description: 'Optional: an inner state key to explain.' },
2234
+ find: { type: 'string', description: 'Optional: free text to locate inside.' },
2235
+ },
2236
+ required: ['mount'],
2237
+ additionalProperties: false,
2238
+ },
2239
+ execute: async ({ mount, runtimeStageId, key, variable, find }) => {
2240
+ const question = { runtimeStageId, key, variable, find };
2241
+ const results = index.subflowResults;
2242
+ const isMount = index.nodes.get(mount)?.subflowId !== undefined;
2243
+ // A mount nested below this level: open its parent here, ask there.
2244
+ if (!isMount && !isStep(mount) && results !== undefined) {
2245
+ const chain = mountChain(results, mount, isStep);
2246
+ if (chain !== undefined && chain.length > 1) {
2247
+ const parent = chain[0];
2248
+ const pack = slot(parent, () => openSubflowArtifacts(artifacts, parent));
2249
+ if (typeof pack === 'string')
2250
+ return pack;
2251
+ return callTraceTool(pack, 'inspect_subflow', { mount, ...definedOf(question) });
2252
+ }
2253
+ }
2254
+ if (!isMount)
2255
+ return notAMount(mount);
2256
+ if (runtimeStageId !== undefined &&
2257
+ runtimeStageId !== mount &&
2258
+ isStep(runtimeStageId) &&
2259
+ index.homeMountOf(runtimeStageId) !== mount) {
2260
+ return (`'${runtimeStageId}' is a step of the run ABOVE subflow ${mount}, not of its own log — ` +
2261
+ `trace_node('${runtimeStageId}') opens it there.`);
2262
+ }
2263
+ const inner = slot(mount, () => openSubflowArtifacts(artifacts, mount));
2264
+ if (typeof inner === 'string')
2265
+ return inner;
2266
+ const body = await askInner(inner, question, callTraceTool);
2267
+ const name = index.nodes.get(mount)?.name;
2268
+ const parent = index.homeMountOf(mount);
2269
+ const commits = innerCommitCount(index.subflowResults, mount);
2270
+ return framed({
2271
+ header: `INSIDE SUBFLOW ${mount}${name !== undefined ? ` — "${name}"` : ''}` +
2272
+ `${parent !== undefined ? ` (nested in ${parent})` : ''}: its own log, ` +
2273
+ `${commits} commit(s)${opensWithSeed(index.subflowResults, mount) ? ", the mount's seed first" : ''}.`,
2274
+ next: `next inside '${mount}': inspect_subflow({ mount: '${mount}', runtimeStageId: ` +
2275
+ `'<inner id>' }) opens a step · 'key' alone names its last writer inside · 'variable' ` +
2276
+ `asks why an inner value is what it is · 'find' searches this inner log.`,
2277
+ namespace: `⚠ the ids above are INNER ids — steps of subflow ${mount}'s own log, not of the run ` +
2278
+ `that mounted it. trace_node / get_value / trace_slice correct them back here.`,
2279
+ }, body);
2090
2280
  },
2091
2281
  });
2092
2282
  }
2283
+ /**
2284
+ * The run's own control-dependence lookup, keyed by every subflow bag opened
2285
+ * below it — so each level filters the RUN's edges to its own log
2286
+ * (`openSubflowArtifacts`), at any depth.
2287
+ */
2288
+ const RAW_CONTROL_DEPS = new WeakMap();
2289
+ /** The mount's record as an artifact bag, or why there is none. */
2290
+ function openSubflowArtifacts(artifacts, mount) {
2291
+ const opened = openSubflow(artifacts.snapshot, mount);
2292
+ if (typeof opened === 'string')
2293
+ return `inspect_subflow: ${opened}`;
2294
+ // Step ids are unique across a run, so the RUN's lookup answers inner ids —
2295
+ // but a decider OUTSIDE this log is not an inner step: keep only edges from
2296
+ // a decider in the mount's own log, so no outer id is served as an inner one.
2297
+ // Always filter the run's RAW lookup, never this level's filtered one: a
2298
+ // nested mount's deciders are not in its parent's log, so filtering the
2299
+ // parent's view would drop every edge one level further down.
2300
+ const raw = RAW_CONTROL_DEPS.get(artifacts) ?? artifacts.controlDeps;
2301
+ const innerIds = new Set(opened.commitLog.map((bundle) => bundle.runtimeStageId));
2302
+ const bag = {
2303
+ snapshot: opened,
2304
+ ...(raw !== undefined && {
2305
+ controlDeps: (id) => {
2306
+ const dep = raw(id);
2307
+ return dep !== undefined && innerIds.has(dep.deciderId) ? dep : undefined;
2308
+ },
2309
+ }),
2310
+ };
2311
+ if (raw !== undefined)
2312
+ RAW_CONTROL_DEPS.set(bag, raw);
2313
+ return bag;
2314
+ }
2315
+ /** The question's params that were actually given (strict schemas refuse `undefined`). */
2316
+ function definedOf(question) {
2317
+ return Object.fromEntries(Object.entries(question).filter((entry) => entry[1] !== undefined));
2318
+ }
2093
2319
  /** No tool in this run keeps a record — name the switch, not the emptiness. */
2094
2320
  function noInnerRecordsMessage(toolCallId) {
2095
2321
  return (`inspect_tool_run: nothing in this run kept a record below the tool boundary, so there is ` +