langchain 1.0.0-alpha.6 → 1.0.0-alpha.7

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 (185) hide show
  1. package/dist/agents/ReactAgent.cjs.map +1 -1
  2. package/dist/agents/ReactAgent.d.cts +1 -2
  3. package/dist/agents/ReactAgent.d.cts.map +1 -1
  4. package/dist/agents/ReactAgent.d.ts +1 -2
  5. package/dist/agents/ReactAgent.d.ts.map +1 -1
  6. package/dist/agents/ReactAgent.js.map +1 -1
  7. package/dist/agents/annotation.cjs.map +1 -1
  8. package/dist/agents/annotation.d.cts +12 -5
  9. package/dist/agents/annotation.d.cts.map +1 -1
  10. package/dist/agents/annotation.d.ts +12 -5
  11. package/dist/agents/annotation.d.ts.map +1 -1
  12. package/dist/agents/annotation.js.map +1 -1
  13. package/dist/agents/createAgent.cjs.map +1 -1
  14. package/dist/agents/createAgent.js.map +1 -1
  15. package/dist/agents/index.cjs.map +1 -1
  16. package/dist/agents/index.d.cts +3 -3
  17. package/dist/agents/index.d.cts.map +1 -1
  18. package/dist/agents/index.d.ts +3 -3
  19. package/dist/agents/index.d.ts.map +1 -1
  20. package/dist/agents/index.js.map +1 -1
  21. package/dist/agents/interrupt.d.cts +14 -1
  22. package/dist/agents/interrupt.d.cts.map +1 -1
  23. package/dist/agents/interrupt.d.ts +14 -1
  24. package/dist/agents/interrupt.d.ts.map +1 -1
  25. package/dist/agents/middlewareAgent/ReactAgent.cjs +262 -55
  26. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
  27. package/dist/agents/middlewareAgent/ReactAgent.d.cts +97 -10
  28. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
  29. package/dist/agents/middlewareAgent/ReactAgent.d.ts +97 -10
  30. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
  31. package/dist/agents/middlewareAgent/ReactAgent.js +264 -57
  32. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
  33. package/dist/agents/middlewareAgent/annotation.cjs +10 -4
  34. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
  35. package/dist/agents/middlewareAgent/annotation.js +10 -4
  36. package/dist/agents/middlewareAgent/annotation.js.map +1 -1
  37. package/dist/agents/middlewareAgent/constants.d.cts +5 -0
  38. package/dist/agents/middlewareAgent/constants.d.cts.map +1 -0
  39. package/dist/agents/middlewareAgent/constants.d.ts +5 -0
  40. package/dist/agents/middlewareAgent/constants.d.ts.map +1 -0
  41. package/dist/agents/middlewareAgent/index.cjs.map +1 -1
  42. package/dist/agents/middlewareAgent/index.js.map +1 -1
  43. package/dist/agents/middlewareAgent/middleware/bigTool.cjs +162 -0
  44. package/dist/agents/middlewareAgent/middleware/bigTool.cjs.map +1 -0
  45. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts +113 -0
  46. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts.map +1 -0
  47. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts +113 -0
  48. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts.map +1 -0
  49. package/dist/agents/middlewareAgent/middleware/bigTool.js +161 -0
  50. package/dist/agents/middlewareAgent/middleware/bigTool.js.map +1 -0
  51. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs +58 -0
  52. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs.map +1 -0
  53. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts +46 -0
  54. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts.map +1 -0
  55. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts +46 -0
  56. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts.map +1 -0
  57. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js +58 -0
  58. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js.map +1 -0
  59. package/dist/agents/middlewareAgent/middleware/hitl.cjs +160 -84
  60. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -1
  61. package/dist/agents/middlewareAgent/middleware/hitl.d.cts +271 -51
  62. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -1
  63. package/dist/agents/middlewareAgent/middleware/hitl.d.ts +271 -51
  64. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -1
  65. package/dist/agents/middlewareAgent/middleware/hitl.js +161 -85
  66. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -1
  67. package/dist/agents/middlewareAgent/middleware/index.cjs +6 -0
  68. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -1
  69. package/dist/agents/middlewareAgent/middleware/index.d.cts +6 -4
  70. package/dist/agents/middlewareAgent/middleware/index.d.ts +6 -4
  71. package/dist/agents/middlewareAgent/middleware/index.js +5 -1
  72. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -1
  73. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs +24 -8
  74. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -1
  75. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts +51 -6
  76. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -1
  77. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts +51 -6
  78. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -1
  79. package/dist/agents/middlewareAgent/middleware/promptCaching.js +24 -8
  80. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -1
  81. package/dist/agents/middlewareAgent/middleware/summarization.cjs +24 -12
  82. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -1
  83. package/dist/agents/middlewareAgent/middleware/summarization.d.cts +5 -3
  84. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -1
  85. package/dist/agents/middlewareAgent/middleware/summarization.d.ts +11 -9
  86. package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +1 -1
  87. package/dist/agents/middlewareAgent/middleware/summarization.js +25 -13
  88. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -1
  89. package/dist/agents/middlewareAgent/middleware.cjs +8 -5
  90. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
  91. package/dist/agents/middlewareAgent/middleware.d.cts +67 -7
  92. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
  93. package/dist/agents/middlewareAgent/middleware.d.ts +67 -7
  94. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
  95. package/dist/agents/middlewareAgent/middleware.js +8 -5
  96. package/dist/agents/middlewareAgent/middleware.js.map +1 -1
  97. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +2 -2
  98. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
  99. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +2 -2
  100. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
  101. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +117 -68
  102. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
  103. package/dist/agents/middlewareAgent/nodes/AgentNode.js +121 -72
  104. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
  105. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +2 -2
  106. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
  107. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +2 -2
  108. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
  109. package/dist/agents/middlewareAgent/nodes/middleware.cjs +42 -17
  110. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
  111. package/dist/agents/middlewareAgent/nodes/middleware.js +42 -18
  112. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
  113. package/dist/agents/middlewareAgent/nodes/utils.cjs +25 -11
  114. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
  115. package/dist/agents/middlewareAgent/nodes/utils.js +26 -12
  116. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
  117. package/dist/agents/middlewareAgent/types.d.cts +153 -66
  118. package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
  119. package/dist/agents/middlewareAgent/types.d.ts +153 -66
  120. package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
  121. package/dist/agents/model.cjs +13 -0
  122. package/dist/agents/model.cjs.map +1 -0
  123. package/dist/agents/model.js +11 -0
  124. package/dist/agents/model.js.map +1 -0
  125. package/dist/agents/nodes/AgentNode.cjs +56 -28
  126. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  127. package/dist/agents/nodes/AgentNode.js +57 -29
  128. package/dist/agents/nodes/AgentNode.js.map +1 -1
  129. package/dist/agents/nodes/ToolNode.cjs +1 -1
  130. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  131. package/dist/agents/nodes/ToolNode.d.cts +1 -1
  132. package/dist/agents/nodes/ToolNode.js +1 -1
  133. package/dist/agents/nodes/ToolNode.js.map +1 -1
  134. package/dist/agents/responses.cjs +52 -10
  135. package/dist/agents/responses.cjs.map +1 -1
  136. package/dist/agents/responses.d.cts +12 -20
  137. package/dist/agents/responses.d.cts.map +1 -1
  138. package/dist/agents/responses.d.ts +12 -20
  139. package/dist/agents/responses.d.ts.map +1 -1
  140. package/dist/agents/responses.js +52 -11
  141. package/dist/agents/responses.js.map +1 -1
  142. package/dist/agents/types.d.cts +2 -3
  143. package/dist/agents/types.d.cts.map +1 -1
  144. package/dist/agents/types.d.ts +2 -3
  145. package/dist/agents/types.d.ts.map +1 -1
  146. package/dist/agents/utils.cjs +5 -23
  147. package/dist/agents/utils.cjs.map +1 -1
  148. package/dist/agents/utils.js +2 -19
  149. package/dist/agents/utils.js.map +1 -1
  150. package/dist/chains/query_constructor/index.d.cts +1 -1
  151. package/dist/chains/summarization/load.d.ts +2 -2
  152. package/dist/chains/summarization/load.d.ts.map +1 -1
  153. package/dist/embeddings/cache_backed.d.ts +1 -1
  154. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  155. package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
  156. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  157. package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
  158. package/dist/index.cjs +38 -6
  159. package/dist/index.cjs.map +1 -1
  160. package/dist/index.d.cts +11 -4
  161. package/dist/index.d.ts +11 -4
  162. package/dist/index.js +18 -4
  163. package/dist/index.js.map +1 -1
  164. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  165. package/dist/langchain-core/dist/messages/content/index.d.cts +20 -1
  166. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  167. package/dist/langchain-core/dist/messages/content/tools.d.cts +67 -6
  168. package/dist/langchain-core/dist/messages/content/tools.d.cts.map +1 -1
  169. package/dist/langchain-core/dist/messages/message.d.cts +6 -6
  170. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -1
  171. package/dist/langchain-core/dist/utils/types/index.d.cts.map +1 -1
  172. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  173. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +20 -1
  174. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  175. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts +67 -6
  176. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts.map +1 -1
  177. package/dist/libs/langchain-core/dist/messages/message.d.ts +6 -6
  178. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -1
  179. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  180. package/dist/load/import_map.cjs +1 -1
  181. package/dist/load/import_map.js +1 -1
  182. package/dist/output_parsers/structured.d.cts +1 -1
  183. package/dist/tools/fs.d.cts +1 -1
  184. package/dist/tools/retriever.d.cts +1 -1
  185. package/package.json +7 -7
@@ -1,19 +1,29 @@
1
- import { JsonSchemaFormat, ProviderStrategy, ResponseFormat, ResponseFormatUndefined, ToolStrategy, TypedToolStrategy } from "../responses.js";
2
- import { AnyAnnotationRoot, PreHookAnnotation, ToAnnotationRoot } from "../annotation.js";
1
+ import { JUMP_TO_TARGETS } from "./constants.js";
2
+ import { AnyAnnotationRoot, ResponseFormatUndefined, ToAnnotationRoot } from "../annotation.js";
3
+ import { JsonSchemaFormat, ProviderStrategy, ResponseFormat, ToolStrategy, TypedToolStrategy } from "../responses.js";
4
+ import { Interrupt } from "../interrupt.js";
3
5
  import { ToolNode } from "../nodes/ToolNode.js";
4
- import { AgentRuntime, ClientTool, ServerTool } from "../types.js";
5
- import { BaseMessage, BaseMessageLike, SystemMessage } from "@langchain/core/messages";
6
- import { Runnable } from "@langchain/core/runnables";
7
- import { LangGraphRunnableConfig, START } from "@langchain/langgraph";
8
- import { InferInteropZodInput, InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
9
- import { z } from "zod/v3";
6
+ import { ClientTool, ServerTool } from "../types.js";
7
+ import { BaseMessage } from "@langchain/core/messages";
8
+ import { END, LangGraphRunnableConfig, PregelOptions, Runtime, START } from "@langchain/langgraph";
9
+ import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodObject, InteropZodOptional, InteropZodType } from "@langchain/core/utils/types";
10
10
  import { LanguageModelLike } from "@langchain/core/language_models/base";
11
- import { All, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
11
+ import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
12
12
 
13
13
  //#region src/agents/middlewareAgent/types.d.ts
14
- type N = typeof START | "model_request" | "tools";
14
+
15
15
  interface BuiltInState {
16
16
  messages: BaseMessage[];
17
+ __interrupt__?: Interrupt[];
18
+ /**
19
+ * Optional property to control routing after afterModel middleware execution.
20
+ * When set by middleware, the agent will jump to the specified node instead of
21
+ * following normal routing logic. The property is automatically cleared after use.
22
+ *
23
+ * - "model_request": Jump back to the model for another LLM call
24
+ * - "tools": Jump to tool execution (requires tools to be available)
25
+ */
26
+ jumpTo?: JumpToTarget;
17
27
  }
18
28
  /**
19
29
  * Information about a tool call that has been executed.
@@ -31,24 +41,19 @@ interface ToolCall {
31
41
  * The arguments that were passed to the tool.
32
42
  */
33
43
  args: Record<string, any>;
34
- }
35
- /**
36
- * Information about a tool result from a tool execution.
37
- */
38
- interface ToolResult {
39
- /**
40
- * The ID of the tool call.
41
- */
42
- id: string;
43
44
  /**
44
45
  * The result of the tool call.
45
46
  */
46
- result: any;
47
+ result?: unknown;
47
48
  /**
48
49
  * An optional error message if the tool call failed.
49
50
  */
50
51
  error?: string;
51
52
  }
53
+ /**
54
+ * Information about a tool result from a tool execution.
55
+ */
56
+
52
57
  /**
53
58
  * Configuration for modifying a model call at runtime.
54
59
  * All fields are optional and only provided fields will override defaults.
@@ -65,7 +70,7 @@ interface ModelRequest {
65
70
  /**
66
71
  * The system message for this step.
67
72
  */
68
- systemMessage?: BaseMessage;
73
+ systemPrompt?: string;
69
74
  /**
70
75
  * Tool choice configuration (model-specific format).
71
76
  * Can be one of:
@@ -82,35 +87,43 @@ interface ModelRequest {
82
87
  };
83
88
  /**
84
89
  * The tools to make available for this step.
85
- * Can be tool names (strings) or tool instances.
86
90
  */
87
- tools: (ClientTool | ServerTool)[];
91
+ tools: string[];
88
92
  }
89
93
  /**
90
- * Runtime information available to middleware (readonly).
94
+ * Type helper to check if TContext is an optional Zod schema
91
95
  */
92
- interface Runtime<TContext = unknown> {
93
- readonly toolCalls: ToolCall[];
94
- readonly toolResults: ToolResult[];
95
- // readonly tokenUsage: {
96
- // readonly inputTokens: number;
97
- // readonly outputTokens: number;
98
- // readonly totalTokens: number;
99
- // };
96
+ type IsOptionalZodObject<T> = T extends InteropZodOptional<any> ? true : false;
97
+ type IsDefaultZodObject<T> = T extends InteropZodDefault<any> ? true : false;
98
+ type WithMaybeContext<TContext> = undefined extends TContext ? {
99
+ readonly context?: TContext;
100
+ } : IsOptionalZodObject<TContext> extends true ? {
101
+ readonly context?: TContext;
102
+ } : IsDefaultZodObject<TContext> extends true ? {
103
+ readonly context?: TContext;
104
+ } : {
100
105
  readonly context: TContext;
101
- }
106
+ };
102
107
  /**
103
- * Control flow interface for middleware.
108
+ * Runtime information available to middleware (readonly).
104
109
  */
105
- interface Controls<TState = unknown> {
106
- jumpTo(target: "model" | "tools", stateUpdate?: Partial<TState>): ControlAction<TState>;
107
- terminate(result?: Partial<TState> | Error): ControlAction<TState>;
108
- }
110
+ type Runtime$1<TState = unknown, TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & {
111
+ readonly toolCalls: ToolCall[];
112
+ /**
113
+ * All tool instances that are provided to the agent.
114
+ */
115
+ readonly tools: (ClientTool | ServerTool)[];
116
+ /**
117
+ * Terminates the agent with an update to the state or throws an error.
118
+ * @param result - The result to terminate the agent with.
119
+ */
120
+ terminate(result: Partial<TState> | Error): ControlAction<TState>;
121
+ } & WithMaybeContext<TContext>;
109
122
  /**
110
123
  * Control action type returned by control methods.
111
124
  */
112
125
  type ControlAction<TStateSchema> = {
113
- type: "jump" | "terminate" | "retry";
126
+ type: "terminate";
114
127
  target?: string;
115
128
  stateUpdate?: Partial<TStateSchema>;
116
129
  result?: any;
@@ -134,12 +147,12 @@ type FilterPrivateProps<T> = { [K in keyof T as K extends `_${string}` ? never :
134
147
  * Helper type to infer the state schema type from a middleware
135
148
  * This filters out private properties (those starting with underscore)
136
149
  */
137
- type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.infer<S>> : {} : {};
150
+ type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends InteropZodObject ? FilterPrivateProps<InferInteropZodOutput<S>> : {} : {};
138
151
  /**
139
152
  * Helper type to infer the input state schema type from a middleware (all properties optional)
140
153
  * This filters out private properties (those starting with underscore)
141
154
  */
142
- type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.input<S>> : {} : {};
155
+ type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends InteropZodObject ? FilterPrivateProps<InferInteropZodInput<S>> : {} : {};
143
156
  /**
144
157
  * Helper type to infer merged state from an array of middleware (just the middleware states)
145
158
  */
@@ -155,22 +168,37 @@ type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any
155
168
  /**
156
169
  * Helper type to infer the input context schema type from a middleware (with optional defaults)
157
170
  */
158
- type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.input<C> : {} : {};
171
+ type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends InteropZodOptional<infer Inner> ? InferInteropZodInput<Inner> | undefined : C extends InteropZodObject ? InferInteropZodInput<C> : {} : {};
159
172
  /**
160
173
  * Helper type to infer merged context from an array of middleware
161
174
  */
162
175
 
176
+ /**
177
+ * Helper to merge two context types, preserving undefined unions
178
+ */
179
+ type MergeContextTypes<A, B> = [A] extends [undefined] ? [B] extends [undefined] ? undefined : B | undefined : [B] extends [undefined] ? A | undefined : [A] extends [B] ? A : [B] extends [A] ? B : A & B;
163
180
  /**
164
181
  * Helper type to infer merged input context from an array of middleware (with optional defaults)
165
182
  */
166
- type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContextInput<First> & InferMiddlewareContextInputs<Rest> : InferMiddlewareContextInput<First> : {} : {};
183
+ type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? MergeContextTypes<InferMiddlewareContextInput<First>, InferMiddlewareContextInputs<Rest>> : InferMiddlewareContextInput<First> : {} : {};
184
+ /**
185
+ * jump targets (user facing)
186
+ */
187
+ type JumpToTarget = (typeof JUMP_TO_TARGETS)[number];
188
+ /**
189
+ * jump targets (internal)
190
+ */
191
+
167
192
  /**
168
193
  * Base middleware interface.
169
194
  */
170
- interface AgentMiddleware<TSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TContextSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TFullContext = any> {
195
+ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = undefined, TContextSchema extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = undefined, TFullContext = any> {
171
196
  stateSchema?: TSchema;
172
197
  contextSchema?: TContextSchema;
173
198
  name: string;
199
+ beforeModelJumpTo?: JumpToTarget[];
200
+ afterModelJumpTo?: JumpToTarget[];
201
+ tools?: (ClientTool | ServerTool)[];
174
202
  /**
175
203
  * Runs before each LLM call, can modify call parameters, changes are not persistent
176
204
  * e.g. if you change `model`, it will only be changed for the next model call
@@ -180,24 +208,18 @@ interface AgentMiddleware<TSchema extends z.ZodObject<z.ZodRawShape> | undefined
180
208
  * @param runtime - Runtime context and metadata
181
209
  * @returns Modified options or undefined to pass through
182
210
  */
183
- prepareModelRequest?(request: ModelRequest, state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>): Promise<Partial<ModelRequest> | void> | Partial<ModelRequest> | void;
184
- beforeModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;
185
- afterModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;
211
+ modifyModelRequest?(request: ModelRequest, state: (TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}) & AgentBuiltInState, runtime: Runtime$1<TFullContext>): Promise<Partial<ModelRequest> | void> | Partial<ModelRequest> | void;
212
+ beforeModel?(state: (TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}) & AgentBuiltInState, runtime: Runtime$1<TFullContext>): Promise<MiddlewareResult<Partial<TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}>>>;
213
+ afterModel?(state: (TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}) & AgentBuiltInState, runtime: Runtime$1<TFullContext>): Promise<MiddlewareResult<Partial<TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}>>>;
186
214
  }
187
215
  /**
188
216
  * Information about a tool call that has been executed.
189
217
  */
190
218
 
191
- /**
192
- * Duplicate of the Prompt type from ../types.ts
193
- */
194
- type Prompt<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = SystemMessage | string | ((state: AgentBuiltInState, config: LangGraphRunnableConfig<ToAnnotationRoot<ContextSchema>["State"]>) => BaseMessageLike[] | Promise<BaseMessageLike[]>) | Runnable;
195
- type DynamicLLMFunction<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = (state: AgentBuiltInState & PreHookAnnotation["State"], runtime: AgentRuntime<ToAnnotationRoot<ContextSchema>["State"]>) => Promise<LanguageModelLike> | LanguageModelLike;
196
219
  type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {
197
- /** The chat model that can utilize OpenAI-style tool calling. */
198
- llm?: LanguageModelLike | DynamicLLMFunction<ContextSchema>;
199
220
  /**
200
- * Initializes a ChatModel based on the provided model name and provider.
221
+ * Defines a model to use for the agent. You can either pass in an instance of a LangChain chat model
222
+ * or a string. If a string is provided the agent initializes a ChatModel based on the provided model name and provider.
201
223
  * It supports various model providers and allows for runtime configuration of model parameters.
202
224
  *
203
225
  * @uses {@link initChatModel}
@@ -208,9 +230,38 @@ type CreateAgentParams<StructuredResponseType extends Record<string, any> = Reco
208
230
  * // ...
209
231
  * });
210
232
  * ```
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * import { ChatOpenAI } from "@langchain/openai";
237
+ * const agent = createAgent({
238
+ * model: new ChatOpenAI({ model: "gpt-4o" }),
239
+ * // ...
240
+ * });
241
+ * ```
242
+ */
243
+ model?: string | LanguageModelLike;
244
+ /**
245
+ * A list of tools or a ToolNode.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * import { tool } from "langchain";
250
+ *
251
+ * const weatherTool = tool(() => "Sunny!", {
252
+ * name: "get_weather",
253
+ * description: "Get the weather for a location",
254
+ * schema: z.object({
255
+ * location: z.string().describe("The location to get weather for"),
256
+ * }),
257
+ * });
258
+ *
259
+ * const agent = createAgent({
260
+ * tools: [weatherTool],
261
+ * // ...
262
+ * });
263
+ * ```
211
264
  */
212
- model?: string;
213
- /** A list of tools or a ToolNode. */
214
265
  tools?: ToolNode | (ServerTool | ClientTool)[];
215
266
  /**
216
267
  * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.
@@ -226,9 +277,9 @@ type CreateAgentParams<StructuredResponseType extends Record<string, any> = Reco
226
277
  * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.
227
278
  * This is now deprecated and will be removed in a future release.
228
279
  *
229
- * Cannot be used together with `prepareModelRequest`.
280
+ * Cannot be used together with `modifyModelRequest`.
230
281
  */
231
- prompt?: Prompt<ContextSchema>;
282
+ systemPrompt?: string;
232
283
  /**
233
284
  * An optional schema for the context. It allows to pass in a typed context object into the agent
234
285
  * invocation and allows to access it in hooks such as `prompt` and middleware.
@@ -267,10 +318,10 @@ type CreateAgentParams<StructuredResponseType extends Record<string, any> = Reco
267
318
  checkpointSaver?: BaseCheckpointSaver | boolean;
268
319
  /** An optional checkpoint saver to persist the agent's state. Alias of "checkpointSaver". */
269
320
  checkpointer?: BaseCheckpointSaver | boolean;
270
- /** An optional list of node names to interrupt before running. */
271
- interruptBefore?: N[] | All;
272
- /** An optional list of node names to interrupt after running. */
273
- interruptAfter?: N[] | All;
321
+ /**
322
+ * An optional store to persist the agent's state.
323
+ * @see {@link https://docs.langchain.com/oss/javascript/langgraph/memory#memory-storage | Long-term memory}
324
+ */
274
325
  store?: BaseStore;
275
326
  /**
276
327
  * An optional schema for the final agent output.
@@ -364,17 +415,53 @@ type CreateAgentParams<StructuredResponseType extends Record<string, any> = Reco
364
415
  */
365
416
  version?: "v1" | "v2";
366
417
  };
418
+ /**
419
+ * Helper type to check if a type is optional (includes undefined)
420
+ */
421
+ type IsOptionalType<T> = undefined extends T ? true : false;
422
+ /**
423
+ * Extract non-undefined part of a union that includes undefined
424
+ */
425
+ type ExtractNonUndefined<T> = T extends undefined ? never : T;
367
426
  /**
368
427
  * Helper type to check if all properties of a type are optional
369
428
  */
370
- type IsAllOptional<T> = T extends Record<string, any> ? {} extends T ? true : false : true;
429
+ type IsAllOptional<T> =
430
+ // If T includes undefined, then it's optional (can be omitted entirely)
431
+ undefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonUndefined<T> extends Record<string, any> ? {} extends ExtractNonUndefined<T> ? true : false : IsOptionalType<T>;
371
432
  /**
372
433
  * Helper type to extract input type from context schema (with optional defaults)
373
434
  */
374
435
  type InferContextInput<ContextSchema extends AnyAnnotationRoot | InteropZodObject> = ContextSchema extends InteropZodObject ? InferInteropZodInput<ContextSchema> : ContextSchema extends AnyAnnotationRoot ? ToAnnotationRoot<ContextSchema>["State"] : {};
375
436
  /**
376
- * Helper type to get the required config type based on context schema
437
+ * Helper to check if ContextSchema is the default (AnyAnnotationRoot)
438
+ */
439
+
440
+ /**
441
+ * Pregel options that are propagated to the agent
442
+ */
443
+ type CreateAgentPregelOptions = "configurable" | "durability" | "store" | "cache" | "signal" | "recursionLimit" | "maxConcurrency" | "timeout";
444
+ /**
445
+ * Decide whether provided configuration requires a context
446
+ */
447
+ type InvokeConfiguration<ContextSchema extends Record<string, any>> =
448
+ /**
449
+ * If the context schema is a default object, `context` can be optional
450
+ */
451
+ ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
452
+ context?: Partial<ContextSchema>;
453
+ } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
454
+ context?: Partial<ContextSchema>;
455
+ } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
456
+ type StreamConfiguration<ContextSchema extends Record<string, any>> =
457
+ /**
458
+ * If the context schema is a default object, `context` can be optional
377
459
  */
460
+ ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
461
+ context?: Partial<ContextSchema>;
462
+ } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & {
463
+ context?: Partial<ContextSchema>;
464
+ } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & WithMaybeContext<ContextSchema>;
378
465
  //#endregion
379
- export { AgentBuiltInState, AgentMiddleware, BuiltInState, Controls, CreateAgentParams, InferContextInput, InferMiddlewareContextInputs, InferMiddlewareInputStates, InferMiddlewareStates, IsAllOptional, MiddlewareResult, ModelRequest, Runtime };
466
+ export { AgentBuiltInState, AgentMiddleware, BuiltInState, CreateAgentParams, InferContextInput, InferMiddlewareContextInputs, InferMiddlewareInputStates, InferMiddlewareStates, InvokeConfiguration, JumpToTarget, MiddlewareResult, ModelRequest, Runtime$1 as Runtime, StreamConfiguration };
380
467
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["z","InteropZodObject","InteropZodType","InferInteropZodInput","LangGraphRunnableConfig","START","LanguageModelLike","SystemMessage","BaseMessageLike","BaseMessage","All","BaseCheckpointSaver","BaseStore","Runnable","PreHookAnnotation","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormatUndefined","JsonSchemaFormat","ToolNode","ClientTool","ServerTool","AgentRuntime","N","BuiltInState","ToolCall","Record","ToolResult","ModelRequest","Runtime","TContext","Controls","TState","Partial","ControlAction","Error","TStateSchema","MiddlewareResult","AgentBuiltInState","FilterPrivateProps","T","K","InferMiddlewareState","AgentMiddleware","S","ZodObject","infer","InferMiddlewareInputState","input","InferMiddlewareStates","First","Rest","InferMiddlewareInputStates","InferMergedState","InferMergedInputState","InferMiddlewareContext","C","InferMiddlewareContextInput","InferMiddlewareContexts","InferMiddlewareContextInputs","ZodRawShape","TSchema","TContextSchema","TFullContext","Promise","ExecutedToolCall","LLMCall","Prompt","ContextSchema","DynamicLLMFunction","CreateAgentParams","StructuredResponseType","ResponseFormatType","AbortSignal","IsAllOptional","InferContextInput","InferAgentConfig","TMiddleware","InternalAgentState"],"sources":["../../../src/agents/middlewareAgent/types.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport type { InteropZodObject, InteropZodType, InferInteropZodInput } from \"@langchain/core/utils/types\";\nimport type { LangGraphRunnableConfig, START } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { SystemMessage, BaseMessageLike, BaseMessage } from \"@langchain/core/messages\";\nimport type { All, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport type { Runnable } from \"@langchain/core/runnables\";\nimport type { PreHookAnnotation, AnyAnnotationRoot, ToAnnotationRoot } from \"../annotation.js\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormatUndefined, JsonSchemaFormat } from \"../responses.js\";\nimport type { ToolNode } from \"../nodes/ToolNode.js\";\nimport type { ClientTool, ServerTool, AgentRuntime } from \"../types.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\nexport interface BuiltInState {\n messages: BaseMessage[];\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n */\nexport interface ModelRequest {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n systemMessage?: BaseMessage;\n /**\n * Tool choice configuration (model-specific format).\n * Can be one of:\n * - `\"auto\"`: means the model can pick between generating a message or calling one or more tools.\n * - `\"none\"`: means the model will not call any tool and instead generates a message.\n * - `\"required\"`: means the model must call one or more tools.\n * - `{ type: \"function\", function: { name: string } }`: The model will use the specified function.\n */\n toolChoice?: \"auto\" | \"none\" | \"required\" | {\n type: \"function\";\n function: {\n name: string;\n };\n };\n /**\n * The tools to make available for this step.\n * Can be tool names (strings) or tool instances.\n */\n tools: (ClientTool | ServerTool)[];\n}\n/**\n * Runtime information available to middleware (readonly).\n */\nexport interface Runtime<TContext = unknown> {\n readonly toolCalls: ToolCall[];\n readonly toolResults: ToolResult[];\n // readonly tokenUsage: {\n // readonly inputTokens: number;\n // readonly outputTokens: number;\n // readonly totalTokens: number;\n // };\n readonly context: TContext;\n}\n/**\n * Control flow interface for middleware.\n */\nexport interface Controls<TState = unknown> {\n jumpTo(target: \"model\" | \"tools\", stateUpdate?: Partial<TState>): ControlAction<TState>;\n terminate(result?: Partial<TState> | Error): ControlAction<TState>;\n}\n/**\n * Control action type returned by control methods.\n */\nexport type ControlAction<TStateSchema> = {\n type: \"jump\" | \"terminate\" | \"retry\";\n target?: string;\n stateUpdate?: Partial<TStateSchema>;\n result?: any;\n error?: Error;\n};\n/**\n * Result type for middleware functions.\n */\nexport type MiddlewareResult<TState> = TState | void;\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n messages: BaseMessage[];\n};\n/**\n * Helper type to filter out properties that start with underscore (private properties)\n */\ntype FilterPrivateProps<T> = {\n [K in keyof T as K extends `_${string}` ? never : K]: T[K];\n};\n/**\n * Helper type to infer the state schema type from a middleware\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.infer<S>> : {} : {};\n/**\n * Helper type to infer the input state schema type from a middleware (all properties optional)\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends z.ZodObject<any> ? FilterPrivateProps<z.input<S>> : {} : {};\n/**\n * Helper type to infer merged state from an array of middleware (just the middleware states)\n */\nexport type InferMiddlewareStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareState<First> & InferMiddlewareStates<Rest> : InferMiddlewareState<First> : {} : {};\n/**\n * Helper type to infer merged input state from an array of middleware (with optional defaults)\n */\nexport type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareInputState<First> & InferMiddlewareInputStates<Rest> : InferMiddlewareInputState<First> : {} : {};\n/**\n * Helper type to infer merged state from an array of middleware (includes built-in state)\n */\nexport type InferMergedState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer merged input state from an array of middleware (includes built-in state)\n */\nexport type InferMergedInputState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareInputStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer the context schema type from a middleware\n */\nexport type InferMiddlewareContext<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.infer<C> : {} : {};\n/**\n * Helper type to infer the input context schema type from a middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends z.ZodObject<any> ? z.input<C> : {} : {};\n/**\n * Helper type to infer merged context from an array of middleware\n */\nexport type InferMiddlewareContexts<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContext<First> & InferMiddlewareContexts<Rest> : InferMiddlewareContext<First> : {} : {};\n/**\n * Helper type to infer merged input context from an array of middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContextInput<First> & InferMiddlewareContextInputs<Rest> : InferMiddlewareContextInput<First> : {} : {};\n/**\n * Base middleware interface.\n */\nexport interface AgentMiddleware<TSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TContextSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined, TFullContext = any> {\n stateSchema?: TSchema;\n contextSchema?: TContextSchema;\n name: string;\n /**\n * Runs before each LLM call, can modify call parameters, changes are not persistent\n * e.g. if you change `model`, it will only be changed for the next model call\n *\n * @param options - Current call options (can be modified by previous middleware)\n * @param state - Current state (read-only in this phase)\n * @param runtime - Runtime context and metadata\n * @returns Modified options or undefined to pass through\n */\n prepareModelRequest?(request: ModelRequest, state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>): Promise<Partial<ModelRequest> | void> | Partial<ModelRequest> | void;\n beforeModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;\n afterModel?(state: (TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>, controls: Controls<(TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}) & AgentBuiltInState>): Promise<MiddlewareResult<Partial<TSchema extends z.ZodObject<any> ? z.infer<TSchema> : {}>>>;\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\n/**\n * Information about an LLM invocation.\n */\nexport interface LLMCall {\n /**\n * The messages that were sent to the LLM.\n */\n messages: BaseMessage[];\n /**\n * The response from the LLM.\n */\n response?: BaseMessage;\n}\n/**\n * Duplicate of the Prompt type from ../types.ts\n */\nexport type Prompt<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = SystemMessage | string | ((state: AgentBuiltInState, config: LangGraphRunnableConfig<ToAnnotationRoot<ContextSchema>[\"State\"]>) => BaseMessageLike[] | Promise<BaseMessageLike[]>) | Runnable;\nexport type DynamicLLMFunction<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = (state: AgentBuiltInState & PreHookAnnotation[\"State\"], runtime: AgentRuntime<ToAnnotationRoot<ContextSchema>[\"State\"]>) => Promise<LanguageModelLike> | LanguageModelLike;\nexport type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm?: LanguageModelLike | DynamicLLMFunction<ContextSchema>;\n /**\n * Initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n */\n model?: string;\n /** A list of tools or a ToolNode. */\n tools?: ToolNode | (ServerTool | ClientTool)[];\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n *\n * Cannot be used together with `prepareModelRequest`.\n */\n prompt?: Prompt<ContextSchema>;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middleware.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middleware instances to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n */\n middleware?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = T extends Record<string, any> ? {} extends T ? true : false : true;\n/**\n * Helper type to extract input type from context schema (with optional defaults)\n */\nexport type InferContextInput<ContextSchema extends AnyAnnotationRoot | InteropZodObject> = ContextSchema extends InteropZodObject ? InferInteropZodInput<ContextSchema> : ContextSchema extends AnyAnnotationRoot ? ToAnnotationRoot<ContextSchema>[\"State\"] : {};\n/**\n * Helper type to get the required config type based on context schema\n */\nexport type InferAgentConfig<ContextSchema extends AnyAnnotationRoot | InteropZodObject, TMiddleware extends readonly AgentMiddleware<any, any, any>[]> = IsAllOptional<InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>> extends true ? LangGraphRunnableConfig<{\n context?: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>;\n}> | undefined : LangGraphRunnableConfig<{\n context: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>;\n}>;\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n __preparedModelOptions?: ModelRequest;\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\nexport {};\n"],"mappings":";;;;;;;;;;;;;KAYY2B,CAAAA,UAAWtB;AAAXsB,UACKC,YAAAA,CADW;EACXA,QAAAA,EACHnB,WADe,EAAA;AAM7B;AAiBA;AAkBA;;AAIWH,UAvCMuB,QAAAA,CAuCNvB;EAAiB;;;EA2BN,EAAA,EAAGmB,MAAAA;EAAU;AAKnC;;EAAwB,IACAI,EAAAA,MAAAA;EAAQ;;AAOF;EAKbM,IAAAA,EAxEPL,MAwEe,CAAA,MAAA,EAAA,GAAA,CAAA;;;;;AAC6CQ,UApErDP,UAAAA,CAoEqDO;EAAa;;;EACrC,EAAA,EAAiBF,MAAAA;EAAM;AAAP;AAK9D;EAAyB,MAAA,EAAA,GAAA;EAAA;;;EAKR,KAAA,CAAA,EAAA,MAAA;AAKjB;AAIA;AAEE;;;AAKmBS,UA7EJb,YAAAA,CA6EIa;EAAC;;;EAAuC,KAAA,EAzElDvC,iBAyEkD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,uBAA3UN,CAAAA,GAAAA;EAAiB;EAAmB,GAAGA,CAAAA,EAE3JT,iBAF2JS,GAEvI0D,kBAFuI1D,CAEpHyD,aAFoHzD,CAAAA;EAAiB;;;;;;;;;;;;;EAA0S,KAEtdT,CAAAA,EAAAA,MAAAA;EAAiB;EAAmC,KAAhCmE,CAAAA,EAgBlBlD,QAhBkBkD,GAAAA,CAgBNhD,UAhBMgD,GAgBOjD,UAhBPiD,CAAAA,EAAAA;EAAkB;;;;;;;;;;;;;;;;EA2JxB,MAAA,CAAA,EA1HXF,MA0HW,CA1HJC,aA0HI,CAAA;EAiBZM;;;;;AAA+D;AAI3E;;;;;;;;;;;;AAAqO;;;;;;;;;;;;;;;kBA7GjNN;;oBAEE7D;;iBAEHA;;oBAEGgB,MAAMjB;;mBAEPiB,MAAMjB;UACfE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAsDSgE;;;;;wBAKK7B;;;;;;;;;;;;;;;;;;;;WAoBb8B;;;;;;;;;;;;;;;;;KAiBDC,mBAAmBlC,UAAUd,iCAAiCc;;;;KAI9DmC,wCAAwChE,oBAAoBd,oBAAoBuE,sBAAsBvE,mBAAmBE,qBAAqBqE,iBAAiBA,sBAAsBzD,oBAAoBC,iBAAiBwD"}
1
+ {"version":3,"file":"types.d.ts","names":["InteropZodObject","InteropZodDefault","InteropZodOptional","InteropZodType","InferInteropZodInput","InferInteropZodOutput","LangGraphRunnableConfig","START","PregelOptions","Runtime","LangGraphRuntime","END","LanguageModelLike","BaseMessage","BaseCheckpointSaver","BaseStore","JUMP_TO_TARGETS","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","JsonSchemaFormat","ResponseFormatUndefined","Interrupt","ToolNode","ClientTool","ServerTool","N","BuiltInState","JumpToTarget","ToolCall","Record","ToolResult","ModelRequest","IsOptionalZodObject","T","IsDefaultZodObject","WithMaybeContext","TContext","Omit","Partial","TState","Error","ControlAction","TStateSchema","MiddlewareResult","AgentBuiltInState","FilterPrivateProps","K","InferMiddlewareState","AgentMiddleware","S","InferMiddlewareInputState","InferMiddlewareStates","First","Rest","InferMiddlewareInputStates","InferMergedState","InferMergedInputState","InferMiddlewareContext","C","InferMiddlewareContextInput","Inner","InferMiddlewareContexts","MergeContextTypes","A","B","InferMiddlewareContextInputs","JumpTo","TSchema","TContextSchema","TFullContext","Promise","ExecutedToolCall","LLMCall","CreateAgentParams","StructuredResponseType","ContextSchema","ResponseFormatType","AbortSignal","IsOptionalType","ExtractNonUndefined","IsAllOptional","InferContextInput","IsDefaultContext","InferAgentConfig","TMiddleware","InternalAgentState","CreateAgentPregelOptions","InvokeConfiguration","Pick","StreamConfiguration"],"sources":["../../../src/agents/middlewareAgent/types.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodObject, InteropZodDefault, InteropZodOptional, InteropZodType, InferInteropZodInput, InferInteropZodOutput } from \"@langchain/core/utils/types\";\nimport type { LangGraphRunnableConfig, START, PregelOptions, Runtime as LangGraphRuntime, END } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { JUMP_TO_TARGETS } from \"./constants.js\";\nimport type { AnyAnnotationRoot, ToAnnotationRoot } from \"../annotation.js\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, JsonSchemaFormat } from \"../responses.js\";\nimport type { ResponseFormatUndefined } from \"../annotation.js\";\nimport type { Interrupt } from \"../interrupt.js\";\nimport type { ToolNode } from \"../nodes/ToolNode.js\";\nimport type { ClientTool, ServerTool } from \"../types.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\nexport interface BuiltInState {\n messages: BaseMessage[];\n __interrupt__?: Interrupt[];\n /**\n * Optional property to control routing after afterModel middleware execution.\n * When set by middleware, the agent will jump to the specified node instead of\n * following normal routing logic. The property is automatically cleared after use.\n *\n * - \"model_request\": Jump back to the model for another LLM call\n * - \"tools\": Jump to tool execution (requires tools to be available)\n */\n jumpTo?: JumpToTarget;\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n /**\n * The result of the tool call.\n */\n result?: unknown;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Configuration for modifying a model call at runtime.\n * All fields are optional and only provided fields will override defaults.\n */\nexport interface ModelRequest {\n /**\n * The model to use for this step.\n */\n model: LanguageModelLike;\n /**\n * The messages to send to the model.\n */\n messages: BaseMessage[];\n /**\n * The system message for this step.\n */\n 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: string[];\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<TState = unknown, TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, \"context\" | \"configurable\">> & {\n readonly toolCalls: ToolCall[];\n /**\n * All tool instances that are provided to the agent.\n */\n readonly tools: (ClientTool | ServerTool)[];\n /**\n * Terminates the agent with an update to the state or throws an error.\n * @param result - The result to terminate the agent with.\n */\n terminate(result: Partial<TState> | Error): ControlAction<TState>;\n} & WithMaybeContext<TContext>;\n/**\n * Control action type returned by control methods.\n */\nexport type ControlAction<TStateSchema> = {\n type: \"terminate\";\n target?: string;\n stateUpdate?: Partial<TStateSchema>;\n result?: any;\n error?: Error;\n};\n/**\n * Result type for middleware functions.\n */\nexport type MiddlewareResult<TState> = TState | void;\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n messages: BaseMessage[];\n};\n/**\n * Helper type to filter out properties that start with underscore (private properties)\n */\ntype FilterPrivateProps<T> = {\n [K in keyof T as K extends `_${string}` ? never : K]: T[K];\n};\n/**\n * Helper type to infer the state schema type from a middleware\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends InteropZodObject ? FilterPrivateProps<InferInteropZodOutput<S>> : {} : {};\n/**\n * Helper type to infer the input state schema type from a middleware (all properties optional)\n * This filters out private properties (those starting with underscore)\n */\nexport type InferMiddlewareInputState<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<infer S, any, any> ? S extends InteropZodObject ? FilterPrivateProps<InferInteropZodInput<S>> : {} : {};\n/**\n * Helper type to infer merged state from an array of middleware (just the middleware states)\n */\nexport type InferMiddlewareStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareState<First> & InferMiddlewareStates<Rest> : InferMiddlewareState<First> : {} : {};\n/**\n * Helper type to infer merged input state from an array of middleware (with optional defaults)\n */\nexport type InferMiddlewareInputStates<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareInputState<First> & InferMiddlewareInputStates<Rest> : InferMiddlewareInputState<First> : {} : {};\n/**\n * Helper type to infer merged state from an array of middleware (includes built-in state)\n */\nexport type InferMergedState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer merged input state from an array of middleware (includes built-in state)\n */\nexport type InferMergedInputState<T extends readonly AgentMiddleware<any, any, any>[]> = InferMiddlewareInputStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer the context schema type from a middleware\n */\nexport type InferMiddlewareContext<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends InteropZodObject ? InferInteropZodInput<C> : {} : {};\n/**\n * Helper type to infer the input context schema type from a middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInput<T extends AgentMiddleware<any, any, any>> = T extends AgentMiddleware<any, infer C, any> ? C extends InteropZodOptional<infer Inner> ? InferInteropZodInput<Inner> | undefined : C extends InteropZodObject ? InferInteropZodInput<C> : {} : {};\n/**\n * Helper type to infer merged context from an array of middleware\n */\nexport type InferMiddlewareContexts<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? InferMiddlewareContext<First> & InferMiddlewareContexts<Rest> : InferMiddlewareContext<First> : {} : {};\n/**\n * Helper to merge two context types, preserving undefined unions\n */\ntype MergeContextTypes<A, B> = [A] extends [undefined] ? [B] extends [undefined] ? undefined : B | undefined : [B] extends [undefined] ? A | undefined : [A] extends [B] ? A : [B] extends [A] ? B : A & B;\n/**\n * Helper type to infer merged input context from an array of middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInputs<T extends readonly AgentMiddleware<any, any, any>[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware<any, any, any> ? Rest extends readonly AgentMiddleware<any, any, any>[] ? MergeContextTypes<InferMiddlewareContextInput<First>, InferMiddlewareContextInputs<Rest>> : InferMiddlewareContextInput<First> : {} : {};\n/**\n * jump targets (user facing)\n */\nexport type JumpToTarget = (typeof JUMP_TO_TARGETS)[number];\n/**\n * jump targets (internal)\n */\nexport type JumpTo = \"model_request\" | \"tools\" | typeof END;\n/**\n * Base middleware interface.\n */\nexport interface AgentMiddleware<TSchema extends InteropZodObject | undefined = undefined, TContextSchema extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = undefined, TFullContext = any> {\n stateSchema?: TSchema;\n contextSchema?: TContextSchema;\n name: string;\n beforeModelJumpTo?: JumpToTarget[];\n afterModelJumpTo?: JumpToTarget[];\n tools?: (ClientTool | ServerTool)[];\n /**\n * Runs before each LLM call, can modify call parameters, changes are not persistent\n * e.g. if you change `model`, it will only be changed for the next model call\n *\n * @param options - Current call options (can be modified by previous middleware)\n * @param state - Current state (read-only in this phase)\n * @param runtime - Runtime context and metadata\n * @returns Modified options or undefined to pass through\n */\n modifyModelRequest?(request: ModelRequest, state: (TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>): Promise<Partial<ModelRequest> | void> | Partial<ModelRequest> | void;\n beforeModel?(state: (TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>): Promise<MiddlewareResult<Partial<TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}>>>;\n afterModel?(state: (TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}) & AgentBuiltInState, runtime: Runtime<TFullContext>): Promise<MiddlewareResult<Partial<TSchema extends InteropZodObject ? InferInteropZodInput<TSchema> : {}>>>;\n}\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\n/**\n * Information about an LLM invocation.\n */\nexport interface LLMCall {\n /**\n * The messages that were sent to the LLM.\n */\n messages: BaseMessage[];\n /**\n * The response from the LLM.\n */\n response?: BaseMessage;\n}\nexport type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /**\n * Defines a model to use for the agent. You can either pass in an instance of a LangChain chat model\n * or a string. If a string is provided the agent initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * const agent = createAgent({\n * model: new ChatOpenAI({ model: \"gpt-4o\" }),\n * // ...\n * });\n * ```\n */\n model?: string | LanguageModelLike;\n /**\n * A list of tools or a ToolNode.\n *\n * @example\n * ```ts\n * import { tool } from \"langchain\";\n *\n * const weatherTool = tool(() => \"Sunny!\", {\n * name: \"get_weather\",\n * description: \"Get the weather for a location\",\n * schema: z.object({\n * location: z.string().describe(\"The location to get weather for\"),\n * }),\n * });\n *\n * const agent = createAgent({\n * tools: [weatherTool],\n * // ...\n * });\n * ```\n */\n tools?: ToolNode | (ServerTool | ClientTool)[];\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n *\n * Cannot be used together with `modifyModelRequest`.\n */\n systemPrompt?: string;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middleware.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /**\n * An optional store to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/memory#memory-storage | Long-term memory}\n */\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middleware instances to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n */\n middleware?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Helper type to check if 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 * Helper type to extract input type from context schema (with optional defaults)\n */\nexport type InferContextInput<ContextSchema extends AnyAnnotationRoot | InteropZodObject> = ContextSchema extends InteropZodObject ? InferInteropZodInput<ContextSchema> : ContextSchema extends AnyAnnotationRoot ? ToAnnotationRoot<ContextSchema>[\"State\"] : {};\n/**\n * Helper to check if ContextSchema is the default (AnyAnnotationRoot)\n */\ntype IsDefaultContext<T> = [T] extends [AnyAnnotationRoot] ? any extends T ? true : false : false;\n/**\n * Helper type to get the required config type based on context schema\n */\nexport type InferAgentConfig<ContextSchema extends AnyAnnotationRoot | InteropZodObject, TMiddleware extends readonly AgentMiddleware<any, any, any>[]> = IsDefaultContext<ContextSchema> extends true ? TMiddleware extends readonly [] ? LangGraphRunnableConfig | undefined // No middleware, no context needed\n : WithMaybeContext<InferMiddlewareContextInputs<TMiddleware>> extends {\n readonly context?: any;\n} ? LangGraphRunnableConfig<{\n context?: InferMiddlewareContextInputs<TMiddleware>;\n}> | undefined : LangGraphRunnableConfig<{\n context: InferMiddlewareContextInputs<TMiddleware>;\n}> : WithMaybeContext<InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>> extends {\n readonly context?: any;\n} ? LangGraphRunnableConfig<{\n context?: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>;\n}> | undefined : LangGraphRunnableConfig<{\n context: InferContextInput<ContextSchema> & InferMiddlewareContextInputs<TMiddleware>;\n}>;\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n __preparedModelOptions?: ModelRequest;\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\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":";;;;;;;;;;;;;;AAc6B,UAAZ8B,YAAAA,CAAY;EAAA,QACfjB,EAAAA,WAAAA,EAAAA;EAAW,aACLY,CAAAA,EAAAA,SAAAA,EAAAA;EAAS;AASJ;AAKzB;AA2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oBAAoB6C,eAAe7C;;;;KAIhLgD,wCAAwCpE,oBAAoBjB,oBAAoB+E,sBAAsB/E,mBAAmBI,qBAAqB2E,iBAAiBA,sBAAsB9D,oBAAoBC,iBAAiB6D;;;;;;;;KA+BjOW,wBAAAA;;;;KAIOC,0CAA0C1D;;;;AAItD8C,sBAAsB9E,yBAAyByC,QAAQkD,KAAKpF,8BAA8BkF;YAC5EhD,QAAQqC;IAClBK,cAAcL,8BAA8BrC,QAAQkD,KAAKpF,8BAA8BkF;YAC7EhD,QAAQqC;IAClBrC,QAAQkD,KAAKpF,8BAA8BkF,6BAA6BnD,iBAAiBwC;KACjFc,0CAA0C5D;;;;AAItD8C,sBAAsB9E,yBAAyByC,QAAQkD,KAAKpF,8BAA8BkF;YAC5EhD,QAAQqC;IAClBK,cAAcL,8BAA8BrC,QAAQkD,KAAKpF,8BAA8BkF;YAC7EhD,QAAQqC;IAClBrC,QAAQkD,KAAKpF,8BAA8BkF,4CAA4CnD,iBAAiBwC"}
@@ -0,0 +1,13 @@
1
+
2
+ //#region src/agents/model.ts
3
+ function isBaseChatModel(model) {
4
+ return "invoke" in model && typeof model.invoke === "function" && "_streamResponseChunks" in model;
5
+ }
6
+ function isConfigurableModel(model) {
7
+ return typeof model === "object" && model != null && "_queuedMethodOperations" in model && "_model" in model && typeof model._model === "function";
8
+ }
9
+
10
+ //#endregion
11
+ exports.isBaseChatModel = isBaseChatModel;
12
+ exports.isConfigurableModel = isConfigurableModel;
13
+ //# sourceMappingURL=model.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.cjs","names":["model: LanguageModelLike","model: unknown"],"sources":["../../src/agents/model.ts"],"sourcesContent":["import type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\n\nexport interface ConfigurableModelInterface {\n _queuedMethodOperations: Record<string, unknown>;\n _model: () => Promise<BaseChatModel>;\n}\n\nexport function isBaseChatModel(\n model: LanguageModelLike\n): model is BaseChatModel {\n return (\n \"invoke\" in model &&\n typeof model.invoke === \"function\" &&\n \"_streamResponseChunks\" in model\n );\n}\n\nexport function isConfigurableModel(\n model: unknown\n): model is ConfigurableModelInterface {\n return (\n typeof model === \"object\" &&\n model != null &&\n \"_queuedMethodOperations\" in model &&\n \"_model\" in model &&\n typeof model._model === \"function\"\n );\n}\n"],"mappings":";;AAQA,SAAgB,gBACdA,OACwB;AACxB,QACE,YAAY,SACZ,OAAO,MAAM,WAAW,cACxB,2BAA2B;AAE9B;AAED,SAAgB,oBACdC,OACqC;AACrC,QACE,OAAO,UAAU,YACjB,SAAS,QACT,6BAA6B,SAC7B,YAAY,SACZ,OAAO,MAAM,WAAW;AAE3B"}
@@ -0,0 +1,11 @@
1
+ //#region src/agents/model.ts
2
+ function isBaseChatModel(model) {
3
+ return "invoke" in model && typeof model.invoke === "function" && "_streamResponseChunks" in model;
4
+ }
5
+ function isConfigurableModel(model) {
6
+ return typeof model === "object" && model != null && "_queuedMethodOperations" in model && "_model" in model && typeof model._model === "function";
7
+ }
8
+
9
+ //#endregion
10
+ export { isBaseChatModel, isConfigurableModel };
11
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":["model: LanguageModelLike","model: unknown"],"sources":["../../src/agents/model.ts"],"sourcesContent":["import type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\n\nexport interface ConfigurableModelInterface {\n _queuedMethodOperations: Record<string, unknown>;\n _model: () => Promise<BaseChatModel>;\n}\n\nexport function isBaseChatModel(\n model: LanguageModelLike\n): model is BaseChatModel {\n return (\n \"invoke\" in model &&\n typeof model.invoke === \"function\" &&\n \"_streamResponseChunks\" in model\n );\n}\n\nexport function isConfigurableModel(\n model: unknown\n): model is ConfigurableModelInterface {\n return (\n typeof model === \"object\" &&\n model != null &&\n \"_queuedMethodOperations\" in model &&\n \"_model\" in model &&\n typeof model._model === \"function\"\n );\n}\n"],"mappings":";AAQA,SAAgB,gBACdA,OACwB;AACxB,QACE,YAAY,SACZ,OAAO,MAAM,WAAW,cACxB,2BAA2B;AAE9B;AAED,SAAgB,oBACdC,OACqC;AACrC,QACE,OAAO,UAAU,YACjB,SAAS,QACT,6BAA6B,SAC7B,YAAY,SACZ,OAAO,MAAM,WAAW;AAE3B"}