- Token Bearer auth sur le streaming server (auto-généré ou env var) - Validation actions replay (types, longueurs, coordonnées 0-1) - Rate limiting in-memory (10 replays/min, 200 images/min) - Security headers Flask (nosniff, SAMEORIGIN, XSS) - Validation uploads (50MB max, MIME type) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
# agent_v1/config.py
|
|
"""
|
|
Configuration avancée pour Agent V1.
|
|
"""
|
|
from __future__ import annotations
|
|
import os
|
|
import platform
|
|
import socket
|
|
from pathlib import Path
|
|
|
|
AGENT_VERSION = "1.0.0"
|
|
|
|
# Identifiant unique de la machine (utilisé pour le multi-machine)
|
|
# Configurable via variable d'environnement, sinon auto-généré depuis hostname + OS
|
|
MACHINE_ID = os.environ.get(
|
|
"RPA_MACHINE_ID",
|
|
f"{socket.gethostname()}_{platform.system().lower()}",
|
|
)
|
|
|
|
# Dossier racine de l'agent
|
|
BASE_DIR = Path(__file__).resolve().parent
|
|
|
|
# Endpoint du serveur Streaming (port 5005)
|
|
SERVER_URL = os.getenv("RPA_SERVER_URL", "http://localhost:5005/api/v1")
|
|
UPLOAD_ENDPOINT = f"{SERVER_URL}/traces/upload"
|
|
STREAMING_ENDPOINT = f"{SERVER_URL}/traces/stream"
|
|
|
|
# Token d'authentification API (doit correspondre au token du serveur)
|
|
# Configurable via variable d'environnement RPA_API_TOKEN
|
|
API_TOKEN = os.environ.get("RPA_API_TOKEN", "")
|
|
|
|
# Paramètres de session
|
|
MAX_SESSION_DURATION_S = 60 * 60 # 1 heure
|
|
SESSIONS_ROOT = BASE_DIR / "sessions"
|
|
|
|
# Paramètres Vision (Crops pour qwen3-vl)
|
|
TARGETED_CROP_SIZE = (400, 400)
|
|
SCREENSHOT_QUALITY = 85
|
|
|
|
# Floutage des données sensibles (conformité AI Act)
|
|
# Floute les champs de saisie dans les screenshots AVANT stockage/envoi
|
|
# Désactiver avec RPA_BLUR_SENSITIVE=false pour le développement/tests
|
|
BLUR_SENSITIVE = os.environ.get("RPA_BLUR_SENSITIVE", "true").lower() in ("true", "1", "yes")
|
|
|
|
# Retention des logs — minimum 6 mois (180 jours) requis par le Reglement IA
|
|
# (Article 12 — journalisation automatique, Article 26(6) — conservation minimum)
|
|
# Configurable via variable d'environnement pour permettre l'ajustement
|
|
LOG_RETENTION_DAYS = int(os.environ.get("RPA_LOG_RETENTION_DAYS", "180"))
|
|
|
|
# Monitoring
|
|
PERF_MONITOR_INTERVAL_S = 30
|
|
LOGS_DIR = BASE_DIR / "logs"
|
|
LOG_FILE = LOGS_DIR / "agent_v1.log"
|
|
|
|
# Création des dossiers
|
|
os.makedirs(SESSIONS_ROOT, exist_ok=True)
|
|
os.makedirs(LOGS_DIR, exist_ok=True)
|