@langchain/langgraph-api 0.0.59 → 0.0.61

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.
@@ -0,0 +1,288 @@
1
+ import type { LangGraphRunnableConfig, CheckpointMetadata as LangGraphCheckpointMetadata, StateSnapshot as LangGraphStateSnapshot } from "@langchain/langgraph";
2
+ import type { RunCommand } from "../command.mjs";
3
+ import type { AuthContext } from "../auth/index.mjs";
4
+ export type { RunCommand } from "../command.mjs";
5
+ export type StorageEnv = {
6
+ Variables: {
7
+ LANGGRAPH_OPS: Ops;
8
+ };
9
+ };
10
+ export type Metadata = Record<string, unknown>;
11
+ export type ThreadStatus = "idle" | "busy" | "interrupted" | "error";
12
+ export type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
13
+ export type StreamMode = "values" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "debug" | "tasks" | "checkpoints";
14
+ export type MultitaskStrategy = "reject" | "rollback" | "interrupt" | "enqueue";
15
+ export type OnConflictBehavior = "raise" | "do_nothing";
16
+ export type IfNotExists = "create" | "reject";
17
+ export interface RunnableConfig {
18
+ tags?: string[];
19
+ recursion_limit?: number;
20
+ configurable?: {
21
+ thread_id?: string;
22
+ thread_ts?: string;
23
+ [key: string]: unknown;
24
+ };
25
+ metadata?: LangGraphRunnableConfig["metadata"];
26
+ }
27
+ export interface Assistant {
28
+ name: string | undefined;
29
+ assistant_id: string;
30
+ graph_id: string;
31
+ created_at: Date;
32
+ updated_at: Date;
33
+ version: number;
34
+ config: RunnableConfig;
35
+ context: unknown;
36
+ metadata: Metadata;
37
+ }
38
+ export interface AssistantVersion {
39
+ assistant_id: string;
40
+ version: number;
41
+ graph_id: string;
42
+ config: RunnableConfig;
43
+ context: unknown;
44
+ metadata: Metadata;
45
+ created_at: Date;
46
+ name: string | undefined;
47
+ }
48
+ export interface RunKwargs {
49
+ input?: unknown;
50
+ command?: RunCommand;
51
+ stream_mode?: Array<StreamMode>;
52
+ interrupt_before?: "*" | string[] | undefined;
53
+ interrupt_after?: "*" | string[] | undefined;
54
+ config?: RunnableConfig;
55
+ context?: unknown;
56
+ subgraphs?: boolean;
57
+ resumable?: boolean;
58
+ temporary?: boolean;
59
+ webhook?: unknown;
60
+ feedback_keys?: string[] | undefined;
61
+ [key: string]: unknown;
62
+ }
63
+ export interface Run {
64
+ run_id: string;
65
+ thread_id: string;
66
+ assistant_id: string;
67
+ created_at: Date;
68
+ updated_at: Date;
69
+ status: RunStatus;
70
+ metadata: Metadata;
71
+ kwargs: RunKwargs;
72
+ multitask_strategy: MultitaskStrategy;
73
+ }
74
+ export interface Store {
75
+ runs: Record<string, Run>;
76
+ threads: Record<string, Thread>;
77
+ assistants: Record<string, Assistant>;
78
+ assistant_versions: AssistantVersion[];
79
+ retry_counter: Record<string, number>;
80
+ }
81
+ export interface Message {
82
+ topic: `run:${string}:stream:${string}`;
83
+ data: unknown;
84
+ }
85
+ export interface Thread {
86
+ thread_id: string;
87
+ created_at: Date;
88
+ updated_at: Date;
89
+ metadata?: Metadata;
90
+ config?: RunnableConfig;
91
+ status: ThreadStatus;
92
+ values?: Record<string, unknown>;
93
+ interrupts?: Record<string, unknown>;
94
+ }
95
+ export interface CheckpointTask {
96
+ id: string;
97
+ name: string;
98
+ error?: string;
99
+ interrupts: Record<string, unknown>;
100
+ state?: RunnableConfig;
101
+ }
102
+ export interface CheckpointPayload {
103
+ config?: RunnableConfig;
104
+ metadata: LangGraphCheckpointMetadata;
105
+ values: Record<string, unknown>;
106
+ next: string[];
107
+ parent_config?: RunnableConfig;
108
+ tasks: CheckpointTask[];
109
+ }
110
+ export interface Checkpoint {
111
+ thread_id: string;
112
+ checkpoint_ns: string;
113
+ checkpoint_id: string | null;
114
+ checkpoint_map: Record<string, unknown> | null;
115
+ }
116
+ export interface ThreadTask {
117
+ id: string;
118
+ name: string;
119
+ error: string | null;
120
+ interrupts: Record<string, unknown>[];
121
+ checkpoint: Checkpoint | null;
122
+ state: ThreadState | null;
123
+ result: unknown | null;
124
+ }
125
+ export interface ThreadState {
126
+ values: Record<string, unknown>;
127
+ next: string[];
128
+ checkpoint: Checkpoint | null;
129
+ metadata: Record<string, unknown> | undefined;
130
+ created_at: Date | null;
131
+ parent_checkpoint: Checkpoint | null;
132
+ tasks: ThreadTask[];
133
+ }
134
+ export interface RunsRepo {
135
+ next(): AsyncGenerator<{
136
+ run: Run;
137
+ attempt: number;
138
+ signal: AbortSignal;
139
+ }>;
140
+ put(runId: string, assistantId: string, kwargs: RunKwargs, options: {
141
+ threadId?: string;
142
+ userId?: string;
143
+ status?: RunStatus;
144
+ metadata?: Metadata;
145
+ preventInsertInInflight?: boolean;
146
+ multitaskStrategy?: MultitaskStrategy;
147
+ ifNotExists?: IfNotExists;
148
+ afterSeconds?: number;
149
+ }, auth: AuthContext | undefined): Promise<Run[]>;
150
+ get(runId: string, thread_id: string | undefined, auth: AuthContext | undefined): Promise<Run | null>;
151
+ delete(run_id: string, thread_id: string | undefined, auth: AuthContext | undefined): Promise<string | null>;
152
+ wait(runId: string, threadId: string | undefined, auth: AuthContext | undefined): Promise<unknown>;
153
+ join(runId: string, threadId: string, auth: AuthContext | undefined): Promise<unknown>;
154
+ setStatus(runId: string, status: RunStatus): Promise<unknown>;
155
+ cancel(threadId: string | undefined, runIds: string[], options: {
156
+ action?: "interrupt" | "rollback";
157
+ }, auth: AuthContext | undefined): Promise<void>;
158
+ search(threadId: string, options: {
159
+ limit?: number | null;
160
+ offset?: number | null;
161
+ status?: string | null;
162
+ metadata?: Metadata | null;
163
+ }, auth: AuthContext | undefined): Promise<Run[]>;
164
+ readonly stream: RunsStreamRepo;
165
+ }
166
+ export interface RunsStreamRepo {
167
+ join(runId: string, threadId: string | undefined, options: {
168
+ ignore404?: boolean;
169
+ cancelOnDisconnect?: AbortSignal;
170
+ lastEventId: string | undefined;
171
+ }, auth: AuthContext | undefined): AsyncGenerator<{
172
+ id?: string;
173
+ event: string;
174
+ data: unknown;
175
+ }>;
176
+ publish(payload: {
177
+ runId: string;
178
+ resumable: boolean;
179
+ event: string;
180
+ data: unknown | Error;
181
+ }): Promise<void>;
182
+ }
183
+ export interface ThreadsRepo {
184
+ search(options: {
185
+ metadata?: Metadata;
186
+ status?: ThreadStatus;
187
+ values?: Record<string, unknown>;
188
+ limit: number;
189
+ offset: number;
190
+ sort_by?: "thread_id" | "status" | "created_at" | "updated_at";
191
+ sort_order?: "asc" | "desc";
192
+ }, auth: AuthContext | undefined): AsyncGenerator<{
193
+ thread: Thread;
194
+ total: number;
195
+ }>;
196
+ get(thread_id: string, auth: AuthContext | undefined): Promise<Thread>;
197
+ put(thread_id: string, options: {
198
+ metadata?: Metadata;
199
+ if_exists: OnConflictBehavior;
200
+ }, auth: AuthContext | undefined): Promise<Thread>;
201
+ patch(threadId: string, options: {
202
+ metadata?: Metadata;
203
+ }, auth: AuthContext | undefined): Promise<Thread>;
204
+ setStatus(threadId: string, options: {
205
+ checkpoint?: CheckpointPayload;
206
+ exception?: Error;
207
+ }): Promise<void>;
208
+ delete(thread_id: string, auth: AuthContext | undefined): Promise<string[]>;
209
+ copy(thread_id: string, auth: AuthContext | undefined): Promise<Thread>;
210
+ count(options: {
211
+ metadata?: Metadata;
212
+ values?: Record<string, unknown>;
213
+ status?: ThreadStatus;
214
+ }, auth: AuthContext | undefined): Promise<number>;
215
+ readonly state: ThreadsStateRepo;
216
+ }
217
+ export interface ThreadsStateRepo {
218
+ get(config: RunnableConfig, options: {
219
+ subgraphs?: boolean;
220
+ }, auth: AuthContext | undefined): Promise<LangGraphStateSnapshot>;
221
+ post(config: RunnableConfig, values: Record<string, unknown>[] | Record<string, unknown> | null | undefined, asNode: string | undefined, auth: AuthContext | undefined): Promise<{
222
+ checkpoint: Record<string, unknown> | undefined;
223
+ }>;
224
+ bulk(config: RunnableConfig, supersteps: Array<{
225
+ updates: Array<{
226
+ values?: Record<string, unknown>[] | Record<string, unknown> | unknown | null | undefined;
227
+ command?: RunCommand | undefined | null;
228
+ as_node?: string | undefined;
229
+ }>;
230
+ }>, auth: AuthContext | undefined): Promise<{
231
+ checkpoint: Record<string, unknown> | undefined;
232
+ } | unknown[]>;
233
+ list(config: RunnableConfig, options: {
234
+ limit?: number;
235
+ before?: string | RunnableConfig;
236
+ metadata?: Metadata;
237
+ }, auth: AuthContext | undefined): Promise<LangGraphStateSnapshot[]>;
238
+ }
239
+ export interface AssistantsRepo {
240
+ search(options: {
241
+ graph_id?: string;
242
+ metadata?: Metadata;
243
+ limit: number;
244
+ offset: number;
245
+ }, auth: AuthContext | undefined): AsyncGenerator<{
246
+ assistant: Assistant;
247
+ total: number;
248
+ }>;
249
+ get(assistant_id: string, auth: AuthContext | undefined): Promise<Assistant>;
250
+ put(assistant_id: string, options: {
251
+ config: RunnableConfig;
252
+ context: unknown;
253
+ graph_id: string;
254
+ metadata?: Metadata;
255
+ if_exists: OnConflictBehavior;
256
+ name?: string;
257
+ }, auth: AuthContext | undefined): Promise<Assistant>;
258
+ patch(assistantId: string, options: {
259
+ config?: RunnableConfig;
260
+ context?: unknown;
261
+ graph_id?: string;
262
+ metadata?: Metadata;
263
+ name?: string;
264
+ }, auth: AuthContext | undefined): Promise<Assistant>;
265
+ delete(assistant_id: string, auth: AuthContext | undefined): Promise<string[]>;
266
+ count(options: {
267
+ graph_id?: string;
268
+ metadata?: Metadata;
269
+ }, auth: AuthContext | undefined): Promise<number>;
270
+ setLatest(assistant_id: string, version: number, auth: AuthContext | undefined): Promise<Assistant>;
271
+ getVersions(assistant_id: string, options: {
272
+ limit: number;
273
+ offset: number;
274
+ metadata?: Metadata;
275
+ }, auth: AuthContext | undefined): Promise<AssistantVersion[]>;
276
+ }
277
+ export interface Ops {
278
+ readonly assistants: AssistantsRepo;
279
+ readonly threads: ThreadsRepo;
280
+ readonly runs: RunsRepo;
281
+ truncate(flags: {
282
+ runs?: boolean;
283
+ threads?: boolean;
284
+ assistants?: boolean;
285
+ checkpointer?: boolean;
286
+ store?: boolean;
287
+ }): Promise<void>;
288
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/stream.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { BaseCheckpointSaver, LangGraphRunnableConfig, CheckpointMetadata, Interrupt, StateSnapshot } from "@langchain/langgraph";
2
2
  import type { Pregel } from "@langchain/langgraph/pregel";
3
- import type { Checkpoint, Run, RunnableConfig } from "./storage/ops.mjs";
3
+ import type { Checkpoint, Run, RunnableConfig } from "./storage/types.mjs";
4
4
  interface DebugTask {
5
5
  id: string;
6
6
  name: string;
package/dist/stream.mjs CHANGED
@@ -140,6 +140,18 @@ export async function* streamState(run, options) {
140
140
  data = { ...debugChunk, payload: debugResult };
141
141
  }
142
142
  }
143
+ else if (mode === "checkpoints") {
144
+ const debugCheckpoint = preprocessDebugCheckpoint(chunk);
145
+ options?.onCheckpoint?.(debugCheckpoint);
146
+ data = debugCheckpoint;
147
+ }
148
+ else if (mode === "tasks") {
149
+ const debugTask = preprocessDebugCheckpointTask(chunk);
150
+ if ("result" in debugTask || "error" in debugTask) {
151
+ options?.onTaskResult?.(debugTask);
152
+ }
153
+ data = debugTask;
154
+ }
143
155
  if (mode === "messages") {
144
156
  if (userStreamMode.includes("messages-tuple")) {
145
157
  if (kwargs.subgraphs && ns?.length) {
@@ -1,3 +1,3 @@
1
- import type { Checkpoint, RunnableConfig } from "../storage/ops.mjs";
1
+ import type { Checkpoint, RunnableConfig } from "../storage/types.mjs";
2
2
  export declare const runnableConfigToCheckpoint: (config: RunnableConfig | null | undefined) => Checkpoint | null;
3
3
  export declare const taskRunnableConfigToCheckpoint: (config: RunnableConfig | null | undefined) => Partial<Checkpoint> | null;
@@ -1,4 +1,4 @@
1
- import type { Run } from "./storage/ops.mjs";
1
+ import type { Run } from "./storage/types.mjs";
2
2
  import type { StreamCheckpoint } from "./stream.mjs";
3
3
  export declare function callWebhook(result: {
4
4
  checkpoint: StreamCheckpoint | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-api",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^18.19.0 || >=20.16.0"
@@ -15,10 +15,18 @@
15
15
  "types": "./dist/cli/spawn.d.mts",
16
16
  "default": "./dist/cli/spawn.mjs"
17
17
  },
18
+ "./server": {
19
+ "types": "./dist/server.d.mts",
20
+ "default": "./dist/server.mjs"
21
+ },
18
22
  "./auth": {
19
23
  "types": "./dist/auth/index.d.mts",
20
24
  "default": "./dist/auth/index.mjs"
21
25
  },
26
+ "./graph": {
27
+ "types": "./dist/graph/api.d.mts",
28
+ "default": "./dist/graph/api.mjs"
29
+ },
22
30
  "./semver": {
23
31
  "types": "./dist/semver/index.d.mts",
24
32
  "default": "./dist/semver/index.mjs"
@@ -27,6 +35,10 @@
27
35
  "types": "./dist/graph/parser/index.d.mts",
28
36
  "default": "./dist/graph/parser/index.mjs"
29
37
  },
38
+ "./storage": {
39
+ "types": "./dist/storage/types.d.mts",
40
+ "default": "./dist/storage/types.mjs"
41
+ },
30
42
  "./experimental/embed": {
31
43
  "types": "./dist/experimental/embed.d.mts",
32
44
  "default": "./dist/experimental/embed.mjs"
@@ -52,7 +64,7 @@
52
64
  "@babel/code-frame": "^7.26.2",
53
65
  "@hono/node-server": "^1.12.0",
54
66
  "@hono/zod-validator": "^0.2.2",
55
- "@langchain/langgraph-ui": "0.0.59",
67
+ "@langchain/langgraph-ui": "0.0.61",
56
68
  "@types/json-schema": "^7.0.15",
57
69
  "@typescript/vfs": "^1.6.0",
58
70
  "dedent": "^1.5.3",
@@ -84,9 +96,9 @@
84
96
  },
85
97
  "devDependencies": {
86
98
  "@langchain/core": "^0.3.59",
87
- "@langchain/langgraph": "0.4.5",
99
+ "@langchain/langgraph": "0.4.7",
88
100
  "@langchain/langgraph-checkpoint": "0.1.0",
89
- "@langchain/langgraph-sdk": "0.0.107",
101
+ "@langchain/langgraph-sdk": "0.0.111",
90
102
  "@types/babel__code-frame": "^7.0.6",
91
103
  "@types/node": "^18.15.11",
92
104
  "@types/react": "^19.0.8",