Marker interface for transformers provided by internal LangChain products (e.g. ReactAgent's ToolCallTransformer, DeepAgent's SubagentTransformer).
Native transformers differ from user-defined extension transformers in where their projection lands on the run stream:
Native — projections become direct getters on a
GraphRunStream subclass (e.g. run.toolCalls, run.subagents).
They emit events on protocol-defined channels (tools, lifecycle,
tasks, etc.).
Extension (user-defined) — projections are merged into
run.extensions. Events emitted via emit() use an
application-chosen method name (e.g. emit("a2a", data)) and are
accessible to remote clients via session.subscribe("custom:<name>").
The __native brand is used by downstream stream factory functions
to distinguish native transformers from extension transformers at
registration time. See docs/native-stream-transformers.md for the
full pattern.
interface NativeStreamTransformerStreamTransformer<TProjection>Mark the channel as failed after all buffered items are consumed.
Called once when the underlying Pregel run completes without throwing. Optional — only needed for non-channel teardown (e.g. resolving promises).
May return a PromiseLike<void> to defer the main event log close
until the async work (e.g. emitting terminal lifecycle events) has
completed. The mux awaits all returned promises before closing its
event log.
Called once before the run starts.
Optional hook invoked by StreamMux.addTransformer immediately
after the transformer is attached to the mux. Receives a limited
handle that exposes only StreamEmitter.push — enough for
the transformer to emit synthesized ProtocolEvents on any
namespace it chooses (e.g. a deepagents SubagentTransformer
fabricating lifecycle/messages/values events under a
["tools:<tool_call_id>"] namespace when a task tool starts).
Transformers that do not synthesize events can omit this hook.
The StreamEmitter handle is only safe to call from within
StreamTransformer.process. Emitting from an unrelated async
context (e.g. after process has returned, from a setTimeout,
etc.) races with the mux's close/fail cycle and may land events in
an already-closed log.
Called for each ProtocolEvent before it is appended to the main log.
Mark the channel as failed after all buffered items are consumed.
Called once when the underlying Pregel run completes without throwing.
Called once before the run starts.
Optional hook invoked by StreamMux.addTransformer immediately
Called for each ProtocolEvent before it is appended to the main log.