@langchain/langgraph-sdk 0.0.18 → 0.0.20

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.cjs CHANGED
@@ -109,6 +109,7 @@ class CronsClient extends BaseClient {
109
109
  interrupt_after: payload?.interruptAfter,
110
110
  webhook: payload?.webhook,
111
111
  multitask_strategy: payload?.multitaskStrategy,
112
+ if_not_exists: payload?.ifNotExists,
112
113
  };
113
114
  return this.fetch(`/threads/${threadId}/runs/crons`, {
114
115
  method: "POST",
@@ -132,6 +133,7 @@ class CronsClient extends BaseClient {
132
133
  interrupt_after: payload?.interruptAfter,
133
134
  webhook: payload?.webhook,
134
135
  multitask_strategy: payload?.multitaskStrategy,
136
+ if_not_exists: payload?.ifNotExists,
135
137
  };
136
138
  return this.fetch(`/runs/crons`, {
137
139
  method: "POST",
@@ -482,6 +484,7 @@ class RunsClient extends BaseClient {
482
484
  on_completion: payload?.onCompletion,
483
485
  on_disconnect: payload?.onDisconnect,
484
486
  after_seconds: payload?.afterSeconds,
487
+ if_not_exists: payload?.ifNotExists,
485
488
  };
486
489
  const endpoint = threadId == null ? `/runs/stream` : `/threads/${threadId}/runs/stream`;
487
490
  const response = await this.asyncCaller.fetch(...this.prepareFetchOptions(endpoint, {
@@ -544,6 +547,7 @@ class RunsClient extends BaseClient {
544
547
  checkpoint_id: payload?.checkpointId,
545
548
  multitask_strategy: payload?.multitaskStrategy,
546
549
  after_seconds: payload?.afterSeconds,
550
+ if_not_exists: payload?.ifNotExists,
547
551
  };
548
552
  return this.fetch(`/threads/${threadId}/runs`, {
549
553
  method: "POST",
@@ -591,14 +595,25 @@ class RunsClient extends BaseClient {
591
595
  on_completion: payload?.onCompletion,
592
596
  on_disconnect: payload?.onDisconnect,
593
597
  after_seconds: payload?.afterSeconds,
598
+ if_not_exists: payload?.ifNotExists,
594
599
  };
595
600
  const endpoint = threadId == null ? `/runs/wait` : `/threads/${threadId}/runs/wait`;
596
- return this.fetch(endpoint, {
601
+ const response = await this.fetch(endpoint, {
597
602
  method: "POST",
598
603
  json,
599
604
  timeoutMs: null,
600
605
  signal: payload?.signal,
601
606
  });
607
+ const raiseError = payload?.raiseError !== undefined ? payload.raiseError : true;
608
+ if (raiseError &&
609
+ "__error__" in response &&
610
+ typeof response.__error__ === "object" &&
611
+ response.__error__ &&
612
+ "error" in response.__error__ &&
613
+ "message" in response.__error__) {
614
+ throw new Error(`${response.__error__?.error}: ${response.__error__?.message}`);
615
+ }
616
+ return response;
602
617
  }
603
618
  /**
604
619
  * List all runs for a thread.
package/dist/client.js CHANGED
@@ -106,6 +106,7 @@ export class CronsClient extends BaseClient {
106
106
  interrupt_after: payload?.interruptAfter,
107
107
  webhook: payload?.webhook,
108
108
  multitask_strategy: payload?.multitaskStrategy,
109
+ if_not_exists: payload?.ifNotExists,
109
110
  };
110
111
  return this.fetch(`/threads/${threadId}/runs/crons`, {
111
112
  method: "POST",
@@ -129,6 +130,7 @@ export class CronsClient extends BaseClient {
129
130
  interrupt_after: payload?.interruptAfter,
130
131
  webhook: payload?.webhook,
131
132
  multitask_strategy: payload?.multitaskStrategy,
133
+ if_not_exists: payload?.ifNotExists,
132
134
  };
133
135
  return this.fetch(`/runs/crons`, {
134
136
  method: "POST",
@@ -476,6 +478,7 @@ export class RunsClient extends BaseClient {
476
478
  on_completion: payload?.onCompletion,
477
479
  on_disconnect: payload?.onDisconnect,
478
480
  after_seconds: payload?.afterSeconds,
481
+ if_not_exists: payload?.ifNotExists,
479
482
  };
480
483
  const endpoint = threadId == null ? `/runs/stream` : `/threads/${threadId}/runs/stream`;
481
484
  const response = await this.asyncCaller.fetch(...this.prepareFetchOptions(endpoint, {
@@ -538,6 +541,7 @@ export class RunsClient extends BaseClient {
538
541
  checkpoint_id: payload?.checkpointId,
539
542
  multitask_strategy: payload?.multitaskStrategy,
540
543
  after_seconds: payload?.afterSeconds,
544
+ if_not_exists: payload?.ifNotExists,
541
545
  };
542
546
  return this.fetch(`/threads/${threadId}/runs`, {
543
547
  method: "POST",
@@ -585,14 +589,25 @@ export class RunsClient extends BaseClient {
585
589
  on_completion: payload?.onCompletion,
586
590
  on_disconnect: payload?.onDisconnect,
587
591
  after_seconds: payload?.afterSeconds,
592
+ if_not_exists: payload?.ifNotExists,
588
593
  };
589
594
  const endpoint = threadId == null ? `/runs/wait` : `/threads/${threadId}/runs/wait`;
590
- return this.fetch(endpoint, {
595
+ const response = await this.fetch(endpoint, {
591
596
  method: "POST",
592
597
  json,
593
598
  timeoutMs: null,
594
599
  signal: payload?.signal,
595
600
  });
601
+ const raiseError = payload?.raiseError !== undefined ? payload.raiseError : true;
602
+ if (raiseError &&
603
+ "__error__" in response &&
604
+ typeof response.__error__ === "object" &&
605
+ response.__error__ &&
606
+ "error" in response.__error__ &&
607
+ "message" in response.__error__) {
608
+ throw new Error(`${response.__error__?.error}: ${response.__error__?.message}`);
609
+ }
610
+ return response;
596
611
  }
597
612
  /**
598
613
  * List all runs for a thread.
package/dist/types.d.ts CHANGED
@@ -72,6 +72,10 @@ interface RunsInvokePayload {
72
72
  * Use to schedule future runs.
73
73
  */
74
74
  afterSeconds?: number;
75
+ /**
76
+ * Behavior if the specified run doesn't exist. Defaults to "reject".
77
+ */
78
+ ifNotExists?: "create" | "reject";
75
79
  }
76
80
  export interface RunsStreamPayload extends RunsInvokePayload {
77
81
  /**
@@ -102,5 +106,10 @@ export interface CronsCreatePayload extends RunsCreatePayload {
102
106
  */
103
107
  schedule: string;
104
108
  }
105
- export type RunsWaitPayload = RunsStreamPayload;
109
+ export interface RunsWaitPayload extends RunsStreamPayload {
110
+ /**
111
+ * Raise errors returned by the run. Default is `true`.
112
+ */
113
+ raiseError?: boolean;
114
+ }
106
115
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",