33 lines
1.6 KiB
Bash
33 lines
1.6 KiB
Bash
|
|
#!/bin/sh
|
||
|
|
# Runs inside the test box: a headless sway desktop with `wev` (it prints every click and key it
|
||
|
|
# gets) in front, then AnyBot's own computer tools against it. Prints what wev heard.
|
||
|
|
set -e
|
||
|
|
export XDG_RUNTIME_DIR=/tmp/xdg-wl && rm -rf $XDG_RUNTIME_DIR && mkdir -m 700 -p $XDG_RUNTIME_DIR
|
||
|
|
unset DISPLAY
|
||
|
|
cat > /tmp/sway.conf <<'CONF'
|
||
|
|
output HEADLESS-1 resolution 1280x800 position 0 0
|
||
|
|
default_border none
|
||
|
|
CONF
|
||
|
|
WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 WLR_RENDERER=pixman sway -c /tmp/sway.conf >/tmp/sway.log 2>&1 &
|
||
|
|
for i in $(seq 50); do [ -S $XDG_RUNTIME_DIR/wayland-1 ] && break; sleep 0.1; done
|
||
|
|
export WAYLAND_DISPLAY=wayland-1
|
||
|
|
stdbuf -oL wev > /tmp/wev.log 2>&1 &
|
||
|
|
sleep 1.5
|
||
|
|
BIN=${CARGO_TARGET_DIR:-target}/release/anybot
|
||
|
|
$BIN --tool computer_use_check_permissions '{}' \
|
||
|
|
computer_use_screenshot '{}' \
|
||
|
|
computer_use_click '{"x":400,"y":300}' \
|
||
|
|
computer_use_click '{"x":420,"y":310,"button":"right"}' \
|
||
|
|
computer_use_typing '{"value":"Hi 你好"}' \
|
||
|
|
computer_use_press_key '{"key":"cmd+a"}' \
|
||
|
|
computer_use_press_key '{"key":"return"}' \
|
||
|
|
computer_use_scroll '{"x":400,"y":300,"direction":"down","amount":2}'
|
||
|
|
sleep 0.5
|
||
|
|
grim /tmp/grim.png
|
||
|
|
echo "--- wev heard:"
|
||
|
|
grep -E "state: 1|axis: 0|depressed: 0+[1-9]" -A1 /tmp/wev.log | grep -oE "button: [0-9]+ \([a-z]+\)|utf8: '[^']+'|sym: (Control_L|Return)|axis: 0 \(vertical\), value: -?[0-9.]+|depressed: 0+[1-9]+" | uniq | tr '\n' ' '; echo
|
||
|
|
echo "--- screenshot (anybot vs grim):"
|
||
|
|
identify -format "%wx%h\n" /tmp/anybot-tool-1.jpg /tmp/grim.png
|
||
|
|
cp /tmp/anybot-tool-1.jpg /out/wayland-shot.jpg 2>/dev/null || true
|
||
|
|
cp /tmp/grim.png /out/wayland-grim.png 2>/dev/null || true
|