Guide to migrating AgentBay Linux desktop to FC Agent Sandbox Desktop
Migrate Wuying AgentBay to FC Agent Sandbox e2b-desktop by mapping session.computer methods to e2b-desktop equivalents, building the Desktop template, and integrating noVNC for live desktop access.
Capability mapping
Method names and signatures are subject to the published e2b-desktop SDK. Some capabilities are supplemented by shell commands inside the sandbox and are labeled Aligned with shell commands in the following table.
|
Wuying AgentBay |
|
Description |
|
Mouse |
||
|
|
|
Pass the coordinates directly; the two-step approach with |
|
|
|
Same as above. |
|
|
|
Same name. |
|
|
|
Different signature; tuple parameters. |
|
|
|
Same name. |
|
|
|
No coordinate parameters; move first and then scroll. |
|
|
|
Aligned with shell commands. |
|
Keyboard |
||
|
|
|
Different method name. |
|
|
|
A single key, or a list of the keys that make up one key combination. |
|
|
|
Aligned with shell commands. |
|
Screenshot |
||
|
|
|
Same name; PNG bytes. |
|
|
|
Aligned with shell commands (scrot supports jpg/png; jpg must be read explicitly as bytes). |
|
Screen information |
||
|
|
|
Aligned with shell commands. |
|
|
|
Same name. |
|
Window management |
||
|
|
|
Aligned with shell commands. |
|
|
|
Aligned with shell commands. |
|
|
|
Aligned with shell commands. |
|
|
|
Aligned with shell commands. |
|
|
|
Aligned with shell commands (for terminal-based applications, the window dimensions are rounded to character cells). |
|
|
|
Aligned with shell commands. |
|
|
|
Aligned with shell commands. |
|
Application management |
||
|
|
|
Aligned with shell commands ( |
|
|
|
Aligned with shell commands. |
|
|
|
Aligned with shell commands. |
|
|
|
Aligned with shell commands. |
|
Agent (differences) |
||
|
|
None |
C-1: not supported yet. |
|
|
None |
C-2: not supported yet. |
|
|
None |
C-3: not supported yet. |
|
Desktop observation |
||
|
|
|
Authentication is built in. See VNC live stream. |
-
C-1 to C-3 (natural-language Agent) are not planned and fall outside the product design scope of FC Agent Sandbox; all other capabilities can be aligned through the SDK or shell commands.
-
Scenarios that do not require Computer Use: when you only interact with web pages, prefer Browser Use (CDP, Chrome DevTools Protocol); for pure batch-processing scenarios, use commands/code.
-
The mappings above have been verified item by item through actual runs with the
e2b-desktop==2.4.1+desktop:v0.0.44template (29/29 passed). -
The template comes preinstalled with
xdotool/scrot/xdpyinfo/xprop/xwininfo/xfconf-query; not preinstalled:wmctrl. For window management, use the equivalent xdotool or xprop commands listed in the preceding table; if you need wmctrl semantics, runapt-get install -y wmctrlto install it, because the sandbox can access the Debian repositories. -
The frontend examples in the WebSDK integration section have been verified in a real Chrome browser (the Remote Frame Buffer (RFB) connection, screen rendering, and real-time refresh of desktop changes all passed).
Limits
The Linux desktop (Computer Use) migration uses the e2b-desktop SDK:
-
Mouse, keyboard, and screenshot are existing SDK methods (two-step); the VNC live stream is built in and comes with authentication.
-
You must use its
Sandboxsubclass to create a sandbox. The sandbox lifecycle semantics are consistent with e2b (still usecreate/connect/list/kill). -
Superset capabilities such as window management and application management are not within the scope of this SDK. See Capability mapping.
Built-in template mapping
|
AgentBay |
FC E2B |
Description |
|
|
desktop template (internal beta image |
The FC image already has a desktop environment configured, and the desktop template is built from this image through |
Prerequisites: Desktop template
The Desktop template is not a built-in template that is ready to use immediately after activation; it must be built from the FC Desktop image. The image already includes Xvfb + xfce4 + x11vnc + websockify + Chrome, so no Dockerfile is required.
Set environment variables
export E2B_API_KEY=<YOUR-API-KEY>
export E2B_API_URL=https://api.cn-beijing.e2b.fc.aliyuncs.com
export E2B_DOMAIN=cn-beijing.e2b.fc.aliyuncs.com
Build the template
-
Install dependencies.
pip install "e2b>=2.31.0" e2b-desktop==2.4.1 python-dotenv -
Save the following content as
build.py.# build.py from dotenv import load_dotenv from e2b import Template, default_build_logger load_dotenv() # This is the current stable version; it will be updated later FROM_IMAGE = "fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/desktop:v0.0.44" build = Template.build( Template().from_image(FROM_IMAGE), name="my-desktop-template", # You can set this to any value cpu_count=4, memory_mb=8192, on_build_logs=default_build_logger(), ) print(f"template_id: {build.template_id}") -
Run the build.
python build.py
-
The region of the image repository must be the same as that of
E2B_API_URL/E2B_DOMAIN. For other regions, replacecn-beijingin the image address. -
Recommended specifications: 4 vCPUs and 8192 MB of memory. The template does not require a start command or a readiness command; the Desktop SDK automatically starts the desktop environment and the live stream.
Main migration examples
Common interaction loop (screenshot + action)
# === Before migration: AgentBay ===
session = agent_bay.create(CreateSessionParams(image_id="linux_latest")).session
session.computer.move_mouse(640, 400)
session.computer.click_mouse(640, 400)
session.computer.input_text("echo hello")
session.computer.press_keys(["enter"])
png = session.computer.screenshot()
# === After migration: e2b-desktop SDK ===
from e2b_desktop import Sandbox
desktop = Sandbox.create(template="my-desktop-template", timeout=600)
try:
# Start Chrome and wait for rendering
desktop.launch("google-chrome", "https://example.com")
desktop.wait(10000)
# Mouse: the E2B SDK uses a two-step approach (move + click); use the drag tuple for dragging
desktop.move_mouse(640, 400)
desktop.left_click()
desktop.double_click()
desktop.drag((100, 100), (300, 300))
desktop.scroll("down", 5)
# Keyboard: write types text, press presses a single key or a key combination
desktop.launch("xfce4-terminal")
desktop.wait(3000)
desktop.write("echo hello")
desktop.press("enter")
desktop.press(["ctrl", "c"])
# Screenshot (PNG bytes, passed to the vision model)
image = desktop.screenshot()
with open("desktop.png", "wb") as f:
f.write(image)
finally:
desktop.kill()
VNC live stream (manual takeover)
# Corresponds to the link_url observation method of the Wuying desktop scenario; the E2B SDK stream has built-in authentication
desktop.stream.start()
stream_url = desktop.stream.get_url()
# Pass stream_url to a controlled backend / browser-side noVNC
desktop.stream.stop()
WebSDK integration
The browser side connects directly to the VNC live stream of the sandbox through noVNC (CDN JS), without the control-plane SDK or an npm build. The sandbox lifecycle is managed by the backend (Python), and the frontend is only responsible for desktop rendering.
Backend: get the VNC stream address
# Backend Python: create a sandbox and get the noVNC stream address
from e2b_desktop import Sandbox
desktop = Sandbox.create(template="my-desktop-template", timeout=600)
desktop.stream.start()
stream_url = desktop.stream.get_url()
# If the FC E2B side requires a traffic access token for the data plane, carry it as a query parameter
# token = getattr(desktop, "traffic_access_token", None)
# if token:
# stream_url += f"&traffic_access_token={token}"
# Return stream_url to the frontend (for example, in an API response or over WebSocket)
Frontend: HTML + CDN noVNC
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FC Desktop</title>
<style>
#vnc-screen { width: 100vw; height: 100vh; }
</style>
</head>
<body>
<div id="vnc-screen"></div>
<script type="module">
// ESM import of the official noVNC build (pinned version)
import RFB from 'https://cdn.jsdelivr.net/gh/novnc/noVNC@v1.6.0/core/rfb.js';
async function initVNC() {
// Fetch from the backend API: stream_url
const resp = await fetch('/api/sandbox/vnc-url');
const { streamUrl } = await resp.json();
const rfb = new RFB(
document.getElementById('vnc-screen'),
streamUrl, // https://{sandbox-host}/vnc.html?autoconnect=true&resize=scale
// The same URL plays a dual role: opened directly in the browser, it is the noVNC page file; RFB upgrades it to
// wss://{sandbox-host}/vnc.html as the WebSocket endpoint (proxied by websockify to x11vnc)
{ credentials: { password: '' } } // stream.start() leaves this empty when authentication is not enabled
);
rfb.scaleViewport = true;
rfb.resizeSession = false;
}
initVNC();
</script>
</body>
</html>
-
A direct browser connection to
wss://{sandbox-host}/vnc.htmlrequires no custom request headers (verified in practice: GET 200 and a successful RFB handshake). VNC authentication is controlled bystream.start(require_auth=True)+get_url(auth_key=...); after it is enabled, also returnauth_keyto the frontend and pass it intocredentials.password. -
If the data plane requires a traffic access token, the FC backend supports passing it as a query parameter (the backend concatenates it into
stream_urlbefore returning it; see Backend: get the VNC stream address). The browser WebSocket requires no custom headers and no relay service; noVNC is transparent to extra query parameters (verified in practice with thepassword=parameter). -
The frontend does not need to develop its own Web SDK: noVNC (CDN ESM) is a complete data-plane client, and all connection parameters are in the URL.
Context storage
FC Agent Sandbox provides storage services as composable capabilities. Use AgenticFS or Object Storage Service (OSS) to persist and share data:
Appendix: noVNC integration demo
The following example provides a noVNC integration demo that can run locally and consists of three files: the backend demo.py, the frontend index.html, and the credential configuration .env. The sandbox lifecycle and credentials are managed by the backend, and the frontend is only responsible for desktop rendering.
Example files
Once real values are filled in, the .env file contains secrets. Do not commit it to the code repository, share it, or paste it into chats or tickets.
Data flow
Browser (index.html, noVNC CDN ESM)
│ GET /api/sandbox/vnc-url ──→ demo.py (returns only streamUrl)
│ RFB connects directly to wss://{sandbox-host}/vnc.html ──→ websockify ──→ x11vnc ──→ Xvfb desktop
└─ Rendering + keyboard/mouse input (the data plane does not go through the backend)
How to run
-
Install dependencies.
pip install "e2b>=2.31.0" e2b-desktop==2.4.1 python-dotenv -
In
.env, fill in the real values of credentials such asE2B_API_KEY. -
Run the demo.
python demo.py -
Open the service address printed in the terminal (in the form of
http://127.0.0.1:<RANDOM-PORT>/) in a browser to view and operate the live desktop. -
Press Ctrl-C to exit; the program automatically stops the VNC stream and destroys the sandbox.
Verification records
-
Backend API:
/api/sandbox/vnc-urlreturns a streamUrl that starts withhttps://and contains/vnc.html;/returns the page as expected. -
Exit: after SIGTERM/Ctrl-C, the VNC stream is stopped and the sandbox is destroyed automatically.
-
Frontend: the RFB connection, screen rendering, and real-time refresh of desktop changes have been verified in a real Chrome browser.