langchain 1.2.24 → 1.2.25

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 (325) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +24 -13
  3. package/dist/_virtual/_rolldown/runtime.js +36 -0
  4. package/dist/agents/ReactAgent.cjs +52 -65
  5. package/dist/agents/ReactAgent.cjs.map +1 -1
  6. package/dist/agents/ReactAgent.d.cts.map +1 -1
  7. package/dist/agents/ReactAgent.d.ts.map +1 -1
  8. package/dist/agents/ReactAgent.js +11 -24
  9. package/dist/agents/ReactAgent.js.map +1 -1
  10. package/dist/agents/RunnableCallable.cjs +7 -7
  11. package/dist/agents/RunnableCallable.cjs.map +1 -1
  12. package/dist/agents/RunnableCallable.js.map +1 -1
  13. package/dist/agents/annotation.cjs +41 -37
  14. package/dist/agents/annotation.cjs.map +1 -1
  15. package/dist/agents/annotation.js +21 -17
  16. package/dist/agents/annotation.js.map +1 -1
  17. package/dist/agents/constants.d.cts.map +1 -1
  18. package/dist/agents/constants.d.ts.map +1 -1
  19. package/dist/agents/errors.cjs +3 -3
  20. package/dist/agents/errors.cjs.map +1 -1
  21. package/dist/agents/errors.d.cts.map +1 -1
  22. package/dist/agents/errors.d.ts.map +1 -1
  23. package/dist/agents/errors.js.map +1 -1
  24. package/dist/agents/index.cjs.map +1 -1
  25. package/dist/agents/index.d.cts +2 -2
  26. package/dist/agents/index.d.cts.map +1 -1
  27. package/dist/agents/index.d.ts +2 -2
  28. package/dist/agents/index.d.ts.map +1 -1
  29. package/dist/agents/index.js.map +1 -1
  30. package/dist/agents/middleware/constants.cjs +2 -2
  31. package/dist/agents/middleware/constants.cjs.map +1 -1
  32. package/dist/agents/middleware/constants.js.map +1 -1
  33. package/dist/agents/middleware/contextEditing.cjs +14 -27
  34. package/dist/agents/middleware/contextEditing.cjs.map +1 -1
  35. package/dist/agents/middleware/contextEditing.d.cts +2 -3
  36. package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
  37. package/dist/agents/middleware/contextEditing.d.ts +2 -3
  38. package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
  39. package/dist/agents/middleware/contextEditing.js +5 -18
  40. package/dist/agents/middleware/contextEditing.js.map +1 -1
  41. package/dist/agents/middleware/dynamicSystemPrompt.cjs +3 -4
  42. package/dist/agents/middleware/dynamicSystemPrompt.cjs.map +1 -1
  43. package/dist/agents/middleware/dynamicSystemPrompt.d.cts +2 -2
  44. package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
  45. package/dist/agents/middleware/dynamicSystemPrompt.d.ts +2 -2
  46. package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
  47. package/dist/agents/middleware/dynamicSystemPrompt.js +1 -2
  48. package/dist/agents/middleware/dynamicSystemPrompt.js.map +1 -1
  49. package/dist/agents/middleware/error.cjs +2 -2
  50. package/dist/agents/middleware/error.cjs.map +1 -1
  51. package/dist/agents/middleware/error.js.map +1 -1
  52. package/dist/agents/middleware/hitl.cjs +16 -26
  53. package/dist/agents/middleware/hitl.cjs.map +1 -1
  54. package/dist/agents/middleware/hitl.d.cts.map +1 -1
  55. package/dist/agents/middleware/hitl.d.ts.map +1 -1
  56. package/dist/agents/middleware/hitl.js +8 -18
  57. package/dist/agents/middleware/hitl.js.map +1 -1
  58. package/dist/agents/middleware/index.js +2 -0
  59. package/dist/agents/middleware/llmToolSelector.cjs +9 -10
  60. package/dist/agents/middleware/llmToolSelector.cjs.map +1 -1
  61. package/dist/agents/middleware/llmToolSelector.d.cts +4 -4
  62. package/dist/agents/middleware/llmToolSelector.d.cts.map +1 -1
  63. package/dist/agents/middleware/llmToolSelector.d.ts +4 -4
  64. package/dist/agents/middleware/llmToolSelector.d.ts.map +1 -1
  65. package/dist/agents/middleware/llmToolSelector.js +3 -4
  66. package/dist/agents/middleware/llmToolSelector.js.map +1 -1
  67. package/dist/agents/middleware/modelCallLimit.cjs +5 -5
  68. package/dist/agents/middleware/modelCallLimit.cjs.map +1 -1
  69. package/dist/agents/middleware/modelCallLimit.d.cts +2 -2
  70. package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -1
  71. package/dist/agents/middleware/modelCallLimit.d.ts +2 -2
  72. package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -1
  73. package/dist/agents/middleware/modelCallLimit.js.map +1 -1
  74. package/dist/agents/middleware/modelFallback.cjs.map +1 -1
  75. package/dist/agents/middleware/modelFallback.d.cts +0 -1
  76. package/dist/agents/middleware/modelFallback.d.cts.map +1 -1
  77. package/dist/agents/middleware/modelFallback.d.ts +0 -1
  78. package/dist/agents/middleware/modelFallback.d.ts.map +1 -1
  79. package/dist/agents/middleware/modelFallback.js.map +1 -1
  80. package/dist/agents/middleware/modelRetry.cjs +19 -17
  81. package/dist/agents/middleware/modelRetry.cjs.map +1 -1
  82. package/dist/agents/middleware/modelRetry.d.cts +0 -1
  83. package/dist/agents/middleware/modelRetry.d.cts.map +1 -1
  84. package/dist/agents/middleware/modelRetry.d.ts +0 -1
  85. package/dist/agents/middleware/modelRetry.d.ts.map +1 -1
  86. package/dist/agents/middleware/modelRetry.js +15 -13
  87. package/dist/agents/middleware/modelRetry.js.map +1 -1
  88. package/dist/agents/middleware/pii.cjs +21 -32
  89. package/dist/agents/middleware/pii.cjs.map +1 -1
  90. package/dist/agents/middleware/pii.d.cts +0 -1
  91. package/dist/agents/middleware/pii.d.cts.map +1 -1
  92. package/dist/agents/middleware/pii.d.ts +0 -1
  93. package/dist/agents/middleware/pii.d.ts.map +1 -1
  94. package/dist/agents/middleware/pii.js +10 -21
  95. package/dist/agents/middleware/pii.js.map +1 -1
  96. package/dist/agents/middleware/piiRedaction.cjs +22 -28
  97. package/dist/agents/middleware/piiRedaction.cjs.map +1 -1
  98. package/dist/agents/middleware/piiRedaction.d.cts +0 -1
  99. package/dist/agents/middleware/piiRedaction.d.cts.map +1 -1
  100. package/dist/agents/middleware/piiRedaction.d.ts +0 -1
  101. package/dist/agents/middleware/piiRedaction.d.ts.map +1 -1
  102. package/dist/agents/middleware/piiRedaction.js +8 -14
  103. package/dist/agents/middleware/piiRedaction.js.map +1 -1
  104. package/dist/agents/middleware/provider/anthropic/promptCaching.cjs +5 -8
  105. package/dist/agents/middleware/provider/anthropic/promptCaching.cjs.map +1 -1
  106. package/dist/agents/middleware/provider/anthropic/promptCaching.d.cts +2 -2
  107. package/dist/agents/middleware/provider/anthropic/promptCaching.d.cts.map +1 -1
  108. package/dist/agents/middleware/provider/anthropic/promptCaching.d.ts +2 -2
  109. package/dist/agents/middleware/provider/anthropic/promptCaching.d.ts.map +1 -1
  110. package/dist/agents/middleware/provider/anthropic/promptCaching.js +3 -6
  111. package/dist/agents/middleware/provider/anthropic/promptCaching.js.map +1 -1
  112. package/dist/agents/middleware/provider/openai/moderation.cjs +17 -22
  113. package/dist/agents/middleware/provider/openai/moderation.cjs.map +1 -1
  114. package/dist/agents/middleware/provider/openai/moderation.d.cts +0 -2
  115. package/dist/agents/middleware/provider/openai/moderation.d.cts.map +1 -1
  116. package/dist/agents/middleware/provider/openai/moderation.d.ts +0 -2
  117. package/dist/agents/middleware/provider/openai/moderation.d.ts.map +1 -1
  118. package/dist/agents/middleware/provider/openai/moderation.js +10 -15
  119. package/dist/agents/middleware/provider/openai/moderation.js.map +1 -1
  120. package/dist/agents/middleware/summarization.cjs +39 -62
  121. package/dist/agents/middleware/summarization.cjs.map +1 -1
  122. package/dist/agents/middleware/summarization.d.cts +2 -2
  123. package/dist/agents/middleware/summarization.d.cts.map +1 -1
  124. package/dist/agents/middleware/summarization.d.ts +2 -2
  125. package/dist/agents/middleware/summarization.d.ts.map +1 -1
  126. package/dist/agents/middleware/summarization.js +17 -40
  127. package/dist/agents/middleware/summarization.js.map +1 -1
  128. package/dist/agents/middleware/todoListMiddleware.cjs +21 -27
  129. package/dist/agents/middleware/todoListMiddleware.cjs.map +1 -1
  130. package/dist/agents/middleware/todoListMiddleware.d.cts +4 -4
  131. package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -1
  132. package/dist/agents/middleware/todoListMiddleware.d.ts +4 -4
  133. package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -1
  134. package/dist/agents/middleware/todoListMiddleware.js +12 -18
  135. package/dist/agents/middleware/todoListMiddleware.js.map +1 -1
  136. package/dist/agents/middleware/toolCallLimit.cjs +24 -46
  137. package/dist/agents/middleware/toolCallLimit.cjs.map +1 -1
  138. package/dist/agents/middleware/toolCallLimit.d.cts +2 -3
  139. package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
  140. package/dist/agents/middleware/toolCallLimit.d.ts +2 -3
  141. package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
  142. package/dist/agents/middleware/toolCallLimit.js +17 -39
  143. package/dist/agents/middleware/toolCallLimit.js.map +1 -1
  144. package/dist/agents/middleware/toolEmulator.cjs +8 -13
  145. package/dist/agents/middleware/toolEmulator.cjs.map +1 -1
  146. package/dist/agents/middleware/toolEmulator.d.cts +0 -1
  147. package/dist/agents/middleware/toolEmulator.d.cts.map +1 -1
  148. package/dist/agents/middleware/toolEmulator.d.ts +0 -1
  149. package/dist/agents/middleware/toolEmulator.d.ts.map +1 -1
  150. package/dist/agents/middleware/toolEmulator.js +5 -10
  151. package/dist/agents/middleware/toolEmulator.js.map +1 -1
  152. package/dist/agents/middleware/toolRetry.cjs +19 -17
  153. package/dist/agents/middleware/toolRetry.cjs.map +1 -1
  154. package/dist/agents/middleware/toolRetry.d.cts +0 -1
  155. package/dist/agents/middleware/toolRetry.d.cts.map +1 -1
  156. package/dist/agents/middleware/toolRetry.d.ts +0 -1
  157. package/dist/agents/middleware/toolRetry.d.ts.map +1 -1
  158. package/dist/agents/middleware/toolRetry.js +15 -13
  159. package/dist/agents/middleware/toolRetry.js.map +1 -1
  160. package/dist/agents/middleware/types.cjs.map +1 -1
  161. package/dist/agents/middleware/types.d.cts +33 -33
  162. package/dist/agents/middleware/types.d.cts.map +1 -1
  163. package/dist/agents/middleware/types.d.ts +33 -33
  164. package/dist/agents/middleware/types.d.ts.map +1 -1
  165. package/dist/agents/middleware/types.js.map +1 -1
  166. package/dist/agents/middleware/utils.cjs +8 -8
  167. package/dist/agents/middleware/utils.cjs.map +1 -1
  168. package/dist/agents/middleware/utils.d.cts +0 -1
  169. package/dist/agents/middleware/utils.d.cts.map +1 -1
  170. package/dist/agents/middleware/utils.d.ts +0 -1
  171. package/dist/agents/middleware/utils.d.ts.map +1 -1
  172. package/dist/agents/middleware/utils.js +3 -3
  173. package/dist/agents/middleware/utils.js.map +1 -1
  174. package/dist/agents/middleware.cjs +1 -2
  175. package/dist/agents/middleware.cjs.map +1 -1
  176. package/dist/agents/middleware.d.cts +0 -1
  177. package/dist/agents/middleware.d.cts.map +1 -1
  178. package/dist/agents/middleware.d.ts +0 -1
  179. package/dist/agents/middleware.d.ts.map +1 -1
  180. package/dist/agents/middleware.js +1 -2
  181. package/dist/agents/middleware.js.map +1 -1
  182. package/dist/agents/model.cjs.map +1 -1
  183. package/dist/agents/model.js.map +1 -1
  184. package/dist/agents/nodes/AfterAgentNode.cjs +1 -2
  185. package/dist/agents/nodes/AfterAgentNode.cjs.map +1 -1
  186. package/dist/agents/nodes/AfterAgentNode.js +1 -2
  187. package/dist/agents/nodes/AfterAgentNode.js.map +1 -1
  188. package/dist/agents/nodes/AfterModelNode.cjs +1 -2
  189. package/dist/agents/nodes/AfterModelNode.cjs.map +1 -1
  190. package/dist/agents/nodes/AfterModelNode.js +1 -2
  191. package/dist/agents/nodes/AfterModelNode.js.map +1 -1
  192. package/dist/agents/nodes/AgentNode.cjs +46 -58
  193. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  194. package/dist/agents/nodes/AgentNode.js +16 -28
  195. package/dist/agents/nodes/AgentNode.js.map +1 -1
  196. package/dist/agents/nodes/BeforeAgentNode.cjs +1 -2
  197. package/dist/agents/nodes/BeforeAgentNode.cjs.map +1 -1
  198. package/dist/agents/nodes/BeforeAgentNode.js +1 -2
  199. package/dist/agents/nodes/BeforeAgentNode.js.map +1 -1
  200. package/dist/agents/nodes/BeforeModelNode.cjs +1 -2
  201. package/dist/agents/nodes/BeforeModelNode.cjs.map +1 -1
  202. package/dist/agents/nodes/BeforeModelNode.js +1 -2
  203. package/dist/agents/nodes/BeforeModelNode.js.map +1 -1
  204. package/dist/agents/nodes/ToolNode.cjs +25 -25
  205. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  206. package/dist/agents/nodes/ToolNode.js +6 -6
  207. package/dist/agents/nodes/ToolNode.js.map +1 -1
  208. package/dist/agents/nodes/middleware.cjs +3 -3
  209. package/dist/agents/nodes/middleware.cjs.map +1 -1
  210. package/dist/agents/nodes/middleware.js.map +1 -1
  211. package/dist/agents/nodes/types.d.cts +0 -1
  212. package/dist/agents/nodes/types.d.cts.map +1 -1
  213. package/dist/agents/nodes/types.d.ts +0 -1
  214. package/dist/agents/nodes/types.d.ts.map +1 -1
  215. package/dist/agents/nodes/utils.cjs +16 -17
  216. package/dist/agents/nodes/utils.cjs.map +1 -1
  217. package/dist/agents/nodes/utils.js +2 -3
  218. package/dist/agents/nodes/utils.js.map +1 -1
  219. package/dist/agents/responses.cjs +20 -30
  220. package/dist/agents/responses.cjs.map +1 -1
  221. package/dist/agents/responses.d.cts +0 -1
  222. package/dist/agents/responses.d.cts.map +1 -1
  223. package/dist/agents/responses.d.ts +0 -1
  224. package/dist/agents/responses.d.ts.map +1 -1
  225. package/dist/agents/responses.js +12 -22
  226. package/dist/agents/responses.js.map +1 -1
  227. package/dist/agents/runtime.d.cts +0 -1
  228. package/dist/agents/runtime.d.cts.map +1 -1
  229. package/dist/agents/runtime.d.ts +0 -1
  230. package/dist/agents/runtime.d.ts.map +1 -1
  231. package/dist/agents/state.cjs +1 -2
  232. package/dist/agents/state.cjs.map +1 -1
  233. package/dist/agents/state.js +1 -2
  234. package/dist/agents/state.js.map +1 -1
  235. package/dist/agents/tests/utils.cjs +21 -26
  236. package/dist/agents/tests/utils.cjs.map +1 -1
  237. package/dist/agents/tests/utils.d.cts +0 -1
  238. package/dist/agents/tests/utils.d.cts.map +1 -1
  239. package/dist/agents/tests/utils.d.ts +0 -1
  240. package/dist/agents/tests/utils.d.ts.map +1 -1
  241. package/dist/agents/tests/utils.js +12 -17
  242. package/dist/agents/tests/utils.js.map +1 -1
  243. package/dist/agents/types.d.cts +4 -5
  244. package/dist/agents/types.d.cts.map +1 -1
  245. package/dist/agents/types.d.ts +4 -5
  246. package/dist/agents/types.d.ts.map +1 -1
  247. package/dist/agents/utils.cjs +32 -32
  248. package/dist/agents/utils.cjs.map +1 -1
  249. package/dist/agents/utils.js +6 -6
  250. package/dist/agents/utils.js.map +1 -1
  251. package/dist/agents/withAgentName.cjs +5 -5
  252. package/dist/agents/withAgentName.cjs.map +1 -1
  253. package/dist/agents/withAgentName.js.map +1 -1
  254. package/dist/chat_models/universal.cjs +34 -41
  255. package/dist/chat_models/universal.cjs.map +1 -1
  256. package/dist/chat_models/universal.d.cts.map +1 -1
  257. package/dist/chat_models/universal.d.ts.map +1 -1
  258. package/dist/chat_models/universal.js +21 -29
  259. package/dist/chat_models/universal.js.map +1 -1
  260. package/dist/hub/base.cjs +3 -4
  261. package/dist/hub/base.cjs.map +1 -1
  262. package/dist/hub/base.d.cts +0 -1
  263. package/dist/hub/base.d.cts.map +1 -1
  264. package/dist/hub/base.d.ts +0 -1
  265. package/dist/hub/base.d.ts.map +1 -1
  266. package/dist/hub/base.js +1 -2
  267. package/dist/hub/base.js.map +1 -1
  268. package/dist/hub/index.cjs +2 -2
  269. package/dist/hub/index.cjs.map +1 -1
  270. package/dist/hub/index.d.cts +0 -1
  271. package/dist/hub/index.d.cts.map +1 -1
  272. package/dist/hub/index.d.ts +0 -1
  273. package/dist/hub/index.d.ts.map +1 -1
  274. package/dist/hub/index.js +1 -2
  275. package/dist/hub/index.js.map +1 -1
  276. package/dist/hub/node.cjs +7 -13
  277. package/dist/hub/node.cjs.map +1 -1
  278. package/dist/hub/node.d.cts +0 -1
  279. package/dist/hub/node.d.cts.map +1 -1
  280. package/dist/hub/node.d.ts +0 -1
  281. package/dist/hub/node.d.ts.map +1 -1
  282. package/dist/hub/node.js +6 -13
  283. package/dist/hub/node.js.map +1 -1
  284. package/dist/index.cjs +48 -48
  285. package/dist/index.d.cts +2 -1
  286. package/dist/index.d.ts +2 -1
  287. package/dist/index.js +2 -3
  288. package/dist/load/import_constants.cjs.map +1 -1
  289. package/dist/load/import_constants.js.map +1 -1
  290. package/dist/load/import_map.cjs +46 -47
  291. package/dist/load/import_map.cjs.map +1 -1
  292. package/dist/load/import_map.js +2 -3
  293. package/dist/load/import_map.js.map +1 -1
  294. package/dist/load/import_type.d.cts.map +1 -1
  295. package/dist/load/import_type.d.ts.map +1 -1
  296. package/dist/load/index.cjs +13 -3
  297. package/dist/load/index.cjs.map +1 -1
  298. package/dist/load/index.d.cts +9 -1
  299. package/dist/load/index.d.cts.map +1 -1
  300. package/dist/load/index.d.ts +9 -1
  301. package/dist/load/index.d.ts.map +1 -1
  302. package/dist/load/index.js +9 -0
  303. package/dist/load/index.js.map +1 -1
  304. package/dist/load/serializable.cjs +7 -6
  305. package/dist/load/serializable.js +4 -4
  306. package/dist/storage/encoder_backed.cjs +9 -10
  307. package/dist/storage/encoder_backed.cjs.map +1 -1
  308. package/dist/storage/encoder_backed.d.cts +0 -1
  309. package/dist/storage/encoder_backed.d.cts.map +1 -1
  310. package/dist/storage/encoder_backed.d.ts +0 -1
  311. package/dist/storage/encoder_backed.d.ts.map +1 -1
  312. package/dist/storage/encoder_backed.js +4 -6
  313. package/dist/storage/encoder_backed.js.map +1 -1
  314. package/dist/storage/file_system.cjs +12 -11
  315. package/dist/storage/file_system.cjs.map +1 -1
  316. package/dist/storage/file_system.d.cts +0 -1
  317. package/dist/storage/file_system.d.cts.map +1 -1
  318. package/dist/storage/file_system.d.ts +0 -1
  319. package/dist/storage/file_system.d.ts.map +1 -1
  320. package/dist/storage/file_system.js +5 -7
  321. package/dist/storage/file_system.js.map +1 -1
  322. package/dist/storage/in_memory.cjs +5 -5
  323. package/dist/storage/in_memory.js +2 -3
  324. package/package.json +6 -6
  325. package/dist/_virtual/rolldown_runtime.js +0 -25
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.js","names":["stateSchema: TStateSchema","middlewareList: TMiddleware","stateFields: Record<string, any>","inputFields: Record<string, any>","outputFields: Record<string, any>","schema: InteropZodObject | StateSchema<any>"],"sources":["../../src/agents/annotation.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n StateSchema,\n MessagesValue,\n UntrackedValue,\n ReducedValue,\n type StateDefinitionInit,\n} from \"@langchain/langgraph\";\nimport { schemaMetaRegistry } from \"@langchain/langgraph/zod\";\n\nimport type { AgentMiddleware } from \"./middleware/types.js\";\nimport {\n type InteropZodObject,\n isZodSchemaV4,\n getInteropZodObjectShape,\n isInteropZodObject,\n} from \"@langchain/core/utils/types\";\n\n/**\n * Type for jumpTo navigation targets\n */\ntype JumpToTarget = \"model_request\" | \"tools\" | \"end\" | undefined;\n\nexport function createAgentState<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n TMiddleware extends readonly AgentMiddleware<any, any, any>[] = [],\n>(\n hasStructuredResponse = true,\n stateSchema: TStateSchema,\n middlewareList: TMiddleware = [] as unknown as TMiddleware\n) {\n /**\n * Collect fields from state schemas\n */\n const stateFields: Record<string, any> = {\n // jumpTo is used for internal navigation control\n jumpTo: new UntrackedValue<JumpToTarget>(),\n };\n\n // Separate shapes for input/output without reducer metadata (to avoid channel conflicts)\n const inputFields: Record<string, any> = {};\n const outputFields: Record<string, any> = {};\n\n const applySchema = (schema: InteropZodObject | StateSchema<any>) => {\n // Handle StateSchema: extract from .fields\n if (StateSchema.isInstance(schema)) {\n for (const [key, field] of Object.entries(schema.fields)) {\n if (key.startsWith(\"_\")) {\n continue;\n }\n if (!(key in stateFields)) {\n // Add to stateFields to preserve ReducedValue/UntrackedValue behavior\n stateFields[key] = field;\n\n // For ioFields, extract the appropriate schema from ReducedValue\n if (ReducedValue.isInstance(field)) {\n // For input, use inputSchema if available, otherwise use the value schema\n inputFields[key] = field.inputSchema || field.valueSchema;\n outputFields[key] = field.valueSchema;\n } else {\n // For non-ReducedValue fields, use the field as-is\n inputFields[key] = field;\n outputFields[key] = field;\n }\n }\n }\n return;\n }\n\n // Handle Zod v3/v4: extract shape using interop utilities\n const shape = getInteropZodObjectShape(schema);\n for (const [key, fieldSchema] of Object.entries(shape)) {\n // Skip private state properties (prefixed with underscore)\n if (key.startsWith(\"_\")) {\n continue;\n }\n if (!(key in stateFields)) {\n // Check for reducer metadata (Zod v4 only supports schemaMetaRegistry)\n if (isZodSchemaV4(fieldSchema)) {\n const meta = schemaMetaRegistry.get(fieldSchema);\n if (meta?.reducer) {\n // Wrap with ReducedValue to preserve reducer behavior\n if (meta.reducer.schema) {\n stateFields[key] = new ReducedValue(fieldSchema as any, {\n inputSchema: meta.reducer.schema as any,\n reducer: meta.reducer.fn,\n });\n // For input, use the inputSchema\n inputFields[key] = meta.reducer.schema;\n outputFields[key] = fieldSchema;\n } else {\n stateFields[key] = new ReducedValue(fieldSchema as any, {\n reducer: meta.reducer.fn,\n });\n // No inputSchema, use the value schema\n inputFields[key] = fieldSchema;\n outputFields[key] = fieldSchema;\n }\n continue;\n }\n }\n\n // No reducer - use schema directly\n stateFields[key] = fieldSchema;\n inputFields[key] = fieldSchema;\n outputFields[key] = fieldSchema;\n }\n }\n };\n\n /**\n * Add state schema properties from user-provided schema.\n * Supports both StateSchema and Zod v3/v4 objects.\n */\n if (\n stateSchema &&\n (StateSchema.isInstance(stateSchema) || isInteropZodObject(stateSchema))\n ) {\n applySchema(stateSchema);\n }\n\n /**\n * Add state schema properties from middleware.\n * Supports both StateSchema and Zod v3/v4 objects.\n */\n for (const middleware of middlewareList) {\n if (\n middleware.stateSchema &&\n (StateSchema.isInstance(middleware.stateSchema) ||\n isInteropZodObject(middleware.stateSchema))\n ) {\n applySchema(middleware.stateSchema);\n }\n }\n\n // Only include structuredResponse when responseFormat is defined\n if (hasStructuredResponse) {\n outputFields.structuredResponse = new UntrackedValue<any>();\n }\n\n /**\n * Create StateSchema instances for state, input, and output.\n * Using MessagesValue provides the proper message reducer behavior.\n */\n return {\n state: new StateSchema({\n messages: MessagesValue,\n ...stateFields,\n }),\n input: new StateSchema({\n messages: MessagesValue,\n ...inputFields,\n }),\n output: new StateSchema({\n messages: MessagesValue,\n ...outputFields,\n }),\n };\n}\n"],"mappings":";;;;;AAuBA,SAAgB,iBAId,wBAAwB,MACxBA,aACAC,iBAA8B,CAAE,GAChC;;;;CAIA,MAAMC,cAAmC,EAEvC,QAAQ,IAAI,iBACb;CAGD,MAAMC,cAAmC,CAAE;CAC3C,MAAMC,eAAoC,CAAE;CAE5C,MAAM,cAAc,CAACC,WAAgD;AAEnE,MAAI,YAAY,WAAW,OAAO,EAAE;AAClC,QAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,OAAO,OAAO,EAAE;AACxD,QAAI,IAAI,WAAW,IAAI,CACrB;AAEF,QAAI,EAAE,OAAO,cAAc;KAEzB,YAAY,OAAO;AAGnB,SAAI,aAAa,WAAW,MAAM,EAAE;MAElC,YAAY,OAAO,MAAM,eAAe,MAAM;MAC9C,aAAa,OAAO,MAAM;KAC3B,OAAM;MAEL,YAAY,OAAO;MACnB,aAAa,OAAO;KACrB;IACF;GACF;AACD;EACD;EAGD,MAAM,QAAQ,yBAAyB,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,YAAY,IAAI,OAAO,QAAQ,MAAM,EAAE;AAEtD,OAAI,IAAI,WAAW,IAAI,CACrB;AAEF,OAAI,EAAE,OAAO,cAAc;AAEzB,QAAI,cAAc,YAAY,EAAE;KAC9B,MAAM,OAAO,mBAAmB,IAAI,YAAY;AAChD,SAAI,MAAM,SAAS;AAEjB,UAAI,KAAK,QAAQ,QAAQ;OACvB,YAAY,OAAO,IAAI,aAAa,aAAoB;QACtD,aAAa,KAAK,QAAQ;QAC1B,SAAS,KAAK,QAAQ;OACvB;OAED,YAAY,OAAO,KAAK,QAAQ;OAChC,aAAa,OAAO;MACrB,OAAM;OACL,YAAY,OAAO,IAAI,aAAa,aAAoB,EACtD,SAAS,KAAK,QAAQ,GACvB;OAED,YAAY,OAAO;OACnB,aAAa,OAAO;MACrB;AACD;KACD;IACF;IAGD,YAAY,OAAO;IACnB,YAAY,OAAO;IACnB,aAAa,OAAO;GACrB;EACF;CACF;;;;;AAMD,KACE,gBACC,YAAY,WAAW,YAAY,IAAI,mBAAmB,YAAY,GAEvE,YAAY,YAAY;;;;;AAO1B,MAAK,MAAM,cAAc,eACvB,KACE,WAAW,gBACV,YAAY,WAAW,WAAW,YAAY,IAC7C,mBAAmB,WAAW,YAAY,GAE5C,YAAY,WAAW,YAAY;AAKvC,KAAI,uBACF,aAAa,qBAAqB,IAAI;;;;;AAOxC,QAAO;EACL,OAAO,IAAI,YAAY;GACrB,UAAU;GACV,GAAG;EACJ;EACD,OAAO,IAAI,YAAY;GACrB,UAAU;GACV,GAAG;EACJ;EACD,QAAQ,IAAI,YAAY;GACtB,UAAU;GACV,GAAG;EACJ;CACF;AACF"}
1
+ {"version":3,"file":"annotation.js","names":[],"sources":["../../src/agents/annotation.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n StateSchema,\n MessagesValue,\n UntrackedValue,\n ReducedValue,\n type StateDefinitionInit,\n} from \"@langchain/langgraph\";\nimport { schemaMetaRegistry } from \"@langchain/langgraph/zod\";\n\nimport type { AgentMiddleware } from \"./middleware/types.js\";\nimport {\n type InteropZodObject,\n isZodSchemaV4,\n getInteropZodObjectShape,\n isInteropZodObject,\n} from \"@langchain/core/utils/types\";\n\n/**\n * Type for jumpTo navigation targets\n */\ntype JumpToTarget = \"model_request\" | \"tools\" | \"end\" | undefined;\n\nexport function createAgentState<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n TMiddleware extends readonly AgentMiddleware<any, any, any>[] = [],\n>(\n hasStructuredResponse = true,\n stateSchema: TStateSchema,\n middlewareList: TMiddleware = [] as unknown as TMiddleware\n) {\n /**\n * Collect fields from state schemas\n */\n const stateFields: Record<string, any> = {\n // jumpTo is used for internal navigation control\n jumpTo: new UntrackedValue<JumpToTarget>(),\n };\n\n // Separate shapes for input/output without reducer metadata (to avoid channel conflicts)\n const inputFields: Record<string, any> = {};\n const outputFields: Record<string, any> = {};\n\n const applySchema = (schema: InteropZodObject | StateSchema<any>) => {\n // Handle StateSchema: extract from .fields\n if (StateSchema.isInstance(schema)) {\n for (const [key, field] of Object.entries(schema.fields)) {\n if (!(key in stateFields)) {\n // Add to stateFields to preserve ReducedValue/UntrackedValue behavior\n stateFields[key] = field;\n\n // Private state (underscore-prefixed) persists in the graph state\n // but is not exposed as input/output channels.\n if (key.startsWith(\"_\")) {\n continue;\n }\n\n // For ioFields, extract the appropriate schema from ReducedValue\n if (ReducedValue.isInstance(field)) {\n // For input, use inputSchema if available, otherwise use the value schema\n inputFields[key] = field.inputSchema || field.valueSchema;\n outputFields[key] = field.valueSchema;\n } else {\n // For non-ReducedValue fields, use the field as-is\n inputFields[key] = field;\n outputFields[key] = field;\n }\n }\n }\n return;\n }\n\n // Handle Zod v3/v4: extract shape using interop utilities\n const shape = getInteropZodObjectShape(schema);\n for (const [key, fieldSchema] of Object.entries(shape)) {\n const isPrivate = key.startsWith(\"_\");\n\n if (!(key in stateFields)) {\n // Check for reducer metadata (Zod v4 only supports schemaMetaRegistry)\n if (isZodSchemaV4(fieldSchema)) {\n const meta = schemaMetaRegistry.get(fieldSchema);\n if (meta?.reducer) {\n // Wrap with ReducedValue to preserve reducer behavior\n if (meta.reducer.schema) {\n stateFields[key] = new ReducedValue(fieldSchema as any, {\n inputSchema: meta.reducer.schema as any,\n reducer: meta.reducer.fn,\n });\n if (!isPrivate) {\n // For input, use the inputSchema\n inputFields[key] = meta.reducer.schema;\n outputFields[key] = fieldSchema;\n }\n } else {\n stateFields[key] = new ReducedValue(fieldSchema as any, {\n reducer: meta.reducer.fn,\n });\n if (!isPrivate) {\n // No inputSchema, use the value schema\n inputFields[key] = fieldSchema;\n outputFields[key] = fieldSchema;\n }\n }\n continue;\n }\n }\n\n // No reducer - use schema directly\n stateFields[key] = fieldSchema;\n\n // Private state (underscore-prefixed) persists in the graph state\n // but is not exposed as input/output channels.\n if (!isPrivate) {\n inputFields[key] = fieldSchema;\n outputFields[key] = fieldSchema;\n }\n }\n }\n };\n\n /**\n * Add state schema properties from user-provided schema.\n * Supports both StateSchema and Zod v3/v4 objects.\n */\n if (\n stateSchema &&\n (StateSchema.isInstance(stateSchema) || isInteropZodObject(stateSchema))\n ) {\n applySchema(stateSchema);\n }\n\n /**\n * Add state schema properties from middleware.\n * Supports both StateSchema and Zod v3/v4 objects.\n */\n for (const middleware of middlewareList) {\n if (\n middleware.stateSchema &&\n (StateSchema.isInstance(middleware.stateSchema) ||\n isInteropZodObject(middleware.stateSchema))\n ) {\n applySchema(middleware.stateSchema);\n }\n }\n\n // Only include structuredResponse when responseFormat is defined\n if (hasStructuredResponse) {\n outputFields.structuredResponse = new UntrackedValue<any>();\n }\n\n /**\n * Create StateSchema instances for state, input, and output.\n * Using MessagesValue provides the proper message reducer behavior.\n */\n return {\n state: new StateSchema({\n messages: MessagesValue,\n ...stateFields,\n }),\n input: new StateSchema({\n messages: MessagesValue,\n ...inputFields,\n }),\n output: new StateSchema({\n messages: MessagesValue,\n ...outputFields,\n }),\n };\n}\n"],"mappings":";;;;;AAuBA,SAAgB,iBAId,wBAAwB,MACxB,aACA,iBAA8B,EAAE,EAChC;;;;CAIA,MAAM,cAAmC,EAEvC,QAAQ,IAAI,gBAA8B,EAC3C;CAGD,MAAM,cAAmC,EAAE;CAC3C,MAAM,eAAoC,EAAE;CAE5C,MAAM,eAAe,WAAgD;AAEnE,MAAI,YAAY,WAAW,OAAO,EAAE;AAClC,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ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;AAO7D,QAAO;EACL,OAAO,IAAI,YAAY;GACrB,UAAU;GACV,GAAG;GACJ,CAAC;EACF,OAAO,IAAI,YAAY;GACrB,UAAU;GACV,GAAG;GACJ,CAAC;EACF,QAAQ,IAAI,YAAY;GACtB,UAAU;GACV,GAAG;GACJ,CAAC;EACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.cts","names":["JUMP_TO_TARGETS","JumpToTarget"],"sources":["../../src/agents/constants.d.ts"],"sourcesContent":["/**\n * jump targets (user facing)\n */\nexport declare const JUMP_TO_TARGETS: readonly [\"model\", \"tools\", \"end\"];\nexport type JumpToTarget = (typeof JUMP_TO_TARGETS)[number];\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;AAGA;AACA;cADqBA;KACTC,YAAAA,WAAuBD"}
1
+ {"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/agents/constants.ts"],"mappings":";;AAGA;;cAAa,eAAA;AAAA,KACD,YAAA,WAAuB,eAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","names":["JUMP_TO_TARGETS","JumpToTarget"],"sources":["../../src/agents/constants.d.ts"],"sourcesContent":["/**\n * jump targets (user facing)\n */\nexport declare const JUMP_TO_TARGETS: readonly [\"model\", \"tools\", \"end\"];\nexport type JumpToTarget = (typeof JUMP_TO_TARGETS)[number];\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;AAGA;AACA;cADqBA;KACTC,YAAAA,WAAuBD"}
1
+ {"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/agents/constants.ts"],"mappings":";;AAGA;;cAAa,eAAA;AAAA,KACD,YAAA,WAAuB,eAAA"}
@@ -1,5 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const __langchain_langgraph = require_rolldown_runtime.__toESM(require("@langchain/langgraph"));
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ let _langchain_langgraph = require("@langchain/langgraph");
3
3
 
4
4
  //#region src/agents/errors.ts
5
5
  var MultipleToolsBoundError = class extends Error {
@@ -66,7 +66,7 @@ var MiddlewareError = class MiddlewareError extends Error {
66
66
  * @returns The original error if it's a GraphBubbleUp, otherwise a new MiddlewareError
67
67
  */
68
68
  static wrap(error, middlewareName) {
69
- if ((0, __langchain_langgraph.isGraphBubbleUp)(error)) return error;
69
+ if ((0, _langchain_langgraph.isGraphBubbleUp)(error)) return error;
70
70
  return new MiddlewareError(error, middlewareName);
71
71
  }
72
72
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":["toolNames: string[]","toolName: string","errors: string[]","toolError: unknown","toolCall: ToolCall","error: unknown","middlewareName: string"],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { isGraphBubbleUp } from \"@langchain/langgraph\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to createAgent. \" +\n \"The agent will bind the tools provided in the 'tools' parameter.\"\n );\n }\n}\n\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport class MultipleStructuredOutputsError extends Error {\n public readonly toolNames: string[];\n\n constructor(toolNames: string[]) {\n super(\n `The model has called multiple tools: ${toolNames.join(\n \", \"\n )} to return a structured output. ` +\n \"This is not supported. Please provide a single structured output.\"\n );\n this.toolNames = toolNames;\n }\n}\n\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport class StructuredOutputParsingError extends Error {\n public readonly toolName: string;\n\n public readonly errors: string[];\n\n constructor(toolName: string, errors: string[]) {\n super(\n `Failed to parse structured output for tool '${toolName}':${errors\n .map((e) => `\\n - ${e}`)\n .join(\"\")}.`\n );\n this.toolName = toolName;\n this.errors = errors;\n }\n}\n\n/**\n * Raised when a tool call is throwing an error.\n */\nexport class ToolInvocationError extends Error {\n public readonly toolCall: ToolCall;\n\n public readonly toolError: Error;\n\n constructor(toolError: unknown, toolCall: ToolCall) {\n const error =\n toolError instanceof Error ? toolError : new Error(String(toolError));\n const toolArgs = JSON.stringify(toolCall.args);\n super(\n `Error invoking tool '${toolCall.name}' with kwargs ${toolArgs} with error: ${error.stack}\\n Please fix the error and try again.`\n );\n\n this.toolCall = toolCall;\n this.toolError = error;\n }\n}\n\n/**\n * Error thrown when a middleware fails.\n *\n * Use `MiddlewareError.wrap()` to create instances. The constructor is private\n * to ensure that GraphBubbleUp errors (like GraphInterrupt) are never wrapped.\n */\nexport class MiddlewareError extends Error {\n static readonly \"~brand\" = \"MiddlewareError\";\n\n private constructor(error: unknown, middlewareName: string) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n super(errorMessage);\n this.name =\n error instanceof Error\n ? error.name\n : `${middlewareName[0].toUpperCase() + middlewareName.slice(1)}Error`;\n\n if (error instanceof Error) {\n this.cause = error;\n }\n }\n\n /**\n * Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error\n * (like GraphInterrupt) which should propagate unchanged.\n *\n * @param error - The error to wrap\n * @param middlewareName - The name of the middleware that threw the error\n * @returns The original error if it's a GraphBubbleUp, otherwise a new MiddlewareError\n */\n static wrap(error: unknown, middlewareName: string): Error {\n // Don't wrap GraphBubbleUp errors (GraphInterrupt, NodeInterrupt, etc.)\n // These are control flow mechanisms that need to bubble up unchanged\n if (isGraphBubbleUp(error)) {\n return error;\n }\n return new MiddlewareError(error, middlewareName);\n }\n\n /**\n * Check if the error is a MiddlewareError.\n * @param error - The error to check\n * @returns Whether the error is a MiddlewareError\n */\n static isInstance(error: unknown): error is MiddlewareError {\n return (\n error instanceof Error &&\n \"~brand\" in error &&\n error[\"~brand\"] === \"MiddlewareError\"\n );\n }\n}\n"],"mappings":";;;;AAIA,IAAa,0BAAb,cAA6C,MAAM;CACjD,cAAc;EACZ,MACE,uKAGD;CACF;AACF;;;;AAKD,IAAa,iCAAb,cAAoD,MAAM;CACxD,AAAgB;CAEhB,YAAYA,WAAq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AC1D,SACE,iBAAiB,SACjB,YAAY,SACZ,MAAM,cAAc;CAEvB;AACF"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { isGraphBubbleUp } from \"@langchain/langgraph\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to createAgent. \" +\n \"The agent will bind the tools provided in the 'tools' parameter.\"\n );\n }\n}\n\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport class MultipleStructuredOutputsError extends Error {\n public readonly toolNames: string[];\n\n constructor(toolNames: string[]) {\n super(\n `The model has called multiple tools: ${toolNames.join(\n \", \"\n )} to return a structured output. ` +\n \"This is not supported. Please provide a single structured output.\"\n );\n this.toolNames = toolNames;\n }\n}\n\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport class StructuredOutputParsingError extends Error {\n public readonly toolName: string;\n\n public readonly errors: string[];\n\n constructor(toolName: string, errors: string[]) {\n super(\n `Failed to parse structured output for tool '${toolName}':${errors\n .map((e) => `\\n - ${e}`)\n .join(\"\")}.`\n );\n this.toolName = toolName;\n this.errors = errors;\n }\n}\n\n/**\n * Raised when a tool call is throwing an error.\n */\nexport class ToolInvocationError extends Error {\n public readonly toolCall: ToolCall;\n\n public readonly toolError: Error;\n\n constructor(toolError: unknown, toolCall: ToolCall) {\n const error =\n toolError instanceof Error ? toolError : new Error(String(toolError));\n const toolArgs = JSON.stringify(toolCall.args);\n super(\n `Error invoking tool '${toolCall.name}' with kwargs ${toolArgs} with error: ${error.stack}\\n Please fix the error and try again.`\n );\n\n this.toolCall = toolCall;\n this.toolError = error;\n }\n}\n\n/**\n * Error thrown when a middleware fails.\n *\n * Use `MiddlewareError.wrap()` to create instances. The constructor is private\n * to ensure that GraphBubbleUp errors (like GraphInterrupt) are never wrapped.\n */\nexport class MiddlewareError extends Error {\n static readonly \"~brand\" = \"MiddlewareError\";\n\n private constructor(error: unknown, middlewareName: string) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n super(errorMessage);\n this.name =\n error instanceof Error\n ? error.name\n : `${middlewareName[0].toUpperCase() + middlewareName.slice(1)}Error`;\n\n if (error instanceof Error) {\n this.cause = error;\n }\n }\n\n /**\n * Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error\n * (like GraphInterrupt) which should propagate unchanged.\n *\n * @param error - The error to wrap\n * @param middlewareName - The name of the middleware that threw the error\n * @returns The original error if it's a GraphBubbleUp, otherwise a new MiddlewareError\n */\n static wrap(error: unknown, middlewareName: string): Error {\n // Don't wrap GraphBubbleUp errors (GraphInterrupt, NodeInterrupt, etc.)\n // These are control flow mechanisms that need to bubble up unchanged\n if (isGraphBubbleUp(error)) {\n return error;\n }\n return new MiddlewareError(error, middlewareName);\n }\n\n /**\n * Check if the error is a MiddlewareError.\n * @param error - The error to check\n * @returns Whether the error is a MiddlewareError\n */\n static isInstance(error: unknown): error is MiddlewareError {\n return (\n error instanceof Error &&\n \"~brand\" in error &&\n error[\"~brand\"] === \"MiddlewareError\"\n );\n }\n}\n"],"mappings":";;;;AAIA,IAAa,0BAAb,cAA6C,MAAM;CACjD,cAAc;AACZ,QACE,uKAGD;;;;;;AAOL,IAAa,iCAAb,cAAoD,MAAM;CACxD,AAAgB;CAEhB,YAAY,WAAqB;AAC/B,QACE,wCAAwC,UAAU,KAChD,KACD,CAAC,mGAEH;AACD,OAAK,YAAY;;;;;;AAOrB,IAAa,+BAAb,cAAkD,MAAM;CACtD,AAAgB;CAEhB,AAAgB;CAEhB,YAAY,UAAkB,QAAkB;AAC9C,QACE,+CAA+C,SAAS,IAAI,OACzD,KAAK,MAAM,SAAS,IAAI,CACxB,KAAK,GAAG,CAAC,GACb;AACD,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;AAOlB,IAAa,sBAAb,cAAyC,MAAM;CAC7C,AAAgB;CAEhB,AAAgB;CAEhB,YAAY,WAAoB,UAAoB;EAClD,MAAM,QACJ,qBAAqB,QAAQ,YAAY,IAAI,MAAM,OAAO,UAAU,CAAC;EACvE,MAAM,WAAW,KAAK,UAAU,SAAS,KAAK;AAC9C,QACE,wBAAwB,SAAS,KAAK,gBAAgB,SAAS,eAAe,MAAM,MAAM,wCAC3F;AAED,OAAK,WAAW;AAChB,OAAK,YAAY;;;;;;;;;AAUrB,IAAa,kBAAb,MAAa,wBAAwB,MAAM;CACzC,OAAgB,WAAW;CAE3B,AAAQ,YAAY,OAAgB,gBAAwB;EAC1D,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,QAAM,aAAa;AACnB,OAAK,OACH,iBAAiB,QACb,MAAM,OACN,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe,MAAM,EAAE,CAAC;AAEnE,MAAI,iBAAiB,MACnB,MAAK,QAAQ;;;;;;;;;;CAYjB,OAAO,KAAK,OAAgB,gBAA+B;AAGzD,gDAAoB,MAAM,CACxB,QAAO;AAET,SAAO,IAAI,gBAAgB,OAAO,eAAe;;;;;;;CAQnD,OAAO,WAAW,OAA0C;AAC1D,SACE,iBAAiB,SACjB,YAAY,SACZ,MAAM,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.cts","names":["ToolCall","MultipleToolsBoundError","Error","MultipleStructuredOutputsError","StructuredOutputParsingError","ToolInvocationError","MiddlewareError"],"sources":["../../src/agents/errors.d.ts"],"sourcesContent":["import type { ToolCall } from \"@langchain/core/messages/tool\";\nexport declare class MultipleToolsBoundError extends Error {\n constructor();\n}\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport declare class MultipleStructuredOutputsError extends Error {\n readonly toolNames: string[];\n constructor(toolNames: string[]);\n}\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport declare class StructuredOutputParsingError extends Error {\n readonly toolName: string;\n readonly errors: string[];\n constructor(toolName: string, errors: string[]);\n}\n/**\n * Raised when a tool call is throwing an error.\n */\nexport declare class ToolInvocationError extends Error {\n readonly toolCall: ToolCall;\n readonly toolError: Error;\n constructor(toolError: unknown, toolCall: ToolCall);\n}\n/**\n * Error thrown when a middleware fails.\n *\n * Use `MiddlewareError.wrap()` to create instances. The constructor is private\n * to ensure that GraphBubbleUp errors (like GraphInterrupt) are never wrapped.\n */\nexport declare class MiddlewareError extends Error {\n static readonly \"~brand\" = \"MiddlewareError\";\n private constructor();\n /**\n * Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error\n * (like GraphInterrupt) which should propagate unchanged.\n *\n * @param error - The error to wrap\n * @param middlewareName - The name of the middleware that threw the error\n * @returns The original error if it's a GraphBubbleUp, otherwise a new MiddlewareError\n */\n static wrap(error: unknown, middlewareName: string): Error;\n /**\n * Check if the error is a MiddlewareError.\n * @param error - The error to check\n * @returns Whether the error is a MiddlewareError\n */\n static isInstance(error: unknown): error is MiddlewareError;\n}\n//# sourceMappingURL=errors.d.ts.map"],"mappings":";;;cACqBC,uBAAAA,SAAgCC,KAAK;;AAA1D;AAMA;AAOA;AAQA;AACuBF,cAhBFG,8BAAAA,SAAuCD,KAAK,CAgB1CF;EACCE,SAAAA,SAAAA,EAAAA,MAAAA,EAAAA;EACsBF,WAAAA,CAAAA,SAAAA,EAAAA,MAAAA,EAAAA;;AAHQ;AAWtD;;AAiBgDM,cApC3BF,4BAAAA,SAAqCF,KAAK,CAoCfI;EAjBHJ,SAAAA,QAAAA,EAAAA,MAAAA;EAAK,SAAA,MAAA,EAAA,MAAA,EAAA;;;;;;cAX7BG,mBAAAA,SAA4BH,KAAAA;qBAC1BF;sBACCE;4CACsBF;;;;;;;;cAQzBM,eAAAA,SAAwBJ,KAAAA;;;;;;;;;;;uDAWYA;;;;;;8CAMTI"}
1
+ {"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/agents/errors.ts"],"mappings":";;;cAIa,uBAAA,SAAgC,KAAA;EAC3C,WAAA,CAAA;AAAA;;;;cAYW,8BAAA,SAAuC,KAAA;EAAA,SAClC,SAAA;EAEhB,WAAA,CAAY,SAAA;AAAA;;;;cAcD,4BAAA,SAAqC,KAAA;EAAA,SAChC,QAAA;EAAA,SAEA,MAAA;EAEhB,WAAA,CAAY,QAAA,UAAkB,MAAA;AAAA;;;;cAcnB,mBAAA,SAA4B,KAAA;EAAA,SACvB,QAAA,EAAU,QAAA;EAAA,SAEV,SAAA,EAAW,KAAA;EAE3B,WAAA,CAAY,SAAA,WAAoB,QAAA,EAAU,QAAA;AAAA;;;;AAL5C;;;cAwBa,eAAA,SAAwB,KAAA;EAAA;EAAA,QAG5B,WAAA,CAAA;EA3BgC;;;;;;;;EAAA,OAgDhC,IAAA,CAAK,KAAA,WAAgB,cAAA,WAAyB,KAAA;EA3CzC;;;;;EAAA,OAyDL,UAAA,CAAW,KAAA,YAAiB,KAAA,IAAS,eAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","names":["ToolCall","MultipleToolsBoundError","Error","MultipleStructuredOutputsError","StructuredOutputParsingError","ToolInvocationError","MiddlewareError"],"sources":["../../src/agents/errors.d.ts"],"sourcesContent":["import type { ToolCall } from \"@langchain/core/messages/tool\";\nexport declare class MultipleToolsBoundError extends Error {\n constructor();\n}\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport declare class MultipleStructuredOutputsError extends Error {\n readonly toolNames: string[];\n constructor(toolNames: string[]);\n}\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport declare class StructuredOutputParsingError extends Error {\n readonly toolName: string;\n readonly errors: string[];\n constructor(toolName: string, errors: string[]);\n}\n/**\n * Raised when a tool call is throwing an error.\n */\nexport declare class ToolInvocationError extends Error {\n readonly toolCall: ToolCall;\n readonly toolError: Error;\n constructor(toolError: unknown, toolCall: ToolCall);\n}\n/**\n * Error thrown when a middleware fails.\n *\n * Use `MiddlewareError.wrap()` to create instances. The constructor is private\n * to ensure that GraphBubbleUp errors (like GraphInterrupt) are never wrapped.\n */\nexport declare class MiddlewareError extends Error {\n static readonly \"~brand\" = \"MiddlewareError\";\n private constructor();\n /**\n * Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error\n * (like GraphInterrupt) which should propagate unchanged.\n *\n * @param error - The error to wrap\n * @param middlewareName - The name of the middleware that threw the error\n * @returns The original error if it's a GraphBubbleUp, otherwise a new MiddlewareError\n */\n static wrap(error: unknown, middlewareName: string): Error;\n /**\n * Check if the error is a MiddlewareError.\n * @param error - The error to check\n * @returns Whether the error is a MiddlewareError\n */\n static isInstance(error: unknown): error is MiddlewareError;\n}\n//# sourceMappingURL=errors.d.ts.map"],"mappings":";;;cACqBC,uBAAAA,SAAgCC,KAAK;;AAA1D;AAMA;AAOA;AAQA;AACuBF,cAhBFG,8BAAAA,SAAuCD,KAAK,CAgB1CF;EACCE,SAAAA,SAAAA,EAAAA,MAAAA,EAAAA;EACsBF,WAAAA,CAAAA,SAAAA,EAAAA,MAAAA,EAAAA;;AAHQ;AAWtD;;AAiBgDM,cApC3BF,4BAAAA,SAAqCF,KAAK,CAoCfI;EAjBHJ,SAAAA,QAAAA,EAAAA,MAAAA;EAAK,SAAA,MAAA,EAAA,MAAA,EAAA;;;;;;cAX7BG,mBAAAA,SAA4BH,KAAAA;qBAC1BF;sBACCE;4CACsBF;;;;;;;;cAQzBM,eAAAA,SAAwBJ,KAAAA;;;;;;;;;;;uDAWYA;;;;;;8CAMTI"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/agents/errors.ts"],"mappings":";;;cAIa,uBAAA,SAAgC,KAAA;EAC3C,WAAA,CAAA;AAAA;;;;cAYW,8BAAA,SAAuC,KAAA;EAAA,SAClC,SAAA;EAEhB,WAAA,CAAY,SAAA;AAAA;;;;cAcD,4BAAA,SAAqC,KAAA;EAAA,SAChC,QAAA;EAAA,SAEA,MAAA;EAEhB,WAAA,CAAY,QAAA,UAAkB,MAAA;AAAA;;;;cAcnB,mBAAA,SAA4B,KAAA;EAAA,SACvB,QAAA,EAAU,QAAA;EAAA,SAEV,SAAA,EAAW,KAAA;EAE3B,WAAA,CAAY,SAAA,WAAoB,QAAA,EAAU,QAAA;AAAA;;;;AAL5C;;;cAwBa,eAAA,SAAwB,KAAA;EAAA;EAAA,QAG5B,WAAA,CAAA;EA3BgC;;;;;;;;EAAA,OAgDhC,IAAA,CAAK,KAAA,WAAgB,cAAA,WAAyB,KAAA;EA3CzC;;;;;EAAA,OAyDL,UAAA,CAAW,KAAA,YAAiB,KAAA,IAAS,eAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["toolNames: string[]","toolName: string","errors: string[]","toolError: unknown","toolCall: ToolCall","error: unknown","middlewareName: string"],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { isGraphBubbleUp } from \"@langchain/langgraph\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to createAgent. \" +\n \"The agent will bind the tools provided in the 'tools' parameter.\"\n );\n }\n}\n\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport class MultipleStructuredOutputsError extends Error {\n public readonly toolNames: string[];\n\n constructor(toolNames: string[]) {\n super(\n `The model has called multiple tools: ${toolNames.join(\n \", \"\n )} to return a structured output. ` +\n \"This is not supported. Please provide a single structured output.\"\n );\n this.toolNames = toolNames;\n }\n}\n\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport class StructuredOutputParsingError extends Error {\n public readonly toolName: string;\n\n public readonly errors: string[];\n\n constructor(toolName: string, errors: string[]) {\n super(\n `Failed to parse structured output for tool '${toolName}':${errors\n .map((e) => `\\n - ${e}`)\n .join(\"\")}.`\n );\n this.toolName = toolName;\n this.errors = errors;\n }\n}\n\n/**\n * Raised when a tool call is throwing an error.\n */\nexport class ToolInvocationError extends Error {\n public readonly toolCall: ToolCall;\n\n public readonly toolError: Error;\n\n constructor(toolError: unknown, toolCall: ToolCall) {\n const error =\n toolError instanceof Error ? toolError : new Error(String(toolError));\n const toolArgs = JSON.stringify(toolCall.args);\n super(\n `Error invoking tool '${toolCall.name}' with kwargs ${toolArgs} with error: ${error.stack}\\n Please fix the error and try again.`\n );\n\n this.toolCall = toolCall;\n this.toolError = error;\n }\n}\n\n/**\n * Error thrown when a middleware fails.\n *\n * Use `MiddlewareError.wrap()` to create instances. The constructor is private\n * to ensure that GraphBubbleUp errors (like GraphInterrupt) are never wrapped.\n */\nexport class MiddlewareError extends Error {\n static readonly \"~brand\" = \"MiddlewareError\";\n\n private constructor(error: unknown, middlewareName: string) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n super(errorMessage);\n this.name =\n error instanceof Error\n ? error.name\n : `${middlewareName[0].toUpperCase() + middlewareName.slice(1)}Error`;\n\n if (error instanceof Error) {\n this.cause = error;\n }\n }\n\n /**\n * Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error\n * (like GraphInterrupt) which should propagate unchanged.\n *\n * @param error - The error to wrap\n * @param middlewareName - The name of the middleware that threw the error\n * @returns The original error if it's a GraphBubbleUp, otherwise a new MiddlewareError\n */\n static wrap(error: unknown, middlewareName: string): Error {\n // Don't wrap GraphBubbleUp errors (GraphInterrupt, NodeInterrupt, etc.)\n // These are control flow mechanisms that need to bubble up unchanged\n if (isGraphBubbleUp(error)) {\n return error;\n }\n return new MiddlewareError(error, middlewareName);\n }\n\n /**\n * Check if the error is a MiddlewareError.\n * @param error - The error to check\n * @returns Whether the error is a MiddlewareError\n */\n static isInstance(error: unknown): error is MiddlewareError {\n return (\n error instanceof Error &&\n \"~brand\" in error &&\n error[\"~brand\"] === \"MiddlewareError\"\n );\n }\n}\n"],"mappings":";;;AAIA,IAAa,0BAAb,cAA6C,MAAM;CACjD,cAAc;EACZ,MACE,uKAGD;CACF;AACF;;;;AAKD,IA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O,IAAI,gBAAgB,OAAO;CACnC;;;;;;CAOD,OAAO,WAAWD,OAA0C;AAC1D,SACE,iBAAiB,SACjB,YAAY,SACZ,MAAM,cAAc;CAEvB;AACF"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { isGraphBubbleUp } from \"@langchain/langgraph\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to createAgent. \" +\n \"The agent will bind the tools provided in the 'tools' parameter.\"\n );\n }\n}\n\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport class MultipleStructuredOutputsError extends Error {\n public readonly toolNames: string[];\n\n constructor(toolNames: string[]) {\n super(\n `The model has called multiple tools: ${toolNames.join(\n \", \"\n )} to return a structured output. ` +\n \"This is not supported. Please provide a single structured output.\"\n );\n this.toolNames = toolNames;\n }\n}\n\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport class StructuredOutputParsingError extends Error {\n public readonly toolName: string;\n\n public readonly errors: string[];\n\n constructor(toolName: string, errors: string[]) {\n super(\n `Failed to parse structured output for tool '${toolName}':${errors\n .map((e) => `\\n - ${e}`)\n .join(\"\")}.`\n );\n this.toolName = toolName;\n this.errors = errors;\n }\n}\n\n/**\n * Raised when a tool call is throwing an error.\n */\nexport class ToolInvocationError extends Error {\n public readonly toolCall: ToolCall;\n\n public readonly toolError: Error;\n\n constructor(toolError: unknown, toolCall: ToolCall) {\n const error =\n toolError instanceof Error ? toolError : new Error(String(toolError));\n const toolArgs = JSON.stringify(toolCall.args);\n super(\n `Error invoking tool '${toolCall.name}' with kwargs ${toolArgs} with error: ${error.stack}\\n Please fix the error and try again.`\n );\n\n this.toolCall = toolCall;\n this.toolError = error;\n }\n}\n\n/**\n * Error thrown when a middleware fails.\n *\n * Use `MiddlewareError.wrap()` to create instances. The constructor is private\n * to ensure that GraphBubbleUp errors (like GraphInterrupt) are never wrapped.\n */\nexport class MiddlewareError extends Error {\n static readonly \"~brand\" = \"MiddlewareError\";\n\n private constructor(error: unknown, middlewareName: string) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n super(errorMessage);\n this.name =\n error instanceof Error\n ? error.name\n : `${middlewareName[0].toUpperCase() + middlewareName.slice(1)}Error`;\n\n if (error instanceof Error) {\n this.cause = error;\n }\n }\n\n /**\n * Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error\n * (like GraphInterrupt) which should propagate unchanged.\n *\n * @param error - The error to wrap\n * @param middlewareName - The name of the middleware that threw the error\n * @returns The original error if it's a GraphBubbleUp, otherwise a new MiddlewareError\n */\n static wrap(error: unknown, middlewareName: string): Error {\n // Don't wrap GraphBubbleUp errors (GraphInterrupt, NodeInterrupt, etc.)\n // These are control flow mechanisms that need to bubble up unchanged\n if (isGraphBubbleUp(error)) {\n return error;\n }\n return new MiddlewareError(error, middlewareName);\n }\n\n /**\n * Check if the error is a MiddlewareError.\n * @param error - The error to check\n * @returns Whether the error is a MiddlewareError\n */\n static isInstance(error: unknown): error is MiddlewareError {\n return (\n error instanceof Error &&\n \"~brand\" in error &&\n error[\"~brand\"] === \"MiddlewareError\"\n );\n }\n}\n"],"mappings":";;;AAIA,IAAa,0BAAb,cAA6C,MAAM;CACjD,cAAc;AACZ,QACE,uKAGD;;;;;;AAOL,IAAa,iCAAb,cAAoD,MAAM;CACxD,AAAgB;CAEhB,YAAY,WAAqB;AAC/B,QACE,wCAAwC,UAAU,KAChD,KACD,CAAC,mGAEH;AACD,OAAK,YAAY;;;;;;AAOrB,IAAa,+BAAb,cAAkD,MAAM;CACtD,AAAgB;CAEhB,AAAgB;CAEhB,YAAY,UAAkB,QAAkB;AAC9C,QACE,+CAA+C,SAAS,IAAI,OACzD,KAAK,MAAM,SAAS,IAAI,CACxB,KAAK,GAAG,CAAC,GACb;AACD,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;AAOlB,IAAa,sBAAb,cAAyC,MAAM;CAC7C,AAAgB;CAEhB,AAAgB;CAEhB,YAAY,WAAoB,UAAoB;EAClD,MAAM,QACJ,qBAAqB,QAAQ,YAAY,IAAI,MAAM,OAAO,UAAU,CAAC;EACvE,MAAM,WAAW,KAAK,UAAU,SAAS,KAAK;AAC9C,QACE,wBAAwB,SAAS,KAAK,gBAAgB,SAAS,eAAe,MAAM,MAAM,wCAC3F;AAED,OAAK,WAAW;AAChB,OAAK,YAAY;;;;;;;;;AAUrB,IAAa,kBAAb,MAAa,wBAAwB,MAAM;CACzC,OAAgB,WAAW;CAE3B,AAAQ,YAAY,OAAgB,gBAAwB;EAC1D,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,QAAM,aAAa;AACnB,OAAK,OACH,iBAAiB,QACb,MAAM,OACN,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe,MAAM,EAAE,CAAC;AAEnE,MAAI,iBAAiB,MACnB,MAAK,QAAQ;;;;;;;;;;CAYjB,OAAO,KAAK,OAAgB,gBAA+B;AAGzD,MAAI,gBAAgB,MAAM,CACxB,QAAO;AAET,SAAO,IAAI,gBAAgB,OAAO,eAAe;;;;;;;CAQnD,OAAO,WAAW,OAA0C;AAC1D,SACE,iBAAiB,SACjB,YAAY,SACZ,MAAM,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n any\n >","ReactAgent"],"sources":["../../src/agents/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { StateDefinitionInit } from \"@langchain/langgraph\";\n\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nimport type {\n CreateAgentParams,\n AgentTypeConfig,\n CombineTools,\n} from \"./types.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot } from \"./middleware/types.js\";\nimport type { ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools\n * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively\n * work towards solutions.\n *\n * The agent follows the ReAct pattern, interleaving reasoning steps with tool calls to iteratively\n * work towards solutions. It can handle multiple tool calls in sequence or parallel, maintain state\n * across interactions, and provide auditable decision processes.\n *\n * ## Core Components\n *\n * ### Model\n * The reasoning engine can be specified as:\n * - **String identifier**: `\"openai:gpt-4o\"` for simple setup\n * - **Model instance**: Configured model object for full control\n * - **Dynamic function**: Select models at runtime based on state\n *\n * ### Tools\n * Tools give agents the ability to take actions:\n * - Pass an array of tools created with the `tool` function\n * - Or provide a configured `ToolNode` for custom error handling\n *\n * ### Prompt\n * Shape how your agent approaches tasks:\n * - String for simple instructions\n * - SystemMessage for structured prompts\n * - Function for dynamic prompts based on state\n *\n * ### Middleware\n * Middleware allows you to extend the agent's behavior:\n * - Add pre/post-model processing for context injection or validation\n * - Add dynamic control flows, e.g. terminate invocation or retries\n * - Add human-in-the-loop capabilities\n * - Add tool calls to the agent\n * - Add tool results to the agent\n *\n * ## Advanced Features\n *\n * - **Structured Output**: Use `responseFormat` with a Zod schema to get typed responses\n * - **Memory**: Extend the state schema to remember information across interactions\n * - **Streaming**: Get real-time updates as the agent processes\n *\n * @param options - Configuration options for the agent\n * @param options.llm - The language model as an instance of a chat model\n * @param options.model - The language model as a string identifier, see more in {@link https://docs.langchain.com/oss/javascript/langchain/models#basic-usage | Models}.\n * @param options.tools - Array of tools or configured ToolNode\n * @param options.prompt - System instructions (string, SystemMessage, or function)\n * @param options.responseFormat - Zod schema for structured output\n * @param options.stateSchema - Custom state schema for memory\n * @param options.middleware - Array of middleware for extending agent behavior, see more in {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}.\n *\n * @returns A ReactAgent instance with `invoke` and `stream` methods\n *\n * @example Basic agent with tools\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const search = tool(\n * ({ query }) => `Results for: ${query}`,\n * {\n * name: \"search\",\n * description: \"Search for information\",\n * schema: z.object({\n * query: z.string().describe(\"The search query\"),\n * })\n * }\n * );\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [search],\n * });\n *\n * const result = await agent.invoke({\n * messages: [{ role: \"user\", content: \"Search for ReAct agents\" }],\n * });\n * ```\n *\n * @example Structured output\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const ContactInfo = z.object({\n * name: z.string(),\n * email: z.string(),\n * phone: z.string(),\n * });\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [],\n * responseFormat: ContactInfo,\n * });\n *\n * const result = await agent.invoke({\n * messages: [{\n * role: \"user\",\n * content: \"Extract: John Doe, john@example.com, (555) 123-4567\"\n * }],\n * });\n *\n * console.log(result.structuredResponse);\n * // { name: 'John Doe', email: 'john@example.com', phone: '(555) 123-4567' }\n * ```\n *\n * @example Streaming responses\n * ```ts\n * const stream = await agent.stream(\n * { messages: [{ role: \"user\", content: \"What's the weather?\" }] },\n * { streamMode: \"values\" }\n * );\n *\n * for await (const chunk of stream) {\n * // ...\n * }\n * ```\n *\n * @example With StateSchema\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { StateSchema, ReducedValue } from \"@langchain/langgraph\";\n * import { z } from \"zod\";\n *\n * const AgentState = new StateSchema({\n * userId: z.string(),\n * count: z.number().default(0),\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * { inputSchema: z.string(), reducer: (c, n) => [...c, n] }\n * ),\n * });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [searchTool],\n * stateSchema: AgentState,\n * });\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n InteropZodType<StructuredResponseFormat>\n > & {\n responseFormat: InteropZodType<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n StructuredResponseFormat extends readonly InteropZodType<any>[],\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n StructuredResponseFormat\n > & {\n responseFormat: StructuredResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TypedToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: TypedToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ProviderStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ProviderStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 8: Without responseFormat property at all - with proper middleware state typing\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & { middleware?: TMiddleware; tools?: TTools }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Implementation\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any>,\n TStateSchema extends StateDefinitionInit,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject,\n TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[],\n TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n any\n >\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n> {\n return new ReactAgent(params);\n}\n\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport type { JumpToTarget } from \"./constants.js\";\nexport type { Runtime } from \"./runtime.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type TypedToolStrategy,\n type ResponseFormat,\n type ResponseFormatUndefined,\n} from \"./responses.js\";\nexport { createMiddleware } from \"./middleware.js\";\nexport { MIDDLEWARE_BRAND } from \"./middleware/types.js\";\nexport type * from \"./middleware/types.js\";\nexport { FakeToolCallingModel } from \"./tests/utils.js\";\nexport type { ReactAgent } from \"./ReactAgent.js\";\n"],"mappings":";;;;;;;;AAmhBA,SAAgB,YAUdA,QAcA;AACA,QAAO,IAAIC,8BAAW;AACvB"}
1
+ {"version":3,"file":"index.cjs","names":["ReactAgent"],"sources":["../../src/agents/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { StateDefinitionInit } from \"@langchain/langgraph\";\n\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nimport type {\n CreateAgentParams,\n AgentTypeConfig,\n CombineTools,\n} from \"./types.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot } from \"./middleware/types.js\";\nimport type { ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools\n * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively\n * work towards solutions.\n *\n * The agent follows the ReAct pattern, interleaving reasoning steps with tool calls to iteratively\n * work towards solutions. It can handle multiple tool calls in sequence or parallel, maintain state\n * across interactions, and provide auditable decision processes.\n *\n * ## Core Components\n *\n * ### Model\n * The reasoning engine can be specified as:\n * - **String identifier**: `\"openai:gpt-4o\"` for simple setup\n * - **Model instance**: Configured model object for full control\n * - **Dynamic function**: Select models at runtime based on state\n *\n * ### Tools\n * Tools give agents the ability to take actions:\n * - Pass an array of tools created with the `tool` function\n * - Or provide a configured `ToolNode` for custom error handling\n *\n * ### Prompt\n * Shape how your agent approaches tasks:\n * - String for simple instructions\n * - SystemMessage for structured prompts\n * - Function for dynamic prompts based on state\n *\n * ### Middleware\n * Middleware allows you to extend the agent's behavior:\n * - Add pre/post-model processing for context injection or validation\n * - Add dynamic control flows, e.g. terminate invocation or retries\n * - Add human-in-the-loop capabilities\n * - Add tool calls to the agent\n * - Add tool results to the agent\n *\n * ## Advanced Features\n *\n * - **Structured Output**: Use `responseFormat` with a Zod schema to get typed responses\n * - **Memory**: Extend the state schema to remember information across interactions\n * - **Streaming**: Get real-time updates as the agent processes\n *\n * @param options - Configuration options for the agent\n * @param options.llm - The language model as an instance of a chat model\n * @param options.model - The language model as a string identifier, see more in {@link https://docs.langchain.com/oss/javascript/langchain/models#basic-usage | Models}.\n * @param options.tools - Array of tools or configured ToolNode\n * @param options.prompt - System instructions (string, SystemMessage, or function)\n * @param options.responseFormat - Zod schema for structured output\n * @param options.stateSchema - Custom state schema for memory\n * @param options.middleware - Array of middleware for extending agent behavior, see more in {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}.\n *\n * @returns A ReactAgent instance with `invoke` and `stream` methods\n *\n * @example Basic agent with tools\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const search = tool(\n * ({ query }) => `Results for: ${query}`,\n * {\n * name: \"search\",\n * description: \"Search for information\",\n * schema: z.object({\n * query: z.string().describe(\"The search query\"),\n * })\n * }\n * );\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [search],\n * });\n *\n * const result = await agent.invoke({\n * messages: [{ role: \"user\", content: \"Search for ReAct agents\" }],\n * });\n * ```\n *\n * @example Structured output\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const ContactInfo = z.object({\n * name: z.string(),\n * email: z.string(),\n * phone: z.string(),\n * });\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [],\n * responseFormat: ContactInfo,\n * });\n *\n * const result = await agent.invoke({\n * messages: [{\n * role: \"user\",\n * content: \"Extract: John Doe, john@example.com, (555) 123-4567\"\n * }],\n * });\n *\n * console.log(result.structuredResponse);\n * // { name: 'John Doe', email: 'john@example.com', phone: '(555) 123-4567' }\n * ```\n *\n * @example Streaming responses\n * ```ts\n * const stream = await agent.stream(\n * { messages: [{ role: \"user\", content: \"What's the weather?\" }] },\n * { streamMode: \"values\" }\n * );\n *\n * for await (const chunk of stream) {\n * // ...\n * }\n * ```\n *\n * @example With StateSchema\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { StateSchema, ReducedValue } from \"@langchain/langgraph\";\n * import { z } from \"zod\";\n *\n * const AgentState = new StateSchema({\n * userId: z.string(),\n * count: z.number().default(0),\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * { inputSchema: z.string(), reducer: (c, n) => [...c, n] }\n * ),\n * });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [searchTool],\n * stateSchema: AgentState,\n * });\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n InteropZodType<StructuredResponseFormat>\n > & {\n responseFormat: InteropZodType<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n StructuredResponseFormat extends readonly InteropZodType<any>[],\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n StructuredResponseFormat\n > & {\n responseFormat: StructuredResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TypedToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: TypedToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ProviderStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ProviderStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 8: Without responseFormat property at all - with proper middleware state typing\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & { middleware?: TMiddleware; tools?: TTools }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Implementation\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any>,\n TStateSchema extends StateDefinitionInit,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject,\n TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[],\n TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n any\n >\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n> {\n return new ReactAgent(params);\n}\n\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./nodes/types.js\";\nexport type { JumpToTarget } from \"./constants.js\";\nexport type { Runtime } from \"./runtime.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type TypedToolStrategy,\n type ResponseFormat,\n type ResponseFormatUndefined,\n} from \"./responses.js\";\nexport { createMiddleware } from \"./middleware.js\";\nexport { MIDDLEWARE_BRAND } from \"./middleware/types.js\";\nexport type * from \"./middleware/types.js\";\nexport { FakeToolCallingModel } from \"./tests/utils.js\";\nexport type { ReactAgent } from \"./ReactAgent.js\";\n"],"mappings":";;;;;;;;AAmhBA,SAAgB,YAUd,QAcA;AACA,QAAO,IAAIA,8BAAW,OAAO"}
@@ -1,7 +1,8 @@
1
1
  import { MiddlewareError, MultipleStructuredOutputsError, MultipleToolsBoundError, StructuredOutputParsingError, ToolInvocationError } from "./errors.cjs";
2
2
  import { JsonSchemaFormat, ProviderStrategy, ResponseFormat, ResponseFormatUndefined, ToolStrategy, TypedToolStrategy, providerStrategy, toolStrategy } from "./responses.cjs";
3
3
  import { JumpToTarget } from "./constants.cjs";
4
- import { Runtime } from "./runtime.cjs";
4
+ import { Runtime as Runtime$1 } from "./runtime.cjs";
5
+ import { ModelRequest } from "./nodes/types.cjs";
5
6
  import { AfterAgentHook, AfterModelHook, AgentMiddleware, AnyAnnotationRoot, BeforeAgentHook, BeforeModelHook, DefaultMiddlewareTypeConfig, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContextSchema, InferMiddlewareContexts, InferMiddlewareFullContext, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareSchema, InferMiddlewareState, InferMiddlewareStates, InferMiddlewareToolsFromConfig, InferMiddlewareType, InferSchemaInput, MIDDLEWARE_BRAND, MiddlewareResult, MiddlewareTypeConfig, NormalizedSchemaInput, ResolveMiddlewareTypeConfig, ToAnnotationRoot, ToolCallHandler, ToolCallRequest, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook } from "./middleware/types.cjs";
6
7
  import { AgentTypeConfig, BuiltInState, CombineTools, CreateAgentParams, DefaultAgentTypeConfig, ExecutedToolCall, ExtractZodArrayTypes, InferAgentContext, InferAgentContextSchema, InferAgentMiddleware, InferAgentResponse, InferAgentState, InferAgentStateSchema, InferAgentTools, InferAgentType, InferMiddlewareTools, InferMiddlewareToolsArray, Interrupt, JumpTo, N, ResolveAgentTypeConfig, ToolCall, ToolResult, ToolsToMessageToolSet, UserInput, WithStateGraphNodes } from "./types.cjs";
7
8
  import { ReactAgent } from "./ReactAgent.cjs";
@@ -12,7 +13,6 @@ import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
12
13
  import { StateDefinitionInit } from "@langchain/langgraph";
13
14
 
14
15
  //#region src/agents/index.d.ts
15
-
16
16
  /**
17
17
  * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools
18
18
  * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["InteropZodObject","InteropZodType","ClientTool","ServerTool","StateDefinitionInit","ResponseFormatUndefined","CreateAgentParams","AgentTypeConfig","CombineTools","AgentMiddleware","AnyAnnotationRoot","ExtractZodArrayTypes","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormat","JsonSchemaFormat","ReactAgent","createAgent","StructuredResponseFormat","TStateSchema","ContextSchema","TMiddleware","TTools","Record","Omit","JumpToTarget","Runtime","toolStrategy","providerStrategy","createMiddleware","MIDDLEWARE_BRAND","FakeToolCallingModel"],"sources":["../../src/agents/index.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { StateDefinitionInit } from \"@langchain/langgraph\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nimport type { CreateAgentParams, AgentTypeConfig, CombineTools } from \"./types.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot } from \"./middleware/types.js\";\nimport type { ExtractZodArrayTypes } from \"./types.js\";\nimport type { ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormat, JsonSchemaFormat } from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n/**\n * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools\n * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively\n * work towards solutions.\n *\n * The agent follows the ReAct pattern, interleaving reasoning steps with tool calls to iteratively\n * work towards solutions. It can handle multiple tool calls in sequence or parallel, maintain state\n * across interactions, and provide auditable decision processes.\n *\n * ## Core Components\n *\n * ### Model\n * The reasoning engine can be specified as:\n * - **String identifier**: `\"openai:gpt-4o\"` for simple setup\n * - **Model instance**: Configured model object for full control\n * - **Dynamic function**: Select models at runtime based on state\n *\n * ### Tools\n * Tools give agents the ability to take actions:\n * - Pass an array of tools created with the `tool` function\n * - Or provide a configured `ToolNode` for custom error handling\n *\n * ### Prompt\n * Shape how your agent approaches tasks:\n * - String for simple instructions\n * - SystemMessage for structured prompts\n * - Function for dynamic prompts based on state\n *\n * ### Middleware\n * Middleware allows you to extend the agent's behavior:\n * - Add pre/post-model processing for context injection or validation\n * - Add dynamic control flows, e.g. terminate invocation or retries\n * - Add human-in-the-loop capabilities\n * - Add tool calls to the agent\n * - Add tool results to the agent\n *\n * ## Advanced Features\n *\n * - **Structured Output**: Use `responseFormat` with a Zod schema to get typed responses\n * - **Memory**: Extend the state schema to remember information across interactions\n * - **Streaming**: Get real-time updates as the agent processes\n *\n * @param options - Configuration options for the agent\n * @param options.llm - The language model as an instance of a chat model\n * @param options.model - The language model as a string identifier, see more in {@link https://docs.langchain.com/oss/javascript/langchain/models#basic-usage | Models}.\n * @param options.tools - Array of tools or configured ToolNode\n * @param options.prompt - System instructions (string, SystemMessage, or function)\n * @param options.responseFormat - Zod schema for structured output\n * @param options.stateSchema - Custom state schema for memory\n * @param options.middleware - Array of middleware for extending agent behavior, see more in {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}.\n *\n * @returns A ReactAgent instance with `invoke` and `stream` methods\n *\n * @example Basic agent with tools\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const search = tool(\n * ({ query }) => `Results for: ${query}`,\n * {\n * name: \"search\",\n * description: \"Search for information\",\n * schema: z.object({\n * query: z.string().describe(\"The search query\"),\n * })\n * }\n * );\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [search],\n * });\n *\n * const result = await agent.invoke({\n * messages: [{ role: \"user\", content: \"Search for ReAct agents\" }],\n * });\n * ```\n *\n * @example Structured output\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const ContactInfo = z.object({\n * name: z.string(),\n * email: z.string(),\n * phone: z.string(),\n * });\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [],\n * responseFormat: ContactInfo,\n * });\n *\n * const result = await agent.invoke({\n * messages: [{\n * role: \"user\",\n * content: \"Extract: John Doe, john@example.com, (555) 123-4567\"\n * }],\n * });\n *\n * console.log(result.structuredResponse);\n * // { name: 'John Doe', email: 'john@example.com', phone: '(555) 123-4567' }\n * ```\n *\n * @example Streaming responses\n * ```ts\n * const stream = await agent.stream(\n * { messages: [{ role: \"user\", content: \"What's the weather?\" }] },\n * { streamMode: \"values\" }\n * );\n *\n * for await (const chunk of stream) {\n * // ...\n * }\n * ```\n *\n * @example With StateSchema\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { StateSchema, ReducedValue } from \"@langchain/langgraph\";\n * import { z } from \"zod\";\n *\n * const AgentState = new StateSchema({\n * userId: z.string(),\n * count: z.number().default(0),\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * { inputSchema: z.string(), reducer: (c, n) => [...c, n] }\n * ),\n * });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [searchTool],\n * stateSchema: AgentState,\n * });\n * ```\n */\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, InteropZodType<StructuredResponseFormat>> & {\n responseFormat: InteropZodType<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends readonly InteropZodType<any>[], TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any> ? ExtractZodArrayTypes<StructuredResponseFormat> : Record<string, any>, TStateSchema, ContextSchema, StructuredResponseFormat> & {\n responseFormat: StructuredResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any> ? ExtractZodArrayTypes<StructuredResponseFormat> : Record<string, any>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<Record<string, unknown>, TStateSchema, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<Record<string, unknown>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<Record<string, unknown>, TStateSchema, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<Record<string, unknown>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<Record<string, unknown>, TStateSchema, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<Record<string, unknown>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, TypedToolStrategy<StructuredResponseFormat>> & {\n responseFormat: TypedToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, ToolStrategy<StructuredResponseFormat>> & {\n responseFormat: ToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, ProviderStrategy<StructuredResponseFormat>> & {\n responseFormat: ProviderStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: Omit<CreateAgentParams<ResponseFormatUndefined, TStateSchema, ContextSchema, never>, \"responseFormat\"> & {\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<ResponseFormatUndefined, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: Omit<CreateAgentParams<ResponseFormatUndefined, TStateSchema, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<ResponseFormatUndefined, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, ResponseFormat> & {\n responseFormat: ResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport type { JumpToTarget } from \"./constants.js\";\nexport type { Runtime } from \"./runtime.js\";\nexport { toolStrategy, providerStrategy, ToolStrategy, ProviderStrategy, type TypedToolStrategy, type ResponseFormat, type ResponseFormatUndefined, } from \"./responses.js\";\nexport { createMiddleware } from \"./middleware.js\";\nexport { MIDDLEWARE_BRAND } from \"./middleware/types.js\";\nexport type * from \"./middleware/types.js\";\nexport { FakeToolCallingModel } from \"./tests/utils.js\";\nexport type { ReactAgent } from \"./ReactAgent.js\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AAA,qCACiC,eAAA,cACxB,eAAA,mCACoB,UAAA,GAAa,UAAA,gBACxC,UAAA,GACA,UAAA,IAAA,CAGJ,MAAA,EAAQ,IAAA,CACN,iBAAA,CACE,uBAAA,EACA,YAAA,EACA,aAAA;EAKF,cAAA;EACA,UAAA,GAAa,WAAA;EACb,KAAA,GAAQ,MAAA;AAAA,IAET,UAAA,CACD,eAAA,CACE,uBAAA,EACA,YAAA,EACA,aAAA,EACA,WAAA,EACA,YAAA,CAAa,MAAA,EAAQ,WAAA;AAAA,iBAKT,WAAA,kCACmB,MAAA,gBAAsB,MAAA,oCAClC,mBAAA,gDACC,iBAAA,GAAoB,gBAAA,GACxC,iBAAA,qCACiC,eAAA,cACxB,eAAA,mCACoB,UAAA,GAAa,UAAA,gBACxC,UAAA,GACA,UAAA,IAAA,CAGJ,MAAA,EAAQ,iBAAA,CACN,wBAAA,EACA,YAAA,EACA,aAAA,EACA,cAAA;EAEA,cAAA,EAAgB,cAAA;EAChB,UAAA,GAAa,WAAA;EACb,KAAA,GAAQ,MAAA;AAAA,IAET,UAAA,CACD,eAAA,CACE,wBAAA,EACA,YAAA,EACA,aAAA,EACA,WAAA,EACA,YAAA,CAAa,MAAA,EAAQ,WAAA"}
@@ -1,7 +1,8 @@
1
1
  import { MiddlewareError, MultipleStructuredOutputsError, MultipleToolsBoundError, StructuredOutputParsingError, ToolInvocationError } from "./errors.js";
2
2
  import { JsonSchemaFormat, ProviderStrategy, ResponseFormat, ResponseFormatUndefined, ToolStrategy, TypedToolStrategy, providerStrategy, toolStrategy } from "./responses.js";
3
3
  import { JumpToTarget } from "./constants.js";
4
- import { Runtime } from "./runtime.js";
4
+ import { Runtime as Runtime$1 } from "./runtime.js";
5
+ import { ModelRequest } from "./nodes/types.js";
5
6
  import { AfterAgentHook, AfterModelHook, AgentMiddleware, AnyAnnotationRoot, BeforeAgentHook, BeforeModelHook, DefaultMiddlewareTypeConfig, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContextSchema, InferMiddlewareContexts, InferMiddlewareFullContext, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareSchema, InferMiddlewareState, InferMiddlewareStates, InferMiddlewareToolsFromConfig, InferMiddlewareType, InferSchemaInput, MIDDLEWARE_BRAND, MiddlewareResult, MiddlewareTypeConfig, NormalizedSchemaInput, ResolveMiddlewareTypeConfig, ToAnnotationRoot, ToolCallHandler, ToolCallRequest, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook } from "./middleware/types.js";
6
7
  import { AgentTypeConfig, BuiltInState, CombineTools, CreateAgentParams, DefaultAgentTypeConfig, ExecutedToolCall, ExtractZodArrayTypes, InferAgentContext, InferAgentContextSchema, InferAgentMiddleware, InferAgentResponse, InferAgentState, InferAgentStateSchema, InferAgentTools, InferAgentType, InferMiddlewareTools, InferMiddlewareToolsArray, Interrupt, JumpTo, N, ResolveAgentTypeConfig, ToolCall, ToolResult, ToolsToMessageToolSet, UserInput, WithStateGraphNodes } from "./types.js";
7
8
  import { ReactAgent } from "./ReactAgent.js";
@@ -12,7 +13,6 @@ import { StateDefinitionInit } from "@langchain/langgraph";
12
13
  import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
13
14
 
14
15
  //#region src/agents/index.d.ts
15
-
16
16
  /**
17
17
  * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools
18
18
  * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["InteropZodObject","InteropZodType","ClientTool","ServerTool","StateDefinitionInit","ResponseFormatUndefined","CreateAgentParams","AgentTypeConfig","CombineTools","AgentMiddleware","AnyAnnotationRoot","ExtractZodArrayTypes","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormat","JsonSchemaFormat","ReactAgent","createAgent","StructuredResponseFormat","TStateSchema","ContextSchema","TMiddleware","TTools","Record","Omit","JumpToTarget","Runtime","toolStrategy","providerStrategy","createMiddleware","MIDDLEWARE_BRAND","FakeToolCallingModel"],"sources":["../../src/agents/index.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { StateDefinitionInit } from \"@langchain/langgraph\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nimport type { CreateAgentParams, AgentTypeConfig, CombineTools } from \"./types.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot } from \"./middleware/types.js\";\nimport type { ExtractZodArrayTypes } from \"./types.js\";\nimport type { ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormat, JsonSchemaFormat } from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n/**\n * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools\n * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively\n * work towards solutions.\n *\n * The agent follows the ReAct pattern, interleaving reasoning steps with tool calls to iteratively\n * work towards solutions. It can handle multiple tool calls in sequence or parallel, maintain state\n * across interactions, and provide auditable decision processes.\n *\n * ## Core Components\n *\n * ### Model\n * The reasoning engine can be specified as:\n * - **String identifier**: `\"openai:gpt-4o\"` for simple setup\n * - **Model instance**: Configured model object for full control\n * - **Dynamic function**: Select models at runtime based on state\n *\n * ### Tools\n * Tools give agents the ability to take actions:\n * - Pass an array of tools created with the `tool` function\n * - Or provide a configured `ToolNode` for custom error handling\n *\n * ### Prompt\n * Shape how your agent approaches tasks:\n * - String for simple instructions\n * - SystemMessage for structured prompts\n * - Function for dynamic prompts based on state\n *\n * ### Middleware\n * Middleware allows you to extend the agent's behavior:\n * - Add pre/post-model processing for context injection or validation\n * - Add dynamic control flows, e.g. terminate invocation or retries\n * - Add human-in-the-loop capabilities\n * - Add tool calls to the agent\n * - Add tool results to the agent\n *\n * ## Advanced Features\n *\n * - **Structured Output**: Use `responseFormat` with a Zod schema to get typed responses\n * - **Memory**: Extend the state schema to remember information across interactions\n * - **Streaming**: Get real-time updates as the agent processes\n *\n * @param options - Configuration options for the agent\n * @param options.llm - The language model as an instance of a chat model\n * @param options.model - The language model as a string identifier, see more in {@link https://docs.langchain.com/oss/javascript/langchain/models#basic-usage | Models}.\n * @param options.tools - Array of tools or configured ToolNode\n * @param options.prompt - System instructions (string, SystemMessage, or function)\n * @param options.responseFormat - Zod schema for structured output\n * @param options.stateSchema - Custom state schema for memory\n * @param options.middleware - Array of middleware for extending agent behavior, see more in {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}.\n *\n * @returns A ReactAgent instance with `invoke` and `stream` methods\n *\n * @example Basic agent with tools\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const search = tool(\n * ({ query }) => `Results for: ${query}`,\n * {\n * name: \"search\",\n * description: \"Search for information\",\n * schema: z.object({\n * query: z.string().describe(\"The search query\"),\n * })\n * }\n * );\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [search],\n * });\n *\n * const result = await agent.invoke({\n * messages: [{ role: \"user\", content: \"Search for ReAct agents\" }],\n * });\n * ```\n *\n * @example Structured output\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const ContactInfo = z.object({\n * name: z.string(),\n * email: z.string(),\n * phone: z.string(),\n * });\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [],\n * responseFormat: ContactInfo,\n * });\n *\n * const result = await agent.invoke({\n * messages: [{\n * role: \"user\",\n * content: \"Extract: John Doe, john@example.com, (555) 123-4567\"\n * }],\n * });\n *\n * console.log(result.structuredResponse);\n * // { name: 'John Doe', email: 'john@example.com', phone: '(555) 123-4567' }\n * ```\n *\n * @example Streaming responses\n * ```ts\n * const stream = await agent.stream(\n * { messages: [{ role: \"user\", content: \"What's the weather?\" }] },\n * { streamMode: \"values\" }\n * );\n *\n * for await (const chunk of stream) {\n * // ...\n * }\n * ```\n *\n * @example With StateSchema\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { StateSchema, ReducedValue } from \"@langchain/langgraph\";\n * import { z } from \"zod\";\n *\n * const AgentState = new StateSchema({\n * userId: z.string(),\n * count: z.number().default(0),\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * { inputSchema: z.string(), reducer: (c, n) => [...c, n] }\n * ),\n * });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [searchTool],\n * stateSchema: AgentState,\n * });\n * ```\n */\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, InteropZodType<StructuredResponseFormat>> & {\n responseFormat: InteropZodType<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends readonly InteropZodType<any>[], TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any> ? ExtractZodArrayTypes<StructuredResponseFormat> : Record<string, any>, TStateSchema, ContextSchema, StructuredResponseFormat> & {\n responseFormat: StructuredResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any> ? ExtractZodArrayTypes<StructuredResponseFormat> : Record<string, any>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<Record<string, unknown>, TStateSchema, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<Record<string, unknown>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<Record<string, unknown>, TStateSchema, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<Record<string, unknown>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<Record<string, unknown>, TStateSchema, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<Record<string, unknown>, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, TypedToolStrategy<StructuredResponseFormat>> & {\n responseFormat: TypedToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, ToolStrategy<StructuredResponseFormat>> & {\n responseFormat: ToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, ProviderStrategy<StructuredResponseFormat>> & {\n responseFormat: ProviderStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: Omit<CreateAgentParams<ResponseFormatUndefined, TStateSchema, ContextSchema, never>, \"responseFormat\"> & {\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<ResponseFormatUndefined, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: Omit<CreateAgentParams<ResponseFormatUndefined, TStateSchema, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<ResponseFormatUndefined, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, TStateSchema extends StateDefinitionInit | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, const TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], const TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]>(params: CreateAgentParams<StructuredResponseFormat, TStateSchema, ContextSchema, ResponseFormat> & {\n responseFormat: ResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n}): ReactAgent<AgentTypeConfig<StructuredResponseFormat, TStateSchema, ContextSchema, TMiddleware, CombineTools<TTools, TMiddleware>>>;\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport type { JumpToTarget } from \"./constants.js\";\nexport type { Runtime } from \"./runtime.js\";\nexport { toolStrategy, providerStrategy, ToolStrategy, ProviderStrategy, type TypedToolStrategy, type ResponseFormat, type ResponseFormatUndefined, } from \"./responses.js\";\nexport { createMiddleware } from \"./middleware.js\";\nexport { MIDDLEWARE_BRAND } from \"./middleware/types.js\";\nexport type * from \"./middleware/types.js\";\nexport { FakeToolCallingModel } from \"./tests/utils.js\";\nexport type { ReactAgent } from \"./ReactAgent.js\";\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIc;AACd;;;;;AAAyNS,iBApBjMS,WAoBiMT,CAAAA,iCApBpJe,MAoBoJf,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GApB9He,MAoB8Hf,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,EAAAA,qBApBpFL,mBAoBoFK,GAAAA,SAAAA,GAAAA,SAAAA,EAAAA,sBApBjBC,iBAoBiBD,GApBGT,gBAoBHS,GApBsBC,iBAoBtBD,EAAAA,0BAAAA,SApB4EA,eAoB5EA,EAAAA,GAAAA,SApByGA,eAoBzGA,EAAAA,EAAAA,qBAAAA,SAAAA,CApB2JP,UAoB3JO,GApBwKN,UAoBxKM,CAAAA,EAAAA,GAAAA,SAAAA,CApBkMP,UAoBlMO,GApB+MN,UAoB/MM,CAAAA,EAAAA,CAAAA,CAAAA,MAAAA,EApBsOH,iBAoBt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@@
1
- {"version":3,"file":"index.js","names":["params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n any\n >"],"sources":["../../src/agents/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { StateDefinitionInit } from \"@langchain/langgraph\";\n\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nimport type {\n CreateAgentParams,\n AgentTypeConfig,\n CombineTools,\n} from \"./types.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot } from \"./middleware/types.js\";\nimport type { ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools\n * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively\n * work towards solutions.\n *\n * The agent follows the ReAct pattern, interleaving reasoning steps with tool calls to iteratively\n * work towards solutions. It can handle multiple tool calls in sequence or parallel, maintain state\n * across interactions, and provide auditable decision processes.\n *\n * ## Core Components\n *\n * ### Model\n * The reasoning engine can be specified as:\n * - **String identifier**: `\"openai:gpt-4o\"` for simple setup\n * - **Model instance**: Configured model object for full control\n * - **Dynamic function**: Select models at runtime based on state\n *\n * ### Tools\n * Tools give agents the ability to take actions:\n * - Pass an array of tools created with the `tool` function\n * - Or provide a configured `ToolNode` for custom error handling\n *\n * ### Prompt\n * Shape how your agent approaches tasks:\n * - String for simple instructions\n * - SystemMessage for structured prompts\n * - Function for dynamic prompts based on state\n *\n * ### Middleware\n * Middleware allows you to extend the agent's behavior:\n * - Add pre/post-model processing for context injection or validation\n * - Add dynamic control flows, e.g. terminate invocation or retries\n * - Add human-in-the-loop capabilities\n * - Add tool calls to the agent\n * - Add tool results to the agent\n *\n * ## Advanced Features\n *\n * - **Structured Output**: Use `responseFormat` with a Zod schema to get typed responses\n * - **Memory**: Extend the state schema to remember information across interactions\n * - **Streaming**: Get real-time updates as the agent processes\n *\n * @param options - Configuration options for the agent\n * @param options.llm - The language model as an instance of a chat model\n * @param options.model - The language model as a string identifier, see more in {@link https://docs.langchain.com/oss/javascript/langchain/models#basic-usage | Models}.\n * @param options.tools - Array of tools or configured ToolNode\n * @param options.prompt - System instructions (string, SystemMessage, or function)\n * @param options.responseFormat - Zod schema for structured output\n * @param options.stateSchema - Custom state schema for memory\n * @param options.middleware - Array of middleware for extending agent behavior, see more in {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}.\n *\n * @returns A ReactAgent instance with `invoke` and `stream` methods\n *\n * @example Basic agent with tools\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const search = tool(\n * ({ query }) => `Results for: ${query}`,\n * {\n * name: \"search\",\n * description: \"Search for information\",\n * schema: z.object({\n * query: z.string().describe(\"The search query\"),\n * })\n * }\n * );\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [search],\n * });\n *\n * const result = await agent.invoke({\n * messages: [{ role: \"user\", content: \"Search for ReAct agents\" }],\n * });\n * ```\n *\n * @example Structured output\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const ContactInfo = z.object({\n * name: z.string(),\n * email: z.string(),\n * phone: z.string(),\n * });\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [],\n * responseFormat: ContactInfo,\n * });\n *\n * const result = await agent.invoke({\n * messages: [{\n * role: \"user\",\n * content: \"Extract: John Doe, john@example.com, (555) 123-4567\"\n * }],\n * });\n *\n * console.log(result.structuredResponse);\n * // { name: 'John Doe', email: 'john@example.com', phone: '(555) 123-4567' }\n * ```\n *\n * @example Streaming responses\n * ```ts\n * const stream = await agent.stream(\n * { messages: [{ role: \"user\", content: \"What's the weather?\" }] },\n * { streamMode: \"values\" }\n * );\n *\n * for await (const chunk of stream) {\n * // ...\n * }\n * ```\n *\n * @example With StateSchema\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { StateSchema, ReducedValue } from \"@langchain/langgraph\";\n * import { z } from \"zod\";\n *\n * const AgentState = new StateSchema({\n * userId: z.string(),\n * count: z.number().default(0),\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * { inputSchema: z.string(), reducer: (c, n) => [...c, n] }\n * ),\n * });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [searchTool],\n * stateSchema: AgentState,\n * });\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n InteropZodType<StructuredResponseFormat>\n > & {\n responseFormat: InteropZodType<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n StructuredResponseFormat extends readonly InteropZodType<any>[],\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n StructuredResponseFormat\n > & {\n responseFormat: StructuredResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TypedToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: TypedToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ProviderStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ProviderStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 8: Without responseFormat property at all - with proper middleware state typing\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & { middleware?: TMiddleware; tools?: TTools }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Implementation\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any>,\n TStateSchema extends StateDefinitionInit,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject,\n TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[],\n TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n any\n >\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n> {\n return new ReactAgent(params);\n}\n\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport type { JumpToTarget } from \"./constants.js\";\nexport type { Runtime } from \"./runtime.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type TypedToolStrategy,\n type ResponseFormat,\n type ResponseFormatUndefined,\n} from \"./responses.js\";\nexport { createMiddleware } from \"./middleware.js\";\nexport { MIDDLEWARE_BRAND } from \"./middleware/types.js\";\nexport type * from \"./middleware/types.js\";\nexport { FakeToolCallingModel } from \"./tests/utils.js\";\nexport type { ReactAgent } from \"./ReactAgent.js\";\n"],"mappings":";;;;;;;;AAmhBA,SAAgB,YAUdA,QAcA;AACA,QAAO,IAAI,WAAW;AACvB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/agents/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { StateDefinitionInit } from \"@langchain/langgraph\";\n\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nimport type {\n CreateAgentParams,\n AgentTypeConfig,\n CombineTools,\n} from \"./types.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot } from \"./middleware/types.js\";\nimport type { ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools\n * and middleware to create systems that can reason about tasks, decide which tools to use, and iteratively\n * work towards solutions.\n *\n * The agent follows the ReAct pattern, interleaving reasoning steps with tool calls to iteratively\n * work towards solutions. It can handle multiple tool calls in sequence or parallel, maintain state\n * across interactions, and provide auditable decision processes.\n *\n * ## Core Components\n *\n * ### Model\n * The reasoning engine can be specified as:\n * - **String identifier**: `\"openai:gpt-4o\"` for simple setup\n * - **Model instance**: Configured model object for full control\n * - **Dynamic function**: Select models at runtime based on state\n *\n * ### Tools\n * Tools give agents the ability to take actions:\n * - Pass an array of tools created with the `tool` function\n * - Or provide a configured `ToolNode` for custom error handling\n *\n * ### Prompt\n * Shape how your agent approaches tasks:\n * - String for simple instructions\n * - SystemMessage for structured prompts\n * - Function for dynamic prompts based on state\n *\n * ### Middleware\n * Middleware allows you to extend the agent's behavior:\n * - Add pre/post-model processing for context injection or validation\n * - Add dynamic control flows, e.g. terminate invocation or retries\n * - Add human-in-the-loop capabilities\n * - Add tool calls to the agent\n * - Add tool results to the agent\n *\n * ## Advanced Features\n *\n * - **Structured Output**: Use `responseFormat` with a Zod schema to get typed responses\n * - **Memory**: Extend the state schema to remember information across interactions\n * - **Streaming**: Get real-time updates as the agent processes\n *\n * @param options - Configuration options for the agent\n * @param options.llm - The language model as an instance of a chat model\n * @param options.model - The language model as a string identifier, see more in {@link https://docs.langchain.com/oss/javascript/langchain/models#basic-usage | Models}.\n * @param options.tools - Array of tools or configured ToolNode\n * @param options.prompt - System instructions (string, SystemMessage, or function)\n * @param options.responseFormat - Zod schema for structured output\n * @param options.stateSchema - Custom state schema for memory\n * @param options.middleware - Array of middleware for extending agent behavior, see more in {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}.\n *\n * @returns A ReactAgent instance with `invoke` and `stream` methods\n *\n * @example Basic agent with tools\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const search = tool(\n * ({ query }) => `Results for: ${query}`,\n * {\n * name: \"search\",\n * description: \"Search for information\",\n * schema: z.object({\n * query: z.string().describe(\"The search query\"),\n * })\n * }\n * );\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [search],\n * });\n *\n * const result = await agent.invoke({\n * messages: [{ role: \"user\", content: \"Search for ReAct agents\" }],\n * });\n * ```\n *\n * @example Structured output\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const ContactInfo = z.object({\n * name: z.string(),\n * email: z.string(),\n * phone: z.string(),\n * });\n *\n * const agent = createAgent({\n * llm: \"openai:gpt-4o\",\n * tools: [],\n * responseFormat: ContactInfo,\n * });\n *\n * const result = await agent.invoke({\n * messages: [{\n * role: \"user\",\n * content: \"Extract: John Doe, john@example.com, (555) 123-4567\"\n * }],\n * });\n *\n * console.log(result.structuredResponse);\n * // { name: 'John Doe', email: 'john@example.com', phone: '(555) 123-4567' }\n * ```\n *\n * @example Streaming responses\n * ```ts\n * const stream = await agent.stream(\n * { messages: [{ role: \"user\", content: \"What's the weather?\" }] },\n * { streamMode: \"values\" }\n * );\n *\n * for await (const chunk of stream) {\n * // ...\n * }\n * ```\n *\n * @example With StateSchema\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { StateSchema, ReducedValue } from \"@langchain/langgraph\";\n * import { z } from \"zod\";\n *\n * const AgentState = new StateSchema({\n * userId: z.string(),\n * count: z.number().default(0),\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * { inputSchema: z.string(), reducer: (c, n) => [...c, n] }\n * ),\n * });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [searchTool],\n * stateSchema: AgentState,\n * });\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n InteropZodType<StructuredResponseFormat>\n > & {\n responseFormat: InteropZodType<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n StructuredResponseFormat extends readonly InteropZodType<any>[],\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n StructuredResponseFormat\n > & {\n responseFormat: StructuredResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ExtractZodArrayTypes<StructuredResponseFormat> extends Record<string, any>\n ? ExtractZodArrayTypes<StructuredResponseFormat>\n : Record<string, any>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n Record<string, unknown>,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TypedToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: TypedToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ToolStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ToolStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ProviderStrategy<StructuredResponseFormat>\n > & {\n responseFormat: ProviderStrategy<StructuredResponseFormat>;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 8: Without responseFormat property at all - with proper middleware state typing\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & { middleware?: TMiddleware; tools?: TTools }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: Omit<\n CreateAgentParams<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n ResponseFormatUndefined,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n TStateSchema extends StateDefinitionInit | undefined = undefined,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject =\n AnyAnnotationRoot,\n const TMiddleware extends readonly AgentMiddleware[] =\n readonly AgentMiddleware[],\n const TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n middleware?: TMiddleware;\n tools?: TTools;\n }\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n>;\n\n// Implementation\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any>,\n TStateSchema extends StateDefinitionInit,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject,\n TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[],\n TTools extends readonly (ClientTool | ServerTool)[] = readonly (\n | ClientTool\n | ServerTool\n )[],\n>(\n params: CreateAgentParams<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n any\n >\n): ReactAgent<\n AgentTypeConfig<\n StructuredResponseFormat,\n TStateSchema,\n ContextSchema,\n TMiddleware,\n CombineTools<TTools, TMiddleware>\n >\n> {\n return new ReactAgent(params);\n}\n\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./nodes/types.js\";\nexport type { JumpToTarget } from \"./constants.js\";\nexport type { Runtime } from \"./runtime.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type TypedToolStrategy,\n type ResponseFormat,\n type ResponseFormatUndefined,\n} from \"./responses.js\";\nexport { createMiddleware } from \"./middleware.js\";\nexport { MIDDLEWARE_BRAND } from \"./middleware/types.js\";\nexport type * from \"./middleware/types.js\";\nexport { FakeToolCallingModel } from \"./tests/utils.js\";\nexport type { ReactAgent } from \"./ReactAgent.js\";\n"],"mappings":";;;;;;;;AAmhBA,SAAgB,YAUd,QAcA;AACA,QAAO,IAAI,WAAW,OAAO"}
@@ -1,5 +1,5 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const zod_v3 = require_rolldown_runtime.__toESM(require("zod/v3"));
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ let zod_v3 = require("zod/v3");
3
3
 
4
4
  //#region src/agents/middleware/constants.ts
5
5
  const RetrySchema = zod_v3.z.object({
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","names":["z"],"sources":["../../../src/agents/middleware/constants.ts"],"sourcesContent":["import { z } from \"zod/v3\";\n\nexport const RetrySchema = z.object({\n /**\n * Maximum number of retry attempts after the initial call.\n * Default is 2 retries (3 total attempts). Must be >= 0.\n */\n maxRetries: z.number().min(0).default(2),\n\n /**\n * Either an array of error constructors to retry on, or a function\n * that takes an error and returns `true` if it should be retried.\n * Default is to retry on all errors.\n */\n retryOn: z\n .union([\n z.function().args(z.instanceof(Error)).returns(z.boolean()),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n z.array(z.custom<new (...args: any[]) => Error>()),\n ])\n .default(() => () => true),\n\n /**\n * Multiplier for exponential backoff. Each retry waits\n * `initialDelayMs * (backoffFactor ** retryNumber)` milliseconds.\n * Set to 0.0 for constant delay. Default is 2.0.\n */\n backoffFactor: z.number().min(0).default(2.0),\n\n /**\n * Initial delay in milliseconds before first retry. Default is 1000 (1 second).\n */\n initialDelayMs: z.number().min(0).default(1000),\n\n /**\n * Maximum delay in milliseconds between retries. Caps exponential\n * backoff growth. Default is 60000 (60 seconds).\n */\n maxDelayMs: z.number().min(0).default(60000),\n\n /**\n * Whether to add random jitter (±25%) to delay to avoid thundering herd.\n * Default is `true`.\n */\n jitter: z.boolean().default(true),\n});\n"],"mappings":";;;;AAEA,MAAa,cAAcA,SAAE,OAAO;CAKlC,YAAYA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAOxC,SAASA,SACN,MAAM,CACLA,SAAE,UAAU,CAAC,KAAKA,SAAE,WAAW,MAAM,CAAC,CAAC,QAAQA,SAAE,SAAS,CAAC,EAE3DA,SAAE,MAAMA,SAAE,QAAuC,CAAC,AACnD,EAAC,CACD,QAAQ,MAAM,MAAM,KAAK;CAO5B,eAAeA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAI;CAK7C,gBAAgBA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAK;CAM/C,YAAYA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAM;CAM5C,QAAQA,SAAE,SAAS,CAAC,QAAQ,KAAK;AAClC,EAAC"}
1
+ {"version":3,"file":"constants.cjs","names":["z"],"sources":["../../../src/agents/middleware/constants.ts"],"sourcesContent":["import { z } from \"zod/v3\";\n\nexport const RetrySchema = z.object({\n /**\n * Maximum number of retry attempts after the initial call.\n * Default is 2 retries (3 total attempts). Must be >= 0.\n */\n maxRetries: z.number().min(0).default(2),\n\n /**\n * Either an array of error constructors to retry on, or a function\n * that takes an error and returns `true` if it should be retried.\n * Default is to retry on all errors.\n */\n retryOn: z\n .union([\n z.function().args(z.instanceof(Error)).returns(z.boolean()),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n z.array(z.custom<new (...args: any[]) => Error>()),\n ])\n .default(() => () => true),\n\n /**\n * Multiplier for exponential backoff. Each retry waits\n * `initialDelayMs * (backoffFactor ** retryNumber)` milliseconds.\n * Set to 0.0 for constant delay. Default is 2.0.\n */\n backoffFactor: z.number().min(0).default(2.0),\n\n /**\n * Initial delay in milliseconds before first retry. Default is 1000 (1 second).\n */\n initialDelayMs: z.number().min(0).default(1000),\n\n /**\n * Maximum delay in milliseconds between retries. Caps exponential\n * backoff growth. Default is 60000 (60 seconds).\n */\n maxDelayMs: z.number().min(0).default(60000),\n\n /**\n * Whether to add random jitter (±25%) to delay to avoid thundering herd.\n * Default is `true`.\n */\n jitter: z.boolean().default(true),\n});\n"],"mappings":";;;;AAEA,MAAa,cAAcA,SAAE,OAAO;CAKlC,YAAYA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAOxC,SAASA,SACN,MAAM,CACLA,SAAE,UAAU,CAAC,KAAKA,SAAE,WAAW,MAAM,CAAC,CAAC,QAAQA,SAAE,SAAS,CAAC,EAE3DA,SAAE,MAAMA,SAAE,QAAuC,CAAC,CACnD,CAAC,CACD,oBAAoB,KAAK;CAO5B,eAAeA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAI;CAK7C,gBAAgBA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAK;CAM/C,YAAYA,SAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAM;CAM5C,QAAQA,SAAE,SAAS,CAAC,QAAQ,KAAK;CAClC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../../../src/agents/middleware/constants.ts"],"sourcesContent":["import { z } from \"zod/v3\";\n\nexport const RetrySchema = z.object({\n /**\n * Maximum number of retry attempts after the initial call.\n * Default is 2 retries (3 total attempts). Must be >= 0.\n */\n maxRetries: z.number().min(0).default(2),\n\n /**\n * Either an array of error constructors to retry on, or a function\n * that takes an error and returns `true` if it should be retried.\n * Default is to retry on all errors.\n */\n retryOn: z\n .union([\n z.function().args(z.instanceof(Error)).returns(z.boolean()),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n z.array(z.custom<new (...args: any[]) => Error>()),\n ])\n .default(() => () => true),\n\n /**\n * Multiplier for exponential backoff. Each retry waits\n * `initialDelayMs * (backoffFactor ** retryNumber)` milliseconds.\n * Set to 0.0 for constant delay. Default is 2.0.\n */\n backoffFactor: z.number().min(0).default(2.0),\n\n /**\n * Initial delay in milliseconds before first retry. Default is 1000 (1 second).\n */\n initialDelayMs: z.number().min(0).default(1000),\n\n /**\n * Maximum delay in milliseconds between retries. Caps exponential\n * backoff growth. Default is 60000 (60 seconds).\n */\n maxDelayMs: z.number().min(0).default(60000),\n\n /**\n * Whether to add random jitter (±25%) to delay to avoid thundering herd.\n * Default is `true`.\n */\n jitter: z.boolean().default(true),\n});\n"],"mappings":";;;AAEA,MAAa,cAAc,EAAE,OAAO;CAKlC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAOxC,SAAS,EACN,MAAM,CACL,EAAE,UAAU,CAAC,KAAK,EAAE,WAAW,MAAM,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAE3D,EAAE,MAAM,EAAE,QAAuC,CAAC,AACnD,EAAC,CACD,QAAQ,MAAM,MAAM,KAAK;CAO5B,eAAe,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAI;CAK7C,gBAAgB,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAK;CAM/C,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAM;CAM5C,QAAQ,EAAE,SAAS,CAAC,QAAQ,KAAK;AAClC,EAAC"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../../../src/agents/middleware/constants.ts"],"sourcesContent":["import { z } from \"zod/v3\";\n\nexport const RetrySchema = z.object({\n /**\n * Maximum number of retry attempts after the initial call.\n * Default is 2 retries (3 total attempts). Must be >= 0.\n */\n maxRetries: z.number().min(0).default(2),\n\n /**\n * Either an array of error constructors to retry on, or a function\n * that takes an error and returns `true` if it should be retried.\n * Default is to retry on all errors.\n */\n retryOn: z\n .union([\n z.function().args(z.instanceof(Error)).returns(z.boolean()),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n z.array(z.custom<new (...args: any[]) => Error>()),\n ])\n .default(() => () => true),\n\n /**\n * Multiplier for exponential backoff. Each retry waits\n * `initialDelayMs * (backoffFactor ** retryNumber)` milliseconds.\n * Set to 0.0 for constant delay. Default is 2.0.\n */\n backoffFactor: z.number().min(0).default(2.0),\n\n /**\n * Initial delay in milliseconds before first retry. Default is 1000 (1 second).\n */\n initialDelayMs: z.number().min(0).default(1000),\n\n /**\n * Maximum delay in milliseconds between retries. Caps exponential\n * backoff growth. Default is 60000 (60 seconds).\n */\n maxDelayMs: z.number().min(0).default(60000),\n\n /**\n * Whether to add random jitter (±25%) to delay to avoid thundering herd.\n * Default is `true`.\n */\n jitter: z.boolean().default(true),\n});\n"],"mappings":";;;AAEA,MAAa,cAAc,EAAE,OAAO;CAKlC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAOxC,SAAS,EACN,MAAM,CACL,EAAE,UAAU,CAAC,KAAK,EAAE,WAAW,MAAM,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAE3D,EAAE,MAAM,EAAE,QAAuC,CAAC,CACnD,CAAC,CACD,oBAAoB,KAAK;CAO5B,eAAe,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAI;CAK7C,gBAAgB,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAK;CAM/C,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAM;CAM5C,QAAQ,EAAE,SAAS,CAAC,QAAQ,KAAK;CAClC,CAAC"}