@testdriverai/runner 7.8.0-test.45 → 7.8.0-test.47

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.
@@ -459,7 +459,7 @@ class AblyService extends EventEmitter {
459
459
  // Signal readiness to SDK — commands sent before this would be lost
460
460
  const readyPayload = {
461
461
  type: 'runner.ready',
462
- os: 'windows',
462
+ os: process.platform === 'win32' ? 'windows' : 'linux',
463
463
  sandboxId: this._sandboxId,
464
464
  runnerVersion: getLocalVersion() || 'unknown',
465
465
  timestamp: Date.now(),
package/lib/automation.js CHANGED
@@ -45,8 +45,10 @@ const API_KEY = process.env.TD_API_KEY;
45
45
  // shell injection and escaping issues.
46
46
 
47
47
  const PYTHON = IS_WINDOWS ? 'python' : 'python3';
48
+ // On Linux, ensure DISPLAY is set (use env var or fallback to :0)
49
+ // The os.environ.get() preserves the parent's DISPLAY setting for E2B's :1 display
48
50
  const PY_IMPORT = IS_LINUX
49
- ? "import os; os.environ['DISPLAY'] = ':0'; import pyautogui, sys; pyautogui.FAILSAFE = False; "
51
+ ? "import os; os.environ.setdefault('DISPLAY', ':0'); import pyautogui, sys; pyautogui.FAILSAFE = False; "
50
52
  : 'import pyautogui, sys; pyautogui.FAILSAFE = False; ';
51
53
 
52
54
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testdriverai/runner",
3
- "version": "7.8.0-test.45",
3
+ "version": "7.8.0-test.47",
4
4
  "description": "TestDriver Runner - Ably-based remote automation agent with Node.js automation",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,105 @@
1
+ #!/bin/bash
2
+ # ─── TestDriver Sandbox Agent Startup ────────────────────────────────────────
3
+ # Starts the sandbox-agent.js (Ably-based automation agent) inside the E2B
4
+ # sandbox. This script is called by the API after writing the config file
5
+ # to /tmp/testdriver-agent.json.
6
+ #
7
+ # This matches the Windows runner pattern: the agent runs locally on the
8
+ # sandbox and executes commands via pyautogui (instead of @e2b/desktop RPC).
9
+ #
10
+ # Usage: bash /opt/testdriver-runner/scripts-desktop/start-agent.sh [&]
11
+ #
12
+ # Prerequisites:
13
+ # - Desktop environment running (start-desktop.sh completed)
14
+ # - Config file at /tmp/testdriver-agent.json with Ably credentials
15
+ # - Node.js installed
16
+ # - Runner installed at /opt/testdriver-runner
17
+
18
+ set -e
19
+
20
+ export DISPLAY="${DISPLAY:-:0}"
21
+ export XAUTHORITY="${XAUTHORITY:-${HOME}/.Xauthority}"
22
+
23
+ RUNNER_DIR="/opt/testdriver-runner"
24
+ CONFIG_PATH="/tmp/testdriver-agent.json"
25
+ LOG_FILE="/tmp/sandbox-agent.log"
26
+ PID_FILE="/tmp/sandbox-agent.pid"
27
+
28
+ log() {
29
+ echo "[$(date -Iseconds)] [start-agent] $1" | tee -a "$LOG_FILE"
30
+ }
31
+
32
+ # ─── Check if already running ─────────────────────────────────────────────────
33
+ if [ -f "$PID_FILE" ]; then
34
+ existing_pid=$(cat "$PID_FILE")
35
+ if kill -0 "$existing_pid" 2>/dev/null; then
36
+ log "Agent already running (PID: $existing_pid), exiting"
37
+ exit 0
38
+ else
39
+ log "Stale PID file found, removing"
40
+ rm -f "$PID_FILE"
41
+ fi
42
+ fi
43
+
44
+ # ─── Verify prerequisites ─────────────────────────────────────────────────────
45
+ if [ ! -d "$RUNNER_DIR" ]; then
46
+ log "ERROR: Runner not found at $RUNNER_DIR"
47
+ exit 1
48
+ fi
49
+
50
+ if [ ! -f "$RUNNER_DIR/sandbox-agent.js" ]; then
51
+ log "ERROR: sandbox-agent.js not found in $RUNNER_DIR"
52
+ exit 1
53
+ fi
54
+
55
+ if ! command -v node &> /dev/null; then
56
+ log "ERROR: Node.js not installed"
57
+ exit 1
58
+ fi
59
+
60
+ # ─── Wait for config file (with timeout) ─────────────────────────────────────
61
+ # The API writes the config file before calling this script, but we add a
62
+ # brief wait just in case there's any race condition.
63
+ WAIT_TIMEOUT=30
64
+ WAIT_INTERVAL=1
65
+ elapsed=0
66
+
67
+ log "Waiting for config file: $CONFIG_PATH"
68
+ while [ ! -f "$CONFIG_PATH" ] && [ $elapsed -lt $WAIT_TIMEOUT ]; do
69
+ sleep $WAIT_INTERVAL
70
+ elapsed=$((elapsed + WAIT_INTERVAL))
71
+ done
72
+
73
+ if [ ! -f "$CONFIG_PATH" ]; then
74
+ log "ERROR: Config file not found after ${WAIT_TIMEOUT}s: $CONFIG_PATH"
75
+ exit 1
76
+ fi
77
+
78
+ log "Config file found"
79
+
80
+ # ─── Start the agent ──────────────────────────────────────────────────────────
81
+ log "Starting sandbox-agent.js..."
82
+ log "DISPLAY=$DISPLAY, RUNNER_DIR=$RUNNER_DIR"
83
+
84
+ # Run in background, redirect output to log file
85
+ cd "$RUNNER_DIR"
86
+ nohup node sandbox-agent.js >> "$LOG_FILE" 2>&1 &
87
+ AGENT_PID=$!
88
+
89
+ # Write PID file for process management
90
+ echo "$AGENT_PID" > "$PID_FILE"
91
+
92
+ log "Agent started (PID: $AGENT_PID)"
93
+ log "Log file: $LOG_FILE"
94
+
95
+ # Brief pause to catch any immediate startup errors
96
+ sleep 2
97
+
98
+ if kill -0 "$AGENT_PID" 2>/dev/null; then
99
+ log "Agent running successfully"
100
+ exit 0
101
+ else
102
+ log "ERROR: Agent exited unexpectedly. Check $LOG_FILE for details"
103
+ tail -20 "$LOG_FILE" | while read line; do log " $line"; done
104
+ exit 1
105
+ fi