AgentConnection
Defined in: packages/engine/src/lib/agent-session/connection.ts:78
One connection’s ordered Agent Session event stream.
Capacity is bounded per connection:
- At most 32 utterances are pending, including the one being planned or
awaiting acknowledgement. A further utterance receives an
errorevent with codequeue_fulland is not remembered, so it can be sent again. - At most 4,096 input IDs are remembered, with no eviction, so a repeated
input is always ignored. After that, a new utterance receives an
errorevent with codesession_capacity. The host must open a new connection to continue. - Each UI change waits for acknowledgement for at most
OpenConnectionOptions.acknowledgementTimeoutMs, 30 seconds by
default. On the UI-only route a timeout fails the run and cancels queued
work. On an agent connection a timeout of a
change_screenchange answers the goals that depend on itunknown, leaves a goal with a clarification verdict atneeds_clarification, and lets the next queued Screen Change start.
The agent loop is experimental in 0.3 and may change in any minor release.
Methods
Section titled “Methods”close()
Section titled “close()”close():
void
Defined in: packages/engine/src/lib/agent-session/connection.ts:92
Aborts pending work and releases listeners. Idempotent; no later events are emitted.
Returns
Section titled “Returns”void
send()
Section titled “send()”send(
input):Promise<void>
Defined in: packages/engine/src/lib/agent-session/connection.ts:88
Accepts untrusted input. An utterance resolves according to its route:
the UI-only route resolves when it emits ui_change, before the later
ui_applied; an Agent Run route resolves when the run finishes, so a
change_screen call can keep it pending until ui_applied or the
acknowledgement timeout. Sends queued behind earlier work can also
remain pending. Input sent after close() is dropped without an event or
a diagnostic.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”Promise<void>
subscribe()
Section titled “subscribe()”subscribe(
listener): () =>void
Defined in: packages/engine/src/lib/agent-session/connection.ts:90
Observes future events in emission order. Returns an unsubscribe function; there is no replay.
Parameters
Section titled “Parameters”listener
Section titled “listener”(event) => void
Returns
Section titled “Returns”() => void