@langgraph-js/sdk 1.6.4 → 1.7.1

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.
@@ -152,6 +152,8 @@ export declare class LangGraphClient extends Client {
152
152
  */
153
153
  onStreamingUpdate(callback: StreamingUpdateCallback): () => void;
154
154
  private emitStreamingUpdate;
155
+ /** 前端工具人机交互时,锁住面板 */
156
+ isFELocking(messages: RenderMessage[]): boolean | undefined;
155
157
  graphState: any;
156
158
  currentRun?: {
157
159
  run_id: string;
@@ -332,6 +332,16 @@ export class LangGraphClient extends Client {
332
332
  emitStreamingUpdate(event) {
333
333
  this.streamingCallbacks.forEach((callback) => callback(event));
334
334
  }
335
+ /** 前端工具人机交互时,锁住面板 */
336
+ isFELocking(messages) {
337
+ var _a;
338
+ const lastMessage = messages[messages.length - 1];
339
+ if (!lastMessage) {
340
+ return false;
341
+ }
342
+ const tool = this.tools.getTool(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.name);
343
+ return tool && tool.render && (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === "tool" && !((_a = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.additional_kwargs) === null || _a === void 0 ? void 0 : _a.done);
344
+ }
335
345
  /**
336
346
  * @zh 取消当前的 Run。
337
347
  * @en Cancels the current Run.
@@ -47,6 +47,7 @@ export declare const createChatStore: (initClientName: string, config: LangGraph
47
47
  currentNodeName: import("nanostores").PreinitializedWritableAtom<string> & object;
48
48
  };
49
49
  mutations: {
50
+ isFELocking(): boolean | undefined;
50
51
  initClient: () => Promise<LangGraphClient>;
51
52
  sendMessage: (message?: Message[], extraData?: SendMessageOptions) => Promise<void>;
52
53
  stopGeneration: () => void;
@@ -215,6 +215,10 @@ export const createChatStore = (initClientName, config, context = {}) => {
215
215
  currentNodeName,
216
216
  },
217
217
  mutations: {
218
+ isFELocking() {
219
+ var _a;
220
+ return (_a = client.get()) === null || _a === void 0 ? void 0 : _a.isFELocking(renderMessages.get());
221
+ },
218
222
  initClient,
219
223
  sendMessage,
220
224
  stopGeneration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langgraph-js/sdk",
3
- "version": "1.6.4",
3
+ "version": "1.7.1",
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",
@@ -394,6 +394,7 @@ export class LangGraphClient extends Client {
394
394
  }
395
395
  );
396
396
  }
397
+
397
398
  /**
398
399
  * @zh 注册流式更新的回调函数。
399
400
  * @en Registers a callback function for streaming updates.
@@ -408,6 +409,15 @@ export class LangGraphClient extends Client {
408
409
  private emitStreamingUpdate(event: StreamingUpdateEvent) {
409
410
  this.streamingCallbacks.forEach((callback) => callback(event));
410
411
  }
412
+ /** 前端工具人机交互时,锁住面板 */
413
+ isFELocking(messages: RenderMessage[]) {
414
+ const lastMessage = messages[messages.length - 1];
415
+ if (!lastMessage) {
416
+ return false;
417
+ }
418
+ const tool = this.tools.getTool(lastMessage?.name!);
419
+ return tool && tool.render && lastMessage?.type === "tool" && !lastMessage?.additional_kwargs?.done;
420
+ }
411
421
  graphState: any = {};
412
422
  currentRun?: { run_id: string };
413
423
  /**
@@ -1,4 +1,4 @@
1
- import { atom } from "nanostores";
1
+ import { atom, computed } from "nanostores";
2
2
  import { LangGraphClient, LangGraphClientConfig, RenderMessage, SendMessageOptions } from "../LangGraphClient.js";
3
3
  import { AssistantGraph, Message, Thread } from "@langchain/langgraph-sdk";
4
4
  import { rafDebounce } from "./rafDebounce.js";
@@ -205,6 +205,7 @@ export const createChatStore = (
205
205
  const tool = toolsDefine.find((i) => i.name === tool_name!)?.render;
206
206
  return tool ? (message: RenderMessage) => tool(new ToolRenderData(message, client.get()!)) : null;
207
207
  };
208
+
208
209
  return {
209
210
  data: {
210
211
  client,
@@ -222,6 +223,9 @@ export const createChatStore = (
222
223
  currentNodeName,
223
224
  },
224
225
  mutations: {
226
+ isFELocking() {
227
+ return client.get()?.isFELocking(renderMessages.get());
228
+ },
225
229
  initClient,
226
230
  sendMessage,
227
231
  stopGeneration,