feat(langgraph): expose all channels under @langchain/langgraph/channels (#1613)

This commit is contained in:
David Duong
2025-09-08 19:15:54 +02:00
committed by GitHub
parent cfbbb4ec61
commit 20f1d641ad
9 changed files with 40 additions and 16 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@langchain/langgraph": patch
---
Channels are now part of the public API, allowing users to customise behaviour of checkpointing per channel (#976)
+11
View File
@@ -113,6 +113,17 @@
},
"input": "./src/web.ts"
},
"./channels": {
"import": {
"types": "./dist/channels/index.d.ts",
"default": "./dist/channels/index.js"
},
"require": {
"types": "./dist/channels/index.d.cts",
"default": "./dist/channels/index.cjs"
},
"input": "./src/channels/index.ts"
},
"./pregel": {
"import": {
"types": "./dist/pregel/index.d.ts",
-2
View File
@@ -6,8 +6,6 @@ import { BaseChannel } from "./base.js";
*
* Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values
* will be continuously overwritten.
*
* @internal
*/
export class AnyValue<Value> extends BaseChannel<Value, Value, Value> {
lc_graph_name = "AnyValue";
@@ -20,7 +20,6 @@ function isWaitForNames<Value>(
* - in the "waiting" state it collects named values until all are received.
* - once all named values are received, it can be read once, and it switches
* back to the "priming" state.
* @internal
*/
export class DynamicBarrierValue<Value> extends BaseChannel<
void,
@@ -1,9 +1,8 @@
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
import { BaseChannel } from "./index.js";
import { BaseChannel } from "./base.js";
/**
* Stores the value received in the step immediately preceding, clears after.
* @internal
*/
export class EphemeralValue<Value> extends BaseChannel<Value, Value, Value> {
lc_graph_name = "EphemeralValue";
+12 -7
View File
@@ -3,12 +3,17 @@ export {
createCheckpoint,
emptyChannels as empty,
} from "./base.js";
export { type BinaryOperator, BinaryOperatorAggregate } from "./binop.js";
export type { AnyValue } from "./any_value.js";
export type {
WaitForNames,
export type { BinaryOperator } from "./binop.js";
export { AnyValue } from "./any_value.js";
export { LastValue, LastValueAfterFinish } from "./last_value.js";
export {
type WaitForNames,
DynamicBarrierValue,
} from "./dynamic_barrier_value.js";
export type { LastValue } from "./last_value.js";
export type { NamedBarrierValue } from "./named_barrier_value.js";
export type { Topic } from "./topic.js";
export { BinaryOperatorAggregate } from "./binop.js";
export { EphemeralValue } from "./ephemeral_value.js";
export {
NamedBarrierValue,
NamedBarrierValueAfterFinish,
} from "./named_barrier_value.js";
export { Topic } from "./topic.js";
@@ -62,7 +62,6 @@ export class LastValue<Value> extends BaseChannel<Value, Value, Value> {
/**
* Stores the last value received, but only made available after finish().
* Once made available, clears the value.
* @internal
*/
export class LastValueAfterFinish<Value> extends BaseChannel<
Value,
@@ -9,7 +9,6 @@ export const areSetsEqual = <T>(a: Set<T>, b: Set<T>) =>
*
* This ensures that if node N and node M both write to channel C, the value of C will not be updated
* until N and M have completed updating.
* @internal
*/
export class NamedBarrierValue<Value> extends BaseChannel<
void,
+11 -2
View File
@@ -2,7 +2,7 @@ import { EmptyChannelError } from "../errors.js";
import { BaseChannel } from "./base.js";
/**
* @internal
* A configurable PubSub Topic.
*/
export class Topic<Value> extends BaseChannel<
Array<Value>,
@@ -19,7 +19,16 @@ export class Topic<Value> extends BaseChannel<
values: Value[];
constructor(fields?: { unique?: boolean; accumulate?: boolean }) {
constructor(fields?: {
/**
* Whether to only add unique values to the topic. If `true`, only unique values (using reference equality) will be added to the topic.
*/
unique?: boolean;
/**
* Whether to accumulate values across steps. If `false`, the channel will be emptied after each step.
*/
accumulate?: boolean;
}) {
super();
this.unique = fields?.unique ?? this.unique;