Skip to main content
Reference for the <char-agent> custom element.

Attributes

AttributeTypeDescription
publishable-keystringPublishable key used to resolve org context
display-mode'pip' | 'inline' | 'fullscreen'Host display mode hint
enable-debug-toolsbooleanEnables debug tools in embed runtime
api-basestringOverrides API base (default production)

Properties

PropertyTypeDescription
publishableKeystring | undefinedProperty form of publishable-key
apiBasestring | undefinedProperty 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

OptionTypeRequiredNotes
publishableKeystringYesOrg-scoped embed credential
idTokenstringNoEnd-user identity token from your IDP
Only publishableKey (required) and idToken (optional) are supported in auth methods.

Events

EventDetail
char-initializedvoid
char-closevoid
char-errorCharErrorDetail
char-size-changedCharSizeChangedDetail
char-request-display-modeCharRequestDisplayModeDetail
char-open-linkCharOpenLinkDetail