@langchain/langgraph-sdk 0.0.20 → 0.0.22

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
@@ -375,6 +375,7 @@ class ThreadsClient extends BaseClient {
375
375
  metadata: query?.metadata ?? undefined,
376
376
  limit: query?.limit ?? 10,
377
377
  offset: query?.offset ?? 0,
378
+ status: query?.status,
378
379
  },
379
380
  });
380
381
  }
@@ -646,13 +647,15 @@ class RunsClient extends BaseClient {
646
647
  * @param threadId The ID of the thread.
647
648
  * @param runId The ID of the run.
648
649
  * @param wait Whether to block when canceling
650
+ * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
649
651
  * @returns
650
652
  */
651
- async cancel(threadId, runId, wait = false) {
653
+ async cancel(threadId, runId, wait = false, action = "interrupt") {
652
654
  return this.fetch(`/threads/${threadId}/runs/${runId}/cancel`, {
653
655
  method: "POST",
654
656
  params: {
655
657
  wait: wait ? "1" : "0",
658
+ action: action,
656
659
  },
657
660
  });
658
661
  }
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, ThreadStatus } 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 {
@@ -222,6 +222,11 @@ export declare class ThreadsClient extends BaseClient {
222
222
  * Offset to start from.
223
223
  */
224
224
  offset?: number;
225
+ /**
226
+ * Thread status to filter on.
227
+ * Must be one of 'idle', 'busy', 'interrupted' or 'error'.
228
+ */
229
+ status?: ThreadStatus;
225
230
  }): Promise<Thread[]>;
226
231
  /**
227
232
  * Get state for a thread.
@@ -327,9 +332,10 @@ export declare class RunsClient extends BaseClient {
327
332
  * @param threadId The ID of the thread.
328
333
  * @param runId The ID of the run.
329
334
  * @param wait Whether to block when canceling
335
+ * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
330
336
  * @returns
331
337
  */
332
- cancel(threadId: string, runId: string, wait?: boolean): Promise<void>;
338
+ cancel(threadId: string, runId: string, wait?: boolean, action?: CancelAction): Promise<void>;
333
339
  /**
334
340
  * Block until a run is done.
335
341
  *
package/dist/client.js CHANGED
@@ -370,6 +370,7 @@ export class ThreadsClient extends BaseClient {
370
370
  metadata: query?.metadata ?? undefined,
371
371
  limit: query?.limit ?? 10,
372
372
  offset: query?.offset ?? 0,
373
+ status: query?.status,
373
374
  },
374
375
  });
375
376
  }
@@ -640,13 +641,15 @@ export class RunsClient extends BaseClient {
640
641
  * @param threadId The ID of the thread.
641
642
  * @param runId The ID of the run.
642
643
  * @param wait Whether to block when canceling
644
+ * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
643
645
  * @returns
644
646
  */
645
- async cancel(threadId, runId, wait = false) {
647
+ async cancel(threadId, runId, wait = false, action = "interrupt") {
646
648
  return this.fetch(`/threads/${threadId}/runs/${runId}/cancel`, {
647
649
  method: "POST",
648
650
  params: {
649
651
  wait: wait ? "1" : "0",
652
+ action: action,
650
653
  },
651
654
  });
652
655
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Client } from "./client.js";
2
- export type { Assistant, AssistantVersion, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, Cron, Checkpoint, } from "./schema.js";
2
+ export type { Assistant, AssistantVersion, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, ThreadStatus, Cron, Checkpoint, } from "./schema.js";
3
3
  export type { OnConflictBehavior } from "./types.js";
package/dist/schema.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { JSONSchema7 } from "json-schema";
2
2
  type Optional<T> = T | null | undefined;
3
3
  type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
4
- type ThreadStatus = "idle" | "busy" | "interrupted" | "error";
4
+ export 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.22",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",