@langchain/langgraph-sdk 0.0.28 → 0.0.30

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
@@ -660,6 +660,7 @@ class RunsClient extends BaseClient {
660
660
  params: {
661
661
  limit: options?.limit ?? 10,
662
662
  offset: options?.offset ?? 0,
663
+ status: options?.status ?? undefined,
663
664
  },
664
665
  });
665
666
  }
@@ -711,14 +712,19 @@ class RunsClient extends BaseClient {
711
712
  *
712
713
  * @param threadId The ID of the thread.
713
714
  * @param runId The ID of the run.
714
- * @param signal An optional abort signal.
715
715
  * @returns An async generator yielding stream parts.
716
716
  */
717
- async *joinStream(threadId, runId, signal) {
717
+ async *joinStream(threadId, runId, options) {
718
+ const opts = typeof options === "object" &&
719
+ options != null &&
720
+ options instanceof AbortSignal
721
+ ? { signal: options }
722
+ : options;
718
723
  const response = await this.asyncCaller.fetch(...this.prepareFetchOptions(`/threads/${threadId}/runs/${runId}/stream`, {
719
724
  method: "GET",
720
725
  timeoutMs: null,
721
- signal,
726
+ signal: opts?.signal,
727
+ params: { cancel_on_disconnect: opts?.cancelOnDisconnect ? "1" : "0" },
722
728
  }));
723
729
  let parser;
724
730
  let onEndEvent;
@@ -726,7 +732,7 @@ class RunsClient extends BaseClient {
726
732
  const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
727
733
  async start(ctrl) {
728
734
  parser = (0, index_js_1.createParser)((event) => {
729
- if ((signal && signal.aborted) ||
735
+ if ((opts?.signal && opts.signal.aborted) ||
730
736
  (event.type === "event" && event.data === "[DONE]")) {
731
737
  ctrl.terminate();
732
738
  return;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Assistant, AssistantGraph, CancelAction, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, Cron, AssistantVersion, Subgraphs, Checkpoint, SearchItemsResponse, ListNamespaceResponse, Item, ThreadStatus } from "./schema.js";
1
+ import { Assistant, AssistantGraph, CancelAction, Config, DefaultValues, GraphSchema, Metadata, Run, RunStatus, 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
  /**
@@ -329,6 +329,10 @@ export declare class RunsClient extends BaseClient {
329
329
  * Defaults to 0.
330
330
  */
331
331
  offset?: number;
332
+ /**
333
+ * Status of the run to filter by.
334
+ */
335
+ status?: RunStatus;
332
336
  }): Promise<Run[]>;
333
337
  /**
334
338
  * Get a run by ID.
@@ -365,10 +369,12 @@ export declare class RunsClient extends BaseClient {
365
369
  *
366
370
  * @param threadId The ID of the thread.
367
371
  * @param runId The ID of the run.
368
- * @param signal An optional abort signal.
369
372
  * @returns An async generator yielding stream parts.
370
373
  */
371
- joinStream(threadId: string, runId: string, signal?: AbortSignal): AsyncGenerator<{
374
+ joinStream(threadId: string, runId: string, options?: {
375
+ signal?: AbortSignal;
376
+ cancelOnDisconnect?: boolean;
377
+ } | AbortSignal): AsyncGenerator<{
372
378
  event: StreamEvent;
373
379
  data: any;
374
380
  }>;
package/dist/client.js CHANGED
@@ -653,6 +653,7 @@ export class RunsClient extends BaseClient {
653
653
  params: {
654
654
  limit: options?.limit ?? 10,
655
655
  offset: options?.offset ?? 0,
656
+ status: options?.status ?? undefined,
656
657
  },
657
658
  });
658
659
  }
@@ -704,14 +705,19 @@ export class RunsClient extends BaseClient {
704
705
  *
705
706
  * @param threadId The ID of the thread.
706
707
  * @param runId The ID of the run.
707
- * @param signal An optional abort signal.
708
708
  * @returns An async generator yielding stream parts.
709
709
  */
710
- async *joinStream(threadId, runId, signal) {
710
+ async *joinStream(threadId, runId, options) {
711
+ const opts = typeof options === "object" &&
712
+ options != null &&
713
+ options instanceof AbortSignal
714
+ ? { signal: options }
715
+ : options;
711
716
  const response = await this.asyncCaller.fetch(...this.prepareFetchOptions(`/threads/${threadId}/runs/${runId}/stream`, {
712
717
  method: "GET",
713
718
  timeoutMs: null,
714
- signal,
719
+ signal: opts?.signal,
720
+ params: { cancel_on_disconnect: opts?.cancelOnDisconnect ? "1" : "0" },
715
721
  }));
716
722
  let parser;
717
723
  let onEndEvent;
@@ -719,7 +725,7 @@ export class RunsClient extends BaseClient {
719
725
  const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
720
726
  async start(ctrl) {
721
727
  parser = createParser((event) => {
722
- if ((signal && signal.aborted) ||
728
+ if ((opts?.signal && opts.signal.aborted) ||
723
729
  (event.type === "event" && event.data === "[DONE]")) {
724
730
  ctrl.terminate();
725
731
  return;
package/dist/schema.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { JSONSchema7 } from "json-schema";
2
2
  type Optional<T> = T | null | undefined;
3
- type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
3
+ export type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
4
4
  export type ThreadStatus = "idle" | "busy" | "interrupted" | "error";
5
5
  type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";
6
6
  export type CancelAction = "interrupt" | "rollback";
@@ -9,6 +9,7 @@ const p_queue_1 = __importDefault(require("p-queue"));
9
9
  const STATUS_NO_RETRY = [
10
10
  400, // Bad Request
11
11
  401, // Unauthorized
12
+ 402, // Payment required
12
13
  403, // Forbidden
13
14
  404, // Not Found
14
15
  405, // Method Not Allowed
@@ -3,6 +3,7 @@ import PQueueMod from "p-queue";
3
3
  const STATUS_NO_RETRY = [
4
4
  400, // Bad Request
5
5
  401, // Unauthorized
6
+ 402, // Payment required
6
7
  403, // Forbidden
7
8
  404, // Not Found
8
9
  405, // Method Not Allowed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",