Workers
Extension gateway
The gateway between the Ultron browser extension and the rest of the platform. Each connected user has their own Durable Object instance holding extension state: open tabs, queued events, current selection, last command. Acts as a thin authenticated proxy so the extension never has direct credentials for downstream surfaces.
Updated today
Overview
At a glance
- Worker
extension-gateway- Durable Object
UserExtensionDO- DO key
- (user_id, extension_session)
- Purpose
- Proxy + per-user state for the browser extension
- Auth
- Short-lived tokens issued by edge-auth, validated per call
Worker shape
wrangler.toml (key bindings)toml
UserExtensionDO
One DO per connected user.
src/index.ts (DO sketch)ts
Note
The DO is the single source of truth for the extension's state. A page reload in the browser does not lose anything; the next ping pulls the state back from the DO.
Endpoints
| Method + path | Body | Returns |
|---|---|---|
| POST /report-tab | { tabId, url, title, ts } | ok |
| POST /report-selection | { text, url, ts } | ok |
| POST /queue | { kind, payload } | ok (event queued) |
| GET /flush | - | Array of queued events; clears the queue |
| POST /act | { prompt, scopes? } | Streams the chat-v2 response back to the extension |
| GET /state | - | Snapshot of DO state for diagnostics |
| POST /pin-note | { noteId } | Pin a brain note for quick access |
Per-tab session state
The extension reports tab events into the gateway so the DO always knows what page the user is looking at. When the user invokes the extension, the gateway can build context from current tab + recent tabs without an extra round trip to the browser. This makes "summarise this page" or "save this contact to leads" actions fast and stateless on the extension side.
| State key | Updated by | Used by |
|---|---|---|
| open_tabs | POST /report-tab | POST /act when the prompt needs current-tab context |
| last_selection | POST /report-selection | POST /act for selection-driven prompts |
| queued_events | POST /queue | GET /flush from a follow-up extension call |
| pinned_brain_notes | POST /pin-note | POST /act injects pinned notes as context |
File map
cf-workers/extension-gateway
wrangler.toml
src
index.tsDO class, route table, app proxy
auth.tstoken validation against edge-auth
act.tsstreaming proxy to chat-v2