v0.1.0 released npm i bsquare-widget

Drop an AI agent into any web page.

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.

Get started
index.html
<!-- 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 };
      } },
  ],
});
B
Assistant
Online · acts on this page
Add the trail jacket to my cart
On it — adding the Trail Jacket.
add_to_cart
Built on open standards
AG-UIPydanticAIFastAPIServer-Sent EventsShadow DOM
How host actions work

The agent reaches into your page — safely.

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.

1

Agent calls a tool

The PydanticAI agent invokes navigate_to_page mid-stream over SSE.

2

Proxy advertises & awaits

@host_action_proxy publishes the action and parks the coroutine.

3

Widget runs it on the page

The matching registered hostAction handler executes against the DOM.

4

Result wakes the tool

A POST to /host-action-result resolves the await and the agent continues.

Why BSquare

Everything you need to ship an agent on day one.

Shadow-DOM isolated

Mounts in a closed shadow root — your host page's CSS and the widget never collide.

Streams over SSE

Token-by-token responses from any AG-UI endpoint, rendered as they arrive.

Host actions

Let the agent click, navigate, and mutate the live page through declarative handlers.

PydanticAI native

Decorate a tool with @host_action_proxy and you're done — typed end to end.

Multi-tenant ready

One bundle, many tenants via a transparent dispatcher — no per-customer builds.

MIT & self-hosted

Ship it on your own infra with your own credentials. No lock-in, no per-seat tax.

Two packages

A widget for the browser, a host for your server.

JS
bsquare-widget
The injectable browser bundle · npm
$ npm i bsquare-widget
PY
bsquare-host
FastAPI mount + PydanticAI proxy · pip
$ pip install bsquare-host

Mount your first agent in 60 seconds.

Free, open source, MIT-licensed. Bring your own model and your own backend.