@langchain/langgraph 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -198,10 +198,26 @@ const _getAction = (state: { messages: Array<BaseMessage> }): AgentAction => {
198
198
  };
199
199
  };
200
200
 
201
- const callTool = async (state: { messages: Array<BaseMessage> }) => {
201
+ // Define the function that calls the model
202
+ const callModel = async (
203
+ state: { messages: Array<BaseMessage> },
204
+ config?: RunnableConfig
205
+ ) => {
206
+ const { messages } = state;
207
+ const response = await newModel.invoke(messages, config);
208
+ // We return a list, because this will get added to the existing list
209
+ return {
210
+ messages: [response],
211
+ };
212
+ };
213
+
214
+ const callTool = async (
215
+ state: { messages: Array<BaseMessage> },
216
+ config?: RunnableConfig
217
+ ) => {
202
218
  const action = _getAction(state);
203
219
  // We call the tool_executor and get back a response
204
- const response = await toolExecutor.invoke(action);
220
+ const response = await toolExecutor.invoke(action, config);
205
221
  // We use the response to create a FunctionMessage
206
222
  const functionMessage = new FunctionMessage({
207
223
  content: response,
@@ -315,7 +331,6 @@ Langchain Expression Language allows you to easily define chains (DAGs) but does
315
331
 
316
332
  ## Examples
317
333
 
318
-
319
334
  ### ChatAgentExecutor: with function calling
320
335
 
321
336
  This agent executor takes a list of messages as input and outputs a list of messages.
@@ -331,6 +346,12 @@ This agent executor uses existing LangChain agents.
331
346
 
332
347
  - [Getting Started Notebook](https://github.com/langchain-ai/langgraphjs/blob/main/examples/agent_executor/base.ipynb): Walks through creating this type of executor from scratch
333
348
 
349
+ ### Multi-agent Examples
350
+
351
+ - [Multi-agent collaboration](https://github.com/langchain-ai/langgraphjs/blob/main/examples/multi_agent/multi-agent-collaboration.ipynb): how to create two agents that work together to accomplish a task
352
+ - [Multi-agent with supervisor](https://github.com/langchain-ai/langgraphjs/blob/main/examples/multi_agent/agent_supervisor.ipynb): how to orchestrate individual agents by using an LLM as a "supervisor" to distribute work
353
+ - [Hierarchical agent teams](https://github.com/langchain-ai/langgraphjs/blob/main/examples/multi_agent/hierarchical_agent_teams.ipynb): how to orchestrate "teams" of agents as nested graphs that can collaborate to solve a problem
354
+
334
355
  ## Documentation
335
356
 
336
357
  There are only a few new APIs to use.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseCheckpointSaver = exports.CheckpointAt = exports.emptyCheckpoint = void 0;
3
+ exports.BaseCheckpointSaver = exports.emptyCheckpoint = void 0;
4
4
  function emptyCheckpoint() {
5
5
  return {
6
6
  v: 1,
@@ -11,18 +11,13 @@ function emptyCheckpoint() {
11
11
  };
12
12
  }
13
13
  exports.emptyCheckpoint = emptyCheckpoint;
14
- var CheckpointAt;
15
- (function (CheckpointAt) {
16
- CheckpointAt["END_OF_STEP"] = "end_of_step";
17
- CheckpointAt["END_OF_RUN"] = "end_of_run";
18
- })(CheckpointAt || (exports.CheckpointAt = CheckpointAt = {}));
19
14
  class BaseCheckpointSaver {
20
15
  constructor() {
21
16
  Object.defineProperty(this, "at", {
22
17
  enumerable: true,
23
18
  configurable: true,
24
19
  writable: true,
25
- value: CheckpointAt.END_OF_RUN
20
+ value: "end_of_run" /* CheckpointAt.END_OF_RUN */
26
21
  });
27
22
  }
28
23
  get configSpecs() {
@@ -35,7 +35,7 @@ export interface Checkpoint {
35
35
  versionsSeen: Record<string, Record<string, number>>;
36
36
  }
37
37
  export declare function emptyCheckpoint(): Checkpoint;
38
- export declare enum CheckpointAt {
38
+ export declare const enum CheckpointAt {
39
39
  END_OF_STEP = "end_of_step",
40
40
  END_OF_RUN = "end_of_run"
41
41
  }
@@ -7,18 +7,13 @@ export function emptyCheckpoint() {
7
7
  versionsSeen: {},
8
8
  };
9
9
  }
10
- export var CheckpointAt;
11
- (function (CheckpointAt) {
12
- CheckpointAt["END_OF_STEP"] = "end_of_step";
13
- CheckpointAt["END_OF_RUN"] = "end_of_run";
14
- })(CheckpointAt || (CheckpointAt = {}));
15
10
  export class BaseCheckpointSaver {
16
11
  constructor() {
17
12
  Object.defineProperty(this, "at", {
18
13
  enumerable: true,
19
14
  configurable: true,
20
15
  writable: true,
21
- value: CheckpointAt.END_OF_RUN
16
+ value: "end_of_run" /* CheckpointAt.END_OF_RUN */
22
17
  });
23
18
  }
24
19
  get configSpecs() {
@@ -4,14 +4,16 @@ import { Graph } from "./graph.js";
4
4
  import { BaseCheckpointSaver } from "../checkpoint/base.js";
5
5
  import { Pregel } from "../pregel/index.js";
6
6
  export declare const START = "__start__";
7
- export interface StateGraphArgs<T = any> {
8
- channels: Record<string, {
9
- value: BinaryOperator<T> | null;
10
- default?: () => T;
11
- }>;
7
+ export interface StateGraphArgs<Channels extends Record<string, any>> {
8
+ channels: {
9
+ [K in keyof Channels]: {
10
+ value: BinaryOperator<Channels[K]> | null;
11
+ default?: () => Channels[K];
12
+ };
13
+ };
12
14
  }
13
- export declare class StateGraph<T> extends Graph {
15
+ export declare class StateGraph<Channels extends Record<string, any>> extends Graph<Channels> {
14
16
  channels: Record<string, BaseChannel>;
15
- constructor(fields: StateGraphArgs<T>);
17
+ constructor(fields: StateGraphArgs<Channels>);
16
18
  compile(checkpointer?: BaseCheckpointSaver): Pregel;
17
19
  }
@@ -43,18 +43,18 @@ function createAgentExecutor({ agentRunnable, tools, inputSchema, }) {
43
43
  }
44
44
  return "continue";
45
45
  };
46
- const runAgent = async (data) => {
47
- const agentOutcome = await agentRunnable.invoke(data);
46
+ const runAgent = async (data, config) => {
47
+ const agentOutcome = await agentRunnable.invoke(data, config);
48
48
  return {
49
49
  agentOutcome,
50
50
  };
51
51
  };
52
- const executeTools = async (data) => {
52
+ const executeTools = async (data, config) => {
53
53
  const agentAction = data.agentOutcome;
54
54
  if (!agentAction || "returnValues" in agentAction) {
55
55
  throw new Error("Agent has not been run yet");
56
56
  }
57
- const output = await toolExecutor.invoke(agentAction);
57
+ const output = await toolExecutor.invoke(agentAction, config);
58
58
  return {
59
59
  steps: [[agentAction, output]],
60
60
  };
@@ -1,10 +1,21 @@
1
+ import { AgentAction, AgentFinish } from "@langchain/core/agents";
2
+ import { BaseMessage } from "@langchain/core/messages";
1
3
  import { Runnable } from "@langchain/core/runnables";
2
4
  import { Tool } from "@langchain/core/tools";
3
5
  import { ToolExecutor } from "./tool_executor.js";
4
6
  import { StateGraphArgs } from "../graph/state.js";
5
7
  import { Pregel } from "../pregel/index.js";
6
- type AgentChannels<T> = StateGraphArgs<Array<any> | T>["channels"];
7
- export declare function createAgentExecutor<T extends Array<any> = Array<any>>({ agentRunnable, tools, inputSchema, }: {
8
+ type Step = [AgentAction | AgentFinish, string];
9
+ interface AgentStateBase {
10
+ agentOutcome?: AgentAction | AgentFinish;
11
+ steps: Array<Step>;
12
+ }
13
+ export interface AgentExecutorState extends AgentStateBase {
14
+ input: string;
15
+ chatHistory?: BaseMessage[];
16
+ }
17
+ type AgentChannels<T extends AgentExecutorState> = StateGraphArgs<AgentExecutorState | T>["channels"];
18
+ export declare function createAgentExecutor<T extends AgentExecutorState>({ agentRunnable, tools, inputSchema, }: {
8
19
  agentRunnable: Runnable;
9
20
  tools: Array<Tool> | ToolExecutor;
10
21
  inputSchema?: AgentChannels<T>;
@@ -1,4 +1,4 @@
1
- import { RunnableLambda } from "@langchain/core/runnables";
1
+ import { RunnableLambda, } from "@langchain/core/runnables";
2
2
  import { ToolExecutor } from "./tool_executor.js";
3
3
  import { StateGraph } from "../graph/state.js";
4
4
  import { END } from "../index.js";
@@ -40,18 +40,18 @@ export function createAgentExecutor({ agentRunnable, tools, inputSchema, }) {
40
40
  }
41
41
  return "continue";
42
42
  };
43
- const runAgent = async (data) => {
44
- const agentOutcome = await agentRunnable.invoke(data);
43
+ const runAgent = async (data, config) => {
44
+ const agentOutcome = await agentRunnable.invoke(data, config);
45
45
  return {
46
46
  agentOutcome,
47
47
  };
48
48
  };
49
- const executeTools = async (data) => {
49
+ const executeTools = async (data, config) => {
50
50
  const agentAction = data.agentOutcome;
51
51
  if (!agentAction || "returnValues" in agentAction) {
52
52
  throw new Error("Agent has not been run yet");
53
53
  }
54
- const output = await toolExecutor.invoke(agentAction);
54
+ const output = await toolExecutor.invoke(agentAction, config);
55
55
  return {
56
56
  steps: [[agentAction, output]],
57
57
  };
@@ -41,9 +41,9 @@ function createFunctionCallingExecutor({ model, tools, }) {
41
41
  return "continue";
42
42
  };
43
43
  // Define the function that calls the model
44
- const callModel = async (state) => {
44
+ const callModel = async (state, config) => {
45
45
  const { messages } = state;
46
- const response = await newModel.invoke(messages);
46
+ const response = await newModel.invoke(messages, config);
47
47
  // We return a list, because this will get added to the existing list
48
48
  return {
49
49
  messages: [response],
@@ -68,10 +68,10 @@ function createFunctionCallingExecutor({ model, tools, }) {
68
68
  log: "",
69
69
  };
70
70
  };
71
- const callTool = async (state) => {
71
+ const callTool = async (state, config) => {
72
72
  const action = _getAction(state);
73
73
  // We call the tool_executor and get back a response
74
- const response = await toolExecutor.invoke(action);
74
+ const response = await toolExecutor.invoke(action, config);
75
75
  // We use the response to create a FunctionMessage
76
76
  const functionMessage = new messages_1.FunctionMessage({
77
77
  content: response,
@@ -1,5 +1,9 @@
1
1
  import { Tool } from "@langchain/core/tools";
2
+ import { BaseMessage } from "@langchain/core/messages";
2
3
  import { ToolExecutor } from "./tool_executor.js";
4
+ export type FunctionCallingExecutorState = {
5
+ messages: Array<BaseMessage>;
6
+ };
3
7
  export declare function createFunctionCallingExecutor<Model extends object>({ model, tools, }: {
4
8
  model: Model;
5
9
  tools: Array<Tool> | ToolExecutor;
@@ -38,9 +38,9 @@ export function createFunctionCallingExecutor({ model, tools, }) {
38
38
  return "continue";
39
39
  };
40
40
  // Define the function that calls the model
41
- const callModel = async (state) => {
41
+ const callModel = async (state, config) => {
42
42
  const { messages } = state;
43
- const response = await newModel.invoke(messages);
43
+ const response = await newModel.invoke(messages, config);
44
44
  // We return a list, because this will get added to the existing list
45
45
  return {
46
46
  messages: [response],
@@ -65,10 +65,10 @@ export function createFunctionCallingExecutor({ model, tools, }) {
65
65
  log: "",
66
66
  };
67
67
  };
68
- const callTool = async (state) => {
68
+ const callTool = async (state, config) => {
69
69
  const action = _getAction(state);
70
70
  // We call the tool_executor and get back a response
71
- const response = await toolExecutor.invoke(action);
71
+ const response = await toolExecutor.invoke(action, config);
72
72
  // We use the response to create a FunctionMessage
73
73
  const functionMessage = new FunctionMessage({
74
74
  content: response,
@@ -1,3 +1,3 @@
1
- export { createAgentExecutor } from "./agent_executor.js";
2
- export { createFunctionCallingExecutor } from "./chat_agent_executor.js";
1
+ export { type AgentExecutorState, createAgentExecutor, } from "./agent_executor.js";
2
+ export { type FunctionCallingExecutorState, createFunctionCallingExecutor, } from "./chat_agent_executor.js";
3
3
  export { type ToolExecutorArgs, type ToolInvocationInterface, ToolExecutor, } from "./tool_executor.js";
@@ -1,3 +1,3 @@
1
- export { createAgentExecutor } from "./agent_executor.js";
2
- export { createFunctionCallingExecutor } from "./chat_agent_executor.js";
1
+ export { createAgentExecutor, } from "./agent_executor.js";
2
+ export { createFunctionCallingExecutor, } from "./chat_agent_executor.js";
3
3
  export { ToolExecutor, } from "./tool_executor.js";
@@ -47,7 +47,7 @@ class ToolExecutor extends runnables_1.RunnableBinding {
47
47
  return acc;
48
48
  }, {});
49
49
  }
50
- async _execute(toolInvocation, _config) {
50
+ async _execute(toolInvocation, config) {
51
51
  if (!(toolInvocation.tool in this.toolMap)) {
52
52
  return this.invalidToolMsgTemplate
53
53
  .replace("{requestedToolName}", toolInvocation.tool)
@@ -55,7 +55,7 @@ class ToolExecutor extends runnables_1.RunnableBinding {
55
55
  }
56
56
  else {
57
57
  const tool = this.toolMap[toolInvocation.tool];
58
- const output = await tool.invoke(toolInvocation.toolInput);
58
+ const output = await tool.invoke(toolInvocation.toolInput, config);
59
59
  return output;
60
60
  }
61
61
  }
@@ -22,6 +22,6 @@ export declare class ToolExecutor extends RunnableBinding<ToolExecutorInputType,
22
22
  toolMap: Record<string, Tool>;
23
23
  invalidToolMsgTemplate: string;
24
24
  constructor(fields: ToolExecutorArgs);
25
- _execute(toolInvocation: ToolInvocationInterface, _config?: RunnableConfig): Promise<string>;
25
+ _execute(toolInvocation: ToolInvocationInterface, config?: RunnableConfig): Promise<string>;
26
26
  }
27
27
  export {};
@@ -44,7 +44,7 @@ export class ToolExecutor extends RunnableBinding {
44
44
  return acc;
45
45
  }, {});
46
46
  }
47
- async _execute(toolInvocation, _config) {
47
+ async _execute(toolInvocation, config) {
48
48
  if (!(toolInvocation.tool in this.toolMap)) {
49
49
  return this.invalidToolMsgTemplate
50
50
  .replace("{requestedToolName}", toolInvocation.tool)
@@ -52,7 +52,7 @@ export class ToolExecutor extends RunnableBinding {
52
52
  }
53
53
  else {
54
54
  const tool = this.toolMap[toolInvocation.tool];
55
- const output = await tool.invoke(toolInvocation.toolInput);
55
+ const output = await tool.invoke(toolInvocation.toolInput, config);
56
56
  return output;
57
57
  }
58
58
  }
@@ -91,6 +91,9 @@ class Channel {
91
91
  }
92
92
  exports.Channel = Channel;
93
93
  class Pregel extends runnables_1.Runnable {
94
+ static lc_name() {
95
+ return "LangGraph";
96
+ }
94
97
  constructor(fields) {
95
98
  super();
96
99
  // Because Pregel extends `Runnable`.
@@ -256,7 +259,7 @@ class Pregel extends runnables_1.Runnable {
256
259
  }
257
260
  // save end of step checkpoint
258
261
  if (this.checkpointer &&
259
- this.checkpointer.at === base_js_2.CheckpointAt.END_OF_STEP) {
262
+ this.checkpointer.at === "end_of_step" /* CheckpointAt.END_OF_STEP */) {
260
263
  checkpoint = await (0, base_js_1.createCheckpoint)(checkpoint, channels);
261
264
  this.checkpointer.put(config, checkpoint);
262
265
  }
@@ -266,7 +269,7 @@ class Pregel extends runnables_1.Runnable {
266
269
  }
267
270
  }
268
271
  // save end of run checkpoint
269
- if (this.checkpointer && this.checkpointer.at === base_js_2.CheckpointAt.END_OF_RUN) {
272
+ if (this.checkpointer && this.checkpointer.at === "end_of_run" /* CheckpointAt.END_OF_RUN */) {
270
273
  checkpoint = await (0, base_js_1.createCheckpoint)(checkpoint, channels);
271
274
  this.checkpointer.put(config, checkpoint);
272
275
  }
@@ -342,7 +345,7 @@ pendingWrites, config, forStep) {
342
345
  const pendingWritesByChannel = {};
343
346
  // Group writes by channel
344
347
  for (const [chan, val] of pendingWrites) {
345
- for (const c in reserved_js_1.ReservedChannels) {
348
+ for (const c in reserved_js_1.ReservedChannelsMap) {
346
349
  if (chan === c) {
347
350
  throw new Error(`Can't write to reserved channel ${chan}`);
348
351
  }
@@ -355,7 +358,7 @@ pendingWrites, config, forStep) {
355
358
  }
356
359
  }
357
360
  // Update reserved channels
358
- pendingWritesByChannel[reserved_js_1.ReservedChannels.isLastStep] = [
361
+ pendingWritesByChannel[reserved_js_1.ReservedChannelsMap.isLastStep] = [
359
362
  forStep + 1 === config.recursionLimit,
360
363
  ];
361
364
  const updatedChannels = new Set();
@@ -57,6 +57,7 @@ export interface PregelOptions extends RunnableConfig {
57
57
  export type PregelInputType = any;
58
58
  export type PregelOutputType = any;
59
59
  export declare class Pregel extends Runnable<PregelInputType, PregelOutputType, PregelOptions> implements PregelInterface {
60
+ static lc_name(): string;
60
61
  lc_namespace: string[];
61
62
  channels: Record<string, BaseChannel>;
62
63
  output: string | Array<string>;
@@ -2,10 +2,10 @@
2
2
  import { Runnable, _coerceToRunnable, patchConfig, } from "@langchain/core/runnables";
3
3
  import { IterableReadableStream } from "@langchain/core/utils/stream";
4
4
  import { EmptyChannelError, createCheckpoint, emptyChannels, } from "../channels/base.js";
5
- import { CheckpointAt, emptyCheckpoint, } from "../checkpoint/base.js";
5
+ import { emptyCheckpoint, } from "../checkpoint/base.js";
6
6
  import { ChannelBatch, ChannelInvoke } from "./read.js";
7
7
  import { validateGraph } from "./validate.js";
8
- import { ReservedChannels } from "./reserved.js";
8
+ 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";
@@ -86,6 +86,9 @@ export class Channel {
86
86
  }
87
87
  }
88
88
  export class Pregel extends Runnable {
89
+ static lc_name() {
90
+ return "LangGraph";
91
+ }
89
92
  constructor(fields) {
90
93
  super();
91
94
  // Because Pregel extends `Runnable`.
@@ -251,7 +254,7 @@ export class Pregel extends Runnable {
251
254
  }
252
255
  // save end of step checkpoint
253
256
  if (this.checkpointer &&
254
- this.checkpointer.at === CheckpointAt.END_OF_STEP) {
257
+ this.checkpointer.at === "end_of_step" /* CheckpointAt.END_OF_STEP */) {
255
258
  checkpoint = await createCheckpoint(checkpoint, channels);
256
259
  this.checkpointer.put(config, checkpoint);
257
260
  }
@@ -261,7 +264,7 @@ export class Pregel extends Runnable {
261
264
  }
262
265
  }
263
266
  // save end of run checkpoint
264
- if (this.checkpointer && this.checkpointer.at === CheckpointAt.END_OF_RUN) {
267
+ if (this.checkpointer && this.checkpointer.at === "end_of_run" /* CheckpointAt.END_OF_RUN */) {
265
268
  checkpoint = await createCheckpoint(checkpoint, channels);
266
269
  this.checkpointer.put(config, checkpoint);
267
270
  }
@@ -336,7 +339,7 @@ pendingWrites, config, forStep) {
336
339
  const pendingWritesByChannel = {};
337
340
  // Group writes by channel
338
341
  for (const [chan, val] of pendingWrites) {
339
- for (const c in ReservedChannels) {
342
+ for (const c in ReservedChannelsMap) {
340
343
  if (chan === c) {
341
344
  throw new Error(`Can't write to reserved channel ${chan}`);
342
345
  }
@@ -349,7 +352,7 @@ pendingWrites, config, forStep) {
349
352
  }
350
353
  }
351
354
  // Update reserved channels
352
- pendingWritesByChannel[ReservedChannels.isLastStep] = [
355
+ pendingWritesByChannel[ReservedChannelsMap.isLastStep] = [
353
356
  forStep + 1 === config.recursionLimit,
354
357
  ];
355
358
  const updatedChannels = new Set();
@@ -58,7 +58,7 @@ class ChannelRead extends runnables_1.RunnableLambda {
58
58
  }
59
59
  }
60
60
  exports.ChannelRead = ChannelRead;
61
- const defaultRunnableBound = new runnables_1.RunnablePassthrough();
61
+ const defaultRunnableBound = /* #__PURE__ */ new runnables_1.RunnablePassthrough();
62
62
  class ChannelInvoke extends runnables_1.RunnableBinding {
63
63
  constructor(fields) {
64
64
  const { channels, triggers, when } = fields;
@@ -54,7 +54,7 @@ export class ChannelRead extends RunnableLambda {
54
54
  return read(this.channel);
55
55
  }
56
56
  }
57
- const defaultRunnableBound = new RunnablePassthrough();
57
+ const defaultRunnableBound = /* #__PURE__ */ new RunnablePassthrough();
58
58
  export class ChannelInvoke extends RunnableBinding {
59
59
  constructor(fields) {
60
60
  const { channels, triggers, when } = fields;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReservedChannels = void 0;
4
- var ReservedChannels;
5
- (function (ReservedChannels) {
6
- ReservedChannels["isLastStep"] = "isLastStep";
7
- })(ReservedChannels || (exports.ReservedChannels = ReservedChannels = {}));
3
+ exports.ReservedChannelsMap = void 0;
4
+ exports.ReservedChannelsMap = {
5
+ isLastStep: "isLastStep",
6
+ };
@@ -1,3 +1,3 @@
1
- export declare enum ReservedChannels {
2
- isLastStep = "isLastStep"
3
- }
1
+ export declare const ReservedChannelsMap: {
2
+ isLastStep: string;
3
+ };
@@ -1,4 +1,3 @@
1
- export var ReservedChannels;
2
- (function (ReservedChannels) {
3
- ReservedChannels["isLastStep"] = "isLastStep";
4
- })(ReservedChannels || (ReservedChannels = {}));
1
+ export const ReservedChannelsMap = {
2
+ isLastStep: "isLastStep",
3
+ };
@@ -63,7 +63,7 @@ function validateGraph({ nodes, channels, input, output, hidden, interrupt, }) {
63
63
  }
64
64
  }
65
65
  }
66
- for (const chan in reserved_js_1.ReservedChannels) {
66
+ for (const chan in reserved_js_1.ReservedChannelsMap) {
67
67
  if (!(chan in newChannels)) {
68
68
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
69
  newChannels[chan] = new last_value_js_1.LastValue();
@@ -1,5 +1,5 @@
1
1
  import { LastValue } from "../channels/last_value.js";
2
- import { ReservedChannels } from "./reserved.js";
2
+ import { ReservedChannelsMap } from "./reserved.js";
3
3
  export function validateGraph({ nodes, channels, input, output, hidden, interrupt, }) {
4
4
  const newChannels = channels;
5
5
  const subscribedChannels = new Set();
@@ -60,7 +60,7 @@ export function validateGraph({ nodes, channels, input, output, hidden, interrup
60
60
  }
61
61
  }
62
62
  }
63
- for (const chan in ReservedChannels) {
63
+ for (const chan in ReservedChannelsMap) {
64
64
  if (!(chan in newChannels)) {
65
65
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
66
  newChannels[chan] = new LastValue();
package/index.d.cts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/index.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -15,29 +15,35 @@
15
15
  "scripts": {
16
16
  "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
17
17
  "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests",
18
- "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rm -rf dist-cjs",
19
- "build:watch": "node scripts/create-entrypoints.js && tsc --outDir dist/ --watch",
20
- "build:scripts": "node scripts/create-entrypoints.js && node scripts/check-tree-shaking.js",
21
- "lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/ && dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts --",
22
- "lint:fix": "yarn lint --fix",
23
- "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
18
+ "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs",
19
+ "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch",
20
+ "build:scripts": "yarn create-entrypoints && yarn check-tree-shaking",
21
+ "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
22
+ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
23
+ "lint": "yarn lint:eslint && yarn lint:dpdm",
24
+ "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
25
+ "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn create-entrypoints -- --pre",
24
26
  "prepack": "yarn build",
25
27
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
26
28
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
27
29
  "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
28
30
  "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
29
- "format": "prettier --write \"src\"",
30
- "format:check": "prettier --check \"src\""
31
+ "format": "prettier --config .prettierrc --write \"src\"",
32
+ "format:check": "prettier --config .prettierrc --check \"src\"",
33
+ "move-cjs-to-dist": "yarn lc-build --config ./langchain.config.js --move-cjs-dist",
34
+ "create-entrypoints": "yarn lc-build --config ./langchain.config.js --create-entrypoints",
35
+ "check-tree-shaking": "yarn lc-build --config ./langchain.config.js --tree-shaking"
31
36
  },
32
37
  "author": "LangChain",
33
38
  "license": "MIT",
34
39
  "dependencies": {
35
- "@langchain/core": "^0.1.15"
40
+ "@langchain/core": "^0.1.22"
36
41
  },
37
42
  "devDependencies": {
38
43
  "@jest/globals": "^29.5.0",
39
44
  "@langchain/community": "^0.0.17",
40
45
  "@langchain/openai": "^0.0.12",
46
+ "@langchain/scripts": "~0.0",
41
47
  "@swc/core": "^1.3.90",
42
48
  "@swc/jest": "^0.2.29",
43
49
  "@tsconfig/recommended": "^1.0.3",
@@ -68,17 +74,29 @@
68
74
  },
69
75
  "exports": {
70
76
  ".": {
71
- "types": "./index.d.ts",
77
+ "types": {
78
+ "import": "./index.d.ts",
79
+ "require": "./index.d.cts",
80
+ "default": "./index.d.ts"
81
+ },
72
82
  "import": "./index.js",
73
83
  "require": "./index.cjs"
74
84
  },
75
85
  "./pregel": {
76
- "types": "./pregel.d.ts",
86
+ "types": {
87
+ "import": "./pregel.d.ts",
88
+ "require": "./pregel.d.cts",
89
+ "default": "./pregel.d.ts"
90
+ },
77
91
  "import": "./pregel.js",
78
92
  "require": "./pregel.cjs"
79
93
  },
80
94
  "./prebuilt": {
81
- "types": "./prebuilt.d.ts",
95
+ "types": {
96
+ "import": "./prebuilt.d.ts",
97
+ "require": "./prebuilt.d.cts",
98
+ "default": "./prebuilt.d.ts"
99
+ },
82
100
  "import": "./prebuilt.js",
83
101
  "require": "./prebuilt.cjs"
84
102
  },
@@ -89,11 +107,14 @@
89
107
  "index.cjs",
90
108
  "index.js",
91
109
  "index.d.ts",
110
+ "index.d.cts",
92
111
  "pregel.cjs",
93
112
  "pregel.js",
94
113
  "pregel.d.ts",
114
+ "pregel.d.cts",
95
115
  "prebuilt.cjs",
96
116
  "prebuilt.js",
97
- "prebuilt.d.ts"
117
+ "prebuilt.d.ts",
118
+ "prebuilt.d.cts"
98
119
  ]
99
120
  }
package/prebuilt.d.cts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/prebuilt/index.js'
package/pregel.d.cts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/pregel/index.js'