@langgraph-js/sdk 3.5.0 → 3.5.2

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.
@@ -266,7 +266,7 @@ export class LangGraphClient extends EventEmitter {
266
266
  Object.assign(this.messagesMetadata, chunk.data);
267
267
  continue;
268
268
  }
269
- else if (chunk.event === "messages/partial") {
269
+ else if (chunk.event === "messages/partial" || chunk.event === "messages/complete") {
270
270
  for (const message of chunk.data) {
271
271
  this.messageProcessor.updateStreamingMessage(message);
272
272
  }
@@ -297,6 +297,7 @@ export class LangGraphClient extends EventEmitter {
297
297
  const data = await this.runFETool();
298
298
  if (data)
299
299
  streamRecord.push(...data);
300
+ this.humanInTheLoop = null;
300
301
  this.emit("done", {
301
302
  event: "done",
302
303
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ const t = {
2
+ type: "tool",
3
+ tool_call_id: "123"
4
+ };
5
+ export {};
@@ -22,10 +22,24 @@ export interface UnionTool<Args extends ZodRawShape, Child extends Object = Obje
22
22
  isPureParams?: boolean;
23
23
  }
24
24
  export type ToolCallback<Args extends ZodRawShape> = (args: z.infer<z.ZodObject<Args>>, context?: any) => CallToolResult | Promise<CallToolResult>;
25
+ export type InterruptResponse = {
26
+ decisions: ({
27
+ type: "approve";
28
+ } | {
29
+ type: "edit";
30
+ edited_action: {
31
+ name: string;
32
+ args: Record<string, any>;
33
+ };
34
+ } | {
35
+ type: "reject";
36
+ message: string;
37
+ })[];
38
+ };
25
39
  export type CallToolResult = string | {
26
40
  type: "text";
27
41
  text: string;
28
- }[];
42
+ }[] | InterruptResponse;
29
43
  /** 用于格式校验 */
30
44
  export declare const createTool: <Args extends ZodRawShape>(tool: UnionTool<Args>) => UnionTool<Args, Object, any>;
31
45
  /**
@@ -159,7 +173,7 @@ export declare const createMCPTool: <Args extends ZodRawShape>(tool: UnionTool<A
159
173
  content: {
160
174
  type: "text";
161
175
  text: string;
162
- }[] | undefined;
176
+ }[] | InterruptResponse | undefined;
163
177
  isError?: undefined;
164
178
  } | {
165
179
  content: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langgraph-js/sdk",
3
- "version": "3.5.0",
3
+ "version": "3.5.2",
4
4
  "description": "The UI SDK for LangGraph - seamlessly integrate your AI agents with frontend interfaces",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -382,7 +382,7 @@ export class LangGraphClient<TStateType = unknown> extends EventEmitter<LangGrap
382
382
  } else if (chunk.event === "messages/metadata") {
383
383
  Object.assign(this.messagesMetadata, chunk.data);
384
384
  continue;
385
- } else if (chunk.event === "messages/partial") {
385
+ } else if (chunk.event === "messages/partial" || chunk.event === "messages/complete") {
386
386
  for (const message of chunk.data) {
387
387
  this.messageProcessor.updateStreamingMessage(message);
388
388
  }
@@ -413,6 +413,7 @@ export class LangGraphClient<TStateType = unknown> extends EventEmitter<LangGrap
413
413
  }
414
414
  const data = await this.runFETool();
415
415
  if (data) streamRecord.push(...data);
416
+ this.humanInTheLoop = null;
416
417
  this.emit("done", {
417
418
  event: "done",
418
419
  });
@@ -25,8 +25,20 @@ export interface UnionTool<Args extends ZodRawShape, Child extends Object = Obje
25
25
  isPureParams?: boolean;
26
26
  }
27
27
  export type ToolCallback<Args extends ZodRawShape> = (args: z.infer<z.ZodObject<Args>>, context?: any) => CallToolResult | Promise<CallToolResult>;
28
-
29
- export type CallToolResult = string | { type: "text"; text: string }[];
28
+ export type InterruptResponse = {
29
+ decisions: (
30
+ | { type: "approve" }
31
+ | {
32
+ type: "edit";
33
+ edited_action: {
34
+ name: string;
35
+ args: Record<string, any>;
36
+ };
37
+ }
38
+ | { type: "reject"; message: string }
39
+ )[];
40
+ };
41
+ export type CallToolResult = string | { type: "text"; text: string }[] | InterruptResponse;
30
42
 
31
43
  /** 用于格式校验 */
32
44
  export const createTool = <Args extends ZodRawShape>(tool: UnionTool<Args>) => {