|
| 1 | +# TOOL-ROLES.md — KRITISCHE Tool-Rollen-Trennung |
| 2 | + |
| 3 | +> **Die wichtigste Architektur-Regel der Stealth-Quad.** |
| 4 | +> Falsches Tool im falschen Kontext = Klick auf falsches Element = Detection. |
| 5 | +
|
| 6 | +--- |
| 7 | + |
| 8 | +## 🎯 DAS FUNDAMENTALE PROBLEM |
| 9 | + |
| 10 | +Chrome hat **ZWEI Kontexte**: das Hauptfenster und Popup-Fenster. |
| 11 | +Jedes Tool kann NUR EINEN Kontext sehen. |
| 12 | + |
| 13 | +``` |
| 14 | +┌─────────────────────────────────────────────────────┐ |
| 15 | +│ Hauptfenster (heypiggy.com/dashboard) │ |
| 16 | +│ → skylight-cli list-elements --pid X │ |
| 17 | +│ → skylight-cli click --pid X --element-index Y │ |
| 18 | +│ → playstealth launch (startet dieses Fenster) │ |
| 19 | +└────────────────────────────┬────────────────────────┘ |
| 20 | + │ |
| 21 | + ┌────────▼────────┐ |
| 22 | + │ Popup (Google │ |
| 23 | + │ OAuth, Consent) │ |
| 24 | + │ → cua-driver │ |
| 25 | + │ → window_id │ |
| 26 | + └─────────────────┘ |
| 27 | +``` |
| 28 | + |
| 29 | +**skylight-cli cached NUR das Hauptfenster.** |
| 30 | +**Popup-Indices von skylight-cli sind INVALID!** |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## 🔑 REGEL 1: skylight-cli = HAUPTFENSTER |
| 35 | + |
| 36 | +### Was skylight-cli kann: |
| 37 | +```bash |
| 38 | +# Chrome starten + PID bekommen |
| 39 | +playstealth launch --url 'https://heypiggy.com/?page=dashboard' |
| 40 | +# → {"pid": 12345, ...} |
| 41 | + |
| 42 | +# Elements im HAUPTFENSTER scannen |
| 43 | +skylight-cli list-elements --pid 12345 |
| 44 | + |
| 45 | +# Im HAUPTFENSTER klicken (NUR element-index!) |
| 46 | +skylight-cli click --pid 12345 --element-index 42 |
| 47 | + |
| 48 | +# Im HAUPTFENSTER Text eintippen |
| 49 | +skylight-cli type --pid 12345 --element-index 55 --text "München" |
| 50 | + |
| 51 | +# Screenshot vom HAUPTFENSTER |
| 52 | +skylight-cli screenshot --pid 12345 --mode som --output /tmp/page.png |
| 53 | +``` |
| 54 | + |
| 55 | +### Was skylight-cli NICHT kann: |
| 56 | +- ❌ KEINE Popup-Elemente sehen |
| 57 | +- ❌ KEINE Google OAuth Buttons klicken |
| 58 | +- ❌ KEINE Consent-Dialoge bedienen |
| 59 | +- ❌ KEINE Koordinaten raten (`--x --y` ist BANNED) |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## 🔑 REGEL 2: cua-driver = POPUP-FENSTER |
| 64 | + |
| 65 | +### Was cua-driver kann: |
| 66 | +```bash |
| 67 | +# Daemon starten (einmalig pro Session) |
| 68 | +cua-driver serve & |
| 69 | + |
| 70 | +# ALLE Fenster (inkl. Popups) auflisten |
| 71 | +cua-driver call list_windows '{}' |
| 72 | +# → {"windows": [{"window_id": W1, "pid": 12345, "title": "Google"}, ...]} |
| 73 | + |
| 74 | +# Popup-State laden (CACHE pro window_id!) |
| 75 | +cua-driver call get_window_state '{"pid":12345,"window_id":W1}' |
| 76 | + |
| 77 | +# Im Popup klicken |
| 78 | +cua-driver call click '{"pid":12345,"window_id":W1,"element_index":25,"action":"press"}' |
| 79 | + |
| 80 | +# Im Popup Text eintippen |
| 81 | +cua-driver call set_value '{"pid":12345,"window_id":W1,"element_index":25,"value":"email@gmail.com"}' |
| 82 | +``` |
| 83 | + |
| 84 | +### Was cua-driver NICHT kann: |
| 85 | +- ❌ KEIN Hauptfenster verwalten (nutze skylight-cli dafür) |
| 86 | +- ❌ KEINE Chrome-Instanz starten (nutze playstealth dafür) |
| 87 | +- ❌ KEINE Page-Transitions erkennen (nutze skylight-cli list-elements dafür) |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## 🔑 REGEL 3: playstealth = CHROME START |
| 92 | + |
| 93 | +```bash |
| 94 | +# Isolierte Chrome-Instanz (eigene PID, eigener Cache) |
| 95 | +playstealth launch --url 'https://heypiggy.com/?page=dashboard' |
| 96 | + |
| 97 | +# NIEMALS direkt Chrome starten! |
| 98 | +# ❌ open -na "Google Chrome" |
| 99 | +# ❌ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome |
| 100 | +``` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## 🔑 REGEL 4: screen-follow = VIDEO |
| 105 | + |
| 106 | +```bash |
| 107 | +# Screen Recording (für Post-Mortem) |
| 108 | +screen-follow record --video --output /tmp/session.mp4 |
| 109 | + |
| 110 | +# Video-Analyse nach Session |
| 111 | +python3 -m runner.video_analyzer --last errors |
| 112 | +``` |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## 📋 GOOGLE OAUTH FLOW (komplettes Beispiel) |
| 117 | + |
| 118 | +```bash |
| 119 | +PID=$(pgrep -f "Google Chrome.app/Contents/MacOS/Google Chrome$" | head -1) |
| 120 | +echo "Chrome PID=$PID" |
| 121 | + |
| 122 | +# 1. cua-driver Daemon |
| 123 | +cua-driver serve & |
| 124 | + |
| 125 | +# 2. Google-Login-Button klicken (HAUPTFENSTER → skylight!) |
| 126 | +skylight-cli click --pid $PID --element-index 33 |
| 127 | +sleep 2 |
| 128 | + |
| 129 | +# 3. Popup window_id finden |
| 130 | +WID=$(cua-driver call list_windows '{}' | python3 -c " |
| 131 | +import sys,json |
| 132 | +for w in json.load(sys.stdin).get('windows',[]): |
| 133 | + if w.get('pid')==$PID: |
| 134 | + t=(w.get('title','')).lower() |
| 135 | + if 'anmelden' in t or 'sign' in t or 'google' in t: |
| 136 | + print(w['window_id']) |
| 137 | +") |
| 138 | + |
| 139 | +# 4. Email eintippen (POPUP → cua-driver!) |
| 140 | +cua-driver call set_value "{\"pid\":$PID,\"window_id\":$WID,\"element_index\":25,\"value\":\"email@gmail.com\"}" |
| 141 | + |
| 142 | +# 5. "Weiter" klicken |
| 143 | +cua-driver call click "{\"pid\":$PID,\"window_id\":$WID,\"element_index\":35,\"action\":\"press\"}" |
| 144 | +sleep 2 |
| 145 | + |
| 146 | +# 6. "Fortfahren" (Consent) |
| 147 | +cua-driver call click "{\"pid\":$PID,\"window_id\":$WID,\"element_index\":65,\"action\":\"press\"}" |
| 148 | +sleep 2 |
| 149 | + |
| 150 | +# 7. Finales "Weiter" → Dashboard |
| 151 | +cua-driver call click "{\"pid\":$PID,\"window_id\":$WID,\"element_index\":41,\"action\":\"press\"}" |
| 152 | +``` |
| 153 | + |
| 154 | +### Was passiert wenn man skylight in Popups nutzt: |
| 155 | +- `skylight-cli list-elements --pid $PID` nach OAuth-Klick → **leere Liste** oder falsche Indices |
| 156 | +- Klick auf "falschen" Index → **falsches Element** → Detection → Account banned |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## 🔑 REGEL 5: NEUEN TAB HANDHABEN |
| 161 | + |
| 162 | +Ein neuer Tab ist KEIN Popup! Er hat die gleiche PID aber neue URL. |
| 163 | +skylight-cli kann neue Tabs sehen: |
| 164 | + |
| 165 | +```bash |
| 166 | +# Auf neuen Tab warten |
| 167 | +sleep 3 |
| 168 | + |
| 169 | +# Neue Elements scannen (skylight-cli, gleiche PID) |
| 170 | +skylight-cli list-elements --pid $PID | python3 -c " |
| 171 | +import json,sys |
| 172 | +for e in json.load(sys.stdin)['elements']: |
| 173 | + print(f'[{e[\"index\"]}] {e[\"role\"]}: {e.get(\"label\",\"\")[:60]}') |
| 174 | +" |
| 175 | +``` |
| 176 | + |
| 177 | +**Unterscheidung Popup vs. Tab**: |
| 178 | + |
| 179 | +| Kriterium | Popup | Neuer Tab | |
| 180 | +|-----------|-------|-----------| |
| 181 | +| Gleiche PID? | Ja | Ja | |
| 182 | +| `list_windows` zeigt es? | Ja (window_id != 0) | Nein | |
| 183 | +| `list-elements` zeigt es? | Nein | Ja | |
| 184 | +| Tool | **cua-driver** | **skylight-cli** | |
| 185 | + |
| 186 | +--- |
| 187 | + |
| 188 | +## 🚨 FAIL-SICHERUNG |
| 189 | + |
| 190 | +Falls du unsicher bist, welches Tool: |
| 191 | + |
| 192 | +1. **Frage**: "Ist das ein Popup-Fenster?" (Google OAuth, Consent, Alert) |
| 193 | + - Ja → cua-driver |
| 194 | + - Nein → skylight-cli |
| 195 | + |
| 196 | +2. **Verify**: |
| 197 | + - skylight: `skylight-cli list-elements --pid X | wc -l` (sollte >10 sein) |
| 198 | + - cua-driver: `cua-driver call list_windows '{}' | jq '.windows | length'` |
| 199 | + |
| 200 | +3. **Bei Fehler**: Erst skylight probieren, dann cua-driver. NIE beide mischen! |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## 📚 VERWANDTE DOKUMENTATION |
| 205 | + |
| 206 | +- `docs/cua-driver-popup-pattern.md` — Vollständiger Popup-Flow |
| 207 | +- `brain.md` — Systemwissen (cua-driver Daemon) |
| 208 | +- `commands.md` — Alle Befehle |
| 209 | +- `banned.md` — Verbotene Patterns |
0 commit comments