Implémente le SWAP réel de la MAJ silencieuse (DETTE-022), remplace les stubs : - updater.apply_update : ARME le swap (extrait le ZIP -> agent_v1_new/ + marqueur UPDATE_READY, garde-fou zip-slip). N'écrase JAMAIS le vivant. - updater.write_boot_ok_marker : désarme le rollback (retire PENDING_BOOT). - Lea.bat (template + embed généré par configure_embed.ps1) : swap ATOMIQUE par renames (agent_v1 -> agent_v1_prev backup ; agent_v1_new -> agent_v1) + rollback auto si PENDING_BOOT persiste (boot précédent non confirmé). - main.py : confirme le boot après 90 s de liveness locale OU quit propre (évite un faux rollback ; RPA_BOOT_CONFIRM_DELAY_S surchargeable pour les tests). Testable (Python) : 45 tests verts. Le swap OS (renames Lea.bat) + le câblage main.py seront validés par le test Win 11 (step 0 pré-canary, dont le rollback). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
106 lines
3.8 KiB
Batchfile
106 lines
3.8 KiB
Batchfile
@echo off
|
|
chcp 65001 >nul 2>&1
|
|
title Lea - Assistante IA
|
|
|
|
:: ---------------------------------------------------------------
|
|
:: Se placer dans le dossier du script (important pour les chemins)
|
|
:: ---------------------------------------------------------------
|
|
cd /d "%~dp0"
|
|
|
|
:: ---------------------------------------------------------------
|
|
:: Fermer l'ancienne instance de Lea (UNIQUEMENT via le PID du lock)
|
|
:: NE JAMAIS tuer tous les pythonw.exe/python.exe du poste :
|
|
:: cela tuerait Jupyter, Spyder, Anaconda, scripts metier, etc.
|
|
:: ---------------------------------------------------------------
|
|
if exist "lea_agent.lock" (
|
|
for /f "usebackq tokens=* delims=" %%i in ("lea_agent.lock") do (
|
|
taskkill /F /PID %%i >nul 2>&1
|
|
)
|
|
del /f /q "lea_agent.lock" >nul 2>&1
|
|
timeout /t 2 >nul
|
|
)
|
|
|
|
:: ---------------------------------------------------------------
|
|
:: MAJ SILENCIEUSE — swap atomique + rollback (hors-process)
|
|
:: L'ancienne instance est fermee ci-dessus : agent_v1\ est libre.
|
|
:: Renames uniquement (quasi-atomiques), jamais d'ecrasement fichier par fichier.
|
|
:: ---------------------------------------------------------------
|
|
if exist "PENDING_BOOT" (
|
|
:: Le boot precedent n'a JAMAIS confirme (crash) -> ROLLBACK version precedente
|
|
echo [MAJ] Boot precedent non confirme : retour a la version precedente.
|
|
if exist "agent_v1_prev" (
|
|
if exist "agent_v1_echec" rmdir /s /q "agent_v1_echec" >nul 2>&1
|
|
if exist "agent_v1" move "agent_v1" "agent_v1_echec" >nul 2>&1
|
|
move "agent_v1_prev" "agent_v1" >nul 2>&1
|
|
)
|
|
del /f /q "PENDING_BOOT" >nul 2>&1
|
|
) else if exist "UPDATE_READY" (
|
|
:: Une MAJ est armee (agent_v1_new pret) -> SWAP
|
|
if exist "agent_v1_new" (
|
|
echo [MAJ] Application de la mise a jour...
|
|
if exist "agent_v1" (
|
|
if exist "agent_v1_prev" rmdir /s /q "agent_v1_prev" >nul 2>&1
|
|
move "agent_v1" "agent_v1_prev" >nul 2>&1
|
|
)
|
|
move "agent_v1_new" "agent_v1" >nul 2>&1
|
|
move "UPDATE_READY" "PENDING_BOOT" >nul 2>&1
|
|
) else (
|
|
del /f /q "UPDATE_READY" >nul 2>&1
|
|
)
|
|
)
|
|
|
|
:: ---------------------------------------------------------------
|
|
:: Verifier que l'installation a ete faite
|
|
:: ---------------------------------------------------------------
|
|
if not exist ".venv\Scripts\python.exe" (
|
|
echo.
|
|
echo Lea n'est pas encore installee.
|
|
echo Lancez d'abord "install.bat" puis revenez ici.
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
:: ---------------------------------------------------------------
|
|
:: Charger la configuration depuis config.txt
|
|
:: Les lignes commencant par # sont ignorees (commentaires)
|
|
:: Format attendu : NOM_VARIABLE=valeur
|
|
:: ---------------------------------------------------------------
|
|
if exist "config.txt" (
|
|
for /f "usebackq eol=# tokens=1,* delims==" %%a in ("config.txt") do (
|
|
if not "%%a"=="" if not "%%b"=="" set "%%a=%%b"
|
|
)
|
|
) else (
|
|
echo ATTENTION : config.txt introuvable, utilisation des valeurs par defaut.
|
|
)
|
|
|
|
:: ---------------------------------------------------------------
|
|
:: Lancer Lea
|
|
:: ---------------------------------------------------------------
|
|
echo.
|
|
echo Demarrage de Lea...
|
|
echo (Lea apparait dans la barre des taches, en bas a droite)
|
|
echo.
|
|
echo Pour arreter Lea : clic droit sur l'icone ^> "Quitter Lea"
|
|
echo Vous pouvez fermer cette fenetre.
|
|
echo.
|
|
|
|
start "" /b .venv\Scripts\pythonw.exe run_agent_v1.py
|
|
|
|
:: Attendre 3s puis verifier que Lea tourne (via le PID du lock)
|
|
timeout /t 3 >nul
|
|
set "LEA_ALIVE=0"
|
|
if exist "lea_agent.lock" (
|
|
for /f "usebackq tokens=* delims=" %%i in ("lea_agent.lock") do (
|
|
tasklist /FI "PID eq %%i" /NH 2>nul | findstr /I "pythonw" >nul && set "LEA_ALIVE=1"
|
|
)
|
|
)
|
|
if "%LEA_ALIVE%"=="0" (
|
|
echo.
|
|
echo Lea n'a pas demarre correctement.
|
|
echo Tentative avec affichage des erreurs...
|
|
echo.
|
|
.venv\Scripts\python.exe run_agent_v1.py
|
|
pause
|
|
)
|