langchain 1.0.2 → 1.0.3

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 (431) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/agents/ReactAgent.cjs +21 -41
  3. package/dist/agents/ReactAgent.cjs.map +1 -1
  4. package/dist/agents/ReactAgent.js +21 -41
  5. package/dist/agents/ReactAgent.js.map +1 -1
  6. package/dist/agents/annotation.cjs +1 -0
  7. package/dist/agents/annotation.cjs.map +1 -1
  8. package/dist/agents/annotation.js +1 -0
  9. package/dist/agents/annotation.js.map +1 -1
  10. package/dist/agents/middleware/callLimit.d.cts.map +1 -1
  11. package/dist/agents/middleware/callLimit.d.ts.map +1 -1
  12. package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
  13. package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
  14. package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
  15. package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
  16. package/dist/agents/middleware/hitl.cjs +7 -2
  17. package/dist/agents/middleware/hitl.cjs.map +1 -1
  18. package/dist/agents/middleware/hitl.d.cts.map +1 -1
  19. package/dist/agents/middleware/hitl.d.ts.map +1 -1
  20. package/dist/agents/middleware/hitl.js +7 -2
  21. package/dist/agents/middleware/hitl.js.map +1 -1
  22. package/dist/agents/middleware/index.cjs +2 -1
  23. package/dist/agents/middleware/index.d.cts +15 -0
  24. package/dist/agents/middleware/index.d.ts +14 -0
  25. package/dist/agents/middleware/index.js +2 -1
  26. package/dist/agents/middleware/modelCallLimit.cjs +145 -0
  27. package/dist/agents/middleware/modelCallLimit.cjs.map +1 -0
  28. package/dist/agents/middleware/modelCallLimit.d.cts +128 -0
  29. package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -0
  30. package/dist/agents/middleware/modelCallLimit.d.ts +128 -0
  31. package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -0
  32. package/dist/agents/middleware/modelCallLimit.js +144 -0
  33. package/dist/agents/middleware/modelCallLimit.js.map +1 -0
  34. package/dist/agents/middleware/promptCaching.d.cts.map +1 -1
  35. package/dist/agents/middleware/promptCaching.d.ts.map +1 -1
  36. package/dist/agents/middleware/summarization.cjs +4 -2
  37. package/dist/agents/middleware/summarization.cjs.map +1 -1
  38. package/dist/agents/middleware/summarization.d.cts +7 -6
  39. package/dist/agents/middleware/summarization.d.cts.map +1 -1
  40. package/dist/agents/middleware/summarization.d.ts +7 -6
  41. package/dist/agents/middleware/summarization.d.ts.map +1 -1
  42. package/dist/agents/middleware/summarization.js +4 -2
  43. package/dist/agents/middleware/summarization.js.map +1 -1
  44. package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -1
  45. package/dist/agents/middleware/toolCallLimit.cjs +205 -92
  46. package/dist/agents/middleware/toolCallLimit.cjs.map +1 -1
  47. package/dist/agents/middleware/toolCallLimit.d.cts +46 -37
  48. package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
  49. package/dist/agents/middleware/toolCallLimit.d.ts +46 -37
  50. package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
  51. package/dist/agents/middleware/toolCallLimit.js +206 -93
  52. package/dist/agents/middleware/toolCallLimit.js.map +1 -1
  53. package/dist/agents/middleware/toolRetry.cjs +224 -0
  54. package/dist/agents/middleware/toolRetry.cjs.map +1 -0
  55. package/dist/agents/middleware/toolRetry.d.cts +179 -0
  56. package/dist/agents/middleware/toolRetry.d.cts.map +1 -0
  57. package/dist/agents/middleware/toolRetry.d.ts +179 -0
  58. package/dist/agents/middleware/toolRetry.d.ts.map +1 -0
  59. package/dist/agents/middleware/toolRetry.js +223 -0
  60. package/dist/agents/middleware/toolRetry.js.map +1 -0
  61. package/dist/agents/middleware/types.d.cts +21 -19
  62. package/dist/agents/middleware/types.d.cts.map +1 -1
  63. package/dist/agents/middleware/types.d.ts +21 -19
  64. package/dist/agents/middleware/types.d.ts.map +1 -1
  65. package/dist/agents/middleware/utils.cjs +7 -0
  66. package/dist/agents/middleware/utils.cjs.map +1 -1
  67. package/dist/agents/middleware/utils.d.cts.map +1 -1
  68. package/dist/agents/middleware/utils.d.ts.map +1 -1
  69. package/dist/agents/middleware/utils.js +7 -1
  70. package/dist/agents/middleware/utils.js.map +1 -1
  71. package/dist/agents/middleware.cjs.map +1 -1
  72. package/dist/agents/middleware.d.cts +4 -4
  73. package/dist/agents/middleware.d.cts.map +1 -1
  74. package/dist/agents/middleware.d.ts +4 -4
  75. package/dist/agents/middleware.d.ts.map +1 -1
  76. package/dist/agents/middleware.js.map +1 -1
  77. package/dist/agents/nodes/AgentNode.cjs +21 -47
  78. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  79. package/dist/agents/nodes/AgentNode.js +22 -48
  80. package/dist/agents/nodes/AgentNode.js.map +1 -1
  81. package/dist/agents/nodes/ToolNode.cjs +12 -18
  82. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  83. package/dist/agents/nodes/ToolNode.js +12 -18
  84. package/dist/agents/nodes/ToolNode.js.map +1 -1
  85. package/dist/agents/nodes/middleware.cjs +9 -7
  86. package/dist/agents/nodes/middleware.cjs.map +1 -1
  87. package/dist/agents/nodes/middleware.js +10 -8
  88. package/dist/agents/nodes/middleware.js.map +1 -1
  89. package/dist/agents/nodes/types.d.cts +1 -1
  90. package/dist/agents/nodes/types.d.cts.map +1 -1
  91. package/dist/agents/nodes/types.d.ts +1 -1
  92. package/dist/agents/nodes/types.d.ts.map +1 -1
  93. package/dist/agents/nodes/utils.cjs +5 -1
  94. package/dist/agents/nodes/utils.cjs.map +1 -1
  95. package/dist/agents/nodes/utils.js +5 -1
  96. package/dist/agents/nodes/utils.js.map +1 -1
  97. package/dist/agents/runtime.d.cts +11 -27
  98. package/dist/agents/runtime.d.cts.map +1 -1
  99. package/dist/agents/runtime.d.ts +11 -27
  100. package/dist/agents/runtime.d.ts.map +1 -1
  101. package/dist/agents/state.cjs +45 -0
  102. package/dist/agents/state.cjs.map +1 -0
  103. package/dist/agents/state.js +44 -0
  104. package/dist/agents/state.js.map +1 -0
  105. package/dist/agents/types.d.cts +1 -1
  106. package/dist/agents/types.d.cts.map +1 -1
  107. package/dist/agents/types.d.ts +1 -1
  108. package/dist/agents/types.d.ts.map +1 -1
  109. package/dist/agents/utils.cjs +10 -2
  110. package/dist/agents/utils.cjs.map +1 -1
  111. package/dist/agents/utils.js +10 -2
  112. package/dist/agents/utils.js.map +1 -1
  113. package/dist/chat_models/universal.cjs +2 -2
  114. package/dist/chat_models/universal.cjs.map +1 -1
  115. package/dist/chat_models/universal.js +2 -2
  116. package/dist/chat_models/universal.js.map +1 -1
  117. package/dist/embeddings/cache_backed.cjs +140 -0
  118. package/dist/embeddings/cache_backed.cjs.map +1 -0
  119. package/dist/embeddings/cache_backed.d.cts +107 -0
  120. package/dist/embeddings/cache_backed.d.cts.map +1 -0
  121. package/dist/embeddings/cache_backed.d.ts +107 -0
  122. package/dist/embeddings/cache_backed.d.ts.map +1 -0
  123. package/dist/embeddings/cache_backed.js +134 -0
  124. package/dist/embeddings/cache_backed.js.map +1 -0
  125. package/dist/embeddings/fake.cjs +22 -0
  126. package/dist/embeddings/fake.cjs.map +1 -0
  127. package/dist/embeddings/fake.d.cts +1 -0
  128. package/dist/embeddings/fake.d.ts +1 -0
  129. package/dist/embeddings/fake.js +12 -0
  130. package/dist/embeddings/fake.js.map +1 -0
  131. package/dist/index.cjs +6 -18
  132. package/dist/index.cjs.map +1 -1
  133. package/dist/index.d.cts +3 -3
  134. package/dist/index.d.ts +3 -3
  135. package/dist/index.js +4 -5
  136. package/dist/index.js.map +1 -1
  137. package/dist/node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.cjs +248 -0
  138. package/dist/node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.cjs.map +1 -0
  139. package/dist/node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js +244 -0
  140. package/dist/node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js.map +1 -0
  141. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.cjs +3096 -0
  142. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.cjs.map +1 -0
  143. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.js +3095 -0
  144. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.js.map +1 -0
  145. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/env.cjs +12 -0
  146. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/env.cjs.map +1 -0
  147. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/env.js +12 -0
  148. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/env.js.map +1 -0
  149. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/constants.cjs +71 -0
  150. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/constants.cjs.map +1 -0
  151. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/constants.js +38 -0
  152. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/constants.js.map +1 -0
  153. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/translator.cjs +221 -0
  154. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/translator.cjs.map +1 -0
  155. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/translator.js +221 -0
  156. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/translator.js.map +1 -0
  157. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/index.cjs +11 -0
  158. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/index.cjs.map +1 -0
  159. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/index.js +11 -0
  160. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/index.js.map +1 -0
  161. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.cjs +703 -0
  162. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.cjs.map +1 -0
  163. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.js +702 -0
  164. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.js.map +1 -0
  165. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/constants.cjs +7 -0
  166. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/constants.cjs.map +1 -0
  167. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/constants.js +6 -0
  168. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/constants.js.map +1 -0
  169. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/fetch.cjs +29 -0
  170. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/fetch.cjs.map +1 -0
  171. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/fetch.js +28 -0
  172. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/fetch.js.map +1 -0
  173. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/otel.cjs +115 -0
  174. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/otel.cjs.map +1 -0
  175. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/otel.js +113 -0
  176. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/otel.js.map +1 -0
  177. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/_uuid.cjs +14 -0
  178. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/_uuid.cjs.map +1 -0
  179. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/_uuid.js +13 -0
  180. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/_uuid.js.map +1 -0
  181. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/async_caller.cjs +95 -0
  182. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/async_caller.cjs.map +1 -0
  183. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/async_caller.js +95 -0
  184. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/async_caller.js.map +1 -0
  185. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.cjs +136 -0
  186. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.cjs.map +1 -0
  187. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.js +131 -0
  188. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.js.map +1 -0
  189. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.cjs +102 -0
  190. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.cjs.map +1 -0
  191. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.js +99 -0
  192. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.js.map +1 -0
  193. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs +140 -0
  194. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs.map +1 -0
  195. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js +140 -0
  196. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js.map +1 -0
  197. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/messages.cjs +18 -0
  198. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/messages.cjs.map +1 -0
  199. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/messages.js +16 -0
  200. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/messages.js.map +1 -0
  201. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/project.cjs +10 -0
  202. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/project.cjs.map +1 -0
  203. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/project.js +10 -0
  204. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/project.js.map +1 -0
  205. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/prompts.cjs +30 -0
  206. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/prompts.cjs.map +1 -0
  207. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/prompts.js +30 -0
  208. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/prompts.js.map +1 -0
  209. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/warn.cjs +13 -0
  210. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/warn.cjs.map +1 -0
  211. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/warn.js +12 -0
  212. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/warn.js.map +1 -0
  213. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/index.cjs +6 -0
  214. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/index.js +6 -0
  215. package/dist/node_modules/.pnpm/p-finally@1.0.0/node_modules/p-finally/index.cjs +27 -0
  216. package/dist/node_modules/.pnpm/p-finally@1.0.0/node_modules/p-finally/index.cjs.map +1 -0
  217. package/dist/node_modules/.pnpm/p-finally@1.0.0/node_modules/p-finally/index.js +23 -0
  218. package/dist/node_modules/.pnpm/p-finally@1.0.0/node_modules/p-finally/index.js.map +1 -0
  219. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/index.cjs +267 -0
  220. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/index.cjs.map +1 -0
  221. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/index.js +263 -0
  222. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/index.js.map +1 -0
  223. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/lower-bound.cjs +32 -0
  224. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/lower-bound.cjs.map +1 -0
  225. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/lower-bound.js +28 -0
  226. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/lower-bound.js.map +1 -0
  227. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/priority-queue.cjs +49 -0
  228. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/priority-queue.cjs.map +1 -0
  229. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/priority-queue.js +45 -0
  230. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/priority-queue.js.map +1 -0
  231. package/dist/node_modules/.pnpm/p-retry@4.6.2/node_modules/p-retry/index.cjs +83 -0
  232. package/dist/node_modules/.pnpm/p-retry@4.6.2/node_modules/p-retry/index.cjs.map +1 -0
  233. package/dist/node_modules/.pnpm/p-retry@4.6.2/node_modules/p-retry/index.js +79 -0
  234. package/dist/node_modules/.pnpm/p-retry@4.6.2/node_modules/p-retry/index.js.map +1 -0
  235. package/dist/node_modules/.pnpm/p-timeout@3.2.0/node_modules/p-timeout/index.cjs +52 -0
  236. package/dist/node_modules/.pnpm/p-timeout@3.2.0/node_modules/p-timeout/index.cjs.map +1 -0
  237. package/dist/node_modules/.pnpm/p-timeout@3.2.0/node_modules/p-timeout/index.js +48 -0
  238. package/dist/node_modules/.pnpm/p-timeout@3.2.0/node_modules/p-timeout/index.js.map +1 -0
  239. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.cjs +16 -0
  240. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.cjs.map +1 -0
  241. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js +13 -0
  242. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js.map +1 -0
  243. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.cjs +77 -0
  244. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.cjs.map +1 -0
  245. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js +74 -0
  246. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js.map +1 -0
  247. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.cjs +115 -0
  248. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.cjs.map +1 -0
  249. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js +112 -0
  250. package/dist/node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js.map +1 -0
  251. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/comparator.cjs +90 -0
  252. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/comparator.cjs.map +1 -0
  253. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/comparator.js +86 -0
  254. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/comparator.js.map +1 -0
  255. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/range.cjs +294 -0
  256. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/range.cjs.map +1 -0
  257. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/range.js +290 -0
  258. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/range.js.map +1 -0
  259. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.cjs +191 -0
  260. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.cjs.map +1 -0
  261. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.js +187 -0
  262. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.js.map +1 -0
  263. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.cjs +24 -0
  264. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.cjs.map +1 -0
  265. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.js +20 -0
  266. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.js.map +1 -0
  267. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/cmp.cjs +51 -0
  268. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/cmp.cjs.map +1 -0
  269. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/cmp.js +47 -0
  270. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/cmp.js.map +1 -0
  271. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/coerce.cjs +48 -0
  272. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/coerce.cjs.map +1 -0
  273. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/coerce.js +44 -0
  274. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/coerce.js.map +1 -0
  275. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-build.cjs +25 -0
  276. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-build.cjs.map +1 -0
  277. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-build.js +21 -0
  278. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-build.js.map +1 -0
  279. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-loose.cjs +21 -0
  280. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-loose.cjs.map +1 -0
  281. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-loose.js +17 -0
  282. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare-loose.js.map +1 -0
  283. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare.cjs +21 -0
  284. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare.cjs.map +1 -0
  285. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare.js +17 -0
  286. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/compare.js.map +1 -0
  287. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/diff.cjs +43 -0
  288. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/diff.cjs.map +1 -0
  289. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/diff.js +39 -0
  290. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/diff.js.map +1 -0
  291. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/eq.cjs +21 -0
  292. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/eq.cjs.map +1 -0
  293. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/eq.js +17 -0
  294. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/eq.js.map +1 -0
  295. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gt.cjs +21 -0
  296. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gt.cjs.map +1 -0
  297. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gt.js +17 -0
  298. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gt.js.map +1 -0
  299. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gte.cjs +21 -0
  300. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gte.cjs.map +1 -0
  301. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gte.js +17 -0
  302. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/gte.js.map +1 -0
  303. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/inc.cjs +32 -0
  304. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/inc.cjs.map +1 -0
  305. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/inc.js +28 -0
  306. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/inc.js.map +1 -0
  307. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lt.cjs +21 -0
  308. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lt.cjs.map +1 -0
  309. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lt.js +17 -0
  310. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lt.js.map +1 -0
  311. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lte.cjs +21 -0
  312. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lte.cjs.map +1 -0
  313. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lte.js +17 -0
  314. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/lte.js.map +1 -0
  315. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/major.cjs +21 -0
  316. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/major.cjs.map +1 -0
  317. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/major.js +17 -0
  318. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/major.js.map +1 -0
  319. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/minor.cjs +21 -0
  320. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/minor.cjs.map +1 -0
  321. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/minor.js +17 -0
  322. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/minor.js.map +1 -0
  323. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/neq.cjs +21 -0
  324. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/neq.cjs.map +1 -0
  325. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/neq.js +17 -0
  326. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/neq.js.map +1 -0
  327. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.cjs +29 -0
  328. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.cjs.map +1 -0
  329. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.js +25 -0
  330. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.js.map +1 -0
  331. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/patch.cjs +21 -0
  332. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/patch.cjs.map +1 -0
  333. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/patch.js +17 -0
  334. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/patch.js.map +1 -0
  335. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/prerelease.cjs +24 -0
  336. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/prerelease.cjs.map +1 -0
  337. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/prerelease.js +20 -0
  338. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/prerelease.js.map +1 -0
  339. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rcompare.cjs +21 -0
  340. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rcompare.cjs.map +1 -0
  341. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rcompare.js +17 -0
  342. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rcompare.js.map +1 -0
  343. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rsort.cjs +21 -0
  344. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rsort.cjs.map +1 -0
  345. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rsort.js +17 -0
  346. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/rsort.js.map +1 -0
  347. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/satisfies.cjs +28 -0
  348. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/satisfies.cjs.map +1 -0
  349. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/satisfies.js +24 -0
  350. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/satisfies.js.map +1 -0
  351. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/sort.cjs +21 -0
  352. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/sort.cjs.map +1 -0
  353. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/sort.js +17 -0
  354. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/sort.js.map +1 -0
  355. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.cjs +24 -0
  356. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.cjs.map +1 -0
  357. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.js +20 -0
  358. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.js.map +1 -0
  359. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.cjs +146 -0
  360. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.cjs.map +1 -0
  361. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.js +142 -0
  362. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/index.js.map +1 -0
  363. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.cjs +41 -0
  364. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.cjs.map +1 -0
  365. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js +37 -0
  366. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js.map +1 -0
  367. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.cjs +19 -0
  368. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.cjs.map +1 -0
  369. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.js +15 -0
  370. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.js.map +1 -0
  371. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.cjs +32 -0
  372. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.cjs.map +1 -0
  373. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.js +28 -0
  374. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.js.map +1 -0
  375. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/lrucache.cjs +47 -0
  376. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/lrucache.cjs.map +1 -0
  377. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/lrucache.js +43 -0
  378. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/lrucache.js.map +1 -0
  379. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.cjs +25 -0
  380. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.cjs.map +1 -0
  381. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.js +21 -0
  382. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.js.map +1 -0
  383. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.cjs +94 -0
  384. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.cjs.map +1 -0
  385. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.js +90 -0
  386. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.js.map +1 -0
  387. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/gtr.cjs +21 -0
  388. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/gtr.cjs.map +1 -0
  389. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/gtr.js +17 -0
  390. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/gtr.js.map +1 -0
  391. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.cjs +25 -0
  392. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.cjs.map +1 -0
  393. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.js +21 -0
  394. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.js.map +1 -0
  395. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/ltr.cjs +21 -0
  396. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/ltr.cjs.map +1 -0
  397. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/ltr.js +17 -0
  398. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/ltr.js.map +1 -0
  399. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/max-satisfying.cjs +41 -0
  400. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/max-satisfying.cjs.map +1 -0
  401. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/max-satisfying.js +37 -0
  402. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/max-satisfying.js.map +1 -0
  403. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-satisfying.cjs +41 -0
  404. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-satisfying.cjs.map +1 -0
  405. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-satisfying.js +37 -0
  406. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-satisfying.js.map +1 -0
  407. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-version.cjs +55 -0
  408. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-version.cjs.map +1 -0
  409. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-version.js +51 -0
  410. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/min-version.js.map +1 -0
  411. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/outside.cjs +74 -0
  412. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/outside.cjs.map +1 -0
  413. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/outside.js +70 -0
  414. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/outside.js.map +1 -0
  415. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/simplify.cjs +48 -0
  416. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/simplify.cjs.map +1 -0
  417. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/simplify.js +44 -0
  418. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/simplify.js.map +1 -0
  419. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/subset.cjs +112 -0
  420. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/subset.cjs.map +1 -0
  421. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/subset.js +108 -0
  422. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/subset.js.map +1 -0
  423. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/to-comparators.cjs +21 -0
  424. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/to-comparators.cjs.map +1 -0
  425. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/to-comparators.js +17 -0
  426. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/to-comparators.js.map +1 -0
  427. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/valid.cjs +27 -0
  428. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/valid.cjs.map +1 -0
  429. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/valid.js +23 -0
  430. package/dist/node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/valid.js.map +1 -0
  431. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.cjs","names":["RunnableCallable","fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>","options: MiddlewareNodeOptions","#options","state: TStateSchema","config?: LangGraphRunnableConfig","relevantContext: Record<string, unknown>","runtime: Runtime<TContextSchema>","jumpToConstraint: JumpToTarget[] | undefined","constraint: string | undefined","getHookConstraint","parseJumpToTarget","derivePrivateState"],"sources":["../../../src/agents/nodes/middleware.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\nimport { interopParse } from \"@langchain/core/utils/types\";\n\nimport { RunnableCallable, RunnableCallableArgs } from \"../RunnableCallable.js\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime, PrivateState } from \"../runtime.js\";\nimport type { AgentMiddleware, MiddlewareResult } from \"../middleware/types.js\";\nimport { derivePrivateState, parseJumpToTarget } from \"./utils.js\";\nimport { getHookConstraint } from \"../middleware/utils.js\";\n\n/**\n * Named class for context objects to provide better error messages\n */\nclass AgentContext {}\nclass AgentRuntime {}\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>;\n\nexport interface MiddlewareNodeOptions {\n getPrivateState: () => PrivateState;\n}\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n #options: MiddlewareNodeOptions;\n\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n constructor(\n fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>,\n options: MiddlewareNodeOptions\n ) {\n super(fields);\n this.#options = options;\n }\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>\n ): Promise<MiddlewareResult<TStateSchema>> | MiddlewareResult<TStateSchema>;\n\n async invokeMiddleware(\n state: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Parse context using middleware's contextSchema to apply defaults and validation\n */\n if (this.middleware.contextSchema) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n const invokeContext = config?.context || {};\n for (const key of Object.keys(schemaShape)) {\n if (key in invokeContext) {\n relevantContext[key] = invokeContext[key];\n }\n }\n /**\n * Parse to apply defaults and validation, even if relevantContext is empty\n * This will throw if required fields are missing and no defaults exist\n */\n filteredContext = interopParse(\n this.middleware.contextSchema,\n relevantContext\n ) as TContextSchema;\n }\n }\n\n /**\n * ToDo: implement later\n */\n const runtime: Runtime<TContextSchema> = {\n context: filteredContext,\n writer: config?.writer,\n interrupt: config?.interrupt,\n signal: config?.signal,\n ...this.#options.getPrivateState(),\n };\n\n const result = await this.runHook(\n state,\n /**\n * assign runtime and context values into empty named class\n * instances to create a better error message.\n */\n Object.freeze(\n Object.assign(new AgentRuntime(), {\n ...runtime,\n context: Object.freeze(\n Object.assign(new AgentContext(), filteredContext)\n ),\n })\n )\n );\n delete result?._privateState;\n\n /**\n * If result is undefined, return current state\n */\n if (!result) {\n return { ...state, jumpTo: undefined };\n }\n\n /**\n * Verify that the jump target is allowed for the middleware\n */\n let jumpToConstraint: JumpToTarget[] | undefined;\n let constraint: string | undefined;\n\n if (this.name?.startsWith(\"BeforeAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeAgent);\n constraint = \"beforeAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"BeforeModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeModel);\n constraint = \"beforeModel.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterAgent);\n constraint = \"afterAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterModel);\n constraint = \"afterModel.canJumpTo\";\n }\n\n if (\n typeof result.jumpTo === \"string\" &&\n !jumpToConstraint?.includes(result.jumpTo as JumpToTarget)\n ) {\n const suggestion =\n jumpToConstraint && jumpToConstraint.length > 0\n ? `must be one of: ${jumpToConstraint?.join(\", \")}.`\n : constraint\n ? `no ${constraint} defined in middleware ${this.middleware.name}`\n : \"\";\n throw new Error(`Invalid jump target: ${result.jumpTo}, ${suggestion}.`);\n }\n\n const jumpTo = parseJumpToTarget(result.jumpTo as string);\n\n /**\n * If result is a control action, handle it\n */\n if (typeof result === \"object\" && \"type\" in result) {\n // Handle control actions\n if (result.type === \"terminate\") {\n if (result.error) {\n throw result.error;\n }\n return {\n ...state,\n ...(result.result || {}),\n jumpTo,\n };\n }\n\n throw new Error(`Invalid control action: ${JSON.stringify(result)}`);\n }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result, jumpTo };\n }\n\n get nodeOptions(): {\n input: z.ZodObject<TStateSchema>;\n } {\n return {\n input: derivePrivateState(\n this.middleware.stateSchema\n ) as z.ZodObject<TStateSchema>,\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAM,eAAN,MAAmB,CA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AAU,KAAK,MAAM,WAAW,kBAAkB,EAAE;GACnD,mBAAmBA,kCAAkB,KAAK,WAAW,WAAW;GAChE,aAAa;EACd;AAED,MACE,OAAO,OAAO,WAAW,YACzB,CAAC,kBAAkB,SAAS,OAAO,OAAuB,EAC1D;GACA,MAAM,aACJ,oBAAoB,iBAAiB,SAAS,IAC1C,CAAC,gBAAgB,EAAE,kBAAkB,KAAK,KAAK,CAAC,CAAC,CAAC,GAClD,aACA,CAAC,GAAG,EAAE,WAAW,uBAAuB,EAAE,KAAK,WAAW,MAAM,GAChE;AACN,SAAM,IAAI,MAAM,CAAC,qBAAqB,EAAE,OAAO,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;EACxE;EAED,MAAM,SAASC,gCAAkB,OAAO,OAAiB;;;;AAKzD,MAAI,OAAO,WAAW,YAAY,UAAU,QAAQ;AAElD,OAAI,OAAO,SAAS,aAAa;AAC/B,QAAI,OAAO,MACT,OAAM,OAAO;AAEf,WAAO;KACL,GAAG;KACH,GAAI,OAAO,UAAU,CAAE;KACvB;IACD;GACF;AAED,SAAM,IAAI,MAAM,CAAC,wBAAwB,EAAE,KAAK,UAAU,OAAO,EAAE;EACpE;;;;AAKD,SAAO;GAAE,GAAG;GAAO,GAAG;GAAQ;EAAQ;CACvC;CAED,IAAI,cAEF;AACA,SAAO,EACL,OAAOC,iCACL,KAAK,WAAW,YACjB,CACF;CACF;AACF"}
1
+ {"version":3,"file":"middleware.cjs","names":["RunnableCallable","fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>","options: MiddlewareNodeOptions","#options","invokeState: TStateSchema","config?: LangGraphRunnableConfig","relevantContext: Record<string, unknown>","state: TStateSchema","runtime: Runtime<TContextSchema>","jumpToConstraint: JumpToTarget[] | undefined","constraint: string | undefined","getHookConstraint","derivePrivateState"],"sources":["../../../src/agents/nodes/middleware.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\nimport { interopParse } from \"@langchain/core/utils/types\";\n\nimport { RunnableCallable, RunnableCallableArgs } from \"../RunnableCallable.js\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime } from \"../runtime.js\";\nimport type { AgentMiddleware, MiddlewareResult } from \"../middleware/types.js\";\nimport { derivePrivateState } from \"./utils.js\";\nimport { getHookConstraint } from \"../middleware/utils.js\";\n\n/**\n * Named class for context objects to provide better error messages\n */\nclass AgentContext {}\nclass AgentRuntime {}\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>;\n\nexport interface MiddlewareNodeOptions {\n getState: () => Record<string, unknown>;\n}\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n #options: MiddlewareNodeOptions;\n\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n constructor(\n fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>,\n options: MiddlewareNodeOptions\n ) {\n super(fields);\n this.#options = options;\n }\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>\n ): Promise<MiddlewareResult<TStateSchema>> | MiddlewareResult<TStateSchema>;\n\n async invokeMiddleware(\n invokeState: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Parse context using middleware's contextSchema to apply defaults and validation\n */\n if (this.middleware.contextSchema) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n const invokeContext = config?.context || {};\n for (const key of Object.keys(schemaShape)) {\n if (key in invokeContext) {\n relevantContext[key] = invokeContext[key];\n }\n }\n /**\n * Parse to apply defaults and validation, even if relevantContext is empty\n * This will throw if required fields are missing and no defaults exist\n */\n filteredContext = interopParse(\n this.middleware.contextSchema,\n relevantContext\n ) as TContextSchema;\n }\n }\n\n const state: TStateSchema = {\n ...this.#options.getState(),\n ...invokeState,\n /**\n * don't overwrite possible outdated messages from other middleware nodes\n */\n messages: invokeState.messages,\n };\n\n /**\n * ToDo: implement later\n */\n const runtime: Runtime<TContextSchema> = {\n context: filteredContext,\n writer: config?.writer,\n interrupt: config?.interrupt,\n signal: config?.signal,\n };\n\n const result = await this.runHook(\n state,\n /**\n * assign runtime and context values into empty named class\n * instances to create a better error message.\n */\n Object.freeze(\n Object.assign(new AgentRuntime(), {\n ...runtime,\n context: Object.freeze(\n Object.assign(new AgentContext(), filteredContext)\n ),\n })\n )\n );\n\n /**\n * If result is undefined, return current state\n */\n if (!result) {\n return { ...state, jumpTo: undefined };\n }\n\n /**\n * Verify that the jump target is allowed for the middleware\n */\n let jumpToConstraint: JumpToTarget[] | undefined;\n let constraint: string | undefined;\n\n if (this.name?.startsWith(\"BeforeAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeAgent);\n constraint = \"beforeAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"BeforeModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeModel);\n constraint = \"beforeModel.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterAgent);\n constraint = \"afterAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterModel);\n constraint = \"afterModel.canJumpTo\";\n }\n\n if (\n typeof result.jumpTo === \"string\" &&\n !jumpToConstraint?.includes(result.jumpTo as JumpToTarget)\n ) {\n const suggestion =\n jumpToConstraint && jumpToConstraint.length > 0\n ? `must be one of: ${jumpToConstraint?.join(\", \")}.`\n : constraint\n ? `no ${constraint} defined in middleware ${this.middleware.name}`\n : \"\";\n throw new Error(`Invalid jump target: ${result.jumpTo}, ${suggestion}.`);\n }\n\n /**\n * If result is a control action, handle it\n */\n if (typeof result === \"object\" && \"type\" in result) {\n // Handle control actions\n if (result.type === \"terminate\") {\n if (result.error) {\n throw result.error;\n }\n return {\n ...state,\n ...(result.result || {}),\n jumpTo: result.jumpTo,\n };\n }\n\n throw new Error(`Invalid control action: ${JSON.stringify(result)}`);\n }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result, jumpTo: result.jumpTo };\n }\n\n get nodeOptions(): {\n input: z.ZodObject<TStateSchema>;\n } {\n return {\n input: derivePrivateState(\n this.middleware.stateSchema\n ) as z.ZodObject<TStateSchema>,\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAM,eAAN,MAAmB,CAAE;AACrB,IAAM,eAAN,MAAmB,CAAE;AAUrB,IAAsB,iBAAtB,cAGUA,0CAAyD;CACjE;CAOA,YACEC,QACAC,SACA;EACA,MAAM,OAAO;EACb,KAAKC,WAAW;CACjB;CAOD,MAAM,iBACJC,aACAC,QACmC;;;;EAInC,IAAI,kBAAkB,CAAE;;;;AAIxB,MAAI,KAAK,WAAW,eAAe;;;;GAIjC,MAAM,cAAc,KAAK,WAAW,eAAe;AACnD,OAAI,aAAa;IACf,MAAMC,kBAA2C,CAAE;IACnD,MAAM,gBAAgB,QAAQ,WAAW,CAAE;AAC3C,SAAK,MAAM,OAAO,OAAO,KAAK,YAAY,CACxC,KAAI,OAAO,eACT,gBAAgB,OAAO,cAAc;;;;;IAOzC,iEACE,KAAK,WAAW,eAChB,gBACD;GACF;EACF;EAED,MAAMC,QAAsB;GAC1B,GAAG,KAAKJ,SAAS,UAAU;GAC3B,GAAG;GAIH,UAAU,YAAY;EACvB;;;;EAKD,MAAMK,UAAmC;GACvC,SAAS;GACT,QAAQ,QAAQ;GAChB,WAAW,QAAQ;GACnB,QAAQ,QAAQ;EACjB;EAED,MAAM,SAA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B,EAAE,KAAK,UAAU,OAAO,EAAE;EACpE;;;;AAKD,SAAO;GAAE,GAAG;GAAO,GAAG;GAAQ,QAAQ,OAAO;EAAQ;CACtD;CAED,IAAI,cAEF;AACA,SAAO,EACL,OAAOC,iCACL,KAAK,WAAW,YACjB,CACF;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { RunnableCallable } from "../RunnableCallable.js";
2
- import { derivePrivateState, parseJumpToTarget } from "./utils.js";
2
+ import { derivePrivateState } from "./utils.js";
3
3
  import { getHookConstraint } from "../middleware/utils.js";
4
4
  import { interopParse } from "@langchain/core/utils/types";
5
5
 
@@ -15,7 +15,7 @@ var MiddlewareNode = class extends RunnableCallable {
15
15
  super(fields);
16
16
  this.#options = options;
17
17
  }
18
- async invokeMiddleware(state, config) {
18
+ async invokeMiddleware(invokeState, config) {
19
19
  /**
20
20
  * Filter context based on middleware's contextSchema
21
21
  */
@@ -39,6 +39,11 @@ var MiddlewareNode = class extends RunnableCallable {
39
39
  filteredContext = interopParse(this.middleware.contextSchema, relevantContext);
40
40
  }
41
41
  }
42
+ const state = {
43
+ ...this.#options.getState(),
44
+ ...invokeState,
45
+ messages: invokeState.messages
46
+ };
42
47
  /**
43
48
  * ToDo: implement later
44
49
  */
@@ -46,8 +51,7 @@ var MiddlewareNode = class extends RunnableCallable {
46
51
  context: filteredContext,
47
52
  writer: config?.writer,
48
53
  interrupt: config?.interrupt,
49
- signal: config?.signal,
50
- ...this.#options.getPrivateState()
54
+ signal: config?.signal
51
55
  };
52
56
  const result = await this.runHook(
53
57
  state,
@@ -60,7 +64,6 @@ var MiddlewareNode = class extends RunnableCallable {
60
64
  context: Object.freeze(Object.assign(new AgentContext(), filteredContext))
61
65
  }))
62
66
  );
63
- delete result?._privateState;
64
67
  /**
65
68
  * If result is undefined, return current state
66
69
  */
@@ -90,7 +93,6 @@ var MiddlewareNode = class extends RunnableCallable {
90
93
  const suggestion = jumpToConstraint && jumpToConstraint.length > 0 ? `must be one of: ${jumpToConstraint?.join(", ")}.` : constraint ? `no ${constraint} defined in middleware ${this.middleware.name}` : "";
91
94
  throw new Error(`Invalid jump target: ${result.jumpTo}, ${suggestion}.`);
92
95
  }
93
- const jumpTo = parseJumpToTarget(result.jumpTo);
94
96
  /**
95
97
  * If result is a control action, handle it
96
98
  */
@@ -100,7 +102,7 @@ var MiddlewareNode = class extends RunnableCallable {
100
102
  return {
101
103
  ...state,
102
104
  ...result.result || {},
103
- jumpTo
105
+ jumpTo: result.jumpTo
104
106
  };
105
107
  }
106
108
  throw new Error(`Invalid control action: ${JSON.stringify(result)}`);
@@ -111,7 +113,7 @@ var MiddlewareNode = class extends RunnableCallable {
111
113
  return {
112
114
  ...state,
113
115
  ...result,
114
- jumpTo
116
+ jumpTo: result.jumpTo
115
117
  };
116
118
  }
117
119
  get nodeOptions() {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","names":["fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>","options: MiddlewareNodeOptions","#options","state: TStateSchema","config?: LangGraphRunnableConfig","relevantContext: Record<string, unknown>","runtime: Runtime<TContextSchema>","jumpToConstraint: JumpToTarget[] | undefined","constraint: string | undefined"],"sources":["../../../src/agents/nodes/middleware.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\nimport { interopParse } from \"@langchain/core/utils/types\";\n\nimport { RunnableCallable, RunnableCallableArgs } from \"../RunnableCallable.js\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime, PrivateState } from \"../runtime.js\";\nimport type { AgentMiddleware, MiddlewareResult } from \"../middleware/types.js\";\nimport { derivePrivateState, parseJumpToTarget } from \"./utils.js\";\nimport { getHookConstraint } from \"../middleware/utils.js\";\n\n/**\n * Named class for context objects to provide better error messages\n */\nclass AgentContext {}\nclass AgentRuntime {}\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>;\n\nexport interface MiddlewareNodeOptions {\n getPrivateState: () => PrivateState;\n}\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n #options: MiddlewareNodeOptions;\n\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n constructor(\n fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>,\n options: MiddlewareNodeOptions\n ) {\n super(fields);\n this.#options = options;\n }\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>\n ): Promise<MiddlewareResult<TStateSchema>> | MiddlewareResult<TStateSchema>;\n\n async invokeMiddleware(\n state: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Parse context using middleware's contextSchema to apply defaults and validation\n */\n if (this.middleware.contextSchema) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n const invokeContext = config?.context || {};\n for (const key of Object.keys(schemaShape)) {\n if (key in invokeContext) {\n relevantContext[key] = invokeContext[key];\n }\n }\n /**\n * Parse to apply defaults and validation, even if relevantContext is empty\n * This will throw if required fields are missing and no defaults exist\n */\n filteredContext = interopParse(\n this.middleware.contextSchema,\n relevantContext\n ) as TContextSchema;\n }\n }\n\n /**\n * ToDo: implement later\n */\n const runtime: Runtime<TContextSchema> = {\n context: filteredContext,\n writer: config?.writer,\n interrupt: config?.interrupt,\n signal: config?.signal,\n ...this.#options.getPrivateState(),\n };\n\n const result = await this.runHook(\n state,\n /**\n * assign runtime and context values into empty named class\n * instances to create a better error message.\n */\n Object.freeze(\n Object.assign(new AgentRuntime(), {\n ...runtime,\n context: Object.freeze(\n Object.assign(new AgentContext(), filteredContext)\n ),\n })\n )\n );\n delete result?._privateState;\n\n /**\n * If result is undefined, return current state\n */\n if (!result) {\n return { ...state, jumpTo: undefined };\n }\n\n /**\n * Verify that the jump target is allowed for the middleware\n */\n let jumpToConstraint: JumpToTarget[] | undefined;\n let constraint: string | undefined;\n\n if (this.name?.startsWith(\"BeforeAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeAgent);\n constraint = \"beforeAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"BeforeModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeModel);\n constraint = \"beforeModel.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterAgent);\n constraint = \"afterAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterModel);\n constraint = \"afterModel.canJumpTo\";\n }\n\n if (\n typeof result.jumpTo === \"string\" &&\n !jumpToConstraint?.includes(result.jumpTo as JumpToTarget)\n ) {\n const suggestion =\n jumpToConstraint && jumpToConstraint.length > 0\n ? `must be one of: ${jumpToConstraint?.join(\", \")}.`\n : constraint\n ? `no ${constraint} defined in middleware ${this.middleware.name}`\n : \"\";\n throw new Error(`Invalid jump target: ${result.jumpTo}, ${suggestion}.`);\n }\n\n const jumpTo = parseJumpToTarget(result.jumpTo as string);\n\n /**\n * If result is a control action, handle it\n */\n if (typeof result === \"object\" && \"type\" in result) {\n // Handle control actions\n if (result.type === \"terminate\") {\n if (result.error) {\n throw result.error;\n }\n return {\n ...state,\n ...(result.result || {}),\n jumpTo,\n };\n }\n\n throw new Error(`Invalid control action: ${JSON.stringify(result)}`);\n }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result, jumpTo };\n }\n\n get nodeOptions(): {\n input: z.ZodObject<TStateSchema>;\n } {\n return {\n input: derivePrivateState(\n this.middle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WAAU,KAAK,MAAM,WAAW,kBAAkB,EAAE;GACnD,mBAAmB,kBAAkB,KAAK,WAAW,WAAW;GAChE,aAAa;EACd,WAAU,KAAK,MAAM,WAAW,kBAAkB,EAAE;GACnD,mBAAmB,kBAAkB,KAAK,WAAW,WAAW;GAChE,aAAa;EACd;AAED,MACE,OAAO,OAAO,WAAW,YACzB,CAAC,kBAAkB,SAAS,OAAO,OAAuB,EAC1D;GACA,MAAM,aACJ,oBAAoB,iBAAiB,SAAS,IAC1C,CAAC,gBAAgB,EAAE,kBAAkB,KAAK,KAAK,CAAC,CAAC,CAAC,GAClD,aACA,CAAC,GAAG,EAAE,WAAW,uBAAuB,EAAE,KAAK,WAAW,MAAM,GAChE;AACN,SAAM,IAAI,MAAM,CAAC,qBAAqB,EAAE,OAAO,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;EACxE;EAED,MAAM,SAAS,kBAAkB,OAAO,OAAiB;;;;AAKzD,MAAI,OAAO,WAAW,YAAY,UAAU,QAAQ;AAElD,OAAI,OAAO,SAAS,aAAa;AAC/B,QAAI,OAAO,MACT,OAAM,OAAO;AAEf,WAAO;KACL,GAAG;KACH,GAAI,OAAO,UAAU,CAAE;KACvB;IACD;GACF;AAED,SAAM,IAAI,MAAM,CAAC,wBAAwB,EAAE,KAAK,UAAU,OAAO,EAAE;EACpE;;;;AAKD,SAAO;GAAE,GAAG;GAAO,GAAG;GAAQ;EAAQ;CACvC;CAED,IAAI,cAEF;AACA,SAAO,EACL,OAAO,mBACL,KAAK,WAAW,YACjB,CACF;CACF;AACF"}
1
+ {"version":3,"file":"middleware.js","names":["fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>","options: MiddlewareNodeOptions","#options","invokeState: TStateSchema","config?: LangGraphRunnableConfig","relevantContext: Record<string, unknown>","state: TStateSchema","runtime: Runtime<TContextSchema>","jumpToConstraint: JumpToTarget[] | undefined","constraint: string | undefined"],"sources":["../../../src/agents/nodes/middleware.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\nimport { interopParse } from \"@langchain/core/utils/types\";\n\nimport { RunnableCallable, RunnableCallableArgs } from \"../RunnableCallable.js\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime } from \"../runtime.js\";\nimport type { AgentMiddleware, MiddlewareResult } from \"../middleware/types.js\";\nimport { derivePrivateState } from \"./utils.js\";\nimport { getHookConstraint } from \"../middleware/utils.js\";\n\n/**\n * Named class for context objects to provide better error messages\n */\nclass AgentContext {}\nclass AgentRuntime {}\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>;\n\nexport interface MiddlewareNodeOptions {\n getState: () => Record<string, unknown>;\n}\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n #options: MiddlewareNodeOptions;\n\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n constructor(\n fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>,\n options: MiddlewareNodeOptions\n ) {\n super(fields);\n this.#options = options;\n }\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>\n ): Promise<MiddlewareResult<TStateSchema>> | MiddlewareResult<TStateSchema>;\n\n async invokeMiddleware(\n invokeState: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Parse context using middleware's contextSchema to apply defaults and validation\n */\n if (this.middleware.contextSchema) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n const invokeContext = config?.context || {};\n for (const key of Object.keys(schemaShape)) {\n if (key in invokeContext) {\n relevantContext[key] = invokeContext[key];\n }\n }\n /**\n * Parse to apply defaults and validation, even if relevantContext is empty\n * This will throw if required fields are missing and no defaults exist\n */\n filteredContext = interopParse(\n this.middleware.contextSchema,\n relevantContext\n ) as TContextSchema;\n }\n }\n\n const state: TStateSchema = {\n ...this.#options.getState(),\n ...invokeState,\n /**\n * don't overwrite possible outdated messages from other middleware nodes\n */\n messages: invokeState.messages,\n };\n\n /**\n * ToDo: implement later\n */\n const runtime: Runtime<TContextSchema> = {\n context: filteredContext,\n writer: config?.writer,\n interrupt: config?.interrupt,\n signal: config?.signal,\n };\n\n const result = await this.runHook(\n state,\n /**\n * assign runtime and context values into empty named class\n * instances to create a better error message.\n */\n Object.freeze(\n Object.assign(new AgentRuntime(), {\n ...runtime,\n context: Object.freeze(\n Object.assign(new AgentContext(), filteredContext)\n ),\n })\n )\n );\n\n /**\n * If result is undefined, return current state\n */\n if (!result) {\n return { ...state, jumpTo: undefined };\n }\n\n /**\n * Verify that the jump target is allowed for the middleware\n */\n let jumpToConstraint: JumpToTarget[] | undefined;\n let constraint: string | undefined;\n\n if (this.name?.startsWith(\"BeforeAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeAgent);\n constraint = \"beforeAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"BeforeModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeModel);\n constraint = \"beforeModel.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterAgent);\n constraint = \"afterAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterModel);\n constraint = \"afterModel.canJumpTo\";\n }\n\n if (\n typeof result.jumpTo === \"string\" &&\n !jumpToConstraint?.includes(result.jumpTo as JumpToTarget)\n ) {\n const suggestion =\n jumpToConstraint && jumpToConstraint.length > 0\n ? `must be one of: ${jumpToConstraint?.join(\", \")}.`\n : constraint\n ? `no ${constraint} defined in middleware ${this.middleware.name}`\n : \"\";\n throw new Error(`Invalid jump target: ${result.jumpTo}, ${suggestion}.`);\n }\n\n /**\n * If result is a control action, handle it\n */\n if (typeof result === \"object\" && \"type\" in result) {\n // Handle control actions\n if (result.type === \"terminate\") {\n if (result.error) {\n throw result.error;\n }\n return {\n ...state,\n ...(result.result || {}),\n jumpTo: result.jumpTo,\n };\n }\n\n throw new Error(`Invalid control action: ${JSON.stringify(result)}`);\n }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result, jumpTo: result.jumpTo };\n }\n\n get nodeOptions(): {\n input: z.ZodObject<TStateSchema>;\n } {\n return {\n input: derivePrivateState(\n this.middleware.stateSchema\n ) as z.ZodObject<TStateSchema>,\n };\n }\n}\n"],"mappings":";;;;;;;;;AAeA,IAAM,eAAN,MAAmB,CAAE;AACrB,IAAM,eAAN,MAAmB,CAAE;AAUrB,IAAsB,iBAAtB,cAGU,iBAAyD;CACjE;CAOA,YACEA,QACAC,SACA;EACA,MAAM,OAAO;EACb,KAAKC,WAAW;CACjB;CAOD,MAAM,iBACJC,aACAC,QACmC;;;;EAInC,IAAI,kBAAkB,CAAE;;;;AAIxB,MAAI,KAAK,WAAW,eAAe;;;;GAIjC,MAAM,cAAc,KAAK,WAAW,eAAe;AACnD,OAAI,aAAa;IACf,MAAMC,kBAA2C,CAAE;IACnD,MAAM,gBAAgB,QAAQ,WAAW,CAAE;AAC3C,SAAK,MAAM,OAAO,OAAO,KAAK,YAAY,CACxC,KAAI,OAAO,eACT,gBAAgB,OAAO,cAAc;;;;;IAOzC,kBAAkB,aAChB,KAAK,WAAW,eAChB,gBACD;GACF;EACF;EAED,MAAMC,QAAsB;GAC1B,GAAG,KAAKJ,SAAS,UAAU;GAC3B,GAAG;GAIH,UAAU,YAAY;EACvB;;;;EAKD,MAAMK,UAAmC;GACvC,SAAS;GACT,QAAQ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KACvB,QAAQ,OAAO;IAChB;GACF;AAED,SAAM,IAAI,MAAM,CAAC,wBAAwB,EAAE,KAAK,UAAU,OAAO,EAAE;EACpE;;;;AAKD,SAAO;GAAE,GAAG;GAAO,GAAG;GAAQ,QAAQ,OAAO;EAAQ;CACtD;CAED,IAAI,cAEF;AACA,SAAO,EACL,OAAO,mBACL,KAAK,WAAW,YACjB,CACF;CACF;AACF"}
@@ -1,7 +1,7 @@
1
- import { ClientTool, ServerTool } from "../tools.cjs";
2
1
  import { AgentBuiltInState, Runtime } from "../runtime.cjs";
3
2
  import { LanguageModelLike } from "@langchain/core/language_models/base";
4
3
  import { BaseMessage } from "@langchain/core/messages";
4
+ import { ClientTool, ServerTool } from "@langchain/core/tools";
5
5
 
6
6
  //#region src/agents/nodes/types.d.ts
7
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":["LanguageModelLike","BaseMessage","ServerTool","ClientTool","Runtime","AgentBuiltInState","ModelRequest","Record","TState","TContext"],"sources":["../../../src/agents/nodes/types.d.ts"],"sourcesContent":["import type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { ServerTool, ClientTool } from \"../tools.js\";\nimport type { Runtime, AgentBuiltInState } from \"../runtime.js\";\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n *\n * @template TState - The agent's state type, must extend Record<string, unknown>. Defaults to Record<string, unknown>.\n * @template TContext - The runtime context type for accessing metadata and control flow. Defaults to unknown.\n */\nexport interface ModelRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n systemPrompt?: string;\n /**\n * Tool choice configuration (model-specific format).\n * Can be one of:\n * - `\"auto\"`: means the model can pick between generating a message or calling one or more tools.\n * - `\"none\"`: means the model will not call any tool and instead generates a message.\n * - `\"required\"`: means the model must call one or more tools.\n * - `{ type: \"function\", function: { name: string } }`: The model will use the specified function.\n */\n toolChoice?: \"auto\" | \"none\" | \"required\" | {\n type: \"function\";\n function: {\n name: string;\n };\n };\n /**\n * The tools to make available for this step.\n */\n tools: (ServerTool | ClientTool)[];\n /**\n * The current agent state (includes both middleware state and built-in state).\n */\n state: TState & AgentBuiltInState;\n /**\n * The runtime context containing metadata, signal, writer, interrupt, etc.\n */\n runtime: Runtime<TContext>;\n /**\n * Additional settings to bind to the model when preparing it for invocation.\n * These settings are applied via `bindTools()` and can include parameters like\n * `headers`, `container`, etc. The model is re-bound on each request,\n * so these settings can vary per invocation.\n *\n * @example\n * ```ts\n * modelSettings: {\n * headers: { \"anthropic-beta\": \"code-execution-2025-08-25\" },\n * container: \"container_abc123\"\n * }\n * ```\n */\n modelSettings?: Record<string, unknown>;\n}\n"],"mappings":";;;;;;;;;AAWA;;;;;AAQcC,UARGK,YAQHL,CAAAA,eAR+BM,MAQ/BN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GARyDM,MAQzDN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,WAAAA,OAAAA,CAAAA,CAAAA;EAAW;;;EA0BR,KAAGI,EA9BTL,iBA8BSK;EAAiB;;;EAmBX,QAAA,EA7CZJ,WA6CY,EAAA;;;;;;;;;;;;;;;;;;;;;;UAvBdC,aAAaC;;;;SAIdK,SAASH;;;;WAIPD,QAAQK;;;;;;;;;;;;;;;kBAeDF"}
1
+ {"version":3,"file":"types.d.cts","names":["LanguageModelLike","BaseMessage","ServerTool","ClientTool","Runtime","AgentBuiltInState","ModelRequest","Record","TState","TContext"],"sources":["../../../src/agents/nodes/types.d.ts"],"sourcesContent":["import type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { ServerTool, ClientTool } from \"@langchain/core/tools\";\nimport type { Runtime, AgentBuiltInState } from \"../runtime.js\";\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n *\n * @template TState - The agent's state type, must extend Record<string, unknown>. Defaults to Record<string, unknown>.\n * @template TContext - The runtime context type for accessing metadata and control flow. Defaults to unknown.\n */\nexport interface ModelRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n systemPrompt?: string;\n /**\n * Tool choice configuration (model-specific format).\n * Can be one of:\n * - `\"auto\"`: means the model can pick between generating a message or calling one or more tools.\n * - `\"none\"`: means the model will not call any tool and instead generates a message.\n * - `\"required\"`: means the model must call one or more tools.\n * - `{ type: \"function\", function: { name: string } }`: The model will use the specified function.\n */\n toolChoice?: \"auto\" | \"none\" | \"required\" | {\n type: \"function\";\n function: {\n name: string;\n };\n };\n /**\n * The tools to make available for this step.\n */\n tools: (ServerTool | ClientTool)[];\n /**\n * The current agent state (includes both middleware state and built-in state).\n */\n state: TState & AgentBuiltInState;\n /**\n * The runtime context containing metadata, signal, writer, interrupt, etc.\n */\n runtime: Runtime<TContext>;\n /**\n * Additional settings to bind to the model when preparing it for invocation.\n * These settings are applied via `bindTools()` and can include parameters like\n * `headers`, `container`, etc. The model is re-bound on each request,\n * so these settings can vary per invocation.\n *\n * @example\n * ```ts\n * modelSettings: {\n * headers: { \"anthropic-beta\": \"code-execution-2025-08-25\" },\n * container: \"container_abc123\"\n * }\n * ```\n */\n modelSettings?: Record<string, unknown>;\n}\n"],"mappings":";;;;;;;;;AAWA;;;;;AAQcC,UARGK,YAQHL,CAAAA,eAR+BM,MAQ/BN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GARyDM,MAQzDN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,WAAAA,OAAAA,CAAAA,CAAAA;EAAW;;;EA0BR,KAAGI,EA9BTL,iBA8BSK;EAAiB;;;EAmBX,QAAA,EA7CZJ,WA6CY,EAAA;;;;;;;;;;;;;;;;;;;;;;UAvBdC,aAAaC;;;;SAIdK,SAASH;;;;WAIPD,QAAQK;;;;;;;;;;;;;;;kBAeDF"}
@@ -1,6 +1,6 @@
1
- import { ClientTool, ServerTool } from "../tools.js";
2
1
  import { AgentBuiltInState, Runtime } from "../runtime.js";
3
2
  import { BaseMessage } from "@langchain/core/messages";
3
+ import { ClientTool, ServerTool } from "@langchain/core/tools";
4
4
  import { LanguageModelLike } from "@langchain/core/language_models/base";
5
5
 
6
6
  //#region src/agents/nodes/types.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["LanguageModelLike","BaseMessage","ServerTool","ClientTool","Runtime","AgentBuiltInState","ModelRequest","Record","TState","TContext"],"sources":["../../../src/agents/nodes/types.d.ts"],"sourcesContent":["import type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { ServerTool, ClientTool } from \"../tools.js\";\nimport type { Runtime, AgentBuiltInState } from \"../runtime.js\";\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n *\n * @template TState - The agent's state type, must extend Record<string, unknown>. Defaults to Record<string, unknown>.\n * @template TContext - The runtime context type for accessing metadata and control flow. Defaults to unknown.\n */\nexport interface ModelRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n systemPrompt?: string;\n /**\n * Tool choice configuration (model-specific format).\n * Can be one of:\n * - `\"auto\"`: means the model can pick between generating a message or calling one or more tools.\n * - `\"none\"`: means the model will not call any tool and instead generates a message.\n * - `\"required\"`: means the model must call one or more tools.\n * - `{ type: \"function\", function: { name: string } }`: The model will use the specified function.\n */\n toolChoice?: \"auto\" | \"none\" | \"required\" | {\n type: \"function\";\n function: {\n name: string;\n };\n };\n /**\n * The tools to make available for this step.\n */\n tools: (ServerTool | ClientTool)[];\n /**\n * The current agent state (includes both middleware state and built-in state).\n */\n state: TState & AgentBuiltInState;\n /**\n * The runtime context containing metadata, signal, writer, interrupt, etc.\n */\n runtime: Runtime<TContext>;\n /**\n * Additional settings to bind to the model when preparing it for invocation.\n * These settings are applied via `bindTools()` and can include parameters like\n * `headers`, `container`, etc. The model is re-bound on each request,\n * so these settings can vary per invocation.\n *\n * @example\n * ```ts\n * modelSettings: {\n * headers: { \"anthropic-beta\": \"code-execution-2025-08-25\" },\n * container: \"container_abc123\"\n * }\n * ```\n */\n modelSettings?: Record<string, unknown>;\n}\n"],"mappings":";;;;;;;;;AAWA;;;;;AAQcC,UARGK,YAQHL,CAAAA,eAR+BM,MAQ/BN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GARyDM,MAQzDN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,WAAAA,OAAAA,CAAAA,CAAAA;EAAW;;;EA0BR,KAAGI,EA9BTL,iBA8BSK;EAAiB;;;EAmBX,QAAA,EA7CZJ,WA6CY,EAAA;;;;;;;;;;;;;;;;;;;;;;UAvBdC,aAAaC;;;;SAIdK,SAASH;;;;WAIPD,QAAQK;;;;;;;;;;;;;;;kBAeDF"}
1
+ {"version":3,"file":"types.d.ts","names":["LanguageModelLike","BaseMessage","ServerTool","ClientTool","Runtime","AgentBuiltInState","ModelRequest","Record","TState","TContext"],"sources":["../../../src/agents/nodes/types.d.ts"],"sourcesContent":["import type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { ServerTool, ClientTool } from \"@langchain/core/tools\";\nimport type { Runtime, AgentBuiltInState } from \"../runtime.js\";\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n *\n * @template TState - The agent's state type, must extend Record<string, unknown>. Defaults to Record<string, unknown>.\n * @template TContext - The runtime context type for accessing metadata and control flow. Defaults to unknown.\n */\nexport interface ModelRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n systemPrompt?: string;\n /**\n * Tool choice configuration (model-specific format).\n * Can be one of:\n * - `\"auto\"`: means the model can pick between generating a message or calling one or more tools.\n * - `\"none\"`: means the model will not call any tool and instead generates a message.\n * - `\"required\"`: means the model must call one or more tools.\n * - `{ type: \"function\", function: { name: string } }`: The model will use the specified function.\n */\n toolChoice?: \"auto\" | \"none\" | \"required\" | {\n type: \"function\";\n function: {\n name: string;\n };\n };\n /**\n * The tools to make available for this step.\n */\n tools: (ServerTool | ClientTool)[];\n /**\n * The current agent state (includes both middleware state and built-in state).\n */\n state: TState & AgentBuiltInState;\n /**\n * The runtime context containing metadata, signal, writer, interrupt, etc.\n */\n runtime: Runtime<TContext>;\n /**\n * Additional settings to bind to the model when preparing it for invocation.\n * These settings are applied via `bindTools()` and can include parameters like\n * `headers`, `container`, etc. The model is re-bound on each request,\n * so these settings can vary per invocation.\n *\n * @example\n * ```ts\n * modelSettings: {\n * headers: { \"anthropic-beta\": \"code-execution-2025-08-25\" },\n * container: \"container_abc123\"\n * }\n * ```\n */\n modelSettings?: Record<string, unknown>;\n}\n"],"mappings":";;;;;;;;;AAWA;;;;;AAQcC,UARGK,YAQHL,CAAAA,eAR+BM,MAQ/BN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GARyDM,MAQzDN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,WAAAA,OAAAA,CAAAA,CAAAA;EAAW;;;EA0BR,KAAGI,EA9BTL,iBA8BSK;EAAiB;;;EAmBX,QAAA,EA7CZJ,WA6CY,EAAA;;;;;;;;;;;;;;;;;;;;;;UAvBdC,aAAaC;;;;SAIdK,SAASH;;;;WAIPD,QAAQK;;;;;;;;;;;;;;;kBAeDF"}
@@ -13,7 +13,11 @@ const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@
13
13
  */
14
14
  async function initializeMiddlewareStates(middlewareList, state) {
15
15
  const middlewareStates = {};
16
- for (const middleware of middlewareList) if (middleware.stateSchema) {
16
+ for (const middleware of middlewareList) {
17
+ /**
18
+ * skip middleware if it doesn't have a state schema
19
+ */
20
+ if (!middleware.stateSchema) continue;
17
21
  const modifiedSchema = (0, __langchain_core_utils_types.interopZodObjectMakeFieldsOptional)(middleware.stateSchema, (key) => key.startsWith("_"));
18
22
  const parseResult = await (0, __langchain_core_utils_types.interopSafeParseAsync)(modifiedSchema, state);
19
23
  if (parseResult.success) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","z","privateShape: Record<string, any>","target?: string","END"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACAC,OAC8B;CAC9B,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,eACvB,KAAI,WAAW,aAAa;EAE1B,MAAM,sFACJ,WAAW,aACX,CAAC,QAAQ,IAAI,WAAW,IAAI,CAC7B;EAGD,MAAM,cAAc,8DAA4B,gBAAgB,MAAM;AAEtE,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;;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AChB,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
1
+ {"version":3,"file":"utils.cjs","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","z","privateShape: Record<string, any>","target?: string","END"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n /**\n * skip middleware if it doesn't have a state schema\n */\n if (!middleware.stateSchema) {\n continue;\n }\n\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map((issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`)\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACAC,OAC8B;CAC9B,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,gBAAgB;;;;AAIvC,MAAI,CAAC,WAAW,YACd;EAIF,MAAM,sFACJ,WAAW,aACX,CAAC,QAAQ,IAAI,WAAW,IAAI,CAC7B;EAGD,MAAM,cAAc,8DAA4B,gBAAgB,MAAM;AACtE,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;;EAKD,MAAM,iBAAiB,YAAY,MAAM,OACtC,OACC,CAACC,UACC,MAAM,SAAS,kBAAkB,MAAM,YAAY,WACtD,CACA,IAAI,CAACA,UAAoB,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,EAAE,EAAE,MAAM,SAAS,CAAC,CACzE,KAAK,KAAK;AAEb,QAAM,IAAI,MACR,CAAC,YAAY,EAAE,WAAW,KAAK,uDAAuD,EACjF,eAAe,0aAAI,EAad,YAAY,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,gBAAW,CACxD;CAEZ;AAED,QAAO;AACR;;;;;;;AAQD,SAAgB,mBACdC,aAC4B;CAC5B,MAAM,qBAAqB;EACzB,UAAUC,SAAE,OAAsB,MAAM,CAAE,EAAC;EAE3C,oBAAoBA,SAAE,KAAK,CAAC,UAAU;CACvC;AAED,KAAI,CAAC,YACH,QAAOA,SAAE,OAAO,mBAAmB;CAGrC,MAAM,EAAE,OAAO,GAAG;CAClB,MAAMC,eAAoC,EAAE,GAAG,mBAAoB;AAGnE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,aAAa,OAAO,MAAM,UAAU;MAEpC,aAAa,OAAO;AAKxB,QAAOD,SAAE,OAAO,aAAa;AAC9B;AAMD,SAAgB,kBAAkBE,QAAqC;AACrE,KAAI,CAAC,OACH,QAAO;;;;AAMT,KAAI;EAAC;EAAiB;EAASC;CAAI,EAAC,SAAS,OAAO,CAClD,QAAO;AAGT,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,MACb,QAAOA;AAGT,OAAM,IAAI,MACR,CAAC,qBAAqB,EAAE,OAAO,oCAAoC,CAAC;AAEvE;;;;;;;;;AAkBD,SAAgB,kBACd,GAAG,SACU;AACb,QAAO,YAAY,IACjB,QAAQ,OACN,CAAC,gBACC,gBAAgB,QAChB,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
@@ -12,7 +12,11 @@ import { interopSafeParseAsync, interopZodObjectMakeFieldsOptional } from "@lang
12
12
  */
13
13
  async function initializeMiddlewareStates(middlewareList, state) {
14
14
  const middlewareStates = {};
15
- for (const middleware of middlewareList) if (middleware.stateSchema) {
15
+ for (const middleware of middlewareList) {
16
+ /**
17
+ * skip middleware if it doesn't have a state schema
18
+ */
19
+ if (!middleware.stateSchema) continue;
16
20
  const modifiedSchema = interopZodObjectMakeFieldsOptional(middleware.stateSchema, (key) => key.startsWith("_"));
17
21
  const parseResult = await interopSafeParseAsync(modifiedSchema, state);
18
22
  if (parseResult.success) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","target?: string"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACAC,OAC8B;CAC9B,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,eACvB,KAAI,WAAW,aAAa;EAE1B,MAAM,iBAAiB,mCACrB,WAAW,aACX,CAAC,QAAQ,IAAI,WAAW,IAAI,CAC7B;EAGD,MAAM,cAAc,MAAM,sBAAsB,gBAAgB,MAAM;AAEtE,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;;EAKD,MAAM,iBAAiB,YAAY,MAAM,OACtC,OACC,CAACC,UACC,MAAM,SAAS,kBAAkB,MAAM,YAAY,WACtD,CACA,IACC,CAACA,UAAoB,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,EAAE,EAAE,MAAM,SAAS,CACrE,CACA,KAAK,KAAK;AAEb,QAAM,IAAI,MACR,CAAC,YAAY,EAAE,WAAW,KAAK,uDAAuD,EACjF,eAAe,0aAAI,EAad,YAAY,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,gBAAW,CACxD;CAEZ;AAGH,QAAO;AACR;;;;;;;AAQD,SAAgB,mBACdC,aAC4B;CAC5B,MAAM,qBAAqB;EACzB,UAAU,EAAE,OAAsB,MAAM,CAAE,EAAC;EAE3C,oBAAoB,EAAE,KAAK,CAAC,UAAU;CACvC;AAED,KAAI,CAAC,YACH,QAAO,EAAE,OAAO,mBAAmB;CAGrC,MAAM,EAAE,OAAO,GAAG;CAClB,MAAMC,eAAoC,EAAE,GAAG,mBAAoB;AAGnE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,aAAa,OAAO,MAAM,UAAU;MAEpC,aAAa,OAAO;AAKxB,QAAO,EAAE,OAAO,aAAa;AAC9B;AAMD,SAAgB,kBAAkBC,QAAqC;AACrE,KAAI,CAAC,OACH,QAAO;;;;AAMT,KAAI;EAAC;EAAiB;EAAS;CAAI,EAAC,SAAS,OAAO,CAClD,QAAO;AAGT,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,MACb,QAAO;AAGT,OAAM,IAAI,MACR,CAAC,qBAAqB,EAAE,OAAO,oCAAoC,CAAC;AAEvE;;;;;;;;;AAkBD,SAAgB,kBACd,GAAG,SACU;AACb,QAAO,YAAY,IACjB,QAAQ,OACN,CAAC,gBACC,gBAAgB,QAChB,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
1
+ {"version":3,"file":"utils.js","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","target?: string"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n /**\n * skip middleware if it doesn't have a state schema\n */\n if (!middleware.stateSchema) {\n continue;\n }\n\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map((issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`)\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACAC,OAC8B;CAC9B,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,gBAAgB;;;;AAIvC,MAAI,CAAC,WAAW,YACd;EAIF,MAAM,iBAAiB,mCACrB,WAAW,aACX,CAAC,QAAQ,IAAI,WAAW,IAAI,CAC7B;EAGD,MAAM,cAAc,MAAM,sBAAsB,gBAAgB,MAAM;AACtE,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;;EAKD,MAAM,iBAAiB,YAAY,MAAM,OACtC,OACC,CAACC,UACC,MAAM,SAAS,kBAAkB,MAAM,YAAY,WACtD,CACA,IAAI,CAACA,UAAoB,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,EAAE,EAAE,MAAM,SAAS,CAAC,CACzE,KAAK,KAAK;AAEb,QAAM,IAAI,MACR,CAAC,YAAY,EAAE,WAAW,KAAK,uDAAuD,EACjF,eAAe,0aAAI,EAad,YAAY,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,gBAAW,CACxD;CAEZ;AAED,QAAO;AACR;;;;;;;AAQD,SAAgB,mBACdC,aAC4B;CAC5B,MAAM,qBAAqB;EACzB,UAAU,EAAE,OAAsB,MAAM,CAAE,EAAC;EAE3C,oBAAoB,EAAE,KAAK,CAAC,UAAU;CACvC;AAED,KAAI,CAAC,YACH,QAAO,EAAE,OAAO,mBAAmB;CAGrC,MAAM,EAAE,OAAO,GAAG;CAClB,MAAMC,eAAoC,EAAE,GAAG,mBAAoB;AAGnE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,aAAa,OAAO,MAAM,UAAU;MAEpC,aAAa,OAAO;AAKxB,QAAO,EAAE,OAAO,aAAa;AAC9B;AAMD,SAAgB,kBAAkBC,QAAqC;AACrE,KAAI,CAAC,OACH,QAAO;;;;AAMT,KAAI;EAAC;EAAiB;EAAS;CAAI,EAAC,SAAS,OAAO,CAClD,QAAO;AAGT,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,MACb,QAAO;AAGT,OAAM,IAAI,MACR,CAAC,qBAAqB,EAAE,OAAO,oCAAoC,CAAC;AAEvE;;;;;;;;;AAkBD,SAAgB,kBACd,GAAG,SACU;AACb,QAAO,YAAY,IACjB,QAAQ,OACN,CAAC,gBACC,gBAAgB,QAChB,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
@@ -1,4 +1,5 @@
1
1
  import { BaseMessage } from "@langchain/core/messages";
2
+ import { BaseCallbackConfig } from "@langchain/core/callbacks/manager";
2
3
  import { InteropZodDefault, InteropZodOptional } from "@langchain/core/utils/types";
3
4
  import { PregelOptions, Runtime } from "@langchain/langgraph";
4
5
 
@@ -52,33 +53,12 @@ type WithMaybeContext<TContext> = undefined extends TContext ? {
52
53
  /**
53
54
  * Runtime information available to middleware (readonly).
54
55
  */
55
- type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & PrivateState & {
56
+ type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & {
56
57
  configurable?: {
57
58
  thread_id?: string;
58
59
  [key: string]: unknown;
59
60
  };
60
61
  };
61
- interface RunLevelPrivateState {
62
- /**
63
- * The number of times the model has been called at the run level.
64
- * This includes multiple agent invocations.
65
- */
66
- runModelCallCount: number;
67
- }
68
- interface ThreadLevelPrivateState {
69
- /**
70
- * The number of times the model has been called at the thread level.
71
- * This includes multiple agent invocations within different environments
72
- * using the same thread.
73
- */
74
- threadLevelCallCount: number;
75
- }
76
- /**
77
- * As private state we consider all information we want to track within
78
- * the lifecycle of the agent, without exposing it to the user. These informations
79
- * are propagated to the user as _readonly_ runtime properties.
80
- */
81
- interface PrivateState extends ThreadLevelPrivateState, RunLevelPrivateState {}
82
62
  /**
83
63
  * Helper type to check if a type is optional (includes undefined)
84
64
  */
@@ -97,6 +77,10 @@ undefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonU
97
77
  * Pregel options that are propagated to the agent
98
78
  */
99
79
  type CreateAgentPregelOptions = "configurable" | "durability" | "store" | "cache" | "signal" | "recursionLimit" | "maxConcurrency" | "timeout";
80
+ /**
81
+ * Pregel stream options that are propagated to the agent
82
+ */
83
+ type CreateAgentPregelStreamOptions = "encoding" | "streamMode";
100
84
  /**
101
85
  * Decide whether provided configuration requires a context
102
86
  */
@@ -104,20 +88,20 @@ type InvokeConfiguration<ContextSchema extends Record<string, any>> =
104
88
  /**
105
89
  * If the context schema is a default object, `context` can be optional
106
90
  */
107
- ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
91
+ ContextSchema extends InteropZodDefault<any> ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
108
92
  context?: Partial<ContextSchema>;
109
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
93
+ } : IsAllOptional<ContextSchema> extends true ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
110
94
  context?: Partial<ContextSchema>;
111
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
95
+ } : BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
112
96
  type StreamConfiguration<ContextSchema extends Record<string, any>> =
113
97
  /**
114
98
  * If the context schema is a default object, `context` can be optional
115
99
  */
116
100
  ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
117
101
  context?: Partial<ContextSchema>;
118
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & {
102
+ } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & {
119
103
  context?: Partial<ContextSchema>;
120
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & WithMaybeContext<ContextSchema>;
104
+ } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & WithMaybeContext<ContextSchema>;
121
105
  //#endregion
122
106
  export { AgentBuiltInState, InvokeConfiguration, Runtime$1 as Runtime, StreamConfiguration };
123
107
  //# sourceMappingURL=runtime.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.cts","names":["InteropZodOptional","InteropZodDefault","Runtime","LangGraphRuntime","PregelOptions","BaseMessage","ResponseFormatUndefined","AgentBuiltInState","Record","IsOptionalZodObject","T","IsDefaultZodObject","WithMaybeContext","TContext","Omit","Partial","PrivateState","RunLevelPrivateState","ThreadLevelPrivateState","InternalAgentState","StructuredResponseType","IsOptionalType","ExtractNonUndefined","IsAllOptional","CreateAgentPregelOptions","InvokeConfiguration","ContextSchema","Pick","StreamConfiguration"],"sources":["../../src/agents/runtime.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodOptional } from \"@langchain/core/utils/types\";\nimport type { InteropZodDefault } from \"@langchain/core/utils/types\";\nimport type { Runtime as LangGraphRuntime, PregelOptions } from \"@langchain/langgraph\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n /**\n * Array of messages representing the conversation history.\n *\n * This includes all messages exchanged during the agent's execution:\n * - Human messages: Input from the user\n * - AI messages: Responses from the language model\n * - Tool messages: Results from tool executions\n * - System messages: System-level instructions or information\n *\n * Messages are accumulated throughout the agent's lifecycle and can be\n * accessed or modified by middleware hooks during execution.\n */\n messages: BaseMessage[];\n /**\n * Structured response data returned by the agent when a `responseFormat` is configured.\n *\n * This property is only populated when you provide a `responseFormat` schema\n * (as Zod or JSON schema) to the agent configuration. The agent will format\n * its final output to match the specified schema and store it in this property.\n *\n * Note: The type is specified as `Record<string, unknown>` because TypeScript cannot\n * infer the actual response format type in contexts like middleware, where the agent's\n * generic type parameters are not accessible. You may need to cast this to your specific\n * response type when accessing it.\n */\n structuredResponse?: Record<string, unknown>;\n};\n/**\n * Type helper to check if TContext is an optional Zod schema\n */\ntype IsOptionalZodObject<T> = T extends InteropZodOptional<any> ? true : false;\ntype IsDefaultZodObject<T> = T extends InteropZodDefault<any> ? true : false;\nexport type WithMaybeContext<TContext> = undefined extends TContext ? {\n readonly context?: TContext;\n} : IsOptionalZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : IsDefaultZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : {\n readonly context: TContext;\n};\n/**\n * Runtime information available to middleware (readonly).\n */\nexport type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, \"context\" | \"configurable\">> & WithMaybeContext<TContext> & PrivateState & {\n configurable?: {\n thread_id?: string;\n [key: string]: unknown;\n };\n};\nexport interface RunLevelPrivateState {\n /**\n * The number of times the model has been called at the run level.\n * This includes multiple agent invocations.\n */\n runModelCallCount: number;\n}\nexport interface ThreadLevelPrivateState {\n /**\n * The number of times the model has been called at the thread level.\n * This includes multiple agent invocations within different environments\n * using the same thread.\n */\n threadLevelCallCount: number;\n}\n/**\n * As private state we consider all information we want to track within\n * the lifecycle of the agent, without exposing it to the user. These informations\n * are propagated to the user as _readonly_ runtime properties.\n */\nexport interface PrivateState extends ThreadLevelPrivateState, RunLevelPrivateState {\n}\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n _privateState?: PrivateState;\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\n/**\n * Helper type to check if a type is optional (includes undefined)\n */\ntype IsOptionalType<T> = undefined extends T ? true : false;\n/**\n * Extract non-undefined part of a union that includes undefined\n */\ntype ExtractNonUndefined<T> = T extends undefined ? never : T;\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = \n// If T includes undefined, then it's optional (can be omitted entirely)\nundefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonUndefined<T> extends Record<string, any> ? {} extends ExtractNonUndefined<T> ? true : false : IsOptionalType<T>;\n/**\n * Pregel options that are propagated to the agent\n */\ntype CreateAgentPregelOptions = \"configurable\" | \"durability\" | \"store\" | \"cache\" | \"signal\" | \"recursionLimit\" | \"maxConcurrency\" | \"timeout\";\n/**\n * Decide whether provided configuration requires a context\n */\nexport type InvokeConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;\nexport type StreamConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | \"streamMode\">> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | \"streamMode\">> & WithMaybeContext<ContextSchema>;\nexport {};\n"],"mappings":";;;;;;;;;AAmC+B,KA1BnBO,iBAAAA,GA0BmB;EAK1BE;;;;AAAqD;AAAA;;;;AACF;AACxD;;EAA4B,QAA+BI,EApB7CR,WAoB6CQ,EAAAA;EAAQ;;;;;;;;AAOrC;AAK9B;;;EAAgF,kBAAzBV,CAAAA,EAnB9BK,MAmB8BL,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;CAAgB;;;;KAdlEM,mBAc0IO,CAAAA,CAAAA,CAAAA,GAdjHN,CAciHM,SAdvGhB,kBAcuGgB,CAAAA,GAAAA,CAAAA,GAAAA,IAAAA,GAAAA,KAAAA;AAAY,KAbtJL,kBAasJ,CAAA,CAAA,CAAA,GAb9HD,CAa8H,SAbpHT,iBAaoH,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAM1IgB,KAlBLL,gBAkByB,CAAA,QAAA,CAAA,GAAA,SAAA,SAlBsBC,QAkBtB,GAAA;EAOpBK,SAAAA,OAAAA,CAAAA,EAxBML,QAwBiB;AAaxC,CAAA,GApCIJ,mBAoCyB,CApCLI,QAoCK,CAAA,SAAA,IAAA,GAAA;EAAA,SAAA,OAAA,CAAA,EAnCNA,QAmCM;CAAA,GAlCzBF,kBAkCkCO,CAlCfL,QAkCeK,CAAAA,SAAAA,IAAAA,GAAAA;EAAuB,SAAED,OAAAA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BAA8BoB;YAC7ET,QAAQW;IAClBX,QAAQY,KAAKvB,8BAA8BoB,4CAA4CZ,iBAAiBc"}
1
+ {"version":3,"file":"runtime.d.cts","names":["InteropZodOptional","InteropZodDefault","Runtime","LangGraphRuntime","PregelOptions","BaseMessage","BaseCallbackConfig","ResponseFormatUndefined","AgentBuiltInState","Record","IsOptionalZodObject","T","IsDefaultZodObject","WithMaybeContext","TContext","Omit","Partial","InternalAgentState","StructuredResponseType","IsOptionalType","ExtractNonUndefined","IsAllOptional","CreateAgentPregelOptions","CreateAgentPregelStreamOptions","InvokeConfiguration","ContextSchema","Pick","StreamConfiguration"],"sources":["../../src/agents/runtime.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodOptional } from \"@langchain/core/utils/types\";\nimport type { InteropZodDefault } from \"@langchain/core/utils/types\";\nimport type { Runtime as LangGraphRuntime, PregelOptions } from \"@langchain/langgraph\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseCallbackConfig } from \"@langchain/core/callbacks/manager\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n /**\n * Array of messages representing the conversation history.\n *\n * This includes all messages exchanged during the agent's execution:\n * - Human messages: Input from the user\n * - AI messages: Responses from the language model\n * - Tool messages: Results from tool executions\n * - System messages: System-level instructions or information\n *\n * Messages are accumulated throughout the agent's lifecycle and can be\n * accessed or modified by middleware hooks during execution.\n */\n messages: BaseMessage[];\n /**\n * Structured response data returned by the agent when a `responseFormat` is configured.\n *\n * This property is only populated when you provide a `responseFormat` schema\n * (as Zod or JSON schema) to the agent configuration. The agent will format\n * its final output to match the specified schema and store it in this property.\n *\n * Note: The type is specified as `Record<string, unknown>` because TypeScript cannot\n * infer the actual response format type in contexts like middleware, where the agent's\n * generic type parameters are not accessible. You may need to cast this to your specific\n * response type when accessing it.\n */\n structuredResponse?: Record<string, unknown>;\n};\n/**\n * Type helper to check if TContext is an optional Zod schema\n */\ntype IsOptionalZodObject<T> = T extends InteropZodOptional<any> ? true : false;\ntype IsDefaultZodObject<T> = T extends InteropZodDefault<any> ? true : false;\nexport type WithMaybeContext<TContext> = undefined extends TContext ? {\n readonly context?: TContext;\n} : IsOptionalZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : IsDefaultZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : {\n readonly context: TContext;\n};\n/**\n * Runtime information available to middleware (readonly).\n */\nexport type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, \"context\" | \"configurable\">> & WithMaybeContext<TContext> & {\n configurable?: {\n thread_id?: string;\n [key: string]: unknown;\n };\n};\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\n/**\n * Helper type to check if a type is optional (includes undefined)\n */\ntype IsOptionalType<T> = undefined extends T ? true : false;\n/**\n * Extract non-undefined part of a union that includes undefined\n */\ntype ExtractNonUndefined<T> = T extends undefined ? never : T;\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = \n// If T includes undefined, then it's optional (can be omitted entirely)\nundefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonUndefined<T> extends Record<string, any> ? {} extends ExtractNonUndefined<T> ? true : false : IsOptionalType<T>;\n/**\n * Pregel options that are propagated to the agent\n */\ntype CreateAgentPregelOptions = \"configurable\" | \"durability\" | \"store\" | \"cache\" | \"signal\" | \"recursionLimit\" | \"maxConcurrency\" | \"timeout\";\n/**\n * Pregel stream options that are propagated to the agent\n */\ntype CreateAgentPregelStreamOptions = \"encoding\" | \"streamMode\";\n/**\n * Decide whether provided configuration requires a context\n */\nexport type InvokeConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;\nexport type StreamConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & WithMaybeContext<ContextSchema>;\nexport {};\n"],"mappings":";;;;;;;;;;AAoC+B,KA1BnBQ,iBAAAA,GA0BmB;EAK1BE;;;;AAAqD;AAAA;;;;AACF;AACxD;;EAA4B,QAA+BI,EApB7CT,WAoB6CS,EAAAA;EAAQ;;;;;;;;AAOrC;AAK9B;;;EAAgF,kBAAzBX,CAAAA,EAnB9BM,MAmB8BN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;CAAgB;;;;AAA2D,KAd7HO,mBAc6H,CAAA,CAAA,CAAA,GAdpGC,CAcoG,SAd1FX,kBAc0F,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAU/H,KAvBEY,kBA2Bc,CAAA,CAAA,CAAA,GA3BUD,CA2BV,SA3BoBV,iBA2BK,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAIvCmB,KA9BOP,gBA8BY,CAAA,QAAA,CAAA,GAAA,SAAA,SA9BmCC,QA8BnC,GAAA;EAA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AAA,CAAAA,CAAAA;;;;AAA/CS,aAEIJ,SAFkBpB,iBAElBoB,CAAAA,GAAAA,CAAAA,GAF2CL,OAE3CK,CAFmDK,IAEnDL,CAFwDjB,aAExDiB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAFsFC,wBAEtFD,CAAAA,CAAAA,GAAAA;EAAa,OAA4CjB,CAAAA,EAD/CY,OAC+CZ,CADvCqB,aACuCrB,CAAAA;CAAa,GAAtEiB,aAAuFC,CAAzEG,aAAyEH,CAAAA,SAAAA,IAAAA,GAA3CN,OAA2CM,CAAnCI,IAAmCJ,CAA9BlB,aAA8BkB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAAAA,wBAAAA,GAA2BC,8BAA3BD,CAAAA,CAAAA,GAAAA;EAAwB,OAAGC,CAAAA,EACxGP,OADwGO,CAChGE,aADgGF,CAAAA;CAA8B,GAEhJP,OAFoDU,CAE5CA,IAF4CA,CAEvCtB,aAFuCsB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAETJ,wBAFSI,GAEkBH,8BAFlBG,CAAAA,CAAAA,GAEqDb,gBAFrDa,CAEsED,aAFtEC,CAAAA"}
@@ -1,6 +1,7 @@
1
1
  import { BaseMessage } from "@langchain/core/messages";
2
2
  import { PregelOptions, Runtime } from "@langchain/langgraph";
3
3
  import { InteropZodDefault, InteropZodOptional } from "@langchain/core/utils/types";
4
+ import { BaseCallbackConfig } from "@langchain/core/callbacks/manager";
4
5
 
5
6
  //#region src/agents/runtime.d.ts
6
7
 
@@ -52,33 +53,12 @@ type WithMaybeContext<TContext> = undefined extends TContext ? {
52
53
  /**
53
54
  * Runtime information available to middleware (readonly).
54
55
  */
55
- type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & PrivateState & {
56
+ type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & {
56
57
  configurable?: {
57
58
  thread_id?: string;
58
59
  [key: string]: unknown;
59
60
  };
60
61
  };
61
- interface RunLevelPrivateState {
62
- /**
63
- * The number of times the model has been called at the run level.
64
- * This includes multiple agent invocations.
65
- */
66
- runModelCallCount: number;
67
- }
68
- interface ThreadLevelPrivateState {
69
- /**
70
- * The number of times the model has been called at the thread level.
71
- * This includes multiple agent invocations within different environments
72
- * using the same thread.
73
- */
74
- threadLevelCallCount: number;
75
- }
76
- /**
77
- * As private state we consider all information we want to track within
78
- * the lifecycle of the agent, without exposing it to the user. These informations
79
- * are propagated to the user as _readonly_ runtime properties.
80
- */
81
- interface PrivateState extends ThreadLevelPrivateState, RunLevelPrivateState {}
82
62
  /**
83
63
  * Helper type to check if a type is optional (includes undefined)
84
64
  */
@@ -97,6 +77,10 @@ undefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonU
97
77
  * Pregel options that are propagated to the agent
98
78
  */
99
79
  type CreateAgentPregelOptions = "configurable" | "durability" | "store" | "cache" | "signal" | "recursionLimit" | "maxConcurrency" | "timeout";
80
+ /**
81
+ * Pregel stream options that are propagated to the agent
82
+ */
83
+ type CreateAgentPregelStreamOptions = "encoding" | "streamMode";
100
84
  /**
101
85
  * Decide whether provided configuration requires a context
102
86
  */
@@ -104,20 +88,20 @@ type InvokeConfiguration<ContextSchema extends Record<string, any>> =
104
88
  /**
105
89
  * If the context schema is a default object, `context` can be optional
106
90
  */
107
- ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
91
+ ContextSchema extends InteropZodDefault<any> ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
108
92
  context?: Partial<ContextSchema>;
109
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
93
+ } : IsAllOptional<ContextSchema> extends true ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
110
94
  context?: Partial<ContextSchema>;
111
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
95
+ } : BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
112
96
  type StreamConfiguration<ContextSchema extends Record<string, any>> =
113
97
  /**
114
98
  * If the context schema is a default object, `context` can be optional
115
99
  */
116
100
  ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
117
101
  context?: Partial<ContextSchema>;
118
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & {
102
+ } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & {
119
103
  context?: Partial<ContextSchema>;
120
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & WithMaybeContext<ContextSchema>;
104
+ } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & WithMaybeContext<ContextSchema>;
121
105
  //#endregion
122
106
  export { AgentBuiltInState, InvokeConfiguration, Runtime$1 as Runtime, StreamConfiguration };
123
107
  //# sourceMappingURL=runtime.d.ts.map