# @crema/action-bus The "anything can drive the UI" command bus. One dispatch point for LLM tool calls, scripts, and (optional) remote control over WebSocket — all funnel through the same handlers, run against the same DOM contract. Pairs with [`lib-aifirst-shell-ui`](https://git.sky-ai.com/CremaUIStudio/lib-aifirst-shell-ui) which provides a `[data-action]`-tagged shell. Non-AI apps that want scriptable / e2e-testable UIs can use this lib alone. ## Public API ```ts import { commandBus, // singleton CommandBusProvider, // mounts cursor + registers `navigate` parseScript, // DSL ↔ JSON runScript, runScriptText, buildSystemPrompt, // LLM bridge extractActionBlocks, runActionBlocks, estimateTokens, trimMessages, connectCommandSocket, // optional WebSocket producer } from "@crema/action-bus" ``` ## Usage Wrap your app: ```tsx // app/root.tsx import { CommandBusProvider } from "@crema/action-bus" export default function App() { return ( ) } ``` Tag interactive elements: ```tsx ``` Drive the UI: ```ts commandBus.dispatch({ type: "click", target: "save-button" }) commandBus.dispatch({ type: "fill", target: "search-input", value: "acme" }) // Or as text DSL: import { runScriptText } from "@crema/action-bus" runScriptText(` navigate /resources wait_for resources-table fill search-input "acme" `) ``` ## Built-in commands | Command | Args | Purpose | |---|---|---| | `navigate` | `path` | React Router navigation | | `click` | `target` | Click `[data-action=target]` | | `fill` | `target`, `value` | Set input value, fire input + change events | | `submit` | `target` | Submit the form containing target | | `select` | `target`, `value` | Set `