@testdriverai/runner 7.8.0-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/45-allow-colord.pkla +6 -0
- package/README.md +1 -0
- package/Xauthority +0 -0
- package/focusWindow.ps1 +123 -0
- package/getActiveWindow.ps1 +70 -0
- package/index.js +556 -0
- package/lib/ably-service.js +537 -0
- package/lib/automation-bridge.js +85 -0
- package/lib/automation.js +786 -0
- package/lib/automation.js.bak +882 -0
- package/lib/pyautogui-local.js +229 -0
- package/network.ps1 +18 -0
- package/package.json +43 -0
- package/sandbox-agent.js +266 -0
- package/scripts-desktop/control_window.sh +59 -0
- package/scripts-desktop/launch_chrome.sh +3 -0
- package/scripts-desktop/launch_chrome_for_testing.sh +9 -0
- package/scripts-desktop/start-desktop.sh +161 -0
- package/wallpaper.png +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ─── E2B Desktop Environment Startup ─────────────────────────────────────────
|
|
3
|
+
# Starts Xvfb, XFCE, x11vnc, and noVNC for the E2B sandbox.
|
|
4
|
+
# This script is used as the E2B start_cmd so the desktop is ready at boot.
|
|
5
|
+
# The testdriver-runner is started separately by setup-e2b.mjs after
|
|
6
|
+
# environment variables (TD_API_KEY, etc.) are written.
|
|
7
|
+
#
|
|
8
|
+
# IDEMPOTENT: Safe to call multiple times — skips services already running.
|
|
9
|
+
|
|
10
|
+
export DISPLAY=:0
|
|
11
|
+
export XAUTHORITY="${HOME}/.Xauthority"
|
|
12
|
+
SCREEN_WIDTH="${SCREEN_WIDTH:-1366}"
|
|
13
|
+
SCREEN_HEIGHT="${SCREEN_HEIGHT:-768}"
|
|
14
|
+
|
|
15
|
+
# Create Xauthority so pyautogui/Xlib can connect to the display
|
|
16
|
+
touch "$XAUTHORITY" 2>/dev/null || true
|
|
17
|
+
xauth generate :0 . trusted 2>/dev/null || true
|
|
18
|
+
|
|
19
|
+
# ─── Start Xvfb ──────────────────────────────────────────────────────────────
|
|
20
|
+
if pgrep -x Xvfb > /dev/null 2>&1; then
|
|
21
|
+
echo "[start-desktop] Xvfb already running, skipping"
|
|
22
|
+
XVFB_PID=$(pgrep -x Xvfb | head -1)
|
|
23
|
+
else
|
|
24
|
+
echo "[start-desktop] Starting Xvfb on :0 (${SCREEN_WIDTH}x${SCREEN_HEIGHT}x24)"
|
|
25
|
+
# Clean up stale lock file if Xvfb is not actually running
|
|
26
|
+
rm -f /tmp/.X0-lock /tmp/.X11-unix/X0 2>/dev/null
|
|
27
|
+
Xvfb :0 -ac -screen 0 "${SCREEN_WIDTH}x${SCREEN_HEIGHT}x24" -retro -nolisten tcp &
|
|
28
|
+
XVFB_PID=$!
|
|
29
|
+
sleep 2
|
|
30
|
+
|
|
31
|
+
# Verify Xvfb is actually running (same check E2B uses)
|
|
32
|
+
for _i in $(seq 1 10); do
|
|
33
|
+
xdpyinfo -display :0 > /dev/null 2>&1 && break
|
|
34
|
+
sleep 1
|
|
35
|
+
done
|
|
36
|
+
|
|
37
|
+
if ! kill -0 $XVFB_PID 2>/dev/null; then
|
|
38
|
+
echo "[start-desktop] ERROR: Xvfb failed to start, retrying..."
|
|
39
|
+
rm -f /tmp/.X0-lock /tmp/.X11-unix/X0 2>/dev/null
|
|
40
|
+
Xvfb :0 -ac -screen 0 "${SCREEN_WIDTH}x${SCREEN_HEIGHT}x24" -retro -nolisten tcp &
|
|
41
|
+
XVFB_PID=$!
|
|
42
|
+
sleep 3
|
|
43
|
+
fi
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# ─── Disable X11 screen blanking & DPMS ───────────────────────────────────────
|
|
47
|
+
# Xvfb has screen saver and DPMS enabled by default, which can blank the
|
|
48
|
+
# virtual display and cause intermittent black screens over VNC.
|
|
49
|
+
echo "[start-desktop] Disabling screen blanking and DPMS..."
|
|
50
|
+
xset s off 2>/dev/null || true # Disable screen saver
|
|
51
|
+
xset s noblank 2>/dev/null || true # Don't blank the screen
|
|
52
|
+
xset -dpms 2>/dev/null || true # Disable Display Power Management
|
|
53
|
+
|
|
54
|
+
# ─── Start D-Bus session bus ──────────────────────────────────────────────────
|
|
55
|
+
# XFCE needs D-Bus for xfconf, thunar, panel plugins, etc.
|
|
56
|
+
# Without it, components fail silently and can leave a black screen.
|
|
57
|
+
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
|
|
58
|
+
echo "[start-desktop] Starting D-Bus session bus..."
|
|
59
|
+
eval $(dbus-launch --sh-syntax) 2>/dev/null || true
|
|
60
|
+
export DBUS_SESSION_BUS_ADDRESS
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# ─── Start XFCE desktop ──────────────────────────────────────────────────────
|
|
64
|
+
if pgrep -x xfce4-session > /dev/null 2>&1; then
|
|
65
|
+
echo "[start-desktop] XFCE already running, skipping"
|
|
66
|
+
else
|
|
67
|
+
echo "[start-desktop] Starting XFCE desktop..."
|
|
68
|
+
startxfce4 &
|
|
69
|
+
sleep 3
|
|
70
|
+
|
|
71
|
+
# Disable xfwm4 compositor (causes black screen in Xvfb — no GPU)
|
|
72
|
+
xfconf-query -c xfwm4 -p /general/use_compositing -s false 2>/dev/null || true
|
|
73
|
+
|
|
74
|
+
# Kill power manager, screensaver, and error dialogs (not needed in headless)
|
|
75
|
+
killall xfce4-power-manager 2>/dev/null || true
|
|
76
|
+
killall xfce4-screensaver 2>/dev/null || true
|
|
77
|
+
xdotool search --name "Error" windowclose 2>/dev/null || true
|
|
78
|
+
xdotool search --name "Power Manager" windowclose 2>/dev/null || true
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# ─── Set TestDriver wallpaper ─────────────────────────────────────────────────
|
|
82
|
+
WALLPAPER="/usr/share/backgrounds/xfce/wallpaper.png"
|
|
83
|
+
if [ -f "$WALLPAPER" ]; then
|
|
84
|
+
echo "[start-desktop] Setting TestDriver wallpaper..."
|
|
85
|
+
# Set wallpaper for all monitors/workspaces (XFCE uses per-monitor properties)
|
|
86
|
+
for prop in $(xfconf-query -c xfce4-desktop -l 2>/dev/null | grep "last-image$"); do
|
|
87
|
+
xfconf-query -c xfce4-desktop -p "$prop" -s "$WALLPAPER" 2>/dev/null || true
|
|
88
|
+
done
|
|
89
|
+
# Also set the image-style to stretched (5) for all monitors
|
|
90
|
+
for prop in $(xfconf-query -c xfce4-desktop -l 2>/dev/null | grep "image-style$"); do
|
|
91
|
+
xfconf-query -c xfce4-desktop -p "$prop" -s 5 2>/dev/null || true
|
|
92
|
+
done
|
|
93
|
+
# Fallback: set the default monitor property directly
|
|
94
|
+
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -n -t string -s "$WALLPAPER" 2>/dev/null || true
|
|
95
|
+
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/image-style -n -t int -s 5 2>/dev/null || true
|
|
96
|
+
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorscreen/workspace0/last-image -n -t string -s "$WALLPAPER" 2>/dev/null || true
|
|
97
|
+
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorscreen/workspace0/image-style -n -t int -s 5 2>/dev/null || true
|
|
98
|
+
else
|
|
99
|
+
echo "[start-desktop] WARNING: Wallpaper not found at $WALLPAPER"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# ─── Wait for desktop to render before starting VNC ──────────────────────────
|
|
103
|
+
# xfdesktop draws the wallpaper/icons. Wait for it so x11vnc captures a
|
|
104
|
+
# rendered frame instead of a black screen.
|
|
105
|
+
for _i in $(seq 1 15); do
|
|
106
|
+
pgrep -f xfdesktop > /dev/null 2>&1 && break
|
|
107
|
+
sleep 1
|
|
108
|
+
done
|
|
109
|
+
|
|
110
|
+
# Re-disable screen blanking after XFCE startup (XFCE may re-enable it)
|
|
111
|
+
xset s off 2>/dev/null || true
|
|
112
|
+
xset s noblank 2>/dev/null || true
|
|
113
|
+
xset -dpms 2>/dev/null || true
|
|
114
|
+
|
|
115
|
+
# ─── Start x11vnc (VNC server on port 5900) ──────────────────────────────────
|
|
116
|
+
if pgrep -x x11vnc > /dev/null 2>&1; then
|
|
117
|
+
echo "[start-desktop] x11vnc already running, skipping"
|
|
118
|
+
else
|
|
119
|
+
echo "[start-desktop] Starting x11vnc on port 5900..."
|
|
120
|
+
# -noxdamage : poll framebuffer instead of relying on XDAMAGE (broken in Xvfb)
|
|
121
|
+
# -fixscreen V=2 : full screen refresh every 2s to fix stale/black frames
|
|
122
|
+
x11vnc -display :0 -forever -nopw -shared -rfbport 5900 \
|
|
123
|
+
-noxdamage -fixscreen V=2 \
|
|
124
|
+
-bg -o /dev/null 2>/dev/null || true
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
# ─── Start noVNC (HTTP server + WebSocket proxy on port 6080) ─────────────────
|
|
128
|
+
if pgrep -f "websockify.*6080" > /dev/null 2>&1; then
|
|
129
|
+
echo "[start-desktop] noVNC already running, skipping"
|
|
130
|
+
NOVNC_PID=$(pgrep -f "websockify.*6080" | head -1)
|
|
131
|
+
elif [ -d /opt/noVNC/utils/websockify ]; then
|
|
132
|
+
echo "[start-desktop] Starting noVNC (websockify --web) on port 6080..."
|
|
133
|
+
/opt/noVNC/utils/websockify/run --web /opt/noVNC 6080 localhost:5900 &
|
|
134
|
+
NOVNC_PID=$!
|
|
135
|
+
echo "[start-desktop] noVNC started (PID: $NOVNC_PID)"
|
|
136
|
+
elif command -v websockify > /dev/null 2>&1; then
|
|
137
|
+
echo "[start-desktop] Starting noVNC (system websockify) on port 6080..."
|
|
138
|
+
websockify --web /opt/noVNC 6080 localhost:5900 &
|
|
139
|
+
NOVNC_PID=$!
|
|
140
|
+
echo "[start-desktop] noVNC started (PID: $NOVNC_PID)"
|
|
141
|
+
elif [ -d /opt/noVNC ]; then
|
|
142
|
+
echo "[start-desktop] websockify not found, falling back to python3 http.server on port 6080..."
|
|
143
|
+
cd /opt/noVNC && python3 -m http.server 6080 --bind 0.0.0.0 &
|
|
144
|
+
NOVNC_PID=$!
|
|
145
|
+
echo "[start-desktop] noVNC HTTP server started (PID: $NOVNC_PID) — WebSocket proxy not available"
|
|
146
|
+
else
|
|
147
|
+
echo "[start-desktop] WARNING: /opt/noVNC not found, noVNC not started"
|
|
148
|
+
fi
|
|
149
|
+
|
|
150
|
+
# ─── Force a screen redraw ────────────────────────────────────────────────────
|
|
151
|
+
# Send a synthetic keypress so the display is definitely "active" and any
|
|
152
|
+
# screen blanking timers are reset.
|
|
153
|
+
xdotool key --clearmodifiers super 2>/dev/null || true
|
|
154
|
+
sleep 1
|
|
155
|
+
|
|
156
|
+
echo "[start-desktop] Desktop environment ready"
|
|
157
|
+
|
|
158
|
+
# Keep the script running so E2B doesn't consider the sandbox stopped
|
|
159
|
+
# Trap signals for clean shutdown
|
|
160
|
+
trap "kill $XVFB_PID $NOVNC_PID 2>/dev/null; exit 0" SIGTERM SIGINT
|
|
161
|
+
wait
|
package/wallpaper.png
ADDED
|
Binary file
|