import { ... } from "@langchain/langgraph-sdk/client";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 clients.
Returns whether an event should be delivered for a subscription definition.
Get the API key from the environment. Precedence:
Public v1 name for TransportAdapter plus optional high-level
capabilities. Renamed to reflect that this interface now denotes the
full agent-server protocol contract (not merely wire transport):
any object that satisfies it can back a useStream call. See
plan-custom-transport.md §4 for the rollout.
The extra optional methods let adapters surface thread state and
history without the framework needing to issue a parallel HTTP
request — useStream.hydrate() calls getState?() when present
and falls back to client.threads.getState otherwise. Adapters
that don't know how to produce these values can simply omit them.
The legacy TransportAdapter export is retained for back-compat and
resolves to the same structural type; new code should prefer
AgentServerAdapter.
Typed error thrown through media.stream / rejected from
media.blob / media.objectURL when a handle fails before its
message completes. Carries the bytes accumulated up to the failure
point on partialBytes for callers that want to salvage or diagnose.
Incrementally assembles messages events into complete message objects.
Error wrapper for protocol-level error responses returned by the server.
Transport adapter that speaks the thread-centric protocol over HTTP
commands plus SSE event streams. Bound to a specific threadId
at construction. Each openEventStream call opens an independent
filtered SSE connection via POST /threads/:thread_id/stream/events.
Transport adapter that speaks the thread-centric protocol over a
bidirectional WebSocket. Bound to a specific threadId — the socket
connects to ws://.../threads/:thread_id/stream/events.
Async iterable handle for raw event subscriptions.
An optional transform maps each incoming event before it is queued
or delivered to a waiting consumer. This is used by named custom
channel subscriptions (e.g. "custom:a2a") to unwrap the payload
so callers receive the raw emitted data instead of the protocol
event envelope.
High-level wrapper around a protocol connection to a specific thread.
In the thread-centric protocol, threads are durable (backed by
checkpoints) and connections are ephemeral. A ThreadStream is the
client-side handle for interacting with a thread: starting runs,
subscribing to events, consuming assembled projections (messages,
values, toolCalls, etc.), and responding to interrupts.
Construct via client.threads.stream(threadId?, { assistantId? }).
Modules exposed by the high-level ThreadStream wrapper.
Public v1 name for TransportAdapter plus optional high-level
capabilities. Renamed to reflect that this interface now denotes the
full agent-server protocol contract (not merely wire transport):
any object that satisfies it can back a useStream call. See
plan-custom-transport.md §4 for the rollout.
The extra optional methods let adapters surface thread state and
history without the framework needing to issue a parallel HTTP
request — useStream.hydrate() calls getState?() when present
and falls back to client.threads.getState otherwise. Adapters
that don't know how to produce these values can simply omit them.
The legacy TransportAdapter export is retained for back-compat and
resolves to the same structural type; new code should prefer
AgentServerAdapter.
Mutable view of a streamed message as message and content-block events are assembled into a single structure.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Configuration for BaseClient and the exported LangGraph SDK Client.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Dispatch callbacks receive a freshly-started handle on its first
matching content-block-start. Exactly one callback fires per
(messageId, blockType) pair.
Dispatch callbacks receive a freshly-started handle on its first
matching content-block-start. Exactly one callback fires per
(messageId, blockType) pair.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Remote counterpart of an in-process run.extensions.<name> projection.
Each extension is the client-side view of a compile-time
StreamTransformer projection. The server auto-forwards named
StreamChannel.remote(name) outputs on the custom:<name> channel, and
this handle exposes them via two dual interfaces:
AsyncIterable<T> — iterate every item pushed by a streaming
transformer (e.g. a StreamChannel).PromiseLike<T> — await resolves with the final value observed
when the run terminates. For streaming transformers this is the
last item pushed; for final-value transformers it is the single
value emitted on run end.Subscribing is lazy: the underlying custom:<name> subscription is
opened on first property access and cached.
Options for ThreadStream construction.
Transport abstraction implemented by concrete client transports such as WebSocket or SSE adapters.
In the thread-centric protocol, transports are bound to a specific thread at construction time — the thread ID is part of the connection URL.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Emitted by MessageAssembler.consume() to describe how a message changed in
response to a single protocol event.
Accepted values for ThreadStreamOptions["transport"].
fetch / webSocketFactory tune that path.Built-in wire transport used by ThreadStream.
"sse": HTTP commands + one SSE event stream per subscription.
Works in browsers without extra setup."websocket": single bidirectional WebSocket. Lower overhead for
long-lived, multi-subscription sessions.Kinds of failure that can terminate a media handle prematurely.
"message-error" — the upstream message emitted an error event
before completion."stream-closed" — the transport stream closed before
message-finish arrived (thread closed, transport dropped, etc.)."fetch-failed" — the block was url-sourced and the lazy
fetch() rejected (CORS, 404, 5xx, network).Block types this assembler knows how to reassemble into media handles.
Keyed map of ThreadExtension handles, typed off a declared transformer projection shape.
Used as the return type of ThreadStream.extensions. TExtensions
is expected to match the in-process run.extensions shape (i.e. the
output of InferExtensions<TTransformers> from
@langchain/langgraph); each value type is unwrapped via
UnwrapExtension so thread.extensions.foo resolves with the
transformer's emitted payload, not the in-process Promise<T> /
StreamChannel<T> wrapper.
Access any string key to obtain a ThreadExtension<unknown>; keys
that appear in TExtensions narrow to their declared payload type.
Unwrap a single in-process projection value to its observable payload type:
Promise<T> / PromiseLike<T> → T (final-value transformers)StreamChannel<T> / AsyncIterable<T> → T (streaming transformers)This lets a ThreadStream<TExtensions> generic accept the same shape
that graph.streamEvents(..., { version: "v3" }) returns in-process
(via InferExtensions<TTransformers> from @langchain/langgraph),
without forcing users to redeclare payload types on the remote side.