Update app/static/index.html
Browse files- app/static/index.html +129 -0
app/static/index.html
CHANGED
|
@@ -346,6 +346,8 @@ button{font-family:inherit}
|
|
| 346 |
<button class="sfbtn" onclick="toggleTheme()">π Toggle Theme</button>
|
| 347 |
<button class="sfbtn" onclick="clearAllAgents()">ποΈ Clear Agents</button>
|
| 348 |
<button class="sfbtn" onclick="clearAllChats()">ποΈ Clear All Chats</button>
|
|
|
|
|
|
|
| 349 |
</div>
|
| 350 |
</aside>
|
| 351 |
|
|
@@ -453,6 +455,56 @@ button{font-family:inherit}
|
|
| 453 |
</div>
|
| 454 |
</div>
|
| 455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
<!-- ββ Tool Detail Modal βββββββββββββββββββββββββββββββββββ -->
|
| 457 |
<div class="overlay" id="tool-modal" onclick="closeModalOutside(event,'tool-modal')">
|
| 458 |
<div class="modal">
|
|
@@ -1063,6 +1115,83 @@ function autoResize(el){el.style.height='auto';el.style.height=Math.min(el.scrol
|
|
| 1063 |
function useSuggestion(el){const t=el.querySelector('strong').nextSibling?.textContent?.trim()||el.textContent.trim();sendMessage(t)}
|
| 1064 |
function showToast(msg){const t=document.getElementById('toast');t.textContent=msg;t.classList.add('show');setTimeout(()=>t.classList.remove('show'),2600)}
|
| 1065 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1066 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1067 |
// BOOT
|
| 1068 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 346 |
<button class="sfbtn" onclick="toggleTheme()">π Toggle Theme</button>
|
| 347 |
<button class="sfbtn" onclick="clearAllAgents()">ποΈ Clear Agents</button>
|
| 348 |
<button class="sfbtn" onclick="clearAllChats()">ποΈ Clear All Chats</button>
|
| 349 |
+
<button class="sfbtn" onclick="openTelegram()">π± Telegram Bot</button>
|
| 350 |
+
<button class="sfbtn" onclick="openPkgInstaller()">π¦ Install Package</button>
|
| 351 |
</div>
|
| 352 |
</aside>
|
| 353 |
|
|
|
|
| 455 |
</div>
|
| 456 |
</div>
|
| 457 |
|
| 458 |
+
<!-- ββ Telegram Modal ββββββββββββββββββββββββββββββββββββββ -->
|
| 459 |
+
<div class="overlay" id="telegram-modal" onclick="closeModalOutside(event,'telegram-modal')">
|
| 460 |
+
<div class="modal">
|
| 461 |
+
<h2>π± Telegram Bot Setup</h2>
|
| 462 |
+
<div id="tg-status-bar" style="padding:10px 12px;border-radius:6px;font-size:12.5px;margin-bottom:14px;background:var(--bg3);border:1px solid var(--border)">
|
| 463 |
+
Checking statusβ¦
|
| 464 |
+
</div>
|
| 465 |
+
<div class="fg">
|
| 466 |
+
<label>Bot Token</label>
|
| 467 |
+
<input type="password" id="tg-token" placeholder="1234567890:ABCdefGHI..." />
|
| 468 |
+
<div class="hint">Get from <a href="https://t.me/BotFather" target="_blank" style="color:var(--acc)">@BotFather</a> on Telegram β /newbot</div>
|
| 469 |
+
</div>
|
| 470 |
+
<div class="fg">
|
| 471 |
+
<label>Your HuggingFace Space URL</label>
|
| 472 |
+
<input type="text" id="tg-base-url" placeholder="https://YOUR-USERNAME-praisonchat.hf.space" />
|
| 473 |
+
<div class="hint">This is where the webhook will point. Must be HTTPS.</div>
|
| 474 |
+
</div>
|
| 475 |
+
<div style="background:var(--bg3);border-radius:8px;padding:12px;font-size:12px;color:var(--txt2);margin-bottom:14px;line-height:1.6">
|
| 476 |
+
<strong style="color:var(--txt1)">How it works:</strong><br>
|
| 477 |
+
1. Create a bot via @BotFather β /newbot<br>
|
| 478 |
+
2. Paste the token above<br>
|
| 479 |
+
3. Enter your Space URL<br>
|
| 480 |
+
4. Click Connect β the webhook is auto-registered<br>
|
| 481 |
+
5. Open your bot in Telegram and chat!
|
| 482 |
+
</div>
|
| 483 |
+
<div class="modal-actions">
|
| 484 |
+
<button class="btn-g" onclick="disconnectTelegram()" id="tg-disconnect-btn" style="display:none;color:var(--red)">Disconnect</button>
|
| 485 |
+
<button class="btn-g" onclick="closeModal('telegram-modal')">Close</button>
|
| 486 |
+
<button class="btn-p" onclick="connectTelegram()">Connect Bot</button>
|
| 487 |
+
</div>
|
| 488 |
+
</div>
|
| 489 |
+
</div>
|
| 490 |
+
|
| 491 |
+
<!-- ββ Package Installer Modal ββββββββββββββββββββββββββββββ -->
|
| 492 |
+
<div class="overlay" id="pkg-modal" onclick="closeModalOutside(event,'pkg-modal')">
|
| 493 |
+
<div class="modal">
|
| 494 |
+
<h2>π¦ Install Python Package</h2>
|
| 495 |
+
<div class="fg">
|
| 496 |
+
<label>Package Name(s)</label>
|
| 497 |
+
<input type="text" id="pkg-input" placeholder="e.g. pandas numpy yfinance" />
|
| 498 |
+
<div class="hint">Space-separated. Packages are installed into the agent environment.</div>
|
| 499 |
+
</div>
|
| 500 |
+
<div id="pkg-result" style="display:none;padding:10px;border-radius:6px;font-size:12.5px;margin-top:8px;font-family:monospace"></div>
|
| 501 |
+
<div class="modal-actions">
|
| 502 |
+
<button class="btn-g" onclick="closeModal('pkg-modal')">Close</button>
|
| 503 |
+
<button class="btn-p" onclick="installPackage()">Install</button>
|
| 504 |
+
</div>
|
| 505 |
+
</div>
|
| 506 |
+
</div>
|
| 507 |
+
|
| 508 |
<!-- ββ Tool Detail Modal βββββββββββββββββββββββββββββββββββ -->
|
| 509 |
<div class="overlay" id="tool-modal" onclick="closeModalOutside(event,'tool-modal')">
|
| 510 |
<div class="modal">
|
|
|
|
| 1115 |
function useSuggestion(el){const t=el.querySelector('strong').nextSibling?.textContent?.trim()||el.textContent.trim();sendMessage(t)}
|
| 1116 |
function showToast(msg){const t=document.getElementById('toast');t.textContent=msg;t.classList.add('show');setTimeout(()=>t.classList.remove('show'),2600)}
|
| 1117 |
|
| 1118 |
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1119 |
+
// TELEGRAM
|
| 1120 |
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1121 |
+
async function openTelegram(){
|
| 1122 |
+
document.getElementById('telegram-modal').classList.add('open');
|
| 1123 |
+
const bar = document.getElementById('tg-status-bar');
|
| 1124 |
+
bar.textContent = 'Checking statusβ¦';
|
| 1125 |
+
try{
|
| 1126 |
+
const r = await fetch('/api/telegram/status');
|
| 1127 |
+
const d = await r.json();
|
| 1128 |
+
if(d.connected && d.bot && d.bot.username){
|
| 1129 |
+
bar.style.background='rgba(79,209,160,.12)';bar.style.borderColor='var(--green)';
|
| 1130 |
+
bar.innerHTML=`β
Connected as <strong>@${d.bot.username}</strong> (${d.bot.first_name})<br>Webhook: ${d.webhook?.url||'not set'}`;
|
| 1131 |
+
document.getElementById('tg-disconnect-btn').style.display='';
|
| 1132 |
+
} else {
|
| 1133 |
+
bar.style.background='var(--bg3)';bar.style.borderColor='var(--border)';
|
| 1134 |
+
bar.textContent='Not connected. Enter your bot token below.';
|
| 1135 |
+
document.getElementById('tg-disconnect-btn').style.display='none';
|
| 1136 |
+
}
|
| 1137 |
+
}catch(e){bar.textContent='Could not check status: '+e.message}
|
| 1138 |
+
}
|
| 1139 |
+
|
| 1140 |
+
async function connectTelegram(){
|
| 1141 |
+
const token = document.getElementById('tg-token').value.trim();
|
| 1142 |
+
const baseUrl = document.getElementById('tg-base-url').value.trim();
|
| 1143 |
+
const bar = document.getElementById('tg-status-bar');
|
| 1144 |
+
if(!token){showToast('β οΈ Enter your bot token');return}
|
| 1145 |
+
bar.textContent='Connectingβ¦';
|
| 1146 |
+
try{
|
| 1147 |
+
const r = await fetch('/api/telegram/setup',{method:'POST',
|
| 1148 |
+
headers:{'Content-Type':'application/json'},
|
| 1149 |
+
body:JSON.stringify({token,base_url:baseUrl})});
|
| 1150 |
+
const d = await r.json();
|
| 1151 |
+
if(d.ok){
|
| 1152 |
+
bar.style.background='rgba(79,209,160,.12)';bar.style.borderColor='var(--green)';
|
| 1153 |
+
bar.innerHTML=`β
Connected as <strong>@${d.bot?.username}</strong>! <br>Open your bot in Telegram and start chatting.`;
|
| 1154 |
+
document.getElementById('tg-disconnect-btn').style.display='';
|
| 1155 |
+
showToast('β
Telegram bot connected!');
|
| 1156 |
+
} else {
|
| 1157 |
+
bar.style.background='rgba(240,88,88,.1)';bar.style.borderColor='var(--red)';
|
| 1158 |
+
bar.textContent='β Failed: '+(d.detail||JSON.stringify(d));
|
| 1159 |
+
}
|
| 1160 |
+
}catch(e){bar.textContent='Error: '+e.message}
|
| 1161 |
+
}
|
| 1162 |
+
|
| 1163 |
+
async function disconnectTelegram(){
|
| 1164 |
+
if(!confirm('Disconnect Telegram bot?'))return;
|
| 1165 |
+
await fetch('/api/telegram/disconnect',{method:'DELETE'});
|
| 1166 |
+
showToast('Telegram bot disconnected');
|
| 1167 |
+
openTelegram();
|
| 1168 |
+
}
|
| 1169 |
+
|
| 1170 |
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1171 |
+
// PACKAGE INSTALLER
|
| 1172 |
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1173 |
+
function openPkgInstaller(){document.getElementById('pkg-modal').classList.add('open')}
|
| 1174 |
+
|
| 1175 |
+
async function installPackage(){
|
| 1176 |
+
const inp = document.getElementById('pkg-input').value.trim();
|
| 1177 |
+
if(!inp){showToast('Enter package name(s)');return}
|
| 1178 |
+
const packages = inp.split(/\s+/);
|
| 1179 |
+
const res = document.getElementById('pkg-result');
|
| 1180 |
+
res.style.display='block';res.style.background='var(--bg3)';
|
| 1181 |
+
res.textContent='Installing '+packages.join(', ')+'β¦';
|
| 1182 |
+
try{
|
| 1183 |
+
const r = await fetch('/api/install-package',{method:'POST',
|
| 1184 |
+
headers:{'Content-Type':'application/json'},
|
| 1185 |
+
body:JSON.stringify({packages})});
|
| 1186 |
+
const d = await r.json();
|
| 1187 |
+
res.style.background = d.ok?'rgba(79,209,160,.12)':'rgba(240,88,88,.1)';
|
| 1188 |
+
res.style.borderColor = d.ok?'var(--green)':'var(--red)';
|
| 1189 |
+
res.style.border = '1px solid';
|
| 1190 |
+
res.textContent = (d.ok?'β
':'β ') + d.message;
|
| 1191 |
+
if(d.ok){showToast('β
Package installed!');addActivity({type:'tool_result',icon:'π¦',html:`Installed: <code>${packages.join(', ')}</code>`})}
|
| 1192 |
+
}catch(e){res.textContent='Error: '+e.message}
|
| 1193 |
+
}
|
| 1194 |
+
|
| 1195 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1196 |
// BOOT
|
| 1197 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|