generative-a11y
Core

createRuntime

Create the core runtime that turns app events into well-timed AnnouncementIntent objects and useful debugging details.

Signature and import

Create one runtime for your app or for each conversation that needs separate settings. Connect delivery before sending events that can produce output.

import { createRuntime } from "@generative-a11y/core";

const runtime = createRuntime({
  preset: "balanced",
  onAnnouncement(intent) {
    deliver(intent);
  },
});

Walkthrough

Import the constructor

Import createRuntime from the package root.

Choose a preset

Presets supply default behavior. policy changes only the settings you provide.

Connect output

onAnnouncement registers the first listener. Browser apps usually use bindRuntime instead.

Prop

Type

RuntimeOptions

Options are read during construction. Nested policy overrides merge with the selected preset.

Prop

Type

Runtime methods

Runtime methods are synchronous. Unsubscribe functions and dispose are idempotent.

Prop

Type

Complete response lifecycle

Each delta contains only new text. A completed event announces useful text that is still waiting, then closes the response.

const accepted = runtime.dispatch({
  type: "response.started",
  responseId: "report-1",
});

runtime.dispatch({
  type: "response.text.delta",
  responseId: "report-1",
  delta: "The migration completed successfully.",
});

runtime.dispatch({
  type: "response.completed",
  responseId: "report-1",
});

console.log({ accepted, pending: runtime.pendingCount() });
runtime.dispose();

Walkthrough

Start the response

Send response.started before text or final events for this responseId.

Send new text

Each delta contains only the text added since the last event.

Finish the response

Completion announces useful text that is still waiting and cancels response timers.

Clean up

Call dispose when the app no longer needs the runtime.

Evidence and testing note

AnnouncementIntent describes an update prepared by core. Test with a real screen reader to confirm what it speaks.

Localized announcements

See catalogs and adapter copy for the typed messages and copy options, language ownership, validation, construction lifetime, and replay requirements. Existing lifecycle evidence and timing remain unchanged.