@kritchoff/agent-browser 0.9.3 → 0.9.5
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/package.json +2 -1
- package/start.sh +117 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kritchoff/agent-browser",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Headless browser automation CLI for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"scripts",
|
|
12
12
|
"skills",
|
|
13
13
|
"sdk.sh",
|
|
14
|
+
"start.sh",
|
|
14
15
|
"docker-compose.sdk.yml"
|
|
15
16
|
],
|
|
16
17
|
"bin": {
|
package/start.sh
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# Colors
|
|
5
|
+
GREEN='\033[0;32m'
|
|
6
|
+
BLUE='\033[0;34m'
|
|
7
|
+
YELLOW='\033[1;33m'
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
NC='\033[0m' # No Color
|
|
10
|
+
|
|
11
|
+
echo -e "${BLUE}=================================================${NC}"
|
|
12
|
+
echo -e "${BLUE} Agent Browser - Android Environment Setup ${NC}"
|
|
13
|
+
echo -e "${BLUE}=================================================${NC}"
|
|
14
|
+
|
|
15
|
+
SNAPSHOT_PATH=""
|
|
16
|
+
while [[ $# -gt 0 ]]; do
|
|
17
|
+
case $1 in
|
|
18
|
+
--snapshot)
|
|
19
|
+
SNAPSHOT_PATH="$2"
|
|
20
|
+
shift 2
|
|
21
|
+
;;
|
|
22
|
+
*)
|
|
23
|
+
echo "Unknown option: $1"
|
|
24
|
+
exit 1
|
|
25
|
+
;;
|
|
26
|
+
esac
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
# 1. Pre-flight Checks
|
|
30
|
+
echo -e "\n${YELLOW}[1/4] Checking System Requirements...${NC}"
|
|
31
|
+
|
|
32
|
+
if ! command -v docker &> /dev/null; then
|
|
33
|
+
echo -e "${RED}Error: Docker is not installed.${NC}"
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
38
|
+
if [ -e /dev/kvm ]; then
|
|
39
|
+
echo -e "${GREEN}✓ KVM Acceleration detected (/dev/kvm)${NC}"
|
|
40
|
+
else
|
|
41
|
+
echo -e "${YELLOW}⚠ Warning: No KVM detected. Emulator will be slow.${NC}"
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# 2. Start Services
|
|
46
|
+
echo -e "\n${YELLOW}[2/4] Starting Docker Stack...${NC}"
|
|
47
|
+
echo " (First run may take a few minutes to download images)"
|
|
48
|
+
|
|
49
|
+
docker compose -f "${COMPOSE_FILE:-docker-compose.prod.yml}" up -d --build --remove-orphans > /dev/null 2>&1
|
|
50
|
+
|
|
51
|
+
# Find actual container names
|
|
52
|
+
ANDROID_CONTAINER=$(docker compose -f "${COMPOSE_FILE:-docker-compose.prod.yml}" ps -q android-service)
|
|
53
|
+
AGENT_CONTAINER=$(docker compose -f "${COMPOSE_FILE:-docker-compose.prod.yml}" ps -q agent-service)
|
|
54
|
+
|
|
55
|
+
# 2b. Import Snapshot (if requested)
|
|
56
|
+
if [ -n "$SNAPSHOT_PATH" ]; then
|
|
57
|
+
echo -e "\n${YELLOW}[2.5/4] Importing Snapshot: $SNAPSHOT_PATH...${NC}"
|
|
58
|
+
|
|
59
|
+
# Wait for container to be responsive
|
|
60
|
+
echo -n " Waiting for container to be ready for import... "
|
|
61
|
+
until docker exec "$ANDROID_CONTAINER" echo "ready" &>/dev/null; do
|
|
62
|
+
sleep 1
|
|
63
|
+
done
|
|
64
|
+
echo -e "${GREEN}OK${NC}"
|
|
65
|
+
|
|
66
|
+
# Import
|
|
67
|
+
if ./scripts/snapshot_manager.sh import "$SNAPSHOT_PATH" "w8rl_imported"; then
|
|
68
|
+
echo -e "${GREEN} Snapshot imported successfully.${NC}"
|
|
69
|
+
|
|
70
|
+
# Configure emulator to load this snapshot
|
|
71
|
+
# We set the env var in the container for the next boot
|
|
72
|
+
# (This assumes the entrypoint script respects EMULATOR_SNAPSHOT_NAME)
|
|
73
|
+
# For now, we'll rely on the default behavior or standard AVD loading
|
|
74
|
+
|
|
75
|
+
echo " Restarting Android service to load snapshot..."
|
|
76
|
+
docker compose -f "${COMPOSE_FILE:-docker-compose.prod.yml}" restart android-service
|
|
77
|
+
|
|
78
|
+
# Update container ID after restart
|
|
79
|
+
ANDROID_CONTAINER=$(docker compose -f "${COMPOSE_FILE:-docker-compose.prod.yml}" ps -q android-service)
|
|
80
|
+
else
|
|
81
|
+
echo -e "${RED}Error: Failed to import snapshot.${NC}"
|
|
82
|
+
exit 1
|
|
83
|
+
fi
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
# 3. Wait for Readiness
|
|
87
|
+
echo -e "\n${YELLOW}[3/4] Waiting for Initialization...${NC}"
|
|
88
|
+
|
|
89
|
+
wait_for_log() {
|
|
90
|
+
local container=$1
|
|
91
|
+
local pattern=$2
|
|
92
|
+
local label=$3
|
|
93
|
+
|
|
94
|
+
echo -n " Waiting for $label... "
|
|
95
|
+
until docker logs "$container" 2>&1 | grep -q "$pattern"; do
|
|
96
|
+
sleep 2
|
|
97
|
+
done
|
|
98
|
+
echo -e "${GREEN}Done!${NC}"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
wait_for_log "$ANDROID_CONTAINER" "Emulator boot complete" "Android Emulator Boot"
|
|
102
|
+
wait_for_log "$ANDROID_CONTAINER" "APK installation complete" "WootzApp Installation"
|
|
103
|
+
wait_for_log "$ANDROID_CONTAINER" "CDP Bridge ready" "CDP Bridge"
|
|
104
|
+
wait_for_log "$AGENT_CONTAINER" "Ready on port 3000" "Agent Daemon Connection"
|
|
105
|
+
|
|
106
|
+
# 4. Success
|
|
107
|
+
echo -e "\n${GREEN}[4/4] Environment Ready!${NC}"
|
|
108
|
+
echo -e "${BLUE}=================================================${NC}"
|
|
109
|
+
echo -e "You can now control the Android browser."
|
|
110
|
+
echo -e ""
|
|
111
|
+
echo -e "Try these commands:"
|
|
112
|
+
echo -e " ${GREEN}./agent open https://google.com${NC}"
|
|
113
|
+
echo -e " ${GREEN}./agent snapshot${NC}"
|
|
114
|
+
echo -e " ${GREEN}./agent click @e1${NC}"
|
|
115
|
+
echo -e ""
|
|
116
|
+
echo -e "See COMMANDS.md for full reference."
|
|
117
|
+
echo -e "${BLUE}=================================================${NC}"
|