langchain 1.2.0 → 2.0.0-dev-1765937705265
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.
- package/CHANGELOG.md +7 -0
- package/dist/agents/ReactAgent.cjs +28 -0
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts +50 -14
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts +50 -14
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +28 -0
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +41 -29
- package/dist/agents/index.d.cts.map +1 -1
- package/dist/agents/index.d.ts +41 -29
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/middleware/contextEditing.d.cts +2 -1
- package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
- package/dist/agents/middleware/contextEditing.d.ts +2 -1
- package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
- package/dist/agents/middleware/dynamicSystemPrompt.d.cts +2 -1
- package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
- package/dist/agents/middleware/dynamicSystemPrompt.d.ts +2 -1
- package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
- package/dist/agents/middleware/hitl.d.cts +9 -1
- package/dist/agents/middleware/hitl.d.cts.map +1 -1
- package/dist/agents/middleware/hitl.d.ts +9 -1
- package/dist/agents/middleware/hitl.d.ts.map +1 -1
- package/dist/agents/middleware/llmToolSelector.d.cts +4 -4
- package/dist/agents/middleware/llmToolSelector.d.cts.map +1 -1
- package/dist/agents/middleware/llmToolSelector.d.ts +4 -4
- package/dist/agents/middleware/llmToolSelector.d.ts.map +1 -1
- package/dist/agents/middleware/modelCallLimit.d.cts +6 -1
- package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -1
- package/dist/agents/middleware/modelCallLimit.d.ts +6 -1
- package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -1
- package/dist/agents/middleware/provider/anthropic/promptCaching.d.cts +7 -1
- package/dist/agents/middleware/provider/anthropic/promptCaching.d.cts.map +1 -1
- package/dist/agents/middleware/provider/anthropic/promptCaching.d.ts +7 -1
- package/dist/agents/middleware/provider/anthropic/promptCaching.d.ts.map +1 -1
- package/dist/agents/middleware/summarization.d.cts +30 -7
- package/dist/agents/middleware/summarization.d.cts.map +1 -1
- package/dist/agents/middleware/summarization.d.ts +30 -7
- package/dist/agents/middleware/summarization.d.ts.map +1 -1
- package/dist/agents/middleware/todoListMiddleware.d.cts +42 -1
- package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -1
- package/dist/agents/middleware/todoListMiddleware.d.ts +42 -1
- package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -1
- package/dist/agents/middleware/toolCallLimit.d.cts +2 -1
- package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
- package/dist/agents/middleware/toolCallLimit.d.ts +2 -1
- package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
- package/dist/agents/middleware/types.cjs.map +1 -1
- package/dist/agents/middleware/types.d.cts +125 -32
- package/dist/agents/middleware/types.d.cts.map +1 -1
- package/dist/agents/middleware/types.d.ts +125 -32
- package/dist/agents/middleware/types.d.ts.map +1 -1
- package/dist/agents/middleware/types.js.map +1 -1
- package/dist/agents/middleware.cjs +1 -1
- package/dist/agents/middleware.cjs.map +1 -1
- package/dist/agents/middleware.d.cts +4 -4
- package/dist/agents/middleware.d.cts.map +1 -1
- package/dist/agents/middleware.d.ts +4 -4
- package/dist/agents/middleware.d.ts.map +1 -1
- package/dist/agents/middleware.js +1 -1
- package/dist/agents/middleware.js.map +1 -1
- package/dist/agents/types.d.cts +254 -8
- package/dist/agents/types.d.cts.map +1 -1
- package/dist/agents/types.d.ts +254 -8
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/package.json +5 -5
- package/chat_models/universal.cjs +0 -1
- package/chat_models/universal.d.cts +0 -1
- package/chat_models/universal.d.ts +0 -1
- package/chat_models/universal.js +0 -1
- package/hub/node.cjs +0 -1
- package/hub/node.d.cts +0 -1
- package/hub/node.d.ts +0 -1
- package/hub/node.js +0 -1
- package/hub.cjs +0 -1
- package/hub.d.cts +0 -1
- package/hub.d.ts +0 -1
- package/hub.js +0 -1
- package/load/serializable.cjs +0 -1
- package/load/serializable.d.cts +0 -1
- package/load/serializable.d.ts +0 -1
- package/load/serializable.js +0 -1
- package/load.cjs +0 -1
- package/load.d.cts +0 -1
- package/load.d.ts +0 -1
- package/load.js +0 -1
- package/storage/encoder_backed.cjs +0 -1
- package/storage/encoder_backed.d.cts +0 -1
- package/storage/encoder_backed.d.ts +0 -1
- package/storage/encoder_backed.js +0 -1
- package/storage/file_system.cjs +0 -1
- package/storage/file_system.d.cts +0 -1
- package/storage/file_system.d.ts +0 -1
- package/storage/file_system.js +0 -1
- package/storage/in_memory.cjs +0 -1
- package/storage/in_memory.d.cts +0 -1
- package/storage/in_memory.d.ts +0 -1
- package/storage/in_memory.js +0 -1
|
@@ -11,7 +11,49 @@ import { InteropZodToStateDefinition } from "@langchain/langgraph/zod";
|
|
|
11
11
|
//#region src/agents/middleware/types.d.ts
|
|
12
12
|
type PromiseOrValue<T> = T | Promise<T>;
|
|
13
13
|
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Type bag that encapsulates all middleware type parameters.
|
|
16
|
+
*
|
|
17
|
+
* This interface bundles all the generic type parameters used throughout the middleware system
|
|
18
|
+
* into a single configuration object. This pattern simplifies type signatures and makes
|
|
19
|
+
* it easier to add new type parameters without changing multiple function signatures.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam TSchema - The middleware state schema type. Can be an `InteropZodObject` or `undefined`.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TContextSchema - The middleware context schema type. Can be an `InteropZodObject`,
|
|
24
|
+
* `InteropZodDefault`, `InteropZodOptional`, or `undefined`.
|
|
25
|
+
*
|
|
26
|
+
* @typeParam TFullContext - The full context type available to middleware hooks.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam TTools - The tools array type registered by the middleware.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Define a type configuration
|
|
33
|
+
* type MyMiddlewareTypes = MiddlewareTypeConfig<
|
|
34
|
+
* typeof myStateSchema,
|
|
35
|
+
* typeof myContextSchema,
|
|
36
|
+
* MyContextType,
|
|
37
|
+
* typeof myTools
|
|
38
|
+
* >;
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
interface MiddlewareTypeConfig<TSchema$1 extends InteropZodObject | undefined = InteropZodObject | undefined, TContextSchema$1 extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined, TFullContext = any, TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]> {
|
|
42
|
+
/** The middleware state schema type */
|
|
43
|
+
Schema: TSchema$1;
|
|
44
|
+
/** The middleware context schema type */
|
|
45
|
+
ContextSchema: TContextSchema$1;
|
|
46
|
+
/** The full context type */
|
|
47
|
+
FullContext: TFullContext;
|
|
48
|
+
/** The tools array type */
|
|
49
|
+
Tools: TTools;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Default type configuration for middleware.
|
|
53
|
+
* Used when no explicit type parameters are provided.
|
|
54
|
+
*/
|
|
55
|
+
type DefaultMiddlewareTypeConfig = MiddlewareTypeConfig;
|
|
56
|
+
type NormalizedSchemaInput<TSchema$1 extends InteropZodObject | undefined | never = any> = [TSchema$1] extends [never] ? AgentBuiltInState : TSchema$1 extends InteropZodObject ? InferInteropZodOutput<TSchema$1> & AgentBuiltInState : TSchema$1 extends Record<string, unknown> ? TSchema$1 & AgentBuiltInState : AgentBuiltInState;
|
|
15
57
|
/**
|
|
16
58
|
* Result type for middleware functions.
|
|
17
59
|
*/
|
|
@@ -45,12 +87,12 @@ interface ToolCallRequest<TState extends Record<string, unknown> = Record<string
|
|
|
45
87
|
* Handler function type for wrapping tool calls.
|
|
46
88
|
* Takes a tool call request and returns the tool result or a command.
|
|
47
89
|
*/
|
|
48
|
-
type ToolCallHandler<TSchema extends Record<string, unknown> = AgentBuiltInState, TContext = unknown> = (request: ToolCallRequest<TSchema, TContext>) => PromiseOrValue<ToolMessage | Command>;
|
|
90
|
+
type ToolCallHandler<TSchema$1 extends Record<string, unknown> = AgentBuiltInState, TContext = unknown> = (request: ToolCallRequest<TSchema$1, TContext>) => PromiseOrValue<ToolMessage | Command>;
|
|
49
91
|
/**
|
|
50
92
|
* Wrapper function type for the wrapToolCall hook.
|
|
51
93
|
* Allows middleware to intercept and modify tool execution.
|
|
52
94
|
*/
|
|
53
|
-
type WrapToolCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ToolCallRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: ToolCallHandler<NormalizedSchemaInput<TSchema>, TContext>) => PromiseOrValue<ToolMessage | Command>;
|
|
95
|
+
type WrapToolCallHook<TSchema$1 extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ToolCallRequest<NormalizedSchemaInput<TSchema$1>, TContext>, handler: ToolCallHandler<NormalizedSchemaInput<TSchema$1>, TContext>) => PromiseOrValue<ToolMessage | Command>;
|
|
54
96
|
/**
|
|
55
97
|
* Handler function type for wrapping model calls.
|
|
56
98
|
* Takes a model request and returns the AI message response.
|
|
@@ -58,7 +100,7 @@ type WrapToolCallHook<TSchema extends InteropZodObject | undefined = undefined,
|
|
|
58
100
|
* @param request - The model request containing model, messages, systemPrompt, tools, state, and runtime
|
|
59
101
|
* @returns The AI message response from the model
|
|
60
102
|
*/
|
|
61
|
-
type WrapModelCallHandler<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: Omit<ModelRequest<NormalizedSchemaInput<TSchema>, TContext>,
|
|
103
|
+
type WrapModelCallHandler<TSchema$1 extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: Omit<ModelRequest<NormalizedSchemaInput<TSchema$1>, TContext>,
|
|
62
104
|
/**
|
|
63
105
|
* allow to reset the system prompt or system message
|
|
64
106
|
*/
|
|
@@ -79,7 +121,7 @@ type WrapModelCallHandler<TSchema extends InteropZodObject | undefined = undefin
|
|
|
79
121
|
* @param handler - The function that invokes the model. Call this with a ModelRequest to get the response
|
|
80
122
|
* @returns The AI message response from the model (or a modified version)
|
|
81
123
|
*/
|
|
82
|
-
type WrapModelCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: WrapModelCallHandler<TSchema, TContext>) => PromiseOrValue<AIMessage>;
|
|
124
|
+
type WrapModelCallHook<TSchema$1 extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<NormalizedSchemaInput<TSchema$1>, TContext>, handler: WrapModelCallHandler<TSchema$1, TContext>) => PromiseOrValue<AIMessage>;
|
|
83
125
|
/**
|
|
84
126
|
* Handler function type for the beforeAgent hook.
|
|
85
127
|
* Called once at the start of agent invocation before any model calls or tool executions.
|
|
@@ -88,14 +130,14 @@ type WrapModelCallHook<TSchema extends InteropZodObject | undefined = undefined,
|
|
|
88
130
|
* @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.
|
|
89
131
|
* @returns A middleware result containing partial state updates or undefined to pass through
|
|
90
132
|
*/
|
|
91
|
-
type BeforeAgentHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;
|
|
133
|
+
type BeforeAgentHandler<TSchema$1, TContext> = (state: TSchema$1, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema$1>>>;
|
|
92
134
|
/**
|
|
93
135
|
* Hook type for the beforeAgent lifecycle event.
|
|
94
136
|
* Can be either a handler function or an object with a handler and optional jump targets.
|
|
95
137
|
* This hook is called once at the start of the agent invocation.
|
|
96
138
|
*/
|
|
97
|
-
type BeforeAgentHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeAgentHandler<NormalizedSchemaInput<TSchema>, TContext> | {
|
|
98
|
-
hook: BeforeAgentHandler<NormalizedSchemaInput<TSchema>, TContext>;
|
|
139
|
+
type BeforeAgentHook<TSchema$1 extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeAgentHandler<NormalizedSchemaInput<TSchema$1>, TContext> | {
|
|
140
|
+
hook: BeforeAgentHandler<NormalizedSchemaInput<TSchema$1>, TContext>;
|
|
99
141
|
canJumpTo?: JumpToTarget[];
|
|
100
142
|
};
|
|
101
143
|
/**
|
|
@@ -106,14 +148,14 @@ type BeforeAgentHook<TSchema extends InteropZodObject | undefined = undefined, T
|
|
|
106
148
|
* @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.
|
|
107
149
|
* @returns A middleware result containing partial state updates or undefined to pass through
|
|
108
150
|
*/
|
|
109
|
-
type BeforeModelHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;
|
|
151
|
+
type BeforeModelHandler<TSchema$1, TContext> = (state: TSchema$1, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema$1>>>;
|
|
110
152
|
/**
|
|
111
153
|
* Hook type for the beforeModel lifecycle event.
|
|
112
154
|
* Can be either a handler function or an object with a handler and optional jump targets.
|
|
113
155
|
* This hook is called before each model invocation.
|
|
114
156
|
*/
|
|
115
|
-
type BeforeModelHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeModelHandler<NormalizedSchemaInput<TSchema>, TContext> | {
|
|
116
|
-
hook: BeforeModelHandler<NormalizedSchemaInput<TSchema>, TContext>;
|
|
157
|
+
type BeforeModelHook<TSchema$1 extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeModelHandler<NormalizedSchemaInput<TSchema$1>, TContext> | {
|
|
158
|
+
hook: BeforeModelHandler<NormalizedSchemaInput<TSchema$1>, TContext>;
|
|
117
159
|
canJumpTo?: JumpToTarget[];
|
|
118
160
|
};
|
|
119
161
|
/**
|
|
@@ -125,14 +167,14 @@ type BeforeModelHook<TSchema extends InteropZodObject | undefined = undefined, T
|
|
|
125
167
|
* @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.
|
|
126
168
|
* @returns A middleware result containing partial state updates or undefined to pass through
|
|
127
169
|
*/
|
|
128
|
-
type AfterModelHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;
|
|
170
|
+
type AfterModelHandler<TSchema$1, TContext> = (state: TSchema$1, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema$1>>>;
|
|
129
171
|
/**
|
|
130
172
|
* Hook type for the afterModel lifecycle event.
|
|
131
173
|
* Can be either a handler function or an object with a handler and optional jump targets.
|
|
132
174
|
* This hook is called after each model invocation.
|
|
133
175
|
*/
|
|
134
|
-
type AfterModelHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterModelHandler<NormalizedSchemaInput<TSchema>, TContext> | {
|
|
135
|
-
hook: AfterModelHandler<NormalizedSchemaInput<TSchema>, TContext>;
|
|
176
|
+
type AfterModelHook<TSchema$1 extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterModelHandler<NormalizedSchemaInput<TSchema$1>, TContext> | {
|
|
177
|
+
hook: AfterModelHandler<NormalizedSchemaInput<TSchema$1>, TContext>;
|
|
136
178
|
canJumpTo?: JumpToTarget[];
|
|
137
179
|
};
|
|
138
180
|
/**
|
|
@@ -143,14 +185,14 @@ type AfterModelHook<TSchema extends InteropZodObject | undefined = undefined, TC
|
|
|
143
185
|
* @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.
|
|
144
186
|
* @returns A middleware result containing partial state updates or undefined to pass through
|
|
145
187
|
*/
|
|
146
|
-
type AfterAgentHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;
|
|
188
|
+
type AfterAgentHandler<TSchema$1, TContext> = (state: TSchema$1, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema$1>>>;
|
|
147
189
|
/**
|
|
148
190
|
* Hook type for the afterAgent lifecycle event.
|
|
149
191
|
* Can be either a handler function or an object with a handler and optional jump targets.
|
|
150
192
|
* This hook is called once at the end of the agent invocation.
|
|
151
193
|
*/
|
|
152
|
-
type AfterAgentHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterAgentHandler<NormalizedSchemaInput<TSchema>, TContext> | {
|
|
153
|
-
hook: AfterAgentHandler<NormalizedSchemaInput<TSchema>, TContext>;
|
|
194
|
+
type AfterAgentHook<TSchema$1 extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterAgentHandler<NormalizedSchemaInput<TSchema$1>, TContext> | {
|
|
195
|
+
hook: AfterAgentHandler<NormalizedSchemaInput<TSchema$1>, TContext>;
|
|
154
196
|
canJumpTo?: JumpToTarget[];
|
|
155
197
|
};
|
|
156
198
|
/**
|
|
@@ -161,13 +203,33 @@ type AfterAgentHook<TSchema extends InteropZodObject | undefined = undefined, TC
|
|
|
161
203
|
declare const MIDDLEWARE_BRAND: unique symbol;
|
|
162
204
|
/**
|
|
163
205
|
* Base middleware interface.
|
|
206
|
+
*
|
|
207
|
+
* @typeParam TSchema - The middleware state schema type
|
|
208
|
+
* @typeParam TContextSchema - The middleware context schema type
|
|
209
|
+
* @typeParam TFullContext - The full context type available to hooks
|
|
210
|
+
* @typeParam TTools - The tools array type registered by the middleware
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const middleware = createMiddleware({
|
|
215
|
+
* name: "myMiddleware",
|
|
216
|
+
* stateSchema: z.object({ count: z.number() }),
|
|
217
|
+
* tools: [myTool],
|
|
218
|
+
* });
|
|
219
|
+
* ```
|
|
164
220
|
*/
|
|
165
|
-
interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TContextSchema extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = any, TFullContext = any> {
|
|
221
|
+
interface AgentMiddleware<TSchema$1 extends InteropZodObject | undefined = any, TContextSchema$1 extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = any, TFullContext = any, TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]> {
|
|
166
222
|
/**
|
|
167
223
|
* Brand property to distinguish middleware instances from plain objects or functions.
|
|
168
224
|
* This is required and prevents accidental assignment of functions to middleware arrays.
|
|
169
225
|
*/
|
|
170
226
|
readonly [MIDDLEWARE_BRAND]: true;
|
|
227
|
+
/**
|
|
228
|
+
* Type marker for extracting the MiddlewareTypeConfig from a middleware instance.
|
|
229
|
+
* This is a phantom property used only for type inference.
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
readonly "~middlewareTypes"?: MiddlewareTypeConfig<TSchema$1, TContextSchema$1, TFullContext, TTools>;
|
|
171
233
|
/**
|
|
172
234
|
* The name of the middleware.
|
|
173
235
|
*/
|
|
@@ -179,7 +241,7 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
179
241
|
* - A Zod default object
|
|
180
242
|
* - Undefined
|
|
181
243
|
*/
|
|
182
|
-
stateSchema?: TSchema;
|
|
244
|
+
stateSchema?: TSchema$1;
|
|
183
245
|
/**
|
|
184
246
|
* The schema of the middleware context. Middleware context is read-only and not persisted between multiple invocations. It can be either:
|
|
185
247
|
* - A Zod object
|
|
@@ -187,11 +249,11 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
187
249
|
* - A Zod default object
|
|
188
250
|
* - Undefined
|
|
189
251
|
*/
|
|
190
|
-
contextSchema?: TContextSchema;
|
|
252
|
+
contextSchema?: TContextSchema$1;
|
|
191
253
|
/**
|
|
192
254
|
* Additional tools registered by the middleware.
|
|
193
255
|
*/
|
|
194
|
-
tools?:
|
|
256
|
+
tools?: TTools;
|
|
195
257
|
/**
|
|
196
258
|
* Wraps tool execution with custom logic. This allows you to:
|
|
197
259
|
* - Modify tool call parameters before execution
|
|
@@ -254,7 +316,7 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
254
316
|
* }
|
|
255
317
|
* ```
|
|
256
318
|
*/
|
|
257
|
-
wrapToolCall?: WrapToolCallHook<TSchema, TFullContext>;
|
|
319
|
+
wrapToolCall?: WrapToolCallHook<TSchema$1, TFullContext>;
|
|
258
320
|
/**
|
|
259
321
|
* Wraps the model invocation with custom logic. This allows you to:
|
|
260
322
|
* - Modify the request before calling the model
|
|
@@ -283,7 +345,7 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
283
345
|
* }
|
|
284
346
|
* ```
|
|
285
347
|
*/
|
|
286
|
-
wrapModelCall?: WrapModelCallHook<TSchema, TFullContext>;
|
|
348
|
+
wrapModelCall?: WrapModelCallHook<TSchema$1, TFullContext>;
|
|
287
349
|
/**
|
|
288
350
|
* The function to run before the agent execution starts. This function is called once at the start of the agent invocation.
|
|
289
351
|
* It allows to modify the state of the agent before any model calls or tool executions.
|
|
@@ -292,7 +354,7 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
292
354
|
* @param runtime - The middleware runtime
|
|
293
355
|
* @returns The modified middleware state or undefined to pass through
|
|
294
356
|
*/
|
|
295
|
-
beforeAgent?: BeforeAgentHook<TSchema, TFullContext>;
|
|
357
|
+
beforeAgent?: BeforeAgentHook<TSchema$1, TFullContext>;
|
|
296
358
|
/**
|
|
297
359
|
* The function to run before the model call. This function is called before the model is invoked and before the `wrapModelCall` hook.
|
|
298
360
|
* It allows to modify the state of the agent.
|
|
@@ -301,7 +363,7 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
301
363
|
* @param runtime - The middleware runtime
|
|
302
364
|
* @returns The modified middleware state or undefined to pass through
|
|
303
365
|
*/
|
|
304
|
-
beforeModel?: BeforeModelHook<TSchema, TFullContext>;
|
|
366
|
+
beforeModel?: BeforeModelHook<TSchema$1, TFullContext>;
|
|
305
367
|
/**
|
|
306
368
|
* The function to run after the model call. This function is called after the model is invoked and before any tools are called.
|
|
307
369
|
* It allows to modify the state of the agent after the model is invoked, e.g. to update tool call parameters.
|
|
@@ -310,7 +372,7 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
310
372
|
* @param runtime - The middleware runtime
|
|
311
373
|
* @returns The modified middleware state or undefined to pass through
|
|
312
374
|
*/
|
|
313
|
-
afterModel?: AfterModelHook<TSchema, TFullContext>;
|
|
375
|
+
afterModel?: AfterModelHook<TSchema$1, TFullContext>;
|
|
314
376
|
/**
|
|
315
377
|
* The function to run after the agent execution completes. This function is called once at the end of the agent invocation.
|
|
316
378
|
* It allows to modify the final state of the agent after all model calls and tool executions are complete.
|
|
@@ -319,23 +381,54 @@ interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TC
|
|
|
319
381
|
* @param runtime - The middleware runtime
|
|
320
382
|
* @returns The modified middleware state or undefined to pass through
|
|
321
383
|
*/
|
|
322
|
-
afterAgent?: AfterAgentHook<TSchema, TFullContext>;
|
|
384
|
+
afterAgent?: AfterAgentHook<TSchema$1, TFullContext>;
|
|
323
385
|
}
|
|
324
386
|
/**
|
|
325
387
|
* Helper type to filter out properties that start with underscore (private properties)
|
|
326
388
|
*/
|
|
327
389
|
type FilterPrivateProps<T> = { [K in keyof T as K extends `_${string}` ? never : K]: T[K] };
|
|
390
|
+
/**
|
|
391
|
+
* Helper type to resolve a MiddlewareTypeConfig from either:
|
|
392
|
+
* - A MiddlewareTypeConfig directly
|
|
393
|
+
* - An AgentMiddleware instance (using `typeof middleware`)
|
|
394
|
+
*/
|
|
395
|
+
type ResolveMiddlewareTypeConfig<T> = T extends {
|
|
396
|
+
"~middlewareTypes"?: infer Types;
|
|
397
|
+
} ? Types extends MiddlewareTypeConfig ? Types : never : T extends MiddlewareTypeConfig ? T : never;
|
|
398
|
+
/**
|
|
399
|
+
* Helper type to extract any property from a MiddlewareTypeConfig or AgentMiddleware.
|
|
400
|
+
*
|
|
401
|
+
* @typeParam T - The MiddlewareTypeConfig or AgentMiddleware to extract from
|
|
402
|
+
* @typeParam K - The property key to extract ("Schema" | "ContextSchema" | "FullContext" | "Tools")
|
|
403
|
+
*/
|
|
404
|
+
type InferMiddlewareType<T, K$1 extends keyof MiddlewareTypeConfig> = ResolveMiddlewareTypeConfig<T>[K$1];
|
|
405
|
+
/**
|
|
406
|
+
* Shorthand helper to extract the Schema type from a MiddlewareTypeConfig or AgentMiddleware.
|
|
407
|
+
*/
|
|
408
|
+
type InferMiddlewareSchema<T> = InferMiddlewareType<T, "Schema">;
|
|
409
|
+
/**
|
|
410
|
+
* Shorthand helper to extract the ContextSchema type from a MiddlewareTypeConfig or AgentMiddleware.
|
|
411
|
+
*/
|
|
412
|
+
type InferMiddlewareContextSchema<T> = InferMiddlewareType<T, "ContextSchema">;
|
|
413
|
+
/**
|
|
414
|
+
* Shorthand helper to extract the FullContext type from a MiddlewareTypeConfig or AgentMiddleware.
|
|
415
|
+
*/
|
|
416
|
+
type InferMiddlewareFullContext<T> = InferMiddlewareType<T, "FullContext">;
|
|
417
|
+
/**
|
|
418
|
+
* Shorthand helper to extract the Tools type from a MiddlewareTypeConfig or AgentMiddleware.
|
|
419
|
+
*/
|
|
420
|
+
type InferMiddlewareToolsFromConfig<T> = InferMiddlewareType<T, "Tools">;
|
|
328
421
|
type InferChannelType<T extends AnyAnnotationRoot | InteropZodObject> = T extends AnyAnnotationRoot ? ToAnnotationRoot<T>["State"] : T extends InteropZodObject ? InferInteropZodInput<T> : {};
|
|
329
422
|
/**
|
|
330
423
|
* Helper type to infer the state schema type from a middleware
|
|
331
424
|
* This filters out private properties (those starting with underscore)
|
|
332
425
|
*/
|
|
333
|
-
type InferMiddlewareState<T extends AgentMiddleware> = T extends AgentMiddleware<infer
|
|
426
|
+
type InferMiddlewareState<T extends AgentMiddleware> = T extends AgentMiddleware<infer TSchema, any, any, any> ? TSchema extends InteropZodObject ? FilterPrivateProps<InferInteropZodOutput<TSchema>> : {} : {};
|
|
334
427
|
/**
|
|
335
428
|
* Helper type to infer the input state schema type from a middleware (all properties optional)
|
|
336
429
|
* This filters out private properties (those starting with underscore)
|
|
337
430
|
*/
|
|
338
|
-
type InferMiddlewareInputState<T extends AgentMiddleware> = T extends AgentMiddleware<infer
|
|
431
|
+
type InferMiddlewareInputState<T extends AgentMiddleware> = T extends AgentMiddleware<infer TSchema, any, any, any> ? TSchema extends InteropZodObject ? FilterPrivateProps<InferInteropZodInput<TSchema>> : {} : {};
|
|
339
432
|
/**
|
|
340
433
|
* Helper type to infer merged state from an array of middleware (just the middleware states)
|
|
341
434
|
*/
|
|
@@ -355,11 +448,11 @@ type InferMergedInputState<T extends readonly AgentMiddleware[]> = InferMiddlewa
|
|
|
355
448
|
/**
|
|
356
449
|
* Helper type to infer the context schema type from a middleware
|
|
357
450
|
*/
|
|
358
|
-
type InferMiddlewareContext<T extends AgentMiddleware> = T extends AgentMiddleware<any, infer
|
|
451
|
+
type InferMiddlewareContext<T extends AgentMiddleware> = T extends AgentMiddleware<any, infer TContextSchema, any, any> ? TContextSchema extends InteropZodObject ? InferInteropZodInput<TContextSchema> : {} : {};
|
|
359
452
|
/**
|
|
360
453
|
* Helper type to infer the input context schema type from a middleware (with optional defaults)
|
|
361
454
|
*/
|
|
362
|
-
type InferMiddlewareContextInput<T extends AgentMiddleware> = T extends AgentMiddleware<any, infer
|
|
455
|
+
type InferMiddlewareContextInput<T extends AgentMiddleware> = T extends AgentMiddleware<any, infer TContextSchema, any, any> ? TContextSchema extends InteropZodOptional<infer Inner> ? InferInteropZodInput<Inner> | undefined : TContextSchema extends InteropZodObject ? InferInteropZodInput<TContextSchema> : {} : {};
|
|
363
456
|
/**
|
|
364
457
|
* Helper type to infer merged context from an array of middleware
|
|
365
458
|
*/
|
|
@@ -379,5 +472,5 @@ type InferContextInput<ContextSchema extends AnyAnnotationRoot | InteropZodObjec
|
|
|
379
472
|
type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;
|
|
380
473
|
type InferSchemaInput<A extends AnyAnnotationRoot | InteropZodObject | undefined> = A extends AnyAnnotationRoot | InteropZodObject ? ToAnnotationRoot<A>["State"] : {};
|
|
381
474
|
//#endregion
|
|
382
|
-
export { AfterAgentHook, AfterModelHook, AgentMiddleware, AnyAnnotationRoot, BeforeAgentHook, BeforeModelHook, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContexts, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareState, InferMiddlewareStates, InferSchemaInput, MIDDLEWARE_BRAND, MiddlewareResult, NormalizedSchemaInput, ToAnnotationRoot, ToolCallHandler, ToolCallRequest, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook };
|
|
475
|
+
export { AfterAgentHook, AfterModelHook, AgentMiddleware, AnyAnnotationRoot, BeforeAgentHook, BeforeModelHook, DefaultMiddlewareTypeConfig, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContextSchema, InferMiddlewareContexts, InferMiddlewareFullContext, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareSchema, InferMiddlewareState, InferMiddlewareStates, InferMiddlewareToolsFromConfig, InferMiddlewareType, InferSchemaInput, MIDDLEWARE_BRAND, MiddlewareResult, MiddlewareTypeConfig, NormalizedSchemaInput, ResolveMiddlewareTypeConfig, ToAnnotationRoot, ToolCallHandler, ToolCallRequest, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook };
|
|
383
476
|
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":["InteropZodObject","InteropZodDefault","InteropZodOptional","InferInteropZodInput","InferInteropZodOutput","InteropZodToStateDefinition","AnnotationRoot","AIMessage","SystemMessage","ToolMessage","ToolCall","Command","ClientTool","ServerTool","JumpToTarget","Runtime","AgentBuiltInState","ModelRequest","PromiseOrValue","T","Promise","AnyAnnotationRoot","NormalizedSchemaInput","TSchema","Record","MiddlewareResult","TState","ToolCallRequest","TContext","ToolCallHandler","WrapToolCallHook","WrapModelCallHandler","Omit","WrapModelCallHook","BeforeAgentHandler","Partial","BeforeAgentHook","BeforeModelHandler","BeforeModelHook","AfterModelHandler","AfterModelHook","AfterAgentHandler","AfterAgentHook","MIDDLEWARE_BRAND","AgentMiddleware","TContextSchema","TFullContext","FilterPrivateProps","K","InferChannelType","ToAnnotationRoot","InferMiddlewareState","S","InferMiddlewareInputState","InferMiddlewareStates","First","Rest","InferMiddlewareInputStates","InferMergedState","InferMergedInputState","InferMiddlewareContext","C","InferMiddlewareContextInput","Inner","InferMiddlewareContexts","MergeContextTypes","A","B","InferMiddlewareContextInputs","InferContextInput","ContextSchema","InferSchemaInput"],"sources":["../../../src/agents/middleware/types.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodDefault, InteropZodOptional, InferInteropZodInput, InferInteropZodOutput } from \"@langchain/core/utils/types\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport type { AnnotationRoot } from \"@langchain/langgraph\";\nimport type { AIMessage, SystemMessage, ToolMessage } from \"@langchain/core/messages\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport type { Command } from \"@langchain/langgraph\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime, AgentBuiltInState } from \"../runtime.js\";\nimport type { ModelRequest } from \"../nodes/types.js\";\ntype PromiseOrValue<T> = T | Promise<T>;\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\nexport type NormalizedSchemaInput<TSchema extends InteropZodObject | undefined | never = any> = [TSchema] extends [never] ? AgentBuiltInState : TSchema extends InteropZodObject ? InferInteropZodOutput<TSchema> & AgentBuiltInState : TSchema extends Record<string, unknown> ? TSchema & AgentBuiltInState : AgentBuiltInState;\n/**\n * Result type for middleware functions.\n */\nexport type MiddlewareResult<TState> = (TState & {\n jumpTo?: JumpToTarget;\n}) | void;\n/**\n * Represents a tool call request for the wrapToolCall hook.\n * Contains the tool call information along with the agent's current state and runtime.\n */\nexport interface ToolCallRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {\n /**\n * The tool call to be executed\n */\n toolCall: ToolCall;\n /**\n * The BaseTool instance being invoked.\n * Provides access to tool metadata like name, description, schema, etc.\n */\n tool: ClientTool | ServerTool;\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/**\n * Handler function type for wrapping tool calls.\n * Takes a tool call request and returns the tool result or a command.\n */\nexport type ToolCallHandler<TSchema extends Record<string, unknown> = AgentBuiltInState, TContext = unknown> = (request: ToolCallRequest<TSchema, TContext>) => PromiseOrValue<ToolMessage | Command>;\n/**\n * Wrapper function type for the wrapToolCall hook.\n * Allows middleware to intercept and modify tool execution.\n */\nexport type WrapToolCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ToolCallRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: ToolCallHandler<NormalizedSchemaInput<TSchema>, TContext>) => PromiseOrValue<ToolMessage | Command>;\n/**\n * Handler function type for wrapping model calls.\n * Takes a model request and returns the AI message response.\n *\n * @param request - The model request containing model, messages, systemPrompt, tools, state, and runtime\n * @returns The AI message response from the model\n */\nexport type WrapModelCallHandler<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: Omit<ModelRequest<NormalizedSchemaInput<TSchema>, TContext>, \n/**\n * allow to reset the system prompt or system message\n */\n\"systemPrompt\" | \"systemMessage\"> & {\n systemPrompt?: string;\n systemMessage?: SystemMessage;\n}) => PromiseOrValue<AIMessage>;\n/**\n * Wrapper function type for the wrapModelCall hook.\n * Allows middleware to intercept and modify model execution.\n * This enables you to:\n * - Modify the request before calling the model (e.g., change system prompt, add/remove tools)\n * - Handle errors and retry with different parameters\n * - Post-process the response\n * - Implement custom caching, logging, or other cross-cutting concerns\n *\n * @param request - The model request containing all parameters needed for the model call\n * @param handler - The function that invokes the model. Call this with a ModelRequest to get the response\n * @returns The AI message response from the model (or a modified version)\n */\nexport type WrapModelCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: WrapModelCallHandler<TSchema, TContext>) => PromiseOrValue<AIMessage>;\n/**\n * Handler function type for the beforeAgent hook.\n * Called once at the start of agent invocation before any model calls or tool executions.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype BeforeAgentHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the beforeAgent lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called once at the start of the agent invocation.\n */\nexport type BeforeAgentHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeAgentHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: BeforeAgentHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Handler function type for the beforeModel hook.\n * Called before the model is invoked and before the wrapModelCall hook.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype BeforeModelHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the beforeModel lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called before each model invocation.\n */\nexport type BeforeModelHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeModelHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: BeforeModelHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Handler function type for the afterModel hook.\n * Called after the model is invoked and before any tools are called.\n * Allows modifying the agent state after model invocation, e.g., to update tool call parameters.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype AfterModelHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the afterModel lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called after each model invocation.\n */\nexport type AfterModelHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterModelHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: AfterModelHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Handler function type for the afterAgent hook.\n * Called once at the end of agent invocation after all model calls and tool executions are complete.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype AfterAgentHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the afterAgent lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called once at the end of the agent invocation.\n */\nexport type AfterAgentHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterAgentHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: AfterAgentHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Unique symbol used to brand middleware instances.\n * This prevents functions from being accidentally assignable to AgentMiddleware\n * since functions have a 'name' property that would otherwise make them structurally compatible.\n */\nexport declare const MIDDLEWARE_BRAND: unique symbol;\n/**\n * Base middleware interface.\n */\nexport interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TContextSchema extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = any, TFullContext = any> {\n /**\n * Brand property to distinguish middleware instances from plain objects or functions.\n * This is required and prevents accidental assignment of functions to middleware arrays.\n */\n readonly [MIDDLEWARE_BRAND]: true;\n /**\n * The name of the middleware.\n */\n name: string;\n /**\n * The schema of the middleware state. Middleware state is persisted between multiple invocations. It can be either:\n * - A Zod object\n * - A Zod optional object\n * - A Zod default object\n * - Undefined\n */\n stateSchema?: TSchema;\n /**\n * The schema of the middleware context. Middleware context is read-only and not persisted between multiple invocations. It can be either:\n * - A Zod object\n * - A Zod optional object\n * - A Zod default object\n * - Undefined\n */\n contextSchema?: TContextSchema;\n /**\n * Additional tools registered by the middleware.\n */\n tools?: (ClientTool | ServerTool)[];\n /**\n * Wraps tool execution with custom logic. This allows you to:\n * - Modify tool call parameters before execution\n * - Handle errors and retry with different parameters\n * - Post-process tool results\n * - Implement caching, logging, authentication, or other cross-cutting concerns\n * - Return Command objects for advanced control flow\n *\n * The handler receives a ToolCallRequest containing the tool call, state, and runtime,\n * along with a handler function to execute the actual tool.\n *\n * @param request - The tool call request containing toolCall, state, and runtime.\n * @param handler - The function that executes the tool. Call this with a ToolCallRequest to get the result.\n * @returns The tool result as a ToolMessage or a Command for advanced control flow.\n *\n * @example\n * ```ts\n * wrapToolCall: async (request, handler) => {\n * console.log(`Calling tool: ${request.tool.name}`);\n * console.log(`Tool description: ${request.tool.description}`);\n *\n * try {\n * // Execute the tool\n * const result = await handler(request);\n * console.log(`Tool ${request.tool.name} succeeded`);\n * return result;\n * } catch (error) {\n * console.error(`Tool ${request.tool.name} failed:`, error);\n * // Could return a custom error message or retry\n * throw error;\n * }\n * }\n * ```\n *\n * @example Authentication\n * ```ts\n * wrapToolCall: async (request, handler) => {\n * // Check if user is authorized for this tool\n * if (!request.runtime.context.isAuthorized(request.tool.name)) {\n * return new ToolMessage({\n * content: \"Unauthorized to call this tool\",\n * tool_call_id: request.toolCall.id,\n * });\n * }\n * return handler(request);\n * }\n * ```\n *\n * @example Caching\n * ```ts\n * const cache = new Map();\n * wrapToolCall: async (request, handler) => {\n * const cacheKey = `${request.tool.name}:${JSON.stringify(request.toolCall.args)}`;\n * if (cache.has(cacheKey)) {\n * return cache.get(cacheKey);\n * }\n * const result = await handler(request);\n * cache.set(cacheKey, result);\n * return result;\n * }\n * ```\n */\n wrapToolCall?: WrapToolCallHook<TSchema, TFullContext>;\n /**\n * Wraps the model invocation with custom logic. This allows you to:\n * - Modify the request before calling the model\n * - Handle errors and retry with different parameters\n * - Post-process the response\n * - Implement custom caching, logging, or other cross-cutting concerns\n *\n * @param request - The model request containing model, messages, systemPrompt, tools, state, and runtime.\n * @param handler - The function that invokes the model. Call this with a ModelRequest to get the response.\n * @returns The response from the model (or a modified version).\n *\n * @example\n * ```ts\n * wrapModelCall: async (request, handler) => {\n * // Modify request before calling\n * const modifiedRequest = { ...request, systemPrompt: \"You are helpful\" };\n *\n * try {\n * // Call the model\n * return await handler(modifiedRequest);\n * } catch (error) {\n * // Handle errors and retry with fallback\n * const fallbackRequest = { ...request, model: fallbackModel };\n * return await handler(fallbackRequest);\n * }\n * }\n * ```\n */\n wrapModelCall?: WrapModelCallHook<TSchema, TFullContext>;\n /**\n * The function to run before the agent execution starts. This function is called once at the start of the agent invocation.\n * It allows to modify the state of the agent before any model calls or tool executions.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n beforeAgent?: BeforeAgentHook<TSchema, TFullContext>;\n /**\n * The function to run before the model call. This function is called before the model is invoked and before the `wrapModelCall` hook.\n * It allows to modify the state of the agent.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n beforeModel?: BeforeModelHook<TSchema, TFullContext>;\n /**\n * The function to run after the model call. This function is called after the model is invoked and before any tools are called.\n * It allows to modify the state of the agent after the model is invoked, e.g. to update tool call parameters.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n afterModel?: AfterModelHook<TSchema, TFullContext>;\n /**\n * The function to run after the agent execution completes. This function is called once at the end of the agent invocation.\n * It allows to modify the final state of the agent after all model calls and tool executions are complete.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n afterAgent?: AfterAgentHook<TSchema, TFullContext>;\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};\nexport type InferChannelType<T extends AnyAnnotationRoot | InteropZodObject> = T extends AnyAnnotationRoot ? ToAnnotationRoot<T>[\"State\"] : T extends InteropZodObject ? InferInteropZodInput<T> : {};\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> = 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> = 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 = AgentMiddleware[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? 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[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? 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[]> = 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[]> = InferMiddlewareInputStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer the context schema type from a middleware\n */\nexport type InferMiddlewareContext<T extends AgentMiddleware> = 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> = 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[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? 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[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? MergeContextTypes<InferMiddlewareContextInput<First>, InferMiddlewareContextInputs<Rest>> : InferMiddlewareContextInput<First> : {} : {};\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\"] : {};\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\nexport type InferSchemaInput<A extends AnyAnnotationRoot | InteropZodObject | undefined> = A extends AnyAnnotationRoot | InteropZodObject ? ToAnnotationRoot<A>[\"State\"] : {};\nexport {};\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;;;;;KAUKkB,oBAAoBC,IAAIC,QAAQD;AAAhCD,KACOG,iBAAAA,GAAoBf,cADb,CAAA,GAAA,CAAA;AAAMa,KAEbG,qBAFaH,CAAAA,gBAEyBnB,gBAFzBmB,GAAAA,SAAAA,GAAAA,KAAAA,GAAAA,GAAAA,CAAAA,GAAAA,CAEwEI,OAFxEJ,CAAAA,SAAAA,CAAAA,KAAAA,CAAAA,GAEmGH,i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PX,KAKjPW,CAAAA,GAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAAA;;;;AAA6B5D,KADlI+D,iBACkI/D,CAAAA,sBAD1Fe,iBAC0Ff,GADtEN,gBACsEM,CAAAA,GADlDgE,aACkDhE,SAD5BN,gBAC4BM,GADTH,oBACSG,CADYgE,aACZhE,CAAAA,GAD6BgE,aAC7BhE,SADmDe,iBACnDf,GADuE4C,gBACvE5C,CADwFgE,aACxFhE,CAAAA,CAAAA,OAAAA,CAAAA,GAAAA,CAAAA,CAAAA;AAAc,KAAhJ4C,gBAAgJ,CAAA,UAArH7B,iBAAqH,GAAjGrB,gBAAiG,CAAA,GAA7EkE,CAA6E,SAAnE7C,iBAAmE,GAA/C6C,CAA+C,GAA3CA,CAA2C,SAAjClE,gBAAiC,GAAdM,cAAc,CAACD,2BAAD,CAA6B6D,CAA7B,CAAA,CAAA,GAAA,KAAA;AAChJK,KAAAA,gBAAgB,CAAAL,UAAW7C,iBAAX,GAA+BrB,gBAA/B,GAAA,SAAA,CAAA,GAA+DkE,CAA/D,SAAyE7C,iBAAzE,GAA6FrB,gBAA7F,GAAgHkD,gBAAhH,CAAiIgB,CAAjI,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":["InteropZodObject","InteropZodDefault","InteropZodOptional","InferInteropZodInput","InferInteropZodOutput","InteropZodToStateDefinition","AnnotationRoot","AIMessage","SystemMessage","ToolMessage","ToolCall","Command","ClientTool","ServerTool","JumpToTarget","Runtime","AgentBuiltInState","ModelRequest","PromiseOrValue","T","Promise","AnyAnnotationRoot","MiddlewareTypeConfig","TSchema","TContextSchema","TFullContext","TTools","DefaultMiddlewareTypeConfig","NormalizedSchemaInput","Record","MiddlewareResult","TState","ToolCallRequest","TContext","ToolCallHandler","WrapToolCallHook","WrapModelCallHandler","Omit","WrapModelCallHook","BeforeAgentHandler","Partial","BeforeAgentHook","BeforeModelHandler","BeforeModelHook","AfterModelHandler","AfterModelHook","AfterAgentHandler","AfterAgentHook","MIDDLEWARE_BRAND","AgentMiddleware","FilterPrivateProps","K","ResolveMiddlewareTypeConfig","Types","InferMiddlewareType","InferMiddlewareSchema","InferMiddlewareContextSchema","InferMiddlewareFullContext","InferMiddlewareToolsFromConfig","InferChannelType","ToAnnotationRoot","InferMiddlewareState","InferMiddlewareInputState","InferMiddlewareStates","First","Rest","InferMiddlewareInputStates","InferMergedState","InferMergedInputState","InferMiddlewareContext","InferMiddlewareContextInput","Inner","InferMiddlewareContexts","MergeContextTypes","A","B","InferMiddlewareContextInputs","InferContextInput","ContextSchema","InferSchemaInput"],"sources":["../../../src/agents/middleware/types.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodDefault, InteropZodOptional, InferInteropZodInput, InferInteropZodOutput } from \"@langchain/core/utils/types\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport type { AnnotationRoot } from \"@langchain/langgraph\";\nimport type { AIMessage, SystemMessage, ToolMessage } from \"@langchain/core/messages\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport type { Command } from \"@langchain/langgraph\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime, AgentBuiltInState } from \"../runtime.js\";\nimport type { ModelRequest } from \"../nodes/types.js\";\ntype PromiseOrValue<T> = T | Promise<T>;\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n/**\n * Type bag that encapsulates all middleware type parameters.\n *\n * This interface bundles all the generic type parameters used throughout the middleware system\n * into a single configuration object. This pattern simplifies type signatures and makes\n * it easier to add new type parameters without changing multiple function signatures.\n *\n * @typeParam TSchema - The middleware state schema type. Can be an `InteropZodObject` or `undefined`.\n *\n * @typeParam TContextSchema - The middleware context schema type. Can be an `InteropZodObject`,\n * `InteropZodDefault`, `InteropZodOptional`, or `undefined`.\n *\n * @typeParam TFullContext - The full context type available to middleware hooks.\n *\n * @typeParam TTools - The tools array type registered by the middleware.\n *\n * @example\n * ```typescript\n * // Define a type configuration\n * type MyMiddlewareTypes = MiddlewareTypeConfig<\n * typeof myStateSchema,\n * typeof myContextSchema,\n * MyContextType,\n * typeof myTools\n * >;\n * ```\n */\nexport interface MiddlewareTypeConfig<TSchema extends InteropZodObject | undefined = InteropZodObject | undefined, TContextSchema extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined, TFullContext = any, TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]> {\n /** The middleware state schema type */\n Schema: TSchema;\n /** The middleware context schema type */\n ContextSchema: TContextSchema;\n /** The full context type */\n FullContext: TFullContext;\n /** The tools array type */\n Tools: TTools;\n}\n/**\n * Default type configuration for middleware.\n * Used when no explicit type parameters are provided.\n */\nexport type DefaultMiddlewareTypeConfig = MiddlewareTypeConfig;\nexport type NormalizedSchemaInput<TSchema extends InteropZodObject | undefined | never = any> = [TSchema] extends [never] ? AgentBuiltInState : TSchema extends InteropZodObject ? InferInteropZodOutput<TSchema> & AgentBuiltInState : TSchema extends Record<string, unknown> ? TSchema & AgentBuiltInState : AgentBuiltInState;\n/**\n * Result type for middleware functions.\n */\nexport type MiddlewareResult<TState> = (TState & {\n jumpTo?: JumpToTarget;\n}) | void;\n/**\n * Represents a tool call request for the wrapToolCall hook.\n * Contains the tool call information along with the agent's current state and runtime.\n */\nexport interface ToolCallRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {\n /**\n * The tool call to be executed\n */\n toolCall: ToolCall;\n /**\n * The BaseTool instance being invoked.\n * Provides access to tool metadata like name, description, schema, etc.\n */\n tool: ClientTool | ServerTool;\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/**\n * Handler function type for wrapping tool calls.\n * Takes a tool call request and returns the tool result or a command.\n */\nexport type ToolCallHandler<TSchema extends Record<string, unknown> = AgentBuiltInState, TContext = unknown> = (request: ToolCallRequest<TSchema, TContext>) => PromiseOrValue<ToolMessage | Command>;\n/**\n * Wrapper function type for the wrapToolCall hook.\n * Allows middleware to intercept and modify tool execution.\n */\nexport type WrapToolCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ToolCallRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: ToolCallHandler<NormalizedSchemaInput<TSchema>, TContext>) => PromiseOrValue<ToolMessage | Command>;\n/**\n * Handler function type for wrapping model calls.\n * Takes a model request and returns the AI message response.\n *\n * @param request - The model request containing model, messages, systemPrompt, tools, state, and runtime\n * @returns The AI message response from the model\n */\nexport type WrapModelCallHandler<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: Omit<ModelRequest<NormalizedSchemaInput<TSchema>, TContext>, \n/**\n * allow to reset the system prompt or system message\n */\n\"systemPrompt\" | \"systemMessage\"> & {\n systemPrompt?: string;\n systemMessage?: SystemMessage;\n}) => PromiseOrValue<AIMessage>;\n/**\n * Wrapper function type for the wrapModelCall hook.\n * Allows middleware to intercept and modify model execution.\n * This enables you to:\n * - Modify the request before calling the model (e.g., change system prompt, add/remove tools)\n * - Handle errors and retry with different parameters\n * - Post-process the response\n * - Implement custom caching, logging, or other cross-cutting concerns\n *\n * @param request - The model request containing all parameters needed for the model call\n * @param handler - The function that invokes the model. Call this with a ModelRequest to get the response\n * @returns The AI message response from the model (or a modified version)\n */\nexport type WrapModelCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: WrapModelCallHandler<TSchema, TContext>) => PromiseOrValue<AIMessage>;\n/**\n * Handler function type for the beforeAgent hook.\n * Called once at the start of agent invocation before any model calls or tool executions.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype BeforeAgentHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the beforeAgent lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called once at the start of the agent invocation.\n */\nexport type BeforeAgentHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeAgentHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: BeforeAgentHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Handler function type for the beforeModel hook.\n * Called before the model is invoked and before the wrapModelCall hook.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype BeforeModelHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the beforeModel lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called before each model invocation.\n */\nexport type BeforeModelHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = BeforeModelHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: BeforeModelHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Handler function type for the afterModel hook.\n * Called after the model is invoked and before any tools are called.\n * Allows modifying the agent state after model invocation, e.g., to update tool call parameters.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype AfterModelHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the afterModel lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called after each model invocation.\n */\nexport type AfterModelHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterModelHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: AfterModelHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Handler function type for the afterAgent hook.\n * Called once at the end of agent invocation after all model calls and tool executions are complete.\n *\n * @param state - The current agent state (includes both middleware state and built-in state)\n * @param runtime - The runtime context containing metadata, signal, writer, interrupt, etc.\n * @returns A middleware result containing partial state updates or undefined to pass through\n */\ntype AfterAgentHandler<TSchema, TContext> = (state: TSchema, runtime: Runtime<TContext>) => PromiseOrValue<MiddlewareResult<Partial<TSchema>>>;\n/**\n * Hook type for the afterAgent lifecycle event.\n * Can be either a handler function or an object with a handler and optional jump targets.\n * This hook is called once at the end of the agent invocation.\n */\nexport type AfterAgentHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = AfterAgentHandler<NormalizedSchemaInput<TSchema>, TContext> | {\n hook: AfterAgentHandler<NormalizedSchemaInput<TSchema>, TContext>;\n canJumpTo?: JumpToTarget[];\n};\n/**\n * Unique symbol used to brand middleware instances.\n * This prevents functions from being accidentally assignable to AgentMiddleware\n * since functions have a 'name' property that would otherwise make them structurally compatible.\n */\nexport declare const MIDDLEWARE_BRAND: unique symbol;\n/**\n * Base middleware interface.\n *\n * @typeParam TSchema - The middleware state schema type\n * @typeParam TContextSchema - The middleware context schema type\n * @typeParam TFullContext - The full context type available to hooks\n * @typeParam TTools - The tools array type registered by the middleware\n *\n * @example\n * ```typescript\n * const middleware = createMiddleware({\n * name: \"myMiddleware\",\n * stateSchema: z.object({ count: z.number() }),\n * tools: [myTool],\n * });\n * ```\n */\nexport interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TContextSchema extends InteropZodObject | InteropZodDefault<InteropZodObject> | InteropZodOptional<InteropZodObject> | undefined = any, TFullContext = any, TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]> {\n /**\n * Brand property to distinguish middleware instances from plain objects or functions.\n * This is required and prevents accidental assignment of functions to middleware arrays.\n */\n readonly [MIDDLEWARE_BRAND]: true;\n /**\n * Type marker for extracting the MiddlewareTypeConfig from a middleware instance.\n * This is a phantom property used only for type inference.\n * @internal\n */\n readonly \"~middlewareTypes\"?: MiddlewareTypeConfig<TSchema, TContextSchema, TFullContext, TTools>;\n /**\n * The name of the middleware.\n */\n name: string;\n /**\n * The schema of the middleware state. Middleware state is persisted between multiple invocations. It can be either:\n * - A Zod object\n * - A Zod optional object\n * - A Zod default object\n * - Undefined\n */\n stateSchema?: TSchema;\n /**\n * The schema of the middleware context. Middleware context is read-only and not persisted between multiple invocations. It can be either:\n * - A Zod object\n * - A Zod optional object\n * - A Zod default object\n * - Undefined\n */\n contextSchema?: TContextSchema;\n /**\n * Additional tools registered by the middleware.\n */\n tools?: TTools;\n /**\n * Wraps tool execution with custom logic. This allows you to:\n * - Modify tool call parameters before execution\n * - Handle errors and retry with different parameters\n * - Post-process tool results\n * - Implement caching, logging, authentication, or other cross-cutting concerns\n * - Return Command objects for advanced control flow\n *\n * The handler receives a ToolCallRequest containing the tool call, state, and runtime,\n * along with a handler function to execute the actual tool.\n *\n * @param request - The tool call request containing toolCall, state, and runtime.\n * @param handler - The function that executes the tool. Call this with a ToolCallRequest to get the result.\n * @returns The tool result as a ToolMessage or a Command for advanced control flow.\n *\n * @example\n * ```ts\n * wrapToolCall: async (request, handler) => {\n * console.log(`Calling tool: ${request.tool.name}`);\n * console.log(`Tool description: ${request.tool.description}`);\n *\n * try {\n * // Execute the tool\n * const result = await handler(request);\n * console.log(`Tool ${request.tool.name} succeeded`);\n * return result;\n * } catch (error) {\n * console.error(`Tool ${request.tool.name} failed:`, error);\n * // Could return a custom error message or retry\n * throw error;\n * }\n * }\n * ```\n *\n * @example Authentication\n * ```ts\n * wrapToolCall: async (request, handler) => {\n * // Check if user is authorized for this tool\n * if (!request.runtime.context.isAuthorized(request.tool.name)) {\n * return new ToolMessage({\n * content: \"Unauthorized to call this tool\",\n * tool_call_id: request.toolCall.id,\n * });\n * }\n * return handler(request);\n * }\n * ```\n *\n * @example Caching\n * ```ts\n * const cache = new Map();\n * wrapToolCall: async (request, handler) => {\n * const cacheKey = `${request.tool.name}:${JSON.stringify(request.toolCall.args)}`;\n * if (cache.has(cacheKey)) {\n * return cache.get(cacheKey);\n * }\n * const result = await handler(request);\n * cache.set(cacheKey, result);\n * return result;\n * }\n * ```\n */\n wrapToolCall?: WrapToolCallHook<TSchema, TFullContext>;\n /**\n * Wraps the model invocation with custom logic. This allows you to:\n * - Modify the request before calling the model\n * - Handle errors and retry with different parameters\n * - Post-process the response\n * - Implement custom caching, logging, or other cross-cutting concerns\n *\n * @param request - The model request containing model, messages, systemPrompt, tools, state, and runtime.\n * @param handler - The function that invokes the model. Call this with a ModelRequest to get the response.\n * @returns The response from the model (or a modified version).\n *\n * @example\n * ```ts\n * wrapModelCall: async (request, handler) => {\n * // Modify request before calling\n * const modifiedRequest = { ...request, systemPrompt: \"You are helpful\" };\n *\n * try {\n * // Call the model\n * return await handler(modifiedRequest);\n * } catch (error) {\n * // Handle errors and retry with fallback\n * const fallbackRequest = { ...request, model: fallbackModel };\n * return await handler(fallbackRequest);\n * }\n * }\n * ```\n */\n wrapModelCall?: WrapModelCallHook<TSchema, TFullContext>;\n /**\n * The function to run before the agent execution starts. This function is called once at the start of the agent invocation.\n * It allows to modify the state of the agent before any model calls or tool executions.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n beforeAgent?: BeforeAgentHook<TSchema, TFullContext>;\n /**\n * The function to run before the model call. This function is called before the model is invoked and before the `wrapModelCall` hook.\n * It allows to modify the state of the agent.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n beforeModel?: BeforeModelHook<TSchema, TFullContext>;\n /**\n * The function to run after the model call. This function is called after the model is invoked and before any tools are called.\n * It allows to modify the state of the agent after the model is invoked, e.g. to update tool call parameters.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n afterModel?: AfterModelHook<TSchema, TFullContext>;\n /**\n * The function to run after the agent execution completes. This function is called once at the end of the agent invocation.\n * It allows to modify the final state of the agent after all model calls and tool executions are complete.\n *\n * @param state - The middleware state\n * @param runtime - The middleware runtime\n * @returns The modified middleware state or undefined to pass through\n */\n afterAgent?: AfterAgentHook<TSchema, TFullContext>;\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 resolve a MiddlewareTypeConfig from either:\n * - A MiddlewareTypeConfig directly\n * - An AgentMiddleware instance (using `typeof middleware`)\n */\nexport type ResolveMiddlewareTypeConfig<T> = T extends {\n \"~middlewareTypes\"?: infer Types;\n} ? Types extends MiddlewareTypeConfig ? Types : never : T extends MiddlewareTypeConfig ? T : never;\n/**\n * Helper type to extract any property from a MiddlewareTypeConfig or AgentMiddleware.\n *\n * @typeParam T - The MiddlewareTypeConfig or AgentMiddleware to extract from\n * @typeParam K - The property key to extract (\"Schema\" | \"ContextSchema\" | \"FullContext\" | \"Tools\")\n */\nexport type InferMiddlewareType<T, K extends keyof MiddlewareTypeConfig> = ResolveMiddlewareTypeConfig<T>[K];\n/**\n * Shorthand helper to extract the Schema type from a MiddlewareTypeConfig or AgentMiddleware.\n */\nexport type InferMiddlewareSchema<T> = InferMiddlewareType<T, \"Schema\">;\n/**\n * Shorthand helper to extract the ContextSchema type from a MiddlewareTypeConfig or AgentMiddleware.\n */\nexport type InferMiddlewareContextSchema<T> = InferMiddlewareType<T, \"ContextSchema\">;\n/**\n * Shorthand helper to extract the FullContext type from a MiddlewareTypeConfig or AgentMiddleware.\n */\nexport type InferMiddlewareFullContext<T> = InferMiddlewareType<T, \"FullContext\">;\n/**\n * Shorthand helper to extract the Tools type from a MiddlewareTypeConfig or AgentMiddleware.\n */\nexport type InferMiddlewareToolsFromConfig<T> = InferMiddlewareType<T, \"Tools\">;\nexport type InferChannelType<T extends AnyAnnotationRoot | InteropZodObject> = T extends AnyAnnotationRoot ? ToAnnotationRoot<T>[\"State\"] : T extends InteropZodObject ? InferInteropZodInput<T> : {};\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> = T extends AgentMiddleware<infer TSchema, any, any, any> ? TSchema extends InteropZodObject ? FilterPrivateProps<InferInteropZodOutput<TSchema>> : {} : {};\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> = T extends AgentMiddleware<infer TSchema, any, any, any> ? TSchema extends InteropZodObject ? FilterPrivateProps<InferInteropZodInput<TSchema>> : {} : {};\n/**\n * Helper type to infer merged state from an array of middleware (just the middleware states)\n */\nexport type InferMiddlewareStates<T = AgentMiddleware[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? 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[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? 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[]> = 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[]> = InferMiddlewareInputStates<T> & AgentBuiltInState;\n/**\n * Helper type to infer the context schema type from a middleware\n */\nexport type InferMiddlewareContext<T extends AgentMiddleware> = T extends AgentMiddleware<any, infer TContextSchema, any, any> ? TContextSchema extends InteropZodObject ? InferInteropZodInput<TContextSchema> : {} : {};\n/**\n * Helper type to infer the input context schema type from a middleware (with optional defaults)\n */\nexport type InferMiddlewareContextInput<T extends AgentMiddleware> = T extends AgentMiddleware<any, infer TContextSchema, any, any> ? TContextSchema extends InteropZodOptional<infer Inner> ? InferInteropZodInput<Inner> | undefined : TContextSchema extends InteropZodObject ? InferInteropZodInput<TContextSchema> : {} : {};\n/**\n * Helper type to infer merged context from an array of middleware\n */\nexport type InferMiddlewareContexts<T extends readonly AgentMiddleware[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? 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[]> = T extends readonly [] ? {} : T extends readonly [infer First, ...infer Rest] ? First extends AgentMiddleware ? Rest extends readonly AgentMiddleware[] ? MergeContextTypes<InferMiddlewareContextInput<First>, InferMiddlewareContextInputs<Rest>> : InferMiddlewareContextInput<First> : {} : {};\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\"] : {};\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\nexport type InferSchemaInput<A extends AnyAnnotationRoot | InteropZodObject | undefined> = A extends AnyAnnotationRoot | InteropZodObject ? ToAnnotationRoot<A>[\"State\"] : {};\nexport {};\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;;;;;KAUKkB,oBAAoBC,IAAIC,QAAQD;AAAhCD,KACOG,iBAAAA,GAAoBf,cADb,CAAA,GAAA,CAAA;;;;AAAiB;AACpC;AA4BA;;;;;;;;;;;;;;;;;;;;;AAQiB;AAMLqB,UAdKL,oBAcsB,CAAA,kBAdetB,gBAcQ,GAAA,SAAA,GAduBA,gBAcvB,GAAA,SAAA,EAAA,yBAd4EA,gBAc5E,GAd+FC,iBAc/F,CAdiHD,gBAcjH,CAAA,GAdqIE,kBAcrI,CAdwJF,gBAcxJ,CAAA,GAAA,SAAA,GAdwLA,gBAcxL,GAd2MC,iBAc3M,CAd6ND,gBAc7N,CAAA,GAdiPE,kBAcjP,CAdoQF,gBAcpQ,CAAA,GAAA,SAAA,EAAA,eAAA,GAAA,EAAA,eAAA,SAAA,CAdgVY,UAchV,GAd6VC,UAc7V,CAAA,EAAA,GAAA,SAAA,CAduXD,UAcvX,GAdoYC,UAcpY,CAAA,EAAA,CAAA,CAAA;EAClDe;EAAsC5B,MAAAA,EAbtCuB,SAasCvB;EAA+CuB;EAA2BP,aAAAA,EAXzGQ,gBAWyGR;EAAoBO;EAAgBvB,WAAAA,EAT/IyB,YAS+IzB;EAAyCuB;EAAtBnB,KAAAA,EAPxKsB,MAOwKtB;;;;;;AAA6HY,KADpSW,2BAAAA,GAA8BL,oBACsQN;AAAiB,KAArTY,qBAAqT,CAAA,kBAA/Q5B,gBAA+Q,GAAA,SAAA,GAAA,KAAA,GAAA,GAAA,CAAA,GAAA,CAAhOuB,SAAgO,CAAA,SAAA,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