ESM entry
Named instance factories, React bindings, and package exports.
The SDK uses explicit client instances. The root entry provides conversation state and actions;
/widget attaches the built-in Messenger to a client, and /react provides instance-scoped hooks.
Package Exports
| Export path | Values | Purpose |
|---|---|---|
@customer-agent/sdk | createClient, message/invitation/event constants, CUSTOMER_AGENT_VERSION | Conversation client without UI or React. |
@customer-agent/sdk/widget | Root values and mountWidget | Attach and control the built-in Messenger. |
@customer-agent/sdk/react | Root values, mountWidget, CustomerAgentProvider, client and widget hooks | React bindings for supplied instances. |
@customer-agent/sdk/sdk.js | Browser script asset | Registers the same factories on window.CustomerAgent. |
@customer-agent/sdk/messages/* | Locale JSON catalogs | Built-in UI translations. |
The ESM entries have named exports and no default export. Widget and React entries re-export the core factory, so an integration can import its factories from one entry. The root entry's runtime and TypeScript declarations work without DOM libraries. React is an optional peer dependency.
Client
import { createClient } from "@customer-agent/sdk"
const client = createClient({ appId: "your-app" })
await client.boot()Client options, methods, state, and errors are defined in Headless client.
Messenger
import { createClient, mountWidget } from "@customer-agent/sdk/widget"
const client = createClient({ appId: "your-app" })
await client.boot()
const widget = await mountWidget({ client })
widget.show({ type: "support" })
widget.unmount()
client.shutdown()mountWidget requires a client and returns a handle bound to that mount. Unmounting
leaves the client running. A new mount replaces the document's previous Messenger; either client
can continue without UI. An old handle never controls a later mount.
Mounting requires a browser document. Imports are safe on the server. The returned promise resolves
when the instance is attached; shell readiness is observed through widget.getState().isReady or
widget.ready. The full conversation panel remains lazy.
Type Exports
The root exports CustomerAgentClient, CustomerAgentClientOptions, CustomerAgentClientState,
CustomerAgentConversationState, CustomerAgentMessage, CustomerAgentAttachment,
CustomerAgentContext, CustomerAgentUser, CustomerAgentPageOptions, SetContextOptions,
CustomerAgentSupportState, CustomerAgentInterviewState, CustomerAgentInterviewSession,
CustomerAgentInterviewInvitationChoice, CustomerAgentInterviewInvitationAction,
CustomerAgentEventMap, and CustomerAgentEventName.
Action-card exports include CARD_OPERATION_STATUS, CustomerAgentActionCard,
CustomerAgentCardOperation, CustomerAgentCardActionResult, and CustomerAgentMessagePart.
Widget and React entries additionally export CustomerAgentWidget, CustomerAgentWidgetOptions,
CustomerAgentWidgetState, and CustomerAgentTarget. The widget entry also exports
CustomerAgentBrowserSDK, the script namespace type.
Version 0.9.0 Migration
| Previous surface | Instance API |
|---|---|
Default CustomerAgent export and named singleton methods | Named createClient; call business methods on its returned client. |
CustomerAgent.boot(options) | createClient(clientOptions), client.boot(), and mountWidget({ client, ...presentation }). |
| Widget business methods | Call the supplied client. Use the widget only for UI controls. |
CustomerAgentOptions | CustomerAgentClientOptions for business configuration; CustomerAgentWidgetOptions for UI. |
Implicit singleton hooks or useCustomerAgentClientState | CustomerAgentProvider with the supplied client, then useCustomerAgentState. |
| Script command function, queue, or data-attribute auto-boot | The named factories on window.CustomerAgent. |
The removed APIs have no compatibility aliases. brand, theme, launcher, and other presentation
options belong to the widget. Identity, context, locale, and page metadata belong to the client.
Client readiness and widget readiness are separate snapshots. The previously accepted, inert theme.colorScheme and theme.radius fields are removed; theme.primaryColor remains supported.
Self-hosted Assets
Publish the complete dist output when self-hosting. The script and ESM entries require their
companion JavaScript chunks and locale/emoji assets. Chunk filenames are build output, not public
package imports.