One script tag mounts a Shadow-DOM-isolated chat widget that streams from your AG-UI / PydanticAI backend — and can act on the host page through host actions.
<!-- 1. one script tag -->
<script src="bsquare-widget.global.js"></script>
// 2. mount the agent
window.BSquare.mountAgent({
apiUrl: 'https://api.example.com',
hostActions: [
{ name: 'navigate_to_page',
description: 'Go to a section',
handler: (p) => {
location.hash = p.page;
return { success: true };
} },
],
});
A tool call on the backend is proxied to the browser, run against the live DOM, and the
result is awaited — keyed by tool_call_id.
The PydanticAI agent invokes navigate_to_page mid-stream over SSE.
@host_action_proxy publishes the action and parks the coroutine.
The matching registered hostAction handler executes against the DOM.
A POST to /host-action-result resolves the await and the agent continues.
Mounts in a closed shadow root — your host page's CSS and the widget never collide.
Token-by-token responses from any AG-UI endpoint, rendered as they arrive.
Let the agent click, navigate, and mutate the live page through declarative handlers.
Decorate a tool with @host_action_proxy and you're done — typed end to end.
One bundle, many tenants via a transparent dispatcher — no per-customer builds.
Ship it on your own infra with your own credentials. No lock-in, no per-seat tax.
Free, open source, MIT-licensed. Bring your own model and your own backend.