@langgraph-js/sdk 3.8.2 → 3.8.4

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/dist/History.d.ts CHANGED
@@ -111,5 +111,7 @@ export declare class History {
111
111
  * @zh 初始化 History(必须先调用)
112
112
  * @en Initializes History (must be called first)
113
113
  */
114
- init(agentName?: string): Promise<import("@langchain/langgraph-sdk").Assistant | undefined>;
114
+ init(agentName?: string, config?: {
115
+ fallbackToAvailableAssistants?: boolean;
116
+ }): Promise<import("@langchain/langgraph-sdk").Assistant | undefined>;
115
117
  }
package/dist/History.js CHANGED
@@ -220,7 +220,7 @@ export class History {
220
220
  * @zh 初始化 History(必须先调用)
221
221
  * @en Initializes History (must be called first)
222
222
  */
223
- async init(agentName) {
224
- return this.virtualClient.initAssistant(agentName);
223
+ async init(agentName, config) {
224
+ return this.virtualClient.initAssistant(agentName, config);
225
225
  }
226
226
  }
@@ -54,7 +54,7 @@ export type InterruptData = {
54
54
  }[];
55
55
  reviewConfigs: {
56
56
  actionName: string;
57
- allowedDecisions: ("approve" | "edit" | "reject")[];
57
+ allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
58
58
  }[];
59
59
  };
60
60
  }[];
@@ -145,10 +145,7 @@ export declare class LangGraphClient<TStateType = unknown> extends EventEmitter<
145
145
  /** 代理 assistants 属性到内部 client */
146
146
  get assistants(): {
147
147
  search(query?: {
148
- graphId? /**
149
- * The maximum number of concurrent calls that can be made.
150
- * Defaults to `Infinity`, which means no limit.
151
- */: string;
148
+ graphId?: string;
152
149
  metadata?: import("@langchain/langgraph-sdk").Metadata;
153
150
  limit?: number;
154
151
  offset?: number;
@@ -332,13 +332,13 @@ export class LangGraphClient extends EventEmitter {
332
332
  }
333
333
  else if (chunk.event === "values") {
334
334
  const data = chunk.data;
335
- if (data.__interrupt__) {
335
+ if (data?.__interrupt__) {
336
336
  this._status = "interrupted";
337
337
  this.humanInTheLoop = camelcaseKeys(data.__interrupt__, {
338
338
  deep: true,
339
339
  });
340
340
  }
341
- else if (data.messages) {
341
+ else if (data?.messages) {
342
342
  const isResume = !!command?.resume;
343
343
  const isLongerThanLocal = data.messages.length >= this.messageProcessor.getGraphMessages().length;
344
344
  // resume 情况下,长度低于前端 message 的统统不接受
@@ -24,13 +24,13 @@ export declare class ToolRenderData<I, D> {
24
24
  }[];
25
25
  reviewConfigs: {
26
26
  actionName: string;
27
- allowedDecisions: ("approve" | "edit" | "reject")[];
27
+ allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
28
28
  }[];
29
29
  };
30
30
  };
31
31
  reviewConfig: {
32
32
  actionName: string;
33
- allowedDecisions: ("approve" | "edit" | "reject")[];
33
+ allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
34
34
  };
35
35
  actionRequest: {
36
36
  name: string;
@@ -93,7 +93,7 @@ export const createChatStore = (initClientName, config, context = {}) => {
93
93
  ...config,
94
94
  client: config.client ?? (await createLangGraphServerClient(config)),
95
95
  });
96
- await historyManager.init(currentAgent.get());
96
+ await historyManager.init(currentAgent.get(), { fallbackToAvailableAssistants: context.fallbackToAvailableAssistants });
97
97
  history.set(historyManager);
98
98
  // 同步远程会话列表
99
99
  await refreshSessionList();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langgraph-js/sdk",
3
- "version": "3.8.2",
3
+ "version": "3.8.4",
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",
package/src/History.ts CHANGED
@@ -288,7 +288,7 @@ export class History {
288
288
  * @zh 初始化 History(必须先调用)
289
289
  * @en Initializes History (must be called first)
290
290
  */
291
- async init(agentName?: string) {
292
- return this.virtualClient.initAssistant(agentName);
291
+ async init(agentName?: string, config?: { fallbackToAvailableAssistants?: boolean }) {
292
+ return this.virtualClient.initAssistant(agentName, config);
293
293
  }
294
294
  }
@@ -55,7 +55,7 @@ export type InterruptData = {
55
55
  }[];
56
56
  reviewConfigs: {
57
57
  actionName: string;
58
- allowedDecisions: ("approve" | "edit" | "reject")[];
58
+ allowedDecisions: ("approve" | "edit" | "reject" | "respond")[];
59
59
  }[];
60
60
  };
61
61
  }[];
@@ -457,17 +457,19 @@ export class LangGraphClient<TStateType = unknown> extends EventEmitter<LangGrap
457
457
  this.emit("message", chunk);
458
458
  return true;
459
459
  } else if (chunk.event === "values") {
460
- const data = chunk.data as {
461
- __interrupt__?: InterruptData;
462
- messages: Message[];
463
- };
460
+ const data = chunk.data as
461
+ | {
462
+ __interrupt__?: InterruptData;
463
+ messages: Message[];
464
+ }
465
+ | undefined;
464
466
 
465
- if (data.__interrupt__) {
467
+ if (data?.__interrupt__) {
466
468
  this._status = "interrupted";
467
469
  this.humanInTheLoop = camelcaseKeys(data.__interrupt__, {
468
470
  deep: true,
469
471
  });
470
- } else if (data.messages) {
472
+ } else if (data?.messages) {
471
473
  const isResume = !!command?.resume;
472
474
  const isLongerThanLocal = data.messages.length >= this.messageProcessor.getGraphMessages().length;
473
475
  // resume 情况下,长度低于前端 message 的统统不接受
@@ -124,7 +124,7 @@ export const createChatStore = (initClientName: string, config: Partial<LangGrap
124
124
  ...config,
125
125
  client: config.client ?? (await createLangGraphServerClient(config as LangGraphClientConfig)),
126
126
  });
127
- await historyManager.init(currentAgent.get());
127
+ await historyManager.init(currentAgent.get(), { fallbackToAvailableAssistants: context.fallbackToAvailableAssistants });
128
128
  history.set(historyManager);
129
129
 
130
130
  // 同步远程会话列表