Angular SDK for building AI-powered applications with Deep Agents, LangChain and LangGraph.
The package ships a Signals-first API built on top of the v2 streaming
protocol. injectStream returns a small, always-on root handle
(values, messages, isLoading, error, …) and pushes anything
namespaced (subagents, subgraphs, media, submission queue, per-message
metadata) behind ref-counted inject* selectors so components
only pay for data they actually consume.
Upgrading from
0.x? Seedocs/v1-migration.mdfor the complete matrix of option, return-shape, and transport changes.
npm install @langchain/angular @langchain/core
Peer dependencies: @angular/core (^18.0.0 – ^21.0.0),
@langchain/core (^1.1.27).
import { Component } from "@angular/core";
import { injectStream } from "@langchain/angular";
@Component({
standalone: true,
template: `
<div>
@for (msg of stream.messages(); track msg.id ?? $index) {
<div>{{ str(msg.content) }}</div>
}
<button
[disabled]="stream.isLoading()"
(click)="onSubmit()"
>
Send
</button>
</div>
`,
})
export class ChatComponent {
readonly stream = injectStream({
assistantId: "agent",
apiUrl: "http://localhost:2024",
});
str(v: unknown) {
return typeof v === "string" ? v : JSON.stringify(v);
}
onSubmit() {
void this.stream.submit({
messages: [{ type: "human", content: "Hello!" }],
});
}
}
injectStream must be called from an Angular injection context —
the host's DestroyRef owns the stream, so navigating away destroys
the controller automatically.
Signal<T>s you call as
functions in templates.transport: "websocket"
opt-in) or a custom backend through an AgentServerAdapter.injectMessages, injectValues,
injectToolCalls, media selectors, submission queue — the first
consumer opens a subscription, the last one's DestroyRef closes
it. Components pay only for what they render.submit({ forkFrom }) replaces the legacy branch /
fetchStateHistory trio.provideStream for subtree sharing,
provideStreamDefaults for app-wide config, StreamService for
class-based wrappers.typeof agent as the first generic —
state, tool args, and per-subagent state flow through to every
selector.Use StreamApi<T> when you need to name the return type of
injectStream, useStream, provideStream, or StreamService in
Angular code. It is the Angular-facing alias for the Signals-first
handle.
UseStreamResult<T> is also exported as a React-compatible alias for
the same shape. Prefer it only in shared utilities that are designed to
accept stream handles from multiple framework packages.
In-depth guides live under docs/:
inject-stream.md — options + return-shape referencetransports.md — SSE, WebSocket, and custom AgentServerAdaptercustom-transport.md — implementing AgentServerAdapter against your own backend, with a worked walkthrough of examples/ui-react-transportselectors.md — scoped reads (injectMessages, injectValues, media, channels, …)interrupts.md — handling and responding to interruptsbranching.md — forking via injectMessageMetadata + submit({ forkFrom })submission-queue.md — injectSubmissionQueue and multitaskStrategy: "enqueue"headless-tools.md — browser-side tool implementationssubagents-subgraphs.md — discovery snapshots and scoped contentdependency-injection.md — provideStream, provideStreamDefaults, StreamServicetype-safety.md — generics, agent inference, and public stream aliasestesting.md — STREAM_INSTANCE fakes and service overridesv1-migration.md — migrating from 0.xFor complete end-to-end examples, visit the LangChain UI Playground.
MIT
Strip headless-tool interrupts from a user-facing interrupt list.
Execute and resume all newly seen headless-tool interrupts from a values
Subscribe to a scoped audio-media stream. Each handle is yielded
Side-effect counterpart to injectChannel. Instead of
Subscribe to a custom:<name> stream extension — the most recent
Subscribe to a scoped file-media stream. Pair with
Subscribe to a scoped image-media stream. Pair with
Resolve the lazy MediaBase.objectURL promise into a string
Read metadata recorded for a specific message id — today exposes
Subscribe to a scoped messages stream.
Angular-side primitive that composes ChannelRegistry.acquire
Angular entry point for the v2-native stream runtime.
Subscribe to a scoped tools (tool-call) stream. Same target and
Subscribe to a scoped values stream — the most recent state
Subscribe to a scoped video-media stream. Pair with
Parses a headless-tool interrupt value from the graph. Accepts both
Creates a provider for a shared useStream instance at the component level.
Provides default LangGraph configuration at the application level.
Framework-free factory that constructs a StreamController