Skip to main content
onEvents(listener, opts?): () => void
Subscribe to the agent’s event stream (attach mode with "events" subscribed). Events arrive in seq order; pass { from } to receive only events with seq >= from. Returns an unsubscribe function. Parameters Returns () => void

The Event Stream

Each this.events.emit on the agent arrives as one AgentEvent. The first connection replays the events the agent retains. Without resume, every reconnect replays them again. A listener then receives earlier events more than once. A listener receives only the events that arrive after it is added. The client keeps no copy of past events.

AgentEvent

One item of the agent’s event stream, as delivered to onEvents listeners. Properties at
readonly at: Date
Wall-clock stamp at emit time; informational (ordering is by seq).
payload
readonly payload: unknown
The event’s payload, exactly as the agent emitted it.
seq
readonly seq: number
Monotonic position in the event stream; also the resume cursor.
type
readonly type: string
The event kind the agent chose when emitting (e.g. "progress").