HTTP Server
Use the HTTP server when the browser controller runs beside an app, agent runtime, or local desktop shell. The server is useful for tool routers and demos, but production apps should still put auth, identity, and permission checks at their own boundary.
Server
Section titled “Server”import { AgentBrowser } from "@cmmd-center/agent-browser";import { PlaywrightBackend } from "@cmmd-center/agent-browser/playwright";import { createBrowserHttpServer } from "@cmmd-center/agent-browser/server";
const browser = new AgentBrowser({ backend: new PlaywrightBackend({ headless: false })});
const app = createBrowserHttpServer({ browser, apiKey: process.env.AGENT_BROWSER_API_KEY, allowedOrigins: [/^https:\/\/.*\.cmmd\.ai$/], preview: { enabled: false }});
app.listen(7357);Use preview: { enabled: false } for production hosts that render their own browser surface. /preview is a demo/debug page, not the product UI.
Client
Section titled “Client”import { AgentBrowserHttpClient } from "@cmmd-center/agent-browser/client";
const browser = new AgentBrowserHttpClient({ baseUrl: "http://localhost:7357", apiKey: process.env.AGENT_BROWSER_API_KEY, sessionId: "default"});
await browser.goto("https://docs.cmmd.ai");
const snapshot = await browser.snapshot();const screenshot = await browser.screenshot({ fullPage: true });The client adds auth headers, carries the configured sessionId, handles JSON/text/binary responses, and surfaces error response text.
Core Routes
Section titled “Core Routes”| Route | Use |
|---|---|
GET /health | Readiness check. |
POST /shutdown | Controlled shutdown hook. |
GET /session | Current session state. |
GET /events | Server-sent event stream. |
GET /screenshot | Current screenshot bytes. |
POST /screenshots | Capture and store screenshot artifacts. |
POST /tabs | Create tabs. |
POST /goto, /reload, /back, /forward | Navigation. |
POST /snapshot, /logs | Observability. |
POST /click, /fill, /press, /select | Element actions. |
POST /cua/click, /dom-cua/click | CUA and DOM-CUA actions. |
POST /annotations, /comments, /cursor | Collaboration events. |
Durable Events And Artifacts
Section titled “Durable Events And Artifacts”import { EventHub, FileScreenshotArtifactStore, JsonlEventSink} from "@cmmd-center/agent-browser";
const events = new EventHub(new JsonlEventSink(".agent-browser/events.jsonl"));const artifacts = new FileScreenshotArtifactStore(".agent-browser/artifacts");
createBrowserHttpServer({ browser, events, artifacts });Use memory stores for tests and demos. Use JSONL/file stores, or a host-owned database implementation, when sessions need replay or auditability.