@illuma-ai/agents 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +2 -2
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/common/enum.cjs +12 -12
  4. package/dist/cjs/common/enum.cjs.map +1 -1
  5. package/dist/cjs/graphs/Graph.cjs +5 -5
  6. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  7. package/dist/cjs/graphs/MultiAgentGraph.cjs +1 -1
  8. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  9. package/dist/cjs/graphs/phases/memoryFlushPhase.cjs +1 -1
  10. package/dist/cjs/graphs/phases/memoryFlushPhase.cjs.map +1 -1
  11. package/dist/cjs/hooks/HookRegistry.cjs +1 -1
  12. package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
  13. package/dist/cjs/hooks/matchers.cjs +2 -2
  14. package/dist/cjs/hooks/matchers.cjs.map +1 -1
  15. package/dist/cjs/hooks/types.cjs +1 -1
  16. package/dist/cjs/hooks/types.cjs.map +1 -1
  17. package/dist/cjs/llm/bedrock/cacheSupport.cjs +1 -1
  18. package/dist/cjs/llm/bedrock/cacheSupport.cjs.map +1 -1
  19. package/dist/cjs/llm/bedrock/index.cjs +2 -2
  20. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  21. package/dist/cjs/llm/openai/index.cjs +1 -1
  22. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  23. package/dist/cjs/llm/openai/utils/index.cjs +2 -2
  24. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
  25. package/dist/cjs/memory/citations.cjs +4 -4
  26. package/dist/cjs/memory/citations.cjs.map +1 -1
  27. package/dist/cjs/memory/constants.cjs +17 -17
  28. package/dist/cjs/memory/constants.cjs.map +1 -1
  29. package/dist/cjs/memory/mmr.cjs +1 -1
  30. package/dist/cjs/memory/mmr.cjs.map +1 -1
  31. package/dist/cjs/memory/paths.cjs +1 -1
  32. package/dist/cjs/memory/paths.cjs.map +1 -1
  33. package/dist/cjs/memory/recallTracking.cjs +3 -3
  34. package/dist/cjs/memory/recallTracking.cjs.map +1 -1
  35. package/dist/cjs/memory/temporalDecay.cjs +2 -2
  36. package/dist/cjs/memory/temporalDecay.cjs.map +1 -1
  37. package/dist/cjs/messages/format.cjs +3 -3
  38. package/dist/cjs/messages/format.cjs.map +1 -1
  39. package/dist/cjs/tools/CodeExecutor.cjs +4 -3
  40. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  41. package/dist/cjs/tools/ToolNode.cjs +5 -5
  42. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  43. package/dist/cjs/tools/memory/memoryAppendTool.cjs +1 -1
  44. package/dist/cjs/tools/memory/memoryAppendTool.cjs.map +1 -1
  45. package/dist/cjs/tools/memory/memoryGetTool.cjs +2 -2
  46. package/dist/cjs/tools/memory/memoryGetTool.cjs.map +1 -1
  47. package/dist/cjs/tools/memory/memorySearchTool.cjs +3 -3
  48. package/dist/cjs/tools/memory/memorySearchTool.cjs.map +1 -1
  49. package/dist/cjs/tools/memory/shared.cjs +1 -1
  50. package/dist/cjs/tools/memory/shared.cjs.map +1 -1
  51. package/dist/cjs/types/agent-cache.cjs +6 -5
  52. package/dist/cjs/types/agent-cache.cjs.map +1 -1
  53. package/dist/cjs/types/graph.cjs.map +1 -1
  54. package/dist/esm/agents/AgentContext.mjs +2 -2
  55. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  56. package/dist/esm/common/enum.mjs +12 -12
  57. package/dist/esm/common/enum.mjs.map +1 -1
  58. package/dist/esm/graphs/Graph.mjs +5 -5
  59. package/dist/esm/graphs/Graph.mjs.map +1 -1
  60. package/dist/esm/graphs/MultiAgentGraph.mjs +1 -1
  61. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  62. package/dist/esm/graphs/phases/memoryFlushPhase.mjs +1 -1
  63. package/dist/esm/graphs/phases/memoryFlushPhase.mjs.map +1 -1
  64. package/dist/esm/hooks/HookRegistry.mjs +1 -1
  65. package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
  66. package/dist/esm/hooks/matchers.mjs +2 -2
  67. package/dist/esm/hooks/matchers.mjs.map +1 -1
  68. package/dist/esm/hooks/types.mjs +1 -1
  69. package/dist/esm/hooks/types.mjs.map +1 -1
  70. package/dist/esm/llm/bedrock/cacheSupport.mjs +1 -1
  71. package/dist/esm/llm/bedrock/cacheSupport.mjs.map +1 -1
  72. package/dist/esm/llm/bedrock/index.mjs +2 -2
  73. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  74. package/dist/esm/llm/openai/index.mjs +1 -1
  75. package/dist/esm/llm/openai/index.mjs.map +1 -1
  76. package/dist/esm/llm/openai/utils/index.mjs +2 -2
  77. package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
  78. package/dist/esm/memory/citations.mjs +4 -4
  79. package/dist/esm/memory/citations.mjs.map +1 -1
  80. package/dist/esm/memory/constants.mjs +17 -17
  81. package/dist/esm/memory/constants.mjs.map +1 -1
  82. package/dist/esm/memory/mmr.mjs +1 -1
  83. package/dist/esm/memory/mmr.mjs.map +1 -1
  84. package/dist/esm/memory/paths.mjs +1 -1
  85. package/dist/esm/memory/paths.mjs.map +1 -1
  86. package/dist/esm/memory/recallTracking.mjs +3 -3
  87. package/dist/esm/memory/recallTracking.mjs.map +1 -1
  88. package/dist/esm/memory/temporalDecay.mjs +2 -2
  89. package/dist/esm/memory/temporalDecay.mjs.map +1 -1
  90. package/dist/esm/messages/format.mjs +3 -3
  91. package/dist/esm/messages/format.mjs.map +1 -1
  92. package/dist/esm/tools/CodeExecutor.mjs +4 -3
  93. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  94. package/dist/esm/tools/ToolNode.mjs +5 -5
  95. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  96. package/dist/esm/tools/memory/memoryAppendTool.mjs +1 -1
  97. package/dist/esm/tools/memory/memoryAppendTool.mjs.map +1 -1
  98. package/dist/esm/tools/memory/memoryGetTool.mjs +2 -2
  99. package/dist/esm/tools/memory/memoryGetTool.mjs.map +1 -1
  100. package/dist/esm/tools/memory/memorySearchTool.mjs +3 -3
  101. package/dist/esm/tools/memory/memorySearchTool.mjs.map +1 -1
  102. package/dist/esm/tools/memory/shared.mjs +1 -1
  103. package/dist/esm/tools/memory/shared.mjs.map +1 -1
  104. package/dist/esm/types/agent-cache.mjs +6 -5
  105. package/dist/esm/types/agent-cache.mjs.map +1 -1
  106. package/dist/esm/types/graph.mjs.map +1 -1
  107. package/dist/types/agents/AgentContext.d.ts +1 -1
  108. package/dist/types/common/enum.d.ts +12 -12
  109. package/dist/types/graphs/Graph.d.ts +2 -2
  110. package/dist/types/graphs/phases/memoryFlushPhase.d.ts +2 -2
  111. package/dist/types/hooks/HookRegistry.d.ts +1 -1
  112. package/dist/types/hooks/matchers.d.ts +2 -2
  113. package/dist/types/hooks/types.d.ts +1 -1
  114. package/dist/types/llm/bedrock/cacheSupport.d.ts +1 -1
  115. package/dist/types/llm/bedrock/index.d.ts +2 -2
  116. package/dist/types/llm/openai/index.d.ts +1 -1
  117. package/dist/types/memory/citations.d.ts +4 -4
  118. package/dist/types/memory/constants.d.ts +17 -17
  119. package/dist/types/memory/mmr.d.ts +3 -3
  120. package/dist/types/memory/paths.d.ts +1 -1
  121. package/dist/types/memory/temporalDecay.d.ts +2 -2
  122. package/dist/types/memory/types.d.ts +3 -3
  123. package/dist/types/messages/format.d.ts +1 -1
  124. package/dist/types/tools/ToolNode.d.ts +3 -3
  125. package/dist/types/tools/memory/shared.d.ts +1 -1
  126. package/dist/types/types/agent-cache.d.ts +6 -5
  127. package/dist/types/types/graph.d.ts +7 -6
  128. package/dist/types/types/messages.d.ts +1 -1
  129. package/dist/types/types/run.d.ts +1 -1
  130. package/dist/types/types/tools.d.ts +5 -5
  131. package/package.json +1 -1
  132. package/src/agents/AgentContext.ts +2 -2
  133. package/src/agents/__tests__/AgentContext.crossAgentTier1.live.test.ts +5 -3
  134. package/src/agents/__tests__/AgentContext.test.ts +1 -1
  135. package/src/common/__tests__/enum.test.ts +1 -1
  136. package/src/common/enum.ts +12 -12
  137. package/src/graphs/Graph.ts +5 -5
  138. package/src/graphs/MultiAgentGraph.ts +1 -1
  139. package/src/graphs/gapFeatures.test.ts +1 -1
  140. package/src/graphs/phases/__tests__/memoryFlushPhase.test.ts +1 -1
  141. package/src/graphs/phases/memoryFlushPhase.ts +2 -2
  142. package/src/hooks/HookRegistry.ts +1 -1
  143. package/src/hooks/index.ts +1 -1
  144. package/src/hooks/matchers.ts +2 -2
  145. package/src/hooks/types.ts +1 -1
  146. package/src/llm/anthropic/utils/server-tool-inputs.test.ts +7 -7
  147. package/src/llm/bedrock/__tests__/bedrock-caching.test.ts +2 -2
  148. package/src/llm/bedrock/cacheSupport.ts +1 -1
  149. package/src/llm/bedrock/index.ts +2 -2
  150. package/src/llm/openai/index.ts +2 -2
  151. package/src/llm/openai/utils/index.ts +2 -2
  152. package/src/memory/citations.ts +4 -4
  153. package/src/memory/constants.ts +17 -17
  154. package/src/memory/mmr.ts +3 -3
  155. package/src/memory/paths.ts +1 -1
  156. package/src/memory/recallTracking.ts +3 -3
  157. package/src/memory/temporalDecay.ts +2 -2
  158. package/src/memory/types.ts +3 -3
  159. package/src/messages/cache.test.ts +1 -1
  160. package/src/messages/ensureThinkingBlock.test.ts +1 -1
  161. package/src/messages/format.ts +4 -4
  162. package/src/messages/formatAgentMessages.test.ts +1 -1
  163. package/src/scripts/subagent-event-driven-debug.ts +2 -2
  164. package/src/specs/anthropic.simple.test.ts +1 -1
  165. package/src/specs/prune.orphans.test.ts +1 -1
  166. package/src/tools/CodeExecutor.ts +4 -3
  167. package/src/tools/ToolNode.ts +6 -6
  168. package/src/tools/__tests__/CodeExecutor.test.ts +3 -3
  169. package/src/tools/memory/memoryAppendTool.ts +1 -1
  170. package/src/tools/memory/memoryGetTool.ts +2 -2
  171. package/src/tools/memory/memorySearchTool.ts +3 -3
  172. package/src/tools/memory/shared.ts +1 -1
  173. package/src/types/agent-cache.ts +6 -5
  174. package/src/types/graph.ts +7 -6
  175. package/src/types/messages.ts +1 -1
  176. package/src/types/run.ts +1 -1
  177. package/src/types/tools.ts +5 -5
  178. package/dist/types/tools/search/test.d.ts +0 -1
  179. package/src/agents/AgentContext.js.map +0 -1
  180. package/src/agents/AgentContext.test.js.map +0 -1
  181. package/src/agents/__tests__/AgentContext.test.js.map +0 -1
  182. package/src/agents/__tests__/resolveStructuredOutputMode.test.js.map +0 -1
  183. package/src/common/enum.js.map +0 -1
  184. package/src/common/index.js.map +0 -1
  185. package/src/events.js.map +0 -1
  186. package/src/graphs/Graph.js.map +0 -1
  187. package/src/graphs/MultiAgentGraph.js.map +0 -1
  188. package/src/graphs/__tests__/structured-output.integration.test.js.map +0 -1
  189. package/src/graphs/__tests__/structured-output.test.js.map +0 -1
  190. package/src/graphs/contextManagement.e2e.test.js.map +0 -1
  191. package/src/graphs/contextManagement.test.js.map +0 -1
  192. package/src/graphs/handoffValidation.test.js.map +0 -1
  193. package/src/graphs/index.js.map +0 -1
  194. package/src/index.js.map +0 -1
  195. package/src/instrumentation.js.map +0 -1
  196. package/src/llm/anthropic/index.js.map +0 -1
  197. package/src/llm/anthropic/types.js.map +0 -1
  198. package/src/llm/anthropic/utils/message_inputs.js.map +0 -1
  199. package/src/llm/anthropic/utils/message_outputs.js.map +0 -1
  200. package/src/llm/anthropic/utils/output_parsers.js.map +0 -1
  201. package/src/llm/anthropic/utils/tools.js.map +0 -1
  202. package/src/llm/bedrock/__tests__/bedrock-caching.test.js.map +0 -1
  203. package/src/llm/bedrock/index.js.map +0 -1
  204. package/src/llm/bedrock/types.js.map +0 -1
  205. package/src/llm/bedrock/utils/index.js.map +0 -1
  206. package/src/llm/bedrock/utils/message_inputs.js.map +0 -1
  207. package/src/llm/bedrock/utils/message_outputs.js.map +0 -1
  208. package/src/llm/fake.js.map +0 -1
  209. package/src/llm/google/index.js.map +0 -1
  210. package/src/llm/google/types.js.map +0 -1
  211. package/src/llm/google/utils/common.js.map +0 -1
  212. package/src/llm/google/utils/tools.js.map +0 -1
  213. package/src/llm/google/utils/zod_to_genai_parameters.js.map +0 -1
  214. package/src/llm/openai/index.js.map +0 -1
  215. package/src/llm/openai/types.js.map +0 -1
  216. package/src/llm/openai/utils/index.js.map +0 -1
  217. package/src/llm/openai/utils/isReasoningModel.test.js.map +0 -1
  218. package/src/llm/openrouter/index.js.map +0 -1
  219. package/src/llm/openrouter/reasoning.test.js.map +0 -1
  220. package/src/llm/providers.js.map +0 -1
  221. package/src/llm/text.js.map +0 -1
  222. package/src/llm/vertexai/index.js.map +0 -1
  223. package/src/messages/__tests__/tools.test.js.map +0 -1
  224. package/src/messages/cache.js.map +0 -1
  225. package/src/messages/cache.test.js.map +0 -1
  226. package/src/messages/content.js.map +0 -1
  227. package/src/messages/content.test.js.map +0 -1
  228. package/src/messages/core.js.map +0 -1
  229. package/src/messages/ensureThinkingBlock.test.js.map +0 -1
  230. package/src/messages/format.js.map +0 -1
  231. package/src/messages/formatAgentMessages.test.js.map +0 -1
  232. package/src/messages/formatAgentMessages.tools.test.js.map +0 -1
  233. package/src/messages/formatMessage.test.js.map +0 -1
  234. package/src/messages/ids.js.map +0 -1
  235. package/src/messages/index.js.map +0 -1
  236. package/src/messages/labelContentByAgent.test.js.map +0 -1
  237. package/src/messages/prune.js.map +0 -1
  238. package/src/messages/reducer.js.map +0 -1
  239. package/src/messages/shiftIndexTokenCountMap.test.js.map +0 -1
  240. package/src/messages/summarize.js.map +0 -1
  241. package/src/messages/summarize.test.js.map +0 -1
  242. package/src/messages/tools.js.map +0 -1
  243. package/src/mockStream.js.map +0 -1
  244. package/src/prompts/collab.js.map +0 -1
  245. package/src/prompts/index.js.map +0 -1
  246. package/src/prompts/taskmanager.js.map +0 -1
  247. package/src/run.js.map +0 -1
  248. package/src/schemas/index.js.map +0 -1
  249. package/src/schemas/schema-preparation.test.js.map +0 -1
  250. package/src/schemas/validate.js.map +0 -1
  251. package/src/schemas/validate.test.js.map +0 -1
  252. package/src/scripts/abort.js.map +0 -1
  253. package/src/scripts/ant_web_search.js.map +0 -1
  254. package/src/scripts/ant_web_search_edge_case.js.map +0 -1
  255. package/src/scripts/ant_web_search_error_edge_case.js.map +0 -1
  256. package/src/scripts/args.js.map +0 -1
  257. package/src/scripts/bedrock-cache-debug.js.map +0 -1
  258. package/src/scripts/bedrock-content-aggregation-test.js.map +0 -1
  259. package/src/scripts/bedrock-merge-test.js.map +0 -1
  260. package/src/scripts/bedrock-parallel-tools-test.js.map +0 -1
  261. package/src/scripts/caching.js.map +0 -1
  262. package/src/scripts/cli.js.map +0 -1
  263. package/src/scripts/cli2.js.map +0 -1
  264. package/src/scripts/cli3.js.map +0 -1
  265. package/src/scripts/cli4.js.map +0 -1
  266. package/src/scripts/cli5.js.map +0 -1
  267. package/src/scripts/code_exec.js.map +0 -1
  268. package/src/scripts/code_exec_files.js.map +0 -1
  269. package/src/scripts/code_exec_multi_session.js.map +0 -1
  270. package/src/scripts/code_exec_ptc.js.map +0 -1
  271. package/src/scripts/code_exec_session.js.map +0 -1
  272. package/src/scripts/code_exec_simple.js.map +0 -1
  273. package/src/scripts/content.js.map +0 -1
  274. package/src/scripts/empty_input.js.map +0 -1
  275. package/src/scripts/handoff-test.js.map +0 -1
  276. package/src/scripts/image.js.map +0 -1
  277. package/src/scripts/memory.js.map +0 -1
  278. package/src/scripts/multi-agent-chain.js.map +0 -1
  279. package/src/scripts/multi-agent-conditional.js.map +0 -1
  280. package/src/scripts/multi-agent-document-review-chain.js.map +0 -1
  281. package/src/scripts/multi-agent-hybrid-flow.js.map +0 -1
  282. package/src/scripts/multi-agent-parallel-start.js.map +0 -1
  283. package/src/scripts/multi-agent-parallel.js.map +0 -1
  284. package/src/scripts/multi-agent-sequence.js.map +0 -1
  285. package/src/scripts/multi-agent-supervisor.js.map +0 -1
  286. package/src/scripts/multi-agent-test.js.map +0 -1
  287. package/src/scripts/parallel-asymmetric-tools-test.js.map +0 -1
  288. package/src/scripts/parallel-full-metadata-test.js.map +0 -1
  289. package/src/scripts/parallel-tools-test.js.map +0 -1
  290. package/src/scripts/programmatic_exec.js.map +0 -1
  291. package/src/scripts/programmatic_exec_agent.js.map +0 -1
  292. package/src/scripts/search.js.map +0 -1
  293. package/src/scripts/sequential-full-metadata-test.js.map +0 -1
  294. package/src/scripts/simple.js.map +0 -1
  295. package/src/scripts/single-agent-metadata-test.js.map +0 -1
  296. package/src/scripts/stream.js.map +0 -1
  297. package/src/scripts/test-custom-prompt-key.js.map +0 -1
  298. package/src/scripts/test-handoff-input.js.map +0 -1
  299. package/src/scripts/test-handoff-preamble.js.map +0 -1
  300. package/src/scripts/test-handoff-steering.js.map +0 -1
  301. package/src/scripts/test-multi-agent-list-handoff.js.map +0 -1
  302. package/src/scripts/test-parallel-agent-labeling.js.map +0 -1
  303. package/src/scripts/test-parallel-handoffs.js.map +0 -1
  304. package/src/scripts/test-thinking-handoff-bedrock.js.map +0 -1
  305. package/src/scripts/test-thinking-handoff.js.map +0 -1
  306. package/src/scripts/test-thinking-to-thinking-handoff-bedrock.js.map +0 -1
  307. package/src/scripts/test-tool-before-handoff-role-order.js.map +0 -1
  308. package/src/scripts/test-tools-before-handoff.js.map +0 -1
  309. package/src/scripts/test_code_api.js.map +0 -1
  310. package/src/scripts/thinking-bedrock.js.map +0 -1
  311. package/src/scripts/thinking-vertexai.js.map +0 -1
  312. package/src/scripts/thinking.js.map +0 -1
  313. package/src/scripts/tool_search.js.map +0 -1
  314. package/src/scripts/tools.js.map +0 -1
  315. package/src/specs/agent-handoffs-bedrock.integration.test.js.map +0 -1
  316. package/src/specs/agent-handoffs.test.js.map +0 -1
  317. package/src/specs/anthropic.simple.test.js.map +0 -1
  318. package/src/specs/azure.simple.test.js.map +0 -1
  319. package/src/specs/cache.simple.test.js.map +0 -1
  320. package/src/specs/custom-event-await.test.js.map +0 -1
  321. package/src/specs/deepseek.simple.test.js.map +0 -1
  322. package/src/specs/emergency-prune.test.js.map +0 -1
  323. package/src/specs/moonshot.simple.test.js.map +0 -1
  324. package/src/specs/observability.integration.test.js.map +0 -1
  325. package/src/specs/openai.simple.test.js.map +0 -1
  326. package/src/specs/openrouter.simple.test.js.map +0 -1
  327. package/src/specs/prune.test.js.map +0 -1
  328. package/src/specs/reasoning.test.js.map +0 -1
  329. package/src/specs/spec.utils.js.map +0 -1
  330. package/src/specs/thinking-handoff.test.js.map +0 -1
  331. package/src/specs/thinking-prune.test.js.map +0 -1
  332. package/src/specs/token-distribution-edge-case.test.js.map +0 -1
  333. package/src/specs/token-memoization.test.js.map +0 -1
  334. package/src/specs/tokens.test.js.map +0 -1
  335. package/src/specs/tool-error.test.js.map +0 -1
  336. package/src/splitStream.js.map +0 -1
  337. package/src/splitStream.test.js.map +0 -1
  338. package/src/stream.js.map +0 -1
  339. package/src/stream.test.js.map +0 -1
  340. package/src/test/mockTools.js.map +0 -1
  341. package/src/tools/BrowserTools.js.map +0 -1
  342. package/src/tools/Calculator.js.map +0 -1
  343. package/src/tools/Calculator.test.js.map +0 -1
  344. package/src/tools/CodeExecutor.js.map +0 -1
  345. package/src/tools/ProgrammaticToolCalling.js.map +0 -1
  346. package/src/tools/StreamingToolCallBuffer.js.map +0 -1
  347. package/src/tools/ToolNode.js.map +0 -1
  348. package/src/tools/ToolSearch.js.map +0 -1
  349. package/src/tools/__tests__/BrowserTools.test.js.map +0 -1
  350. package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.js.map +0 -1
  351. package/src/tools/__tests__/ProgrammaticToolCalling.test.js.map +0 -1
  352. package/src/tools/__tests__/StreamingToolCallBuffer.test.js.map +0 -1
  353. package/src/tools/__tests__/ToolApproval.test.js.map +0 -1
  354. package/src/tools/__tests__/ToolNode.recovery.test.js.map +0 -1
  355. package/src/tools/__tests__/ToolNode.session.test.js.map +0 -1
  356. package/src/tools/__tests__/ToolSearch.integration.test.js.map +0 -1
  357. package/src/tools/__tests__/ToolSearch.test.js.map +0 -1
  358. package/src/tools/__tests__/handlers.test.js.map +0 -1
  359. package/src/tools/__tests__/truncation-recovery.integration.test.js.map +0 -1
  360. package/src/tools/handlers.js.map +0 -1
  361. package/src/tools/schema.js.map +0 -1
  362. package/src/tools/search/anthropic.js.map +0 -1
  363. package/src/tools/search/content.js.map +0 -1
  364. package/src/tools/search/content.test.js.map +0 -1
  365. package/src/tools/search/firecrawl.js.map +0 -1
  366. package/src/tools/search/format.js.map +0 -1
  367. package/src/tools/search/highlights.js.map +0 -1
  368. package/src/tools/search/index.js.map +0 -1
  369. package/src/tools/search/jina-reranker.test.js.map +0 -1
  370. package/src/tools/search/output.md +0 -2775
  371. package/src/tools/search/rerankers.js.map +0 -1
  372. package/src/tools/search/schema.js.map +0 -1
  373. package/src/tools/search/search.js.map +0 -1
  374. package/src/tools/search/serper-scraper.js.map +0 -1
  375. package/src/tools/search/test.html +0 -884
  376. package/src/tools/search/test.js.map +0 -1
  377. package/src/tools/search/test.md +0 -643
  378. package/src/tools/search/test.ts +0 -159
  379. package/src/tools/search/tool.js.map +0 -1
  380. package/src/tools/search/types.js.map +0 -1
  381. package/src/tools/search/utils.js.map +0 -1
  382. package/src/types/graph.js.map +0 -1
  383. package/src/types/graph.test.js.map +0 -1
  384. package/src/types/index.js.map +0 -1
  385. package/src/types/llm.js.map +0 -1
  386. package/src/types/messages.js.map +0 -1
  387. package/src/types/run.js.map +0 -1
  388. package/src/types/stream.js.map +0 -1
  389. package/src/types/tools.js.map +0 -1
  390. package/src/utils/contextAnalytics.js.map +0 -1
  391. package/src/utils/contextAnalytics.test.js.map +0 -1
  392. package/src/utils/events.js.map +0 -1
  393. package/src/utils/graph.js.map +0 -1
  394. package/src/utils/handlers.js.map +0 -1
  395. package/src/utils/index.js.map +0 -1
  396. package/src/utils/llm.js.map +0 -1
  397. package/src/utils/llmConfig.js.map +0 -1
  398. package/src/utils/logging.js.map +0 -1
  399. package/src/utils/misc.js.map +0 -1
  400. package/src/utils/run.js.map +0 -1
  401. package/src/utils/schema.js.map +0 -1
  402. package/src/utils/title.js.map +0 -1
  403. package/src/utils/tokens.js.map +0 -1
  404. package/src/utils/toonFormat.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../../../src/hooks/types.ts"],"sourcesContent":["// src/hooks/types.ts\nimport type { BaseMessage } from '@langchain/core/messages';\n\n/**\n * Closed set of hook lifecycle events supported by the hooks system.\n *\n * These mirror the subset of Claude Code's event surface that makes sense\n * for a library context (no filesystem/CLI-specific events). See\n * `docs/hooks-design-report.md` §3.2 for the mapping to existing\n * `@librechat/agents` emission points.\n */\nexport const HOOK_EVENTS = [\n 'RunStart',\n 'UserPromptSubmit',\n 'PreToolUse',\n 'PostToolUse',\n 'PostToolUseFailure',\n 'PermissionDenied',\n 'SubagentStart',\n 'SubagentStop',\n 'Stop',\n 'StopFailure',\n 'PreCompact',\n 'PostCompact',\n] as const;\n\nexport type HookEvent = (typeof HOOK_EVENTS)[number];\n\n/** Tool-gating decision; executeHooks folds with `deny > ask > allow` precedence. */\nexport type ToolDecision = 'allow' | 'deny' | 'ask';\n\n/** Stop-loop decision; `block` means \"do not stop, run another turn\". Any `block` wins. */\nexport type StopDecision = 'continue' | 'block';\n\n/**\n * Fields shared by every `HookInput`. Discriminated by `hook_event_name`.\n *\n * - `runId` identifies the current agent run and is always present.\n * - `threadId` identifies the conversation thread when the host has one.\n * - `agentId` is only set when the hook fires inside a subagent scope.\n */\nexport interface BaseHookInput {\n runId: string;\n threadId?: string;\n agentId?: string;\n}\n\nexport interface RunStartHookInput extends BaseHookInput {\n hook_event_name: 'RunStart';\n messages: BaseMessage[];\n}\n\nexport interface UserPromptSubmitHookInput extends BaseHookInput {\n hook_event_name: 'UserPromptSubmit';\n prompt: string;\n attachments?: BaseMessage[];\n}\n\n/**\n * Fires before a tool is invoked. Hook may return `deny`/`ask`/`allow` and/or\n * an `updatedInput` that replaces the tool arguments before invocation.\n *\n * `toolInput` is intentionally typed as `Record<string, unknown>` because the\n * SDK is tool-agnostic — concrete tool argument shapes are only known at the\n * call site and are narrowed by the host. This is the one escape hatch in\n * the hook type system.\n */\nexport interface PreToolUseHookInput extends BaseHookInput {\n hook_event_name: 'PreToolUse';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolUseId: string;\n stepId?: string;\n /**\n * Number of times this tool has been invoked in prior batches within the\n * current run. Within a single batch of parallel calls, all calls to the\n * same tool share the same turn value — per-call discrimination within a\n * batch is not supported in v1.\n */\n turn?: number;\n}\n\nexport interface PostToolUseHookInput extends BaseHookInput {\n hook_event_name: 'PostToolUse';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolOutput: unknown;\n toolUseId: string;\n stepId?: string;\n turn?: number;\n}\n\nexport interface PostToolUseFailureHookInput extends BaseHookInput {\n hook_event_name: 'PostToolUseFailure';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolUseId: string;\n error: string;\n stepId?: string;\n turn?: number;\n}\n\nexport interface PermissionDeniedHookInput extends BaseHookInput {\n hook_event_name: 'PermissionDenied';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolUseId: string;\n reason: string;\n}\n\nexport interface SubagentStartHookInput extends BaseHookInput {\n hook_event_name: 'SubagentStart';\n parentAgentId?: string;\n agentId: string;\n agentType: string;\n inputs: BaseMessage[];\n}\n\nexport interface SubagentStopHookInput extends BaseHookInput {\n hook_event_name: 'SubagentStop';\n agentId: string;\n agentType: string;\n messages: BaseMessage[];\n}\n\nexport interface StopHookInput extends BaseHookInput {\n hook_event_name: 'Stop';\n messages: BaseMessage[];\n stopReason?: string;\n stopHookActive: boolean;\n}\n\nexport interface StopFailureHookInput extends BaseHookInput {\n hook_event_name: 'StopFailure';\n error: string;\n lastAssistantMessage?: BaseMessage;\n}\n\nexport interface PreCompactHookInput extends BaseHookInput {\n hook_event_name: 'PreCompact';\n messagesBeforeCount: number;\n /**\n * What triggered compaction. Matches `SummarizationTrigger.type` from the\n * agent's summarization config. `'default'` means no trigger was\n * configured and compaction fired because messages were pruned.\n */\n trigger:\n | 'token_ratio'\n | 'remaining_tokens'\n | 'messages_to_refine'\n | 'default'\n | (string & {});\n}\n\nexport interface PostCompactHookInput extends BaseHookInput {\n hook_event_name: 'PostCompact';\n summary: string;\n /**\n * Number of messages remaining after compaction. The summarize node\n * returns a `removeAll` signal that clears all messages from state;\n * the summary itself is injected into the system prompt, not as a\n * message. This is `0` at the point of hook dispatch.\n */\n messagesAfterCount: number;\n}\n\n/** Discriminated union of every hook input shape. */\nexport type HookInput =\n | RunStartHookInput\n | UserPromptSubmitHookInput\n | PreToolUseHookInput\n | PostToolUseHookInput\n | PostToolUseFailureHookInput\n | PermissionDeniedHookInput\n | SubagentStartHookInput\n | SubagentStopHookInput\n | StopHookInput\n | StopFailureHookInput\n | PreCompactHookInput\n | PostCompactHookInput;\n\n/** Compile-time map from event name to its input shape. */\nexport type HookInputByEvent = {\n RunStart: RunStartHookInput;\n UserPromptSubmit: UserPromptSubmitHookInput;\n PreToolUse: PreToolUseHookInput;\n PostToolUse: PostToolUseHookInput;\n PostToolUseFailure: PostToolUseFailureHookInput;\n PermissionDenied: PermissionDeniedHookInput;\n SubagentStart: SubagentStartHookInput;\n SubagentStop: SubagentStopHookInput;\n Stop: StopHookInput;\n StopFailure: StopFailureHookInput;\n PreCompact: PreCompactHookInput;\n PostCompact: PostCompactHookInput;\n};\n\n/**\n * Fields common to every hook output. Hooks that have nothing to say simply\n * return `{}` (or omit the fields below).\n */\nexport interface BaseHookOutput {\n /** Context string to inject into the conversation. Accumulated across hooks. */\n additionalContext?: string;\n /** True to prevent the next model turn. Any hook can set this. */\n preventContinuation?: boolean;\n /** Reason reported alongside `preventContinuation`. */\n stopReason?: string;\n}\n\nexport type RunStartHookOutput = BaseHookOutput;\n\nexport interface UserPromptSubmitHookOutput extends BaseHookOutput {\n decision?: ToolDecision;\n reason?: string;\n}\n\nexport interface PreToolUseHookOutput extends BaseHookOutput {\n decision?: ToolDecision;\n reason?: string;\n /**\n * Replacement tool input. Merged into the pending tool call by the host.\n *\n * When multiple hooks set `updatedInput` within a single `executeHooks`\n * call, the last writer in registration order wins (outer loop: matcher\n * registration order; inner loop: hook position within the matcher). The\n * winner is deterministic — `Promise.all` preserves input-array order.\n * Consumers that need a single authoritative rewrite should still scope\n * `updatedInput` to one hook per matcher to avoid confusing precedence.\n */\n updatedInput?: Record<string, unknown>;\n}\n\nexport interface PostToolUseHookOutput extends BaseHookOutput {\n /**\n * Replacement tool output. Flows through the aggregated result so the\n * host can substitute it before appending the tool result message.\n * Ordering semantics match `PreToolUseHookOutput.updatedInput`:\n * last-writer-wins in registration order.\n */\n updatedOutput?: unknown;\n}\n\nexport type PostToolUseFailureHookOutput = BaseHookOutput;\n\nexport type PermissionDeniedHookOutput = BaseHookOutput;\n\nexport interface SubagentStartHookOutput extends BaseHookOutput {\n decision?: ToolDecision;\n reason?: string;\n}\n\nexport type SubagentStopHookOutput = BaseHookOutput;\n\nexport interface StopHookOutput extends BaseHookOutput {\n decision?: StopDecision;\n reason?: string;\n}\n\nexport type StopFailureHookOutput = BaseHookOutput;\n\nexport type PreCompactHookOutput = BaseHookOutput;\n\nexport type PostCompactHookOutput = BaseHookOutput;\n\n/** Compile-time map from event name to its output shape. */\nexport type HookOutputByEvent = {\n RunStart: RunStartHookOutput;\n UserPromptSubmit: UserPromptSubmitHookOutput;\n PreToolUse: PreToolUseHookOutput;\n PostToolUse: PostToolUseHookOutput;\n PostToolUseFailure: PostToolUseFailureHookOutput;\n PermissionDenied: PermissionDeniedHookOutput;\n SubagentStart: SubagentStartHookOutput;\n SubagentStop: SubagentStopHookOutput;\n Stop: StopHookOutput;\n StopFailure: StopFailureHookOutput;\n PreCompact: PreCompactHookOutput;\n PostCompact: PostCompactHookOutput;\n};\n\n/** Superset output shape used by the executor's fold loop. */\nexport type HookOutput =\n | RunStartHookOutput\n | UserPromptSubmitHookOutput\n | PreToolUseHookOutput\n | PostToolUseHookOutput\n | PostToolUseFailureHookOutput\n | PermissionDeniedHookOutput\n | SubagentStartHookOutput\n | SubagentStopHookOutput\n | StopHookOutput\n | StopFailureHookOutput\n | PreCompactHookOutput\n | PostCompactHookOutput;\n\n/**\n * A hook callback is a plain async function registered against a specific\n * event. The `signal` is always supplied by `executeHooks` and combines the\n * batch's parent signal with the per-hook timeout — callbacks that perform\n * long-running work should observe it.\n */\nexport type HookCallback<E extends HookEvent = HookEvent> = (\n input: HookInputByEvent[E],\n signal: AbortSignal\n) => HookOutputByEvent[E] | Promise<HookOutputByEvent[E]>;\n\n/**\n * A matcher groups one or more callbacks under a shared regex filter and\n * shared timeout/once/internal flags. The generic `E` ties the callback\n * types to the event the matcher is registered against.\n */\nexport interface HookMatcher<E extends HookEvent = HookEvent> {\n /**\n * Regex pattern matched against the event's primary query string (e.g.\n * the tool name for `PreToolUse`, the agent type for `SubagentStart`).\n *\n * Omitted or empty means \"always match\". For events that do not supply a\n * query string (`RunStart`, `Stop`, etc.), only wildcard matchers fire —\n * a non-empty pattern on such events will never match.\n *\n * Patterns are treated as trusted input: `executeHooks` compiles them\n * with `new RegExp(pattern)` without any sandbox, and a pathological\n * pattern can block the event loop. Host registration code is expected\n * to validate or length-bound patterns that originate from user input.\n */\n pattern?: string;\n /** Callbacks that fire when the matcher hits. Executed in parallel. */\n hooks: HookCallback<E>[];\n /** Per-matcher timeout in ms. Defaults to the executor's batch timeout. */\n timeout?: number;\n /**\n * Atomically remove the matcher before its first dispatch.\n *\n * `executeHooks` claims `once: true` matchers synchronously — between\n * `getMatchers` and its first `await` — so two concurrent calls cannot\n * both dispatch the same matcher. Whichever call runs its sync prefix\n * first wins the matcher; the other sees an empty bucket.\n *\n * Semantics are \"at most one dispatch, ever\" — if every hook in the\n * matcher throws, the matcher is still gone. Use `once` for\n * fire-and-forget bootstrapping (registration, telemetry, setup). Hosts\n * that need retry semantics should register a normal matcher and\n * self-unregister via the callback returned from `registry.register`.\n */\n once?: boolean;\n /** Internal hooks are excluded from telemetry and non-fatal error logging. */\n internal?: boolean;\n}\n\n/**\n * Storage shape for matchers keyed by event. Each event's matcher list is\n * a generic array parameterized by that event type, so lookup via\n * `HooksByEvent[E]` preserves type-safe callback signatures.\n */\nexport type HooksByEvent = {\n [E in HookEvent]?: HookMatcher<E>[];\n};\n\n/**\n * Aggregated result of a single `executeHooks` call. Fields are populated\n * according to the fold rules in `executeHooks.ts`.\n */\nexport interface AggregatedHookResult {\n /** Folded tool-gating decision; `deny > ask > allow`. */\n decision?: ToolDecision;\n /** Folded stop decision; any `block` wins. */\n stopDecision?: StopDecision;\n /** Reason from the hook that set the winning decision. */\n reason?: string;\n /**\n * Replacement tool input from a `PreToolUse` hook.\n *\n * Last-writer-wins in **registration order**: `executeHooks` uses\n * `Promise.all`, which preserves input-array order, so the fold iterates\n * outcomes in the same order they were pushed — outer loop over matchers\n * as they sit in the registry, inner loop over each matcher's `hooks`\n * array. The winner is therefore deterministic but may not match the\n * order in which hooks actually completed. Consumers that want a single\n * authoritative rewrite should still register one `updatedInput`-setting\n * hook per matcher to avoid subtle precedence bugs.\n */\n updatedInput?: Record<string, unknown>;\n /**\n * Replacement tool output from a `PostToolUse` hook.\n *\n * Same last-writer-wins-in-registration-order semantics as\n * `updatedInput`. Present only when at least one hook set it; `undefined`\n * means \"use the original tool output\".\n */\n updatedOutput?: unknown;\n /** Accumulated `additionalContext` strings from every hook, in order. */\n additionalContexts: string[];\n /** True if any hook returned `preventContinuation`. */\n preventContinuation?: boolean;\n /**\n * Reason recorded alongside `preventContinuation`. First winner wins:\n * once a hook sets both flags, later hooks that also set\n * `preventContinuation` do not overwrite the reason.\n */\n stopReason?: string;\n /** Error messages from hooks that threw; always present (possibly empty). */\n errors: string[];\n}\n"],"names":[],"mappings":";;AAGA;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG;IACzB,UAAU;IACV,kBAAkB;IAClB,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,kBAAkB;IAClB,eAAe;IACf,cAAc;IACd,MAAM;IACN,aAAa;IACb,YAAY;IACZ,aAAa;;;;;"}
1
+ {"version":3,"file":"types.cjs","sources":["../../../src/hooks/types.ts"],"sourcesContent":["// src/hooks/types.ts\nimport type { BaseMessage } from '@langchain/core/messages';\n\n/**\n * Closed set of hook lifecycle events supported by the hooks system.\n *\n * These mirror the subset of Claude Code's event surface that makes sense\n * for a library context (no filesystem/CLI-specific events). See\n * `docs/hooks-design-report.md` §3.2 for the mapping to existing\n * `@illuma-ai/agents` emission points.\n */\nexport const HOOK_EVENTS = [\n 'RunStart',\n 'UserPromptSubmit',\n 'PreToolUse',\n 'PostToolUse',\n 'PostToolUseFailure',\n 'PermissionDenied',\n 'SubagentStart',\n 'SubagentStop',\n 'Stop',\n 'StopFailure',\n 'PreCompact',\n 'PostCompact',\n] as const;\n\nexport type HookEvent = (typeof HOOK_EVENTS)[number];\n\n/** Tool-gating decision; executeHooks folds with `deny > ask > allow` precedence. */\nexport type ToolDecision = 'allow' | 'deny' | 'ask';\n\n/** Stop-loop decision; `block` means \"do not stop, run another turn\". Any `block` wins. */\nexport type StopDecision = 'continue' | 'block';\n\n/**\n * Fields shared by every `HookInput`. Discriminated by `hook_event_name`.\n *\n * - `runId` identifies the current agent run and is always present.\n * - `threadId` identifies the conversation thread when the host has one.\n * - `agentId` is only set when the hook fires inside a subagent scope.\n */\nexport interface BaseHookInput {\n runId: string;\n threadId?: string;\n agentId?: string;\n}\n\nexport interface RunStartHookInput extends BaseHookInput {\n hook_event_name: 'RunStart';\n messages: BaseMessage[];\n}\n\nexport interface UserPromptSubmitHookInput extends BaseHookInput {\n hook_event_name: 'UserPromptSubmit';\n prompt: string;\n attachments?: BaseMessage[];\n}\n\n/**\n * Fires before a tool is invoked. Hook may return `deny`/`ask`/`allow` and/or\n * an `updatedInput` that replaces the tool arguments before invocation.\n *\n * `toolInput` is intentionally typed as `Record<string, unknown>` because the\n * SDK is tool-agnostic — concrete tool argument shapes are only known at the\n * call site and are narrowed by the host. This is the one escape hatch in\n * the hook type system.\n */\nexport interface PreToolUseHookInput extends BaseHookInput {\n hook_event_name: 'PreToolUse';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolUseId: string;\n stepId?: string;\n /**\n * Number of times this tool has been invoked in prior batches within the\n * current run. Within a single batch of parallel calls, all calls to the\n * same tool share the same turn value — per-call discrimination within a\n * batch is not supported in v1.\n */\n turn?: number;\n}\n\nexport interface PostToolUseHookInput extends BaseHookInput {\n hook_event_name: 'PostToolUse';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolOutput: unknown;\n toolUseId: string;\n stepId?: string;\n turn?: number;\n}\n\nexport interface PostToolUseFailureHookInput extends BaseHookInput {\n hook_event_name: 'PostToolUseFailure';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolUseId: string;\n error: string;\n stepId?: string;\n turn?: number;\n}\n\nexport interface PermissionDeniedHookInput extends BaseHookInput {\n hook_event_name: 'PermissionDenied';\n toolName: string;\n toolInput: Record<string, unknown>;\n toolUseId: string;\n reason: string;\n}\n\nexport interface SubagentStartHookInput extends BaseHookInput {\n hook_event_name: 'SubagentStart';\n parentAgentId?: string;\n agentId: string;\n agentType: string;\n inputs: BaseMessage[];\n}\n\nexport interface SubagentStopHookInput extends BaseHookInput {\n hook_event_name: 'SubagentStop';\n agentId: string;\n agentType: string;\n messages: BaseMessage[];\n}\n\nexport interface StopHookInput extends BaseHookInput {\n hook_event_name: 'Stop';\n messages: BaseMessage[];\n stopReason?: string;\n stopHookActive: boolean;\n}\n\nexport interface StopFailureHookInput extends BaseHookInput {\n hook_event_name: 'StopFailure';\n error: string;\n lastAssistantMessage?: BaseMessage;\n}\n\nexport interface PreCompactHookInput extends BaseHookInput {\n hook_event_name: 'PreCompact';\n messagesBeforeCount: number;\n /**\n * What triggered compaction. Matches `SummarizationTrigger.type` from the\n * agent's summarization config. `'default'` means no trigger was\n * configured and compaction fired because messages were pruned.\n */\n trigger:\n | 'token_ratio'\n | 'remaining_tokens'\n | 'messages_to_refine'\n | 'default'\n | (string & {});\n}\n\nexport interface PostCompactHookInput extends BaseHookInput {\n hook_event_name: 'PostCompact';\n summary: string;\n /**\n * Number of messages remaining after compaction. The summarize node\n * returns a `removeAll` signal that clears all messages from state;\n * the summary itself is injected into the system prompt, not as a\n * message. This is `0` at the point of hook dispatch.\n */\n messagesAfterCount: number;\n}\n\n/** Discriminated union of every hook input shape. */\nexport type HookInput =\n | RunStartHookInput\n | UserPromptSubmitHookInput\n | PreToolUseHookInput\n | PostToolUseHookInput\n | PostToolUseFailureHookInput\n | PermissionDeniedHookInput\n | SubagentStartHookInput\n | SubagentStopHookInput\n | StopHookInput\n | StopFailureHookInput\n | PreCompactHookInput\n | PostCompactHookInput;\n\n/** Compile-time map from event name to its input shape. */\nexport type HookInputByEvent = {\n RunStart: RunStartHookInput;\n UserPromptSubmit: UserPromptSubmitHookInput;\n PreToolUse: PreToolUseHookInput;\n PostToolUse: PostToolUseHookInput;\n PostToolUseFailure: PostToolUseFailureHookInput;\n PermissionDenied: PermissionDeniedHookInput;\n SubagentStart: SubagentStartHookInput;\n SubagentStop: SubagentStopHookInput;\n Stop: StopHookInput;\n StopFailure: StopFailureHookInput;\n PreCompact: PreCompactHookInput;\n PostCompact: PostCompactHookInput;\n};\n\n/**\n * Fields common to every hook output. Hooks that have nothing to say simply\n * return `{}` (or omit the fields below).\n */\nexport interface BaseHookOutput {\n /** Context string to inject into the conversation. Accumulated across hooks. */\n additionalContext?: string;\n /** True to prevent the next model turn. Any hook can set this. */\n preventContinuation?: boolean;\n /** Reason reported alongside `preventContinuation`. */\n stopReason?: string;\n}\n\nexport type RunStartHookOutput = BaseHookOutput;\n\nexport interface UserPromptSubmitHookOutput extends BaseHookOutput {\n decision?: ToolDecision;\n reason?: string;\n}\n\nexport interface PreToolUseHookOutput extends BaseHookOutput {\n decision?: ToolDecision;\n reason?: string;\n /**\n * Replacement tool input. Merged into the pending tool call by the host.\n *\n * When multiple hooks set `updatedInput` within a single `executeHooks`\n * call, the last writer in registration order wins (outer loop: matcher\n * registration order; inner loop: hook position within the matcher). The\n * winner is deterministic — `Promise.all` preserves input-array order.\n * Consumers that need a single authoritative rewrite should still scope\n * `updatedInput` to one hook per matcher to avoid confusing precedence.\n */\n updatedInput?: Record<string, unknown>;\n}\n\nexport interface PostToolUseHookOutput extends BaseHookOutput {\n /**\n * Replacement tool output. Flows through the aggregated result so the\n * host can substitute it before appending the tool result message.\n * Ordering semantics match `PreToolUseHookOutput.updatedInput`:\n * last-writer-wins in registration order.\n */\n updatedOutput?: unknown;\n}\n\nexport type PostToolUseFailureHookOutput = BaseHookOutput;\n\nexport type PermissionDeniedHookOutput = BaseHookOutput;\n\nexport interface SubagentStartHookOutput extends BaseHookOutput {\n decision?: ToolDecision;\n reason?: string;\n}\n\nexport type SubagentStopHookOutput = BaseHookOutput;\n\nexport interface StopHookOutput extends BaseHookOutput {\n decision?: StopDecision;\n reason?: string;\n}\n\nexport type StopFailureHookOutput = BaseHookOutput;\n\nexport type PreCompactHookOutput = BaseHookOutput;\n\nexport type PostCompactHookOutput = BaseHookOutput;\n\n/** Compile-time map from event name to its output shape. */\nexport type HookOutputByEvent = {\n RunStart: RunStartHookOutput;\n UserPromptSubmit: UserPromptSubmitHookOutput;\n PreToolUse: PreToolUseHookOutput;\n PostToolUse: PostToolUseHookOutput;\n PostToolUseFailure: PostToolUseFailureHookOutput;\n PermissionDenied: PermissionDeniedHookOutput;\n SubagentStart: SubagentStartHookOutput;\n SubagentStop: SubagentStopHookOutput;\n Stop: StopHookOutput;\n StopFailure: StopFailureHookOutput;\n PreCompact: PreCompactHookOutput;\n PostCompact: PostCompactHookOutput;\n};\n\n/** Superset output shape used by the executor's fold loop. */\nexport type HookOutput =\n | RunStartHookOutput\n | UserPromptSubmitHookOutput\n | PreToolUseHookOutput\n | PostToolUseHookOutput\n | PostToolUseFailureHookOutput\n | PermissionDeniedHookOutput\n | SubagentStartHookOutput\n | SubagentStopHookOutput\n | StopHookOutput\n | StopFailureHookOutput\n | PreCompactHookOutput\n | PostCompactHookOutput;\n\n/**\n * A hook callback is a plain async function registered against a specific\n * event. The `signal` is always supplied by `executeHooks` and combines the\n * batch's parent signal with the per-hook timeout — callbacks that perform\n * long-running work should observe it.\n */\nexport type HookCallback<E extends HookEvent = HookEvent> = (\n input: HookInputByEvent[E],\n signal: AbortSignal\n) => HookOutputByEvent[E] | Promise<HookOutputByEvent[E]>;\n\n/**\n * A matcher groups one or more callbacks under a shared regex filter and\n * shared timeout/once/internal flags. The generic `E` ties the callback\n * types to the event the matcher is registered against.\n */\nexport interface HookMatcher<E extends HookEvent = HookEvent> {\n /**\n * Regex pattern matched against the event's primary query string (e.g.\n * the tool name for `PreToolUse`, the agent type for `SubagentStart`).\n *\n * Omitted or empty means \"always match\". For events that do not supply a\n * query string (`RunStart`, `Stop`, etc.), only wildcard matchers fire —\n * a non-empty pattern on such events will never match.\n *\n * Patterns are treated as trusted input: `executeHooks` compiles them\n * with `new RegExp(pattern)` without any sandbox, and a pathological\n * pattern can block the event loop. Host registration code is expected\n * to validate or length-bound patterns that originate from user input.\n */\n pattern?: string;\n /** Callbacks that fire when the matcher hits. Executed in parallel. */\n hooks: HookCallback<E>[];\n /** Per-matcher timeout in ms. Defaults to the executor's batch timeout. */\n timeout?: number;\n /**\n * Atomically remove the matcher before its first dispatch.\n *\n * `executeHooks` claims `once: true` matchers synchronously — between\n * `getMatchers` and its first `await` — so two concurrent calls cannot\n * both dispatch the same matcher. Whichever call runs its sync prefix\n * first wins the matcher; the other sees an empty bucket.\n *\n * Semantics are \"at most one dispatch, ever\" — if every hook in the\n * matcher throws, the matcher is still gone. Use `once` for\n * fire-and-forget bootstrapping (registration, telemetry, setup). Hosts\n * that need retry semantics should register a normal matcher and\n * self-unregister via the callback returned from `registry.register`.\n */\n once?: boolean;\n /** Internal hooks are excluded from telemetry and non-fatal error logging. */\n internal?: boolean;\n}\n\n/**\n * Storage shape for matchers keyed by event. Each event's matcher list is\n * a generic array parameterized by that event type, so lookup via\n * `HooksByEvent[E]` preserves type-safe callback signatures.\n */\nexport type HooksByEvent = {\n [E in HookEvent]?: HookMatcher<E>[];\n};\n\n/**\n * Aggregated result of a single `executeHooks` call. Fields are populated\n * according to the fold rules in `executeHooks.ts`.\n */\nexport interface AggregatedHookResult {\n /** Folded tool-gating decision; `deny > ask > allow`. */\n decision?: ToolDecision;\n /** Folded stop decision; any `block` wins. */\n stopDecision?: StopDecision;\n /** Reason from the hook that set the winning decision. */\n reason?: string;\n /**\n * Replacement tool input from a `PreToolUse` hook.\n *\n * Last-writer-wins in **registration order**: `executeHooks` uses\n * `Promise.all`, which preserves input-array order, so the fold iterates\n * outcomes in the same order they were pushed — outer loop over matchers\n * as they sit in the registry, inner loop over each matcher's `hooks`\n * array. The winner is therefore deterministic but may not match the\n * order in which hooks actually completed. Consumers that want a single\n * authoritative rewrite should still register one `updatedInput`-setting\n * hook per matcher to avoid subtle precedence bugs.\n */\n updatedInput?: Record<string, unknown>;\n /**\n * Replacement tool output from a `PostToolUse` hook.\n *\n * Same last-writer-wins-in-registration-order semantics as\n * `updatedInput`. Present only when at least one hook set it; `undefined`\n * means \"use the original tool output\".\n */\n updatedOutput?: unknown;\n /** Accumulated `additionalContext` strings from every hook, in order. */\n additionalContexts: string[];\n /** True if any hook returned `preventContinuation`. */\n preventContinuation?: boolean;\n /**\n * Reason recorded alongside `preventContinuation`. First winner wins:\n * once a hook sets both flags, later hooks that also set\n * `preventContinuation` do not overwrite the reason.\n */\n stopReason?: string;\n /** Error messages from hooks that threw; always present (possibly empty). */\n errors: string[];\n}\n"],"names":[],"mappings":";;AAGA;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG;IACzB,UAAU;IACV,kBAAkB;IAClB,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,kBAAkB;IAClB,eAAe;IACf,cAAc;IACd,MAAM;IACN,aAAa;IACb,YAAY;IACZ,aAAa;;;;;"}
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * Consumers can extend the allowlist with `bedrockCacheModelPatterns` in
14
14
  * `clientOptions` for proprietary or pre-release model IDs not yet in
15
- * the upstream library.
15
+ * the reference library.
16
16
  */
17
17
  /**
18
18
  * Default allowlist of Bedrock model ID patterns that support cachePoint.
@@ -1 +1 @@
1
- {"version":3,"file":"cacheSupport.cjs","sources":["../../../../src/llm/bedrock/cacheSupport.ts"],"sourcesContent":["/**\n * Bedrock prompt-cache model support detection.\n * ===============================================\n *\n * Bedrock prompt caching (via `cachePoint` blocks) is only supported on\n * specific model families. Other families silently reject or ignore the\n * markers. We maintain an allowlist instead of a substring heuristic so\n * a future model with an unfortunate name (e.g. `llama-claude-killer`)\n * doesn't accidentally match.\n *\n * Consumers can extend the allowlist with `bedrockCacheModelPatterns` in\n * `clientOptions` for proprietary or pre-release model IDs not yet in\n * the upstream library.\n */\n\n/**\n * Default allowlist of Bedrock model ID patterns that support cachePoint.\n * Sourced from AWS Bedrock documentation (verified against us-east-1\n * 2026-05).\n *\n * Adding a new model: append a RegExp here AND add a regression test in\n * `cacheSupport.test.ts` covering at least one full model ID for that\n * family. Removing a model: do not remove without operator confirmation\n * — silent removal would suddenly stop emitting cachePoint markers and\n * regress cost savings.\n */\nexport const DEFAULT_BEDROCK_CACHE_MODEL_PATTERNS: readonly RegExp[] = [\n // Anthropic Claude family (anthropic.claude-* and us.anthropic.claude-*)\n /(?:^|[/.])anthropic\\.claude-/i,\n /(?:^|\\.)us\\.anthropic\\.claude-/i,\n // Amazon Nova family (nova-pro, nova-lite, nova-canvas, etc.)\n /(?:^|[/.])amazon\\.nova-/i,\n /(?:^|\\.)us\\.amazon\\.nova-/i,\n];\n\n/**\n * Returns true when the given Bedrock model ID belongs to a family that\n * supports cachePoint blocks. `additionalPatterns` lets consumers extend\n * the allowlist for models the library doesn't know about yet.\n *\n * @param modelId Bedrock model ID (e.g. `us.anthropic.claude-sonnet-4-5-20250929-v1:0`)\n * @param additionalPatterns Extra patterns from consumer config\n */\nexport function isBedrockCacheSupported(\n modelId: string | undefined,\n additionalPatterns?: readonly RegExp[],\n): boolean {\n if (!modelId) return false;\n const allPatterns = additionalPatterns\n ? [...DEFAULT_BEDROCK_CACHE_MODEL_PATTERNS, ...additionalPatterns]\n : DEFAULT_BEDROCK_CACHE_MODEL_PATTERNS;\n return allPatterns.some((p) => p.test(modelId));\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;AAaG;AAEH;;;;;;;;;;AAUG;AACI,MAAM,oCAAoC,GAAsB;;IAErE,+BAA+B;IAC/B,iCAAiC;;IAEjC,0BAA0B;IAC1B,4BAA4B;;AAG9B;;;;;;;AAOG;AACG,SAAU,uBAAuB,CACrC,OAA2B,EAC3B,kBAAsC,EAAA;AAEtC,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,KAAK;IAC1B,MAAM,WAAW,GAAG;AAClB,UAAE,CAAC,GAAG,oCAAoC,EAAE,GAAG,kBAAkB;UAC/D,oCAAoC;AACxC,IAAA,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACjD;;;;;"}
1
+ {"version":3,"file":"cacheSupport.cjs","sources":["../../../../src/llm/bedrock/cacheSupport.ts"],"sourcesContent":["/**\n * Bedrock prompt-cache model support detection.\n * ===============================================\n *\n * Bedrock prompt caching (via `cachePoint` blocks) is only supported on\n * specific model families. Other families silently reject or ignore the\n * markers. We maintain an allowlist instead of a substring heuristic so\n * a future model with an unfortunate name (e.g. `llama-claude-killer`)\n * doesn't accidentally match.\n *\n * Consumers can extend the allowlist with `bedrockCacheModelPatterns` in\n * `clientOptions` for proprietary or pre-release model IDs not yet in\n * the reference library.\n */\n\n/**\n * Default allowlist of Bedrock model ID patterns that support cachePoint.\n * Sourced from AWS Bedrock documentation (verified against us-east-1\n * 2026-05).\n *\n * Adding a new model: append a RegExp here AND add a regression test in\n * `cacheSupport.test.ts` covering at least one full model ID for that\n * family. Removing a model: do not remove without operator confirmation\n * — silent removal would suddenly stop emitting cachePoint markers and\n * regress cost savings.\n */\nexport const DEFAULT_BEDROCK_CACHE_MODEL_PATTERNS: readonly RegExp[] = [\n // Anthropic Claude family (anthropic.claude-* and us.anthropic.claude-*)\n /(?:^|[/.])anthropic\\.claude-/i,\n /(?:^|\\.)us\\.anthropic\\.claude-/i,\n // Amazon Nova family (nova-pro, nova-lite, nova-canvas, etc.)\n /(?:^|[/.])amazon\\.nova-/i,\n /(?:^|\\.)us\\.amazon\\.nova-/i,\n];\n\n/**\n * Returns true when the given Bedrock model ID belongs to a family that\n * supports cachePoint blocks. `additionalPatterns` lets consumers extend\n * the allowlist for models the library doesn't know about yet.\n *\n * @param modelId Bedrock model ID (e.g. `us.anthropic.claude-sonnet-4-5-20250929-v1:0`)\n * @param additionalPatterns Extra patterns from consumer config\n */\nexport function isBedrockCacheSupported(\n modelId: string | undefined,\n additionalPatterns?: readonly RegExp[],\n): boolean {\n if (!modelId) return false;\n const allPatterns = additionalPatterns\n ? [...DEFAULT_BEDROCK_CACHE_MODEL_PATTERNS, ...additionalPatterns]\n : DEFAULT_BEDROCK_CACHE_MODEL_PATTERNS;\n return allPatterns.some((p) => p.test(modelId));\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;AAaG;AAEH;;;;;;;;;;AAUG;AACI,MAAM,oCAAoC,GAAsB;;IAErE,+BAA+B;IAC/B,iCAAiC;;IAEjC,0BAA0B;IAC1B,4BAA4B;;AAG9B;;;;;;;AAOG;AACG,SAAU,uBAAuB,CACrC,OAA2B,EAC3B,kBAAsC,EAAA;AAEtC,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,KAAK;IAC1B,MAAM,WAAW,GAAG;AAClB,UAAE,CAAC,GAAG,oCAAoC,EAAE,GAAG,kBAAkB;UAC/D,oCAAoC;AACxC,IAAA,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACjD;;;;;"}
@@ -43,8 +43,8 @@ var message_outputs = require('./utils/message_outputs.cjs');
43
43
  /**
44
44
  * Default group selector — puts all tools in a single group named 'core'.
45
45
  * Equivalent to 'single' strategy but explicit. Consumers override this
46
- * to enable per-source grouping (e.g. ranger uses `_mcp_` substring to
47
- * separate core from MCP tools).
46
+ * to enable per-source grouping (e.g. by inspecting tool-name substrings
47
+ * to separate stable framework tools from volatile MCP-sourced tools).
48
48
  */
49
49
  const DEFAULT_TOOL_GROUP_SELECTOR = () => 'core';
50
50
  class IllumaBedrockConverse extends aws.ChatBedrockConverse {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/llm/bedrock/index.ts"],"sourcesContent":["/**\n * Optimized ChatBedrockConverse wrapper that fixes content block merging for\n * streaming responses and adds support for latest @langchain/aws features:\n *\n * - Prompt caching support for Bedrock Converse API (Illuma feature)\n * - Application Inference Profiles (PR #9129)\n * - Service Tiers (Priority/Standard/Flex) (PR #9785) - requires AWS SDK 3.966.0+\n *\n * Bedrock's `@langchain/aws` library does not include an `index` property on content\n * blocks (unlike Anthropic/OpenAI), which causes LangChain's `_mergeLists` to append\n * each streaming chunk as a separate array entry instead of merging by index.\n *\n * This wrapper takes full ownership of the stream by directly interfacing with the\n * AWS SDK client (`this.client`) and using custom handlers from `./utils/` that\n * include `contentBlockIndex` in response_metadata for every delta type. It then\n * promotes `contentBlockIndex` to an `index` property on each content block\n * (mirroring Anthropic's pattern) and strips it from metadata to avoid\n * `_mergeDicts` conflicts.\n *\n * When multiple content block types are present (e.g. reasoning + text), text deltas\n * are promoted from strings to array form with `index` so they merge correctly once\n * the accumulated content is already an array.\n *\n * PROMPT CACHING:\n * When promptCache: true is set, this wrapper adds cachePoint markers to the tools array\n * to enable Bedrock prompt caching for tool definitions. This allows tool schemas to be\n * cached and reused across requests, reducing latency and costs.\n *\n * CACHE TOKEN EXTRACTION:\n * Cache token extraction is handled in `./utils/message_outputs.ts` and added\n * to usage_metadata with input_token_details (cacheReadInputTokens/cacheWriteInputTokens).\n */\n\nimport { ChatBedrockConverse } from '@langchain/aws';\nimport { ConverseStreamCommand } from '@aws-sdk/client-bedrock-runtime';\nimport { AIMessageChunk } from '@langchain/core/messages';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport { ChatGenerationChunk, ChatResult } from '@langchain/core/outputs';\nimport type { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';\nimport type { ChatBedrockConverseInput } from '@langchain/aws';\nimport { isBedrockCacheSupported } from './cacheSupport';\nimport {\n convertToConverseMessages,\n handleConverseStreamContentBlockStart,\n handleConverseStreamContentBlockDelta,\n handleConverseStreamMetadata,\n} from './utils';\n\n/**\n * Service tier type for Bedrock invocations.\n * Requires AWS SDK >= 3.966.0 to actually work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\nexport type ServiceTierType = 'priority' | 'default' | 'flex' | 'reserved';\n\n/**\n * Tool cachePoint allocation strategy.\n *\n * - 'single': one cachePoint at the END of the tools array (whole array\n * cached as one unit). Lightest budget use (1 cachePoint).\n * - 'split': split tools into groups via `toolGroupSelector`. Each\n * non-empty group gets its own cachePoint. Use when groups\n * have different volatility (e.g. stable core tools vs\n * volatile MCP tools). Costs more cachePoint budget.\n * - 'none': no cachePoint on tools array. Use when tool definitions\n * change every request anyway.\n */\nexport type ToolCacheStrategy = 'single' | 'split' | 'none';\n\n/**\n * Group selector for `toolCacheStrategy: 'split'`. Receives the tool name\n * and returns a stable group key — tools with the same key are grouped\n * together. Group order in the output array follows first-encounter order.\n */\nexport type ToolGroupSelector = (toolName: string) => string;\n\n/**\n * Default group selector — puts all tools in a single group named 'core'.\n * Equivalent to 'single' strategy but explicit. Consumers override this\n * to enable per-source grouping (e.g. ranger uses `_mcp_` substring to\n * separate core from MCP tools).\n */\nexport const DEFAULT_TOOL_GROUP_SELECTOR: ToolGroupSelector = () => 'core';\n\n/**\n * Extended input interface with additional features:\n * - promptCache: Enable Bedrock prompt caching for tool definitions\n * - applicationInferenceProfile: Use an inference profile ARN instead of model ID\n * - serviceTier: Specify service tier (Priority, Standard, Flex, Reserved)\n * - toolCacheStrategy: How to allocate cachePoints across tools array\n * - toolGroupSelector: Group key resolver for the 'split' strategy\n */\nexport interface IllumaBedrockConverseInput extends ChatBedrockConverseInput {\n /**\n * Enable Bedrock prompt caching for tool definitions.\n * When true, adds cachePoint marker(s) to tools array per\n * `toolCacheStrategy`. Defaults to 'single'.\n */\n promptCache?: boolean;\n\n /**\n * Tool cachePoint allocation. Defaults to 'single' — one cachePoint at\n * the end of the tools array. Set to 'split' (with `toolGroupSelector`)\n * when different tool groups have different volatility.\n */\n toolCacheStrategy?: ToolCacheStrategy;\n\n /**\n * Group selector for 'split' strategy. Receives a tool name, returns\n * a stable group key. Defaults to a one-group selector (equivalent\n * to 'single').\n */\n toolGroupSelector?: ToolGroupSelector;\n\n /**\n * Additional model ID patterns to consider Bedrock-cache-supported.\n * Defaults are in `src/llm/bedrock/cacheSupport.ts`. Use this when\n * AWS adds a new model family before the next library release.\n */\n bedrockCacheModelPatterns?: readonly RegExp[];\n\n /**\n * Application Inference Profile ARN to use for the model.\n * For example, \"arn:aws:bedrock:eu-west-1:123456789102:application-inference-profile/fm16bt65tzgx\"\n * When provided, this ARN will be used for the actual inference calls instead of the model ID.\n * Must still provide `model` as normal modelId to benefit from all the metadata.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-create.html\n */\n applicationInferenceProfile?: string;\n\n /**\n * Service tier for model invocation.\n * Specifies the processing tier type used for serving the request.\n * Supported values are 'priority', 'default', 'flex', and 'reserved'.\n *\n * - 'priority': Prioritized processing for lower latency\n * - 'default': Standard processing tier\n * - 'flex': Flexible processing tier with lower cost\n * - 'reserved': Reserved capacity for consistent performance\n *\n * If not provided, AWS uses the default tier.\n * Note: Requires AWS SDK >= 3.966.0 to work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\n serviceTier?: ServiceTierType;\n}\n\n/**\n * Extended call options with serviceTier override support.\n */\nexport interface IllumaBedrockConverseCallOptions {\n serviceTier?: ServiceTierType;\n}\n\nexport class IllumaBedrockConverse extends ChatBedrockConverse {\n /** Enable Bedrock prompt caching for tool definitions */\n promptCache: boolean;\n\n /** Application Inference Profile ARN to use instead of model ID */\n applicationInferenceProfile?: string;\n\n /** Service tier for model invocation */\n serviceTier?: ServiceTierType;\n\n /** Tool cachePoint allocation strategy. */\n toolCacheStrategy: ToolCacheStrategy;\n\n /** Group selector for 'split' strategy. */\n toolGroupSelector: ToolGroupSelector;\n\n /** Optional consumer extensions to the cache-supported model allowlist. */\n bedrockCacheModelPatterns?: readonly RegExp[];\n\n constructor(fields?: IllumaBedrockConverseInput) {\n super(fields);\n this.promptCache = fields?.promptCache ?? false;\n this.applicationInferenceProfile = fields?.applicationInferenceProfile;\n this.serviceTier = fields?.serviceTier;\n this.toolCacheStrategy = fields?.toolCacheStrategy ?? 'single';\n this.toolGroupSelector =\n fields?.toolGroupSelector ?? DEFAULT_TOOL_GROUP_SELECTOR;\n this.bedrockCacheModelPatterns = fields?.bedrockCacheModelPatterns;\n\n // Fix: Force supportsToolChoiceValues for Claude models\n // The parent constructor checks `model.includes('claude-3')` but this fails when:\n // 1. Using applicationInferenceProfile ARNs (arn:aws:bedrock:...)\n // 2. Using different naming conventions (claude-4, claude-opus-4, etc.)\n // We need to ensure tool_choice is properly set for withStructuredOutput to work\n const modelName = (fields?.model ?? '').toLowerCase();\n const profileName = (\n fields?.applicationInferenceProfile ?? ''\n ).toLowerCase();\n const isClaudeModel =\n modelName.includes('claude') ||\n modelName.includes('anthropic') ||\n profileName.includes('claude') ||\n profileName.includes('anthropic');\n\n if (isClaudeModel && !this.supportsToolChoiceValues?.length) {\n // Claude models support all tool choice values\n this.supportsToolChoiceValues = ['auto', 'any', 'tool'];\n }\n }\n\n static lc_name(): string {\n return 'IllumaBedrockConverse';\n }\n\n /**\n * Get the model ID to use for API calls.\n * Returns applicationInferenceProfile if set, otherwise returns this.model.\n */\n protected getModelId(): string {\n return this.applicationInferenceProfile ?? this.model;\n }\n\n /**\n * Override invocationParams to:\n * 1. Add cachePoint to tools when promptCache is enabled\n * 2. Add serviceTier support\n *\n * CACHING STRATEGY: Separate cachePoints for core tools and MCP tools\n * - Core tools (web_search, execute_code, etc.) are stable → cache first\n * - MCP tools (have '_mcp_' in name) are dynamic → cache separately after\n * - This allows core tools to stay cached when MCP selection changes\n *\n * NOTE: Only Claude models support cachePoint - Nova and other models will reject it.\n */\n override invocationParams(\n options?: this['ParsedCallOptions'] & IllumaBedrockConverseCallOptions\n ): ReturnType<ChatBedrockConverse['invocationParams']> & {\n serviceTier?: { type: ServiceTierType };\n } {\n const params = super.invocationParams(options);\n\n // Add cachePoint to tools array if promptCache is enabled and tools exist\n /**\n * Bedrock requires all toolSpec.description fields to be non-empty strings.\n * Some tools (e.g., MCP-sourced or dynamically created) may have empty or\n * missing descriptions. Patch them here to avoid Bedrock validation errors.\n */\n if (params.toolConfig?.tools && Array.isArray(params.toolConfig.tools)) {\n for (const t of params.toolConfig.tools) {\n const spec = (t as { toolSpec?: { description?: string } }).toolSpec;\n if (spec && (!spec.description || spec.description === '')) {\n spec.description =\n spec.description ||\n `Tool: ${(spec as { name?: string }).name ?? 'unknown'}`;\n }\n }\n }\n\n /* Allowlist-based gate (see cacheSupport.ts). Replaces the old\n * substring heuristic — same default behavior for Claude/Anthropic/\n * Nova models, plus extension via `bedrockCacheModelPatterns`. */\n const cacheSupported = isBedrockCacheSupported(\n this.model,\n this.bedrockCacheModelPatterns,\n );\n\n if (\n this.promptCache &&\n cacheSupported &&\n this.toolCacheStrategy !== 'none' &&\n params.toolConfig?.tools &&\n Array.isArray(params.toolConfig.tools) &&\n params.toolConfig.tools.length > 0\n ) {\n const tools = params.toolConfig.tools;\n\n if (this.toolCacheStrategy === 'single') {\n /* SINGLE: one cachePoint at the end of the tools array. Lightest\n * budget use; appropriate when the entire tools array is treated\n * as one unit and changes together. */\n const toolsWithCache = [\n ...tools,\n { cachePoint: { type: 'default' } } as (typeof tools)[number],\n ];\n params.toolConfig.tools = toolsWithCache;\n } else if (this.toolCacheStrategy === 'split') {\n /* SPLIT: group tools by `toolGroupSelector` and emit a cachePoint\n * after each non-empty group. Group order follows first-encounter\n * order in the input. Use when groups have different volatility\n * (e.g. stable core tools + volatile MCP tools). */\n const groupOrder: string[] = [];\n const groupMap = new Map<string, typeof tools>();\n for (const tool of tools) {\n const toolName =\n (tool as { toolSpec?: { name?: string } }).toolSpec?.name ?? '';\n const groupKey = this.toolGroupSelector(toolName);\n let group = groupMap.get(groupKey);\n if (!group) {\n group = [];\n groupMap.set(groupKey, group);\n groupOrder.push(groupKey);\n }\n group.push(tool);\n }\n\n const toolsWithCache: typeof tools = [];\n for (const groupKey of groupOrder) {\n const group = groupMap.get(groupKey);\n if (!group || group.length === 0) continue;\n toolsWithCache.push(...group);\n toolsWithCache.push(\n { cachePoint: { type: 'default' } } as (typeof tools)[number],\n );\n }\n params.toolConfig.tools = toolsWithCache;\n }\n }\n\n // Add serviceTier support\n const serviceTierType = options?.serviceTier ?? this.serviceTier;\n\n return {\n ...params,\n serviceTier: serviceTierType ? { type: serviceTierType } : undefined,\n };\n }\n\n /**\n * Override _generateNonStreaming to use applicationInferenceProfile as modelId.\n * Uses the same model-swapping pattern as streaming for consistency.\n */\n override async _generateNonStreaming(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & IllumaBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): Promise<ChatResult> {\n const originalModel = this.model;\n if (\n this.applicationInferenceProfile != null &&\n this.applicationInferenceProfile !== ''\n ) {\n this.model = this.applicationInferenceProfile;\n }\n\n try {\n return await super._generateNonStreaming(messages, options, runManager);\n } finally {\n this.model = originalModel;\n }\n }\n\n /**\n * Own the stream end-to-end so we have direct access to every\n * `contentBlockDelta.contentBlockIndex` from the AWS SDK.\n *\n * This replaces the parent's implementation which strips contentBlockIndex\n * from text and reasoning deltas, making it impossible to merge correctly.\n */\n override async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & IllumaBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n const { converseMessages, converseSystem } =\n convertToConverseMessages(messages);\n const params = this.invocationParams(options);\n\n let { streamUsage } = this;\n if ((options as Record<string, unknown>).streamUsage !== undefined) {\n streamUsage = (options as Record<string, unknown>).streamUsage as boolean;\n }\n\n const modelId = this.getModelId();\n\n const command = new ConverseStreamCommand({\n modelId,\n messages: converseMessages,\n system: converseSystem,\n ...(params as Record<string, unknown>),\n });\n\n const response = await this.client.send(command, {\n abortSignal: options.signal,\n });\n\n if (!response.stream) {\n return;\n }\n\n const seenBlockIndices = new Set<number>();\n\n for await (const event of response.stream) {\n if (event.contentBlockStart != null) {\n const startChunk = handleConverseStreamContentBlockStart(\n event.contentBlockStart\n );\n if (startChunk != null) {\n const idx = event.contentBlockStart.contentBlockIndex;\n if (idx != null) {\n seenBlockIndices.add(idx);\n }\n yield this.enrichChunk(startChunk, seenBlockIndices);\n }\n } else if (event.contentBlockDelta != null) {\n const deltaChunk = handleConverseStreamContentBlockDelta(\n event.contentBlockDelta\n );\n\n const idx = event.contentBlockDelta.contentBlockIndex;\n if (idx != null) {\n seenBlockIndices.add(idx);\n }\n\n yield this.enrichChunk(deltaChunk, seenBlockIndices);\n\n await runManager?.handleLLMNewToken(\n deltaChunk.text,\n undefined,\n undefined,\n undefined,\n undefined,\n { chunk: deltaChunk }\n );\n } else if (event.metadata != null) {\n yield handleConverseStreamMetadata(event.metadata, { streamUsage });\n } else if (event.contentBlockStop != null) {\n const stopIdx = event.contentBlockStop.contentBlockIndex;\n if (stopIdx != null) {\n seenBlockIndices.add(stopIdx);\n }\n } else {\n yield new ChatGenerationChunk({\n text: '',\n message: new AIMessageChunk({\n content: '',\n response_metadata: event,\n }),\n });\n }\n }\n }\n\n /**\n * Inject `index` on content blocks for proper merge behaviour, then strip\n * `contentBlockIndex` from response_metadata to prevent `_mergeDicts` conflicts.\n *\n * Text string content is promoted to array form only when the stream contains\n * multiple content block indices (e.g. reasoning at index 0, text at index 1),\n * ensuring text merges correctly with the already-array accumulated content.\n */\n enrichChunk(\n chunk: ChatGenerationChunk,\n seenBlockIndices: Set<number>\n ): ChatGenerationChunk {\n const message = chunk.message;\n if (!(message instanceof AIMessageChunk)) {\n return chunk;\n }\n\n const metadata = message.response_metadata as Record<string, unknown>;\n const blockIndex = this.extractContentBlockIndex(metadata);\n const hasMetadataIndex = blockIndex != null;\n\n let content: AIMessageChunk['content'] = message.content;\n let contentModified = false;\n\n if (Array.isArray(content) && blockIndex != null) {\n content = content.map((block) =>\n typeof block === 'object' && !('index' in block)\n ? { ...block, index: blockIndex }\n : block\n );\n contentModified = true;\n } else if (\n typeof content === 'string' &&\n content !== '' &&\n blockIndex != null &&\n seenBlockIndices.size > 1\n ) {\n content = [{ type: 'text', text: content, index: blockIndex }];\n contentModified = true;\n }\n\n if (!contentModified && !hasMetadataIndex) {\n return chunk;\n }\n\n const cleanedMetadata = hasMetadataIndex\n ? (this.removeContentBlockIndex(metadata) as Record<string, unknown>)\n : metadata;\n\n return new ChatGenerationChunk({\n text: chunk.text,\n message: new AIMessageChunk({\n ...message,\n content,\n response_metadata: cleanedMetadata,\n }),\n generationInfo: chunk.generationInfo,\n });\n }\n\n /**\n * Extract `contentBlockIndex` from the top level of response_metadata.\n * Our custom handlers always place it at the top level.\n */\n private extractContentBlockIndex(\n metadata: Record<string, unknown>\n ): number | undefined {\n if (\n 'contentBlockIndex' in metadata &&\n typeof metadata.contentBlockIndex === 'number'\n ) {\n return metadata.contentBlockIndex;\n }\n return undefined;\n }\n\n private removeContentBlockIndex(obj: unknown): unknown {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => this.removeContentBlockIndex(item));\n }\n\n if (typeof obj === 'object') {\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key !== 'contentBlockIndex') {\n cleaned[key] = this.removeContentBlockIndex(value);\n }\n }\n return cleaned;\n }\n\n return obj;\n }\n}\n\n/** @deprecated Use IllumaBedrockConverse. Alias kept for backward compatibility with existing imports. */\nexport const CustomChatBedrockConverse = IllumaBedrockConverse;\n\nexport type { ChatBedrockConverseInput };\n"],"names":["ChatBedrockConverse","isBedrockCacheSupported","messages","convertToConverseMessages","ConverseStreamCommand","handleConverseStreamContentBlockStart","handleConverseStreamContentBlockDelta","handleConverseStreamMetadata","ChatGenerationChunk","AIMessageChunk"],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AA6CH;;;;;AAKG;MACU,2BAA2B,GAAsB,MAAM;AAwE9D,MAAO,qBAAsB,SAAQA,uBAAmB,CAAA;;AAE5D,IAAA,WAAW;;AAGX,IAAA,2BAA2B;;AAG3B,IAAA,WAAW;;AAGX,IAAA,iBAAiB;;AAGjB,IAAA,iBAAiB;;AAGjB,IAAA,yBAAyB;AAEzB,IAAA,WAAA,CAAY,MAAmC,EAAA;QAC7C,KAAK,CAAC,MAAM,CAAC;QACb,IAAI,CAAC,WAAW,GAAG,MAAM,EAAE,WAAW,IAAI,KAAK;AAC/C,QAAA,IAAI,CAAC,2BAA2B,GAAG,MAAM,EAAE,2BAA2B;AACtE,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,EAAE,WAAW;QACtC,IAAI,CAAC,iBAAiB,GAAG,MAAM,EAAE,iBAAiB,IAAI,QAAQ;AAC9D,QAAA,IAAI,CAAC,iBAAiB;AACpB,YAAA,MAAM,EAAE,iBAAiB,IAAI,2BAA2B;AAC1D,QAAA,IAAI,CAAC,yBAAyB,GAAG,MAAM,EAAE,yBAAyB;;;;;;AAOlE,QAAA,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,EAAE,WAAW,EAAE;AACrD,QAAA,MAAM,WAAW,GAAG,CAClB,MAAM,EAAE,2BAA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O;gBACV,OAAO;AACP,gBAAA,iBAAiB,EAAE,eAAe;aACnC,CAAC;YACF,cAAc,EAAE,KAAK,CAAC,cAAc;AACrC,SAAA,CAAC;IACJ;AAEA;;;AAGG;AACK,IAAA,wBAAwB,CAC9B,QAAiC,EAAA;QAEjC,IACE,mBAAmB,IAAI,QAAQ;AAC/B,YAAA,OAAO,QAAQ,CAAC,iBAAiB,KAAK,QAAQ,EAC9C;YACA,OAAO,QAAQ,CAAC,iBAAiB;QACnC;AACA,QAAA,OAAO,SAAS;IAClB;AAEQ,IAAA,uBAAuB,CAAC,GAAY,EAAA;QAC1C,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;AACrC,YAAA,OAAO,GAAG;QACZ;AAEA,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AACtB,YAAA,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAC9D;AAEA,QAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,OAAO,GAA4B,EAAE;AAC3C,YAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAC9C,gBAAA,IAAI,GAAG,KAAK,mBAAmB,EAAE;oBAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC;gBACpD;YACF;AACA,YAAA,OAAO,OAAO;QAChB;AAEA,QAAA,OAAO,GAAG;IACZ;AACD;AAED;AACO,MAAM,yBAAyB,GAAG;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/llm/bedrock/index.ts"],"sourcesContent":["/**\n * Optimized ChatBedrockConverse wrapper that fixes content block merging for\n * streaming responses and adds support for latest @langchain/aws features:\n *\n * - Prompt caching support for Bedrock Converse API (Illuma feature)\n * - Application Inference Profiles (PR #9129)\n * - Service Tiers (Priority/Standard/Flex) (PR #9785) - requires AWS SDK 3.966.0+\n *\n * Bedrock's `@langchain/aws` library does not include an `index` property on content\n * blocks (unlike Anthropic/OpenAI), which causes LangChain's `_mergeLists` to append\n * each streaming chunk as a separate array entry instead of merging by index.\n *\n * This wrapper takes full ownership of the stream by directly interfacing with the\n * AWS SDK client (`this.client`) and using custom handlers from `./utils/` that\n * include `contentBlockIndex` in response_metadata for every delta type. It then\n * promotes `contentBlockIndex` to an `index` property on each content block\n * (mirroring Anthropic's pattern) and strips it from metadata to avoid\n * `_mergeDicts` conflicts.\n *\n * When multiple content block types are present (e.g. reasoning + text), text deltas\n * are promoted from strings to array form with `index` so they merge correctly once\n * the accumulated content is already an array.\n *\n * PROMPT CACHING:\n * When promptCache: true is set, this wrapper adds cachePoint markers to the tools array\n * to enable Bedrock prompt caching for tool definitions. This allows tool schemas to be\n * cached and reused across requests, reducing latency and costs.\n *\n * CACHE TOKEN EXTRACTION:\n * Cache token extraction is handled in `./utils/message_outputs.ts` and added\n * to usage_metadata with input_token_details (cacheReadInputTokens/cacheWriteInputTokens).\n */\n\nimport { ChatBedrockConverse } from '@langchain/aws';\nimport { ConverseStreamCommand } from '@aws-sdk/client-bedrock-runtime';\nimport { AIMessageChunk } from '@langchain/core/messages';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport { ChatGenerationChunk, ChatResult } from '@langchain/core/outputs';\nimport type { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';\nimport type { ChatBedrockConverseInput } from '@langchain/aws';\nimport { isBedrockCacheSupported } from './cacheSupport';\nimport {\n convertToConverseMessages,\n handleConverseStreamContentBlockStart,\n handleConverseStreamContentBlockDelta,\n handleConverseStreamMetadata,\n} from './utils';\n\n/**\n * Service tier type for Bedrock invocations.\n * Requires AWS SDK >= 3.966.0 to actually work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\nexport type ServiceTierType = 'priority' | 'default' | 'flex' | 'reserved';\n\n/**\n * Tool cachePoint allocation strategy.\n *\n * - 'single': one cachePoint at the END of the tools array (whole array\n * cached as one unit). Lightest budget use (1 cachePoint).\n * - 'split': split tools into groups via `toolGroupSelector`. Each\n * non-empty group gets its own cachePoint. Use when groups\n * have different volatility (e.g. stable core tools vs\n * volatile MCP tools). Costs more cachePoint budget.\n * - 'none': no cachePoint on tools array. Use when tool definitions\n * change every request anyway.\n */\nexport type ToolCacheStrategy = 'single' | 'split' | 'none';\n\n/**\n * Group selector for `toolCacheStrategy: 'split'`. Receives the tool name\n * and returns a stable group key — tools with the same key are grouped\n * together. Group order in the output array follows first-encounter order.\n */\nexport type ToolGroupSelector = (toolName: string) => string;\n\n/**\n * Default group selector — puts all tools in a single group named 'core'.\n * Equivalent to 'single' strategy but explicit. Consumers override this\n * to enable per-source grouping (e.g. by inspecting tool-name substrings\n * to separate stable framework tools from volatile MCP-sourced tools).\n */\nexport const DEFAULT_TOOL_GROUP_SELECTOR: ToolGroupSelector = () => 'core';\n\n/**\n * Extended input interface with additional features:\n * - promptCache: Enable Bedrock prompt caching for tool definitions\n * - applicationInferenceProfile: Use an inference profile ARN instead of model ID\n * - serviceTier: Specify service tier (Priority, Standard, Flex, Reserved)\n * - toolCacheStrategy: How to allocate cachePoints across tools array\n * - toolGroupSelector: Group key resolver for the 'split' strategy\n */\nexport interface IllumaBedrockConverseInput extends ChatBedrockConverseInput {\n /**\n * Enable Bedrock prompt caching for tool definitions.\n * When true, adds cachePoint marker(s) to tools array per\n * `toolCacheStrategy`. Defaults to 'single'.\n */\n promptCache?: boolean;\n\n /**\n * Tool cachePoint allocation. Defaults to 'single' — one cachePoint at\n * the end of the tools array. Set to 'split' (with `toolGroupSelector`)\n * when different tool groups have different volatility.\n */\n toolCacheStrategy?: ToolCacheStrategy;\n\n /**\n * Group selector for 'split' strategy. Receives a tool name, returns\n * a stable group key. Defaults to a one-group selector (equivalent\n * to 'single').\n */\n toolGroupSelector?: ToolGroupSelector;\n\n /**\n * Additional model ID patterns to consider Bedrock-cache-supported.\n * Defaults are in `src/llm/bedrock/cacheSupport.ts`. Use this when\n * AWS adds a new model family before the next library release.\n */\n bedrockCacheModelPatterns?: readonly RegExp[];\n\n /**\n * Application Inference Profile ARN to use for the model.\n * For example, \"arn:aws:bedrock:eu-west-1:123456789102:application-inference-profile/fm16bt65tzgx\"\n * When provided, this ARN will be used for the actual inference calls instead of the model ID.\n * Must still provide `model` as normal modelId to benefit from all the metadata.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-create.html\n */\n applicationInferenceProfile?: string;\n\n /**\n * Service tier for model invocation.\n * Specifies the processing tier type used for serving the request.\n * Supported values are 'priority', 'default', 'flex', and 'reserved'.\n *\n * - 'priority': Prioritized processing for lower latency\n * - 'default': Standard processing tier\n * - 'flex': Flexible processing tier with lower cost\n * - 'reserved': Reserved capacity for consistent performance\n *\n * If not provided, AWS uses the default tier.\n * Note: Requires AWS SDK >= 3.966.0 to work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\n serviceTier?: ServiceTierType;\n}\n\n/**\n * Extended call options with serviceTier override support.\n */\nexport interface IllumaBedrockConverseCallOptions {\n serviceTier?: ServiceTierType;\n}\n\nexport class IllumaBedrockConverse extends ChatBedrockConverse {\n /** Enable Bedrock prompt caching for tool definitions */\n promptCache: boolean;\n\n /** Application Inference Profile ARN to use instead of model ID */\n applicationInferenceProfile?: string;\n\n /** Service tier for model invocation */\n serviceTier?: ServiceTierType;\n\n /** Tool cachePoint allocation strategy. */\n toolCacheStrategy: ToolCacheStrategy;\n\n /** Group selector for 'split' strategy. */\n toolGroupSelector: ToolGroupSelector;\n\n /** Optional consumer extensions to the cache-supported model allowlist. */\n bedrockCacheModelPatterns?: readonly RegExp[];\n\n constructor(fields?: IllumaBedrockConverseInput) {\n super(fields);\n this.promptCache = fields?.promptCache ?? false;\n this.applicationInferenceProfile = fields?.applicationInferenceProfile;\n this.serviceTier = fields?.serviceTier;\n this.toolCacheStrategy = fields?.toolCacheStrategy ?? 'single';\n this.toolGroupSelector =\n fields?.toolGroupSelector ?? DEFAULT_TOOL_GROUP_SELECTOR;\n this.bedrockCacheModelPatterns = fields?.bedrockCacheModelPatterns;\n\n // Fix: Force supportsToolChoiceValues for Claude models\n // The parent constructor checks `model.includes('claude-3')` but this fails when:\n // 1. Using applicationInferenceProfile ARNs (arn:aws:bedrock:...)\n // 2. Using different naming conventions (claude-4, claude-opus-4, etc.)\n // We need to ensure tool_choice is properly set for withStructuredOutput to work\n const modelName = (fields?.model ?? '').toLowerCase();\n const profileName = (\n fields?.applicationInferenceProfile ?? ''\n ).toLowerCase();\n const isClaudeModel =\n modelName.includes('claude') ||\n modelName.includes('anthropic') ||\n profileName.includes('claude') ||\n profileName.includes('anthropic');\n\n if (isClaudeModel && !this.supportsToolChoiceValues?.length) {\n // Claude models support all tool choice values\n this.supportsToolChoiceValues = ['auto', 'any', 'tool'];\n }\n }\n\n static lc_name(): string {\n return 'IllumaBedrockConverse';\n }\n\n /**\n * Get the model ID to use for API calls.\n * Returns applicationInferenceProfile if set, otherwise returns this.model.\n */\n protected getModelId(): string {\n return this.applicationInferenceProfile ?? this.model;\n }\n\n /**\n * Override invocationParams to:\n * 1. Add cachePoint to tools when promptCache is enabled\n * 2. Add serviceTier support\n *\n * CACHING STRATEGY: Separate cachePoints for core tools and MCP tools\n * - Core tools (web_search, execute_code, etc.) are stable → cache first\n * - MCP tools (have '_mcp_' in name) are dynamic → cache separately after\n * - This allows core tools to stay cached when MCP selection changes\n *\n * NOTE: Only Claude models support cachePoint - Nova and other models will reject it.\n */\n override invocationParams(\n options?: this['ParsedCallOptions'] & IllumaBedrockConverseCallOptions\n ): ReturnType<ChatBedrockConverse['invocationParams']> & {\n serviceTier?: { type: ServiceTierType };\n } {\n const params = super.invocationParams(options);\n\n // Add cachePoint to tools array if promptCache is enabled and tools exist\n /**\n * Bedrock requires all toolSpec.description fields to be non-empty strings.\n * Some tools (e.g., MCP-sourced or dynamically created) may have empty or\n * missing descriptions. Patch them here to avoid Bedrock validation errors.\n */\n if (params.toolConfig?.tools && Array.isArray(params.toolConfig.tools)) {\n for (const t of params.toolConfig.tools) {\n const spec = (t as { toolSpec?: { description?: string } }).toolSpec;\n if (spec && (!spec.description || spec.description === '')) {\n spec.description =\n spec.description ||\n `Tool: ${(spec as { name?: string }).name ?? 'unknown'}`;\n }\n }\n }\n\n /* Allowlist-based gate (see cacheSupport.ts). Replaces the old\n * substring heuristic — same default behavior for Claude/Anthropic/\n * Nova models, plus extension via `bedrockCacheModelPatterns`. */\n const cacheSupported = isBedrockCacheSupported(\n this.model,\n this.bedrockCacheModelPatterns,\n );\n\n if (\n this.promptCache &&\n cacheSupported &&\n this.toolCacheStrategy !== 'none' &&\n params.toolConfig?.tools &&\n Array.isArray(params.toolConfig.tools) &&\n params.toolConfig.tools.length > 0\n ) {\n const tools = params.toolConfig.tools;\n\n if (this.toolCacheStrategy === 'single') {\n /* SINGLE: one cachePoint at the end of the tools array. Lightest\n * budget use; appropriate when the entire tools array is treated\n * as one unit and changes together. */\n const toolsWithCache = [\n ...tools,\n { cachePoint: { type: 'default' } } as (typeof tools)[number],\n ];\n params.toolConfig.tools = toolsWithCache;\n } else if (this.toolCacheStrategy === 'split') {\n /* SPLIT: group tools by `toolGroupSelector` and emit a cachePoint\n * after each non-empty group. Group order follows first-encounter\n * order in the input. Use when groups have different volatility\n * (e.g. stable core tools + volatile MCP tools). */\n const groupOrder: string[] = [];\n const groupMap = new Map<string, typeof tools>();\n for (const tool of tools) {\n const toolName =\n (tool as { toolSpec?: { name?: string } }).toolSpec?.name ?? '';\n const groupKey = this.toolGroupSelector(toolName);\n let group = groupMap.get(groupKey);\n if (!group) {\n group = [];\n groupMap.set(groupKey, group);\n groupOrder.push(groupKey);\n }\n group.push(tool);\n }\n\n const toolsWithCache: typeof tools = [];\n for (const groupKey of groupOrder) {\n const group = groupMap.get(groupKey);\n if (!group || group.length === 0) continue;\n toolsWithCache.push(...group);\n toolsWithCache.push(\n { cachePoint: { type: 'default' } } as (typeof tools)[number],\n );\n }\n params.toolConfig.tools = toolsWithCache;\n }\n }\n\n // Add serviceTier support\n const serviceTierType = options?.serviceTier ?? this.serviceTier;\n\n return {\n ...params,\n serviceTier: serviceTierType ? { type: serviceTierType } : undefined,\n };\n }\n\n /**\n * Override _generateNonStreaming to use applicationInferenceProfile as modelId.\n * Uses the same model-swapping pattern as streaming for consistency.\n */\n override async _generateNonStreaming(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & IllumaBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): Promise<ChatResult> {\n const originalModel = this.model;\n if (\n this.applicationInferenceProfile != null &&\n this.applicationInferenceProfile !== ''\n ) {\n this.model = this.applicationInferenceProfile;\n }\n\n try {\n return await super._generateNonStreaming(messages, options, runManager);\n } finally {\n this.model = originalModel;\n }\n }\n\n /**\n * Own the stream end-to-end so we have direct access to every\n * `contentBlockDelta.contentBlockIndex` from the AWS SDK.\n *\n * This replaces the parent's implementation which strips contentBlockIndex\n * from text and reasoning deltas, making it impossible to merge correctly.\n */\n override async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & IllumaBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n const { converseMessages, converseSystem } =\n convertToConverseMessages(messages);\n const params = this.invocationParams(options);\n\n let { streamUsage } = this;\n if ((options as Record<string, unknown>).streamUsage !== undefined) {\n streamUsage = (options as Record<string, unknown>).streamUsage as boolean;\n }\n\n const modelId = this.getModelId();\n\n const command = new ConverseStreamCommand({\n modelId,\n messages: converseMessages,\n system: converseSystem,\n ...(params as Record<string, unknown>),\n });\n\n const response = await this.client.send(command, {\n abortSignal: options.signal,\n });\n\n if (!response.stream) {\n return;\n }\n\n const seenBlockIndices = new Set<number>();\n\n for await (const event of response.stream) {\n if (event.contentBlockStart != null) {\n const startChunk = handleConverseStreamContentBlockStart(\n event.contentBlockStart\n );\n if (startChunk != null) {\n const idx = event.contentBlockStart.contentBlockIndex;\n if (idx != null) {\n seenBlockIndices.add(idx);\n }\n yield this.enrichChunk(startChunk, seenBlockIndices);\n }\n } else if (event.contentBlockDelta != null) {\n const deltaChunk = handleConverseStreamContentBlockDelta(\n event.contentBlockDelta\n );\n\n const idx = event.contentBlockDelta.contentBlockIndex;\n if (idx != null) {\n seenBlockIndices.add(idx);\n }\n\n yield this.enrichChunk(deltaChunk, seenBlockIndices);\n\n await runManager?.handleLLMNewToken(\n deltaChunk.text,\n undefined,\n undefined,\n undefined,\n undefined,\n { chunk: deltaChunk }\n );\n } else if (event.metadata != null) {\n yield handleConverseStreamMetadata(event.metadata, { streamUsage });\n } else if (event.contentBlockStop != null) {\n const stopIdx = event.contentBlockStop.contentBlockIndex;\n if (stopIdx != null) {\n seenBlockIndices.add(stopIdx);\n }\n } else {\n yield new ChatGenerationChunk({\n text: '',\n message: new AIMessageChunk({\n content: '',\n response_metadata: event,\n }),\n });\n }\n }\n }\n\n /**\n * Inject `index` on content blocks for proper merge behaviour, then strip\n * `contentBlockIndex` from response_metadata to prevent `_mergeDicts` conflicts.\n *\n * Text string content is promoted to array form only when the stream contains\n * multiple content block indices (e.g. reasoning at index 0, text at index 1),\n * ensuring text merges correctly with the already-array accumulated content.\n */\n enrichChunk(\n chunk: ChatGenerationChunk,\n seenBlockIndices: Set<number>\n ): ChatGenerationChunk {\n const message = chunk.message;\n if (!(message instanceof AIMessageChunk)) {\n return chunk;\n }\n\n const metadata = message.response_metadata as Record<string, unknown>;\n const blockIndex = this.extractContentBlockIndex(metadata);\n const hasMetadataIndex = blockIndex != null;\n\n let content: AIMessageChunk['content'] = message.content;\n let contentModified = false;\n\n if (Array.isArray(content) && blockIndex != null) {\n content = content.map((block) =>\n typeof block === 'object' && !('index' in block)\n ? { ...block, index: blockIndex }\n : block\n );\n contentModified = true;\n } else if (\n typeof content === 'string' &&\n content !== '' &&\n blockIndex != null &&\n seenBlockIndices.size > 1\n ) {\n content = [{ type: 'text', text: content, index: blockIndex }];\n contentModified = true;\n }\n\n if (!contentModified && !hasMetadataIndex) {\n return chunk;\n }\n\n const cleanedMetadata = hasMetadataIndex\n ? (this.removeContentBlockIndex(metadata) as Record<string, unknown>)\n : metadata;\n\n return new ChatGenerationChunk({\n text: chunk.text,\n message: new AIMessageChunk({\n ...message,\n content,\n response_metadata: cleanedMetadata,\n }),\n generationInfo: chunk.generationInfo,\n });\n }\n\n /**\n * Extract `contentBlockIndex` from the top level of response_metadata.\n * Our custom handlers always place it at the top level.\n */\n private extractContentBlockIndex(\n metadata: Record<string, unknown>\n ): number | undefined {\n if (\n 'contentBlockIndex' in metadata &&\n typeof metadata.contentBlockIndex === 'number'\n ) {\n return metadata.contentBlockIndex;\n }\n return undefined;\n }\n\n private removeContentBlockIndex(obj: unknown): unknown {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => this.removeContentBlockIndex(item));\n }\n\n if (typeof obj === 'object') {\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key !== 'contentBlockIndex') {\n cleaned[key] = this.removeContentBlockIndex(value);\n }\n }\n return cleaned;\n }\n\n return obj;\n }\n}\n\n/** @deprecated Use IllumaBedrockConverse. Alias kept for backward compatibility with existing imports. */\nexport const CustomChatBedrockConverse = IllumaBedrockConverse;\n\nexport type { ChatBedrockConverseInput };\n"],"names":["ChatBedrockConverse","isBedrockCacheSupported","messages","convertToConverseMessages","ConverseStreamCommand","handleConverseStreamContentBlockStart","handleConverseStreamContentBlockDelta","handleConverseStreamMetadata","ChatGenerationChunk","AIMessageChunk"],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AA6CH;;;;;AAKG;MACU,2BAA2B,GAAsB,MAAM;AAwE9D,MAAO,qBAAsB,SAAQA,uBAAmB,CAAA;;AAE5D,IA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,EAAE;AACtB,YAAA,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAC9D;AAEA,QAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,OAAO,GAA4B,EAAE;AAC3C,YAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAC9C,gBAAA,IAAI,GAAG,KAAK,mBAAmB,EAAE;oBAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC;gBACpD;YACF;AACA,YAAA,OAAO,OAAO;QAChB;AAEA,QAAA,OAAO,GAAG;IACZ;AACD;AAED;AACO,MAAM,yBAAyB,GAAG;;;;;;"}
@@ -640,7 +640,7 @@ class ChatDeepSeek extends deepseek.ChatDeepSeek {
640
640
  }
641
641
  class ChatMoonshot extends ChatOpenAI {
642
642
  static lc_name() {
643
- return 'LibreChatMoonshot';
643
+ return 'IllumaMoonshot';
644
644
  }
645
645
  _convertMessages(messages) {
646
646
  return index._convertMessagesToOpenAIParams(messages, this.model, {