@langgraph-js/sdk 2.0.0 → 2.0.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.
- package/dist/LangGraphClient.d.ts +19 -41
- package/dist/LangGraphClient.js +2 -2
- package/dist/client/LanggraphServer.d.ts +2 -1
- package/dist/client/LanggraphServer.js +2 -2
- package/dist/types.d.ts +11 -35
- package/dist/ui-store/createChatStore.d.ts +1 -1
- package/dist/ui-store/createChatStore.js +1 -1
- package/package.json +1 -1
- package/src/LangGraphClient.ts +5 -4
- package/src/client/LanggraphServer.ts +3 -2
- package/src/types.ts +11 -48
- package/src/ui-store/createChatStore.ts +2 -2
|
@@ -68,7 +68,7 @@ export interface LangGraphClientConfig {
|
|
|
68
68
|
timeoutMs?: number;
|
|
69
69
|
defaultHeaders?: Record<string, string | null | undefined>;
|
|
70
70
|
/** 自定义客户端实现,如果不提供则使用官方 Client */
|
|
71
|
-
client: ILangGraphClient
|
|
71
|
+
client: ILangGraphClient<any, any>;
|
|
72
72
|
}
|
|
73
73
|
export interface LangGraphEvents {
|
|
74
74
|
/** 流开始事件 */
|
|
@@ -113,6 +113,11 @@ export declare class LangGraphClient<TStateType = unknown, TUpdateType = TStateT
|
|
|
113
113
|
private currentAssistant;
|
|
114
114
|
private currentThread;
|
|
115
115
|
tools: ToolManager;
|
|
116
|
+
availableAssistants: Assistant[];
|
|
117
|
+
graphState: any;
|
|
118
|
+
currentRun?: {
|
|
119
|
+
run_id: string;
|
|
120
|
+
};
|
|
116
121
|
stopController: AbortController | null;
|
|
117
122
|
/** 用于存储 subAgent 状态数据的键 */
|
|
118
123
|
subAgentsKey: string;
|
|
@@ -135,7 +140,7 @@ export declare class LangGraphClient<TStateType = unknown, TUpdateType = TStateT
|
|
|
135
140
|
};
|
|
136
141
|
/** 代理 threads 属性到内部 client */
|
|
137
142
|
get threads(): {
|
|
138
|
-
create
|
|
143
|
+
create(payload?: {
|
|
139
144
|
metadata?: import("@langchain/langgraph-sdk").Metadata;
|
|
140
145
|
threadId?: string;
|
|
141
146
|
ifExists?: import("@langchain/langgraph-sdk").OnConflictBehavior;
|
|
@@ -143,20 +148,22 @@ export declare class LangGraphClient<TStateType = unknown, TUpdateType = TStateT
|
|
|
143
148
|
supersteps?: Array<{
|
|
144
149
|
updates: Array<{
|
|
145
150
|
values: unknown;
|
|
146
|
-
command
|
|
151
|
+
command? /** 值更新事件 */: Command;
|
|
147
152
|
asNode: string;
|
|
148
153
|
}>;
|
|
149
154
|
}>;
|
|
150
|
-
}): Promise<Thread<
|
|
151
|
-
search
|
|
152
|
-
metadata
|
|
155
|
+
}): Promise<Thread<TStateType>>;
|
|
156
|
+
search(query?: {
|
|
157
|
+
metadata
|
|
158
|
+
/** Thread 创建事件 */
|
|
159
|
+
? /** Thread 创建事件 */: import("@langchain/langgraph-sdk").Metadata;
|
|
153
160
|
limit?: number;
|
|
154
161
|
offset?: number;
|
|
155
162
|
status?: import("@langchain/langgraph-sdk").ThreadStatus;
|
|
156
163
|
sortBy?: import("./types.js").ThreadSortBy;
|
|
157
164
|
sortOrder?: import("./types.js").SortOrder;
|
|
158
|
-
}): Promise<Thread<
|
|
159
|
-
get
|
|
165
|
+
}): Promise<Thread<TStateType>[]>;
|
|
166
|
+
get(threadId: string): Promise<Thread<TStateType>>;
|
|
160
167
|
delete(threadId: string): Promise<void>;
|
|
161
168
|
};
|
|
162
169
|
/** 代理 runs 属性到内部 client */
|
|
@@ -166,31 +173,7 @@ export declare class LangGraphClient<TStateType = unknown, TUpdateType = TStateT
|
|
|
166
173
|
offset?: number;
|
|
167
174
|
status?: import("./types.js").RunStatus;
|
|
168
175
|
}): Promise<import("@langchain/langgraph-sdk").Run[]>;
|
|
169
|
-
stream<
|
|
170
|
-
input?: Record<string, unknown> | null;
|
|
171
|
-
metadata?: import("@langchain/langgraph-sdk").Metadata;
|
|
172
|
-
config?: import("@langchain/langgraph-sdk").Config;
|
|
173
|
-
checkpointId?: string;
|
|
174
|
-
checkpoint?: Omit<import("@langchain/langgraph-sdk").Checkpoint, "thread_id">;
|
|
175
|
-
checkpointDuring?: boolean;
|
|
176
|
-
interruptBefore?: "*" | string[];
|
|
177
|
-
interruptAfter?: "*" | string[];
|
|
178
|
-
signal?: AbortController["signal"];
|
|
179
|
-
webhook?: string;
|
|
180
|
-
onDisconnect?: import("./types.js").DisconnectMode;
|
|
181
|
-
afterSeconds?: number;
|
|
182
|
-
ifNotExists?: "create" | "reject";
|
|
183
|
-
command?: Command;
|
|
184
|
-
onRunCreated?: (params: {
|
|
185
|
-
run_id: string;
|
|
186
|
-
thread_id?: string;
|
|
187
|
-
}) => void;
|
|
188
|
-
streamMode?: TStreamMode | undefined;
|
|
189
|
-
streamSubgraphs?: TSubgraphs | undefined;
|
|
190
|
-
streamResumable?: boolean;
|
|
191
|
-
feedbackKeys?: string[];
|
|
192
|
-
} | undefined): import("./types.js").TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, unknown>;
|
|
193
|
-
stream<TStreamMode extends import("@langchain/langgraph-sdk").StreamMode | import("@langchain/langgraph-sdk").StreamMode[] = import("@langchain/langgraph-sdk").StreamMode, TSubgraphs extends boolean = false>(threadId: string, assistantId: string, payload?: {
|
|
176
|
+
stream<TSubgraphs extends boolean = false>(threadId: string, assistantId: string, payload?: {
|
|
194
177
|
input?: Record<string, unknown> | null;
|
|
195
178
|
metadata?: import("@langchain/langgraph-sdk").Metadata;
|
|
196
179
|
config?: import("@langchain/langgraph-sdk").Config;
|
|
@@ -211,12 +194,12 @@ export declare class LangGraphClient<TStateType = unknown, TUpdateType = TStateT
|
|
|
211
194
|
run_id: string;
|
|
212
195
|
thread_id?: string;
|
|
213
196
|
}) => void;
|
|
214
|
-
streamMode?:
|
|
197
|
+
streamMode?: import("@langchain/langgraph-sdk").StreamMode[];
|
|
215
198
|
streamSubgraphs?: TSubgraphs | undefined;
|
|
216
199
|
streamResumable?: boolean;
|
|
217
200
|
feedbackKeys?: string[];
|
|
218
|
-
} | undefined): import("./types.js").TypedAsyncGenerator<
|
|
219
|
-
joinStream(threadId: string
|
|
201
|
+
} | undefined): import("./types.js").TypedAsyncGenerator<TSubgraphs, TStateType, TUpdateType>;
|
|
202
|
+
joinStream(threadId: string, runId: string, options?: {
|
|
220
203
|
signal?: AbortSignal;
|
|
221
204
|
cancelOnDisconnect?: boolean;
|
|
222
205
|
lastEventId?: string;
|
|
@@ -228,7 +211,6 @@ export declare class LangGraphClient<TStateType = unknown, TUpdateType = TStateT
|
|
|
228
211
|
}>;
|
|
229
212
|
cancel(threadId: string, runId: string, wait?: boolean, action?: import("./types.js").CancelAction): Promise<void>;
|
|
230
213
|
};
|
|
231
|
-
availableAssistants: Assistant[];
|
|
232
214
|
private listAssistants;
|
|
233
215
|
/**
|
|
234
216
|
* @zh 初始化 Assistant。
|
|
@@ -272,10 +254,6 @@ export declare class LangGraphClient<TStateType = unknown, TUpdateType = TStateT
|
|
|
272
254
|
};
|
|
273
255
|
/** 前端工具人机交互时,锁住面板 */
|
|
274
256
|
isFELocking(messages: RenderMessage[]): boolean | undefined;
|
|
275
|
-
graphState: any;
|
|
276
|
-
currentRun?: {
|
|
277
|
-
run_id: string;
|
|
278
|
-
};
|
|
279
257
|
/**
|
|
280
258
|
* @zh 取消当前的 Run。
|
|
281
259
|
* @en Cancels the current Run.
|
package/dist/LangGraphClient.js
CHANGED
|
@@ -11,11 +11,11 @@ export class LangGraphClient extends EventEmitter {
|
|
|
11
11
|
this.currentAssistant = null;
|
|
12
12
|
this.currentThread = null;
|
|
13
13
|
this.tools = new ToolManager();
|
|
14
|
+
this.availableAssistants = [];
|
|
15
|
+
this.graphState = {};
|
|
14
16
|
this.stopController = null;
|
|
15
17
|
/** 用于存储 subAgent 状态数据的键 */
|
|
16
18
|
this.subAgentsKey = "task_store";
|
|
17
|
-
this.availableAssistants = [];
|
|
18
|
-
this.graphState = {};
|
|
19
19
|
/** 当前子图位置,但是依赖 stream,不太适合稳定使用*/
|
|
20
20
|
this.graphPosition = "";
|
|
21
21
|
this.extraParams = {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { LangGraphClientConfig } from "../LangGraphClient.js";
|
|
1
2
|
import { ILangGraphClient } from "../types.js";
|
|
2
|
-
export declare const createLangGraphServerClient: () => Promise<ILangGraphClient>;
|
|
3
|
+
export declare const createLangGraphServerClient: (config: LangGraphClientConfig) => Promise<ILangGraphClient>;
|
package/dist/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";
|
|
|
8
8
|
export type DisconnectMode = "cancel" | "continue";
|
|
9
9
|
export type OnCompletionBehavior = "complete" | "continue";
|
|
10
10
|
export type CancelAction = "interrupt" | "rollback";
|
|
11
|
-
export type TypedAsyncGenerator<
|
|
11
|
+
export type TypedAsyncGenerator<TStateType = unknown, TUpdateType = TStateType, TCustomType = unknown> = AsyncGenerator<{
|
|
12
12
|
values: ValuesStreamEvent<TStateType>;
|
|
13
13
|
updates: UpdatesStreamEvent<TUpdateType>;
|
|
14
14
|
custom: CustomStreamEvent<TCustomType>;
|
|
@@ -16,7 +16,7 @@ export type TypedAsyncGenerator<TStreamMode extends StreamMode | StreamMode[] =
|
|
|
16
16
|
messages: MessagesStreamEvent;
|
|
17
17
|
"messages-tuple": MessagesTupleStreamEvent;
|
|
18
18
|
events: EventsStreamEvent;
|
|
19
|
-
}[
|
|
19
|
+
}[StreamMode] | ErrorStreamEvent | MetadataStreamEvent | FeedbackStreamEvent>;
|
|
20
20
|
/**
|
|
21
21
|
* 兼容 LangGraph SDK 的接口定义,方便进行无侵入式的扩展
|
|
22
22
|
*/
|
|
@@ -35,7 +35,7 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
35
35
|
}): Promise<AssistantGraph>;
|
|
36
36
|
};
|
|
37
37
|
threads: {
|
|
38
|
-
create
|
|
38
|
+
create(payload?: {
|
|
39
39
|
metadata?: Metadata;
|
|
40
40
|
threadId?: string;
|
|
41
41
|
ifExists?: OnConflictBehavior;
|
|
@@ -47,16 +47,16 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
47
47
|
asNode: string;
|
|
48
48
|
}>;
|
|
49
49
|
}>;
|
|
50
|
-
}): Promise<Thread<
|
|
51
|
-
search
|
|
50
|
+
}): Promise<Thread<TStateType>>;
|
|
51
|
+
search(query?: {
|
|
52
52
|
metadata?: Metadata;
|
|
53
53
|
limit?: number;
|
|
54
54
|
offset?: number;
|
|
55
55
|
status?: ThreadStatus;
|
|
56
56
|
sortBy?: ThreadSortBy;
|
|
57
57
|
sortOrder?: SortOrder;
|
|
58
|
-
}): Promise<Thread<
|
|
59
|
-
get
|
|
58
|
+
}): Promise<Thread<TStateType>[]>;
|
|
59
|
+
get(threadId: string): Promise<Thread<TStateType>>;
|
|
60
60
|
delete(threadId: string): Promise<void>;
|
|
61
61
|
};
|
|
62
62
|
runs: {
|
|
@@ -65,31 +65,7 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
65
65
|
offset?: number;
|
|
66
66
|
status?: RunStatus;
|
|
67
67
|
}): Promise<Run[]>;
|
|
68
|
-
stream<
|
|
69
|
-
input?: Record<string, unknown> | null;
|
|
70
|
-
metadata?: Metadata;
|
|
71
|
-
config?: Config;
|
|
72
|
-
checkpointId?: string;
|
|
73
|
-
checkpoint?: Omit<Checkpoint, "thread_id">;
|
|
74
|
-
checkpointDuring?: boolean;
|
|
75
|
-
interruptBefore?: "*" | string[];
|
|
76
|
-
interruptAfter?: "*" | string[];
|
|
77
|
-
signal?: AbortController["signal"];
|
|
78
|
-
webhook?: string;
|
|
79
|
-
onDisconnect?: DisconnectMode;
|
|
80
|
-
afterSeconds?: number;
|
|
81
|
-
ifNotExists?: "create" | "reject";
|
|
82
|
-
command?: Command;
|
|
83
|
-
onRunCreated?: (params: {
|
|
84
|
-
run_id: string;
|
|
85
|
-
thread_id?: string;
|
|
86
|
-
}) => void;
|
|
87
|
-
streamMode?: TStreamMode;
|
|
88
|
-
streamSubgraphs?: TSubgraphs;
|
|
89
|
-
streamResumable?: boolean;
|
|
90
|
-
feedbackKeys?: string[];
|
|
91
|
-
}): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType>;
|
|
92
|
-
stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(threadId: string, assistantId: string, payload?: {
|
|
68
|
+
stream<TSubgraphs extends boolean = false>(threadId: string, assistantId: string, payload?: {
|
|
93
69
|
input?: Record<string, unknown> | null;
|
|
94
70
|
metadata?: Metadata;
|
|
95
71
|
config?: Config;
|
|
@@ -110,12 +86,12 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
110
86
|
run_id: string;
|
|
111
87
|
thread_id?: string;
|
|
112
88
|
}) => void;
|
|
113
|
-
streamMode?:
|
|
89
|
+
streamMode?: StreamMode[];
|
|
114
90
|
streamSubgraphs?: TSubgraphs;
|
|
115
91
|
streamResumable?: boolean;
|
|
116
92
|
feedbackKeys?: string[];
|
|
117
|
-
}): TypedAsyncGenerator<
|
|
118
|
-
joinStream(threadId: string
|
|
93
|
+
}): TypedAsyncGenerator<TSubgraphs, TStateType, TUpdateType>;
|
|
94
|
+
joinStream(threadId: string, runId: string, options?: {
|
|
119
95
|
signal?: AbortSignal;
|
|
120
96
|
cancelOnDisconnect?: boolean;
|
|
121
97
|
lastEventId?: string;
|
|
@@ -25,7 +25,7 @@ export declare const getHistoryContent: (thread: Thread) => string | any[];
|
|
|
25
25
|
* @zh 创建一个用于聊天界面的状态管理器 (store)。
|
|
26
26
|
* @en Creates a state manager (store) for the chat interface.
|
|
27
27
|
*/
|
|
28
|
-
export declare const createChatStore: (initClientName: string, config: LangGraphClientConfig
|
|
28
|
+
export declare const createChatStore: (initClientName: string, config: Partial<LangGraphClientConfig>, context?: {
|
|
29
29
|
showHistory?: boolean;
|
|
30
30
|
showGraph?: boolean;
|
|
31
31
|
onInit?: (client: LangGraphClient) => void;
|
|
@@ -106,7 +106,7 @@ export const createChatStore = (initClientName, config, context = {}) => {
|
|
|
106
106
|
var _a, _b;
|
|
107
107
|
const newClient = new LangGraphClient({
|
|
108
108
|
...config,
|
|
109
|
-
client: (_a = config.client) !== null && _a !== void 0 ? _a : (await createLangGraphServerClient()),
|
|
109
|
+
client: (_a = config.client) !== null && _a !== void 0 ? _a : (await createLangGraphServerClient(config)),
|
|
110
110
|
});
|
|
111
111
|
await newClient.initAssistant(currentAgent.get());
|
|
112
112
|
currentAgent.set(newClient.getCurrentAssistant().graph_id);
|
package/package.json
CHANGED
package/src/LangGraphClient.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface LangGraphClientConfig {
|
|
|
68
68
|
timeoutMs?: number;
|
|
69
69
|
defaultHeaders?: Record<string, string | null | undefined>;
|
|
70
70
|
/** 自定义客户端实现,如果不提供则使用官方 Client */
|
|
71
|
-
client: ILangGraphClient
|
|
71
|
+
client: ILangGraphClient<any, any>;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// 定义事件数据类型
|
|
@@ -96,6 +96,9 @@ export class LangGraphClient<TStateType = unknown, TUpdateType = TStateType> ext
|
|
|
96
96
|
private currentAssistant: Assistant | null = null;
|
|
97
97
|
private currentThread: Thread<TStateType> | null = null;
|
|
98
98
|
tools: ToolManager = new ToolManager();
|
|
99
|
+
availableAssistants: Assistant[] = [];
|
|
100
|
+
graphState: any = {};
|
|
101
|
+
currentRun?: { run_id: string };
|
|
99
102
|
stopController: AbortController | null = null;
|
|
100
103
|
/** 用于存储 subAgent 状态数据的键 */
|
|
101
104
|
subAgentsKey = "task_store";
|
|
@@ -122,7 +125,6 @@ export class LangGraphClient<TStateType = unknown, TUpdateType = TStateType> ext
|
|
|
122
125
|
get runs() {
|
|
123
126
|
return this.client.runs;
|
|
124
127
|
}
|
|
125
|
-
availableAssistants: Assistant[] = [];
|
|
126
128
|
private listAssistants() {
|
|
127
129
|
return this.assistants.search({
|
|
128
130
|
metadata: null,
|
|
@@ -272,8 +274,7 @@ export class LangGraphClient<TStateType = unknown, TUpdateType = TStateType> ext
|
|
|
272
274
|
const tool = this.tools.getTool(lastMessage?.name!);
|
|
273
275
|
return tool && tool.render && lastMessage?.type === "tool" && !lastMessage?.additional_kwargs?.done;
|
|
274
276
|
}
|
|
275
|
-
|
|
276
|
-
currentRun?: { run_id: string };
|
|
277
|
+
|
|
277
278
|
/**
|
|
278
279
|
* @zh 取消当前的 Run。
|
|
279
280
|
* @en Cancels the current Run.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LangGraphClientConfig } from "../LangGraphClient.js";
|
|
1
2
|
import { ILangGraphClient } from "../types.js";
|
|
2
3
|
|
|
3
|
-
export const createLangGraphServerClient = async (): Promise<ILangGraphClient> => {
|
|
4
|
+
export const createLangGraphServerClient = async (config: LangGraphClientConfig): Promise<ILangGraphClient> => {
|
|
4
5
|
const { Client } = await import("@langchain/langgraph-sdk");
|
|
5
|
-
return new Client() as unknown as ILangGraphClient;
|
|
6
|
+
return new Client(config) as unknown as ILangGraphClient;
|
|
6
7
|
};
|
package/src/types.ts
CHANGED
|
@@ -34,13 +34,7 @@ export type OnCompletionBehavior = "complete" | "continue";
|
|
|
34
34
|
export type CancelAction = "interrupt" | "rollback";
|
|
35
35
|
|
|
36
36
|
// 流式异步生成器类型
|
|
37
|
-
export type TypedAsyncGenerator<
|
|
38
|
-
TStreamMode extends StreamMode | StreamMode[] = [],
|
|
39
|
-
TSubgraphs extends boolean = false,
|
|
40
|
-
TStateType = unknown,
|
|
41
|
-
TUpdateType = TStateType,
|
|
42
|
-
TCustomType = unknown,
|
|
43
|
-
> = AsyncGenerator<
|
|
37
|
+
export type TypedAsyncGenerator<TStateType = unknown, TUpdateType = TStateType, TCustomType = unknown> = AsyncGenerator<
|
|
44
38
|
| {
|
|
45
39
|
values: ValuesStreamEvent<TStateType>;
|
|
46
40
|
updates: UpdatesStreamEvent<TUpdateType>;
|
|
@@ -49,7 +43,7 @@ export type TypedAsyncGenerator<
|
|
|
49
43
|
messages: MessagesStreamEvent;
|
|
50
44
|
"messages-tuple": MessagesTupleStreamEvent;
|
|
51
45
|
events: EventsStreamEvent;
|
|
52
|
-
}[
|
|
46
|
+
}[StreamMode]
|
|
53
47
|
| ErrorStreamEvent
|
|
54
48
|
| MetadataStreamEvent
|
|
55
49
|
| FeedbackStreamEvent
|
|
@@ -64,7 +58,7 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
64
58
|
getGraph(assistantId: string, options?: { xray?: boolean | number }): Promise<AssistantGraph>;
|
|
65
59
|
};
|
|
66
60
|
threads: {
|
|
67
|
-
create
|
|
61
|
+
create(payload?: {
|
|
68
62
|
metadata?: Metadata;
|
|
69
63
|
threadId?: string;
|
|
70
64
|
ifExists?: OnConflictBehavior;
|
|
@@ -76,16 +70,9 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
76
70
|
asNode: string;
|
|
77
71
|
}>;
|
|
78
72
|
}>;
|
|
79
|
-
}): Promise<Thread<
|
|
80
|
-
search
|
|
81
|
-
|
|
82
|
-
limit?: number;
|
|
83
|
-
offset?: number;
|
|
84
|
-
status?: ThreadStatus;
|
|
85
|
-
sortBy?: ThreadSortBy;
|
|
86
|
-
sortOrder?: SortOrder;
|
|
87
|
-
}): Promise<Thread<ValuesType>[]>;
|
|
88
|
-
get<ValuesType = TStateType>(threadId: string): Promise<Thread<ValuesType>>;
|
|
73
|
+
}): Promise<Thread<TStateType>>;
|
|
74
|
+
search(query?: { metadata?: Metadata; limit?: number; offset?: number; status?: ThreadStatus; sortBy?: ThreadSortBy; sortOrder?: SortOrder }): Promise<Thread<TStateType>[]>;
|
|
75
|
+
get(threadId: string): Promise<Thread<TStateType>>;
|
|
89
76
|
delete(threadId: string): Promise<void>;
|
|
90
77
|
};
|
|
91
78
|
runs: {
|
|
@@ -97,32 +84,8 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
97
84
|
status?: RunStatus;
|
|
98
85
|
}
|
|
99
86
|
): Promise<Run[]>;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
assistantId: string,
|
|
103
|
-
payload?: {
|
|
104
|
-
input?: Record<string, unknown> | null;
|
|
105
|
-
metadata?: Metadata;
|
|
106
|
-
config?: Config;
|
|
107
|
-
checkpointId?: string;
|
|
108
|
-
checkpoint?: Omit<Checkpoint, "thread_id">;
|
|
109
|
-
checkpointDuring?: boolean;
|
|
110
|
-
interruptBefore?: "*" | string[];
|
|
111
|
-
interruptAfter?: "*" | string[];
|
|
112
|
-
signal?: AbortController["signal"];
|
|
113
|
-
webhook?: string;
|
|
114
|
-
onDisconnect?: DisconnectMode;
|
|
115
|
-
afterSeconds?: number;
|
|
116
|
-
ifNotExists?: "create" | "reject";
|
|
117
|
-
command?: Command;
|
|
118
|
-
onRunCreated?: (params: { run_id: string; thread_id?: string }) => void;
|
|
119
|
-
streamMode?: TStreamMode;
|
|
120
|
-
streamSubgraphs?: TSubgraphs;
|
|
121
|
-
streamResumable?: boolean;
|
|
122
|
-
feedbackKeys?: string[];
|
|
123
|
-
}
|
|
124
|
-
): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType>;
|
|
125
|
-
stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(
|
|
87
|
+
|
|
88
|
+
stream<TSubgraphs extends boolean = false>(
|
|
126
89
|
threadId: string,
|
|
127
90
|
assistantId: string,
|
|
128
91
|
payload?: {
|
|
@@ -143,14 +106,14 @@ export interface ILangGraphClient<TStateType = unknown, TUpdateType = TStateType
|
|
|
143
106
|
ifNotExists?: "create" | "reject";
|
|
144
107
|
command?: Command;
|
|
145
108
|
onRunCreated?: (params: { run_id: string; thread_id?: string }) => void;
|
|
146
|
-
streamMode?:
|
|
109
|
+
streamMode?: StreamMode[];
|
|
147
110
|
streamSubgraphs?: TSubgraphs;
|
|
148
111
|
streamResumable?: boolean;
|
|
149
112
|
feedbackKeys?: string[];
|
|
150
113
|
}
|
|
151
|
-
): TypedAsyncGenerator<
|
|
114
|
+
): TypedAsyncGenerator<TSubgraphs, TStateType, TUpdateType>;
|
|
152
115
|
joinStream(
|
|
153
|
-
threadId: string
|
|
116
|
+
threadId: string,
|
|
154
117
|
runId: string,
|
|
155
118
|
options?:
|
|
156
119
|
| {
|
|
@@ -66,7 +66,7 @@ export const getHistoryContent = (thread: Thread) => {
|
|
|
66
66
|
*/
|
|
67
67
|
export const createChatStore = (
|
|
68
68
|
initClientName: string,
|
|
69
|
-
config: LangGraphClientConfig
|
|
69
|
+
config: Partial<LangGraphClientConfig>,
|
|
70
70
|
context: {
|
|
71
71
|
showHistory?: boolean;
|
|
72
72
|
showGraph?: boolean;
|
|
@@ -113,7 +113,7 @@ export const createChatStore = (
|
|
|
113
113
|
async function initClient() {
|
|
114
114
|
const newClient = new LangGraphClient({
|
|
115
115
|
...config,
|
|
116
|
-
client: config.client ?? (await createLangGraphServerClient()),
|
|
116
|
+
client: config.client ?? (await createLangGraphServerClient(config as LangGraphClientConfig)),
|
|
117
117
|
});
|
|
118
118
|
await newClient.initAssistant(currentAgent.get());
|
|
119
119
|
currentAgent.set(newClient.getCurrentAssistant()!.graph_id);
|