Custom actions¶
Custom actions extend the same TypeScript registry used by built-ins. Register
a handler with registerAction(type, handler), then invoke it only through
engine.dispatch(type, payload). The handler receives the Engine and payload;
it may return a value. If it mutates state, use the Engine's normal dispatch
path and keep document values JSON-serializable.
import { registerAction } from "./engine/actions.js";
registerAction("custom:announce", (_engine, payload) => payload);
const result = await engine.dispatch("custom:announce", { text: "ready" });
unregisterAction(type) removes a registry entry. Registering an existing type
overwrites it with a warning, so use names that belong to your application.