Reference for the <char-agent> custom element.
Attributes
| Attribute | Type | Description |
|---|
publishable-key | string | Publishable key used to resolve org context |
display-mode | 'pip' | 'inline' | 'fullscreen' | Host display mode hint |
enable-debug-tools | boolean | Enables debug tools in embed runtime |
api-base | string | Overrides API base (default production) |
Properties
| Property | Type | Description |
|---|
publishableKey | string | undefined | Property form of publishable-key |
apiBase | string | undefined | Property form of api-base |
Imperative auth API
import type { CharAgentElement } from "@mcp-b/char/web-component";
const agent = document.querySelector("char-agent") as CharAgentElement;
agent.connect({
publishableKey: "pk_live_...",
idToken: currentUserIdToken, // optional
});
connect(options)
- Requires
publishableKey
- Accepts optional
idToken
- Returns
boolean
setAuth(options | null)
- Wrapper for
connect() / disconnect()
- Pass
null to clear auth
disconnect()
- Clears auth in the embed runtime
- Returns
boolean
Method option types
| Option | Type | Required | Notes |
|---|
publishableKey | string | Yes | Org-scoped embed credential |
idToken | string | No | End-user identity token from your IDP |
Only publishableKey (required) and idToken (optional) are supported in auth methods.
Events
| Event | Detail |
|---|
char-initialized | void |
char-close | void |
char-error | CharErrorDetail |
char-size-changed | CharSizeChangedDetail |
char-request-display-mode | CharRequestDisplayModeDetail |
char-open-link | CharOpenLinkDetail |