Web component
The chat of @dudko.dev/agent-web-react
as a standard web component. A site on Vue, Angular, Svelte, Solid, Astro or plain HTML gets
the same chat with one tag:
<dd-agent-chat lang="ru" chat-title="Support"></dd-agent-chat>It is not a second chat. The element mounts the React package’s <AgentProvider> and <AgentChat>
inside a custom element: the same transcript, streamed answers in Markdown, tool calls and their
cost, consent prompts, the model’s and a server’s questions, saved chats, the workspace, MCP Apps,
voice, 33 languages. React is inside the element; your page needs none. The agent itself is
@dudko.dev/agent-web, the in-browser LLM
agent: your page picks its version and its model providers.
The family
Section titled “The family”One planning loop: two agents, and the layers that put its chat on a page. Every package has its page at agent.dudko.dev/docs. The live demo and the app are built on them.
| Package | What it is |
|---|---|
@dudko.dev/agent |
The agent in Node: stdio and HTTP MCP servers, OAuth 2.1, a REPL CLI, persistence and resume |
@dudko.dev/agent-web |
The same agent in a browser tab, with no backend: your own key or a local WebGPU model |
@dudko.dev/agent-web-ui |
Its chat with no framework: the state, a controller, labels in 33 languages, Markdown |
@dudko.dev/agent-web-react |
React: the useAgent hook and a ready chat panel |
@dudko.dev/agent-web-element (this package) |
<dd-agent-chat>: the whole chat as a web component, for a page on any stack |
@dudko.dev/agent-web-vue |
Vue 3: the useAgent() composable |
@dudko.dev/agent-web-angular |
Angular: injectAgent(), the chat state as signals |
@dudko.dev/agent-web-svelte |
Svelte 4 and 5: createAgent(), the chat state as a store |
Install
Section titled “Install”npm install @dudko.dev/agent-web-element @dudko.dev/agent-web# and the model providers you use, e.g.npm install @ai-sdk/googleimport '@dudko.dev/agent-web-element' // defines <dd-agent-chat>That import also puts the chat’s stylesheet into the document. Nothing else to load.
Without a bundler
Section titled “Without a bundler”dist/browser/agent-web-element.js is the element for a <script type="module"> (a CDN or a
download): React, the React package and the UI package are in it; the core is not - map it with an
import map, to the core’s own browser build, the same URL your page imports it from (one core on
the page; with backend only, the core is never loaded and the map needs no entry for it):
<script type="importmap"> { "imports": { "@dudko.dev/agent-web": "https://cdn.jsdelivr.net/npm/@dudko.dev/agent-web/dist/agent-web.js", "@ai-sdk/google": "https://cdn.jsdelivr.net/npm/@ai-sdk/google/+esm" } }</script><script type="module" src="https://cdn.jsdelivr.net/npm/@dudko.dev/agent-web-element/dist/browser/agent-web-element.js"></script>
<dd-agent-chat id="chat" chat-title="Assistant" style="height: 600px"></dd-agent-chat>
<script type="module"> import { VaultCredentialStore } from '@dudko.dev/agent-web'
const credentials = new VaultCredentialStore() // keys encrypted at rest, in IndexedDB // once, e.g. from a settings form: await credentials.setApiKey('google', key)
const chat = document.getElementById('chat') chat.config = { model: { providerType: 'google', model: 'gemini-3.5-flash', credentialRef: 'google' }, credentials, } chat.addEventListener('dd-agent-run-end', (e) => console.log(e.detail.result?.final))</script>A language’s labels (lang) are a file beside agent-web-element.js, fetched when asked for.
Sizes (measured 2026-11-30, element 0.0.5 on agent-web-ui 0.0.4 and agent-web-react 0.0.48;
gzip at the default level): dist/browser/agent-web-element.js is 609 KiB minified, 182 KiB
gzip (React and react-dom are about 67 KiB gzip of it, the chat’s stylesheet 17 KiB); one chunk
beside it (4 KiB gzip: what turns a language into labels) loads with it; a language is 5-7 KiB gzip
(a variant, es-419 say, also its base), fetched only when asked for. The npm build
(dist/index.js and its chunk: React, react-dom and the React package, not minified - your bundler
minifies) is 1.1 MiB, 209 KiB gzip; @dudko.dev/agent-web-ui is imported, not in it. Neither build
imports the core statically: the only import of @dudko.dev/agent-web is the ui package’s dynamic
one, taken when an agent is built in the page. So a chat with backend fetches nothing of the
core - these 182 KiB gzip (plus a language, if asked for) are the whole chat, and the import map
needs no entry for the core. The core’s own browser build (dist/agent-web.js), fetched only for
an agent in the page, is 354 KiB gzip more.
How a page uses it
Section titled “How a page uses it”Plain HTML
Section titled “Plain HTML”As above: the tag, then config set from a script. Until config is set the element draws
nothing.
Tell Vue the tag is not one of its components, and give objects as properties (.prop):
vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === 'dd-agent-chat' } } })<script setup lang="ts">import '@dudko.dev/agent-web-element'import { config } from './agent' // { model, credentials, tools, … }const onEnd = (e: CustomEvent) => console.log(e.detail.result?.final)</script>
<template> <dd-agent-chat :config.prop="config" lang="de" chat-title="Hilfe" @dd-agent-run-end="onEnd" /></template>Angular
Section titled “Angular”import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'import '@dudko.dev/agent-web-element'import { config } from './agent'
@Component({ selector: 'app-help', standalone: true, schemas: [CUSTOM_ELEMENTS_SCHEMA], template: `<dd-agent-chat [config]="config" lang="fr" (dd-agent-run-end)="onEnd($event)"></dd-agent-chat>`,})export class HelpComponent { config = config onEnd(e: Event) { console.log((e as CustomEvent).detail.result?.final) }}Svelte
Section titled “Svelte”<script> import '@dudko.dev/agent-web-element' import { config } from './agent'</script>
<dd-agent-chat {config} lang="es" on:dd-agent-run-end={(e) => console.log(e.detail.result?.final)} />(Svelte sets a property when the element has one of that name, as config is. Svelte 5:
ondd-agent-run-end={…}.)
Solid (<dd-agent-chat prop:config={config} on:dd-agent-run-end={…} />) and Astro (the tag in the
markup, config set in a <script>) work the same way. On a server (SSR) the import defines
nothing; the element comes alive in the browser.
Properties
Section titled “Properties”Objects and functions are given as properties. Setting one re-renders the chat; only a NEW
config object builds a new agent (setting the same object again changes nothing).
| Property | What it is |
|---|---|
config |
What createAgent of @dudko.dev/agent-web takes: model, credentials, tools, memory, toolApproval, askUser, learning, … (BrowserAgentConfig). Required - unless backend is set (an agent on a server: then not used). A new object = a new agent; the conversation on screen starts over |
backend |
An agent on a SERVER instead of one built in the page: the swarm gateway’s base URL (http(s), absolute or relative to the page; also the attribute). No config, no model, no key in the page - see An agent on a server |
backendHeaders |
Headers for every request to the gateway: an object, or a function called before each request (async () => ({ authorization: 'Bearer ' + await visitorToken() })). A property only - a token never goes in the markup |
backendFetch |
The fetch the chat reaches the gateway with (default the page’s own): a function with fetch’s signature that carries each request another way - a VS Code webview’s postMessage to its extension host (apps/vscode in the monorepo does), a worker, a test double. It gets the full URL under backend and answers a Response (the events as a streamed text/event-stream body). A property only |
backendCredentials |
fetch’s credentials for the gateway: 'include' (a cookie sent cross-site - an anonymous visitor cookie), 'same-origin' (default), 'omit' (also the attribute backend-credentials) |
session |
The gateway session: set it to continue one (its transcript is replayed); read it for the current one (the first message starts a session; dd-agent-session tells every change) |
sessionPersist |
Where session-storage keeps the session’s id: 'tab' (default: sessionStorage, each tab its own conversation) or 'browser' (localStorage: every tab of the site on one conversation, followed across tabs without a reload - see One conversation in every tab). Also the attribute session-persist |
textOnly |
A text-only chat: no “+”, no paste or drop of files and images, no dictation, no voice message. Default: true with backend, else false (also the attribute text-only) |
pageContext |
What the person is looking at, read when a message is sent and passed with it - every collector OFF unless switched on: { collect: { path: true, title: true, selection: true, focus: { includeValues: true }, geolocation: { precision: 2 } }, extra: () => ({ … }), include, exclude, maxChars } (the React package’s docs/chat.md lists the collectors). The focus and the selection are read OUTSIDE the chat; a password / hidden / card / one-time-code field’s value never. With backend it goes to the server as the message’s context (the gateway keeps only its contextKeys). Wins over the attribute page-context. options.showPageContext: false hides the “Sharing: …” chip |
agentOptions |
useAgent’s options: maxEvents, approvals, questions, followUp, watch, appToolGrants. Read when the agent is built |
labels |
Any of the chat’s words (AgentLabelsOverride), over the language’s |
lang |
The language of the labels (also the attribute): one of 33 (loadAgentLabels of @dudko.dev/agent-web-ui/locales; the nearest one, English for an unknown tag). Until a language has loaded the element draws nothing, so no English flashes first |
theme |
'auto' (the device’s scheme), 'light', 'dark' |
chatTitle |
The title (text) |
placeholder |
The message box’s placeholder (text) |
markdown |
Answers and .md files as Markdown - true by default (the React package’s markdownContent / markdownFileContent); false draws them as plain text |
linkHosts |
The hosts an answer may link to (['example.com', 'github.com/your-org']: a host, or a host and a path prefix): any other link is drawn as its words and its address, as text. Unset (default): every safe link is a link. A malformed entry keeps no link at all |
emptyState |
What shows before the first message: text, or a DOM node of yours (the empty slot wins) |
history |
Saved chats: true (default: IndexedDB, the Chats panel), false, or a ChatHistoryStore (exported here: new ChatHistoryStore({ dbName })). Every element on a page with true shares one store - give each its own to keep their lists apart |
files |
The workspace: the core’s VirtualFileSystem (the Files panel, file chips, attachments). Give the agent createFileTools(files) to work in it |
composer |
false hides the message box; an object gives its options: commands, builtinCommands, skillCommands, showCommands (the “/” button; it also goes when there are no commands), model, thinking, attachments, convertFile, speech, voiceMessage, longText, steering, showTimer, showAgents, showApprovalMode, draft, disabled, textOnly, dropZone ('self' / 'window'), … (COMPOSER_OPTION_KEYS) |
options |
The other <AgentChat> props that are data: show* switches, stoppableSubagents, activityOpen, htmlPreview, narrowWidth, defaultHistoryOpen, defaultFilesOpen, readAloud, imageViewer, classNames, className, mcpApps, appSandbox, appFullscreen, appDownloads, appSampling, appsCollapsed, appPanel, onAppPanel, elicitations, onElicitationAnswer, textOnly, allowRemember (CHAT_OPTION_KEYS). Any other key is ignored, with a warning in the console |
renderToolCard |
(call, message) => Node | string | null: a tool call as a card in the answer (a NEW node each call; a string is drawn as text, never as HTML; null for the calls you do not draw) |
Read-only: agent (the core’s Agent, once built), status ('idle' | 'initializing' |
'ready' | 'running' | 'error'). Methods: run(goal, options?) (as if the person sent it;
resolves with the core’s RunResult, or undefined when not ready or already running), stop(),
reset().
Attributes
Section titled “Attributes”For plain HTML, strings only. A property of the same meaning wins over its attribute.
| Attribute | |
|---|---|
chat-title |
The title. title works too - but it is also the browser’s tooltip over the whole element |
lang |
The language of the labels |
theme / data-awr-theme |
auto | light | dark (anything else is auto) |
placeholder |
The message box’s placeholder |
markdown |
markdown="off" (or false, no, 0) draws answers as plain text |
link-hosts |
The same list, separated by blanks or commas: link-hosts="example.com github.com/your-org" |
backend |
The gateway’s base URL of an agent on a server (backend="/agent"): no config needed - see An agent on a server |
backend-credentials |
include | same-origin | omit: include sends a cookie with every request to the gateway (an anonymous visitor cookie) |
session |
A gateway session to continue ([A-Za-z0-9_-]{1,64}) |
session-storage |
A key: the session’s id is kept under it (in sessionStorage, or localStorage with session-persist="browser"), so a reload continues the conversation (its transcript replayed) |
session-persist |
tab (default) | browser: where session-storage keeps the id - this tab only, or every tab of the site (one conversation, followed across tabs) |
text-only |
text-only (or on) / text-only="off": a text-only chat, or not (default: on with backend) |
page-context |
The collectors to switch on, by name, separated by spaces: page-context="path title selection" (url, path, title, language, referrer, focus, selection, geolocation, viewport, scroll, headings, time, colorScheme, device; an unknown name is left out with a warning). A field’s value is never switched on from the markup - that is the property’s focus: { includeValues: true } |
light-dom |
Draw this element’s chat in the page’s DOM instead of a shadow root (read once, when the element is first put on the page) - see “Shadow DOM, or the light DOM” |
Put elements of yours in the chat with slot:
<dd-agent-chat> <div slot="empty"><p>Ask me about your orders.</p></div> <button slot="header-end" type="button" onclick="openHelp()">Help</button></dd-agent-chat>| Slot | Where |
|---|---|
empty |
Before the first message |
header |
Replaces the whole header |
header-start, header-end |
In the header, before the title / after the usage |
before-messages, after-messages |
In the transcript, above / below the messages |
footer-start |
Above the message box |
sidebar |
Under the chat list in the Chats panel |
In a shadow root (the default) these are real <slot>s: your nodes stay children of the element,
where you put them, and the browser shows them in the chat. Your page’s CSS styles them (they are
yours), and a framework may add, remove or replace them as it likes.
In the light DOM (light-dom) the element MOVES your nodes into the chat (they are the same
objects; your listeners stay) and back when it is removed. Keep a slot’s element itself in place
there - change what is inside it - since a framework that removes or replaces the slotted element
directly will not find it where it put it.
What is customisable: the words (labels, lang), the theme and the --awr-* tokens (below),
which parts show (options’ show*), the composer’s options, the places above, the empty state,
tool cards, Markdown on or off. What is not: the React package’s render props (renderMessage,
renderContent, renderApproval, …), components and slots - they take React nodes, which a
page without React cannot give. For a chat drawn your own way, use @dudko.dev/agent-web-react (or
build on @dudko.dev/agent-web-ui).
Events
Section titled “Events”Every event is a CustomEvent that bubbles and is composed (a listener on the element, on any
ancestor, or across your own shadow roots hears it). Names are also AGENT_EVENTS.
| Event | detail |
|---|---|
dd-agent-ready |
{ agent } - the agent was built (again after a new config); with backend once, agent undefined (it is on the server) |
dd-agent-message |
{ text, attachments, steering } - the person sent a message (attachments: the files’ names; steering: said to a run under way) |
dd-agent-run-start |
{ goal, runId? } |
dd-agent-run-end |
{ result?, stopped, error? } - result is the core’s RunResult (result.final is the answer); a run the chat started itself (its “Send now” of undelivered messages) ends without result |
dd-agent-error |
{ error, phase, code? } - phase: 'build' when the agent could not be built from config |
dd-agent-approval-requested |
{ id, name, input, readOnly, app?, skill?, subagent? } - a tool call (or a server’s skill, or an app’s call) waits for the person’s consent. The person answers in the chat; the element has no way to answer for them |
dd-agent-event |
{ event } - every event of the core, as it comes |
dd-agent-tool-result |
{ tool, callId, ok, output, live } - a tool call of the agent ended (its name, its result - or the error when ok is false). live: a call of a run started from THIS element, as it happens; with backend, false for the calls of the session’s replay (a reload, session set) and of a turn another tab or client started - so a page acts on what its visitor’s own message caused once, not again on every reload. callId: with backend the event’s cursor on the gateway’s stream, else a number the element counts; act on one id once. A helper’s calls are not told |
dd-agent-session |
{ sessionId } - with backend: the gateway session changed (started by the first message; undefined when the gateway no longer knew it, or after reset(); with session-persist="browser" also when another tab started or dropped one and this element followed) |
An agent on a server: backend
Section titled “An agent on a server: backend”The element can talk to an agent that runs on a SERVER - the swarm’s gateway
(examples/swarm: Temporal +
Postgres, Cloudflare, Google Cloud or AWS, one HTTP API) - instead of building one in the page.
Nothing of the agent is in the browser: no model, no key, no tool. A support widget on a public
site:
<dd-agent-chat id="support" chat-title="Support" session-storage="support-chat"></dd-agent-chat><script type="module"> const chat = document.getElementById('support') // A signed visitor token from your site, sent with every request (or backend-credentials="include" // for a cookie). Set it before `backend`: the first request may go at once. chat.backendHeaders = async () => ({ authorization: `Bearer ${await visitorToken()}` }) chat.backend = 'https://support.example.com/agent'</script>It is the React package’s useRemoteAgent (the ui package’s createRemoteAgentController): the
first message starts a session (POST /sessions), the next ones go to it, each turn streams in
from GET /sessions/:id/events (SSE; a dropped stream is opened again with Last-Event-ID -
nothing missed, nothing twice), Stop is POST /sessions/:id/stop. A call the server’s policy asks
about shows its consent card; Allow once / Deny are posted to
POST /sessions/:id/answers/:requestId. With session-storage (or your own session and
dd-agent-session) a reload continues the conversation: its stream is replayed.
One conversation in every tab: session-persist="browser"
Section titled “One conversation in every tab: session-persist="browser"”By default session-storage keeps the id in sessionStorage: each tab has its own conversation.
When the visitor’s identity is the same in every tab (a cookie of the gateway’s host, a token
of your site), session-persist="browser" keeps it in localStorage instead, and the element
follows it across tabs: a session another tab starts, or another tab’s new chat (reset() - the
key removed), switches this element to that session (its transcript replayed) or to none, at
once, without a reload; dd-agent-session tells the page each switch, as it tells a change of
its own. Two tabs then show the same conversation, and a message from either goes to it. Storage
that cannot be used (a private window, a sandboxed frame) is skipped: the chat works, nothing is
kept.
<dd-agent-chat backend="https://support.example.com/agent" backend-credentials="include" session-storage="support-chat" session-persist="browser"></dd-agent-chat>With backend the chat is, unless you say otherwise: text only (text-only="off" or
options.textOnly: false gives the “+” back - but a server agent takes text only), no saved
chats (history; the conversation is the server’s session), no consent-mode chip and no
context meter (the server’s settings), no “Always allow” (on a server every call is decided
on its own). agent is undefined; run(text), stop() and reset() (a new session with the
next message) work as on a local agent. Nothing of the in-browser agent is loaded either: the element
imports the core only to build an agent in the page (a dynamic import, never taken with backend),
so your bundler leaves the core, the AI SDK and zod in a chunk the page never fetches - and without
a bundler, the import map needs no entry for @dudko.dev/agent-web. The support chat of
agent.dudko.dev is this: 182 KiB gzip on its first open, React and the chat. The gateway’s CORS must allow your page’s origin
(CORS_ORIGINS). Details: the React package’s
docs/chat.md.
Shadow DOM, or the light DOM
Section titled “Shadow DOM, or the light DOM”By default the chat is drawn in an open shadow root of the element. Your page’s CSS does not
reach into it - tag rules, class and id rules, !important alike - and the chat’s CSS does not
reach out. The chat’s stylesheet is adopted by the shadow root (no <style> element, so a page with
a strict style-src needs no 'unsafe-inline' for it). A browser test draws the chat on a page
with * { all: revert }, button { … }, svg { … }, a body font and letter spacing, AND rules
with classes, ids and attributes that name the chat’s own parts, all !important, and compares
every part’s box and look with the same chat on a page with no CSS: equal.
What still crosses, as with any element: inherited properties (the chat’s root sets the text ones
it does not set itself, so your body { letter-spacing: 2px } stays outside), the --awr-* theme
tokens you set ON THE ELEMENT (below), and the element’s own box - it is your page’s element, so
your rules on it apply. A page-wide * { all: revert } matches the element too and makes it inline;
say dd-agent-chat { display: block } on such a page.
The element is a block, 560 px tall unless you size it (any rule of yours on the element wins):
dd-agent-chat { height: 100%; }dd-agent-chat { --awr-accent: #0a7; --awr-radius: 4px; } /* the theme tokens, on the element */theme / data-awr-theme and the theme property pick the scheme; a token you set wins over the
scheme’s. Events leave the shadow root (composed), and from the page a click in the chat comes
from the element, as with any element that has a shadow root.
The chat of @dudko.dev/agent-web-react reads the focus, the element under a point and an event’s
target from the root it lives in, so everything works the same inside a shadow root: its menus, the
consent prompts, the armed “Allow” buttons of MCP Apps (they count a press only when nothing covers
them - asked of the whole page, through shadow roots), the full-screen gesture of an app, the image
viewer’s and the file dialog’s focus traps, the side panels on a phone. The React package’s own
browser tests run those parts in a shadow root too.
The light DOM: light-dom, or { shadow: false }
Section titled “The light DOM: light-dom, or { shadow: false }”<dd-agent-chat light-dom></dd-agent-chat>import { defineAgentChat } from '@dudko.dev/agent-web-element/element'defineAgentChat('support-chat', { shadow: false }) // every <support-chat> in the light DOMFor a page that must style the chat’s parts with its own selectors (.awr-msg__bubble { … }), or
a tool that cannot see into shadow roots. The attribute is read once, when the element is first put
on the page (a shadow root cannot be taken off again). There the chat is in your page’s DOM and its
CSS is scoped instead:
- every rule of the chat’s stylesheet names an
awr-class, and every rule the element adds starts with its tag: nothing styles your page (a test reads every selector, and a browser test compares your page’s own elements with and without the chat); - your page’s tag rules do not reach in: inside the chat, each element the chat draws is put back
to the browser’s defaults at the weight of two tags (
dd-agent-chat buttonbeats yourbutton, never a class) and the chat’s own rules apply on top; the inherited text properties are reset on its root; the icons’ sizes, paint and shapes are said again in CSS (a page’s* { all: revert }removes SVG presentation attributes). The same browser test (tag rules only) holds; - your nodes in slots and tool cards keep your page’s rules;
- a rule of yours with a class or an id in it (
.page button), or!important, is stronger and DOES reach in: scope page-wide rules to your page’s own parts; - the theme tokens go on the chat’s root:
dd-agent-chat .awr-chat { --awr-accent: #0a7; }.
The stylesheet goes into the document as an adopted stylesheet, once.
defineAgentChat(tag, { styles: false }) leaves the styles to you: in a shadow root, adopt a sheet
into el.shadowRoot yourself (your page’s CSS does not reach in); in the light DOM, load
@dudko.dev/agent-web-ui/styles.css and size the element.
Why the React package had to change first
Section titled “Why the React package had to change first”A first probe of the element in a shadow root failed: there the React package’s chat assumed it lived in the document - its menus closed on a mousedown
“outside” judged from the document (where a click inside a shadow root comes from the host), the
armed buttons of MCP Apps checked document.elementFromPoint (which answers the host, so they
never armed), and the focus traps, menu keys and the full-screen gesture read
document.activeElement (the host). The React package now asks the chat’s own root in each of those
places, with a browser test in a shadow root for each - and the element moved into one.
Lifecycle
Section titled “Lifecycle”- Connected: the chat is mounted (a React root of its own). Two elements on a page are two chats, each with its own agent, language and events.
- Removed: the chat is unmounted once the current task is over - the run under way stopped
(
dd-agent-run-endwithstopped: trueon the element), consent requests settled, listeners gone, your slotted nodes back in the element (in a shadow root they never left it). The shadow root stays, empty, and is used again when the element is put back. Put back: mounted again, with a new agent. - Moved (removed and put back at once, as a framework reordering a list does): the same chat goes on.
Another tag name
Section titled “Another tag name”import { defineAgentChat } from '@dudko.dev/agent-web-element/element' // defines nothing itselfdefineAgentChat('support-chat')A tag that is already defined is never redefined (defineAgentChat returns the class it has, and
warns when that is not this element). @dudko.dev/agent-web-element itself defines
dd-agent-chat the same way, so a page that defined it first keeps its own.
What ./element exports
Section titled “What ./element exports”@dudko.dev/agent-web-element/element defines no tag; besides the class and defineAgentChat it
exports the pure parts the element is made of (each also what the attribute of the same name
accepts), for a page or a wrapper that wants the same rules:
| Export | What |
|---|---|
AgentChatElement, defineAgentChat(tag, { shadow? }), AGENT_CHAT_TAG, SLOT_NAMES, OBSERVED_ATTRIBUTES, LIGHT_DOM_ATTRIBUTE |
The element, its definition under a name, its tag, slots and attributes |
AGENT_EVENTS, elementEventsOf, AgentElementEventMap and the details (ReadyDetail, SessionDetail, MessageDetail, RunStartDetail, RunEndDetail, ErrorDetail, ApprovalRequestedDetail, EventDetail) |
The events |
parseTheme, parseLang, parseSwitch, parseText, parseCredentials |
An attribute’s text to a value (undefined for anything not one of the known shapes) |
parseBackend(value, base?) |
backend: an http(s) URL (relative ones against base), never one with credentials in it |
parseSessionId(value) |
session: [A-Za-z0-9_-]{1,64} |
parseSessionPersist(value), SessionPersist |
session-persist: 'tab' | 'browser' |
sessionOfStorageChange({ key, newValue }, key) |
With session-persist="browser": what another tab’s storage event means for the session kept under key - undefined (another key), or { sessionId } to be on now (sessionId undefined: none - removed, cleared, or not a session id) |
CHAT_OPTION_KEYS, COMPOSER_OPTION_KEYS, pickOptions, chatPropsOf |
Which keys options / composer take, and the chat’s props from the element’s inputs (with backend: text only, no saved chats, no consent chip, no context meter, no “Always allow” unless turned on) |
CHAT_CSS, elementCss, shadowChatCss, shadowCss, ICON_SHAPES, RESET_TAGS, splitSelectors, topLevelRules |
The stylesheets of both modes and what they are built from |
ChatHistoryStore |
The ui package’s saved chats, the very class the chat checks for |
Types: ElementInputs, ElementTheme, ElementAgentOptions, ElementRemote, HostContent, RenderToolCard, DefineAgentChatOptions |
Security
Section titled “Security”The element adds no new way in. Attributes are text (a theme or a language that is not one of the
known shapes is ignored); strings you give (emptyState, a tool card) are drawn as text, never as
HTML; React render props are not taken from options. Everything else is the React package’s
chat, unchanged: untrusted HTML only in its sandboxed frame (sandbox, never
allow-same-origin), MCP Apps in theirs, consent asked in the chat. The browser tests check the
sandboxed HTML preview when the element draws it. See the React package’s
docs.
Browser tests
Section titled “Browser tests”pnpm nx test:e2e @dudko.dev/agent-web-element (Playwright, Chromium) runs plain HTML pages served
on loopback by the test itself (e2e/page-server.ts: an import map, the element’s browser build,
the core’s) against a scripted Gemini (the React package’s e2e/gemini.ts): a run with a Markdown
answer and its events, an error, consent and the sandboxed preview, Russian, attributes, slots,
removal and return, a move, two elements, property changes, another tag name, a hostile page’s CSS,
nothing leaking out, no sideways scroll at 390 and 320 px - every test twice: as the element ships
(in a shadow root, where the hostile page adds class, id and !important rules) and with
light-dom. ELEMENT_RENDERS=<dir> writes renders of both.
License
Section titled “License”MIT
Ask about the agents
What you write goes to the project's server and an AI model. Answers can be wrong.
Loading the chat…