@langchain/langgraph-sdk 0.0.20 → 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
@@ -646,13 +646,15 @@ class RunsClient extends BaseClient {
646
646
  * @param threadId The ID of the thread.
647
647
  * @param runId The ID of the run.
648
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`.
649
650
  * @returns
650
651
  */
651
- async cancel(threadId, runId, wait = false) {
652
+ async cancel(threadId, runId, wait = false, action = "interrupt") {
652
653
  return this.fetch(`/threads/${threadId}/runs/${runId}/cancel`, {
653
654
  method: "POST",
654
655
  params: {
655
656
  wait: wait ? "1" : "0",
657
+ action: action,
656
658
  },
657
659
  });
658
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
@@ -640,13 +640,15 @@ export class RunsClient extends BaseClient {
640
640
  * @param threadId The ID of the thread.
641
641
  * @param runId The ID of the run.
642
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`.
643
644
  * @returns
644
645
  */
645
- async cancel(threadId, runId, wait = false) {
646
+ async cancel(threadId, runId, wait = false, action = "interrupt") {
646
647
  return this.fetch(`/threads/${threadId}/runs/${runId}/cancel`, {
647
648
  method: "POST",
648
649
  params: {
649
650
  wait: wait ? "1" : "0",
651
+ action: action,
650
652
  },
651
653
  });
652
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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.20",
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",