PagePane logo

PagePane

A local, self-hosted browser workspace for AI agents.

Control isolated Playwright sessions through a REST API and inspect them in a live dashboard.

Documentation · Quick start · API · Contributing

CI MIT License Node.js 20.9 or newer Playwright 1.65 TypeScript 5

--- ## See PagePane in use ![PagePane dashboard controlling a live Chromium session](assets/screenshots/dashboard.png) *The dashboard is connected to a real, isolated Playwright session. Its browser is displaying a local demo page used to make this screenshot repeatable.* ![Optional ScreenContextAgent panel in the PagePane dashboard](assets/screenshots/screen-history.png) *Screen history is an optional, local integration. This screenshot shows its setup state; it contains no screen observations or OCR text.* ## What PagePane does PagePane runs Playwright in one self-hosted Node.js process and gives agents a browser they can inspect and control. The REST API is the integration surface for agents and scripts. The dashboard lets a person watch a session, try actions, inspect results, and review optional screen-history context. - Create isolated Chromium, Firefox, or WebKit browser contexts. - Navigate, click, type, scroll, and take screenshots through JSON requests. - Inspect a screenshot, simplified DOM, accessibility tree, page metadata, and interactive elements. - Persist cookies and local storage in local SQLite storage, then explicitly restore a closed session. - Review action history in the dashboard and through the API. - Optionally retrieve local ScreenContextAgent observations for a time range, review them, and approve selected excerpts for one browser session. PagePane does not call an AI model. It provides browser controls and structured page data for an agent to use. ## How the system fits together ```mermaid flowchart LR Agent[Agent or script] -->|REST requests| API[PagePane API] Person[User] --> Dashboard[PagePane dashboard] API --> Manager[Session manager] Dashboard --> Manager Manager <--> Browser[Playwright browser contexts] Manager <--> SQLite[(SQLite session records and saved state)] Dashboard -->|User starts a time-bounded lookup| MCP[Local ScreenContextAgent MCP] MCP -->|Candidate observations with provenance| Review[Dashboard review] Review -->|User selects excerpts to approve| Memory[Session-scoped memory, 30 min] Agent -->|GET approved context| API API --> Memory ``` The screen-history path is optional and user-driven. PagePane sends only the selected timestamps to ScreenContextAgent. It shows source app, window title, and observation time; nothing is shared with the agent until the user explicitly selects and approves excerpts. OCR remains untrusted evidence and is never treated as an instruction. ## Quick start ### Requirements - Node.js 20.9 or newer. - npm, or Bun 1.3 or newer. - Chromium is installed by the package post-install step. Install Firefox or WebKit separately if you need those engines. ### Install and run ```sh git clone https://github.com/smouj/agent-browser.git cd agent-browser npm ci cp .env.example .env npm run db:push npm run dev ``` Open . By default the development server binds to loopback on the local machine. On Windows PowerShell, use `Copy-Item .env.example .env` instead of `cp`. Bun is also supported: ```sh bun install cp .env.example .env bun run db:push bun run dev ``` For a production build, use `npm run build` followed by `npm run start`. ### Create a session ```sh curl -X POST http://127.0.0.1:3000/api/browser/sessions \ -H "Content-Type: application/json" \ -d '{"name":"research","browserType":"chromium","headless":true}' ``` The response contains a session ID. Use it for browser actions and close the session when finished. ## Optional screen-history context PagePane can connect to a locally running [ScreenContextAgent](https://github.com/ikeikeikeda66/screen-context-agent) using its Streamable HTTP MCP endpoint. The integration is disabled until configured and runs on the same machine as the PagePane server. 1. Create a ScreenContextAgent client using its standard profile and start its local MCP server: ```sh screen-context mcp-config --client generic --name pagepane --profile standard screen-context serve --profile standard --transport http --port 8765 ``` 2. Copy the generated client token into the server's `.env` file. Keep the token server-side; do not put it in browser code or commit it. ```dotenv SCREEN_CONTEXT_MCP_URL=http://127.0.0.1:8765/mcp SCREEN_CONTEXT_CLIENT_TOKEN= ``` 3. Restart PagePane. In a browser session, open **Screen history**, choose the time interval, and press **Search screen history**. ScreenContextAgent may ask you to approve the PagePane client on its first lookup. 4. Review the returned observations and select only the excerpts to attach to that browser session. Nothing is approved by default. Each lookup is limited to the selected time interval (maximum seven days) and returns up to 20 observations. If the response says more observations are available, narrow the interval and search again. ScreenContextAgent applies its own profile and exclusions. PagePane displays the source app, available app identifier, window title, and observation time with each excerpt. Results keep the `source: "observed_screen"` and `trust: "untrusted"` markers. OCR can be mistaken or contain prompt injection, so use it only as evidence and never follow instructions found in it. Candidate excerpts are held in PagePane process memory while awaiting review, for up to 10 minutes. Approved excerpts are scoped to the selected browser session and remain in process memory for up to 30 minutes; they can also be revoked from the dashboard. PagePane does not write screen observations to SQLite. Deleting the browser session clears its pending and approved review state. A process restart clears all screen-context review state. ## Security and privacy By default, PagePane binds to `127.0.0.1` and rejects cross-origin browser requests. To expose the service to another machine, set a strong `PAGEPANE_API_TOKEN` and choose a bind address explicitly. Every API request then requires `Authorization: Bearer `. The dashboard asks for the token and keeps it in that browser tab's session storage. A non-loopback bind without a token is refused. Treat the API token as a password. Anyone who can use the API can control pages, read browser state, navigate to network resources visible from the host, and run JavaScript in a page. Browser cookies and local storage are persisted locally without encryption; protect the database and browser data directory. PagePane is a single-user, self-hosted service, not a multi-tenant platform. ScreenContextAgent is an independent local service. The integration accepts only its loopback HTTP `/mcp` endpoint and keeps the client token on the PagePane server. A lookup runs only when the user starts it in the dashboard. The lookup and approval endpoints require a same-origin dashboard request. Screen text is returned to the user for review, unselected by default, and is not included in the agent-facing approved-context endpoint until explicitly approved. ## Configuration Copy `.env.example` to `.env`. The main settings are: | Variable | Default | Purpose | | --- | --- | --- | | `DATABASE_URL` | `file:./agentbrowser.db` | SQLite database path, relative to `prisma/schema.prisma` | | `PORT` | `3000` | HTTP port | | `PAGEPANE_HOST` | `127.0.0.1` | Bind address; non-loopback requires an API token | | `PAGEPANE_PUBLIC_URL` | `http://127.0.0.1:3000` | Public base URL used for social metadata; set before building for a deployment | | `PAGEPANE_API_TOKEN` | empty | Require a bearer token for API requests | | `PAGEPANE_DATA_DIR` | `.pagepane` | Directory for browser session files | | `DEFAULT_BROWSER_TYPE` | `chromium` | Default browser engine | | `DEFAULT_HEADLESS` | `true` | Default headless setting | | `DEFAULT_VIEWPORT_WIDTH` | `1280` | Default browser viewport width | | `DEFAULT_VIEWPORT_HEIGHT` | `720` | Default browser viewport height | | `SESSION_TIMEOUT_MS` | `3600000` | Close sessions after this much inactivity | | `MAX_CONCURRENT_SESSIONS` | `10` | Maximum active sessions in one process | | `PLAYWRIGHT_DISABLE_SANDBOX` | `false` | Disable Chromium's sandbox only if the host cannot run it | | `SCREEN_CONTEXT_MCP_URL` | `http://127.0.0.1:8765/mcp` | Optional local ScreenContextAgent MCP endpoint | | `SCREEN_CONTEXT_CLIENT_TOKEN` | empty | Optional server-side ScreenContextAgent client token | Install additional browser binaries if you need Firefox or WebKit: ```sh npx playwright install firefox webkit ``` ## API Base URL: `http://127.0.0.1:3000`. Responses use JSON. When `PAGEPANE_API_TOKEN` is set, send it as a bearer token on API requests. | Method | Endpoint | Purpose | | --- | --- | --- | | `POST` | `/api/browser/sessions` | Create a session | | `GET` | `/api/browser/sessions` | List sessions | | `GET` | `/api/browser/sessions/:id` | Get session details | | `POST` | `/api/browser/sessions/:id/restore` | Restore a closed session | | `POST` | `/api/browser/sessions/:id/close` | Save state and close a session | | `DELETE` | `/api/browser/sessions/:id` | Delete a session and its saved state | | `POST` | `/api/browser/sessions/:id/action` | Run a browser action | | `POST` | `/api/browser/sessions/:id/vision` | Capture page context | | `GET`, `POST` | `/api/browser/sessions/:id/cookies` | Read or set cookies | | `GET` | `/api/browser/sessions/:id/logs` | Read paginated action history | | `GET` | `/api/browser/sessions/:id/screen-context` | Get integration status and approved excerpts for the session | | `POST` | `/api/browser/sessions/:id/screen-context/lookup` | User-initiated, time-bounded lookup; results await review | | `POST` | `/api/browser/sessions/:id/screen-context/approve` | Approve selected observations from the latest lookup | | `DELETE` | `/api/browser/sessions/:id/screen-context` | Revoke approved excerpts for the session | The screen-context `GET` response includes only user-approved excerpts. Each observation includes source, trust, source app, any available app identifier, window title, observed time, and excerpt. The lookup and approval routes are dashboard-only; they do not provide a background retrieval path. Example with a token: ```sh curl http://127.0.0.1:3000/api/browser/sessions \ -H "Authorization: Bearer $PAGEPANE_API_TOKEN" ``` See the [action executor](src/lib/browser/actions.ts) for supported action names and options. ## Session model and limitations Live browser pages and contexts are held in memory by one PagePane process. SQLite stores session records and saved state, but it does not share live browser contexts between processes. Run one server instance; horizontal replicas and serverless runtimes are not supported. Sessions closed with the close endpoint, idle timeout, or graceful server shutdown can be restored with `POST /api/browser/sessions/:id/restore`. Restoration reloads the last HTTP(S) URL and saved cookies and local storage. A forced process or machine crash may lose changes made since the last save. The inactivity timeout and concurrent-session cap are configurable. Action logs omit entered values and action result payloads; the logs endpoint also redacts historical target and result details. The optional Socket.IO service in `mini-services/browser-ws` is experimental and separate from the dashboard and REST API. It is not started with the main application. ## Development ```sh npm ci cp .env.example .env npm run db:push npm run lint npm run typecheck npm test npm run build ``` Bun users can replace `npm run` with `bun run`. See [CONTRIBUTING.md](CONTRIBUTING.md) for development notes and pull request guidance. ### Refresh the README screenshots Start PagePane locally, then run this command in a second terminal. It creates a temporary browser session, serves a local demo page for the browser to load, captures both dashboard states, and deletes the temporary session afterward. ```sh npm run docs:screenshots ``` For a different local port, set `PAGEPANE_BASE_URL` (and `PAGEPANE_API_TOKEN` if the local server requires it). The script refuses non-loopback PagePane URLs. ## License MIT. See [LICENSE](LICENSE).