@langchain/langgraph-sdk 0.0.1-rc.1 → 0.0.1-rc.10

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 CHANGED
@@ -1,15 +1,17 @@
1
- import { Assistant, AssistantGraph, Config, GraphSchema, Metadata, Run, RunEvent, Thread, ThreadState } from "./schema.js";
1
+ import { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, RunEvent, Thread, ThreadState } from "./schema.js";
2
2
  import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.mjs";
3
3
  import { RunsCreatePayload, RunsStreamPayload, RunsWaitPayload } from "./types.mjs";
4
4
  interface ClientConfig {
5
5
  apiUrl?: string;
6
6
  callerOptions?: AsyncCallerParams;
7
7
  timeoutMs?: number;
8
+ defaultHeaders?: Record<string, string | null | undefined>;
8
9
  }
9
10
  declare class BaseClient {
10
11
  protected asyncCaller: AsyncCaller;
11
12
  protected timeoutMs: number;
12
13
  protected apiUrl: string;
14
+ protected defaultHeaders: Record<string, string | null | undefined>;
13
15
  constructor(config?: ClientConfig);
14
16
  protected prepareFetchOptions(path: string, options?: RequestInit & {
15
17
  json?: unknown;
@@ -21,19 +23,51 @@ declare class BaseClient {
21
23
  }): Promise<T>;
22
24
  }
23
25
  declare class AssistantsClient extends BaseClient {
26
+ /**
27
+ * Get an assistant by ID.
28
+ *
29
+ * @param assistantId The ID of the assistant.
30
+ * @returns Assistant
31
+ */
24
32
  get(assistantId: string): Promise<Assistant>;
33
+ /**
34
+ * Get the JSON representation of the graph assigned to a runnable
35
+ * @param assistantId The ID of the assistant.
36
+ * @returns Serialized graph
37
+ */
25
38
  getGraph(assistantId: string): Promise<AssistantGraph>;
39
+ /**
40
+ * Get the state and config schema of the graph assigned to a runnable
41
+ * @param assistantId The ID of the assistant.
42
+ * @returns Graph schema
43
+ */
26
44
  getSchemas(assistantId: string): Promise<GraphSchema>;
45
+ /**
46
+ * Create a new assistant.
47
+ * @param payload Payload for creating an assistant.
48
+ * @returns The created assistant.
49
+ */
27
50
  create(payload: {
28
51
  graphId: string;
29
52
  config?: Config;
30
53
  metadata?: Metadata;
31
54
  }): Promise<Assistant>;
32
- upsert(assistantId: string, payload: {
55
+ /**
56
+ * Update an assistant.
57
+ * @param assistantId ID of the assistant.
58
+ * @param payload Payload for updating the assistant.
59
+ * @returns The updated assistant.
60
+ */
61
+ update(assistantId: string, payload: {
33
62
  graphId: string;
34
63
  config?: Config;
35
64
  metadata?: Metadata;
36
65
  }): Promise<Assistant>;
66
+ /**
67
+ * List assistants.
68
+ * @param query Query options.
69
+ * @returns List of assistants.
70
+ */
37
71
  search(query?: {
38
72
  metadata?: Metadata;
39
73
  limit?: number;
@@ -54,7 +88,7 @@ declare class ThreadsClient extends BaseClient {
54
88
  * @param payload Payload for creating a thread.
55
89
  * @returns The created thread.
56
90
  */
57
- create(payload: {
91
+ create(payload?: {
58
92
  /**
59
93
  * Metadata for the thread.
60
94
  */
@@ -67,7 +101,7 @@ declare class ThreadsClient extends BaseClient {
67
101
  * @param payload Payload for updating the thread.
68
102
  * @returns The updated thread.
69
103
  */
70
- upsert(threadId: string, payload?: {
104
+ update(threadId: string, payload?: {
71
105
  /**
72
106
  * Metadata for the thread.
73
107
  */
@@ -106,20 +140,20 @@ declare class ThreadsClient extends BaseClient {
106
140
  * @param threadId ID of the thread.
107
141
  * @returns Thread state.
108
142
  */
109
- getState(threadId: string): Promise<ThreadState>;
143
+ getState<ValuesType = DefaultValues>(threadId: string, checkpointId?: string): Promise<ThreadState<ValuesType>>;
110
144
  /**
111
145
  * Add state to a thread.
112
146
  *
113
- * @param threadIdOrConfig Thread ID or config that identifies the state to start from.
114
- * @param values The state update
115
- * @param options Additional options.
147
+ * @param threadId The ID of the thread.
116
148
  * @returns
117
149
  */
118
- updateState(threadIdOrConfig: string | Config, values: Record<string, unknown>, options?: {
150
+ updateState<ValuesType = DefaultValues>(threadId: string, options: {
151
+ values: ValuesType;
152
+ checkpointId?: string;
119
153
  asNode?: string;
120
154
  }): Promise<void>;
121
155
  /**
122
- * Patch the state of a thread.
156
+ * Patch the metadata of a thread.
123
157
  *
124
158
  * @param threadIdOrConfig Thread ID or config to patch the state of.
125
159
  * @param metadata Metadata to patch the state with.
@@ -132,10 +166,11 @@ declare class ThreadsClient extends BaseClient {
132
166
  * @param options Additional options.
133
167
  * @returns List of thread states.
134
168
  */
135
- getHistory(threadId: string, options?: {
169
+ getHistory<ValuesType = DefaultValues>(threadId: string, options?: {
136
170
  limit?: number;
137
171
  before?: Config;
138
- }): Promise<ThreadState[]>;
172
+ metadata?: Metadata;
173
+ }): Promise<ThreadState<ValuesType>[]>;
139
174
  }
140
175
  declare class RunsClient extends BaseClient {
141
176
  /**
@@ -146,8 +181,8 @@ declare class RunsClient extends BaseClient {
146
181
  * @param payload Payload for creating a run.
147
182
  */
148
183
  stream(threadId: string, assistantId: string, payload?: RunsStreamPayload): AsyncGenerator<{
149
- event: string;
150
- data: unknown;
184
+ event: "events" | "metadata" | "debug" | "updates" | "values" | "messages/partial" | "messages/metadata" | "messages/complete" | (string & {});
185
+ data: any;
151
186
  }>;
152
187
  /**
153
188
  * Create a run.
@@ -216,8 +251,17 @@ declare class RunsClient extends BaseClient {
216
251
  }): Promise<RunEvent[]>;
217
252
  }
218
253
  export declare class Client {
254
+ /**
255
+ * The client for interacting with assistants.
256
+ */
219
257
  assistants: AssistantsClient;
258
+ /**
259
+ * The client for interacting with threads.
260
+ */
220
261
  threads: ThreadsClient;
262
+ /**
263
+ * The client for interacting with runs.
264
+ */
221
265
  runs: RunsClient;
222
266
  constructor(config?: ClientConfig);
223
267
  }
package/dist/client.mjs CHANGED
@@ -21,16 +21,26 @@ class BaseClient {
21
21
  writable: true,
22
22
  value: void 0
23
23
  });
24
+ Object.defineProperty(this, "defaultHeaders", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ });
24
30
  this.asyncCaller = new AsyncCaller({
25
- maxRetries: 5,
26
- maxConcurrency: 5,
31
+ maxRetries: 4,
32
+ maxConcurrency: 4,
27
33
  ...config?.callerOptions,
28
34
  });
29
35
  this.timeoutMs = config?.timeoutMs || 12_000;
30
36
  this.apiUrl = config?.apiUrl || "http://localhost:8123";
37
+ this.defaultHeaders = config?.defaultHeaders || {};
31
38
  }
32
39
  prepareFetchOptions(path, options) {
33
- const mutatedOptions = { ...options };
40
+ const mutatedOptions = {
41
+ ...options,
42
+ headers: { ...this.defaultHeaders, ...options?.headers },
43
+ };
34
44
  if (mutatedOptions.json) {
35
45
  mutatedOptions.body = JSON.stringify(mutatedOptions.json);
36
46
  mutatedOptions.headers = {
@@ -59,15 +69,36 @@ class BaseClient {
59
69
  }
60
70
  }
61
71
  class AssistantsClient extends BaseClient {
72
+ /**
73
+ * Get an assistant by ID.
74
+ *
75
+ * @param assistantId The ID of the assistant.
76
+ * @returns Assistant
77
+ */
62
78
  async get(assistantId) {
63
79
  return this.fetch(`/assistants/${assistantId}`);
64
80
  }
81
+ /**
82
+ * Get the JSON representation of the graph assigned to a runnable
83
+ * @param assistantId The ID of the assistant.
84
+ * @returns Serialized graph
85
+ */
65
86
  async getGraph(assistantId) {
66
87
  return this.fetch(`/assistants/${assistantId}/graph`);
67
88
  }
89
+ /**
90
+ * Get the state and config schema of the graph assigned to a runnable
91
+ * @param assistantId The ID of the assistant.
92
+ * @returns Graph schema
93
+ */
68
94
  async getSchemas(assistantId) {
69
95
  return this.fetch(`/assistants/${assistantId}/schemas`);
70
96
  }
97
+ /**
98
+ * Create a new assistant.
99
+ * @param payload Payload for creating an assistant.
100
+ * @returns The created assistant.
101
+ */
71
102
  async create(payload) {
72
103
  return this.fetch("/assistants", {
73
104
  method: "POST",
@@ -78,9 +109,15 @@ class AssistantsClient extends BaseClient {
78
109
  },
79
110
  });
80
111
  }
81
- async upsert(assistantId, payload) {
112
+ /**
113
+ * Update an assistant.
114
+ * @param assistantId ID of the assistant.
115
+ * @param payload Payload for updating the assistant.
116
+ * @returns The updated assistant.
117
+ */
118
+ async update(assistantId, payload) {
82
119
  return this.fetch(`/assistants/${assistantId}`, {
83
- method: "PUT",
120
+ method: "PATCH",
84
121
  json: {
85
122
  graph_id: payload.graphId,
86
123
  config: payload.config,
@@ -88,6 +125,11 @@ class AssistantsClient extends BaseClient {
88
125
  },
89
126
  });
90
127
  }
128
+ /**
129
+ * List assistants.
130
+ * @param query Query options.
131
+ * @returns List of assistants.
132
+ */
91
133
  async search(query) {
92
134
  return this.fetch("/assistants/search", {
93
135
  method: "POST",
@@ -118,7 +160,7 @@ class ThreadsClient extends BaseClient {
118
160
  async create(payload) {
119
161
  return this.fetch(`/threads`, {
120
162
  method: "POST",
121
- json: { metadata: payload },
163
+ json: { metadata: payload?.metadata },
122
164
  });
123
165
  }
124
166
  /**
@@ -128,10 +170,10 @@ class ThreadsClient extends BaseClient {
128
170
  * @param payload Payload for updating the thread.
129
171
  * @returns The updated thread.
130
172
  */
131
- async upsert(threadId, payload) {
173
+ async update(threadId, payload) {
132
174
  return this.fetch(`/threads/${threadId}`, {
133
- method: "PUT",
134
- json: { metadata: payload },
175
+ method: "PATCH",
176
+ json: { metadata: payload?.metadata },
135
177
  });
136
178
  }
137
179
  /**
@@ -166,38 +208,29 @@ class ThreadsClient extends BaseClient {
166
208
  * @param threadId ID of the thread.
167
209
  * @returns Thread state.
168
210
  */
169
- async getState(threadId) {
170
- return this.fetch(`/threads/${threadId}/state`);
211
+ async getState(threadId, checkpointId) {
212
+ return this.fetch(checkpointId != null
213
+ ? `/threads/${threadId}/state/${checkpointId}`
214
+ : `/threads/${threadId}/state`);
171
215
  }
172
216
  /**
173
217
  * Add state to a thread.
174
218
  *
175
- * @param threadIdOrConfig Thread ID or config that identifies the state to start from.
176
- * @param values The state update
177
- * @param options Additional options.
219
+ * @param threadId The ID of the thread.
178
220
  * @returns
179
221
  */
180
- async updateState(threadIdOrConfig, values, options) {
181
- let config = undefined;
182
- let threadId;
183
- if (typeof threadIdOrConfig !== "string") {
184
- config = threadIdOrConfig;
185
- if (typeof config.configurable?.thread_id !== "string") {
186
- throw new Error("Thread ID is required when updating state with a config.");
187
- }
188
- threadId = config.configurable.thread_id;
189
- }
190
- else {
191
- config = undefined;
192
- threadId = threadIdOrConfig;
193
- }
222
+ async updateState(threadId, options) {
194
223
  return this.fetch(`/threads/${threadId}/state`, {
195
224
  method: "POST",
196
- json: { values, config, as_node: options?.asNode },
225
+ json: {
226
+ values: options.values,
227
+ checkpoint_id: options.checkpointId,
228
+ as_node: options?.asNode,
229
+ },
197
230
  });
198
231
  }
199
232
  /**
200
- * Patch the state of a thread.
233
+ * Patch the metadata of a thread.
201
234
  *
202
235
  * @param threadIdOrConfig Thread ID or config to patch the state of.
203
236
  * @param metadata Metadata to patch the state with.
@@ -227,9 +260,11 @@ class ThreadsClient extends BaseClient {
227
260
  */
228
261
  async getHistory(threadId, options) {
229
262
  return this.fetch(`/threads/${threadId}/history`, {
230
- params: {
263
+ method: "POST",
264
+ json: {
231
265
  limit: options?.limit ?? 10,
232
266
  before: options?.before,
267
+ metadata: options?.metadata,
233
268
  },
234
269
  });
235
270
  }
@@ -250,17 +285,20 @@ class RunsClient extends BaseClient {
250
285
  config: payload?.config,
251
286
  metadata: payload?.metadata,
252
287
  stream_mode: payload?.streamMode,
288
+ feedback_keys: payload?.feedbackKeys,
253
289
  assistant_id: assistantId,
254
290
  interrupt_before: payload?.interruptBefore,
255
291
  interrupt_after: payload?.interruptAfter,
256
292
  },
293
+ signal: payload?.signal,
257
294
  }));
258
295
  let parser;
259
296
  const textDecoder = new TextDecoder();
260
297
  const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
261
298
  async start(ctrl) {
262
299
  parser = createParser((event) => {
263
- if (event.type === "event" && event.data === "[DONE]") {
300
+ if ((payload?.signal && payload.signal.aborted) ||
301
+ (event.type === "event" && event.data === "[DONE]")) {
264
302
  ctrl.terminate();
265
303
  return;
266
304
  }
@@ -298,6 +336,7 @@ class RunsClient extends BaseClient {
298
336
  interrupt_after: payload?.interruptAfter,
299
337
  webhook: payload?.webhook,
300
338
  },
339
+ signal: payload?.signal,
301
340
  });
302
341
  }
303
342
  /**
@@ -319,6 +358,7 @@ class RunsClient extends BaseClient {
319
358
  interrupt_before: payload?.interruptBefore,
320
359
  interrupt_after: payload?.interruptAfter,
321
360
  },
361
+ signal: payload?.signal,
322
362
  });
323
363
  }
324
364
  /**
@@ -365,18 +405,27 @@ class RunsClient extends BaseClient {
365
405
  }
366
406
  export class Client {
367
407
  constructor(config) {
408
+ /**
409
+ * The client for interacting with assistants.
410
+ */
368
411
  Object.defineProperty(this, "assistants", {
369
412
  enumerable: true,
370
413
  configurable: true,
371
414
  writable: true,
372
415
  value: void 0
373
416
  });
417
+ /**
418
+ * The client for interacting with threads.
419
+ */
374
420
  Object.defineProperty(this, "threads", {
375
421
  enumerable: true,
376
422
  configurable: true,
377
423
  writable: true,
378
424
  value: void 0
379
425
  });
426
+ /**
427
+ * The client for interacting with runs.
428
+ */
380
429
  Object.defineProperty(this, "runs", {
381
430
  enumerable: true,
382
431
  configurable: true,
package/dist/index.d.mts CHANGED
@@ -1 +1,2 @@
1
1
  export { Client } from "./client.mjs";
2
+ export type { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, RunEvent, Thread, ThreadState, } from "./schema.js";
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,14 +15,30 @@ 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
  }
21
29
  export interface GraphSchema {
30
+ /**
31
+ * The ID of the graph.
32
+ */
22
33
  graph_id: string;
23
- state_schema: Record<string, unknown>;
24
- config_schema: Record<string, unknown>;
34
+ /**
35
+ * The schema for the graph state
36
+ */
37
+ state_schema: JSONSchema7;
38
+ /**
39
+ * The schema for the graph config
40
+ */
41
+ config_schema: JSONSchema7;
25
42
  }
26
43
  export type Metadata = Optional<Record<string, unknown>>;
27
44
  export interface Assistant {
@@ -39,13 +56,14 @@ export interface Thread {
39
56
  updated_at: string;
40
57
  metadata: Metadata;
41
58
  }
42
- export interface ThreadState {
43
- values: Record<string, unknown>[] | Record<string, unknown>;
59
+ export type DefaultValues = Record<string, unknown>[] | Record<string, unknown>;
60
+ export interface ThreadState<ValuesType = DefaultValues> {
61
+ values: ValuesType;
44
62
  next: string[];
45
- config: Config;
63
+ checkpoint_id: string;
46
64
  metadata: Metadata;
47
65
  created_at: Optional<string>;
48
- parent_config: Optional<Config>;
66
+ parent_checkpoint_id: Optional<string>;
49
67
  }
50
68
  export interface Run {
51
69
  run_id: string;
package/dist/types.d.mts CHANGED
@@ -21,6 +21,10 @@ interface RunsInvokePayload {
21
21
  * Interrupt execution after leaving these nodes.
22
22
  */
23
23
  interruptAfter?: string[];
24
+ /**
25
+ * Abort controller signal to cancel the run.
26
+ */
27
+ signal?: AbortController["signal"];
24
28
  }
25
29
  export interface RunsStreamPayload extends RunsInvokePayload {
26
30
  /**
@@ -33,6 +37,11 @@ export interface RunsStreamPayload extends RunsInvokePayload {
33
37
  * afterwards using the `client.runs.listEvents()` method.
34
38
  */
35
39
  streamMode?: StreamMode | Array<StreamMode>;
40
+ /**
41
+ * Pass one or more feedbackKeys if you want to request short-lived signed URLs
42
+ * for submitting feedback to LangSmith with this key for this run.
43
+ */
44
+ feedbackKeys?: string[];
36
45
  }
37
46
  export interface RunsCreatePayload extends RunsInvokePayload {
38
47
  /**
@@ -24,8 +24,8 @@ export interface AsyncCallerCallOptions {
24
24
  * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults
25
25
  * to `Infinity`. This means that by default, all calls will be made in parallel.
26
26
  *
27
- * Retries are limited by the `maxRetries` parameter, which defaults to 6. This
28
- * means that by default, each call will be retried up to 6 times, with an
27
+ * Retries are limited by the `maxRetries` parameter, which defaults to 5. This
28
+ * means that by default, each call will be retried up to 5 times, with an
29
29
  * exponential backoff between each attempt.
30
30
  */
31
31
  export declare class AsyncCaller {
@@ -9,10 +9,57 @@ const STATUS_NO_RETRY = [
9
9
  406, // Not Acceptable
10
10
  407, // Proxy Authentication Required
11
11
  408, // Request Timeout
12
+ 422, // Unprocessable Entity
12
13
  ];
13
14
  const STATUS_IGNORE = [
14
15
  409, // Conflict
15
16
  ];
17
+ /**
18
+ * Do not rely on globalThis.Response, rather just
19
+ * do duck typing
20
+ */
21
+ function isResponse(x) {
22
+ if (x == null || typeof x !== "object")
23
+ return false;
24
+ return "status" in x && "statusText" in x && "text" in x;
25
+ }
26
+ /**
27
+ * Utility error to properly handle failed requests
28
+ */
29
+ class HTTPError extends Error {
30
+ constructor(status, message, response) {
31
+ super(`HTTP ${status}: ${message}`);
32
+ Object.defineProperty(this, "status", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: void 0
37
+ });
38
+ Object.defineProperty(this, "text", {
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true,
42
+ value: void 0
43
+ });
44
+ Object.defineProperty(this, "response", {
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true,
48
+ value: void 0
49
+ });
50
+ this.status = status;
51
+ this.text = message;
52
+ this.response = response;
53
+ }
54
+ static async fromResponse(response, options) {
55
+ try {
56
+ return new HTTPError(response.status, await response.text(), options?.includeResponse ? response : undefined);
57
+ }
58
+ catch {
59
+ return new HTTPError(response.status, response.statusText, options?.includeResponse ? response : undefined);
60
+ }
61
+ }
62
+ }
16
63
  /**
17
64
  * A class that can be used to make async calls with concurrency and retry logic.
18
65
  *
@@ -22,8 +69,8 @@ const STATUS_IGNORE = [
22
69
  * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults
23
70
  * to `Infinity`. This means that by default, all calls will be made in parallel.
24
71
  *
25
- * Retries are limited by the `maxRetries` parameter, which defaults to 6. This
26
- * means that by default, each call will be retried up to 6 times, with an
72
+ * Retries are limited by the `maxRetries` parameter, which defaults to 5. This
73
+ * means that by default, each call will be retried up to 5 times, with an
27
74
  * exponential backoff between each attempt.
28
75
  */
29
76
  export class AsyncCaller {
@@ -53,7 +100,7 @@ export class AsyncCaller {
53
100
  value: void 0
54
101
  });
55
102
  this.maxConcurrency = params.maxConcurrency ?? Infinity;
56
- this.maxRetries = params.maxRetries ?? 6;
103
+ this.maxRetries = params.maxRetries ?? 4;
57
104
  if ("default" in PQueueMod) {
58
105
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
106
  this.queue = new PQueueMod.default({
@@ -69,15 +116,15 @@ export class AsyncCaller {
69
116
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
117
  call(callable, ...args) {
71
118
  const onFailedResponseHook = this.onFailedResponseHook;
72
- return this.queue.add(() => pRetry(() => callable(...args).catch((error) => {
119
+ return this.queue.add(() => pRetry(() => callable(...args).catch(async (error) => {
73
120
  // eslint-disable-next-line no-instanceof/no-instanceof
74
- console.error;
75
121
  if (error instanceof Error) {
76
122
  throw error;
77
123
  }
78
- else if (error instanceof Response) {
79
- // TODO: try to parse the response body and throw a more informative error
80
- throw new Error(`HTTP ${error.status}: ${error.statusText}`);
124
+ else if (isResponse(error)) {
125
+ throw await HTTPError.fromResponse(error, {
126
+ includeResponse: !!onFailedResponseHook,
127
+ });
81
128
  }
82
129
  else {
83
130
  throw new Error(error);
@@ -93,18 +140,15 @@ export class AsyncCaller {
93
140
  if (error?.code === "ECONNABORTED") {
94
141
  throw error;
95
142
  }
96
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
- const response = error?.response;
98
- const status = response?.status;
99
- if (status) {
100
- if (STATUS_NO_RETRY.includes(+status)) {
143
+ if (error instanceof HTTPError) {
144
+ if (STATUS_NO_RETRY.includes(error.status)) {
101
145
  throw error;
102
146
  }
103
- else if (STATUS_IGNORE.includes(+status)) {
147
+ else if (STATUS_IGNORE.includes(error.status)) {
104
148
  return;
105
149
  }
106
- if (onFailedResponseHook) {
107
- await onFailedResponseHook(response);
150
+ if (onFailedResponseHook && error.response) {
151
+ await onFailedResponseHook(error.response);
108
152
  }
109
153
  }
110
154
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.1-rc.1",
3
+ "version": "0.0.1-rc.10",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",
@@ -9,11 +9,14 @@
9
9
  "build": "yarn clean && yarn build:esm && yarn build:cjs && node scripts/create-entrypoints.js",
10
10
  "build:esm": "rm -f src/package.json && tsc --outDir dist/ && rm -rf dist/tests dist/**/tests",
11
11
  "build:cjs": "echo '{}' > src/package.json && tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rm -r dist-cjs src/package.json",
12
- "prepublish": "yarn run build"
12
+ "prepublish": "yarn run build",
13
+ "format": "prettier --write src",
14
+ "lint": "prettier --check src && tsc --noEmit"
13
15
  },
14
16
  "main": "index.js",
15
17
  "license": "MIT",
16
18
  "dependencies": {
19
+ "@types/json-schema": "^7.0.15",
17
20
  "eventsource-parser": "^1.1.2",
18
21
  "p-queue": "^6.6.2",
19
22
  "p-retry": "4",
@@ -23,6 +26,7 @@
23
26
  "@tsconfig/recommended": "^1.0.2",
24
27
  "@types/node": "^20.12.12",
25
28
  "@types/uuid": "^9.0.1",
29
+ "prettier": "^3.2.5",
26
30
  "typescript": "^5.4.5"
27
31
  },
28
32
  "exports": {