@threadplane/ag-uiInterfacev0.3.4

AgUiAgent

The neutral Agent contract, widened with the AG-UI adapter's customEvents signal (the chat composition feature-detects it to enable live a2ui streaming), the browser client-tools capability, and concrete ACTIVITY-backed subagents. Mirrors langgraph's LangGraphAgent extension where the protocol surfaces overlap.

import type { AgUiAgent } from '@threadplane/ag-ui';

Declaration

export interface AgUiAgent<TState = Record<string, unknown>> extends Agent<TState>  {
  clientTools: ClientToolsCapability;
  customEvents: Signal<CustomStreamEvent[]>;
  dispose(): void;
  interruptSession: Signal<InterruptSessionSnapshot>;
  rawEvents$: Observable<BaseEvent>;
  ready: Promise<void>;
  reconcileInterrupt(): Promise<void>;
  subagents: Signal<Map<string, Subagent>>;
  submit(input: AgentSubmitInput, opts?: AgUiSubmitOptions): Promise<void>;
}

Type parameters

TState
Default: Record<string, unknown>

Members

clientTools

clientTools: ClientToolsCapability;

customEvents

customEvents: Signal<CustomStreamEvent[]>;

dispose · overload 1

Unsubscribe and stop local work. Does not cancel backend checkpoints.

dispose(): void;

Returns

void

interruptSession

Full interrupt batch and its request ownership phase.

interruptSession: Signal<InterruptSessionSnapshot>;

rawEvents$

Every AG-UI protocol event the adapter reduced into its signals, in arrival order, for hosts that fold the full stream into their own view model.

Emits exactly the events the signals saw: events from a superseded run, events after a run was stopped or failed, and events after a terminal outcome are suppressed here too. Each event is emitted after the signals are updated for it. A run's terminal RUN_ERROR is always emitted once, after error() and status() settle. Where provideAgent() protects operation errors, the emitted RUN_ERROR honours the same protection as error(): it carries only the generic message, with the server's message, code and payload dropped. Hot and unbuffered — subscribe before submitting to see a whole run. Completes on dispose().

Hydration from a configured replay source emits every replayed event, in order, once the whole replay has been folded into the signals; subscribe before awaiting ready to see them. Hydration from persistence restores a committed snapshot rather than replaying protocol events, so nothing is emitted for it; read the hydrated messages() and state() instead.

rawEvents$: Observable<BaseEvent>;

ready

Resolves after replayed or persisted thread state is hydrated; actions wait for it.

ready: Promise<void>;

reconcileInterrupt · overload 1

Recover an uncertain attempt using the configured authoritative reconciler, adopting whatever it reports — including an acknowledged answer that only proves the resume was started. The imperative escape hatch; prefer the base contract's checkStatus for the control offered to a user when error().recovery === 'check', which settles only on a conclusive answer.

reconcileInterrupt(): Promise<void>;

Returns

Promise<void>

subagents

Subagent activities (activityType==='subagent') projected to the neutral Subagent contract, keyed by messageId. Narrows the base Agent's optional subagents? to a concrete signal for AG-UI consumers.

subagents: Signal<Map<string, Subagent>>;

submit · overload 1

submit(input: AgentSubmitInput, opts?: AgUiSubmitOptions): Promise<void>;

Parameters

input · required
AgentSubmitInput
opts · optional
AgUiSubmitOptions

Returns

Promise<void>