Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +141 -40
templates/index.html
CHANGED
|
@@ -2,33 +2,139 @@
|
|
| 2 |
<html lang="es">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
|
|
|
| 5 |
<title>Mission Control v2 – Prueba</title>
|
| 6 |
<style>
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
@keyframes spin {
|
| 14 |
0% { transform: rotate(0deg); }
|
| 15 |
100% { transform: rotate(360deg); }
|
| 16 |
}
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
</style>
|
| 19 |
</head>
|
| 20 |
<body>
|
|
|
|
| 21 |
|
| 22 |
-
<
|
| 23 |
-
|
| 24 |
-
<label for="task">Escribe tu misión:</label><br>
|
| 25 |
-
<textarea id="task" placeholder="Ejemplo: Genera una imagen de un gato astronauta..."></textarea><br>
|
| 26 |
|
| 27 |
<button onclick="launchMission()">Lanzar misión</button>
|
| 28 |
|
| 29 |
<div id="result">
|
| 30 |
<h3>Resultado:</h3>
|
| 31 |
-
<
|
| 32 |
</div>
|
| 33 |
|
| 34 |
<script>
|
|
@@ -36,69 +142,64 @@
|
|
| 36 |
const taskInput = document.getElementById('task');
|
| 37 |
const task = taskInput.value.trim();
|
| 38 |
if (!task) return alert('Escribe algo primero');
|
| 39 |
-
|
| 40 |
const output = document.getElementById('output');
|
| 41 |
output.innerHTML = `
|
| 42 |
-
<div style="text-align:center; color:#666; padding:
|
| 43 |
-
<div class="spinner"
|
| 44 |
Procesando... (puede tardar 10–60 segundos la primera vez)
|
| 45 |
</div>
|
| 46 |
`;
|
| 47 |
-
|
| 48 |
try {
|
| 49 |
const res = await fetch('/api/mission', {
|
| 50 |
method: 'POST',
|
| 51 |
headers: { 'Content-Type': 'application/json' },
|
| 52 |
body: JSON.stringify({ task })
|
| 53 |
});
|
| 54 |
-
|
| 55 |
const data = await res.json();
|
| 56 |
-
|
| 57 |
if (!res.ok) {
|
| 58 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error ${res.status}: ${JSON.stringify(data, null, 2)}</pre>`;
|
| 59 |
return;
|
| 60 |
}
|
| 61 |
-
|
| 62 |
let html = '<h3>Resultado de la misión</h3>';
|
| 63 |
-
|
| 64 |
-
//
|
| 65 |
if (data.plan && data.plan.reasoning) {
|
| 66 |
html += `<p><strong>Manager pensó:</strong> ${data.plan.reasoning}</p>`;
|
| 67 |
}
|
| 68 |
-
|
| 69 |
-
//
|
| 70 |
if (data.results && data.results.length > 0) {
|
| 71 |
-
html += '<h4>Agentes que trabajaron:</h4>
|
| 72 |
data.results.forEach(r => {
|
| 73 |
-
const
|
| 74 |
-
const statusText = r.success ? 'Éxito' : 'Error';
|
| 75 |
html += `
|
| 76 |
-
<
|
| 77 |
-
<strong>${r.agent} (${
|
| 78 |
-
${r.response ? r.response.substring(0,
|
| 79 |
-
</
|
| 80 |
});
|
| 81 |
-
html += '</ul>';
|
| 82 |
} else {
|
| 83 |
html += '<p>No se delegó a ningún agente.</p>';
|
| 84 |
}
|
| 85 |
-
|
| 86 |
-
// Link de descarga
|
| 87 |
if (data.file_url) {
|
| 88 |
html += `
|
| 89 |
-
<
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
</a>
|
| 93 |
-
</p>`;
|
| 94 |
}
|
| 95 |
-
|
| 96 |
output.innerHTML = html;
|
| 97 |
} catch (err) {
|
| 98 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error de conexión: ${err.message}</pre>`;
|
| 99 |
}
|
| 100 |
}
|
| 101 |
</script>
|
| 102 |
-
|
| 103 |
</body>
|
| 104 |
</html>
|
|
|
|
| 2 |
<html lang="es">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Mission Control v2 – Prueba</title>
|
| 7 |
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--primary: #27ae60;
|
| 10 |
+
--primary-dark: #219653;
|
| 11 |
+
--dark-bg: #1e1e1e;
|
| 12 |
+
--text-light: #e0e0e0;
|
| 13 |
+
--success: #4caf50;
|
| 14 |
+
--success-light: #81c784;
|
| 15 |
+
--error: #ef5350;
|
| 16 |
+
--error-light: #ffccbc;
|
| 17 |
+
--info: #3498db;
|
| 18 |
+
--bg-light: #f8f9fa;
|
| 19 |
+
--bg-card: #2d2d2d;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 23 |
+
body {
|
| 24 |
+
font-family: Arial, sans-serif;
|
| 25 |
+
background: var(--bg-light);
|
| 26 |
+
color: #333;
|
| 27 |
+
margin: 20px;
|
| 28 |
+
line-height: 1.6;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
h1 { color: #2c3e50; margin-bottom: 20px; }
|
| 32 |
+
label { font-weight: bold; display: block; margin-bottom: 8px; }
|
| 33 |
+
|
| 34 |
+
textarea {
|
| 35 |
+
width: 100%;
|
| 36 |
+
height: 120px;
|
| 37 |
+
padding: 12px;
|
| 38 |
+
margin-bottom: 12px;
|
| 39 |
+
font-family: monospace;
|
| 40 |
+
border: 1px solid #ccc;
|
| 41 |
+
border-radius: 6px;
|
| 42 |
+
resize: vertical;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
button {
|
| 46 |
+
padding: 12px 24px;
|
| 47 |
+
background: var(--primary);
|
| 48 |
+
color: white;
|
| 49 |
+
border: none;
|
| 50 |
+
border-radius: 6px;
|
| 51 |
+
cursor: pointer;
|
| 52 |
+
font-size: 1rem;
|
| 53 |
+
transition: background 0.2s;
|
| 54 |
+
}
|
| 55 |
+
button:hover { background: var(--primary-dark); }
|
| 56 |
+
|
| 57 |
+
#result {
|
| 58 |
+
margin-top: 30px;
|
| 59 |
+
padding: 20px;
|
| 60 |
+
background: white;
|
| 61 |
+
border-radius: 8px;
|
| 62 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.spinner {
|
| 66 |
+
border: 4px solid #f3f3f3;
|
| 67 |
+
border-top: 4px solid var(--info);
|
| 68 |
+
border-radius: 50%;
|
| 69 |
+
width: 40px;
|
| 70 |
+
height: 40px;
|
| 71 |
+
animation: spin 1s linear infinite;
|
| 72 |
+
margin: 20px auto;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
@keyframes spin {
|
| 76 |
0% { transform: rotate(0deg); }
|
| 77 |
100% { transform: rotate(360deg); }
|
| 78 |
}
|
| 79 |
+
|
| 80 |
+
/* Resultados de agentes */
|
| 81 |
+
.agent-result {
|
| 82 |
+
margin: 16px 0;
|
| 83 |
+
padding: 16px;
|
| 84 |
+
border-radius: 6px;
|
| 85 |
+
background: var(--bg-card);
|
| 86 |
+
color: var(--text-light);
|
| 87 |
+
border-left: 4px solid var(--success);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.agent-result.error {
|
| 91 |
+
border-left-color: var(--error);
|
| 92 |
+
background: #3d1f1f;
|
| 93 |
+
color: var(--error-light);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.agent-result strong {
|
| 97 |
+
color: var(--success-light);
|
| 98 |
+
display: block;
|
| 99 |
+
margin-bottom: 8px;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.download-btn {
|
| 103 |
+
display: inline-block;
|
| 104 |
+
padding: 12px 24px;
|
| 105 |
+
background: #1976d2;
|
| 106 |
+
color: white;
|
| 107 |
+
text-decoration: none;
|
| 108 |
+
border-radius: 6px;
|
| 109 |
+
margin-top: 16px;
|
| 110 |
+
transition: background 0.2s;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.download-btn:hover {
|
| 114 |
+
background: #1565c0;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
pre {
|
| 118 |
+
background: #272822;
|
| 119 |
+
color: #f8f8f2;
|
| 120 |
+
padding: 15px;
|
| 121 |
+
border-radius: 6px;
|
| 122 |
+
overflow-x: auto;
|
| 123 |
+
margin: 12px 0;
|
| 124 |
+
}
|
| 125 |
</style>
|
| 126 |
</head>
|
| 127 |
<body>
|
| 128 |
+
<h1>Mission Control v2 – Prueba</h1>
|
| 129 |
|
| 130 |
+
<label for="task">Escribe tu misión:</label>
|
| 131 |
+
<textarea id="task" placeholder="Ejemplo: Genera una imagen de un gato astronauta..."></textarea>
|
|
|
|
|
|
|
| 132 |
|
| 133 |
<button onclick="launchMission()">Lanzar misión</button>
|
| 134 |
|
| 135 |
<div id="result">
|
| 136 |
<h3>Resultado:</h3>
|
| 137 |
+
<div id="output">Esperando...</div>
|
| 138 |
</div>
|
| 139 |
|
| 140 |
<script>
|
|
|
|
| 142 |
const taskInput = document.getElementById('task');
|
| 143 |
const task = taskInput.value.trim();
|
| 144 |
if (!task) return alert('Escribe algo primero');
|
| 145 |
+
|
| 146 |
const output = document.getElementById('output');
|
| 147 |
output.innerHTML = `
|
| 148 |
+
<div style="text-align:center; color:#666; padding:30px;">
|
| 149 |
+
<div class="spinner"></div>
|
| 150 |
Procesando... (puede tardar 10–60 segundos la primera vez)
|
| 151 |
</div>
|
| 152 |
`;
|
| 153 |
+
|
| 154 |
try {
|
| 155 |
const res = await fetch('/api/mission', {
|
| 156 |
method: 'POST',
|
| 157 |
headers: { 'Content-Type': 'application/json' },
|
| 158 |
body: JSON.stringify({ task })
|
| 159 |
});
|
| 160 |
+
|
| 161 |
const data = await res.json();
|
| 162 |
+
|
| 163 |
if (!res.ok) {
|
| 164 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error ${res.status}: ${JSON.stringify(data, null, 2)}</pre>`;
|
| 165 |
return;
|
| 166 |
}
|
| 167 |
+
|
| 168 |
let html = '<h3>Resultado de la misión</h3>';
|
| 169 |
+
|
| 170 |
+
// Razonamiento del manager
|
| 171 |
if (data.plan && data.plan.reasoning) {
|
| 172 |
html += `<p><strong>Manager pensó:</strong> ${data.plan.reasoning}</p>`;
|
| 173 |
}
|
| 174 |
+
|
| 175 |
+
// Resultados de agentes
|
| 176 |
if (data.results && data.results.length > 0) {
|
| 177 |
+
html += '<h4>Agentes que trabajaron:</h4>';
|
| 178 |
data.results.forEach(r => {
|
| 179 |
+
const isError = !r.success;
|
|
|
|
| 180 |
html += `
|
| 181 |
+
<div class="agent-result ${isError ? 'error' : ''}">
|
| 182 |
+
<strong>${r.agent} (${isError ? 'Error' : 'Éxito'})</strong>
|
| 183 |
+
<div>${r.response ? r.response.substring(0, 400) + (r.response.length > 400 ? '...' : '') : r.error || 'Sin respuesta'}</div>
|
| 184 |
+
</div>`;
|
| 185 |
});
|
|
|
|
| 186 |
} else {
|
| 187 |
html += '<p>No se delegó a ningún agente.</p>';
|
| 188 |
}
|
| 189 |
+
|
| 190 |
+
// Link de descarga
|
| 191 |
if (data.file_url) {
|
| 192 |
html += `
|
| 193 |
+
<a href="${data.file_url}" target="_blank" class="download-btn" download>
|
| 194 |
+
Descargar documento generado
|
| 195 |
+
</a>`;
|
|
|
|
|
|
|
| 196 |
}
|
| 197 |
+
|
| 198 |
output.innerHTML = html;
|
| 199 |
} catch (err) {
|
| 200 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error de conexión: ${err.message}</pre>`;
|
| 201 |
}
|
| 202 |
}
|
| 203 |
</script>
|
|
|
|
| 204 |
</body>
|
| 205 |
</html>
|