Skip to content

Web Component API

<rtc-agent> is the sole component exposed by RTC Agent. Built on Lit, it contains 38 sub-components and 20 Controllers internally, but presents only a clean Web Component interface externally — attribute configuration, event listening, and CSS variable customization.

AttributeTypeDefaultDescription
🎨 theme"light" | "dark" | "system""system"Theme mode. system follows the OS setting
📛 app-labelstring"RTC Agent"Title bar text + minimized bubble tooltip
🖼️ bubble-iconstringDefault iconSVG / HTML content displayed inside the minimized bubble
📄 scenarios-urlstringURL of the scenario manifest, pointing to manifest.json
🔗 server-urlstring""Server address. Falls back to the current page’s domain when empty

JS Properties (set via JavaScript only, not HTML attributes):

PropertyTypeDefaultDescription
⚙️ agentConfigobjectnullDeclarative function registration (recommended approach)
📦 registryFunctionRegistrynullImperative function registration (created via defineRegistry)
🪟 windowConfigWindowConfignullWindow behavior configuration (mode, size, interaction limits)
🎛️ activityBarConfigActivityBarConfignullActivity Bar button visibility configuration
<!-- Minimal integration -->
<rtc-agent></rtc-agent>
<!-- Custom theme and title -->
<rtc-agent theme="dark" app-label="My AI Assistant"></rtc-agent>
<!-- With scenario docs and function registration -->
<rtc-agent
app-label="Order Assistant"
scenarios-url="https://example.com/scenarios"
.agentConfig=${{
name: 'OrderApp',
persona: 'You are an order management assistant',
groups: [{ /* ... */ }]
}}
></rtc-agent>
// Window configuration (JS property, set after rtc-agent-ready)
const agent = document.querySelector('rtc-agent');
agent.addEventListener('rtc-agent-ready', () => {
// Embedded panel: disable drag/resize/buttons, default to maximized
agent.windowConfig = { embedded: true };
// Keep only chat, hide files/settings buttons
agent.activityBarConfig = {
disabledActivities: ['files', 'settings'],
};
});
EventTriggerPurpose
🟢 rtc-agent-readyComponent initialization completeSafe to access the component instance and set attributes at this point
const agent = document.querySelector('rtc-agent');
agent.addEventListener('rtc-agent-ready', () => {
// Component is ready, safe to operate
agent.theme = 'dark';
agent.appLabel = 'Custom Title';
});

💡 Best Practice: Always wait for the rtc-agent-ready event before interacting with the component to avoid errors caused by uninitialized state.

<rtc-agent> includes three built-in window modes, supporting floating, fullscreen, and minimized bubble:

InteractionDescription
🖱️ DragThe title bar serves as the drag handle
↔️ ResizeSupports 8-directional resize operations
⌨️ KeyboardArrow keys move the window; Shift to accelerate
📏 Viewport constraintWindow always stays within the visible area and cannot be dragged off-screen

Use the windowConfig property to control default window behavior and interaction limits:

agent.windowConfig = {
// Default window mode
defaultMode: 'maximized', // 'normal' | 'maximized' | 'minimized'
// Embedded mode (shortcut)
// Equivalent to: defaultMode: 'maximized' + draggable: false + resizable: false
// + showMinimize: false + showMaximize: false
embedded: true,
// Fine-grained control
draggable: false, // Whether the window can be dragged
resizable: false, // Whether the window can be resized
showMinimize: false, // Whether to show the minimize button
showMaximize: false, // Whether to show the maximize button
showClose: false, // Whether to show the close button
// Size and position
initialSize: { width: 420, height: 640 },
initialPosition: { x: 100, y: 100 },
minWidth: 350,
minHeight: 520,
maxWidth: Infinity,
maxHeight: Infinity,
// Minimized bubble position
bubblePosition: {
corner: 'bottom-right', // Origin corner of the coordinate system
offset: { x: -20, y: 20 }, // Cartesian coordinate offset
},
};

bubblePosition uses a mathematical Cartesian coordinate system to control the position of the minimized bubble:

FieldTypeDescription
corner'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'The corner of the host application where the coordinate origin is placed
offset.xnumberHorizontal offset (positive = right, negative = left)
offset.ynumberVertical offset (positive = up, negative = down, mathematical coordinate system)

Examples:

// Bottom-right corner, 20px inward offset (default)
bubblePosition: { corner: 'bottom-right', offset: { x: -20, y: 20 } }
// Top-left corner, 20px offset to bottom-right
bubblePosition: { corner: 'top-left', offset: { x: 20, y: -20 } }
// Bottom-left corner, 30px offset to top-right
bubblePosition: { corner: 'bottom-left', offset: { x: 30, y: 30 } }

💡 Expand Direction: On the first restore from minimized state, the window expands based on the corner configuration. For example, with corner: 'bottom-right', the window’s bottom-right corner aligns with the bubble position, expanding toward the upper-left. Subsequent minimize/restore cycles use the remembered position.

Common Scenarios:

ScenarioConfiguration
Embedded panel{ embedded: true }
Fixed position window{ draggable: false, resizable: false }
No minimize button{ showMinimize: false, defaultMode: 'maximized' }
Floating chat windownull (uses defaults)

Use the activityBarConfig property to control button visibility in the Activity Bar:

agent.activityBarConfig = {
// Activities to hide (chat is always visible and cannot be hidden)
disabledActivities: ['files', 'settings'],
// Default active activity
defaultActivity: 'chat', // 'chat' | 'files' | 'settings'
};
ActivityDescriptionHideable
💬 chatChat interface❌ Always visible
📁 filesFile manager
⚙️ settingsSettings panel

The component uses 20 Controllers internally to manage state. 9 core state Controllers handle business logic, and 11 UI Controllers handle interface interactions. Controllers do not reference each other directly; instead, the root component <rtc-agent> acts as the central hub orchestrating cross-Controller communication:

💡 Design Principle: Controllers are decoupled from each other; all cross-Controller communication goes through the root component. Sub-components obtain state via @lit/context and do not hold direct Controller references.

CSS variables allow you to customize the component’s appearance and dimensions without modifying source code:

rtc-agent {
/* Window default dimensions */
--rtc-window-default-width: 420px;
--rtc-window-default-height: 640px;
/* Minimized bubble size */
--rtc-bubble-size: 40px;
}
VariableDefaultDescription
--rtc-window-default-width420pxDefault width of the floating window
--rtc-window-default-height640pxDefault height of the floating window
--rtc-bubble-size40pxDiameter of the minimized bubble

The component uses a three-layer style architecture, progressing from foundational tokens to top-level variables:

LayerContentDescription
🏗️ Design TokensSpacing, typography, radius, shadow, transition, z-indexFoundational design constants ensuring visual consistency
🌓 Color ThemesLight / Dark (VS Code style)Two complete color schemes with automatic adaptation
🔧 CSS VariablesComponent-level customization (window dimensions, bubble size)Overridable by host applications for personalization
AreaBehavior
⌨️ Input AreaTextarea + bottom toolbar; Enter to submit, Shift+Enter for newline; toolbar includes attachments, tools, mode toggle, send/stop
📨 Message ListAuto-scrolls to bottom; “New messages” button shown when user scrolls away; supports Markdown rendering and code highlighting
Tool Confirmation DialogDisplays tool name and parameters; Yes / No buttons; clicking the background is equivalent to rejecting