injectAgent
Injects the AG-UI agent from Angular's dependency injection container.
Use this in components or services provided via provideAgent() (or
provideFakeAgent()).
Returns an AgUiAgent — the runtime-neutral Agent contract plus the
AG-UI-specific customEvents signal — so customEvents is reachable
directly, without casting.
Typed state via AgentRef. Pass the same ref that was supplied to
provideAgent(ref, …) to carry the state type through DI without repeating
the generic at every call site. The no-arg form defaults to
AgUiAgent<Record<string, unknown>>.
import { injectAgent } from '@threadplane/ag-ui';Declaration · overload 1
export declare function injectAgent(): AgUiAgent;Returns
AgUiAgentExamples
Typed state via AgentRef
const agent = injectAgent(TRIP); // AgUiAgent<TripState>Declaration · overload 2
Type parameters
T
Parameters
ref· requiredAgentRef<T>
Returns
AgUiAgent<T>