@langchain/langgraph 0.0.7 → 0.0.9-rc.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.
@@ -189,7 +189,7 @@ class Graph {
189
189
  throw new Error(`Node \`${node}\` is a dead-end`);
190
190
  }
191
191
  }
192
- const allEndsAreDefined = Object.values(this.branches).every((branchList) => branchList.every((branch) => branch.ends !== null));
192
+ const allEndsAreDefined = Object.values(this.branches).every((branchList) => branchList.every((branch) => branch.ends));
193
193
  if (allEndsAreDefined) {
194
194
  const allEnds = new Set([...this.edges]
195
195
  .map(([_, end]) => end)
@@ -186,7 +186,7 @@ export class Graph {
186
186
  throw new Error(`Node \`${node}\` is a dead-end`);
187
187
  }
188
188
  }
189
- const allEndsAreDefined = Object.values(this.branches).every((branchList) => branchList.every((branch) => branch.ends !== null));
189
+ const allEndsAreDefined = Object.values(this.branches).every((branchList) => branchList.every((branch) => branch.ends));
190
190
  if (allEndsAreDefined) {
191
191
  const allEnds = new Set([...this.edges]
192
192
  .map(([_, end]) => end)
@@ -12,6 +12,7 @@ const reserved_js_1 = require("./reserved.cjs");
12
12
  const io_js_1 = require("./io.cjs");
13
13
  const write_js_1 = require("./write.cjs");
14
14
  const constants_js_1 = require("../constants.cjs");
15
+ const async_local_storage_js_1 = require("../setup/async_local_storage.cjs");
15
16
  const DEFAULT_RECURSION_LIMIT = 25;
16
17
  class GraphRecursionError extends Error {
17
18
  constructor(message) {
@@ -95,7 +96,7 @@ class Pregel extends runnables_1.Runnable {
95
96
  return "LangGraph";
96
97
  }
97
98
  constructor(fields) {
98
- super();
99
+ super(fields);
99
100
  // Because Pregel extends `Runnable`.
100
101
  Object.defineProperty(this, "lc_namespace", {
101
102
  enumerable: true,
@@ -157,6 +158,7 @@ class Pregel extends runnables_1.Runnable {
157
158
  writable: true,
158
159
  value: []
159
160
  });
161
+ (0, async_local_storage_js_1.initializeAsyncLocalStorage)();
160
162
  this.channels = fields.channels ?? this.channels;
161
163
  this.output = fields.output ?? this.output;
162
164
  this.input = fields.input ?? this.input;
@@ -9,6 +9,7 @@ import { ReservedChannelsMap } from "./reserved.js";
9
9
  import { mapInput, mapOutput } from "./io.js";
10
10
  import { ChannelWrite } from "./write.js";
11
11
  import { CONFIG_KEY_READ, CONFIG_KEY_SEND } from "../constants.js";
12
+ import { initializeAsyncLocalStorage } from "../setup/async_local_storage.js";
12
13
  const DEFAULT_RECURSION_LIMIT = 25;
13
14
  export class GraphRecursionError extends Error {
14
15
  constructor(message) {
@@ -90,7 +91,7 @@ export class Pregel extends Runnable {
90
91
  return "LangGraph";
91
92
  }
92
93
  constructor(fields) {
93
- super();
94
+ super(fields);
94
95
  // Because Pregel extends `Runnable`.
95
96
  Object.defineProperty(this, "lc_namespace", {
96
97
  enumerable: true,
@@ -152,6 +153,7 @@ export class Pregel extends Runnable {
152
153
  writable: true,
153
154
  value: []
154
155
  });
156
+ initializeAsyncLocalStorage();
155
157
  this.channels = fields.channels ?? this.channels;
156
158
  this.output = fields.output ?? this.output;
157
159
  this.input = fields.input ?? this.input;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeAsyncLocalStorage = void 0;
4
+ const singletons_1 = require("@langchain/core/singletons");
5
+ const async_hooks_1 = require("async_hooks");
6
+ function initializeAsyncLocalStorage() {
7
+ singletons_1.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new async_hooks_1.AsyncLocalStorage());
8
+ }
9
+ exports.initializeAsyncLocalStorage = initializeAsyncLocalStorage;
@@ -0,0 +1 @@
1
+ export declare function initializeAsyncLocalStorage(): void;
@@ -0,0 +1,5 @@
1
+ import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
2
+ import { AsyncLocalStorage } from "async_hooks";
3
+ export function initializeAsyncLocalStorage() {
4
+ AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorage());
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "0.0.7",
3
+ "version": "0.0.9-rc.0",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -37,13 +37,13 @@
37
37
  "author": "LangChain",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@langchain/core": "^0.1.27"
40
+ "@langchain/core": "^0.1.33"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@jest/globals": "^29.5.0",
44
44
  "@langchain/community": "^0.0.27",
45
45
  "@langchain/openai": "^0.0.14",
46
- "@langchain/scripts": "~0.0",
46
+ "@langchain/scripts": "latest",
47
47
  "@swc/core": "^1.3.90",
48
48
  "@swc/jest": "^0.2.29",
49
49
  "@tsconfig/recommended": "^1.0.3",