import { ... } from "@langchain/langgraph/stream";Maps a protocol event method to its subscription Channel.
Returns undefined for unrecognized methods so that new server-side
channels (e.g. from extension transformers) don't break existing
subscribers. The custom method resolves to the named custom:<name>
channel when the payload carries a name, otherwise the bare custom
channel. Both "input" and the wire-level "input.requested" map to the
input channel.
Whether namespace starts with prefix.
Segments are compared literally first; if the prefix segment itself contains
no :, the candidate segment is also compared after its dynamic suffix is
stripped (see normalizeNamespaceSegment). This mirrors
is_prefix_match in api/langgraph_api/protocol/namespace.py so server-side
filtering and client-side per-subscription narrowing stay consistent.
@langchain/langgraph/stream ā backend toolkit for the v2 streaming protocol.
This entrypoint collects the primitives needed to build a custom transport or server on top of the Agent Streaming Protocol:
streamEvents (v3) payloads
into canonical ProtocolEvents.since replay cursor).These are intentionally transport-agnostic: pair them with SSE, WebSocket, or any custom framing to expose a graph over the protocol.
Whether value names a protocol subscription channel ā either a base
channel ("messages", "values", ā¦) or a named custom channel
("custom:<name>"). Unknown/future method names return false,
mirroring inferChannel.
Returns whether an event should be delivered for a subscription definition.
When the definition carries a since replay cursor, events at or before
that sequence number are excluded ā letting the same predicate drive both
live fan-out and buffered replay over a StreamChannel.
Strip dynamic suffixes (after :) from a namespace segment.
Server-emitted namespaces contain runtime-generated suffixes like
"fetcher:abc-uuid", while user-supplied subscription filters are typically
static names ("fetcher"). Mirrors normalize_namespace_segment in
api/langgraph_api/protocol/namespace.py.
True when payload is a lightweight checkpoint envelope (not a full-state
Pregel checkpoints debug payload).
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remote or new StreamChannel(name) are also
auto-forwarded to remote clients.
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remote or new StreamChannel(name) are also
auto-forwarded to remote clients.
Minimal protocol-event shape consumed by inferChannel and matchesSubscription.
Both the core ProtocolEvent and the wire-level Event from
@langchain/protocol structurally satisfy this contract, so the same
predicates can drive in-process fan-out, buffered replay, and server-side
(SSE / WebSocket) event-sink filtering without coupling to a single event
type.
Single envelope for a streaming protocol emission: sequence, channel
(method), and payload (params).
Channels that can appear on a protocol event. Beyond the raw
StreamMode channels emitted by the Pregel stream, the v2
protocol layer synthesizes additional channels (e.g. lifecycle,
input) via built-in StreamTransformers and exposes
user-defined channels created with StreamChannel.
Hierarchical path identifying a position in the agent tree.
Each element is one segment; longer arrays mean deeper nesting (e.g. subgraph or multi-agent scopes).
The set of stream modes requested by
streamEvents(..., { version: "v3" }) ā every mode the protocol maps
to a channel.
The verbose "debug" mode is intentionally excluded: it was a thin
re-wrap of checkpoints + tasks carrying no new information.
The "checkpoints" mode is likewise excluded from the stream-mode
request because the protocol's checkpoints channel carries only a
lightweight envelope (id, parent_id, step, source) emitted as a
separate [namespace, "checkpoints", envelope] chunk before each paired
values chunk ā not the full-state shape from Pregel's checkpoints
stream mode when subscribed via debug.