@langchain/langgraph 0.2.39 → 0.2.40

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.
@@ -3,3 +3,4 @@ export { type FunctionCallingExecutorState, createFunctionCallingExecutor, } fro
3
3
  export { type AgentState, type CreateReactAgentParams, createReactAgent, } from "./react_agent_executor.js";
4
4
  export { type ToolExecutorArgs, type ToolInvocationInterface, ToolExecutor, } from "./tool_executor.js";
5
5
  export { ToolNode, toolsCondition, type ToolNodeOptions } from "./tool_node.js";
6
+ export type { HumanInterruptConfig, ActionRequest, HumanInterrupt, HumanResponse, } from "./interrupt.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Configuration interface that defines what actions are allowed for a human interrupt.
3
+ * This controls the available interaction options when the graph is paused for human input.
4
+ *
5
+ * @property {boolean} allow_ignore - Whether the human can choose to ignore/skip the current step
6
+ * @property {boolean} allow_respond - Whether the human can provide a text response/feedback
7
+ * @property {boolean} allow_edit - Whether the human can edit the provided content/state
8
+ * @property {boolean} allow_accept - Whether the human can accept/approve the current state
9
+ */
10
+ export interface HumanInterruptConfig {
11
+ allow_ignore: boolean;
12
+ allow_respond: boolean;
13
+ allow_edit: boolean;
14
+ allow_accept: boolean;
15
+ }
16
+ /**
17
+ * Represents a request for human action within the graph execution.
18
+ * Contains the action type and any associated arguments needed for the action.
19
+ *
20
+ * @property {string} action - The type or name of action being requested (e.g., "Approve XYZ action")
21
+ * @property {Record<string, any>} args - Key-value pairs of arguments needed for the action
22
+ */
23
+ export interface ActionRequest {
24
+ action: string;
25
+ args: Record<string, any>;
26
+ }
27
+ /**
28
+ * Represents an interrupt triggered by the graph that requires human intervention.
29
+ * This is passed to the `interrupt` function when execution is paused for human input.
30
+ *
31
+ * @property {ActionRequest} action_request - The specific action being requested from the human
32
+ * @property {HumanInterruptConfig} config - Configuration defining what actions are allowed
33
+ * @property {string} [description] - Optional detailed description of what input is needed
34
+ */
35
+ export interface HumanInterrupt {
36
+ action_request: ActionRequest;
37
+ config: HumanInterruptConfig;
38
+ description?: string;
39
+ }
40
+ /**
41
+ * The response provided by a human to an interrupt, which is returned when graph execution resumes.
42
+ *
43
+ * @property {("accept"|"ignore"|"response"|"edit")} type - The type of response:
44
+ * - "accept": Approves the current state without changes
45
+ * - "ignore": Skips/ignores the current step
46
+ * - "response": Provides text feedback or instructions
47
+ * - "edit": Modifies the current state/content
48
+ * @property {null|string|ActionRequest} args - The response payload:
49
+ * - null: For ignore/accept actions
50
+ * - string: For text responses
51
+ * - ActionRequest: For edit actions with updated content
52
+ */
53
+ export type HumanResponse = {
54
+ type: "accept" | "ignore" | "response" | "edit";
55
+ args: null | string | ActionRequest;
56
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -94,8 +94,15 @@ function* mapCommand(cmd, pendingWrites) {
94
94
  if (typeof cmd.update !== "object" || !cmd.update) {
95
95
  throw new Error("Expected cmd.update to be a dict mapping channel names to update values");
96
96
  }
97
- for (const [k, v] of Object.entries(cmd.update)) {
98
- yield [constants_js_1.NULL_TASK_ID, k, v];
97
+ if (Array.isArray(cmd.update)) {
98
+ for (const [k, v] of cmd.update) {
99
+ yield [constants_js_1.NULL_TASK_ID, k, v];
100
+ }
101
+ }
102
+ else {
103
+ for (const [k, v] of Object.entries(cmd.update)) {
104
+ yield [constants_js_1.NULL_TASK_ID, k, v];
105
+ }
99
106
  }
100
107
  }
101
108
  }
package/dist/pregel/io.js CHANGED
@@ -89,8 +89,15 @@ export function* mapCommand(cmd, pendingWrites) {
89
89
  if (typeof cmd.update !== "object" || !cmd.update) {
90
90
  throw new Error("Expected cmd.update to be a dict mapping channel names to update values");
91
91
  }
92
- for (const [k, v] of Object.entries(cmd.update)) {
93
- yield [NULL_TASK_ID, k, v];
92
+ if (Array.isArray(cmd.update)) {
93
+ for (const [k, v] of cmd.update) {
94
+ yield [NULL_TASK_ID, k, v];
95
+ }
96
+ }
97
+ else {
98
+ for (const [k, v] of Object.entries(cmd.update)) {
99
+ yield [NULL_TASK_ID, k, v];
100
+ }
94
101
  }
95
102
  }
96
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "0.2.39",
3
+ "version": "0.2.40",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -72,7 +72,7 @@
72
72
  "pg": "^8.13.0",
73
73
  "prettier": "^2.8.3",
74
74
  "release-it": "^17.6.0",
75
- "rollup": "^4.24.1",
75
+ "rollup": "^4.29.0",
76
76
  "ts-jest": "^29.1.0",
77
77
  "tsx": "^4.7.0",
78
78
  "typescript": "^4.9.5 || ^5.4.5",