@langchain/langgraph-sdk 0.0.21 → 0.0.23-dev.0

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/client.d.cts CHANGED
@@ -1 +1 @@
1
- export * from './dist/client.cjs'
1
+ export * from './dist/client.js'
package/dist/client.cjs CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = exports.StoreClient = exports.RunsClient = exports.ThreadsClient = exports.AssistantsClient = exports.CronsClient = void 0;
4
- const async_caller_js_1 = require("./utils/async_caller.cjs");
5
- const index_js_1 = require("./utils/eventsource-parser/index.cjs");
6
- const stream_js_1 = require("./utils/stream.cjs");
7
- const signals_js_1 = require("./utils/signals.cjs");
1
+ import { AsyncCaller } from "./utils/async_caller.js";
2
+ import { createParser, } from "./utils/eventsource-parser/index.js";
3
+ import { IterableReadableStream } from "./utils/stream.js";
4
+ import { mergeSignals } from "./utils/signals.js";
8
5
  class BaseClient {
9
6
  constructor(config) {
10
7
  Object.defineProperty(this, "asyncCaller", {
@@ -31,7 +28,7 @@ class BaseClient {
31
28
  writable: true,
32
29
  value: void 0
33
30
  });
34
- this.asyncCaller = new async_caller_js_1.AsyncCaller({
31
+ this.asyncCaller = new AsyncCaller({
35
32
  maxRetries: 4,
36
33
  maxConcurrency: 4,
37
34
  ...config?.callerOptions,
@@ -67,7 +64,7 @@ class BaseClient {
67
64
  else {
68
65
  timeoutSignal = AbortSignal.timeout(this.timeoutMs);
69
66
  }
70
- mutatedOptions.signal = (0, signals_js_1.mergeSignals)(timeoutSignal, mutatedOptions.signal);
67
+ mutatedOptions.signal = mergeSignals(timeoutSignal, mutatedOptions.signal);
71
68
  const targetUrl = new URL(`${this.apiUrl}${path}`);
72
69
  if (mutatedOptions.params) {
73
70
  for (const [key, value] of Object.entries(mutatedOptions.params)) {
@@ -90,7 +87,7 @@ class BaseClient {
90
87
  return response.json();
91
88
  }
92
89
  }
93
- class CronsClient extends BaseClient {
90
+ export class CronsClient extends BaseClient {
94
91
  /**
95
92
  *
96
93
  * @param threadId The ID of the thread.
@@ -166,8 +163,7 @@ class CronsClient extends BaseClient {
166
163
  });
167
164
  }
168
165
  }
169
- exports.CronsClient = CronsClient;
170
- class AssistantsClient extends BaseClient {
166
+ export class AssistantsClient extends BaseClient {
171
167
  /**
172
168
  * Get an assistant by ID.
173
169
  *
@@ -302,8 +298,7 @@ class AssistantsClient extends BaseClient {
302
298
  });
303
299
  }
304
300
  }
305
- exports.AssistantsClient = AssistantsClient;
306
- class ThreadsClient extends BaseClient {
301
+ export class ThreadsClient extends BaseClient {
307
302
  /**
308
303
  * Get a thread by ID.
309
304
  *
@@ -375,6 +370,7 @@ class ThreadsClient extends BaseClient {
375
370
  metadata: query?.metadata ?? undefined,
376
371
  limit: query?.limit ?? 10,
377
372
  offset: query?.offset ?? 0,
373
+ status: query?.status,
378
374
  },
379
375
  });
380
376
  }
@@ -457,8 +453,7 @@ class ThreadsClient extends BaseClient {
457
453
  });
458
454
  }
459
455
  }
460
- exports.ThreadsClient = ThreadsClient;
461
- class RunsClient extends BaseClient {
456
+ export class RunsClient extends BaseClient {
462
457
  /**
463
458
  * Create a run and stream the results.
464
459
  *
@@ -498,7 +493,7 @@ class RunsClient extends BaseClient {
498
493
  const textDecoder = new TextDecoder();
499
494
  const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
500
495
  async start(ctrl) {
501
- parser = (0, index_js_1.createParser)((event) => {
496
+ parser = createParser((event) => {
502
497
  if ((payload?.signal && payload.signal.aborted) ||
503
498
  (event.type === "event" && event.data === "[DONE]")) {
504
499
  ctrl.terminate();
@@ -524,7 +519,7 @@ class RunsClient extends BaseClient {
524
519
  onEndEvent();
525
520
  },
526
521
  }));
527
- yield* stream_js_1.IterableReadableStream.fromReadableStream(stream);
522
+ yield* IterableReadableStream.fromReadableStream(stream);
528
523
  }
529
524
  /**
530
525
  * Create a run.
@@ -692,7 +687,7 @@ class RunsClient extends BaseClient {
692
687
  const textDecoder = new TextDecoder();
693
688
  const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
694
689
  async start(ctrl) {
695
- parser = (0, index_js_1.createParser)((event) => {
690
+ parser = createParser((event) => {
696
691
  if ((signal && signal.aborted) ||
697
692
  (event.type === "event" && event.data === "[DONE]")) {
698
693
  ctrl.terminate();
@@ -718,7 +713,7 @@ class RunsClient extends BaseClient {
718
713
  onEndEvent();
719
714
  },
720
715
  }));
721
- yield* stream_js_1.IterableReadableStream.fromReadableStream(stream);
716
+ yield* IterableReadableStream.fromReadableStream(stream);
722
717
  }
723
718
  /**
724
719
  * Delete a run.
@@ -733,8 +728,7 @@ class RunsClient extends BaseClient {
733
728
  });
734
729
  }
735
730
  }
736
- exports.RunsClient = RunsClient;
737
- class StoreClient extends BaseClient {
731
+ export class StoreClient extends BaseClient {
738
732
  /**
739
733
  * Store or update an item.
740
734
  *
@@ -853,8 +847,7 @@ class StoreClient extends BaseClient {
853
847
  });
854
848
  }
855
849
  }
856
- exports.StoreClient = StoreClient;
857
- class Client {
850
+ export class Client {
858
851
  constructor(config) {
859
852
  /**
860
853
  * The client for interacting with assistants.
@@ -908,4 +901,3 @@ class Client {
908
901
  this.store = new StoreClient(config);
909
902
  }
910
903
  }
911
- exports.Client = Client;
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 } 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.
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
  }
package/dist/index.cjs CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = void 0;
4
- var client_js_1 = require("./client.cjs");
5
- Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_1.Client; } });
1
+ export { Client } from "./client.js";
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.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/schema.d.ts CHANGED
@@ -1,7 +1,7 @@
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
6
  export type CancelAction = "interrupt" | "rollback";
7
7
  export interface Config {
package/dist/types.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Checkpoint, Config, Metadata } from "./schema.js";
2
- export type StreamMode = "values" | "messages" | "updates" | "events" | "debug";
2
+ export type StreamMode = "values" | "messages" | "updates" | "events" | "debug" | "custom" | "messages-tuple";
3
3
  export type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";
4
4
  export type OnConflictBehavior = "raise" | "do_nothing";
5
5
  export type OnCompletionBehavior = "complete" | "continue";
@@ -1,11 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AsyncCaller = void 0;
7
- const p_retry_1 = __importDefault(require("p-retry"));
8
- const p_queue_1 = __importDefault(require("p-queue"));
1
+ import pRetry from "p-retry";
2
+ import PQueueMod from "p-queue";
9
3
  const STATUS_NO_RETRY = [
10
4
  400, // Bad Request
11
5
  401, // Unauthorized
@@ -79,7 +73,7 @@ class HTTPError extends Error {
79
73
  * means that by default, each call will be retried up to 5 times, with an
80
74
  * exponential backoff between each attempt.
81
75
  */
82
- class AsyncCaller {
76
+ export class AsyncCaller {
83
77
  constructor(params) {
84
78
  Object.defineProperty(this, "maxConcurrency", {
85
79
  enumerable: true,
@@ -113,15 +107,15 @@ class AsyncCaller {
113
107
  });
114
108
  this.maxConcurrency = params.maxConcurrency ?? Infinity;
115
109
  this.maxRetries = params.maxRetries ?? 4;
116
- if ("default" in p_queue_1.default) {
110
+ if ("default" in PQueueMod) {
117
111
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
118
- this.queue = new p_queue_1.default.default({
112
+ this.queue = new PQueueMod.default({
119
113
  concurrency: this.maxConcurrency,
120
114
  });
121
115
  }
122
116
  else {
123
117
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
124
- this.queue = new p_queue_1.default({ concurrency: this.maxConcurrency });
118
+ this.queue = new PQueueMod({ concurrency: this.maxConcurrency });
125
119
  }
126
120
  this.onFailedResponseHook = params?.onFailedResponseHook;
127
121
  this.customFetch = params.fetch;
@@ -129,7 +123,7 @@ class AsyncCaller {
129
123
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
130
124
  call(callable, ...args) {
131
125
  const onFailedResponseHook = this.onFailedResponseHook;
132
- return this.queue.add(() => (0, p_retry_1.default)(() => callable(...args).catch(async (error) => {
126
+ return this.queue.add(() => pRetry(() => callable(...args).catch(async (error) => {
133
127
  // eslint-disable-next-line no-instanceof/no-instanceof
134
128
  if (error instanceof Error) {
135
129
  throw error;
@@ -192,4 +186,3 @@ class AsyncCaller {
192
186
  return this.call(() => fetchFn(...args).then((res) => (res.ok ? res : Promise.reject(res))));
193
187
  }
194
188
  }
195
- exports.AsyncCaller = AsyncCaller;
@@ -1,7 +1,3 @@
1
- "use strict";
2
1
  // From https://github.com/rexxars/eventsource-parser
3
2
  // Inlined due to CJS import issues
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.createParser = void 0;
6
- var parse_js_1 = require("./parse.cjs");
7
- Object.defineProperty(exports, "createParser", { enumerable: true, get: function () { return parse_js_1.createParser; } });
3
+ export { createParser } from "./parse.js";
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createParser = void 0;
4
1
  /**
5
2
  * Creates a new EventSource parser.
6
3
  *
@@ -10,7 +7,7 @@ exports.createParser = void 0;
10
7
  * @returns A new EventSource parser, with `parse` and `reset` methods.
11
8
  * @public
12
9
  */
13
- function createParser(onParse) {
10
+ export function createParser(onParse) {
14
11
  // Processing state
15
12
  let isFirstChunk;
16
13
  let buffer;
@@ -143,7 +140,6 @@ function createParser(onParse) {
143
140
  }
144
141
  }
145
142
  }
146
- exports.createParser = createParser;
147
143
  const BOM = [239, 187, 191];
148
144
  function hasBom(buffer) {
149
145
  return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode);
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventSourceParserStream = void 0;
4
- const parse_js_1 = require("./parse.cjs");
1
+ import { createParser } from "./parse.js";
5
2
  /**
6
3
  * A TransformStream that ingests a stream of strings and produces a stream of ParsedEvents.
7
4
  *
@@ -14,12 +11,12 @@ const parse_js_1 = require("./parse.cjs");
14
11
  * ```
15
12
  * @public
16
13
  */
17
- class EventSourceParserStream extends TransformStream {
14
+ export class EventSourceParserStream extends TransformStream {
18
15
  constructor() {
19
16
  let parser;
20
17
  super({
21
18
  start(controller) {
22
- parser = (0, parse_js_1.createParser)((event) => {
19
+ parser = createParser((event) => {
23
20
  if (event.type === "event") {
24
21
  controller.enqueue(event);
25
22
  }
@@ -31,4 +28,3 @@ class EventSourceParserStream extends TransformStream {
31
28
  });
32
29
  }
33
30
  }
34
- exports.EventSourceParserStream = EventSourceParserStream;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeSignals = void 0;
4
- function mergeSignals(...signals) {
1
+ export function mergeSignals(...signals) {
5
2
  const nonZeroSignals = signals.filter((signal) => signal != null);
6
3
  if (nonZeroSignals.length === 0)
7
4
  return undefined;
@@ -19,4 +16,3 @@ function mergeSignals(...signals) {
19
16
  }
20
17
  return controller.signal;
21
18
  }
22
- exports.mergeSignals = mergeSignals;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IterableReadableStream = void 0;
4
1
  /*
5
2
  * Support async iterator syntax for ReadableStreams in all environments.
6
3
  * Source: https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
7
4
  */
8
- class IterableReadableStream extends ReadableStream {
5
+ export class IterableReadableStream extends ReadableStream {
9
6
  constructor() {
10
7
  super(...arguments);
11
8
  Object.defineProperty(this, "reader", {
@@ -112,4 +109,3 @@ class IterableReadableStream extends ReadableStream {
112
109
  });
113
110
  }
114
111
  }
115
- exports.IterableReadableStream = IterableReadableStream;
package/index.d.cts CHANGED
@@ -1 +1 @@
1
- export * from './dist/index.cjs'
1
+ export * from './dist/index.js'
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.21",
3
+ "version": "0.0.23-dev.0",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",
7
7
  "scripts": {
8
- "clean": "rm -rf dist/ && node scripts/create-entrypoints.js clean",
9
- "build": "yarn clean && yarn build:esm && yarn build:cjs && node scripts/create-entrypoints.js",
10
- "build:esm": "rm -f src/package.json && tsc --outDir dist/ && rm -rf dist/tests dist/**/tests",
11
- "build:cjs": "echo '{}' > src/package.json && tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rm -r dist-cjs src/package.json",
8
+ "clean": "rm -rf dist/ dist-cjs/",
9
+ "build": "yarn clean && yarn lc_build --create-entrypoints --pre --tree-shaking",
12
10
  "prepublish": "yarn run build",
13
11
  "format": "prettier --write src",
14
12
  "lint": "prettier --check src && tsc --noEmit"
@@ -22,6 +20,7 @@
22
20
  "uuid": "^9.0.0"
23
21
  },
24
22
  "devDependencies": {
23
+ "@langchain/scripts": "^0.1.3",
25
24
  "@tsconfig/recommended": "^1.0.2",
26
25
  "@types/node": "^20.12.12",
27
26
  "@types/uuid": "^9.0.1",
@@ -54,13 +53,13 @@
54
53
  },
55
54
  "files": [
56
55
  "dist/",
57
- "client.cjs",
58
- "client.js",
59
- "client.d.ts",
60
- "client.d.cts",
61
56
  "index.cjs",
62
57
  "index.js",
63
58
  "index.d.ts",
64
- "index.d.cts"
59
+ "index.d.cts",
60
+ "client.cjs",
61
+ "client.js",
62
+ "client.d.ts",
63
+ "client.d.cts"
65
64
  ]
66
65
  }