# RPA Vision Agent (Rust) — Phases 1-5 Agent complet pour RPA Vision V3, ecrit en Rust. Parite fonctionnelle avec l'agent Python (`agent_v0/agent_v1/`) en un seul executable de 2.4 Mo. ## Fonctionnalites ### Phase 1 — Agent minimal (headless) - **Heartbeat** : capture ecran toutes les 5s, JPEG, dedup par hash perceptuel - **Replay** : poll serveur, execute actions (click, type, key_combo, scroll, wait) - **Resolution visuelle** : resolution de cibles via le serveur (template matching) - **Serveur de capture** : port 5006 (GET /capture, GET /health, POST /file-action) ### Phase 3 — Systray + Notifications - **Systray** : icone avec cercle colore (gris=idle, rouge=enregistrement, vert=connecte, bleu=replay) - **Menu contextuel** : Machine ID, statut, Apprenez-moi, C'est termine, Mes taches, ARRET D'URGENCE, Chat, Fichiers, Quitter - **Notifications toast** : via winrt-notification (bienvenue, session, replay, connexion) - **Etat partage** : thread-safe via AtomicBool + Mutex ### Phase 4 — Chat WebView2 - **WebView2** : fenetre 520x720, charge http://{server}:5004/chat - **Positionnement** : bas-droite pres du systray - **Fallback** : HTML embarque si le serveur est indisponible - **Toggle** : show/hide via menu systray ### Phase 5 — Parite complete - **Enregistrement** : capture evenements souris/clavier via rdev, envoi au serveur - **Floutage** : detection de champs de saisie + blur gaussien (protection donnees sensibles) - **Configuration** : BLUR_SENSITIVE, LOG_RETENTION_DAYS, CHAT_PORT - **Health check** : verification connexion serveur toutes les 30s ## Build ### Linux (pour tests) ```bash sudo apt install libpipewire-0.3-dev libclang-dev libgbm-dev libxdo-dev cargo build --release ``` ### Cross-compilation vers Windows ```bash rustup target add x86_64-pc-windows-gnu sudo apt install gcc-mingw-w64-x86-64 cargo build --release --target x86_64-pc-windows-gnu ``` ### Deploiement sur le PC cible ```bash sshpass -p 'loli' scp -o StrictHostKeyChecking=no \ target/x86_64-pc-windows-gnu/release/rpa-agent.exe \ dom@192.168.1.11:"C:\\rpa_vision\\rpa-agent.exe" ``` ## Configuration | Variable | Defaut | Description | |---|---|---| | `RPA_SERVER_URL` | `http://localhost:5005/api/v1` | URL du serveur streaming | | `RPA_MACHINE_ID` | `{hostname}_{os}` | Identifiant de la machine | | `RPA_CAPTURE_PORT` | `5006` | Port du serveur de capture | | `RPA_HEARTBEAT_INTERVAL` | `5` | Intervalle heartbeat (secondes) | | `RPA_JPEG_QUALITY` | `85` | Qualite JPEG (1-100) | | `RPA_BLUR_SENSITIVE` | `true` | Flouter les zones sensibles | | `RPA_LOG_RETENTION_DAYS` | `180` | Retention des logs (jours) | | `RPA_CHAT_PORT` | `5004` | Port du serveur de chat | ## Architecture ``` src/ ├── main.rs — Orchestrateur, 7 threads (heartbeat, replay, serveur, health, recorder, chat, tray) ├── config.rs — Configuration (env vars + defauts) ├── state.rs — Etat partage thread-safe (AtomicBool, Mutex) ├── capture.rs — Capture ecran (xcap), JPEG, hash perceptuel ├── network.rs — Client HTTP (heartbeat, poll replay, rapport resultat) ├── replay.rs — Boucle de polling replay avec notifications ├── executor.rs — Execution actions (click, type, key_combo, scroll, wait) ├── visual.rs — Resolution visuelle des cibles via le serveur ├── server.rs — Mini serveur HTTP port 5006 (/capture, /health, /file-action) ├── tray.rs — Icone systray + menu contextuel (tray-icon, winit) ├── notifications.rs — Notifications toast Windows (winrt-notification) ├── chat.rs — Fenetre de chat WebView2 (wry) ├── recorder.rs — Capture evenements souris/clavier (rdev) └── blur.rs — Floutage zones sensibles (detection + box blur) ``` ## Taille du binaire | Configuration | Taille | |---|---| | Release (LTO + strip + opt-level z) | **2.4 Mo** | | Python equivalent (venv + packages) | ~200 Mo | ## Compatibilite - **OS** : Windows 10/11 (systray, notifications, chat WebView2) - **Fallback Linux** : mode console (heartbeat, replay, serveur) - **Serveur** : compatible api_stream.py (port 5005)