langchain 1.5.16 → 1.5.18
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 +16 -0
- package/dist/agents/ReactAgent.cjs +1 -0
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +1 -0
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/middleware/hitl.cjs +197 -11
- package/dist/agents/middleware/hitl.cjs.map +1 -1
- package/dist/agents/middleware/hitl.d.cts +139 -25
- package/dist/agents/middleware/hitl.d.cts.map +1 -1
- package/dist/agents/middleware/hitl.d.ts +167 -53
- package/dist/agents/middleware/hitl.d.ts.map +1 -1
- package/dist/agents/middleware/hitl.js +210 -25
- package/dist/agents/middleware/hitl.js.map +1 -1
- package/dist/agents/middleware/index.cjs +1 -0
- package/dist/agents/middleware/index.d.cts +2 -2
- package/dist/agents/middleware/index.d.ts +2 -2
- package/dist/agents/middleware/index.js +2 -2
- package/dist/agents/tests/utils.cjs.map +1 -1
- package/dist/agents/tests/utils.d.cts +1 -1
- package/dist/agents/tests/utils.d.ts +1 -1
- package/dist/agents/tests/utils.js.map +1 -1
- package/dist/agents/types.d.cts +6 -0
- package/dist/agents/types.d.cts.map +1 -1
- package/dist/agents/types.d.ts +6 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/browser.cjs +2 -0
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +3 -2
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/package.json +6 -6
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AgentBuiltInState, Runtime } from "../runtime.cjs";
|
|
2
2
|
import { AgentMiddleware, ToolCallRequest } from "./types.cjs";
|
|
3
|
+
import { Interrupt } from "../types.cjs";
|
|
3
4
|
import { ToolCall } from "@langchain/core/messages";
|
|
4
5
|
import { InferInteropZodInput } from "@langchain/core/utils/types";
|
|
5
6
|
import { z } from "zod/v3";
|
|
7
|
+
import { z as z$1 } from "zod/v4";
|
|
6
8
|
//#region src/agents/middleware/hitl.d.ts
|
|
7
9
|
declare const WhenFunctionSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCallRequest<AgentBuiltInState, unknown>, z.ZodTypeDef, ToolCallRequest<AgentBuiltInState, unknown>>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodPromise<z.ZodBoolean>]>>;
|
|
8
10
|
/**
|
|
@@ -13,7 +15,12 @@ declare const WhenFunctionSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCallRe
|
|
|
13
15
|
*
|
|
14
16
|
* The request is constructed with `tool` set to `undefined` and `runtime` set to
|
|
15
17
|
* the node-level {@link Runtime}, so it reflects the batch (`afterModel`) context
|
|
16
|
-
* rather than a per-call tool execution.
|
|
18
|
+
* rather than a per-call tool execution. In `"per_call"` mode the predicate runs
|
|
19
|
+
* in `wrapToolCall` and receives the real request, with `tool` set.
|
|
20
|
+
*
|
|
21
|
+
* In both modes the predicate runs again when the run resumes, so it must return
|
|
22
|
+
* the same answer for the same call. If it returns `false` on resume, the
|
|
23
|
+
* reviewer's answer is skipped and the tool runs, even if they rejected it.
|
|
17
24
|
*
|
|
18
25
|
* @param request - The tool call request being evaluated
|
|
19
26
|
* @returns `true` to interrupt for the tool call, `false` to auto-approve it.
|
|
@@ -48,13 +55,13 @@ declare const DescriptionFunctionSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<Too
|
|
|
48
55
|
* ```
|
|
49
56
|
*/
|
|
50
57
|
export type DescriptionFactory = z.infer<typeof DescriptionFunctionSchema>;
|
|
51
|
-
declare const DecisionType: z.ZodEnum<["approve", "edit", "reject"]>;
|
|
58
|
+
declare const DecisionType: z.ZodEnum<["approve", "edit", "reject", "respond"]>;
|
|
52
59
|
type DecisionType = z.infer<typeof DecisionType>;
|
|
53
60
|
declare const InterruptOnConfigSchema: z.ZodObject<{
|
|
54
61
|
/**
|
|
55
62
|
* The decisions that are allowed for this action.
|
|
56
63
|
*/
|
|
57
|
-
allowedDecisions: z.ZodArray<z.ZodEnum<["approve", "edit", "reject"]>, "many">;
|
|
64
|
+
allowedDecisions: z.ZodArray<z.ZodEnum<["approve", "edit", "reject", "respond"]>, "many">;
|
|
58
65
|
/**
|
|
59
66
|
* The description attached to the request for human input.
|
|
60
67
|
* Can be either:
|
|
@@ -101,6 +108,9 @@ declare const InterruptOnConfigSchema: z.ZodObject<{
|
|
|
101
108
|
description: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCall<string, Record<string, any>>, z.ZodTypeDef, ToolCall<string, Record<string, any>>>, z.ZodType<AgentBuiltInState, z.ZodTypeDef, AgentBuiltInState>, z.ZodType<Runtime<unknown>, z.ZodTypeDef, Runtime<unknown>>], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>]>>;
|
|
102
109
|
/**
|
|
103
110
|
* JSON schema for the arguments associated with the action, if edits are allowed.
|
|
111
|
+
*
|
|
112
|
+
* Not used in `"per_call"` mode: an edit's `args` are checked against the tool's
|
|
113
|
+
* own schema there.
|
|
104
114
|
*/
|
|
105
115
|
argsSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
106
116
|
/**
|
|
@@ -110,7 +120,9 @@ declare const InterruptOnConfigSchema: z.ZodObject<{
|
|
|
110
120
|
* `false` to auto-approve the tool call.
|
|
111
121
|
*
|
|
112
122
|
* The request is constructed with `tool` set to `undefined` and `runtime` set
|
|
113
|
-
* to the node-level {@link Runtime}, so `request.tool` is not available.
|
|
123
|
+
* to the node-level {@link Runtime}, so `request.tool` is not available. In
|
|
124
|
+
* `"per_call"` mode the predicate runs in `wrapToolCall` and receives the real
|
|
125
|
+
* request, with `tool` set.
|
|
114
126
|
*
|
|
115
127
|
* @example
|
|
116
128
|
* ```typescript
|
|
@@ -126,12 +138,12 @@ declare const InterruptOnConfigSchema: z.ZodObject<{
|
|
|
126
138
|
*/
|
|
127
139
|
when: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCallRequest<AgentBuiltInState, unknown>, z.ZodTypeDef, ToolCallRequest<AgentBuiltInState, unknown>>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodPromise<z.ZodBoolean>]>>>;
|
|
128
140
|
}, "strip", z.ZodTypeAny, {
|
|
129
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
141
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
130
142
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
131
143
|
argsSchema?: Record<string, any> | undefined;
|
|
132
144
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
133
145
|
}, {
|
|
134
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
146
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
135
147
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
136
148
|
argsSchema?: Record<string, any> | undefined;
|
|
137
149
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
@@ -241,10 +253,20 @@ export interface RejectDecision {
|
|
|
241
253
|
*/
|
|
242
254
|
message?: string;
|
|
243
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Response when a human answers on behalf of the tool.
|
|
258
|
+
*/
|
|
259
|
+
export interface RespondDecision {
|
|
260
|
+
type: "respond";
|
|
261
|
+
/**
|
|
262
|
+
* The message sent to the model as the tool result.
|
|
263
|
+
*/
|
|
264
|
+
message: string;
|
|
265
|
+
}
|
|
244
266
|
/**
|
|
245
267
|
* Union of all possible decision types.
|
|
246
268
|
*/
|
|
247
|
-
export type Decision = ApproveDecision | EditDecision | RejectDecision;
|
|
269
|
+
export type Decision = ApproveDecision | EditDecision | RejectDecision | RespondDecision;
|
|
248
270
|
/**
|
|
249
271
|
* Response payload for a HITLRequest.
|
|
250
272
|
*/
|
|
@@ -254,12 +276,58 @@ export interface HITLResponse {
|
|
|
254
276
|
*/
|
|
255
277
|
decisions: Decision[];
|
|
256
278
|
}
|
|
279
|
+
declare const ToolApprovalRequestSchema: z$1.ZodObject<{
|
|
280
|
+
type: z$1.ZodLiteral<"tool_approval">;
|
|
281
|
+
tool_call_id: z$1.ZodString;
|
|
282
|
+
name: z$1.ZodString;
|
|
283
|
+
args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
|
|
284
|
+
description: z$1.ZodString;
|
|
285
|
+
}, z$1.core.$strip>;
|
|
286
|
+
/**
|
|
287
|
+
* Interrupt value raised once per gated tool call in `"per_call"` mode. Keys are
|
|
288
|
+
* snake_case, as in Python.
|
|
289
|
+
*/
|
|
290
|
+
export type ToolApprovalRequest = z$1.infer<typeof ToolApprovalRequestSchema>;
|
|
291
|
+
/**
|
|
292
|
+
* The answers a reviewer can give to a `"per_call"` approval of tool `name`, by type.
|
|
293
|
+
*
|
|
294
|
+
* The edit can't switch tools: its `name` is pinned.
|
|
295
|
+
*/
|
|
296
|
+
declare const toolApprovalDecisions: (name: string, tool?: ToolCallRequest["tool"]) => {
|
|
297
|
+
approve: z$1.ZodObject<{
|
|
298
|
+
type: z$1.ZodLiteral<"approve">;
|
|
299
|
+
}, z$1.core.$strip>;
|
|
300
|
+
edit: z$1.ZodObject<{
|
|
301
|
+
type: z$1.ZodLiteral<"edit">;
|
|
302
|
+
edited_action: z$1.ZodObject<{
|
|
303
|
+
name: z$1.ZodLiteral<string>;
|
|
304
|
+
args: z$1.ZodType<Record<string, unknown>, unknown, z$1.core.$ZodTypeInternals<Record<string, unknown>, unknown>>;
|
|
305
|
+
}, z$1.core.$strip>;
|
|
306
|
+
}, z$1.core.$strip>;
|
|
307
|
+
reject: z$1.ZodObject<{
|
|
308
|
+
type: z$1.ZodLiteral<"reject">;
|
|
309
|
+
message: z$1.ZodOptional<z$1.ZodString>;
|
|
310
|
+
}, z$1.core.$strip>;
|
|
311
|
+
respond: z$1.ZodObject<{
|
|
312
|
+
type: z$1.ZodLiteral<"respond">;
|
|
313
|
+
message: z$1.ZodString;
|
|
314
|
+
}, z$1.core.$strip>;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* A reviewer's answer to a `"per_call"` tool approval.
|
|
318
|
+
*/
|
|
319
|
+
export type ToolApprovalDecision = z$1.infer<ReturnType<typeof toolApprovalDecisions>[DecisionType]>;
|
|
320
|
+
/**
|
|
321
|
+
* Whether an interrupt is a `"per_call"` tool approval, e.g.
|
|
322
|
+
* `result.__interrupt__?.filter(isToolApprovalInterrupt)`.
|
|
323
|
+
*/
|
|
324
|
+
export declare function isToolApprovalInterrupt(interrupt: Interrupt | undefined): interrupt is Interrupt<ToolApprovalRequest>;
|
|
257
325
|
declare const contextSchema: z.ZodObject<{
|
|
258
326
|
/**
|
|
259
327
|
* Mapping of tool name to allowed reviewer responses.
|
|
260
328
|
* If a tool doesn't have an entry, it's auto-approved by default.
|
|
261
329
|
*
|
|
262
|
-
* - `true` -> pause for approval and allow approve/edit/reject
|
|
330
|
+
* - `true` -> pause for approval and allow every decision (approve/edit/reject/respond)
|
|
263
331
|
* - `false` -> auto-approve (no human review)
|
|
264
332
|
* - `InterruptOnConfig` -> explicitly specify which decisions are allowed for this tool
|
|
265
333
|
*/
|
|
@@ -267,7 +335,7 @@ declare const contextSchema: z.ZodObject<{
|
|
|
267
335
|
/**
|
|
268
336
|
* The decisions that are allowed for this action.
|
|
269
337
|
*/
|
|
270
|
-
allowedDecisions: z.ZodArray<z.ZodEnum<["approve", "edit", "reject"]>, "many">;
|
|
338
|
+
allowedDecisions: z.ZodArray<z.ZodEnum<["approve", "edit", "reject", "respond"]>, "many">;
|
|
271
339
|
/**
|
|
272
340
|
* The description attached to the request for human input.
|
|
273
341
|
* Can be either:
|
|
@@ -314,6 +382,9 @@ declare const contextSchema: z.ZodObject<{
|
|
|
314
382
|
description: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCall<string, Record<string, any>>, z.ZodTypeDef, ToolCall<string, Record<string, any>>>, z.ZodType<AgentBuiltInState, z.ZodTypeDef, AgentBuiltInState>, z.ZodType<Runtime<unknown>, z.ZodTypeDef, Runtime<unknown>>], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>]>>;
|
|
315
383
|
/**
|
|
316
384
|
* JSON schema for the arguments associated with the action, if edits are allowed.
|
|
385
|
+
*
|
|
386
|
+
* Not used in `"per_call"` mode: an edit's `args` are checked against the tool's
|
|
387
|
+
* own schema there.
|
|
317
388
|
*/
|
|
318
389
|
argsSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
319
390
|
/**
|
|
@@ -323,7 +394,9 @@ declare const contextSchema: z.ZodObject<{
|
|
|
323
394
|
* `false` to auto-approve the tool call.
|
|
324
395
|
*
|
|
325
396
|
* The request is constructed with `tool` set to `undefined` and `runtime` set
|
|
326
|
-
* to the node-level {@link Runtime}, so `request.tool` is not available.
|
|
397
|
+
* to the node-level {@link Runtime}, so `request.tool` is not available. In
|
|
398
|
+
* `"per_call"` mode the predicate runs in `wrapToolCall` and receives the real
|
|
399
|
+
* request, with `tool` set.
|
|
327
400
|
*
|
|
328
401
|
* @example
|
|
329
402
|
* ```typescript
|
|
@@ -339,12 +412,12 @@ declare const contextSchema: z.ZodObject<{
|
|
|
339
412
|
*/
|
|
340
413
|
when: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCallRequest<AgentBuiltInState, unknown>, z.ZodTypeDef, ToolCallRequest<AgentBuiltInState, unknown>>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodPromise<z.ZodBoolean>]>>>;
|
|
341
414
|
}, "strip", z.ZodTypeAny, {
|
|
342
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
415
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
343
416
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
344
417
|
argsSchema?: Record<string, any> | undefined;
|
|
345
418
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
346
419
|
}, {
|
|
347
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
420
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
348
421
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
349
422
|
argsSchema?: Record<string, any> | undefined;
|
|
350
423
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
@@ -360,7 +433,7 @@ declare const contextSchema: z.ZodObject<{
|
|
|
360
433
|
descriptionPrefix: z.ZodDefault<z.ZodString>;
|
|
361
434
|
}, "strip", z.ZodTypeAny, {
|
|
362
435
|
interruptOn?: Record<string, boolean | {
|
|
363
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
436
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
364
437
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
365
438
|
argsSchema?: Record<string, any> | undefined;
|
|
366
439
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
@@ -368,14 +441,49 @@ declare const contextSchema: z.ZodObject<{
|
|
|
368
441
|
descriptionPrefix: string;
|
|
369
442
|
}, {
|
|
370
443
|
interruptOn?: Record<string, boolean | {
|
|
371
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
444
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
372
445
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
373
446
|
argsSchema?: Record<string, any> | undefined;
|
|
374
447
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
375
448
|
}> | undefined;
|
|
376
449
|
descriptionPrefix?: string | undefined;
|
|
377
450
|
}>;
|
|
378
|
-
export type HumanInTheLoopMiddlewareConfig = InferInteropZodInput<typeof contextSchema
|
|
451
|
+
export type HumanInTheLoopMiddlewareConfig = InferInteropZodInput<typeof contextSchema> & {
|
|
452
|
+
/**
|
|
453
|
+
* How the middleware pauses for review. Set at construction only.
|
|
454
|
+
*
|
|
455
|
+
* - `"batched"` (default): one interrupt per model turn for all gated tool calls.
|
|
456
|
+
* - `"per_call"`: one {@link ToolApprovalRequest} interrupt per gated call, with a
|
|
457
|
+
* typed `responseSchema`, answered with a single decision keyed by interrupt ID.
|
|
458
|
+
*
|
|
459
|
+
* In `"per_call"` mode, LangGraph checks each answer before saving it:
|
|
460
|
+
*
|
|
461
|
+
* - An edit can't switch tools, and its args must match the tool's argument
|
|
462
|
+
* types. Args the tool doesn't declare are handled as they are when the model
|
|
463
|
+
* sends them. For a tool without a Zod v4 object schema, any object is accepted
|
|
464
|
+
* and the tool checks it when it runs.
|
|
465
|
+
* - An invalid answer throws a `ZodError` and isn't saved, so the same interrupt
|
|
466
|
+
* can be answered again.
|
|
467
|
+
*
|
|
468
|
+
* If one of several answers sent together is invalid, the others' tools may
|
|
469
|
+
* already have run even if they still show as pending, and answering them again
|
|
470
|
+
* would run them twice. Check answers against `responseSchema` before sending them
|
|
471
|
+
* together, or send one at a time.
|
|
472
|
+
*
|
|
473
|
+
* The review happens as the tool call starts, inside the tool-call middleware
|
|
474
|
+
* chain. List this middleware before tool retry or error-handling middleware so it
|
|
475
|
+
* wraps them. On resume, each paused tool call runs the middleware listed before
|
|
476
|
+
* this one again up to the pause, so that middleware must not have side effects
|
|
477
|
+
* before calling `handler`. The tool itself runs only after the answer.
|
|
478
|
+
*/
|
|
479
|
+
interruptMode?: "batched" | "per_call";
|
|
480
|
+
/**
|
|
481
|
+
* `"per_call"` mode only: text prepended to the result of a tool call a reviewer
|
|
482
|
+
* edited, so the model knows the call it made isn't the one that ran. Pass `null`
|
|
483
|
+
* to add nothing.
|
|
484
|
+
*/
|
|
485
|
+
editNotice?: string | null;
|
|
486
|
+
};
|
|
379
487
|
/**
|
|
380
488
|
* Creates a Human-in-the-Loop (HITL) middleware for tool approval and oversight.
|
|
381
489
|
*
|
|
@@ -578,8 +686,9 @@ export type HumanInTheLoopMiddlewareConfig = InferInteropZodInput<typeof context
|
|
|
578
686
|
* @remarks
|
|
579
687
|
* - Tool calls are processed in the order they appear in the AI message
|
|
580
688
|
* - Auto-approved tools execute immediately without interruption
|
|
581
|
-
* -
|
|
582
|
-
*
|
|
689
|
+
* - In the default `"batched"` mode, multiple tools requiring approval are bundled into a
|
|
690
|
+
* single interrupt request, raised in the `afterModel` phase before any tool runs. In
|
|
691
|
+
* `"per_call"` mode, each gated call raises its own interrupt from `wrapToolCall`
|
|
583
692
|
* - Requires a checkpointer to maintain state across interruptions
|
|
584
693
|
*
|
|
585
694
|
* @see {@link createAgent} for agent creation
|
|
@@ -591,7 +700,7 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
591
700
|
* Mapping of tool name to allowed reviewer responses.
|
|
592
701
|
* If a tool doesn't have an entry, it's auto-approved by default.
|
|
593
702
|
*
|
|
594
|
-
* - `true` -> pause for approval and allow approve/edit/reject
|
|
703
|
+
* - `true` -> pause for approval and allow every decision (approve/edit/reject/respond)
|
|
595
704
|
* - `false` -> auto-approve (no human review)
|
|
596
705
|
* - `InterruptOnConfig` -> explicitly specify which decisions are allowed for this tool
|
|
597
706
|
*/
|
|
@@ -599,7 +708,7 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
599
708
|
/**
|
|
600
709
|
* The decisions that are allowed for this action.
|
|
601
710
|
*/
|
|
602
|
-
allowedDecisions: z.ZodArray<z.ZodEnum<["approve", "edit", "reject"]>, "many">;
|
|
711
|
+
allowedDecisions: z.ZodArray<z.ZodEnum<["approve", "edit", "reject", "respond"]>, "many">;
|
|
603
712
|
/**
|
|
604
713
|
* The description attached to the request for human input.
|
|
605
714
|
* Can be either:
|
|
@@ -646,6 +755,9 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
646
755
|
description: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCall<string, Record<string, any>>, z.ZodTypeDef, ToolCall<string, Record<string, any>>>, z.ZodType<AgentBuiltInState, z.ZodTypeDef, AgentBuiltInState>, z.ZodType<Runtime<unknown>, z.ZodTypeDef, Runtime<unknown>>], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>]>>;
|
|
647
756
|
/**
|
|
648
757
|
* JSON schema for the arguments associated with the action, if edits are allowed.
|
|
758
|
+
*
|
|
759
|
+
* Not used in `"per_call"` mode: an edit's `args` are checked against the tool's
|
|
760
|
+
* own schema there.
|
|
649
761
|
*/
|
|
650
762
|
argsSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
651
763
|
/**
|
|
@@ -655,7 +767,9 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
655
767
|
* `false` to auto-approve the tool call.
|
|
656
768
|
*
|
|
657
769
|
* The request is constructed with `tool` set to `undefined` and `runtime` set
|
|
658
|
-
* to the node-level {@link Runtime}, so `request.tool` is not available.
|
|
770
|
+
* to the node-level {@link Runtime}, so `request.tool` is not available. In
|
|
771
|
+
* `"per_call"` mode the predicate runs in `wrapToolCall` and receives the real
|
|
772
|
+
* request, with `tool` set.
|
|
659
773
|
*
|
|
660
774
|
* @example
|
|
661
775
|
* ```typescript
|
|
@@ -671,12 +785,12 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
671
785
|
*/
|
|
672
786
|
when: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodType<ToolCallRequest<AgentBuiltInState, unknown>, z.ZodTypeDef, ToolCallRequest<AgentBuiltInState, unknown>>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodPromise<z.ZodBoolean>]>>>;
|
|
673
787
|
}, "strip", z.ZodTypeAny, {
|
|
674
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
788
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
675
789
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
676
790
|
argsSchema?: Record<string, any> | undefined;
|
|
677
791
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
678
792
|
}, {
|
|
679
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
793
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
680
794
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
681
795
|
argsSchema?: Record<string, any> | undefined;
|
|
682
796
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
@@ -692,7 +806,7 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
692
806
|
descriptionPrefix: z.ZodDefault<z.ZodString>;
|
|
693
807
|
}, "strip", z.ZodTypeAny, {
|
|
694
808
|
interruptOn?: Record<string, boolean | {
|
|
695
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
809
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
696
810
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
697
811
|
argsSchema?: Record<string, any> | undefined;
|
|
698
812
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
@@ -700,7 +814,7 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
700
814
|
descriptionPrefix: string;
|
|
701
815
|
}, {
|
|
702
816
|
interruptOn?: Record<string, boolean | {
|
|
703
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
817
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
704
818
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
705
819
|
argsSchema?: Record<string, any> | undefined;
|
|
706
820
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
@@ -708,7 +822,7 @@ export declare function humanInTheLoopMiddleware(options: NonNullable<HumanInThe
|
|
|
708
822
|
descriptionPrefix?: string | undefined;
|
|
709
823
|
}>, {
|
|
710
824
|
interruptOn?: Record<string, boolean | {
|
|
711
|
-
allowedDecisions: ("approve" | "edit" | "reject")[];
|
|
825
|
+
allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
|
|
712
826
|
description?: string | ((args_0: ToolCall<string, Record<string, any>>, args_1: AgentBuiltInState, args_2: Runtime<unknown>, ...args: unknown[]) => string | Promise<string>) | undefined;
|
|
713
827
|
argsSchema?: Record<string, any> | undefined;
|
|
714
828
|
when?: ((args_0: ToolCallRequest<AgentBuiltInState, unknown>, ...args: unknown[]) => boolean | Promise<boolean>) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hitl.d.cts","names":["_$__types_js0.AgentMiddleware"],"sources":["../../../src/agents/middleware/hitl.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"hitl.d.cts","names":["z4","_$__types_js0.AgentMiddleware"],"sources":["../../../src/agents/middleware/hitl.ts"],"mappings":";;;;;;;;cAkBM,oBAAkB,EAAA,YAAA,EAAA,UAAA,EAAA,QAAA,gBAAA,6BAAA,EAAA,YAAA,gBAAA,+BAAA,EAAA,aAAA,EAAA,UAAA,EAAA,YAAA,EAAA,WAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCZ,gBAAgB,EAAE,aAAa;cAErC,2BAAyB,EAAA,YAAA,EAAA,UAAA,EAAA,QAAA,iBAAA,sBAAA,EAAA,YAAA,iBAAA,uBAAA,EAAA,QAAA,mBAAA,EAAA,YAAA,oBAAA,EAAA,QAAA,kBAAA,EAAA,YAAA,oBAAA,EAAA,aAAA,EAAA,UAAA,EAAA,WAAA,EAAA,WAAA,EAAA;;;;;;;;;;;;;;;;;;YA0BnB,qBAAqB,EAAE,aAAa;cAM1C,cAAY,EAAA;KACN,eAAe,EAAE,aAAa;cAEpC,yBAAuB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiFjB,oBAAoB,EAAE,aAAa;;;;iBAK9B;;;;EAIf;;;;EAIA,MAAM;;;;;iBAMS;;;;EAIf;;;;EAIA,MAAM;;;;EAIN;;;;;iBAMe;;;;EAIf;;;;EAIA,kBAAkB;;;;EAIlB,aAAa;;;;;;;;;;;;;;;;;;;;;;iBAuBE;;;;EAIf,gBAAgB;;;;EAIhB,eAAe;;;;;iBAMA;EACf;;;;;iBAMe;EACf;;;;;EAKA,cAAc;;;;;iBAMC;EACf;;;;EAIA;;;;;iBAMe;EACf;;;;EAIA;;;;;YAMU,WACR,kBACA,eACA,iBACA;;;;iBAKa;;;;EAIf,WAAW;;cAGP,2BAAyBA,IAAA;;;;;;GAW7BA,IAAA,KAAA;;;;;YAMU,sBAAsBA,IAAG,aAAa;;;;;;cAyB5C,wBAAqB,cACb,OACL;EAEP,SAAOA,IAAA;;;EACP,MAAIA,IAAA;;;;;;;EAOJ,QAAMA,IAAA;;;;EAIN,SAAOA,IAAA;;;;;;;;YASG,uBAAuBA,IAAG,MACpC,kBAAkB,uBAAuB;;;;;wBAO3B,wBACd,WAAW,wBACV,aAAa,UAAU;cAwBpB,eAAa,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAsBP,iCAAiC,4BACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BP;;;;;;EAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkTc,yBACd,SAAS,YAAY,6DAA+B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAkdrD,6CAAA"}
|