@langchain/langgraph-sdk 0.0.1-rc.7 → 0.0.1-rc.9
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/client.d.mts +5 -5
- package/dist/client.mjs +14 -21
- package/dist/schema.d.ts +12 -4
- package/package.json +2 -1
package/dist/client.d.mts
CHANGED
|
@@ -138,17 +138,16 @@ declare class ThreadsClient extends BaseClient {
|
|
|
138
138
|
* @param threadId ID of the thread.
|
|
139
139
|
* @returns Thread state.
|
|
140
140
|
*/
|
|
141
|
-
getState<ValuesType = DefaultValues>(threadId: string): Promise<ThreadState<ValuesType>>;
|
|
141
|
+
getState<ValuesType = DefaultValues>(threadId: string, checkpointId?: string): Promise<ThreadState<ValuesType>>;
|
|
142
142
|
/**
|
|
143
143
|
* Add state to a thread.
|
|
144
144
|
*
|
|
145
|
-
* @param
|
|
146
|
-
* @param values The state update
|
|
147
|
-
* @param options Additional options.
|
|
145
|
+
* @param threadId The ID of the thread.
|
|
148
146
|
* @returns
|
|
149
147
|
*/
|
|
150
|
-
updateState<ValuesType = DefaultValues>(
|
|
148
|
+
updateState<ValuesType = DefaultValues>(threadId: string, options: {
|
|
151
149
|
values: ValuesType;
|
|
150
|
+
checkpointId?: string;
|
|
152
151
|
asNode?: string;
|
|
153
152
|
}): Promise<void>;
|
|
154
153
|
/**
|
|
@@ -168,6 +167,7 @@ declare class ThreadsClient extends BaseClient {
|
|
|
168
167
|
getHistory<ValuesType = DefaultValues>(threadId: string, options?: {
|
|
169
168
|
limit?: number;
|
|
170
169
|
before?: Config;
|
|
170
|
+
metadata?: Metadata;
|
|
171
171
|
}): Promise<ThreadState<ValuesType>[]>;
|
|
172
172
|
}
|
|
173
173
|
declare class RunsClient extends BaseClient {
|
package/dist/client.mjs
CHANGED
|
@@ -198,34 +198,25 @@ class ThreadsClient extends BaseClient {
|
|
|
198
198
|
* @param threadId ID of the thread.
|
|
199
199
|
* @returns Thread state.
|
|
200
200
|
*/
|
|
201
|
-
async getState(threadId) {
|
|
202
|
-
return this.fetch(
|
|
201
|
+
async getState(threadId, checkpointId) {
|
|
202
|
+
return this.fetch(checkpointId != null
|
|
203
|
+
? `/threads/${threadId}/state/${checkpointId}`
|
|
204
|
+
: `/threads/${threadId}/state`);
|
|
203
205
|
}
|
|
204
206
|
/**
|
|
205
207
|
* Add state to a thread.
|
|
206
208
|
*
|
|
207
|
-
* @param
|
|
208
|
-
* @param values The state update
|
|
209
|
-
* @param options Additional options.
|
|
209
|
+
* @param threadId The ID of the thread.
|
|
210
210
|
* @returns
|
|
211
211
|
*/
|
|
212
|
-
async updateState(
|
|
213
|
-
let config = undefined;
|
|
214
|
-
let threadId;
|
|
215
|
-
if (typeof threadIdOrConfig !== "string") {
|
|
216
|
-
config = threadIdOrConfig;
|
|
217
|
-
if (typeof config.configurable?.thread_id !== "string") {
|
|
218
|
-
throw new Error("Thread ID is required when updating state with a config.");
|
|
219
|
-
}
|
|
220
|
-
threadId = config.configurable.thread_id;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
config = undefined;
|
|
224
|
-
threadId = threadIdOrConfig;
|
|
225
|
-
}
|
|
212
|
+
async updateState(threadId, options) {
|
|
226
213
|
return this.fetch(`/threads/${threadId}/state`, {
|
|
227
214
|
method: "POST",
|
|
228
|
-
json: {
|
|
215
|
+
json: {
|
|
216
|
+
values: options.values,
|
|
217
|
+
checkpoint_id: options.checkpointId,
|
|
218
|
+
as_node: options?.asNode,
|
|
219
|
+
},
|
|
229
220
|
});
|
|
230
221
|
}
|
|
231
222
|
/**
|
|
@@ -259,9 +250,11 @@ class ThreadsClient extends BaseClient {
|
|
|
259
250
|
*/
|
|
260
251
|
async getHistory(threadId, options) {
|
|
261
252
|
return this.fetch(`/threads/${threadId}/history`, {
|
|
262
|
-
|
|
253
|
+
method: "POST",
|
|
254
|
+
json: {
|
|
263
255
|
limit: options?.limit ?? 10,
|
|
264
256
|
before: options?.before,
|
|
257
|
+
metadata: options?.metadata,
|
|
265
258
|
},
|
|
266
259
|
});
|
|
267
260
|
}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSONSchema7 } from "json-schema";
|
|
1
2
|
type Optional<T> = T | null | undefined;
|
|
2
3
|
export interface Config {
|
|
3
4
|
/**
|
|
@@ -14,7 +15,14 @@ export interface Config {
|
|
|
14
15
|
* Runtime values for attributes previously made configurable on this Runnable.
|
|
15
16
|
*/
|
|
16
17
|
configurable: {
|
|
18
|
+
/**
|
|
19
|
+
* ID of the thread
|
|
20
|
+
*/
|
|
17
21
|
thread_id?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Timestamp of the state checkpoint
|
|
24
|
+
*/
|
|
25
|
+
thread_ts?: string;
|
|
18
26
|
[key: string]: unknown;
|
|
19
27
|
};
|
|
20
28
|
}
|
|
@@ -26,11 +34,11 @@ export interface GraphSchema {
|
|
|
26
34
|
/**
|
|
27
35
|
* The schema for the graph state
|
|
28
36
|
*/
|
|
29
|
-
state_schema:
|
|
37
|
+
state_schema: JSONSchema7;
|
|
30
38
|
/**
|
|
31
39
|
* The schema for the graph config
|
|
32
40
|
*/
|
|
33
|
-
config_schema:
|
|
41
|
+
config_schema: JSONSchema7;
|
|
34
42
|
}
|
|
35
43
|
export type Metadata = Optional<Record<string, unknown>>;
|
|
36
44
|
export interface Assistant {
|
|
@@ -52,10 +60,10 @@ export type DefaultValues = Record<string, unknown>[] | Record<string, unknown>;
|
|
|
52
60
|
export interface ThreadState<ValuesType = DefaultValues> {
|
|
53
61
|
values: ValuesType;
|
|
54
62
|
next: string[];
|
|
55
|
-
|
|
63
|
+
checkpoint_id: string;
|
|
56
64
|
metadata: Metadata;
|
|
57
65
|
created_at: Optional<string>;
|
|
58
|
-
|
|
66
|
+
parent_checkpoint_id: Optional<string>;
|
|
59
67
|
}
|
|
60
68
|
export interface Run {
|
|
61
69
|
run_id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-sdk",
|
|
3
|
-
"version": "0.0.1-rc.
|
|
3
|
+
"version": "0.0.1-rc.9",
|
|
4
4
|
"description": "Client library for interacting with the LangGraph API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "yarn@1.22.19",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"main": "index.js",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@types/json-schema": "^7.0.15",
|
|
19
20
|
"eventsource-parser": "^1.1.2",
|
|
20
21
|
"p-queue": "^6.6.2",
|
|
21
22
|
"p-retry": "4",
|