LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Getting started
  • injectStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • Dependency injection
  • Type safety
  • Migrating to v1
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewGetting startedinjectStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsDependency injectionType safetyMigrating to v1
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/angularType safety

Type safety

@langchain/angular is designed around agent-brand inference: pass typeof agent to the hook and get typed state, tool calls, and (for DeepAgents) subagent state maps back. Plain state generics still work for graphs that aren't built with the agent helpers.

Agent-brand inference

Pass typeof agent to infer state, tool-call union, and (for DeepAgents) subagent state map:

import { Component } from "@angular/core";
import type { agent } from "./agent";
import { injectStream } from "@langchain/angular";

@Component({
  /* ... */
})
export class ChatComponent {
  readonly stream = injectStream<typeof agent>({
    assistantId: "agent",
    apiUrl: "http://localhost:2024",
  });

  // stream.values() is inferred
  // stream.toolCalls() is a discriminated union of your tools
  // stream.subagents() carries discovery snapshots
}

The same inference works on injectStream<typeof agent>() and on the companion selector injectors when you pass a scoped target:

const messages = injectMessages(stream); // BaseMessage[]
const tools = injectToolCalls<typeof agent>(stream);
const state = injectValues<typeof agent>(stream);

Custom state types

For plain state shapes, pass the state directly. The second and third generic slots are InterruptType and ConfigurableType:

import { injectStream } from "@langchain/angular";
import type { BaseMessage } from "@langchain/core/messages";

interface MyState {
  messages: BaseMessage[];
  context?: string;
}

readonly stream = injectStream<MyState, { question: string }>({
  assistantId: "my-graph",
  apiUrl: "http://localhost:2024",
});

Passing the Stream Handle

Use the Angular-facing StreamApi<T> name when you need to annotate a stream handle in Angular app or library code. UseStreamReturn<T> and UseStreamResult<T> describe the same handle shape, but are mainly useful in shared utilities that intentionally use React-style naming.

  • StreamApi<T> — preferred Angular name for the fully resolved return type of injectStream, provideStream, useStream, and StreamService.
  • UseStreamReturn<T> — same stream handle shape, useful for utilities shared with other frontend packages.
  • AnyStream — type-erased handle. Use when the child only forwards stream into selector injectors and doesn't care about the underlying state shape.
import type { AnyStream, StreamApi, UseStreamReturn } from "@langchain/angular";
import type { agent } from "./agent";

function acceptsAngularStream(stream: StreamApi<typeof agent>) {
  return stream.values();
}

function acceptsSharedStream(stream: UseStreamReturn<typeof agent>) {
  return stream.messages();
}

function passThroughToSelectors(
  stream,
  subgraph,
}: {
  stream: AnyStream;
  subgraph: SubgraphDiscoverySnapshot;
}) {
  return injectValues(stream, subgraph);
}

Type helpers

Helper Use
InferStateType<T> Unwraps a compiled graph / agent brand / agent tool array into its state shape.
InferToolCalls<T> Derives a discriminated union of tool-call shapes.
InferToolOutput<T> Derives a single tool's output type.
InferSubagentStates<T> { name: State, … } map derived from a DeepAgent brand.
WidenUpdateMessages<T> Widens messages so both wire-format and BaseMessage instances typecheck in submit().
StreamSubmitOptions<State, Configurable> Options shape accepted by submit().
AgentServerAdapter / HttpAgentServerAdapter Custom-transport interface + convenience class. See Transports.
SelectorTarget / SubagentDiscoverySnapshot / SubgraphDiscoverySnapshot For components that render scoped views. See Selectors / Subagents.
AssembledToolCall, ToolCallStatus For rendering tool-call UI.
MessageMetadata, UseSubmissionQueueReturn, SubmissionQueueEntry Companion-hook return shapes. See Selectors.

API reference

Interfaces

Interface

UseStreamReturn

Return shape of useStream — the Angular StreamApi.

Interface

StreamSubmitOptions

Interface

AssembledToolCall

Reactive tool handle for framework bindings (stream.toolCalls,

Interface

MessageMetadata

Metadata tracked per message id. Surfaced to applications via

Types

Type

InferStateType

Unwrap the state shape from a compiled graph, a create-agent brand,

Type

InferToolCalls

Infer the discriminated union of AssembledToolCall handles

Type

InferSubagentStates

Infer the subagent → state map from a DeepAgent brand. Non-brands

Type

WidenUpdateMessages

Widen an update type so its messages field also accepts

Type

StreamApi

Convenience alias — the fully-resolved return type of

Type

UseStreamResult

React-compatible alias for the fully-resolved stream handle type.

Type

AnyStream

Erased handle useful as a parameter type for helper components that

Type

ToolCallStatus

High-level outcome of a single tool call.

Type

ToolCallState

The lifecycle state of a tool call.

Type

DefaultToolCall

Default tool call type when no specific tool definitions are provided.

Type

ToolCallsFromTools

Infer a union of tool call types from an array of tools.

Type

MessageMetadataMap

Read-only map exposed via MessageMetadataTracker.store.