Refactor: Renommer command_interface en agent_chat

- command_interface/ → agent_chat/
- Mise à jour run.sh (--chat au lieu de --command)
- Mise à jour documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Dom
2026-01-15 15:13:26 +01:00
parent 752ac537d4
commit c6a857b96b
5 changed files with 2061 additions and 4 deletions

View File

@@ -0,0 +1,858 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RPA Vision V3 - Commande</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
:root {
--primary-color: #6366f1;
--bg-dark: #1e1e2e;
--bg-card: #2a2a3e;
--text-light: #e0e0e0;
--text-muted: #888;
--success: #22c55e;
--warning: #f59e0b;
}
* {
box-sizing: border-box;
}
body {
background: var(--bg-dark);
color: var(--text-light);
font-family: 'Segoe UI', system-ui, sans-serif;
min-height: 100vh;
margin: 0;
padding: 20px;
}
.main-container {
max-width: 800px;
margin: 0 auto;
}
/* Header */
.header {
text-align: center;
margin-bottom: 30px;
}
.header h1 {
font-size: 1.5rem;
font-weight: 300;
color: var(--text-muted);
}
.header h1 span {
color: var(--primary-color);
font-weight: 600;
}
/* Command Input */
.command-box {
background: var(--bg-card);
border-radius: 16px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.command-input-wrapper {
display: flex;
align-items: center;
background: rgba(255,255,255,0.05);
border-radius: 12px;
padding: 5px 15px;
border: 2px solid transparent;
transition: border-color 0.3s;
}
.command-input-wrapper:focus-within {
border-color: var(--primary-color);
}
.command-input-wrapper i {
color: var(--primary-color);
font-size: 1.2rem;
margin-right: 10px;
}
#commandInput {
flex: 1;
background: transparent;
border: none;
color: var(--text-light);
font-size: 1.1rem;
padding: 12px 0;
outline: none;
}
#commandInput::placeholder {
color: var(--text-muted);
}
.execute-btn {
background: var(--primary-color);
border: none;
border-radius: 8px;
padding: 10px 20px;
color: white;
cursor: pointer;
transition: transform 0.2s, opacity 0.2s;
}
.execute-btn:hover {
transform: scale(1.05);
}
.execute-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Results */
.results-box {
background: var(--bg-card);
border-radius: 16px;
padding: 20px;
margin-bottom: 20px;
display: none;
}
.results-box.visible {
display: block;
}
.result-item {
background: rgba(255,255,255,0.03);
border-radius: 10px;
padding: 15px;
margin-bottom: 10px;
cursor: pointer;
transition: background 0.2s;
}
.result-item:hover {
background: rgba(99, 102, 241, 0.1);
}
.result-item.selected {
background: rgba(99, 102, 241, 0.2);
border: 1px solid var(--primary-color);
}
.result-name {
font-weight: 600;
margin-bottom: 5px;
}
.result-confidence {
display: inline-block;
background: var(--primary-color);
color: white;
padding: 2px 8px;
border-radius: 4px;
font-size: 0.8rem;
margin-left: 10px;
}
.result-params {
color: var(--text-muted);
font-size: 0.9rem;
}
/* Execution Status */
.execution-box {
background: var(--bg-card);
border-radius: 16px;
padding: 20px;
margin-bottom: 20px;
display: none;
}
.execution-box.visible {
display: block;
}
.progress-bar-container {
background: rgba(255,255,255,0.1);
border-radius: 10px;
height: 10px;
overflow: hidden;
margin: 15px 0;
}
.progress-bar-fill {
background: linear-gradient(90deg, var(--primary-color), #818cf8);
height: 100%;
width: 0%;
transition: width 0.3s;
border-radius: 10px;
}
.execution-message {
text-align: center;
color: var(--text-muted);
}
.minimize-btn {
position: fixed;
top: 20px;
right: 20px;
background: var(--bg-card);
border: none;
border-radius: 50%;
width: 40px;
height: 40px;
color: var(--text-light);
cursor: pointer;
transition: background 0.2s;
}
.minimize-btn:hover {
background: var(--primary-color);
}
/* Workflows List */
.workflows-box {
background: var(--bg-card);
border-radius: 16px;
padding: 20px;
margin-bottom: 20px;
}
.workflows-box h3 {
font-size: 1rem;
color: var(--text-muted);
margin-bottom: 15px;
}
.workflow-tag {
display: inline-block;
background: rgba(99, 102, 241, 0.2);
color: var(--primary-color);
padding: 4px 10px;
border-radius: 20px;
font-size: 0.8rem;
margin: 2px;
}
/* Help Section */
.help-box {
background: var(--bg-card);
border-radius: 16px;
padding: 20px;
margin-bottom: 20px;
}
.help-toggle {
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
}
.help-content {
display: none;
margin-top: 15px;
padding-top: 15px;
border-top: 1px solid rgba(255,255,255,0.1);
}
.help-content.visible {
display: block;
}
.help-section {
margin-bottom: 20px;
}
.help-section h4 {
color: var(--primary-color);
font-size: 1rem;
margin-bottom: 10px;
}
.help-section p, .help-section ul {
color: var(--text-muted);
font-size: 0.9rem;
line-height: 1.6;
}
/* Status indicator */
.status-indicator {
display: flex;
align-items: center;
gap: 8px;
font-size: 0.85rem;
color: var(--text-muted);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--success);
}
.status-dot.offline {
background: #ef4444;
}
/* GPU Status Bar */
.gpu-status-bar {
display: flex;
justify-content: center;
gap: 20px;
margin-bottom: 20px;
padding: 10px;
background: var(--bg-card);
border-radius: 10px;
font-size: 0.85rem;
}
.gpu-item {
display: flex;
align-items: center;
gap: 6px;
color: var(--text-muted);
}
.gpu-item i {
color: var(--primary-color);
}
.gpu-item.active {
color: var(--success);
}
.gpu-item.warning {
color: var(--warning);
}
/* History */
.history-item {
padding: 10px;
border-bottom: 1px solid rgba(255,255,255,0.05);
font-size: 0.9rem;
}
.history-item:last-child {
border-bottom: none;
}
.history-command {
color: var(--text-light);
}
.history-time {
color: var(--text-muted);
font-size: 0.8rem;
}
/* Minimized state */
body.minimized .main-container {
display: none;
}
body.minimized .minimized-bar {
display: flex;
}
.minimized-bar {
display: none;
position: fixed;
bottom: 20px;
right: 20px;
background: var(--bg-card);
border-radius: 30px;
padding: 10px 20px;
align-items: center;
gap: 15px;
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.minimized-bar .progress-mini {
width: 100px;
height: 4px;
background: rgba(255,255,255,0.1);
border-radius: 2px;
}
.minimized-bar .progress-mini-fill {
height: 100%;
background: var(--primary-color);
border-radius: 2px;
transition: width 0.3s;
}
.restore-btn {
background: var(--primary-color);
border: none;
border-radius: 20px;
padding: 5px 15px;
color: white;
cursor: pointer;
}
/* Animations */
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.executing .status-dot {
animation: pulse 1s infinite;
background: var(--warning);
}
</style>
</head>
<body>
<!-- Minimize Button -->
<button class="minimize-btn" onclick="toggleMinimize()" title="Minimiser (Ctrl+M)">
<i class="bi bi-dash-lg"></i>
</button>
<!-- Minimized Bar -->
<div class="minimized-bar">
<span id="miniStatus">En cours...</span>
<div class="progress-mini">
<div class="progress-mini-fill" id="miniProgress" style="width: 0%"></div>
</div>
<button class="restore-btn" onclick="toggleMinimize()">Restaurer</button>
</div>
<div class="main-container">
<!-- Header -->
<div class="header">
<h1><span>RPA Vision</span> V3</h1>
<div class="status-indicator" id="statusIndicator">
<span class="status-dot"></span>
<span id="statusText">Connecté</span>
</div>
</div>
<!-- GPU Status Bar -->
<div class="gpu-status-bar" id="gpuStatusBar">
<div class="gpu-item">
<i class="bi bi-gpu-card"></i>
<span id="gpuMode">-</span>
</div>
<div class="gpu-item">
<i class="bi bi-cpu"></i>
<span id="vlmState">-</span>
</div>
<div class="gpu-item">
<i class="bi bi-memory"></i>
<span id="vramUsage">-</span>
</div>
<div class="gpu-item">
<i class="bi bi-robot"></i>
<span id="ollamaStatus">-</span>
</div>
</div>
<!-- Command Input -->
<div class="command-box">
<div class="command-input-wrapper">
<i class="bi bi-terminal"></i>
<input type="text" id="commandInput" placeholder="Que voulez-vous faire ? (ex: facturer client Acme)" autofocus>
<button class="execute-btn" id="executeBtn" onclick="executeCommand()">
<i class="bi bi-play-fill"></i> Exécuter
</button>
</div>
</div>
<!-- Search Results -->
<div class="results-box" id="resultsBox">
<h3><i class="bi bi-search"></i> Workflows correspondants</h3>
<div id="resultsList"></div>
</div>
<!-- Execution Status -->
<div class="execution-box" id="executionBox">
<h3><i class="bi bi-gear-wide-connected"></i> Exécution en cours</h3>
<div class="progress-bar-container">
<div class="progress-bar-fill" id="progressBar"></div>
</div>
<p class="execution-message" id="executionMessage">Initialisation...</p>
<div class="text-center mt-3">
<button class="btn btn-outline-danger btn-sm" onclick="cancelExecution()">
<i class="bi bi-x-circle"></i> Annuler
</button>
<button class="btn btn-outline-secondary btn-sm ms-2" onclick="toggleMinimize()">
<i class="bi bi-arrows-angle-contract"></i> Minimiser
</button>
</div>
</div>
<!-- Workflows List -->
<div class="workflows-box">
<h3><i class="bi bi-collection"></i> Workflows disponibles</h3>
<div id="workflowsList"></div>
</div>
<!-- Help -->
<div class="help-box">
<div class="help-toggle" onclick="toggleHelp()">
<h3 style="margin: 0;"><i class="bi bi-question-circle"></i> Mode d'emploi</h3>
<i class="bi bi-chevron-down" id="helpChevron"></i>
</div>
<div class="help-content" id="helpContent">
<div class="help-section">
<h4>🎯 Commandes en langage naturel</h4>
<p>Tapez simplement ce que vous voulez faire. Le système trouvera automatiquement le workflow correspondant.</p>
<ul>
<li><code>facturer le client Acme</code></li>
<li><code>exporter le rapport en PDF</code></li>
<li><code>facturer les clients de A à Z</code></li>
</ul>
</div>
<div class="help-section">
<h4>⌨️ Raccourcis clavier</h4>
<ul>
<li><kbd>Entrée</kbd> - Exécuter la commande</li>
<li><kbd>Échap</kbd> - Annuler / Fermer</li>
<li><kbd></kbd> / <kbd></kbd> - Naviguer dans l'historique</li>
<li><kbd>Ctrl+M</kbd> - Minimiser l'interface</li>
</ul>
</div>
<div class="help-section">
<h4>🔄 Pendant l'exécution</h4>
<p>L'interface peut être minimisée pendant l'exécution. Le workflow s'exécute en arrière-plan et vous serez notifié à la fin.</p>
</div>
</div>
</div>
<!-- History -->
<div class="help-box">
<div class="help-toggle" onclick="toggleHistory()">
<h3 style="margin: 0;"><i class="bi bi-clock-history"></i> Historique</h3>
<i class="bi bi-chevron-down" id="historyChevron"></i>
</div>
<div class="help-content" id="historyContent">
<div id="historyList">
<p class="text-muted">Aucune commande récente</p>
</div>
</div>
</div>
</div>
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
<script>
// WebSocket connection
const socket = io();
// State
let searchTimeout = null;
let selectedResult = null;
let commandHistory = [];
let historyIndex = -1;
// Elements
const commandInput = document.getElementById('commandInput');
const resultsBox = document.getElementById('resultsBox');
const resultsList = document.getElementById('resultsList');
const executionBox = document.getElementById('executionBox');
const progressBar = document.getElementById('progressBar');
const executionMessage = document.getElementById('executionMessage');
const executeBtn = document.getElementById('executeBtn');
// Initialize
document.addEventListener('DOMContentLoaded', () => {
loadWorkflows();
loadHistory();
loadSystemStatus();
// Refresh status every 5 seconds
setInterval(loadSystemStatus, 5000);
// Input events
commandInput.addEventListener('input', onInputChange);
commandInput.addEventListener('keydown', onKeyDown);
});
async function loadSystemStatus() {
try {
const response = await fetch('/api/status');
const data = await response.json();
// GPU Status
if (data.gpu) {
document.getElementById('gpuMode').textContent = data.gpu.mode || '-';
document.getElementById('vlmState').textContent = data.gpu.vlm_state || '-';
if (data.gpu.vram) {
document.getElementById('vramUsage').textContent =
`${data.gpu.vram.used_mb}/${data.gpu.vram.total_mb} MB (${data.gpu.vram.percent}%)`;
}
}
// Ollama Status
if (data.ollama) {
document.getElementById('ollamaStatus').textContent =
data.ollama.available ? `${data.ollama.models_count} modèles` : 'Hors ligne';
document.getElementById('ollamaStatus').parentElement.classList.toggle('active', data.ollama.available);
}
} catch (error) {
console.error('Status error:', error);
}
}
// WebSocket events
socket.on('connect', () => {
document.getElementById('statusText').textContent = 'Connecté';
document.querySelector('.status-dot').classList.remove('offline');
});
socket.on('disconnect', () => {
document.getElementById('statusText').textContent = 'Déconnecté';
document.querySelector('.status-dot').classList.add('offline');
});
socket.on('execution_started', (data) => {
showExecution();
});
socket.on('execution_progress', (data) => {
updateProgress(data.progress, data.step);
});
socket.on('execution_completed', (data) => {
hideExecution();
showNotification(`${data.workflow} terminé !`);
loadHistory();
});
socket.on('execution_cancelled', () => {
hideExecution();
showNotification('❌ Exécution annulée');
});
// Functions
function onInputChange() {
const query = commandInput.value.trim();
if (searchTimeout) clearTimeout(searchTimeout);
if (query.length < 2) {
resultsBox.classList.remove('visible');
return;
}
searchTimeout = setTimeout(() => searchWorkflows(query), 300);
}
function onKeyDown(e) {
if (e.key === 'Enter') {
executeCommand();
} else if (e.key === 'Escape') {
commandInput.value = '';
resultsBox.classList.remove('visible');
} else if (e.key === 'ArrowUp') {
navigateHistory(-1);
e.preventDefault();
} else if (e.key === 'ArrowDown') {
navigateHistory(1);
e.preventDefault();
}
}
// Ctrl+M to minimize
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key === 'm') {
toggleMinimize();
e.preventDefault();
}
});
async function searchWorkflows(query) {
try {
const response = await fetch('/api/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query })
});
const data = await response.json();
displayResults(data.matches);
} catch (error) {
console.error('Search error:', error);
}
}
function displayResults(matches) {
if (!matches || matches.length === 0) {
resultsBox.classList.remove('visible');
return;
}
resultsList.innerHTML = matches.map((m, i) => `
<div class="result-item ${i === 0 ? 'selected' : ''}" onclick="selectResult(${i})" data-index="${i}">
<div class="result-name">
${m.workflow_name}
<span class="result-confidence">${Math.round(m.confidence * 100)}%</span>
</div>
${Object.keys(m.extracted_params).length > 0 ?
`<div class="result-params">Paramètres: ${JSON.stringify(m.extracted_params)}</div>` : ''}
</div>
`).join('');
selectedResult = matches[0];
resultsBox.classList.add('visible');
}
function selectResult(index) {
document.querySelectorAll('.result-item').forEach((el, i) => {
el.classList.toggle('selected', i === index);
});
}
async function executeCommand() {
const command = commandInput.value.trim();
if (!command) return;
executeBtn.disabled = true;
try {
const response = await fetch('/api/execute', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ command })
});
const data = await response.json();
if (data.success) {
commandHistory.unshift(command);
historyIndex = -1;
showExecution();
} else {
showNotification(`${data.error}`);
}
} catch (error) {
showNotification('❌ Erreur de connexion');
} finally {
executeBtn.disabled = false;
}
}
function showExecution() {
resultsBox.classList.remove('visible');
executionBox.classList.add('visible');
document.getElementById('statusIndicator').classList.add('executing');
}
function hideExecution() {
executionBox.classList.remove('visible');
document.getElementById('statusIndicator').classList.remove('executing');
progressBar.style.width = '0%';
}
function updateProgress(percent, message) {
progressBar.style.width = percent + '%';
executionMessage.textContent = message;
document.getElementById('miniProgress').style.width = percent + '%';
document.getElementById('miniStatus').textContent = message;
}
function cancelExecution() {
socket.emit('cancel_execution');
}
function toggleMinimize() {
document.body.classList.toggle('minimized');
}
function toggleHelp() {
document.getElementById('helpContent').classList.toggle('visible');
document.getElementById('helpChevron').classList.toggle('bi-chevron-down');
document.getElementById('helpChevron').classList.toggle('bi-chevron-up');
}
function toggleHistory() {
document.getElementById('historyContent').classList.toggle('visible');
document.getElementById('historyChevron').classList.toggle('bi-chevron-down');
document.getElementById('historyChevron').classList.toggle('bi-chevron-up');
}
function navigateHistory(direction) {
if (commandHistory.length === 0) return;
historyIndex += direction;
historyIndex = Math.max(-1, Math.min(historyIndex, commandHistory.length - 1));
if (historyIndex >= 0) {
commandInput.value = commandHistory[historyIndex];
} else {
commandInput.value = '';
}
}
async function loadWorkflows() {
try {
const response = await fetch('/api/workflows');
const data = await response.json();
const workflowsList = document.getElementById('workflowsList');
workflowsList.innerHTML = data.workflows.map(w => `
<div class="result-item" onclick="commandInput.value='${w.name}'; onInputChange();">
<div class="result-name">${w.name}</div>
<div>${w.tags.map(t => `<span class="workflow-tag">${t}</span>`).join('')}</div>
</div>
`).join('');
} catch (error) {
console.error('Load workflows error:', error);
}
}
async function loadHistory() {
try {
const response = await fetch('/api/history');
const data = await response.json();
const historyList = document.getElementById('historyList');
if (data.history.length === 0) {
historyList.innerHTML = '<p class="text-muted">Aucune commande récente</p>';
} else {
historyList.innerHTML = data.history.slice(0, 10).map(h => `
<div class="history-item" onclick="commandInput.value='${h.command}'; onInputChange();">
<div class="history-command">${h.command}</div>
<div class="history-time">${h.workflow} - ${new Date(h.timestamp).toLocaleString()}</div>
</div>
`).join('');
}
} catch (error) {
console.error('Load history error:', error);
}
}
function showNotification(message) {
// Simple notification
const notification = document.createElement('div');
notification.style.cssText = `
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
background: var(--bg-card);
padding: 15px 25px;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
z-index: 1000;
animation: fadeIn 0.3s;
`;
notification.textContent = message;
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 3000);
}
</script>
</body>
</html>