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
@@ -43,7 +43,9 @@ const tools_js_1 = require("../../core/tools.js");
43
43
  const types_js_1 = require("../../identity/types.js");
44
44
  const capability_js_1 = require("../../artifacts/capability.js");
45
45
  const bounded_js_1 = require("./bounded.js");
46
+ const innerDescent_js_1 = require("./innerDescent.js");
46
47
  const openRecording_js_1 = require("./openRecording.js");
48
+ const subflowRecords_js_1 = require("./subflowRecords.js");
47
49
  const types_js_2 = require("./types.js");
48
50
  // ── Display caps that are structural (not consumer-tunable) ───────────────
49
51
  const OVERVIEW_STAGE_CAP = 40;
@@ -84,6 +86,12 @@ const TOOL_RESULT_PREVIEW_CHARS = 400;
84
86
  /** Schemas embed an `enum` of valid ids/keys only when the set is small —
85
87
  * free #9 validation without bloating the tools block on long runs. */
86
88
  const SCHEMA_ENUM_CAP = 48;
89
+ /**
90
+ * Artifact bags whose pack must not name `inspect_subflow` — the inner packs
91
+ * `inspect_tool_run` opens. Module-private on purpose: not an option a
92
+ * consumer sets, a fact about how the pack is reached.
93
+ */
94
+ const WITHOUT_SUBFLOW_DOOR = new WeakSet();
87
95
  function stagePartOf(runtimeStageId) {
88
96
  const hash = runtimeStageId.lastIndexOf('#');
89
97
  return hash > 0 ? runtimeStageId.slice(0, hash) : runtimeStageId;
@@ -112,6 +120,9 @@ function buildIndex(artifacts) {
112
120
  for (const entry of bundle.trace)
113
121
  knownPaths.add(entry.path);
114
122
  }
123
+ const subflowDoor = !WITHOUT_SUBFLOW_DOOR.has(artifacts);
124
+ const subflowResults = subflowDoor ? (0, subflowRecords_js_1.subflowResultsOf)(artifacts.snapshot) : undefined;
125
+ const homes = new Map();
115
126
  // Walk the execution tree: node → children → next (≈ execution order).
116
127
  const nodes = new Map();
117
128
  const orderedIds = [];
@@ -135,11 +146,20 @@ function buildIndex(artifacts) {
135
146
  visit(node.next);
136
147
  };
137
148
  visit(artifacts.snapshot.executionTree);
138
- // Steps present in the commit log but missing from the tree (defensive).
149
+ // Steps present in the commit log but missing from the tree. A subflow's own
150
+ // log opens with its MOUNT's seed commit, which its tree does not hold — so
151
+ // an id that committed before the tree's first step goes FIRST, not last.
152
+ const treeFirstIdx = firstIdxOf.get(orderedIds[0] ?? '') ?? Infinity;
153
+ const before = [];
139
154
  for (const id of bundlesOf.keys()) {
140
- if (!nodes.has(id))
155
+ if (nodes.has(id))
156
+ continue;
157
+ if ((firstIdxOf.get(id) ?? Infinity) < treeFirstIdx)
158
+ before.push(id);
159
+ else
141
160
  orderedIds.push(id);
142
161
  }
162
+ orderedIds.unshift(...before);
143
163
  const idsByStagePart = new Map();
144
164
  const groupsByStagePart = new Map();
145
165
  const groups = [];
@@ -192,10 +212,22 @@ function buildIndex(artifacts) {
192
212
  untrackedStepCount,
193
213
  initialState: artifacts.snapshot.initialState,
194
214
  explained: new Set(),
215
+ subflowResults,
216
+ subflowDoor,
217
+ homeMountOf: (id) => {
218
+ if (subflowResults === undefined)
219
+ return undefined;
220
+ if (!homes.has(id))
221
+ homes.set(id, (0, subflowRecords_js_1.homeMountOf)(subflowResults, id));
222
+ return homes.get(id);
223
+ },
195
224
  };
196
225
  }
197
226
  // ── Shared message helpers ─────────────────────────────────────────────────
198
227
  function unknownIdMessage(id, index) {
228
+ const home = index.homeMountOf(id);
229
+ if (home !== undefined)
230
+ return innerIdMessage(id, home);
199
231
  const stagePart = stagePartOf(id);
200
232
  const siblings = index.idsByStagePart.get(stagePart);
201
233
  if (siblings && siblings.length > 0) {
@@ -211,6 +243,17 @@ function unknownIdMessage(id, index) {
211
243
  : '') +
212
244
  `. Call run_overview to list every stage.`);
213
245
  }
246
+ /** An id from a subflow's OWN log, pasted into a tool over the log above it. */
247
+ function innerIdMessage(id, mount) {
248
+ return (`'${id}' is a step INSIDE subflow mount ${mount} — an id of that subflow's own log, not ` +
249
+ `of this one. Open it there: inspect_subflow({ mount: '${mount}', runtimeStageId: '${id}' }).`);
250
+ }
251
+ /** The one line a subflow mount carries: it can be opened, and how. */
252
+ function mountLine(index, id) {
253
+ return index.subflowResults !== undefined && id in index.subflowResults
254
+ ? `inside: inspect_subflow({ mount: '${id}' }) opens this subflow's own log.`
255
+ : `inside: no own log kept for this mount — inspect_subflow({ mount: '${id}' }) says why.`;
256
+ }
214
257
  function unknownKeySuffix(index) {
215
258
  if (index.knownPaths.size === 0)
216
259
  return '';
@@ -301,6 +344,7 @@ function matchWindow(text, needleLower, radius) {
301
344
  * | `get_value` | The full value of K as of step X (capped, truncation-marked) |
302
345
  * | `inspect_tool_call` | One tool call end to end: proposed args → ran-with args → result → outcome |
303
346
  * | `inspect_tool_run` | INSIDE one tool call — the chart it ran, when that tool kept its record |
347
+ * | `inspect_subflow` | INSIDE one subflow mount — the subflow's own log, one level at a time |
304
348
  * | `read_narrative` | The human-readable story, paginated (only when narrative provided) |
305
349
  *
306
350
  * Mount on an Agent (`Agent.create({...}).tool(...tools)`) or drive scripted
@@ -333,6 +377,7 @@ function traceToolpack(artifacts, options) {
333
377
  buildGetValue(index, opts),
334
378
  buildInspectToolCall(artifacts, calls),
335
379
  buildInspectToolRun(artifacts, calls, options),
380
+ buildInspectSubflow(artifacts, index, options),
336
381
  ];
337
382
  if (artifacts.narrative !== undefined) {
338
383
  tools.push(buildReadNarrative(artifacts.narrative));
@@ -351,11 +396,21 @@ Object.defineProperty(exports, "TRACE_TOOL_NAMES", { enumerable: true, get: func
351
396
  // ── Schema fragments ───────────────────────────────────────────────────────
352
397
  function idProperty(index, description) {
353
398
  const property = { type: 'string', description };
354
- if (index.orderedIds.length > 0 && index.orderedIds.length <= SCHEMA_ENUM_CAP) {
399
+ // No enum when subflows kept their own logs: the model may then hold an
400
+ // INNER id, and it is owed the correction toward `inspect_subflow` that only
401
+ // `execute` can give — a schema refusal would read as "no such step".
402
+ if (index.orderedIds.length > 0 &&
403
+ index.orderedIds.length <= SCHEMA_ENUM_CAP &&
404
+ !hasMountLogs(index)) {
355
405
  property.enum = index.orderedIds;
356
406
  }
357
407
  return property;
358
408
  }
409
+ /** True when at least one subflow mount kept its own log in this snapshot. */
410
+ function hasMountLogs(index) {
411
+ const results = index.subflowResults;
412
+ return (results !== undefined && Object.keys(results).some((key) => (0, subflowRecords_js_1.innerCommitCount)(results, key) > 0));
413
+ }
359
414
  /**
360
415
  * Key params get guidance (known keys in the description) but NO enum:
361
416
  * unlike step ids — whose universe is complete — a key OUTSIDE the commit
@@ -370,6 +425,23 @@ function keyProperty(index, description) {
370
425
  return { type: 'string', description: `${description}${hint}` };
371
426
  }
372
427
  // ── run_overview ───────────────────────────────────────────────────────────
428
+ /**
429
+ * ONE line, only when the run mounted subflows: their inner steps are not in
430
+ * this log, and here is the door. By reference — nothing from inside a
431
+ * subflow is printed until the model asks for it.
432
+ */
433
+ function overviewSubflowLine(index) {
434
+ if (!index.subflowDoor)
435
+ return undefined;
436
+ const mounts = index.groups.filter((group) => group.isSubflow).flatMap((group) => group.ids);
437
+ if (mounts.length === 0)
438
+ return undefined;
439
+ const results = index.subflowResults;
440
+ const openable = mounts.find((id) => results !== undefined && id in results);
441
+ return openable !== undefined
442
+ ? `[subflow] steps ran their own log: inspect_subflow({ mount: '${openable}' }) opens one.`
443
+ : `[subflow] steps kept no own log here — inspect_subflow({ mount }) says why.`;
444
+ }
373
445
  function buildRunOverview(artifacts, index) {
374
446
  return (0, tools_js_1.defineTool)({
375
447
  name: 'run_overview',
@@ -406,6 +478,9 @@ function buildRunOverview(artifacts, index) {
406
478
  if (index.groups.length > OVERVIEW_STAGE_CAP) {
407
479
  lines.push(`…and ${index.groups.length - OVERVIEW_STAGE_CAP} more stages (output capped)`);
408
480
  }
481
+ const subflowHint = overviewSubflowLine(index);
482
+ if (subflowHint !== undefined)
483
+ lines.push(subflowHint);
409
484
  const loops = index.groups.filter((g) => g.ids.length > 1);
410
485
  if (loops.length > 0) {
411
486
  const top = [...loops]
@@ -1163,6 +1238,8 @@ function buildTraceNode(artifacts, index, opts) {
1163
1238
  lines.push(`STEP ${runtimeStageId} — "${name}"${flags}`);
1164
1239
  if (node?.description)
1165
1240
  lines.push(`description: ${node.description}`);
1241
+ if (node?.subflowId && index.subflowDoor)
1242
+ lines.push(mountLine(index, runtimeStageId));
1166
1243
  // Writes — verb-aware values via commitValueAt (delta-mode safe).
1167
1244
  const writes = new Map(); // path → verb (last wins)
1168
1245
  for (const bundle of bundles ?? []) {
@@ -1489,7 +1566,8 @@ function buildWhoWrote(index, opts) {
1489
1566
  (beforeStageId !== undefined ? ` before ${beforeStageId}` : '') +
1490
1567
  ` in the commit log.` +
1491
1568
  (index.knownPaths.has(path) ? '' : unknownKeySuffix(index)) +
1492
- basisLines(index, basis));
1569
+ basisLines(index, basis) +
1570
+ writtenInsideLine(index, path, beforeIdx));
1493
1571
  }
1494
1572
  const writerIdx = index.commitLog.indexOf(writer);
1495
1573
  const verb = writer.trace.find((entry) => entry.path === path)?.verb ?? 'set';
@@ -1503,10 +1581,49 @@ function buildWhoWrote(index, opts) {
1503
1581
  basisLines(index, [...basis, ...read.basis]) +
1504
1582
  (untracked.length > 0
1505
1583
  ? `\n⚠ that step also consumed ${untracked.join('/')}. ${honestyLine(index, 'incomplete-sources')}`
1506
- : ''));
1584
+ : '') +
1585
+ mergeBackLine(index, writer.runtimeStageId, path));
1507
1586
  },
1508
1587
  });
1509
1588
  }
1589
+ /**
1590
+ * A write by a subflow MOUNT is its merge-back: the value was made inside. One
1591
+ * line names the question that reaches the inner writer; '' otherwise.
1592
+ */
1593
+ function mergeBackLine(index, writerId, path) {
1594
+ if (!index.subflowDoor || index.nodes.get(writerId)?.subflowId === undefined)
1595
+ return '';
1596
+ // The outputMapper may rename or compute the key: claim a writer inside only
1597
+ // when the mount's own log wrote this very path. Otherwise name the mount.
1598
+ if (!(0, subflowRecords_js_1.subflowWrote)(index.subflowResults?.[writerId], path)) {
1599
+ return `\n↳ ${writerId} is a subflow mount — ${mountLine(index, writerId)}`;
1600
+ }
1601
+ return (`\n↳ ${writerId} is a subflow mount — this write is its merge-back. ` +
1602
+ `inspect_subflow({ mount: '${writerId}', key: '${(0, bounded_js_1.displayKey)(path)}' }) names the writer ` +
1603
+ `inside.`);
1604
+ }
1605
+ /**
1606
+ * A key this log never wrote may still be written INSIDE a subflow mounted at
1607
+ * this level — its own log never merged it back. One line naming the latest
1608
+ * such mount; '' when none did (asked only on a miss).
1609
+ */
1610
+ function writtenInsideLine(index, path, beforeIdx) {
1611
+ const results = index.subflowResults;
1612
+ if (!index.subflowDoor || results === undefined)
1613
+ return '';
1614
+ // Only mounts that ran BEFORE the anchor answer "who wrote it before X".
1615
+ const mounts = [...index.orderedIds]
1616
+ .reverse()
1617
+ .filter((id) => index.nodes.get(id)?.subflowId !== undefined)
1618
+ .filter((id) => beforeIdx === undefined || (index.lastIdxOf.get(id) ?? Infinity) < beforeIdx);
1619
+ const inside = mounts.find((id) => (0, subflowRecords_js_1.subflowWrote)(results[id], path));
1620
+ if (inside === undefined)
1621
+ return '';
1622
+ // "Not merged back" is a claim about THIS log: true only if it never wrote the key.
1623
+ const where = index.knownPaths.has(path) ? '' : ' (not merged back here)';
1624
+ return (`\n↳ but subflow ${inside} wrote '${(0, bounded_js_1.displayKey)(path)}' in its OWN log${where}: ` +
1625
+ `inspect_subflow({ mount: '${inside}', key: '${(0, bounded_js_1.displayKey)(path)}' }) names the writer.`);
1626
+ }
1510
1627
  // ── get_value ──────────────────────────────────────────────────────────────
1511
1628
  function buildGetValue(index, opts) {
1512
1629
  return (0, tools_js_1.defineTool)({
@@ -1972,23 +2089,18 @@ function buildInspectToolCall(artifacts, reader) {
1972
2089
  * that just says "nothing" teaches the model the tool is broken.
1973
2090
  */
1974
2091
  function buildInspectToolRun(artifacts, reader, options) {
1975
- // One inner pack at a time, memoized by call id: three drills into one
1976
- // inner run build one index, and the memo pins at most ONE inner run's
1977
- // index beyond the record the store is already holding.
1978
- let memoId;
1979
- let memoTools;
1980
- const innerToolsFor = (record) => {
1981
- if (memoTools !== undefined && memoId === record.toolCallId)
1982
- return memoTools;
2092
+ // One inner pack at a time, memoized by call id (`innerDescent`): three
2093
+ // drills into one inner run build one index.
2094
+ const slot = (0, innerDescent_js_1.innerPackSlot)((inner) => traceToolpack(inner, options));
2095
+ const openRecord = (record) => {
1983
2096
  if (record.recording === undefined) {
1984
2097
  return (`tool call '${record.toolCallId}' ran '${record.toolName}', which keeps records — but ` +
1985
2098
  `THIS one could not be captured: ${record.problem ?? 'reason not recorded'}. The call ` +
1986
2099
  `itself was unaffected; inspect_tool_call('${record.toolCallId}') still has the ` +
1987
2100
  `envelope (arguments in, result out).`);
1988
2101
  }
1989
- let inner;
1990
2102
  try {
1991
- inner = {
2103
+ const inner = {
1992
2104
  // `openRecording` is the adapter, not a copy of it: same lift, same
1993
2105
  // two teaching refusals if the bag is malformed. The two fields it
1994
2106
  // cannot lift from JSON — control edges, and a narrative nobody
@@ -1997,14 +2109,13 @@ function buildInspectToolRun(artifacts, reader, options) {
1997
2109
  ...(record.controlDeps !== undefined && { controlDeps: record.controlDeps }),
1998
2110
  ...(record.narrative !== undefined && { narrative: record.narrative }),
1999
2111
  };
2112
+ WITHOUT_SUBFLOW_DOOR.add(inner);
2113
+ return inner;
2000
2114
  }
2001
2115
  catch (e) {
2002
2116
  return (`the retained record for '${record.toolCallId}' could not be opened: ` +
2003
2117
  `${e instanceof Error ? e.message : String(e)}`);
2004
2118
  }
2005
- memoId = record.toolCallId;
2006
- memoTools = traceToolpack(inner, options);
2007
- return memoTools;
2008
2119
  };
2009
2120
  return (0, tools_js_1.defineTool)({
2010
2121
  name: 'inspect_tool_run',
@@ -2012,8 +2123,8 @@ function buildInspectToolRun(artifacts, reader, options) {
2012
2123
  'record of what they ran; this opens it. Called with just a toolCallId it returns a ' +
2013
2124
  'bounded overview of the inner run (its stages, its errors, its state keys). Add ' +
2014
2125
  "'find' to search that inner run in free text, 'variable' to ask why an inner value is " +
2015
- "what it is, 'runtimeStageId' to open one inner step, or both 'runtimeStageId' and " +
2016
- "'key' for an inner value in full. The ids it returns are the INNER chart's — the " +
2126
+ "what it is, 'key' alone for who last wrote an inner key, 'runtimeStageId' to open one " +
2127
+ "inner step, or both 'runtimeStageId' and 'key' for an inner value in full. The ids it returns are the INNER chart's — the " +
2017
2128
  'outer trace tools do not accept them. Reach for it when inspect_tool_call says a ' +
2018
2129
  'record was kept and the question is about what the tool DID, not what it returned.',
2019
2130
  inputSchema: {
@@ -2030,7 +2141,8 @@ function buildInspectToolRun(artifacts, reader, options) {
2030
2141
  },
2031
2142
  key: {
2032
2143
  type: 'string',
2033
- description: "Optional, with runtimeStageId: the inner state key to fetch in full, e.g. 'forecast'.",
2144
+ description: "Optional: an inner state key, e.g. 'forecast' — alone, who last wrote it inside; " +
2145
+ 'with runtimeStageId, its value in full as of that step.',
2034
2146
  },
2035
2147
  variable: {
2036
2148
  type: 'string',
@@ -2052,49 +2164,163 @@ function buildInspectToolRun(artifacts, reader, options) {
2052
2164
  const record = lookup.get(toolCallId);
2053
2165
  if (record === undefined)
2054
2166
  return unknownInnerRunMessage(toolCallId, lookup, reader);
2055
- const inner = innerToolsFor(record);
2167
+ const inner = slot(record.toolCallId, () => openRecord(record));
2056
2168
  if (typeof inner === 'string')
2057
2169
  return inner;
2058
- // Param-shaped dispatch (the `backtrack({ element })` precedent): the
2059
- // narrowest question the caller asked wins, and the default — no
2060
- // extra params at all — is the entry point, exactly as run_overview
2061
- // is the entry point one level up.
2062
- let body;
2063
- if (find !== undefined) {
2064
- body = await callTraceTool(inner, 'find_in_trace', { query: find });
2065
- }
2066
- else if (variable !== undefined) {
2067
- body = await callTraceTool(inner, 'backtrack', { variable });
2068
- }
2069
- else if (runtimeStageId !== undefined && key !== undefined) {
2070
- body = await callTraceTool(inner, 'get_value', { runtimeStageId, key });
2071
- }
2072
- else if (runtimeStageId !== undefined) {
2073
- body = await callTraceTool(inner, 'trace_node', { runtimeStageId });
2074
- }
2075
- else if (key !== undefined) {
2076
- body =
2077
- `'key' names a value AS OF a step, so it needs a step: pass runtimeStageId too, or ` +
2078
- `use 'variable' to ask why '${(0, bounded_js_1.displayKey)(key)}' is what it is across the whole inner ` +
2079
- `run.`;
2080
- }
2081
- else {
2082
- body = await callTraceTool(inner, 'run_overview', {});
2083
- }
2084
- return [
2085
- `INSIDE TOOL CALL ${toolCallId} — '${record.toolName}' ran a recorded flowchart ` +
2170
+ const body = await (0, innerDescent_js_1.askInner)(inner, { runtimeStageId, key, variable, find }, callTraceTool);
2171
+ return (0, innerDescent_js_1.framed)({
2172
+ header: `INSIDE TOOL CALL ${toolCallId} — '${record.toolName}' ran a recorded flowchart ` +
2086
2173
  `(${record.steps} committed step(s), ${record.outcome}).`,
2087
- body,
2088
- `next inside call '${toolCallId}': inspect_tool_run({ toolCallId: '${toolCallId}', ` +
2174
+ next: `next inside call '${toolCallId}': inspect_tool_run({ toolCallId: '${toolCallId}', ` +
2089
2175
  `runtimeStageId: '<inner id>' }) opens a step · add 'key' for a value in full · ` +
2090
2176
  `'variable' asks why an inner value is what it is · 'find' searches this inner run.`,
2091
- `⚠ the ids above are INNER ids — they name steps of ${record.toolName}'s own chart, not ` +
2092
- `of the run that called it. trace_node / get_value / trace_slice do not accept them; ` +
2093
- `come back through inspect_tool_run.`,
2094
- ].join('\n');
2177
+ namespace: `⚠ the ids above are INNER ids — they name steps of ${record.toolName}'s own chart, ` +
2178
+ `not of the run that called it. trace_node / get_value / trace_slice do not accept ` +
2179
+ `them; come back through inspect_tool_run.`,
2180
+ }, body);
2181
+ },
2182
+ });
2183
+ }
2184
+ // ── inspect_subflow ────────────────────────────────────────────────────────
2185
+ /** How many mounts a correction names. */
2186
+ const MOUNT_SUGGESTION_CAP = 8;
2187
+ /**
2188
+ * INSIDE a subflow mount — the subflow's OWN log, opened.
2189
+ *
2190
+ * A subflow runs in an isolated runtime and commits to its own log, so this
2191
+ * run's log holds only the mount boundary: what went in, what came back. The
2192
+ * evidence of who wrote a value IN there was always recorded (footprintjs keeps
2193
+ * it in `subflowResults`) — no tool served it. This one does, through the same
2194
+ * descent `inspect_tool_run` uses (`innerDescent`): the inner views are the
2195
+ * pack's own tools over the mount's own record, so the inner answers carry the
2196
+ * same reason codes, folded from the SUBFLOW's own `initialState`.
2197
+ *
2198
+ * - BY REFERENCE. Nothing from inside a subflow is printed until the model
2199
+ * asks; the outer views carry one line naming the door.
2200
+ * - ONE LEVEL AT A TIME. A mount nested inside a subflow is opened through
2201
+ * its parent's pack — this tool walks the chain (`mountChain`), each level
2202
+ * answering only for its own log.
2203
+ * - ITS OWN NAMESPACE. Inner ids are said to be inner on every answer, and
2204
+ * an outer tool handed one corrects toward here (`innerIdMessage`).
2205
+ */
2206
+ function buildInspectSubflow(artifacts, index, options) {
2207
+ const slot = (0, innerDescent_js_1.innerPackSlot)((inner) => traceToolpack(inner, options));
2208
+ const isStep = (id) => index.nodes.has(id) || index.firstIdxOf.has(id);
2209
+ const mountIds = () => index.orderedIds.filter((id) => index.nodes.get(id)?.subflowId);
2210
+ const notAMount = (mount) => {
2211
+ if (isStep(mount)) {
2212
+ return `'${mount}' is an outer step, not a subflow mount — trace_node('${mount}') opens it.`;
2213
+ }
2214
+ const mounts = mountIds();
2215
+ const sameStage = mounts.filter((id) => stagePartOf(id) === mount);
2216
+ if (sameStage.length > 0) {
2217
+ return (`'${mount}' ran ${sameStage.length} time(s); a mount is ONE execution: ` +
2218
+ `${sameStage.slice(0, MOUNT_SUGGESTION_CAP).join(', ')}` +
2219
+ `${sameStage.length > MOUNT_SUGGESTION_CAP ? ', …' : ''}. Retry with one of those ids.`);
2220
+ }
2221
+ if (mounts.length === 0)
2222
+ return `the traced run mounted no subflows — there is no inner log to open.`;
2223
+ return (`unknown mount '${mount}'. Subflow mounts in the traced run: ` +
2224
+ `${mounts.slice(0, MOUNT_SUGGESTION_CAP).join(', ')}` +
2225
+ `${mounts.length > MOUNT_SUGGESTION_CAP ? ', …' : ''}.`);
2226
+ };
2227
+ return (0, tools_js_1.defineTool)({
2228
+ name: 'inspect_subflow',
2229
+ description: "Open a [subflow] step's OWN log (the run's log holds only its boundary). Mount id alone: " +
2230
+ "inner overview. 'key': its last writer inside. 'variable': why it is what it is. " +
2231
+ "'find': search. 'runtimeStageId' (+'key'): one inner step (value). Inner ids go back here.",
2232
+ inputSchema: {
2233
+ type: 'object',
2234
+ properties: {
2235
+ mount: { type: 'string', description: "The mount step, e.g. 'sf-tools#11'." },
2236
+ runtimeStageId: { type: 'string', description: 'Optional: an inner step id.' },
2237
+ key: { type: 'string', description: 'Optional: an inner state key.' },
2238
+ variable: { type: 'string', description: 'Optional: an inner state key to explain.' },
2239
+ find: { type: 'string', description: 'Optional: free text to locate inside.' },
2240
+ },
2241
+ required: ['mount'],
2242
+ additionalProperties: false,
2243
+ },
2244
+ execute: async ({ mount, runtimeStageId, key, variable, find }) => {
2245
+ const question = { runtimeStageId, key, variable, find };
2246
+ const results = index.subflowResults;
2247
+ const isMount = index.nodes.get(mount)?.subflowId !== undefined;
2248
+ // A mount nested below this level: open its parent here, ask there.
2249
+ if (!isMount && !isStep(mount) && results !== undefined) {
2250
+ const chain = (0, subflowRecords_js_1.mountChain)(results, mount, isStep);
2251
+ if (chain !== undefined && chain.length > 1) {
2252
+ const parent = chain[0];
2253
+ const pack = slot(parent, () => openSubflowArtifacts(artifacts, parent));
2254
+ if (typeof pack === 'string')
2255
+ return pack;
2256
+ return callTraceTool(pack, 'inspect_subflow', { mount, ...definedOf(question) });
2257
+ }
2258
+ }
2259
+ if (!isMount)
2260
+ return notAMount(mount);
2261
+ if (runtimeStageId !== undefined &&
2262
+ runtimeStageId !== mount &&
2263
+ isStep(runtimeStageId) &&
2264
+ index.homeMountOf(runtimeStageId) !== mount) {
2265
+ return (`'${runtimeStageId}' is a step of the run ABOVE subflow ${mount}, not of its own log — ` +
2266
+ `trace_node('${runtimeStageId}') opens it there.`);
2267
+ }
2268
+ const inner = slot(mount, () => openSubflowArtifacts(artifacts, mount));
2269
+ if (typeof inner === 'string')
2270
+ return inner;
2271
+ const body = await (0, innerDescent_js_1.askInner)(inner, question, callTraceTool);
2272
+ const name = index.nodes.get(mount)?.name;
2273
+ const parent = index.homeMountOf(mount);
2274
+ const commits = (0, subflowRecords_js_1.innerCommitCount)(index.subflowResults, mount);
2275
+ return (0, innerDescent_js_1.framed)({
2276
+ header: `INSIDE SUBFLOW ${mount}${name !== undefined ? ` — "${name}"` : ''}` +
2277
+ `${parent !== undefined ? ` (nested in ${parent})` : ''}: its own log, ` +
2278
+ `${commits} commit(s)${(0, subflowRecords_js_1.opensWithSeed)(index.subflowResults, mount) ? ", the mount's seed first" : ''}.`,
2279
+ next: `next inside '${mount}': inspect_subflow({ mount: '${mount}', runtimeStageId: ` +
2280
+ `'<inner id>' }) opens a step · 'key' alone names its last writer inside · 'variable' ` +
2281
+ `asks why an inner value is what it is · 'find' searches this inner log.`,
2282
+ namespace: `⚠ the ids above are INNER ids — steps of subflow ${mount}'s own log, not of the run ` +
2283
+ `that mounted it. trace_node / get_value / trace_slice correct them back here.`,
2284
+ }, body);
2095
2285
  },
2096
2286
  });
2097
2287
  }
2288
+ /**
2289
+ * The run's own control-dependence lookup, keyed by every subflow bag opened
2290
+ * below it — so each level filters the RUN's edges to its own log
2291
+ * (`openSubflowArtifacts`), at any depth.
2292
+ */
2293
+ const RAW_CONTROL_DEPS = new WeakMap();
2294
+ /** The mount's record as an artifact bag, or why there is none. */
2295
+ function openSubflowArtifacts(artifacts, mount) {
2296
+ const opened = (0, subflowRecords_js_1.openSubflow)(artifacts.snapshot, mount);
2297
+ if (typeof opened === 'string')
2298
+ return `inspect_subflow: ${opened}`;
2299
+ // Step ids are unique across a run, so the RUN's lookup answers inner ids —
2300
+ // but a decider OUTSIDE this log is not an inner step: keep only edges from
2301
+ // a decider in the mount's own log, so no outer id is served as an inner one.
2302
+ // Always filter the run's RAW lookup, never this level's filtered one: a
2303
+ // nested mount's deciders are not in its parent's log, so filtering the
2304
+ // parent's view would drop every edge one level further down.
2305
+ const raw = RAW_CONTROL_DEPS.get(artifacts) ?? artifacts.controlDeps;
2306
+ const innerIds = new Set(opened.commitLog.map((bundle) => bundle.runtimeStageId));
2307
+ const bag = {
2308
+ snapshot: opened,
2309
+ ...(raw !== undefined && {
2310
+ controlDeps: (id) => {
2311
+ const dep = raw(id);
2312
+ return dep !== undefined && innerIds.has(dep.deciderId) ? dep : undefined;
2313
+ },
2314
+ }),
2315
+ };
2316
+ if (raw !== undefined)
2317
+ RAW_CONTROL_DEPS.set(bag, raw);
2318
+ return bag;
2319
+ }
2320
+ /** The question's params that were actually given (strict schemas refuse `undefined`). */
2321
+ function definedOf(question) {
2322
+ return Object.fromEntries(Object.entries(question).filter((entry) => entry[1] !== undefined));
2323
+ }
2098
2324
  /** No tool in this run keeps a record — name the switch, not the emptiness. */
2099
2325
  function noInnerRecordsMessage(toolCallId) {
2100
2326
  return (`inspect_tool_run: nothing in this run kept a record below the tool boundary, so there is ` +