feat: agent Rust complet — systray, chat, enregistrement, floutage (2.4 MB)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,52 +1,58 @@
|
||||
# RPA Vision Agent (Rust) — Phase 1
|
||||
# RPA Vision Agent (Rust) — Phases 1-5
|
||||
|
||||
Agent headless pour RPA Vision V3, ecrit en Rust.
|
||||
Capture des screenshots, les envoie au serveur streaming, poll les actions de replay et les execute.
|
||||
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.
|
||||
|
||||
Equivalent fonctionnel de `agent_v0/agent_v1/` (Python) mais en un seul executable sans dependance.
|
||||
## Fonctionnalites
|
||||
|
||||
## Fonctionnalites (Phase 1)
|
||||
### 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)
|
||||
|
||||
- **Heartbeat** : capture l'ecran toutes les 5s, encode en JPEG, envoie au serveur avec deduplication par hash perceptuel
|
||||
- **Replay** : poll GET /replay/next toutes les secondes, execute les actions (click, type, key_combo, scroll, wait), rapporte le resultat avec screenshot post-action
|
||||
- **Serveur de capture** : mini serveur HTTP sur port 5006 pour screenshots a la demande (GET /capture, GET /health, POST /file-action)
|
||||
- **Configuration** : via variables d'environnement ou valeurs par defaut
|
||||
### 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
|
||||
# Pre-requis systeme (Ubuntu/Debian)
|
||||
sudo apt install libpipewire-0.3-dev libclang-dev libgbm-dev libxdo-dev
|
||||
|
||||
# Build debug
|
||||
cargo build
|
||||
|
||||
# Build release optimise
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
### Cross-compilation vers Windows
|
||||
|
||||
```bash
|
||||
# Option A : cargo-xwin (recommande, produit un .exe MSVC)
|
||||
cargo install cargo-xwin
|
||||
rustup target add x86_64-pc-windows-msvc
|
||||
cargo xwin build --target x86_64-pc-windows-msvc --release
|
||||
|
||||
# Option B : MinGW (plus simple)
|
||||
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
|
||||
|
||||
# Option C : cross (Docker)
|
||||
cargo install cross
|
||||
cross build --release --target x86_64-pc-windows-msvc
|
||||
```
|
||||
|
||||
Le binaire release se trouve dans `target/release/rpa-agent` (Linux) ou
|
||||
`target/x86_64-pc-windows-msvc/release/rpa-agent.exe` (Windows).
|
||||
### 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
|
||||
|
||||
@@ -57,74 +63,39 @@ Le binaire release se trouve dans `target/release/rpa-agent` (Linux) ou
|
||||
| `RPA_CAPTURE_PORT` | `5006` | Port du serveur de capture |
|
||||
| `RPA_HEARTBEAT_INTERVAL` | `5` | Intervalle heartbeat (secondes) |
|
||||
| `RPA_JPEG_QUALITY` | `85` | Qualite JPEG (1-100) |
|
||||
|
||||
## Execution
|
||||
|
||||
```bash
|
||||
# Avec les defauts (serveur local)
|
||||
./target/release/rpa-agent
|
||||
|
||||
# Vers un serveur distant
|
||||
RPA_SERVER_URL=http://192.168.1.10:5005/api/v1 ./target/release/rpa-agent
|
||||
|
||||
# Avec un identifiant machine specifique
|
||||
RPA_MACHINE_ID=pc_bureau_windows ./target/release/rpa-agent
|
||||
```
|
||||
|
||||
## API du serveur de capture (port 5006)
|
||||
|
||||
### GET /capture
|
||||
Retourne un screenshot frais en JSON :
|
||||
```json
|
||||
{
|
||||
"image": "<base64 JPEG>",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"format": "jpeg",
|
||||
"source": "rust_agent",
|
||||
"capture_ms": 42
|
||||
}
|
||||
```
|
||||
|
||||
### GET /health
|
||||
```json
|
||||
{"status": "ok", "agent": "rust", "version": "0.1.0-rust"}
|
||||
```
|
||||
|
||||
### POST /file-action
|
||||
Actions fichiers sur la machine locale :
|
||||
```json
|
||||
{"action": "file_list_dir", "params": {"path": "C:\\Users\\dom\\Documents"}}
|
||||
{"action": "file_create_dir", "params": {"path": "C:\\Users\\dom\\Documents\\tri"}}
|
||||
{"action": "file_move", "params": {"source": "...", "destination": "..."}}
|
||||
{"action": "file_copy", "params": {"source": "...", "destination": "..."}}
|
||||
{"action": "file_sort_by_ext", "params": {"source_dir": "C:\\Users\\dom\\Downloads"}}
|
||||
```
|
||||
| `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 — Point d'entree, 3 threads (heartbeat, replay, serveur)
|
||||
├── config.rs — Configuration (env vars + defauts)
|
||||
├── capture.rs — Capture ecran (xcap), encodage JPEG, hash perceptuel
|
||||
├── network.rs — Client HTTP (heartbeat, poll replay, rapport resultat)
|
||||
├── replay.rs — Boucle de polling replay avec backoff
|
||||
├── executor.rs — Execution actions (click, type, key_combo, scroll, wait)
|
||||
└── server.rs — Mini serveur HTTP port 5006 (/capture, /health, /file-action)
|
||||
├── 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)
|
||||
```
|
||||
|
||||
## Compatibilite serveur
|
||||
## Taille du binaire
|
||||
|
||||
Cet agent est compatible avec le serveur streaming existant (`agent_v0/server_v1/api_stream.py`, port 5005).
|
||||
| Configuration | Taille |
|
||||
|---|---|
|
||||
| Release (LTO + strip + opt-level z) | **2.4 Mo** |
|
||||
| Python equivalent (venv + packages) | ~200 Mo |
|
||||
|
||||
Endpoints utilises :
|
||||
- `POST /api/v1/traces/stream/image` — envoi heartbeat screenshot
|
||||
- `GET /api/v1/traces/stream/replay/next` — poll action replay
|
||||
- `POST /api/v1/traces/stream/replay/result` — rapport resultat replay
|
||||
## Compatibilite
|
||||
|
||||
## Phases suivantes
|
||||
|
||||
- **Phase 2** : Systray + notifications (tray-icon, winrt-notification)
|
||||
- **Phase 3** : Fenetre de chat (wry/WebView2)
|
||||
- **Phase 4** : Parite complete (floutage, capture evenements rdev)
|
||||
- **OS** : Windows 10/11 (systray, notifications, chat WebView2)
|
||||
- **Fallback Linux** : mode console (heartbeat, replay, serveur)
|
||||
- **Serveur** : compatible api_stream.py (port 5005)
|
||||
|
||||
Reference in New Issue
Block a user