@langchain/langgraph-sdk 0.0.19 → 0.0.21

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,6 +595,7 @@ 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
601
  const response = await this.fetch(endpoint, {
@@ -641,13 +646,15 @@ class RunsClient extends BaseClient {
641
646
  * @param threadId The ID of the thread.
642
647
  * @param runId The ID of the run.
643
648
  * @param wait Whether to block when canceling
649
+ * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
644
650
  * @returns
645
651
  */
646
- async cancel(threadId, runId, wait = false) {
652
+ async cancel(threadId, runId, wait = false, action = "interrupt") {
647
653
  return this.fetch(`/threads/${threadId}/runs/${runId}/cancel`, {
648
654
  method: "POST",
649
655
  params: {
650
656
  wait: wait ? "1" : "0",
657
+ action: action,
651
658
  },
652
659
  });
653
660
  }
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, Cron, AssistantVersion, Subgraphs, Checkpoint, SearchItemsResponse, ListNamespaceResponse, Item } from "./schema.js";
1
+ import { Assistant, AssistantGraph, CancelAction, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, Cron, AssistantVersion, Subgraphs, Checkpoint, SearchItemsResponse, ListNamespaceResponse, Item } from "./schema.js";
2
2
  import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
3
3
  import { RunsCreatePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent, CronsCreatePayload, OnConflictBehavior } from "./types.js";
4
4
  interface ClientConfig {
@@ -327,9 +327,10 @@ export declare class RunsClient extends BaseClient {
327
327
  * @param threadId The ID of the thread.
328
328
  * @param runId The ID of the run.
329
329
  * @param wait Whether to block when canceling
330
+ * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
330
331
  * @returns
331
332
  */
332
- cancel(threadId: string, runId: string, wait?: boolean): Promise<void>;
333
+ cancel(threadId: string, runId: string, wait?: boolean, action?: CancelAction): Promise<void>;
333
334
  /**
334
335
  * Block until a run is done.
335
336
  *
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,6 +589,7 @@ 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
595
  const response = await this.fetch(endpoint, {
@@ -635,13 +640,15 @@ export class RunsClient extends BaseClient {
635
640
  * @param threadId The ID of the thread.
636
641
  * @param runId The ID of the run.
637
642
  * @param wait Whether to block when canceling
643
+ * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
638
644
  * @returns
639
645
  */
640
- async cancel(threadId, runId, wait = false) {
646
+ async cancel(threadId, runId, wait = false, action = "interrupt") {
641
647
  return this.fetch(`/threads/${threadId}/runs/${runId}/cancel`, {
642
648
  method: "POST",
643
649
  params: {
644
650
  wait: wait ? "1" : "0",
651
+ action: action,
645
652
  },
646
653
  });
647
654
  }
package/dist/schema.d.ts CHANGED
@@ -3,6 +3,7 @@ type Optional<T> = T | null | undefined;
3
3
  type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
4
4
  type ThreadStatus = "idle" | "busy" | "interrupted" | "error";
5
5
  type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";
6
+ export type CancelAction = "interrupt" | "rollback";
6
7
  export interface Config {
7
8
  /**
8
9
  * Tags for this call and any sub-calls (eg. a Chain calling an LLM).
@@ -56,7 +57,13 @@ export interface GraphSchema {
56
57
  config_schema?: JSONSchema7;
57
58
  }
58
59
  export type Subgraphs = Record<string, GraphSchema>;
59
- export type Metadata = Optional<Record<string, unknown>>;
60
+ export type Metadata = Optional<{
61
+ source?: "input" | "loop" | "update" | (string & {});
62
+ step?: number;
63
+ writes?: Record<string, unknown> | null;
64
+ parents?: Record<string, string>;
65
+ [key: string]: unknown;
66
+ }>;
60
67
  export interface AssistantBase {
61
68
  /** The ID of the assistant. */
62
69
  assistant_id: string;
@@ -79,7 +86,20 @@ export interface Assistant extends AssistantBase {
79
86
  /** The name of the assistant */
80
87
  name: string;
81
88
  }
82
- export type AssistantGraph = Record<string, Array<Record<string, unknown>>>;
89
+ export interface AssistantGraph {
90
+ nodes: Array<{
91
+ id: string | number;
92
+ name?: string;
93
+ data?: Record<string, any> | string;
94
+ metadata?: unknown;
95
+ }>;
96
+ edges: Array<{
97
+ source: string;
98
+ target: string;
99
+ data?: string;
100
+ conditional?: boolean;
101
+ }>;
102
+ }
83
103
  export interface Thread<ValuesType = DefaultValues> {
84
104
  /** The ID of the thread. */
85
105
  thread_id: string;
@@ -131,7 +151,10 @@ export interface ThreadTask {
131
151
  id: string;
132
152
  name: string;
133
153
  error: Optional<string>;
134
- interrupts: Array<Record<string, unknown>>;
154
+ interrupts: Array<{
155
+ value: unknown;
156
+ when: "during";
157
+ }>;
135
158
  checkpoint: Optional<Checkpoint>;
136
159
  state: Optional<ThreadState>;
137
160
  }
package/dist/types.d.ts CHANGED
@@ -29,11 +29,11 @@ interface RunsInvokePayload {
29
29
  /**
30
30
  * Interrupt execution before entering these nodes.
31
31
  */
32
- interruptBefore?: string[];
32
+ interruptBefore?: "*" | string[];
33
33
  /**
34
34
  * Interrupt execution after leaving these nodes.
35
35
  */
36
- interruptAfter?: string[];
36
+ interruptAfter?: "*" | string[];
37
37
  /**
38
38
  * Strategy to handle concurrent runs on the same thread. Only relevant if
39
39
  * there is a pending/inflight run on the same thread. One of:
@@ -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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",