assistant-ui

bindThreadRuntime

Connect one assistant-ui ThreadRuntime and send its public events to a core runtime supplied by your app.

Signature and import

Create one binding per thread scope and dispose it when that subscription owner unmounts.

typescript
import { bindThreadRuntime } from "@generative-a11y/assistant-ui";

const binding = bindThreadRuntime({
  runtime,
  scopeId: "support-thread",
  thread,
  maxTrackedEntities: 1_000,
});

// Removes only the subscription and adapter state.
binding.dispose();

How this code works

  1. 01
    Use the app runtime

    ThreadBinding sends events to core without disposing your runtime.

  2. 02
    Separate thread IDs

    scopeId prevents ID collisions across mounted conversations.

  3. 03
    Read public thread state

    ThreadBinding needs only getState and subscribe from ThreadRuntime.

  4. 04
    Dispose the binding

    dispose removes the subscription without changing the thread runtime.

Options and return values

runtimePick<GenerativeA11yRuntime, 'dispatch'>Required

Receives adapter events while remaining under your app's control.

Default
n/a
scopeIdstringRequired

Stable non-empty namespace for message, tool, approval, and citation identity.

Default
n/a
threadThreadRuntimeSourceRequired

Borrowed getState and subscribe surface from assistant-ui.

Default
n/a
maxTrackedEntitiesnumberOptional

Bounds message, part, tool, and approval identity tracking.

Default
1000
returnThreadBindingReturn

An idempotent dispose method for the adapter subscription.

Default
n/a

Events reported from thread state

Each public thread snapshot is compared with its previous value, and confirmed changes become events.

assistant-ui stategenerative-a11y eventSource
Assistant message starts runningresponse.startedPublic message state
Text growsresponse.text.deltaNew text only
Message finishes, stops, or failscompleted, interrupted, failedPublic message status
Tool call and result partstool lifecyclePublic content parts
Approval stateapproval requested or resolvedPublic content parts
Source partscitation.availableOptional content parts