Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

test(screen-worker): cover the agent-screen caster's core path and correct its README

nirholas4daf9122f58b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46704b1e2..7486a2708 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Generating an animation from a text prompt no longer fails when the motion engine has been idle**: Ask for a custom animation ("a slow tai-chi sweep") and the motion engine has to wake up before it can generate. In its region three other, idle 3D engines were each holding a graphics card warm, so there was nothing left for the motion engine to start on, and roughly twice a day it was refused a card outright and the request failed. The idle holder has been released, so the motion lane can always start. Generation itself is unchanged: a three second prompt still comes back in under three seconds once warm. (`/animations`) `[fix, infra]`
- **Motion Swap's guide now describes the hand and finger capture it has been doing all along**: The Motion Swap guide described body tracking only, so a reader had no way to know the capture also follows both hands, takes wrist rotation from the palm itself, and solves every finger joint, or that it holds your last handshape when your hands leave the frame. The guide and the capture worker's README now cover all of that, plus the exact files a capture produces, every setting the worker reads, and how to run a real capture on your own machine to check a change before it ships. The worker also gained a second test suite covering the parts around the motion solver: the authentication and input rules on its API, the video normalization step, the person-mask video, and the guard that refuses to fetch a video address pointing at our own internal infrastructure. (`/motion-swap`) `[docs, improvement]`
- **Photo to 3D no longer fails when the image host has one slow moment**: Turning a photo into a 3D model starts by downloading the image you pointed at. If that download stalled for even a moment, the whole generation failed and you had to start over. The image is now fetched up to three times with a growing pause between tries, so a single slow moment costs a couple of seconds instead of the job. When an image genuinely cannot be used, the failure now names the reason and the host (unreachable, HTTP 404, not a decodable image) instead of an opaque error code, so you can tell a broken link from a hiccup. (`/create`) `[fix, improvement]`
+- **Sending your agent a task on its live screen actually works again**: The agent screen lets you queue a task for your own agent and watch it browse the web to carry it out. None of that path worked. Queuing a task failed on the server because it looked your agent up in a table that does not exist, so the browser worker polled forever and never saw a task. The worker was broken twice over on its own side too: it read the agent's id from the wrong place, so every frame it published was rejected before it reached the stream, and it drove the browser through a method that moved in version 3 of the automation library, so typing, clicking, reading a page, and even taking a screenshot all failed. All three are fixed and the worker now runs end to end: it picks up your task, navigates, narrates each step, and streams real screenshots. The same bad lookup also blocked grinding a vanity wallet address for an agent, which is fixed as well. (`/agent-screen`) `[fix]`
- **Stylizing a model no longer throws away the finished result over a momentary network hiccup, and plain models keep their intended color**: The stylize filters (voxel, brick, voronoi shell, low-poly) rebuild your model and then upload the result to storage. A brief interruption on that last upload step was not retried, so roughly once a week a job that had already done all its work was reported to you as failed. That upload now retries by itself. Two more repairs ride along: a model that carries no colors of its own now comes back in the soft neutral tone the filters were designed around, instead of the flat gray the geometry library hands out by default, and a model with no size at all is refused with a clear reason rather than returning a file with nothing visible in it. (`/forge`) `[fix, improvement]`
- **The 3D forge now tells a broken GPU worker apart from a healthy one, and stops routing your generation at it**: Our own Hunyuan3D image-to-3D workers answer web requests within seconds of starting, then spend several minutes loading multi-gigabyte model weights in the background. The platform checked only whether a worker answered at all, so a worker that had answered but then failed to load its model looked exactly as healthy as a working one: the forge status page showed it green and generations kept being sent to it. Both the status page and the routing that picks a backend now read the worker's real readiness, so a worker that cannot generate is reported as down and skipped, and one that is still warming up is marked as such instead of promising a fast turnaround it cannot deliver. (`/forge`) `[fix, infra]`
- **The pump.fun MCP server now returns the real name and symbol for tokens launched today**: Ask the pump.fun MCP server for a token's details and it reported no name, no symbol, and no image link for essentially every coin launched recently, including $THREE. The reason: pump.fun now mints Token-2022 tokens, which carry their name and symbol inside the mint itself rather than in the separate metadata account the server was reading. It now reads both places, so a request for a current token returns its actual name, symbol, and metadata link alongside supply and decimals. Older tokens are unaffected. (`/docs/mcp`) `[fix]`
diff --git a/public/changelog.json b/public/changelog.json
index 450354026..3fb5a6975 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-08-11T01:50:57.968Z",
+ "generated_at": "2026-08-11T01:51:40.906Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -83,6 +83,16 @@
"improvement"
]
},
+ {
+ "date": "2026-08-11",
+ "type": "update",
+ "title": "Sending your agent a task on its live screen actually works again",
+ "summary": "The agent screen lets you queue a task for your own agent and watch it browse the web to carry it out. None of that path worked. Queuing a task failed on the server because it looked your agent up in a table that does not exist, so the browser worker polled forever and never saw a task. The worker was broken twice over on its own side too: it read the agent's id from the wrong place, so every frame it published was rejected before it reached the stream, and it drove the browser through a method that moved in version 3 of the automation library, so typing, clicking, reading a page, and even taking a screenshot all failed. All three are fixed and the worker now runs end to end: it picks up your task, navigates, narrates each step, and streams real screenshots. The same bad lookup also blocked grinding a vanity wallet address for an agent, which is fixed as well.",
+ "link": "/agent-screen",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-08-11",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 257f740be..db11707b9 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -62,6 +62,14 @@
<category>fix</category>
<description>Turning a photo into a 3D model starts by downloading the image you pointed at. If that download stalled for even a moment, the whole generation failed and you had to start over. The image is now fetched up to three times with a growing pause between tries, so a single slow moment costs a couple of seconds instead of the job. When an image genuinely cannot be used, the failure now names the reason and the host (unreachable, HTTP 404, not a decodable image) instead of an opaque error code, so you can tell a broken link from a hiccup.</description>
</item>
+ <item>
+ <title>Sending your agent a task on its live screen actually works again</title>
+ <link>https://three.ws/agent-screen</link>
+ <guid isPermaLink="false">2026-08-11:Sending your agent a task on its live screen actually works again</guid>
+ <pubDate>Tue, 11 Aug 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The agent screen lets you queue a task for your own agent and watch it browse the web to carry it out. None of that path worked. Queuing a task failed on the server because it looked your agent up in a table that does not exist, so the browser worker polled forever and never saw a task. The worker was broken twice over on its own side too: it read the agent's id from the wrong place, so every frame it published was rejected before it reached the stream, and it drove the browser through a method that moved in version 3 of the automation library, so typing, clicking, reading a page, and even taking a screenshot all failed. All three are fixed and the worker now runs end to end: it picks up your task, navigates, narrates each step, and streams real screenshots. The same bad lookup also blocked grinding a vanity wallet address for an agent, which is fixed as well.</description>
+ </item>
<item>
<title>Stylizing a model no longer throws away the finished result over a momentary network hiccup, and plain models keep their intended color</title>
<link>https://three.ws/forge</link>
diff --git a/public/features.json b/public/features.json
index b79ec4876..f2aeb6d3c 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-08-11T01:50:57.944Z",
+ "generated_at": "2026-08-11T01:51:40.815Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/tests/agent-screen-worker-smoke.test.js b/tests/agent-screen-worker-smoke.test.js
new file mode 100644
index 000000000..c24fd9767
--- /dev/null
+++ b/tests/agent-screen-worker-smoke.test.js
@@ -0,0 +1,301 @@
+/**
+ * agent-screen-worker core-path smoke test.
+ *
+ * Exercises the worker's real transport end to end: a local HTTP server stands
+ * in for /api/agent-screen-push and /api/agent-task, and the worker's own
+ * capture.js + task-runner.js run against it over real fetch. Nothing in the
+ * worker is stubbed. Only the browser handle is a double, so the test can run
+ * without launching Chrome.
+ *
+ * What this pins (each line is a bug this worker actually shipped):
+ * 1. Every pushed frame carries the agent id. task-runner.js read `cfg.agentId`
+ * while config.js exports `AGENT_ID`, so every frame went out with
+ * `agentId: undefined` and the push endpoint rejected all of them with 400
+ * missing_agent_id. The startup frame from index.js was the only one that
+ * ever landed.
+ * 2. act()/extract() are called on the Stagehand instance with the page passed
+ * as an option. Stagehand v3 moved them off the page object, so the old
+ * `page.act(...)` calls threw on every interactive step.
+ * 3. A failing task poll is reported, not swallowed. The GET side of
+ * /api/agent-task was querying a table that does not exist; the worker
+ * silently treated the 500 as "no task queued" and idled forever.
+ */
+
+import { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest';
+import { createServer } from 'node:http';
+import { pushFrame } from '../workers/agent-screen-worker/capture.js';
+import {
+ pollForTask,
+ runQueuedTask,
+ runAutonomousCycle,
+ pickStartUrl,
+ breakTaskIntoSteps,
+} from '../workers/agent-screen-worker/task-runner.js';
+
+const AGENT_ID = '11111111-2222-3333-4444-555555555555';
+const AGENT_JWT = 'test-agent-bearer-token';
+
+// A 1x1 PNG. The worker base64-encodes whatever the browser hands back, so a
+// real (tiny) PNG keeps the data-URL assertion honest.
+const PNG = Buffer.from(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==',
+ 'base64',
+);
+
+let server;
+let baseUrl;
+/** Frames the stand-in push endpoint received, in order. */
+let received;
+/** Tasks the stand-in task endpoint hands out, drained FIFO. */
+let taskQueue;
+/** Status the task endpoint should answer with (to simulate a broken endpoint). */
+let taskStatus;
+
+beforeAll(async () => {
+ server = createServer((req, res) => {
+ const url = new URL(req.url, 'http://localhost');
+
+ if (url.pathname === '/api/agent-task') {
+ if (taskStatus !== 200) {
+ res.writeHead(taskStatus, { 'content-type': 'application/json' });
+ return res.end(JSON.stringify({ error: 'server_error' }));
+ }
+ res.writeHead(200, { 'content-type': 'application/json' });
+ return res.end(JSON.stringify({ task: taskQueue.shift() || null }));
+ }
+
+ if (url.pathname === '/api/agent-screen-push') {
+ let raw = '';
+ req.on('data', (c) => { raw += c; });
+ return req.on('end', () => {
+ const body = JSON.parse(raw);
+ // Mirror the real endpoint's contract: agentId is mandatory.
+ if (!body.agentId || typeof body.agentId !== 'string') {
+ res.writeHead(400, { 'content-type': 'application/json' });
+ return res.end(JSON.stringify({ error: 'missing_agent_id' }));
+ }
+ received.push({ ...body, authorization: req.headers.authorization });
+ res.writeHead(200, { 'content-type': 'application/json' });
+ res.end(JSON.stringify({ ok: true }));
+ });
+ }
+
+ res.writeHead(404);
+ res.end();
+ });
+
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
+ baseUrl = `http://127.0.0.1:${server.address().port}`;
+});
+
+afterAll(() => new Promise((resolve) => server.close(resolve)));
+
+beforeEach(() => {
+ received = [];
+ taskQueue = [];
+ taskStatus = 200;
+});
+
+function makeCfg(overrides = {}) {
+ return {
+ AGENT_ID,
+ AGENT_JWT,
+ PUSH_URL: `${baseUrl}/api/agent-screen-push`,
+ TASK_URL: `${baseUrl}/api/agent-task`,
+ HOME_URL: 'https://three.ws',
+ // 0 disables screenshot throttling so every frame in a short test carries
+ // an image, instead of the module-level throttle silently downgrading it.
+ SCREENSHOT_INTERVAL_MS: 0,
+ CYCLE_MS: 1,
+ ...overrides,
+ };
+}
+
+// The push() binding index.js hands the runner.
+function makePush(cfg) {
+ return ({ agentId, page, activity, type }) =>
+ pushFrame({
+ agentId,
+ page,
+ activity,
+ type,
+ pushUrl: cfg.PUSH_URL,
+ agentJwt: cfg.AGENT_JWT,
+ screenshotIntervalMs: cfg.SCREENSHOT_INTERVAL_MS,
+ });
+}
+
+// Stand-in for the Stagehand v3 page handle (stagehand.context.activePage()).
+function makePage(startUrl = 'https://three.ws/') {
+ let current = startUrl;
+ const calls = { goto: [], screenshot: 0 };
+ return {
+ calls,
+ url: () => current,
+ async goto(target) { calls.goto.push(target); current = target; },
+ async screenshot() { calls.screenshot += 1; return PNG; },
+ };
+}
+
+describe('pushFrame transport', () => {
+ it('sends the agent id, the bearer token and a raster data URL', async () => {
+ const cfg = makeCfg();
+ const page = makePage();
+ await makePush(cfg)({ agentId: cfg.AGENT_ID, page, activity: 'hello', type: 'screenshot' });
+
+ expect(received).toHaveLength(1);
+ expect(received[0].agentId).toBe(AGENT_ID);
+ expect(received[0].authorization).toBe(`Bearer ${AGENT_JWT}`);
+ expect(received[0].frame.activity).toBe('hello');
+ expect(received[0].frame.data).toMatch(/^data:image\/png;base64,[A-Za-z0-9+/=]+$/);
+ });
+
+ it('degrades to a text-only frame when there is no page handle', async () => {
+ const cfg = makeCfg();
+ await makePush(cfg)({ agentId: cfg.AGENT_ID, page: null, activity: 'no browser', type: 'screenshot' });
+
+ expect(received).toHaveLength(1);
+ expect(received[0].frame.data).toBeNull();
+ });
+});
+
+describe('idle cycle', () => {
+ it('pushes a standing-by frame that carries the agent id', async () => {
+ const cfg = makeCfg();
+ const page = makePage();
+ await runAutonomousCycle({ page, cfg, push: makePush(cfg) });
+
+ expect(received.length).toBeGreaterThan(0);
+ for (const frame of received) expect(frame.agentId).toBe(AGENT_ID);
+ const last = received.at(-1);
+ expect(last.frame.activity).toMatch(/standing by/i);
+ expect(last.frame.data).toMatch(/^data:image\/png;base64,/);
+ });
+
+ it('navigates home only when the browser has drifted off it', async () => {
+ const cfg = makeCfg();
+ const onHome = makePage('https://three.ws/create');
+ await runAutonomousCycle({ page: onHome, cfg, push: makePush(cfg) });
+ expect(onHome.calls.goto).toEqual([]);
+
+ const drifted = makePage('https://news.ycombinator.com/');
+ await runAutonomousCycle({ page: drifted, cfg, push: makePush(cfg) });
+ expect(drifted.calls.goto).toEqual(['https://three.ws']);
+ });
+});
+
+describe('task polling', () => {
+ it('returns the queued task the platform hands back', async () => {
+ taskQueue = [{ text: 'find the weather in Bucharest', type: 'research', ts: 1 }];
+ const task = await pollForTask(makeCfg());
+ expect(task.text).toBe('find the weather in Bucharest');
+ });
+
+ it('returns null on an empty queue and on a failing endpoint', async () => {
+ expect(await pollForTask(makeCfg())).toBeNull();
+ taskStatus = 500;
+ expect(await pollForTask(makeCfg())).toBeNull();
+ });
+});
+
+describe('queued task execution', () => {
+ it('runs a research task end to end with every frame carrying the agent id', async () => {
+ const cfg = makeCfg();
+ const page = makePage();
+ const actCalls = [];
+ const extractCalls = [];
+ const stagehand = {
+ async act(instruction, options) { actCalls.push({ instruction, options }); return { success: true }; },
+ async extract(instruction, schema, options) {
+ extractCalls.push({ instruction, schema, options });
+ return { result: 'Bucharest is 19C and clear.' };
+ },
+ };
+
+ await runQueuedTask({
+ stagehand,
+ page,
+ cfg,
+ push: makePush(cfg),
+ task: { text: 'what is the weather in Bucharest', type: 'research', ts: 1 },
+ });
+
+ // Every frame reached the endpoint, which means none was rejected for a
+ // missing agent id.
+ expect(received.length).toBeGreaterThan(3);
+ for (const frame of received) expect(frame.agentId).toBe(AGENT_ID);
+
+ // Navigation used the routed start URL for a weather task.
+ expect(page.calls.goto).toEqual(['https://weather.com']);
+
+ // extract() ran on the Stagehand instance with the page passed through,
+ // and its result was narrated into the stream.
+ expect(extractCalls).toHaveLength(1);
+ expect(extractCalls[0].options.page).toBe(page);
+ expect(received.some((f) => f.frame.activity.includes('Bucharest is 19C'))).toBe(true);
+
+ // A research task observes and extracts; it does not click anything.
+ expect(actCalls).toHaveLength(0);
+
+ const last = received.at(-1);
+ expect(last.frame.activity).toMatch(/^Task complete:/);
+ }, 30_000);
+
+ it('drives act() through the Stagehand instance for an interactive task', async () => {
+ const cfg = makeCfg();
+ const page = makePage();
+ const actCalls = [];
+ const stagehand = {
+ async act(instruction, options) { actCalls.push({ instruction, options }); return { success: true }; },
+ async extract() { return { result: 'done' }; },
+ };
+
+ await runQueuedTask({
+ stagehand,
+ page,
+ cfg,
+ push: makePush(cfg),
+ task: { text: 'search reddit for three.ws', type: 'browse', ts: 1 },
+ });
+
+ expect(actCalls).toHaveLength(1);
+ expect(actCalls[0].instruction).toBe('search reddit for three.ws');
+ expect(actCalls[0].options.page).toBe(page);
+ for (const frame of received) expect(frame.agentId).toBe(AGENT_ID);
+ }, 30_000);
+
+ it('narrates a step failure instead of aborting the task', async () => {
+ const cfg = makeCfg();
+ const page = makePage();
+ const stagehand = {
+ async act() { throw new Error('element not found'); },
+ async extract() { return { result: 'recovered' }; },
+ };
+
+ await runQueuedTask({
+ stagehand,
+ page,
+ cfg,
+ push: makePush(cfg),
+ task: { text: 'buy a lamp', type: 'browse', ts: 1 },
+ });
+
+ expect(received.some((f) => f.frame.activity === 'Step failed: element not found')).toBe(true);
+ expect(received.at(-1).frame.activity).toMatch(/^Task complete:/);
+ }, 30_000);
+});
+
+describe('task routing helpers', () => {
+ it('routes a task to a topical start page and falls back to search', () => {
+ expect(pickStartUrl('check the weather')).toBe('https://weather.com');
+ expect(pickStartUrl('browse reddit')).toBe('https://www.reddit.com');
+ expect(pickStartUrl('quantum computing explainer')).toBe(
+ 'https://www.google.com/search?q=quantum%20computing%20explainer',
+ );
+ });
+
+ it('gives research tasks a read-only plan and other tasks an interactive one', () => {
+ expect(breakTaskIntoSteps('x', 'research').map((s) => s.action)).toEqual(['observe', 'extract']);
+ expect(breakTaskIntoSteps('x', 'browse').map((s) => s.action)).toEqual(['observe', 'act', 'extract']);
+ });
+});
diff --git a/workers/agent-screen-worker/.dockerignore b/workers/agent-screen-worker/.dockerignore
new file mode 100644
index 000000000..3f5266e4a
--- /dev/null
+++ b/workers/agent-screen-worker/.dockerignore
@@ -0,0 +1,11 @@
+# Build context excludes. The image installs its own deps with `npm ci`, so the
+# host's node_modules must never be copied over them (it would clobber a clean,
+# platform-correct install). Secrets and local logs never enter a build context.
+node_modules
+npm-debug.log
+*.log
+.env
+.env.*
+README.md
+Dockerfile
+.dockerignore
diff --git a/workers/agent-screen-worker/README.md b/workers/agent-screen-worker/README.md
index 6289510d6..c00feeb6d 100644
--- a/workers/agent-screen-worker/README.md
+++ b/workers/agent-screen-worker/README.md
@@ -2,30 +2,45 @@
Long-lived Node.js worker that drives a real browser via [Stagehand](https://github.com/browserbasehq/stagehand), captures screenshots on every meaningful state change, and pushes frames to the three.ws live agent screen stream.
+## Where this runs
+
+**It is owner-run, not a three.ws service.** There is no Cloud Run deployment and no `cloudbuild.yaml` on purpose: this worker authenticates *as one specific agent* with that agent's own `AGENT_JWT`, and it browses under the agent owner's own Browserbase and Anthropic keys. The platform never holds those, so the process runs wherever the owner wants it: a laptop, a VM, or a container they operate.
+
+The `/agent-screen` setup wizard mints a real `AGENT_JWT` for a selected agent and hands the owner the exact command to run, for all three runtimes below (see [src/agent-screen-runcmd.js](../../src/agent-screen-runcmd.js)).
+
+For a *platform-operated* caster that spins browsers on demand for whichever agents viewers are watching, see the sibling [workers/agent-screen-pool](../agent-screen-pool) instead. That one is a first-party service with a shared secret; this one is per-agent and owner-run.
+
## Architecture
```
-index.js boot Stagehand, wire graceful shutdown, start task loop
-config.js env loading + validation
+index.js boot Stagehand, resolve the page handle, wire graceful shutdown, start the task loop
+config.js env loading + validation + local Chrome launch options
capture.js screenshot + push-to-API with per-interval throttling
-task-runner.js autonomous task the agent performs (pump.fun scan by default)
+task-runner.js poll for user-queued tasks, execute them, idle neutrally in between
```
-Frames land at `/api/agent-screen-push` → Redis TTL key → SSE stream at `/api/agent-screen-stream` → rendered by `/agent-screen?agentId=<uuid>` and the 3D desk in `/play`.
+Frames land at `/api/agent-screen-push` -> Redis TTL key -> SSE stream at `/api/agent-screen-stream` -> rendered by `/agent-screen?agentId=<uuid>` and the 3D desk in `/play`.
+
+Tasks flow the other way: a user queues one from `/agent-screen` -> `POST /api/agent-task` -> Redis list -> the worker's `GET /api/agent-task` poll -> Stagehand `act()` / `extract()`.
## Quick start
-### Local Playwright (development)
+### Local browser (development)
+
+Stagehand v3 launches Chrome over CDP through `chrome-launcher`. It does **not** use Playwright's bundled browsers, so local mode needs a real Chrome or Chromium on the machine. `chrome-launcher` finds a system install on its own; point `CHROME_PATH` at anything else, including a Playwright-installed Chromium:
```bash
cd workers/agent-screen-worker
npm install
export AGENT_ID=<uuid-from-db>
export AGENT_JWT=<bearer-token>
+export ANTHROPIC_API_KEY=<your-key>
+# only if you have no system Chrome:
+export CHROME_PATH=$(node -e "console.log(require('playwright').chromium.executablePath())")
npm start
```
-Open `https://three.ws/agent-screen?agentId=<uuid>` — frames appear within seconds.
+Open `https://three.ws/agent-screen?agentId=<uuid>`; frames appear within seconds.
### Docker (self-hosted)
@@ -34,53 +49,79 @@ docker build -t agent-screen-worker .
docker run --env-file .env agent-screen-worker
```
-### Browserbase cloud (production, zero-infra)
+The image installs Chromium and sets `CHROME_PATH` for you. It runs as root, where Chrome refuses to start its sandbox, so the worker drops the sandbox automatically in that case (see `CHROME_NO_SANDBOX` below).
+
+### Browserbase cloud (zero-infra)
-No Docker needed. Run as a plain Node process or in any VM:
+No Docker and no local browser needed. Run as a plain Node process or in any VM:
```bash
-export BROWSERBASE_API_KEY=... # the only Browserbase value — no project id needed
-export ANTHROPIC_API_KEY=... # drives page.act()/page.extract() — see below
+export BROWSERBASE_API_KEY=... # the only Browserbase value; no project id needed
+export ANTHROPIC_API_KEY=... # drives act()/extract(), see below
export AGENT_ID=...
export AGENT_JWT=...
npm start
```
> **`ANTHROPIC_API_KEY` is what makes the agent *do* things.** Stagehand's
-> `page.act()` (type, click, submit) and `page.extract()` (read the page) are
-> LLM-driven. Without a key the agent still opens the browser, navigates, and
-> screenshots — but every interactive step fails. Set it to see the agent
-> actually work a task, not just load pages.
+> `act()` (type, click, submit) and `extract()` (read the page) are LLM-driven.
+> Without a key the agent still opens the browser, navigates, and screenshots,
+> but every interactive step fails with a missing-key error that the worker
+> narrates into the activity log. Set it to see the agent actually work a task,
+> not just load pages.
## Environment variables
| Variable | Required | Default | Description |
|---|---|---|---|
-| `AGENT_ID` | yes | — | UUID of the agent that owns this screen stream |
-| `AGENT_JWT` | yes | — | Bearer token for that agent |
-| `PUSH_URL` | no | `https://three.ws/api/agent-screen-push` | Push endpoint override |
-| `BROWSERBASE_API_KEY` | no | — | Browserbase API key (cloud mode) |
-| `BROWSERBASE_PROJECT_ID` | no | — | Not required — Browserbase resolves the project from the API key. Leave unset. |
-| `ANTHROPIC_API_KEY` | recommended | — | Drives `page.act()`/`page.extract()`. Without it the agent navigates + screenshots but can't type, click, or read pages. |
-| `STAGEHAND_MODEL` | no | `anthropic/claude-opus-4-8` | Model for act/extract. Keep the `anthropic/` prefix (routes to Stagehand's Anthropic client). Use `anthropic/claude-haiku-4-5` for cheaper, faster casting at high volume. |
-| `CYCLE_MS` | no | `30000` | Task loop cycle time in ms |
+| `AGENT_ID` | yes | none | UUID of the agent that owns this screen stream |
+| `AGENT_JWT` | yes | none | Bearer token for that agent |
+| `PUSH_URL` | no | `https://three.ws/api/agent-screen-push` | Frame push endpoint override |
+| `TASK_URL` | no | `https://three.ws/api/agent-task` | Task poll endpoint override |
+| `HOME_URL` | no | `https://three.ws` | Page the agent rests on while idle |
+| `BROWSERBASE_API_KEY` | no | none | Browserbase API key. Setting it switches the worker to cloud mode |
+| `BROWSERBASE_PROJECT_ID` | no | none | Not required. Browserbase resolves the project from the API key. Leave unset |
+| `ANTHROPIC_API_KEY` | recommended | none | Drives `act()`/`extract()`. Without it the agent navigates and screenshots but can't type, click, or read pages |
+| `STAGEHAND_MODEL` | no | `anthropic/claude-opus-4-8` | Model for act/extract. Keep the `anthropic/` prefix. Use `anthropic/claude-haiku-4-5` for cheaper, faster casting at high volume |
+| `CHROME_PATH` | no | auto-detected | Chrome/Chromium executable for local browser mode. Ignored in Browserbase mode |
+| `CHROME_HEADLESS` | no | `1` | Set to `0` to watch the browser in a visible window |
+| `CHROME_NO_SANDBOX` | no | auto | The Chrome sandbox stays on wherever it works, and is dropped automatically when running as uid 0 (the container default), where Chrome refuses to start with it. Set to `1` to force it off on a host whose kernel blocks user namespaces |
+| `CYCLE_MS` | no | `30000` | Idle loop cycle time in ms |
| `SCREENSHOT_INTERVAL_MS` | no | `5000` | Minimum ms between full screenshots (text-only pushes fill the gap) |
+## What the agent does
+
+**Queued tasks.** The worker polls `GET /api/agent-task` every cycle. When a user queues a task from `/agent-screen`, the worker picks a start URL for it, navigates, then runs `observe` / `act` / `extract` steps through Stagehand, narrating each step into the live feed. A step that fails is narrated and the task continues; it never takes the worker down.
+
+**Idle.** With no task queued, the worker rests on `HOME_URL` and pushes a "standing by" frame each cycle. The idle mission is deliberately content-agnostic: it never scans, ranks, or narrates third-party tokens or markets. Every real action is user-directed. [tests/agent-screen-worker-compliance.test.js](../../tests/agent-screen-worker-compliance.test.js) pins that invariant.
+
## Customising the task
-Edit `task-runner.js`. The default task scans pump.fun for trending tokens and narrates findings. Replace or extend `runTask()` for your agent's actual mission.
+Edit `task-runner.js`. `pickStartUrl()` routes a task's text to a starting site and `breakTaskIntoSteps()` turns it into the step plan; replace or extend either for your agent's actual mission.
The `push()` helper accepts `type` values that control how the dashboard styles the entry:
| type | meaning |
|---|---|
-| `screenshot` | Full frame — triggers a screenshot if interval has elapsed |
+| `screenshot` | Full frame; triggers a screenshot if the interval has elapsed |
| `activity` | Text-only log entry |
| `trade` | Trade-related event (styled differently in the log) |
| `analysis` | Research / analysis step |
+Note that `act()` and `extract()` are methods on the **Stagehand instance** in v3, not on the page, and take the target page as an option: `stagehand.act(instruction, { page })`.
+
## Dockerfile build args
| Arg | Default | Description |
|---|---|---|
-| `SKIP_BROWSERS` | `0` | Set to `1` to skip `playwright install` (Browserbase-only deployments) |
+| `SKIP_BROWSERS` | `0` | Set to `1` to skip the Chromium install for Browserbase-only deployments. Produces a much smaller image |
+
+## Tests
+
+Run from the repo root:
+
+```bash
+npx vitest run tests/agent-screen-worker-smoke.test.js tests/agent-screen-worker-compliance.test.js
+```
+
+[tests/agent-screen-worker-smoke.test.js](../../tests/agent-screen-worker-smoke.test.js) exercises the real transport: capture.js and task-runner.js run over real `fetch` against a local stand-in for `/api/agent-screen-push` and `/api/agent-task`, asserting every frame carries its agent id, that act/extract are driven through the Stagehand instance, and that a failing step is narrated rather than fatal.