Skip to content

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.

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.

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.

RouteUse
GET /healthReadiness check.
POST /shutdownControlled shutdown hook.
GET /sessionCurrent session state.
GET /eventsServer-sent event stream.
GET /screenshotCurrent screenshot bytes.
POST /screenshotsCapture and store screenshot artifacts.
POST /tabsCreate tabs.
POST /goto, /reload, /back, /forwardNavigation.
POST /snapshot, /logsObservability.
POST /click, /fill, /press, /selectElement actions.
POST /cua/click, /dom-cua/clickCUA and DOM-CUA actions.
POST /annotations, /comments, /cursorCollaboration events.
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.