createRuntime
Create a runtime that turns application events into announcement intents.
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({
onAnnouncement(intent) {
console.log(intent.text);
},
});Browser apps usually connect output with bindRuntime.
Use onAnnouncement when your app owns another delivery mechanism.
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() });
// Call when the owning surface is removed, after delivery is no longer needed.
function disposeRuntime() {
runtime.dispose();
}Send response.started before deltas or terminal events for that response.
Completion cancels response timers; call dispose() when the runtime owner
ends.
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.