ClientAgentJS

Architecture

ClientAgentJS is organized as a small browser-first runtime with separated responsibilities.

Public entry point

Exports only createAgent.

Agent layer

Responsibilities:

Providers

Responsibilities:

⚠️ Security Warning (Anthropic): The Anthropic provider uses the anthropic-dangerous-direct-browser-access header to bypass CORS limitations. This means the API Key is exposed directly to the client browser. This fits the “Zero-Backend” direct deployment model, but you must ensure you have proper billing limits, or only use this model for personal projects / BYOK (Bring Your Own Key) scenarios.

Memory and storage

Responsibilities:

Transport

Responsibilities:

Tools

Responsibilities:

Design boundary: Local tools are strictly for simple, dependency-free frontend interactions. For advanced capabilities or interactions with external services, use MCP servers instead.

MCP

Responsibilities:

Optional UI

Responsibilities:

Styling Strategy:

The UI modules include a FALLBACK_CSS constant that is injected into the document head when the panel opens. To ensure these styles are easily overridable by the host application, all built-in rules use the :where() CSS pseudo-class, which reduces their specificity to zero. Developers can provide their own styles by targeting the same classes (e.g., .client-agent-js-profile-dlg) without needing to use !important or high-specificity selectors.

Distribution

Responsibilities:


See license: ClientAgentJS