61 lines
1.8 KiB
Bash
Executable File
61 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
WORKDIR="$(mktemp -d)"
|
|
JSON_PATH="$WORKDIR/result.json"
|
|
EXTERNAL_JSON_PATH="${EGO_BROWSER_SCREENSHOT_RESULT_JSON:-}"
|
|
LAST_ERROR=""
|
|
|
|
cleanup() {
|
|
rm -rf "$WORKDIR"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
PROMPT="Open https://www.google.com/, take a screenshot with your normal default browser workflow, keep the task primarily on ego-browser, and tell me the page title plus a short note that the screenshot was captured. If the local ego-browser helper cannot return a screenshot path, use the browser-native fallback inside the browser workflow and make sure the verbose output includes the screenshot path."
|
|
|
|
for attempt in 1 2; do
|
|
LOG_PATH="$WORKDIR/hermes-chat-$attempt.log"
|
|
PARSE_ERR_PATH="$WORKDIR/parse-$attempt.err"
|
|
|
|
if ! hermes chat -q "$PROMPT" -v --yolo > "$LOG_PATH" 2>&1; then
|
|
LAST_ERROR="hermes chat run failed on attempt $attempt"
|
|
sleep 1
|
|
continue
|
|
fi
|
|
|
|
if python3 - <<'PY' "$LOG_PATH" "$JSON_PATH" "$attempt" 2>"$PARSE_ERR_PATH"
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from scripts.ego_browser_smoke_utils import (
|
|
extract_ego_browser_screenshot_result,
|
|
ocr_image_text,
|
|
)
|
|
|
|
log_path = Path(sys.argv[1])
|
|
json_path = Path(sys.argv[2])
|
|
attempt = sys.argv[3]
|
|
text = log_path.read_text()
|
|
|
|
base_payload = extract_ego_browser_screenshot_result(text, attempt=attempt, ocr_text="")
|
|
ocr_text = ocr_image_text(base_payload["screenshot_path"])
|
|
payload = extract_ego_browser_screenshot_result(text, attempt=attempt, ocr_text=ocr_text)
|
|
json_path.write_text(json.dumps(payload, indent=2))
|
|
print(json.dumps(payload, indent=2))
|
|
PY
|
|
then
|
|
if [[ -n "$EXTERNAL_JSON_PATH" ]]; then
|
|
cp "$JSON_PATH" "$EXTERNAL_JSON_PATH"
|
|
fi
|
|
cat "$JSON_PATH"
|
|
exit 0
|
|
fi
|
|
|
|
LAST_ERROR="$(cat "$PARSE_ERR_PATH")"
|
|
sleep 1
|
|
done
|
|
|
|
echo "${LAST_ERROR:-screenshot smoke failed}" >&2
|
|
exit 1
|