Files
weval-l99/v111_hub_enrich.py
2026-04-24 04:38:58 +02:00

87 lines
3.8 KiB
Python

#!/usr/bin/env python3
"""V111 - Enrich hub Capabilities tab with Blade Tasks live + quick action buttons"""
path = "/var/www/html/all-ia-hub.html"
with open(path, "r", encoding="utf-8") as f:
c = f.read()
if "V111-BLADE-ENRICH" in c:
print("ALREADY")
exit(0)
# Add live Blade Tasks card + Quick Actions pannel at TOP of caps-grid
caps_anchor = '<div class="caps-grid" id="caps-grid">\n <div class="cap">\n <h3>&#127760; DeepSeek Web Access</h3>'
v111_add = '''<div class="caps-grid" id="caps-grid">
<!-- V111-BLADE-ENRICH: live blade tasks + quick actions -->
<div class="cap" style="grid-column:1 / -1;background:linear-gradient(135deg,#1e293b,#0f172a);border-color:var(--cy)">
<h3>&#128248; Blade Tasks Queue &mdash; Chrome yacineutt pilote temps-reel</h3>
<p style="margin-bottom:10px">Tasks pending: <b id="blade-pending">...</b> &middot; Tasks done: <b id="blade-done">...</b> &middot; MCP port 8765 Bearer actif</p>
<div style="display:flex;gap:6px;flex-wrap:wrap;margin-top:8px">
<button class="mode" onclick="pushBladeTask(\\'office_create\\',{})">+ Office Create</button>
<button class="mode" onclick="pushBladeTask(\\'deepseek_renew\\',{})">+ DeepSeek Renew</button>
<button class="mode" onclick="pushBladeTask(\\'thuggie_login\\',{})">+ Thuggie Login</button>
<button class="mode" onclick="pushBladeTask(\\'token_github_renew\\',{})">+ GitHub Token</button>
<button class="mode" onclick="pushBladeTask(\\'token_whatsapp_renew\\',{})">+ WhatsApp Token</button>
<button class="mode" onclick="refreshBladeStats()">Refresh</button>
</div>
<div id="blade-log" style="margin-top:10px;font-size:10px;color:var(--mu);max-height:120px;overflow-y:auto;background:var(--bg3);padding:8px;border-radius:4px;display:none"></div>
</div>
<div class="cap">
<h3>&#127760; DeepSeek Web Access</h3>'''
if caps_anchor not in c:
print("ANCHOR NOT FOUND")
exit(1)
c = c.replace(caps_anchor, v111_add, 1)
# Add JS functions before </script>
js_anchor = '// Live stats'
js_v111 = '''// V111-BLADE-ENRICH: live blade tasks stats + push actions
async function refreshBladeStats(){
try{
const r=await fetch('/api/blade-task-create.php?k=WEVADS2026&action=list');
const d=await r.json();
const pending=(d.tasks||[]).filter(t=>t.status==='pending').length;
const done=(d.tasks||[]).filter(t=>t.status==='done').length;
const bp=document.getElementById('blade-pending');
const bd=document.getElementById('blade-done');
if(bp) bp.textContent=pending;
if(bd) bd.textContent=done;
}catch(e){
const bp=document.getElementById('blade-pending');
if(bp) bp.textContent='?';
}
}
async function pushBladeTask(goal, params){
const log=document.getElementById('blade-log');
if(log){log.style.display='block';log.innerHTML+='\\n&gt; Pushing task: '+goal+'...';}
try{
const fd=new FormData();
fd.append('k','WEVADS2026');
fd.append('action','create');
fd.append('goal',goal);
fd.append('params',JSON.stringify(params||{}));
const r=await fetch('/api/blade-task-create.php',{method:'POST',body:fd});
const d=await r.json();
if(log){log.innerHTML+='\\n&gt; '+(d.ok?'\\u2705 Task created: '+d.id:'\\u274c '+(d.error||'failed'));log.scrollTop=log.scrollHeight;}
setTimeout(refreshBladeStats,500);
}catch(e){
if(log) log.innerHTML+='\\n&gt; \\u274c Error: '+e.message;
}
}
// auto-refresh blade stats every 30s when capabilities tab visible
setInterval(()=>{ if(document.getElementById('v-caps').classList.contains('on')) refreshBladeStats(); },30000);
setTimeout(refreshBladeStats, 1500);
// Live stats'''
if js_anchor in c:
c = c.replace(js_anchor, js_v111, 1)
with open(path, "w", encoding="utf-8") as f:
f.write(c)
print(f"PATCHED size={len(c)}")