langchain 1.0.0-alpha.5 → 1.0.0-alpha.6

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 (351) hide show
  1. package/dist/agents/ReactAgent.cjs +5 -5
  2. package/dist/agents/ReactAgent.cjs.map +1 -1
  3. package/dist/agents/ReactAgent.d.cts +1 -3
  4. package/dist/agents/ReactAgent.d.cts.map +1 -1
  5. package/dist/agents/ReactAgent.d.ts +1 -3
  6. package/dist/agents/ReactAgent.d.ts.map +1 -1
  7. package/dist/agents/ReactAgent.js +6 -6
  8. package/dist/agents/ReactAgent.js.map +1 -1
  9. package/dist/agents/annotation.cjs.map +1 -1
  10. package/dist/agents/annotation.d.cts +4 -6
  11. package/dist/agents/annotation.d.cts.map +1 -1
  12. package/dist/agents/annotation.d.ts +4 -6
  13. package/dist/agents/annotation.d.ts.map +1 -1
  14. package/dist/agents/annotation.js.map +1 -1
  15. package/dist/agents/createAgent.cjs.map +1 -1
  16. package/dist/agents/createAgent.js.map +1 -1
  17. package/dist/agents/index.cjs +2 -2
  18. package/dist/agents/index.cjs.map +1 -1
  19. package/dist/agents/index.d.cts +47 -47
  20. package/dist/agents/index.d.cts.map +1 -1
  21. package/dist/agents/index.d.ts +47 -47
  22. package/dist/agents/index.d.ts.map +1 -1
  23. package/dist/agents/index.js +2 -2
  24. package/dist/agents/index.js.map +1 -1
  25. package/dist/agents/middlewareAgent/ReactAgent.cjs +18 -18
  26. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
  27. package/dist/agents/middlewareAgent/ReactAgent.d.cts +8 -9
  28. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
  29. package/dist/agents/middlewareAgent/ReactAgent.d.ts +8 -9
  30. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
  31. package/dist/agents/middlewareAgent/ReactAgent.js +18 -18
  32. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
  33. package/dist/agents/middlewareAgent/annotation.cjs +2 -2
  34. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
  35. package/dist/agents/middlewareAgent/annotation.js +2 -2
  36. package/dist/agents/middlewareAgent/annotation.js.map +1 -1
  37. package/dist/agents/middlewareAgent/index.cjs.map +1 -1
  38. package/dist/agents/middlewareAgent/index.js.map +1 -1
  39. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.cjs +8 -8
  40. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -0
  41. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.d.cts +3 -3
  42. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -0
  43. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.d.ts +3 -3
  44. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -0
  45. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.js +3 -3
  46. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -0
  47. package/dist/agents/middlewareAgent/middleware/index.cjs +26 -0
  48. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -0
  49. package/dist/agents/middlewareAgent/middleware/index.js +17 -0
  50. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -0
  51. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.cjs +51 -22
  52. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -0
  53. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.cts +9 -9
  54. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -0
  55. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.ts +9 -9
  56. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -0
  57. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.js +50 -21
  58. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -0
  59. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.cjs +11 -11
  60. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -0
  61. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.cts +3 -3
  62. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -0
  63. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.ts +10 -10
  64. package/dist/agents/middlewareAgent/{middlewares/summarization.d.cts.map → middleware/summarization.d.ts.map} +1 -1
  65. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.js +4 -4
  66. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -0
  67. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
  68. package/dist/agents/middlewareAgent/middleware.d.cts +1 -1
  69. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
  70. package/dist/agents/middlewareAgent/middleware.d.ts +1 -1
  71. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
  72. package/dist/agents/middlewareAgent/middleware.js.map +1 -1
  73. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
  74. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
  75. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +12 -19
  76. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
  77. package/dist/agents/middlewareAgent/nodes/AgentNode.js +12 -19
  78. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
  79. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
  80. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
  81. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
  82. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
  83. package/dist/agents/middlewareAgent/nodes/utils.cjs +7 -7
  84. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
  85. package/dist/agents/middlewareAgent/nodes/utils.js +3 -3
  86. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
  87. package/dist/agents/middlewareAgent/types.d.cts +10 -23
  88. package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
  89. package/dist/agents/middlewareAgent/types.d.ts +10 -23
  90. package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
  91. package/dist/agents/nodes/AgentNode.cjs +4 -4
  92. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  93. package/dist/agents/nodes/AgentNode.js +4 -4
  94. package/dist/agents/nodes/AgentNode.js.map +1 -1
  95. package/dist/agents/nodes/ToolNode.cjs +3 -3
  96. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  97. package/dist/agents/nodes/ToolNode.d.cts +1 -2
  98. package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
  99. package/dist/agents/nodes/ToolNode.d.ts +1 -2
  100. package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
  101. package/dist/agents/nodes/ToolNode.js +4 -4
  102. package/dist/agents/nodes/ToolNode.js.map +1 -1
  103. package/dist/agents/responses.cjs +1 -1
  104. package/dist/agents/responses.cjs.map +1 -1
  105. package/dist/agents/responses.d.cts.map +1 -1
  106. package/dist/agents/responses.d.ts.map +1 -1
  107. package/dist/agents/responses.js +1 -1
  108. package/dist/agents/responses.js.map +1 -1
  109. package/dist/agents/types.d.cts +1 -3
  110. package/dist/agents/types.d.cts.map +1 -1
  111. package/dist/agents/types.d.ts +1 -3
  112. package/dist/agents/types.d.ts.map +1 -1
  113. package/dist/agents/utils.cjs +6 -6
  114. package/dist/agents/utils.cjs.map +1 -1
  115. package/dist/agents/utils.js +7 -7
  116. package/dist/agents/utils.js.map +1 -1
  117. package/dist/agents/withAgentName.cjs.map +1 -1
  118. package/dist/agents/withAgentName.js.map +1 -1
  119. package/dist/chains/api/prompts.cjs.map +1 -1
  120. package/dist/chains/api/prompts.js.map +1 -1
  121. package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
  122. package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
  123. package/dist/chains/index.cjs +0 -3
  124. package/dist/chains/index.cjs.map +1 -1
  125. package/dist/chains/index.d.cts +1 -2
  126. package/dist/chains/index.d.ts +1 -2
  127. package/dist/chains/index.js +1 -3
  128. package/dist/chains/index.js.map +1 -1
  129. package/dist/chains/openai_functions/extraction.cjs.map +1 -1
  130. package/dist/chains/openai_functions/extraction.d.cts +1 -3
  131. package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
  132. package/dist/chains/openai_functions/extraction.d.ts +1 -3
  133. package/dist/chains/openai_functions/extraction.d.ts.map +1 -1
  134. package/dist/chains/openai_functions/extraction.js.map +1 -1
  135. package/dist/chains/openai_functions/index.cjs +0 -5
  136. package/dist/chains/openai_functions/index.cjs.map +1 -1
  137. package/dist/chains/openai_functions/index.d.cts +1 -2
  138. package/dist/chains/openai_functions/index.d.ts +1 -2
  139. package/dist/chains/openai_functions/index.js +1 -4
  140. package/dist/chains/openai_functions/index.js.map +1 -1
  141. package/dist/chains/openai_functions/openapi.cjs +4 -4
  142. package/dist/chains/openai_functions/openapi.cjs.map +1 -1
  143. package/dist/chains/openai_functions/openapi.d.cts +1 -1
  144. package/dist/chains/openai_functions/openapi.js +4 -4
  145. package/dist/chains/openai_functions/openapi.js.map +1 -1
  146. package/dist/chains/openai_functions/tagging.cjs.map +1 -1
  147. package/dist/chains/openai_functions/tagging.d.cts +1 -3
  148. package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
  149. package/dist/chains/openai_functions/tagging.d.ts +1 -3
  150. package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
  151. package/dist/chains/openai_functions/tagging.js.map +1 -1
  152. package/dist/chains/query_constructor/index.cjs +4 -4
  153. package/dist/chains/query_constructor/index.cjs.map +1 -1
  154. package/dist/chains/query_constructor/index.d.cts +4 -2
  155. package/dist/chains/query_constructor/index.d.cts.map +1 -1
  156. package/dist/chains/query_constructor/index.d.ts +4 -2
  157. package/dist/chains/query_constructor/index.d.ts.map +1 -1
  158. package/dist/chains/query_constructor/index.js +1 -1
  159. package/dist/chains/query_constructor/index.js.map +1 -1
  160. package/dist/chains/question_answering/load.d.ts +2 -2
  161. package/dist/chains/question_answering/load.d.ts.map +1 -1
  162. package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
  163. package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
  164. package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
  165. package/dist/chains/question_answering/refine_prompts.js.map +1 -1
  166. package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
  167. package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
  168. package/dist/chains/router/multi_prompt.cjs +4 -4
  169. package/dist/chains/router/multi_prompt.cjs.map +1 -1
  170. package/dist/chains/router/multi_prompt.js +1 -1
  171. package/dist/chains/router/multi_prompt.js.map +1 -1
  172. package/dist/chains/router/multi_retrieval_qa.cjs +4 -4
  173. package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
  174. package/dist/chains/router/multi_retrieval_qa.js +1 -1
  175. package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
  176. package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
  177. package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
  178. package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
  179. package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
  180. package/dist/chains/summarization/load.d.ts +2 -2
  181. package/dist/chains/summarization/load.d.ts.map +1 -1
  182. package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
  183. package/dist/chains/summarization/stuff_prompts.js.map +1 -1
  184. package/dist/chat_models/universal.cjs +8 -5
  185. package/dist/chat_models/universal.cjs.map +1 -1
  186. package/dist/chat_models/universal.d.cts +2 -2
  187. package/dist/chat_models/universal.d.cts.map +1 -1
  188. package/dist/chat_models/universal.d.ts +2 -2
  189. package/dist/chat_models/universal.d.ts.map +1 -1
  190. package/dist/chat_models/universal.js +8 -5
  191. package/dist/chat_models/universal.js.map +1 -1
  192. package/dist/document_loaders/fs/directory.cjs.map +1 -1
  193. package/dist/document_loaders/fs/directory.d.cts +0 -1
  194. package/dist/document_loaders/fs/directory.d.cts.map +1 -1
  195. package/dist/document_loaders/fs/directory.d.ts +0 -1
  196. package/dist/document_loaders/fs/directory.d.ts.map +1 -1
  197. package/dist/document_loaders/fs/directory.js.map +1 -1
  198. package/dist/document_loaders/fs/json.cjs +7 -1
  199. package/dist/document_loaders/fs/json.cjs.map +1 -1
  200. package/dist/document_loaders/fs/json.js +7 -1
  201. package/dist/document_loaders/fs/json.js.map +1 -1
  202. package/dist/embeddings/cache_backed.cjs +1 -1
  203. package/dist/embeddings/cache_backed.cjs.map +1 -1
  204. package/dist/embeddings/cache_backed.d.cts +1 -1
  205. package/dist/embeddings/cache_backed.d.ts +1 -1
  206. package/dist/embeddings/cache_backed.js +2 -2
  207. package/dist/embeddings/cache_backed.js.map +1 -1
  208. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  209. package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
  210. package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
  211. package/dist/evaluation/embedding_distance/base.cjs +2 -4
  212. package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
  213. package/dist/evaluation/embedding_distance/base.js +2 -3
  214. package/dist/evaluation/embedding_distance/base.js.map +1 -1
  215. package/dist/evaluation/loader.cjs +7 -12
  216. package/dist/evaluation/loader.cjs.map +1 -1
  217. package/dist/evaluation/loader.d.cts +8 -2
  218. package/dist/evaluation/loader.d.cts.map +1 -1
  219. package/dist/evaluation/loader.d.ts +8 -2
  220. package/dist/evaluation/loader.d.ts.map +1 -1
  221. package/dist/evaluation/loader.js +7 -12
  222. package/dist/evaluation/loader.js.map +1 -1
  223. package/dist/hub/base.cjs.map +1 -1
  224. package/dist/hub/base.js.map +1 -1
  225. package/dist/langchain-core/dist/load/serializable.d.cts.map +1 -1
  226. package/dist/langchain-core/dist/messages/base.d.cts +24 -33
  227. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  228. package/dist/langchain-core/dist/messages/content/index.d.cts +1 -1
  229. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  230. package/dist/langchain-core/dist/messages/message.d.cts +598 -0
  231. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -0
  232. package/dist/langchain-core/dist/messages/metadata.d.cts +97 -0
  233. package/dist/langchain-core/dist/messages/metadata.d.cts.map +1 -0
  234. package/dist/langchain-core/dist/messages/utils.d.cts +75 -0
  235. package/dist/langchain-core/dist/messages/utils.d.cts.map +1 -0
  236. package/dist/langchain-core/dist/prompt_values.d.cts.map +1 -1
  237. package/dist/libs/langchain-core/dist/load/serializable.d.ts.map +1 -1
  238. package/dist/libs/langchain-core/dist/messages/base.d.ts +24 -33
  239. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  240. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +1 -1
  241. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  242. package/dist/libs/langchain-core/dist/messages/message.d.ts +598 -0
  243. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -0
  244. package/dist/libs/langchain-core/dist/messages/metadata.d.ts +97 -0
  245. package/dist/libs/langchain-core/dist/messages/metadata.d.ts.map +1 -0
  246. package/dist/libs/langchain-core/dist/messages/utils.d.ts +75 -0
  247. package/dist/libs/langchain-core/dist/messages/utils.d.ts.map +1 -0
  248. package/dist/libs/langchain-core/dist/prompt_values.d.ts.map +1 -1
  249. package/dist/libs/langchain-core/dist/utils/types/index.d.ts +2 -0
  250. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  251. package/dist/libs/langchain-core/dist/utils/types/zod.d.ts +1 -0
  252. package/dist/load/import_map.cjs +3 -14
  253. package/dist/load/import_map.cjs.map +1 -1
  254. package/dist/load/import_map.js +3 -14
  255. package/dist/load/import_map.js.map +1 -1
  256. package/dist/memory/prompt.cjs.map +1 -1
  257. package/dist/memory/prompt.d.cts.map +1 -1
  258. package/dist/memory/prompt.d.ts.map +1 -1
  259. package/dist/memory/prompt.js.map +1 -1
  260. package/dist/output_parsers/combining.cjs +1 -1
  261. package/dist/output_parsers/combining.cjs.map +1 -1
  262. package/dist/output_parsers/combining.js +1 -1
  263. package/dist/output_parsers/combining.js.map +1 -1
  264. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map +1 -1
  265. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map +1 -1
  266. package/dist/output_parsers/expression_type_handlers/base.cjs +1 -1
  267. package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
  268. package/dist/output_parsers/expression_type_handlers/base.js +1 -1
  269. package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
  270. package/dist/output_parsers/regex.cjs.map +1 -1
  271. package/dist/output_parsers/regex.js.map +1 -1
  272. package/dist/output_parsers/structured.cjs +4 -4
  273. package/dist/output_parsers/structured.cjs.map +1 -1
  274. package/dist/output_parsers/structured.d.cts +1 -1
  275. package/dist/output_parsers/structured.d.cts.map +1 -1
  276. package/dist/output_parsers/structured.d.ts +1 -1
  277. package/dist/output_parsers/structured.d.ts.map +1 -1
  278. package/dist/output_parsers/structured.js +2 -2
  279. package/dist/output_parsers/structured.js.map +1 -1
  280. package/dist/retrievers/ensemble.cjs.map +1 -1
  281. package/dist/retrievers/ensemble.js.map +1 -1
  282. package/dist/storage/file_system.cjs +1 -1
  283. package/dist/storage/file_system.cjs.map +1 -1
  284. package/dist/storage/file_system.js +1 -1
  285. package/dist/storage/file_system.js.map +1 -1
  286. package/dist/tools/fs.cjs +5 -5
  287. package/dist/tools/fs.cjs.map +1 -1
  288. package/dist/tools/fs.d.cts +1 -1
  289. package/dist/tools/fs.d.cts.map +1 -1
  290. package/dist/tools/fs.d.ts +1 -1
  291. package/dist/tools/fs.d.ts.map +1 -1
  292. package/dist/tools/fs.js +1 -1
  293. package/dist/tools/fs.js.map +1 -1
  294. package/dist/tools/retriever.cjs +2 -2
  295. package/dist/tools/retriever.cjs.map +1 -1
  296. package/dist/tools/retriever.d.cts +1 -1
  297. package/dist/tools/retriever.d.cts.map +1 -1
  298. package/dist/tools/retriever.d.ts +1 -1
  299. package/dist/tools/retriever.d.ts.map +1 -1
  300. package/dist/tools/retriever.js +1 -1
  301. package/dist/tools/retriever.js.map +1 -1
  302. package/dist/tools/sql.cjs +1 -2
  303. package/dist/tools/sql.cjs.map +1 -1
  304. package/dist/tools/sql.d.cts +1 -1
  305. package/dist/tools/sql.d.cts.map +1 -1
  306. package/dist/tools/sql.d.ts +1 -1
  307. package/dist/tools/sql.d.ts.map +1 -1
  308. package/dist/tools/sql.js +1 -2
  309. package/dist/tools/sql.js.map +1 -1
  310. package/dist/types/expression-parser.d.cts +2 -0
  311. package/dist/types/expression-parser.d.cts.map +1 -1
  312. package/dist/types/expression-parser.d.ts +2 -0
  313. package/dist/types/expression-parser.d.ts.map +1 -1
  314. package/dist/util/hub.cjs +1 -1
  315. package/dist/util/hub.js +1 -1
  316. package/dist/util/openapi.cjs +1 -1
  317. package/dist/util/openapi.cjs.map +1 -1
  318. package/dist/util/openapi.js +1 -1
  319. package/dist/util/openapi.js.map +1 -1
  320. package/package.json +15 -21
  321. package/dist/agents/middlewareAgent/middlewares/hitl.cjs.map +0 -1
  322. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts.map +0 -1
  323. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts.map +0 -1
  324. package/dist/agents/middlewareAgent/middlewares/hitl.js.map +0 -1
  325. package/dist/agents/middlewareAgent/middlewares/index.cjs +0 -8
  326. package/dist/agents/middlewareAgent/middlewares/index.js +0 -5
  327. package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs.map +0 -1
  328. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts.map +0 -1
  329. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts.map +0 -1
  330. package/dist/agents/middlewareAgent/middlewares/promptCaching.js.map +0 -1
  331. package/dist/agents/middlewareAgent/middlewares/summarization.cjs.map +0 -1
  332. package/dist/agents/middlewareAgent/middlewares/summarization.d.ts.map +0 -1
  333. package/dist/agents/middlewareAgent/middlewares/summarization.js.map +0 -1
  334. package/dist/chains/openai_functions/structured_output.cjs +0 -107
  335. package/dist/chains/openai_functions/structured_output.cjs.map +0 -1
  336. package/dist/chains/openai_functions/structured_output.d.cts +0 -38
  337. package/dist/chains/openai_functions/structured_output.d.cts.map +0 -1
  338. package/dist/chains/openai_functions/structured_output.d.ts +0 -38
  339. package/dist/chains/openai_functions/structured_output.d.ts.map +0 -1
  340. package/dist/chains/openai_functions/structured_output.js +0 -105
  341. package/dist/chains/openai_functions/structured_output.js.map +0 -1
  342. package/dist/chains/openai_moderation.cjs +0 -107
  343. package/dist/chains/openai_moderation.cjs.map +0 -1
  344. package/dist/chains/openai_moderation.d.cts +0 -74
  345. package/dist/chains/openai_moderation.d.cts.map +0 -1
  346. package/dist/chains/openai_moderation.d.ts +0 -74
  347. package/dist/chains/openai_moderation.d.ts.map +0 -1
  348. package/dist/chains/openai_moderation.js +0 -106
  349. package/dist/chains/openai_moderation.js.map +0 -1
  350. /package/dist/agents/middlewareAgent/{middlewares → middleware}/index.d.cts +0 -0
  351. /package/dist/agents/middlewareAgent/{middlewares → middleware}/index.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","names":["state: TStateSchema","config?: LangGraphRunnableConfig","relevantContext: Record<string, unknown>","runtime: Runtime<TContextSchema>","controls: Controls<TStateSchema>","target: \"model\" | \"tools\"","stateUpdate?: Partial<TStateSchema>","result?: Partial<TStateSchema> | Error","result"],"sources":["../../../../src/agents/middlewareAgent/nodes/middleware.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport { z } from \"zod\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\n\nimport { RunnableCallable } from \"../../RunnableCallable.js\";\nimport type {\n Runtime,\n Controls,\n ControlAction,\n AgentMiddleware,\n MiddlewareResult,\n} from \"../types.js\";\nimport {\n derivePrivateState,\n parseToolCalls,\n parseToolResults,\n} from \"./utils.js\";\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>;\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>,\n controls?: Controls<TStateSchema>\n ): Promise<MiddlewareResult<TStateSchema>>;\n\n async invokeMiddleware(\n state: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Check both config.context and config.configurable.context\n */\n if (this.middleware.contextSchema && config?.context) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n for (const key of Object.keys(schemaShape)) {\n if (key in config.context) {\n relevantContext[key] = config.context[key];\n }\n }\n /**\n * Parse to apply defaults and validation\n */\n filteredContext = this.middleware.contextSchema.parse(\n relevantContext\n ) as TContextSchema;\n }\n }\n\n /**\n * ToDo: implement later\n */\n const runtime: Runtime<TContextSchema> = {\n toolCalls: parseToolCalls(state.messages),\n toolResults: parseToolResults(state.messages),\n context: filteredContext,\n };\n\n const controls: Controls<TStateSchema> = {\n jumpTo: (\n target: \"model\" | \"tools\",\n stateUpdate?: Partial<TStateSchema>\n ): ControlAction<TStateSchema> => ({\n type: \"jump\",\n target,\n stateUpdate,\n }),\n terminate: (\n result?: Partial<TStateSchema> | Error\n ): ControlAction<TStateSchema> => {\n if (result instanceof Error) {\n throw result;\n }\n return { type: \"terminate\", result };\n },\n };\n\n const result = await this.runHook(state, runtime, controls);\n\n /**\n * If result is undefined, return current state\n */\n if (!result) {\n return state;\n }\n\n /**\n * If result is a control action, handle it\n */\n // if (typeof result === \"object\" && \"type\" in result) {\n // // Handle control actions\n // const action = result as ControlAction<TStateSchema>;\n // if (action.type === \"terminate\") {\n // if (action.error) {\n // throw action.error;\n // }\n // return { ...state, ...(action.result || {}) };\n // }\n\n // if (action.type === \"jump\") {\n // return new Command<any, TStateSchema, string>({\n // goto: action.target,\n // update: { ...state, ...(action.stateUpdate || {}) },\n // });\n // }\n\n // throw new Error(`Invalid control action: ${JSON.stringify(action)}`);\n // }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result };\n }\n\n get nodeOptions(): {\n input: z.ZodObject<TStateSchema>;\n } {\n return {\n input: derivePrivateState(\n this.middleware.stateSchema\n ) as z.ZodObject<TStateSchema>,\n };\n }\n}\n"],"mappings":";;;;AAsBA,IAAsB,iBAAtB,cAGU,iBAAyD;CAYjE,MAAM,iBACJA,OACAC,QACmC;;;;EAInC,IAAI,kBAAkB,CAAE;;;;AAIxB,MAAI,KAAK,WAAW,iBAAiB,QAAQ,SAAS;;;;GAIpD,MAAM,cAAc,KAAK,WAAW,eAAe;AACnD,OAAI,aAAa;IACf,MAAMC,kBAA2C,CAAE;AACnD,SAAK,MAAM,OAAO,OAAO,KAAK,YAAY,CACxC,KAAI,OAAO,OAAO,SAChB,gBAAgB,OAAO,OAAO,QAAQ;;;;IAM1C,kBAAkB,KAAK,WAAW,cAAc,MAC9C,gBACD;GACF;EACF;;;;EAKD,MAAMC,UAAmC;GACvC,WAAW,eAAe,MAAM,SAAS;GACzC,aAAa,iBAAiB,MAAM,SAAS;GAC7C,SAAS;EACV;EAED,MAAMC,WAAmC;GACvC,QAAQ,CACNC,QACAC,iBACiC;IACjC,MAAM;IACN;IACA;GACD;GACD,WAAW,CACTC,aACgC;AAChC,QAAIC,oBAAkB,MACpB,OAAMA;AAER,WAAO;KAAE,MAAM;KAAa;IAAQ;GACrC;EACF;EAED,MAAM,SAAS,MAAM,KAAK,QAAQ,OAAO,SAAS,SAAS;;;;AAK3D,MAAI,CAAC,OACH,QAAO;;;;;;;AA6BT,SAAO;GAAE,GAAG;GAAO,GAAG;EAAQ;CAC/B;CAED,IAAI,cAEF;AACA,SAAO,EACL,OAAO,mBACL,KAAK,WAAW,YACjB,CACF;CACF;AACF"}
1
+ {"version":3,"file":"middleware.js","names":["state: TStateSchema","config?: LangGraphRunnableConfig","relevantContext: Record<string, unknown>","runtime: Runtime<TContextSchema>","controls: Controls<TStateSchema>","target: \"model\" | \"tools\"","stateUpdate?: Partial<TStateSchema>","result?: Partial<TStateSchema> | Error","result"],"sources":["../../../../src/agents/middlewareAgent/nodes/middleware.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-instanceof/no-instanceof */\nimport { z } from \"zod/v3\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\n\nimport { RunnableCallable } from \"../../RunnableCallable.js\";\nimport type {\n Runtime,\n Controls,\n ControlAction,\n AgentMiddleware,\n MiddlewareResult,\n} from \"../types.js\";\nimport {\n derivePrivateState,\n parseToolCalls,\n parseToolResults,\n} from \"./utils.js\";\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>;\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>,\n controls?: Controls<TStateSchema>\n ): Promise<MiddlewareResult<TStateSchema>>;\n\n async invokeMiddleware(\n state: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Check both config.context and config.configurable.context\n */\n if (this.middleware.contextSchema && config?.context) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n for (const key of Object.keys(schemaShape)) {\n if (key in config.context) {\n relevantContext[key] = config.context[key];\n }\n }\n /**\n * Parse to apply defaults and validation\n */\n filteredContext = this.middleware.contextSchema.parse(\n relevantContext\n ) as TContextSchema;\n }\n }\n\n /**\n * ToDo: implement later\n */\n const runtime: Runtime<TContextSchema> = {\n toolCalls: parseToolCalls(state.messages),\n toolResults: parseToolResults(state.messages),\n context: filteredContext,\n };\n\n const controls: Controls<TStateSchema> = {\n jumpTo: (\n target: \"model\" | \"tools\",\n stateUpdate?: Partial<TStateSchema>\n ): ControlAction<TStateSchema> => ({\n type: \"jump\",\n target,\n stateUpdate,\n }),\n terminate: (\n result?: Partial<TStateSchema> | Error\n ): ControlAction<TStateSchema> => {\n if (result instanceof Error) {\n throw result;\n }\n return { type: \"terminate\", result };\n },\n };\n\n const result = await this.runHook(state, runtime, controls);\n\n /**\n * If result is undefined, return current state\n */\n if (!result) {\n return state;\n }\n\n /**\n * If result is a control action, handle it\n */\n // if (typeof result === \"object\" && \"type\" in result) {\n // // Handle control actions\n // const action = result as ControlAction<TStateSchema>;\n // if (action.type === \"terminate\") {\n // if (action.error) {\n // throw action.error;\n // }\n // return { ...state, ...(action.result || {}) };\n // }\n\n // if (action.type === \"jump\") {\n // return new Command<any, TStateSchema, string>({\n // goto: action.target,\n // update: { ...state, ...(action.stateUpdate || {}) },\n // });\n // }\n\n // throw new Error(`Invalid control action: ${JSON.stringify(action)}`);\n // }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result };\n }\n\n get nodeOptions(): {\n input: z.ZodObject<TStateSchema>;\n } {\n return {\n input: derivePrivateState(\n this.middleware.stateSchema\n ) as z.ZodObject<TStateSchema>,\n };\n }\n}\n"],"mappings":";;;;AAuBA,IAAsB,iBAAtB,cAGU,iBAAyD;CAYjE,MAAM,iBACJA,OACAC,QACmC;;;;EAInC,IAAI,kBAAkB,CAAE;;;;AAIxB,MAAI,KAAK,WAAW,iBAAiB,QAAQ,SAAS;;;;GAIpD,MAAM,cAAc,KAAK,WAAW,eAAe;AACnD,OAAI,aAAa;IACf,MAAMC,kBAA2C,CAAE;AACnD,SAAK,MAAM,OAAO,OAAO,KAAK,YAAY,CACxC,KAAI,OAAO,OAAO,SAChB,gBAAgB,OAAO,OAAO,QAAQ;;;;IAM1C,kBAAkB,KAAK,WAAW,cAAc,MAC9C,gBACD;GACF;EACF;;;;EAKD,MAAMC,UAAmC;GACvC,WAAW,eAAe,MAAM,SAAS;GACzC,aAAa,iBAAiB,MAAM,SAAS;GAC7C,SAAS;EACV;EAED,MAAMC,WAAmC;GACvC,QAAQ,CACNC,QACAC,iBACiC;IACjC,MAAM;IACN;IACA;GACD;GACD,WAAW,CACTC,aACgC;AAChC,QAAIC,oBAAkB,MACpB,OAAMA;AAER,WAAO;KAAE,MAAM;KAAa;IAAQ;GACrC;EACF;EAED,MAAM,SAAS,MAAM,KAAK,QAAQ,OAAO,SAAS,SAAS;;;;AAK3D,MAAI,CAAC,OACH,QAAO;;;;;;;AA6BT,SAAO;GAAE,GAAG;GAAO,GAAG;EAAQ;CAC/B;CAED,IAAI,cAEF;AACA,SAAO,EACL,OAAO,mBACL,KAAK,WAAW,YACjB,CACF;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
2
  const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
3
- const zod = require_rolldown_runtime.__toESM(require("zod"));
3
+ const zod_v3 = require_rolldown_runtime.__toESM(require("zod/v3"));
4
4
 
5
5
  //#region src/agents/middlewareAgent/nodes/utils.ts
6
6
  /**
@@ -10,14 +10,14 @@ const zod = require_rolldown_runtime.__toESM(require("zod"));
10
10
  * Private properties (starting with _) are automatically made optional since
11
11
  * users cannot provide them when invoking the agent.
12
12
  */
13
- function initializeMiddlewareStates(middlewares, state) {
13
+ function initializeMiddlewareStates(middlewareList, state) {
14
14
  const middlewareStates = {};
15
- for (const middleware of middlewares) if (middleware.stateSchema) {
15
+ for (const middleware of middlewareList) if (middleware.stateSchema) {
16
16
  const { shape } = middleware.stateSchema;
17
17
  const modifiedShape = {};
18
18
  for (const [key, value] of Object.entries(shape)) if (key.startsWith("_")) modifiedShape[key] = value.optional();
19
19
  else modifiedShape[key] = value;
20
- const modifiedSchema = zod.z.object(modifiedShape);
20
+ const modifiedSchema = zod_v3.z.object(modifiedShape);
21
21
  const parseResult = modifiedSchema.safeParse(state);
22
22
  if (parseResult.success) {
23
23
  Object.assign(middlewareStates, parseResult.data);
@@ -38,13 +38,13 @@ function initializeMiddlewareStates(middlewares, state) {
38
38
  * @returns A new schema containing only the private properties (underscore-prefixed), all made optional
39
39
  */
40
40
  function derivePrivateState(stateSchema) {
41
- const builtInStateSchema = { messages: zod.z.custom(() => []) };
42
- if (!stateSchema) return zod.z.object(builtInStateSchema);
41
+ const builtInStateSchema = { messages: zod_v3.z.custom(() => []) };
42
+ if (!stateSchema) return zod_v3.z.object(builtInStateSchema);
43
43
  const { shape } = stateSchema;
44
44
  const privateShape = builtInStateSchema;
45
45
  for (const [key, value] of Object.entries(shape)) if (key.startsWith("_")) privateShape[key] = value.optional();
46
46
  else privateShape[key] = value;
47
- return zod.z.object(privateShape);
47
+ return zod_v3.z.object(privateShape);
48
48
  }
49
49
  /**
50
50
  * Parse out all tool calls from the messages
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["middlewares: readonly AgentMiddleware<any, any, any>[]","state: unknown","middlewareStates: Record<string, any>","modifiedShape: Record<string, any>","z","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","messages: BaseMessage[]"],"sources":["../../../../src/agents/middlewareAgent/nodes/utils.ts"],"sourcesContent":["import {\n type BaseMessage,\n type ToolMessage,\n type AIMessage,\n isToolMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { z, type ZodIssue, type ZodTypeAny } from \"zod\";\n\nimport type { AgentMiddleware, ToolCall, ToolResult } from \"../types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport function initializeMiddlewareStates(\n middlewares: readonly AgentMiddleware<any, any, any>[],\n state: unknown\n): Record<string, any> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewares) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const { shape } = middleware.stateSchema;\n const modifiedShape: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make private properties optional\n modifiedShape[key] = (value as ZodTypeAny).optional();\n } else {\n // Keep public properties as-is\n modifiedShape[key] = value;\n }\n }\n\n const modifiedSchema = z.object(modifiedShape);\n\n // Use safeParse with the modified schema\n const parseResult = modifiedSchema.safeParse(state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(stateSchema?: z.ZodObject<z.ZodRawShape>) {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = builtInStateSchema;\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse out all tool calls from the messages\n * @param messages - The messages to parse\n * @returns The tool calls\n */\nexport function parseToolCalls(messages: BaseMessage[]): ToolCall[] {\n return (\n messages\n .filter(\n (message) => isAIMessage(message) && (message as AIMessage).tool_calls\n )\n .map((message) => (message as AIMessage).tool_calls as ToolCall[])\n .flat() || []\n );\n}\n\n/**\n * Parse out all tool results from the messages\n * @param messages - The messages to parse\n * @returns The tool results\n */\nexport function parseToolResults(messages: BaseMessage[]): ToolResult[] {\n return messages\n .filter((message) => isToolMessage(message))\n .map((message) => ({\n id: (message as ToolMessage).tool_call_id,\n result: (message as ToolMessage).content,\n }));\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,2BACdA,aACAC,OACqB;CACrB,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,YACvB,KAAI,WAAW,aAAa;EAE1B,MAAM,EAAE,OAAO,GAAG,WAAW;EAC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AyB,CACjE,MAAM,IAAI,CAAE;AAElB;;;;;;AAOD,SAAgB,iBAAiBA,UAAuC;AACtE,QAAO,SACJ,OAAO,CAAC,yDAA0B,QAAQ,CAAC,CAC3C,IAAI,CAAC,aAAa;EACjB,IAAK,QAAwB;EAC7B,QAAS,QAAwB;CAClC,GAAE;AACN"}
1
+ {"version":3,"file":"utils.cjs","names":["middlewareList: readonly AgentMiddleware<any, any, any>[]","state: unknown","middlewareStates: Record<string, any>","modifiedShape: Record<string, any>","z","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","messages: BaseMessage[]"],"sources":["../../../../src/agents/middlewareAgent/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type BaseMessage,\n type ToolMessage,\n type AIMessage,\n isToolMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { z, type ZodIssue, type ZodTypeAny } from \"zod/v3\";\n\nimport type { AgentMiddleware, ToolCall, ToolResult } from \"../types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware<any, any, any>[],\n state: unknown\n): Record<string, any> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const { shape } = middleware.stateSchema;\n const modifiedShape: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make private properties optional\n modifiedShape[key] = (value as ZodTypeAny).optional();\n } else {\n // Keep public properties as-is\n modifiedShape[key] = value;\n }\n }\n\n const modifiedSchema = z.object(modifiedShape);\n\n // Use safeParse with the modified schema\n const parseResult = modifiedSchema.safeParse(state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = builtInStateSchema;\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse out all tool calls from the messages\n * @param messages - The messages to parse\n * @returns The tool calls\n */\nexport function parseToolCalls(messages: BaseMessage[]): ToolCall[] {\n return (\n messages\n .filter(\n (message) => isAIMessage(message) && (message as AIMessage).tool_calls\n )\n .map((message) => (message as AIMessage).tool_calls as ToolCall[])\n .flat() || []\n );\n}\n\n/**\n * Parse out all tool results from the messages\n * @param messages - The messages to parse\n * @returns The tool results\n */\nexport function parseToolResults(messages: BaseMessage[]): ToolResult[] {\n return messages\n .filter((message) => isToolMessage(message))\n .map((message) => ({\n id: (message as ToolMessage).tool_call_id,\n result: (message as ToolMessage).content,\n }));\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,2BACdA,gBACAC,OACqB;CACrB,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,eACvB,KAAI,WAAW,aAAa;EAE1B,MAAM,EAAE,OAAO,GAAG,WAAW;EAC7B,MAAMC,gBAAqC,CAAE;AAE7C,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,cAAc,OAAQ,MAAqB,UAAU;OAGrD,cAAc,OAAO;EAIzB,MAAM,iBAAiBC,SAAE,OAAO,cAAc;EAG9C,MAAM,cAAc,eAAe,UAAU,MAAM;AAEnD,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;;EAKD,MAAM,iBAAiB,YAAY,MAAM,OACtC,OACC,CAACC,UACC,MAAM,SAAS,kBAAkB,MAAM,YAAY,WACtD,CACA,IACC,CAACA,UAAoB,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,EAAE,EAAE,MAAM,SAAS,CACrE,CACA,KAAK,KAAK;AAEb,QAAM,IAAI,MACR,CAAC,YAAY,EAAE,WAAW,KAAK,uDAAuD,EACjF,eAAe,0aAAI,EAad,YAAY,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,gBAAW,CACxD;CAEZ;AAGH,QAAO;AACR;;;;;;;AAQD,SAAgB,mBACdC,aAC4B;CAC5B,MAAM,qBAAqB,EACzB,UAAUF,SAAE,OAAsB,MAAM,CAAE,EAAC,CAC5C;AAED,KAAI,CAAC,YACH,QAAOA,SAAE,OAAO,mBAAmB;CAGrC,MAAM,EAAE,OAAO,GAAG;CAClB,MAAMG,eAAoC;AAG1C,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,aAAa,OAAO,MAAM,UAAU;MAEpC,aAAa,OAAO;AAKxB,QAAOH,SAAE,OAAO,aAAa;AAC9B;;;;;;AAOD,SAAgB,eAAeI,UAAqC;AAClE,QACE,SACG,OACC,CAAC,uDAAwB,QAAQ,IAAK,QAAsB,WAC7D,CACA,IAAI,CAAC,YAAa,QAAsB,WAAyB,CACjE,MAAM,IAAI,CAAE;AAElB;;;;;;AAOD,SAAgB,iBAAiBA,UAAuC;AACtE,QAAO,SACJ,OAAO,CAAC,yDAA0B,QAAQ,CAAC,CAC3C,IAAI,CAAC,aAAa;EACjB,IAAK,QAAwB;EAC7B,QAAS,QAAwB;CAClC,GAAE;AACN"}
@@ -1,5 +1,5 @@
1
1
  import { isAIMessage, isToolMessage } from "@langchain/core/messages";
2
- import { z } from "zod";
2
+ import { z } from "zod/v3";
3
3
 
4
4
  //#region src/agents/middlewareAgent/nodes/utils.ts
5
5
  /**
@@ -9,9 +9,9 @@ import { z } from "zod";
9
9
  * Private properties (starting with _) are automatically made optional since
10
10
  * users cannot provide them when invoking the agent.
11
11
  */
12
- function initializeMiddlewareStates(middlewares, state) {
12
+ function initializeMiddlewareStates(middlewareList, state) {
13
13
  const middlewareStates = {};
14
- for (const middleware of middlewares) if (middleware.stateSchema) {
14
+ for (const middleware of middlewareList) if (middleware.stateSchema) {
15
15
  const { shape } = middleware.stateSchema;
16
16
  const modifiedShape = {};
17
17
  for (const [key, value] of Object.entries(shape)) if (key.startsWith("_")) modifiedShape[key] = value.optional();
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["middlewares: readonly AgentMiddleware<any, any, any>[]","state: unknown","middlewareStates: Record<string, any>","modifiedShape: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","messages: BaseMessage[]"],"sources":["../../../../src/agents/middlewareAgent/nodes/utils.ts"],"sourcesContent":["import {\n type BaseMessage,\n type ToolMessage,\n type AIMessage,\n isToolMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { z, type ZodIssue, type ZodTypeAny } from \"zod\";\n\nimport type { AgentMiddleware, ToolCall, ToolResult } from \"../types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport function initializeMiddlewareStates(\n middlewares: readonly AgentMiddleware<any, any, any>[],\n state: unknown\n): Record<string, any> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewares) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const { shape } = middleware.stateSchema;\n const modifiedShape: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make private properties optional\n modifiedShape[key] = (value as ZodTypeAny).optional();\n } else {\n // Keep public properties as-is\n modifiedShape[key] = value;\n }\n }\n\n const modifiedSchema = z.object(modifiedShape);\n\n // Use safeParse with the modified schema\n const parseResult = modifiedSchema.safeParse(state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(stateSchema?: z.ZodObject<z.ZodRawShape>) {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = builtInStateSchema;\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse out all tool calls from the messages\n * @param messages - The messages to parse\n * @returns The tool calls\n */\nexport function parseToolCalls(messages: BaseMessage[]): ToolCall[] {\n return (\n messages\n .filter(\n (message) => isAIMessage(message) && (message as AIMessage).tool_calls\n )\n .map((message) => (message as AIMessage).tool_calls as ToolCall[])\n .flat() || []\n );\n}\n\n/**\n * Parse out all tool results from the messages\n * @param messages - The messages to parse\n * @returns The tool results\n */\nexport function parseToolResults(messages: BaseMessage[]): ToolResult[] {\n return messages\n .filter((message) => isToolMessage(message))\n .map((message) => ({\n id: (message as ToolMessage).tool_call_id,\n result: (message as ToolM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AEpC,aAAa,OAAO;AAKxB,QAAO,EAAE,OAAO,aAAa;AAC9B;;;;;;AAOD,SAAgB,eAAeC,UAAqC;AAClE,QACE,SACG,OACC,CAAC,YAAY,YAAY,QAAQ,IAAK,QAAsB,WAC7D,CACA,IAAI,CAAC,YAAa,QAAsB,WAAyB,CACjE,MAAM,IAAI,CAAE;AAElB;;;;;;AAOD,SAAgB,iBAAiBA,UAAuC;AACtE,QAAO,SACJ,OAAO,CAAC,YAAY,cAAc,QAAQ,CAAC,CAC3C,IAAI,CAAC,aAAa;EACjB,IAAK,QAAwB;EAC7B,QAAS,QAAwB;CAClC,GAAE;AACN"}
1
+ {"version":3,"file":"utils.js","names":["middlewareList: readonly AgentMiddleware<any, any, any>[]","state: unknown","middlewareStates: Record<string, any>","modifiedShape: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","messages: BaseMessage[]"],"sources":["../../../../src/agents/middlewareAgent/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type BaseMessage,\n type ToolMessage,\n type AIMessage,\n isToolMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { z, type ZodIssue, type ZodTypeAny } from \"zod/v3\";\n\nimport type { AgentMiddleware, ToolCall, ToolResult } from \"../types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware<any, any, any>[],\n state: unknown\n): Record<string, any> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const { shape } = middleware.stateSchema;\n const modifiedShape: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make private properties optional\n modifiedShape[key] = (value as ZodTypeAny).optional();\n } else {\n // Keep public properties as-is\n modifiedShape[key] = value;\n }\n }\n\n const modifiedSchema = z.object(modifiedShape);\n\n // Use safeParse with the modified schema\n const parseResult = modifiedSchema.safeParse(state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = builtInStateSchema;\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse out all tool calls from the messages\n * @param messages - The messages to parse\n * @returns The tool calls\n */\nexport function parseToolCalls(messages: BaseMessage[]): ToolCall[] {\n return (\n messages\n .filter(\n (message) => isAIMessage(message) && (message as AIMessage).tool_calls\n )\n .map((message) => (message as AIMessage).tool_calls as ToolCall[])\n .flat() || []\n );\n}\n\n/**\n * Parse out all tool results from the messages\n * @param messages - The messages to parse\n * @returns The tool results\n */\nexport function parseToolResults(messages: BaseMessage[]): ToolResult[] {\n return messages\n .filter((message) => isToolMessage(message))\n .map((message) => ({\n id: (message as ToolMessage).tool_call_id,\n result: (message as ToolMessage).content,\n }));\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAgB,2BACdA,gBACAC,OACqB;CACrB,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,eACvB,KAAI,WAAW,aAAa;EAE1B,MAAM,EAAE,OAAO,GAAG,WAAW;EAC7B,MAAMC,gBAAqC,CAAE;AAE7C,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,cAAc,OAAQ,MAAqB,UAAU;OAGrD,cAAc,OAAO;EAIzB,MAAM,iBAAiB,EAAE,OAAO,cAAc;EAG9C,MAAM,cAAc,eAAe,UAAU,MAAM;AAEnD,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;;EAKD,MAAM,iBAAiB,YAAY,MAAM,OACtC,OACC,CAACC,UACC,MAAM,SAAS,kBAAkB,MAAM,YAAY,WACtD,CACA,IACC,CAACA,UAAoB,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,EAAE,EAAE,MAAM,SAAS,CACrE,CACA,KAAK,KAAK;AAEb,QAAM,IAAI,MACR,CAAC,YAAY,EAAE,WAAW,KAAK,uDAAuD,EACjF,eAAe,0aAAI,EAad,YAAY,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,gBAAW,CACxD;CAEZ;AAGH,QAAO;AACR;;;;;;;AAQD,SAAgB,mBACdC,aAC4B;CAC5B,MAAM,qBAAqB,EACzB,UAAU,EAAE,OAAsB,MAAM,CAAE,EAAC,CAC5C;AAED,KAAI,CAAC,YACH,QAAO,EAAE,OAAO,mBAAmB;CAGrC,MAAM,EAAE,OAAO,GAAG;CAClB,MAAMC,eAAoC;AAG1C,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,aAAa,OAAO,MAAM,UAAU;MAEpC,aAAa,OAAO;AAKxB,QAAO,EAAE,OAAO,aAAa;AAC9B;;;;;;AAOD,SAAgB,eAAeC,UAAqC;AAClE,QACE,SACG,OACC,CAAC,YAAY,YAAY,QAAQ,IAAK,QAAsB,WAC7D,CACA,IAAI,CAAC,YAAa,QAAsB,WAAyB,CACjE,MAAM,IAAI,CAAE;AAElB;;;;;;AAOD,SAAgB,iBAAiBA,UAAuC;AACtE,QAAO,SACJ,OAAO,CAAC,YAAY,cAAc,QAAQ,CAAC,CAC3C,IAAI,CAAC,aAAa;EACjB,IAAK,QAAwB;EAC7B,QAAS,QAAwB;CAClC,GAAE;AACN"}
@@ -3,7 +3,7 @@ import { AnyAnnotationRoot, PreHookAnnotation, ToAnnotationRoot } from "../annot
3
3
  import { ToolNode } from "../nodes/ToolNode.cjs";
4
4
  import { AgentRuntime, ClientTool, ServerTool } from "../types.cjs";
5
5
  import { LanguageModelLike } from "@langchain/core/language_models/base";
6
- import { z } from "zod";
6
+ import { z } from "zod/v3";
7
7
  import { InferInteropZodInput, InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
8
8
  import { LangGraphRunnableConfig, START } from "@langchain/langgraph";
9
9
  import { BaseMessage, BaseMessageLike, SystemMessage } from "@langchain/core/messages";
@@ -49,12 +49,6 @@ interface ToolResult {
49
49
  */
50
50
  error?: string;
51
51
  }
52
- interface AnthropicModelSettings {
53
- cache_control: {
54
- type: string;
55
- ttl: string;
56
- };
57
- }
58
52
  /**
59
53
  * Configuration for modifying a model call at runtime.
60
54
  * All fields are optional and only provided fields will override defaults.
@@ -91,11 +85,6 @@ interface ModelRequest {
91
85
  * Can be tool names (strings) or tool instances.
92
86
  */
93
87
  tools: (ClientTool | ServerTool)[];
94
- /**
95
- * The model settings to use for this step.
96
- * Currently only supported for Anthropic models.
97
- */
98
- modelSettings?: AnthropicModelSettings | Record<string, any>;
99
88
  }
100
89
  /**
101
90
  * Runtime information available to middleware (readonly).
@@ -152,15 +141,15 @@ type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends
152
141
  */
153
142
  type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.input<S>> : {} : {};
154
143
  /**
155
- * Helper type to infer merged state from an array of middlewares (just the middleware states)
144
+ * Helper type to infer merged state from an array of middleware (just the middleware states)
156
145
  */
157
146
  type InferMiddlewareStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareState<First> & InferMiddlewareStates<Rest> : InferMiddlewareState<First> : {} : {};
158
147
  /**
159
- * Helper type to infer merged input state from an array of middlewares (with optional defaults)
148
+ * Helper type to infer merged input state from an array of middleware (with optional defaults)
160
149
  */
161
150
  type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareInputState<First> & InferMiddlewareInputStates<Rest> : InferMiddlewareInputState<First> : {} : {};
162
151
  /**
163
- * Helper type to infer merged state from an array of middlewares (includes built-in state)
152
+ * Helper type to infer merged state from an array of middleware (includes built-in state)
164
153
  */
165
154
 
166
155
  /**
@@ -168,11 +157,11 @@ type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any
168
157
  */
169
158
  type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.input<C> : {} : {};
170
159
  /**
171
- * Helper type to infer merged context from an array of middlewares
160
+ * Helper type to infer merged context from an array of middleware
172
161
  */
173
162
 
174
163
  /**
175
- * Helper type to infer merged input context from an array of middlewares (with optional defaults)
164
+ * Helper type to infer merged input context from an array of middleware (with optional defaults)
176
165
  */
177
166
  type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContextInput<First> & InferMiddlewareContextInputs<Rest> : InferMiddlewareContextInput<First> : {} : {};
178
167
  /**
@@ -204,9 +193,7 @@ interface AgentMiddleware<TSchema extends z.ZodObject<z.ZodRawShape> | undefined
204
193
  */
205
194
  type Prompt<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = SystemMessage | string | ((state: AgentBuiltInState, config: LangGraphRunnableConfig<ToAnnotationRoot<ContextSchema>["State"]>) => BaseMessageLike[] | Promise<BaseMessageLike[]>) | Runnable;
206
195
  type DynamicLLMFunction<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = (state: AgentBuiltInState & PreHookAnnotation["State"], runtime: AgentRuntime<ToAnnotationRoot<ContextSchema>["State"]>) => Promise<LanguageModelLike> | LanguageModelLike;
207
- type CreateAgentParams<
208
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
209
- StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {
196
+ type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {
210
197
  /** The chat model that can utilize OpenAI-style tool calling. */
211
198
  llm?: LanguageModelLike | DynamicLLMFunction<ContextSchema>;
212
199
  /**
@@ -244,7 +231,7 @@ StructuredResponseType extends Record<string, any> = Record<string, any>, Contex
244
231
  prompt?: Prompt<ContextSchema>;
245
232
  /**
246
233
  * An optional schema for the context. It allows to pass in a typed context object into the agent
247
- * invocation and allows to access it in hooks such as `prompt` and middlewares.
234
+ * invocation and allows to access it in hooks such as `prompt` and middleware.
248
235
  * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between
249
236
  * agent invocations.
250
237
  *
@@ -340,10 +327,10 @@ StructuredResponseType extends Record<string, any> = Record<string, any>, Contex
340
327
  */
341
328
  responseFormat?: ResponseFormatType;
342
329
  /**
343
- * Middlewares to run during agent execution.
330
+ * Middleware instances to run during agent execution.
344
331
  * Each middleware can define its own state schema and hook into the agent lifecycle.
345
332
  */
346
- middlewares?: readonly AgentMiddleware<any, any, any>[];
333
+ middleware?: readonly AgentMiddleware<any, any, any>[];
347
334
  /**
348
335
  * An optional name for the agent.
349
336
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":["z","InteropZodObject","InteropZodType","InferInteropZodInput","LangGraphRunnableConfig","START","LanguageModelLike","SystemMessage","BaseMessageLike","BaseMessage","All","BaseCheckpointSaver","BaseStore","Runnable","PreHookAnnotation","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormatUndefined","JsonSchemaFormat","ToolNode","ClientTool","ServerTool","AgentRuntime","N","BuiltInState","ToolCall","Record","ToolResult","AnthropicModelSettings","ModelRequest","Runtime","TContext","Controls","TState","Partial","ControlAction","Error","TStateSchema","MiddlewareResult","AgentBuiltInState","FilterPrivateProps","T","K","InferMiddlewareState","AgentMiddleware","S","ZodObject","infer","InferMiddlewareInputState","input","InferMiddlewareStates","First","Rest","InferMiddlewareInputStates","InferMergedState","InferMergedInputState","InferMiddlewareContext","C","InferMiddlewareContextInput","InferMiddlewareContexts","InferMiddlewareContextInputs","ZodRawShape","TSchema","TContextSchema","TFullContext","Promise","ExecutedToolCall","LLMCall","Prompt","ContextSchema","DynamicLLMFunction","CreateAgentParams","StructuredResponseType","ResponseFormatType","AbortSignal","IsAllOptional","InferContextInput","InferAgentConfig","TMiddlewares","InternalAgentState"],"sources":["../../../src/agents/middlewareAgent/types.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport { z } from \"zod\";\nimport type { InteropZodObject, InteropZodType, InferInteropZodInput } from \"@langchain/core/utils/types\";\nimport type { LangGraphRunnableConfig, START } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { SystemMessage, BaseMessageLike, BaseMessage } from \"@langchain/core/messages\";\nimport type { All, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport type { Runnable } from \"@langchain/core/runnables\";\nimport type { PreHookAnnotation, AnyAnnotationRoot, ToAnnotationRoot } from \"../annotation.js\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormatUndefined, JsonSchemaFormat } from \"../responses.js\";\nimport type { ToolNode } from \"../nodes/ToolNode.js\";\nimport type { ClientTool, ServerTool, AgentRuntime } from \"../types.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\nexport interface BuiltInState {\n messages: BaseMessage[];\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\nexport interface AnthropicModelSettings {\n cache_control: {\n type: string;\n ttl: string;\n };\n}\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n */\nexport interface ModelRequest {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n systemMessage?: BaseMessage;\n /**\n * Tool choice configuration (model-specific format).\n * Can be one of:\n * - `\"auto\"`: means the model can pick between generating a message or calling one or more tools.\n * - `\"none\"`: means the model will not call any tool and instead generates a message.\n * - `\"required\"`: means the model must call one or more tools.\n * - `{ type: \"function\", function: { name: string } }`: The model will use the specified function.\n */\n toolChoice?: \"auto\" | \"none\" | \"required\" | {\n type: \"function\";\n function: {\n name: string;\n };\n };\n /**\n * The tools to make available for this step.\n * Can be tool names (strings) or tool instances.\n */\n tools: (ClientTool | ServerTool)[];\n /**\n * The model settings to use for this step.\n * Currently only supported for Anthropic models.\n */\n modelSettings?: AnthropicModelSettings | Record<string, any>;\n}\n/**\n * Runtime information available to middleware (readonly).\n */\nexport interface Runtime<TContext = unknown> {\n readonly toolCalls: ToolCall[];\n readonly toolResults: ToolResult[];\n // readonly tokenUsage: {\n // readonly inputTokens: number;\n // readonly outputTokens: number;\n // readonly totalTokens: number;\n // };\n readonly context: TContext;\n}\n/**\n * Control flow interface for middleware.\n */\nexport interface Controls<TState = unknown> {\n jumpTo(target: \"model\" | \"tools\", stateUpdate?: Partial<TState>): ControlAction<TState>;\n terminate(result?: Partial<TState> | Error): ControlAction<TState>;\n}\n/**\n * Control action type returned by control methods.\n */\nexport type ControlAction<TStateSchema> = {\n type: \"jump\" | \"terminate\" | \"retry\";\n target?: string;\n stateUpdate?: Partial<TStateSchema>;\n result?: any;\n error?: Error;\n};\n/**\n * Result type for middleware functions.\n */\nexport type MiddlewareResult<TState> = TState | void;\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n messages: BaseMessage[];\n};\n/**\n * Helper type to filter out properties that start with underscore (private properties)\n */\ntype FilterPrivateProps<T> = {\n [K in keyof T as K extends `_${string}` ? never : K]: T[K];\n};\n/**\n * Helper type to infer the state schema type from a middleware\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.infer<S>> : {} : {};\n/**\n * Helper type to infer the input state schema type from a middleware (all properties optional)\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.input<S>> : {} : {};\n/**\n * Helper type to infer merged state from an array of middlewares (just the middleware states)\n */\nexport type InferMiddlewareStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareState<First> & InferMiddlewareStates<Rest> : InferMiddlewareState<First> : {} : {};\n/**\n * Helper type to infer merged input state from an array of middlewares (with optional defaults)\n */\nexport type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareInputState<First> & InferMiddlewareInputStates<Rest> : InferMiddlewareInputState<First> : {} : {};\n/**\n * Helper type to infer merged state from an array of middlewares (includes built-in state)\n */\nexport type InferMergedState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer merged input state from an array of middlewares (includes built-in state)\n */\nexport type InferMergedInputState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareInputStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer the context schema type from a middleware\n */\nexport type InferMiddlewareContext<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.infer<C> : {} : {};\n/**\n * Helper type to infer the input context schema type from a middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.input<C> : {} : {};\n/**\n * Helper type to infer merged context from an array of middlewares\n */\nexport type InferMiddlewareContexts<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContext<First> & InferMiddlewareContexts<Rest> : InferMiddlewareContext<First> : {} : {};\n/**\n * Helper type to infer merged input context from an array of middlewares (with optional defaults)\n */\nexport type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContextInput<First> & InferMiddlewareContextInputs<Rest> : InferMiddlewareContextInput<First> : {} : {};\n/**\n * Base middleware interface.\n */\nexport interface AgentMiddleware<TSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TContextSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TFullContext = any> {\n stateSchema?: TSchema;\n contextSchema?: TContextSchema;\n name: string;\n /**\n * Runs before each LLM call, can modify call parameters, changes are not persistent\n * e.g. if you change `model`, it will only be changed for the next model call\n *\n * @param options - Current call options (can be modified by previous middleware)\n * @param state - Current state (read-only in this phase)\n * @param runtime - Runtime context and metadata\n * @returns Modified options or undefined to pass through\n */\n prepareModelRequest?(request: ModelRequest, state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>): Promise<Partial<ModelRequest> | void> | Partial<ModelRequest> | void;\n beforeModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;\n afterModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\n/**\n * Information about an LLM invocation.\n */\nexport interface LLMCall {\n /**\n * The messages that were sent to the LLM.\n */\n messages: BaseMessage[];\n /**\n * The response from the LLM.\n */\n response?: BaseMessage;\n}\n/**\n * Duplicate of the Prompt type from ../types.ts\n */\nexport type Prompt<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = SystemMessage | string | ((state: AgentBuiltInState, config: LangGraphRunnableConfig<ToAnnotationRoot<ContextSchema>[\"State\"]>) => BaseMessageLike[] | Promise<BaseMessageLike[]>) | Runnable;\nexport type DynamicLLMFunction<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = (state: AgentBuiltInState & PreHookAnnotation[\"State\"], runtime: AgentRuntime<ToAnnotationRoot<ContextSchema>[\"State\"]>) => Promise<LanguageModelLike> | LanguageModelLike;\nexport type CreateAgentParams<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm?: LanguageModelLike | DynamicLLMFunction<ContextSchema>;\n /**\n * Initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n */\n model?: string;\n /** A list of tools or a ToolNode. */\n tools?: ToolNode | (ServerTool | ClientTool)[];\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n *\n * Cannot be used together with `prepareModelRequest`.\n */\n prompt?: Prompt<ContextSchema>;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middlewares.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middlewares to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n */\n middlewares?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = T extends Record<string, any> ? {} extends T ? true : false : true;\n/**\n * Helper type to extract input type from context schema (with optional defaults)\n */\nexport type InferContextInput<ContextSchema extends AnyAnnotationRoot | InteropZodObject> = ContextSchema extends InteropZodObject ? InferInteropZodInput<ContextSchema> : ContextSchema extends AnyAnnotationRoot ? ToAnnotationRoot<ContextSchema>[\"State\"] : {};\n/**\n * Helper type to get the required config type based on context schema\n */\nexport type InferAgentConfig<ContextSchema extends AnyAnnotationRoot | InteropZodObject, TMiddlewares extends readonly AgentMiddleware<any, any, any>[]> = IsAllOptional<InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddlewares>> extends true ? LangGraphRunnableConfig<{\n context?: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddlewares>;\n}> | undefined : LangGraphRunnableConfig<{\n context: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddlewares>;\n}>;\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n __preparedModelOptions?: ModelRequest;\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\nexport {};\n"],"mappings":";;;;;;;;;;;;;KAYY2B,CAAAA,UAAWtB;AAAXsB,UACKC,YAAAA,CADW;EACXA,QAAAA,EACHnB,WADe,EAAA;AAM7B;AAiBA;AAcA;AAUA;AAA6B,UAzCZoB,QAAAA,CAyCY;EAAA;;;EAYE,EAAA,EAmBnBL,MAAAA;EAAU;;;EAK6B,IAAA,EAAA,MAAA;EAKlCU;;;EACe,IACNH,EAxEhBD,MAwEgBC,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;;AAMI;AAK9B;;AAC4DM,UA/E3CN,UAAAA,CA+E2CM;EAAM;;;EAAiB,EAAA,EACpDA,MAAAA;EAAM;;;EAAgC,MAApBE,EAAAA,GAAAA;EAAa;AAK9D;;EAAyB,KAGCE,CAAAA,EAAAA,MAAAA;;AAEdD,UA5EKR,sBAAAA,CA4ELQ;EAAK,aAAA,EAAA;IAKLE,IAAAA,EAAAA,MAAAA;IAIAC,GAAAA,EAAAA,MAAAA;EAMPC,CAAAA;;;;;;AACuDE,UAlF3Cb,YAAAA,CAkF2Ca;EAAC;AAM7D;;EAAgC,KAAWE,EApFhC1C,iBAoFgC0C;EAAe;;;EAAmE,QAAWE,EAh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A;EAAiB;EAA8D,GAAnCD,CAAAA,EAE/UZ,iBAF+UY,GAE3TwD,kBAF2TxD,CAExSuD,aAFwSvD,CAAAA;EAAY;;;;;;;;;;;;;EAuE5T,KAEtBP,CAAAA,EAAAA,MAAAA;EAAmB;EAEf,KAAKD,CAAAA,EAzDhBa,QAyDgBb,GAAAA,CAzDJe,UAyDIf,GAzDSc,UAyDTd,CAAAA,EAAAA;EAAG;;;;;;AAkFP;AAiBxB;;;;;AAA2E;AAI3E;;;EAAqE,MAAGT,CAAAA,EA/I3DuE,MA+I2DvE,CA/IpDwE,aA+IoDxE,CAAAA;EAAgB;;;;;;;;AAA6I;;;;;;;;;;;;;;;;;;;;;;;;;kBA7GjNwE;;oBAEE9D;;iBAEHA;;oBAEGgB,MAAMjB;;mBAEPiB,MAAMjB;UACfE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAsDSiE;;;;;yBAKM7B;;;;;;;;;;;;;;;;;;;;WAoBd8B;;;;;;;;;;;;;;;;;KAiBDC,mBAAmBlC,UAAUf,iCAAiCe;;;;KAI9DmC,wCAAwCjE,oBAAoBd,oBAAoBwE,sBAAsBxE,mBAAmBE,qBAAqBsE,iBAAiBA,sBAAsB1D,oBAAoBC,iBAAiByD"}
1
+ {"version":3,"file":"types.d.cts","names":["z","InteropZodObject","InteropZodType","InferInteropZodInput","LangGraphRunnableConfig","START","LanguageModelLike","SystemMessage","BaseMessageLike","BaseMessage","All","BaseCheckpointSaver","BaseStore","Runnable","PreHookAnnotation","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormatUndefined","JsonSchemaFormat","ToolNode","ClientTool","ServerTool","AgentRuntime","N","BuiltInState","ToolCall","Record","ToolResult","ModelRequest","Runtime","TContext","Controls","TState","Partial","ControlAction","Error","TStateSchema","MiddlewareResult","AgentBuiltInState","FilterPrivateProps","T","K","InferMiddlewareState","AgentMiddleware","S","ZodObject","infer","InferMiddlewareInputState","input","InferMiddlewareStates","First","Rest","InferMiddlewareInputStates","InferMergedState","InferMergedInputState","InferMiddlewareContext","C","InferMiddlewareContextInput","InferMiddlewareContexts","InferMiddlewareContextInputs","ZodRawShape","TSchema","TContextSchema","TFullContext","Promise","ExecutedToolCall","LLMCall","Prompt","ContextSchema","DynamicLLMFunction","CreateAgentParams","StructuredResponseType","ResponseFormatType","AbortSignal","IsAllOptional","InferContextInput","InferAgentConfig","TMiddleware","InternalAgentState"],"sources":["../../../src/agents/middlewareAgent/types.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport type { InteropZodObject, InteropZodType, InferInteropZodInput } from \"@langchain/core/utils/types\";\nimport type { LangGraphRunnableConfig, START } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { SystemMessage, BaseMessageLike, BaseMessage } from \"@langchain/core/messages\";\nimport type { All, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport type { Runnable } from \"@langchain/core/runnables\";\nimport type { PreHookAnnotation, AnyAnnotationRoot, ToAnnotationRoot } from \"../annotation.js\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormatUndefined, JsonSchemaFormat } from \"../responses.js\";\nimport type { ToolNode } from \"../nodes/ToolNode.js\";\nimport type { ClientTool, ServerTool, AgentRuntime } from \"../types.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\nexport interface BuiltInState {\n messages: BaseMessage[];\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n */\nexport interface ModelRequest {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n systemMessage?: BaseMessage;\n /**\n * Tool choice configuration (model-specific format).\n * Can be one of:\n * - `\"auto\"`: means the model can pick between generating a message or calling one or more tools.\n * - `\"none\"`: means the model will not call any tool and instead generates a message.\n * - `\"required\"`: means the model must call one or more tools.\n * - `{ type: \"function\", function: { name: string } }`: The model will use the specified function.\n */\n toolChoice?: \"auto\" | \"none\" | \"required\" | {\n type: \"function\";\n function: {\n name: string;\n };\n };\n /**\n * The tools to make available for this step.\n * Can be tool names (strings) or tool instances.\n */\n tools: (ClientTool | ServerTool)[];\n}\n/**\n * Runtime information available to middleware (readonly).\n */\nexport interface Runtime<TContext = unknown> {\n readonly toolCalls: ToolCall[];\n readonly toolResults: ToolResult[];\n // readonly tokenUsage: {\n // readonly inputTokens: number;\n // readonly outputTokens: number;\n // readonly totalTokens: number;\n // };\n readonly context: TContext;\n}\n/**\n * Control flow interface for middleware.\n */\nexport interface Controls<TState = unknown> {\n jumpTo(target: \"model\" | \"tools\", stateUpdate?: Partial<TState>): ControlAction<TState>;\n terminate(result?: Partial<TState> | Error): ControlAction<TState>;\n}\n/**\n * Control action type returned by control methods.\n */\nexport type ControlAction<TStateSchema> = {\n type: \"jump\" | \"terminate\" | \"retry\";\n target?: string;\n stateUpdate?: Partial<TStateSchema>;\n result?: any;\n error?: Error;\n};\n/**\n * Result type for middleware functions.\n */\nexport type MiddlewareResult<TState> = TState | void;\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n messages: BaseMessage[];\n};\n/**\n * Helper type to filter out properties that start with underscore (private properties)\n */\ntype FilterPrivateProps<T> = {\n [K in keyof T as K extends `_${string}` ? never : K]: T[K];\n};\n/**\n * Helper type to infer the state schema type from a middleware\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.infer<S>> : {} : {};\n/**\n * Helper type to infer the input state schema type from a middleware (all properties optional)\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.input<S>> : {} : {};\n/**\n * Helper type to infer merged state from an array of middleware (just the middleware states)\n */\nexport type InferMiddlewareStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareState<First> & InferMiddlewareStates<Rest> : InferMiddlewareState<First> : {} : {};\n/**\n * Helper type to infer merged input state from an array of middleware (with optional defaults)\n */\nexport type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareInputState<First> & InferMiddlewareInputStates<Rest> : InferMiddlewareInputState<First> : {} : {};\n/**\n * Helper type to infer merged state from an array of middleware (includes built-in state)\n */\nexport type InferMergedState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer merged input state from an array of middleware (includes built-in state)\n */\nexport type InferMergedInputState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareInputStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer the context schema type from a middleware\n */\nexport type InferMiddlewareContext<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.infer<C> : {} : {};\n/**\n * Helper type to infer the input context schema type from a middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.input<C> : {} : {};\n/**\n * Helper type to infer merged context from an array of middleware\n */\nexport type InferMiddlewareContexts<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContext<First> & InferMiddlewareContexts<Rest> : InferMiddlewareContext<First> : {} : {};\n/**\n * Helper type to infer merged input context from an array of middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContextInput<First> & InferMiddlewareContextInputs<Rest> : InferMiddlewareContextInput<First> : {} : {};\n/**\n * Base middleware interface.\n */\nexport interface AgentMiddleware<TSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TContextSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TFullContext = any> {\n stateSchema?: TSchema;\n contextSchema?: TContextSchema;\n name: string;\n /**\n * Runs before each LLM call, can modify call parameters, changes are not persistent\n * e.g. if you change `model`, it will only be changed for the next model call\n *\n * @param options - Current call options (can be modified by previous middleware)\n * @param state - Current state (read-only in this phase)\n * @param runtime - Runtime context and metadata\n * @returns Modified options or undefined to pass through\n */\n prepareModelRequest?(request: ModelRequest, state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>): Promise<Partial<ModelRequest> | void> | Partial<ModelRequest> | void;\n beforeModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;\n afterModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\n/**\n * Information about an LLM invocation.\n */\nexport interface LLMCall {\n /**\n * The messages that were sent to the LLM.\n */\n messages: BaseMessage[];\n /**\n * The response from the LLM.\n */\n response?: BaseMessage;\n}\n/**\n * Duplicate of the Prompt type from ../types.ts\n */\nexport type Prompt<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = SystemMessage | string | ((state: AgentBuiltInState, config: LangGraphRunnableConfig<ToAnnotationRoot<ContextSchema>[\"State\"]>) => BaseMessageLike[] | Promise<BaseMessageLike[]>) | Runnable;\nexport type DynamicLLMFunction<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = (state: AgentBuiltInState & PreHookAnnotation[\"State\"], runtime: AgentRuntime<ToAnnotationRoot<ContextSchema>[\"State\"]>) => Promise<LanguageModelLike> | LanguageModelLike;\nexport type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm?: LanguageModelLike | DynamicLLMFunction<ContextSchema>;\n /**\n * Initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n */\n model?: string;\n /** A list of tools or a ToolNode. */\n tools?: ToolNode | (ServerTool | ClientTool)[];\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n *\n * Cannot be used together with `prepareModelRequest`.\n */\n prompt?: Prompt<ContextSchema>;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middleware.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middleware instances to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n */\n middleware?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = T extends Record<string, any> ? {} extends T ? true : false : true;\n/**\n * Helper type to extract input type from context schema (with optional defaults)\n */\nexport type InferContextInput<ContextSchema extends AnyAnnotationRoot | InteropZodObject> = ContextSchema extends InteropZodObject ? InferInteropZodInput<ContextSchema> : ContextSchema extends AnyAnnotationRoot ? ToAnnotationRoot<ContextSchema>[\"State\"] : {};\n/**\n * Helper type to get the required config type based on context schema\n */\nexport type InferAgentConfig<ContextSchema extends AnyAnnotationRoot | InteropZodObject, TMiddleware extends readonly AgentMiddleware<any, any, any>[]> = IsAllOptional<InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>> extends true ? LangGraphRunnableConfig<{\n context?: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>;\n}> | undefined : LangGraphRunnableConfig<{\n context: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>;\n}>;\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n __preparedModelOptions?: ModelRequest;\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\nexport {};\n"],"mappings":";;;;;;;;;;;;;KAYY2B,CAAAA,UAAWtB;AA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,oBAAoBd,oBAAoBuE,sBAAsBvE,mBAAmBE,qBAAqBqE,iBAAiBA,sBAAsBzD,oBAAoBC,iBAAiBwD"}
@@ -6,7 +6,7 @@ import { BaseMessage, BaseMessageLike, SystemMessage } from "@langchain/core/mes
6
6
  import { Runnable } from "@langchain/core/runnables";
7
7
  import { LangGraphRunnableConfig, START } from "@langchain/langgraph";
8
8
  import { InferInteropZodInput, InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
9
- import { z } from "zod";
9
+ import { z } from "zod/v3";
10
10
  import { LanguageModelLike } from "@langchain/core/language_models/base";
11
11
  import { All, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
12
12
 
@@ -49,12 +49,6 @@ interface ToolResult {
49
49
  */
50
50
  error?: string;
51
51
  }
52
- interface AnthropicModelSettings {
53
- cache_control: {
54
- type: string;
55
- ttl: string;
56
- };
57
- }
58
52
  /**
59
53
  * Configuration for modifying a model call at runtime.
60
54
  * All fields are optional and only provided fields will override defaults.
@@ -91,11 +85,6 @@ interface ModelRequest {
91
85
  * Can be tool names (strings) or tool instances.
92
86
  */
93
87
  tools: (ClientTool | ServerTool)[];
94
- /**
95
- * The model settings to use for this step.
96
- * Currently only supported for Anthropic models.
97
- */
98
- modelSettings?: AnthropicModelSettings | Record<string, any>;
99
88
  }
100
89
  /**
101
90
  * Runtime information available to middleware (readonly).
@@ -152,15 +141,15 @@ type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends
152
141
  */
153
142
  type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.input<S>> : {} : {};
154
143
  /**
155
- * Helper type to infer merged state from an array of middlewares (just the middleware states)
144
+ * Helper type to infer merged state from an array of middleware (just the middleware states)
156
145
  */
157
146
  type InferMiddlewareStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareState<First> & InferMiddlewareStates<Rest> : InferMiddlewareState<First> : {} : {};
158
147
  /**
159
- * Helper type to infer merged input state from an array of middlewares (with optional defaults)
148
+ * Helper type to infer merged input state from an array of middleware (with optional defaults)
160
149
  */
161
150
  type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareInputState<First> & InferMiddlewareInputStates<Rest> : InferMiddlewareInputState<First> : {} : {};
162
151
  /**
163
- * Helper type to infer merged state from an array of middlewares (includes built-in state)
152
+ * Helper type to infer merged state from an array of middleware (includes built-in state)
164
153
  */
165
154
 
166
155
  /**
@@ -168,11 +157,11 @@ type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any
168
157
  */
169
158
  type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.input<C> : {} : {};
170
159
  /**
171
- * Helper type to infer merged context from an array of middlewares
160
+ * Helper type to infer merged context from an array of middleware
172
161
  */
173
162
 
174
163
  /**
175
- * Helper type to infer merged input context from an array of middlewares (with optional defaults)
164
+ * Helper type to infer merged input context from an array of middleware (with optional defaults)
176
165
  */
177
166
  type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContextInput<First> & InferMiddlewareContextInputs<Rest> : InferMiddlewareContextInput<First> : {} : {};
178
167
  /**
@@ -204,9 +193,7 @@ interface AgentMiddleware<TSchema extends z.ZodObject<z.ZodRawShape> | undefined
204
193
  */
205
194
  type Prompt<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = SystemMessage | string | ((state: AgentBuiltInState, config: LangGraphRunnableConfig<ToAnnotationRoot<ContextSchema>["State"]>) => BaseMessageLike[] | Promise<BaseMessageLike[]>) | Runnable;
206
195
  type DynamicLLMFunction<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = (state: AgentBuiltInState & PreHookAnnotation["State"], runtime: AgentRuntime<ToAnnotationRoot<ContextSchema>["State"]>) => Promise<LanguageModelLike> | LanguageModelLike;
207
- type CreateAgentParams<
208
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
209
- StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {
196
+ type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {
210
197
  /** The chat model that can utilize OpenAI-style tool calling. */
211
198
  llm?: LanguageModelLike | DynamicLLMFunction<ContextSchema>;
212
199
  /**
@@ -244,7 +231,7 @@ StructuredResponseType extends Record<string, any> = Record<string, any>, Contex
244
231
  prompt?: Prompt<ContextSchema>;
245
232
  /**
246
233
  * An optional schema for the context. It allows to pass in a typed context object into the agent
247
- * invocation and allows to access it in hooks such as `prompt` and middlewares.
234
+ * invocation and allows to access it in hooks such as `prompt` and middleware.
248
235
  * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between
249
236
  * agent invocations.
250
237
  *
@@ -340,10 +327,10 @@ StructuredResponseType extends Record<string, any> = Record<string, any>, Contex
340
327
  */
341
328
  responseFormat?: ResponseFormatType;
342
329
  /**
343
- * Middlewares to run during agent execution.
330
+ * Middleware instances to run during agent execution.
344
331
  * Each middleware can define its own state schema and hook into the agent lifecycle.
345
332
  */
346
- middlewares?: readonly AgentMiddleware<any, any, any>[];
333
+ middleware?: readonly AgentMiddleware<any, any, any>[];
347
334
  /**
348
335
  * An optional name for the agent.
349
336
  */