@langgraph-js/sdk 1.1.1 → 1.1.3

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.
@@ -26,6 +26,13 @@ export type RenderMessage = Message & {
26
26
  /** 渲染时的唯一 id,聚合而来*/
27
27
  unique_id?: string;
28
28
  };
29
+ export type SendMessageOptions = {
30
+ extraParams?: Record<string, any>;
31
+ _debug?: {
32
+ streamResponse?: any;
33
+ };
34
+ command?: Command;
35
+ };
29
36
  export interface LangGraphClientConfig {
30
37
  apiUrl?: string;
31
38
  apiKey?: string;
@@ -81,13 +88,7 @@ export declare class LangGraphClient extends Client {
81
88
  run_id: string;
82
89
  };
83
90
  cancelRun(): void;
84
- sendMessage(input: string | Message[], { extraParams, _debug, command }?: {
85
- extraParams?: Record<string, any>;
86
- _debug?: {
87
- streamResponse?: any;
88
- };
89
- command?: Command;
90
- }): Promise<any[]>;
91
+ sendMessage(input: string | Message[], { extraParams, _debug, command }?: SendMessageOptions): Promise<any[]>;
91
92
  private runFETool;
92
93
  private callFETool;
93
94
  /** 恢复消息,当中断流时使用 */
@@ -1,4 +1,4 @@
1
- import { LangGraphClient, LangGraphClientConfig, RenderMessage } from "../LangGraphClient";
1
+ import { LangGraphClient, LangGraphClientConfig, RenderMessage, SendMessageOptions } from "../LangGraphClient";
2
2
  import { Message, Thread } from "@langchain/langgraph-sdk";
3
3
  export declare const formatTime: (date: Date) => string;
4
4
  export declare const formatTokens: (tokens: number) => string;
@@ -22,8 +22,8 @@ export declare const createChatStore: (initClientName: string, config: LangGraph
22
22
  };
23
23
  mutations: {
24
24
  initClient: () => Promise<void>;
25
- sendMessage: () => Promise<void>;
26
- interruptMessage: () => void;
25
+ sendMessage: (message?: Message[], extraData?: SendMessageOptions) => Promise<void>;
26
+ stopGeneration: () => void;
27
27
  toggleToolCollapse: (toolId: string) => void;
28
28
  toggleHistoryVisible: () => void;
29
29
  refreshHistoryList: () => Promise<void>;
@@ -59,17 +59,17 @@ export const createChatStore = (initClientName, config, context = {}) => {
59
59
  newClient.graphState = {};
60
60
  client.set(newClient);
61
61
  };
62
- const sendMessage = async () => {
62
+ const sendMessage = async (message, extraData) => {
63
63
  var _a;
64
- if (!userInput.get().trim() || loading.get() || !client.get())
64
+ if ((!userInput.get().trim() && !(message === null || message === void 0 ? void 0 : message.length)) || loading.get() || !client.get())
65
65
  return;
66
66
  loading.set(true);
67
67
  inChatError.set(null);
68
- await ((_a = client.get()) === null || _a === void 0 ? void 0 : _a.sendMessage(userInput.get()));
68
+ await ((_a = client.get()) === null || _a === void 0 ? void 0 : _a.sendMessage(message || userInput.get(), extraData));
69
69
  userInput.set("");
70
70
  loading.set(false);
71
71
  };
72
- const interruptMessage = () => {
72
+ const stopGeneration = () => {
73
73
  var _a;
74
74
  (_a = client.get()) === null || _a === void 0 ? void 0 : _a.cancelRun();
75
75
  };
@@ -113,7 +113,7 @@ export const createChatStore = (initClientName, config, context = {}) => {
113
113
  mutations: {
114
114
  initClient,
115
115
  sendMessage,
116
- interruptMessage,
116
+ stopGeneration,
117
117
  toggleToolCollapse,
118
118
  toggleHistoryVisible,
119
119
  refreshHistoryList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langgraph-js/sdk",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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",
@@ -27,7 +27,11 @@ export type RenderMessage = Message & {
27
27
  /** 渲染时的唯一 id,聚合而来*/
28
28
  unique_id?: string;
29
29
  };
30
-
30
+ export type SendMessageOptions = {
31
+ extraParams?: Record<string, any>;
32
+ _debug?: { streamResponse?: any };
33
+ command?: Command;
34
+ };
31
35
  export interface LangGraphClientConfig {
32
36
  apiUrl?: string;
33
37
  apiKey?: string;
@@ -311,7 +315,7 @@ export class LangGraphClient extends Client {
311
315
  this.runs.cancel(this.currentThread!.thread_id, this.currentRun.run_id);
312
316
  }
313
317
  }
314
- async sendMessage(input: string | Message[], { extraParams, _debug, command }: { extraParams?: Record<string, any>; _debug?: { streamResponse?: any }; command?: Command } = {}) {
318
+ async sendMessage(input: string | Message[], { extraParams, _debug, command }: SendMessageOptions = {}) {
315
319
  if (!this.currentAssistant) {
316
320
  throw new Error("Thread or Assistant not initialized");
317
321
  }
@@ -1,5 +1,5 @@
1
1
  import { atom } from "nanostores";
2
- import { LangGraphClient, LangGraphClientConfig, RenderMessage } from "../LangGraphClient";
2
+ import { LangGraphClient, LangGraphClientConfig, RenderMessage, SendMessageOptions } from "../LangGraphClient";
3
3
  import { Message, Thread } from "@langchain/langgraph-sdk";
4
4
  export const formatTime = (date: Date) => {
5
5
  return date.toLocaleTimeString("en-US");
@@ -64,19 +64,19 @@ export const createChatStore = (
64
64
  client.set(newClient);
65
65
  };
66
66
 
67
- const sendMessage = async () => {
68
- if (!userInput.get().trim() || loading.get() || !client.get()) return;
67
+ const sendMessage = async (message?: Message[], extraData?: SendMessageOptions) => {
68
+ if ((!userInput.get().trim() && !message?.length) || loading.get() || !client.get()) return;
69
69
 
70
70
  loading.set(true);
71
71
  inChatError.set(null);
72
72
 
73
- await client.get()?.sendMessage(userInput.get());
73
+ await client.get()?.sendMessage(message || userInput.get(), extraData);
74
74
 
75
75
  userInput.set("");
76
76
  loading.set(false);
77
77
  };
78
78
 
79
- const interruptMessage = () => {
79
+ const stopGeneration = () => {
80
80
  client.get()?.cancelRun();
81
81
  };
82
82
 
@@ -120,7 +120,7 @@ export const createChatStore = (
120
120
  mutations: {
121
121
  initClient,
122
122
  sendMessage,
123
- interruptMessage,
123
+ stopGeneration,
124
124
  toggleToolCollapse,
125
125
  toggleHistoryVisible,
126
126
  refreshHistoryList,