Download index.html from Metapp/Agent: direct link, hf CLI and curl.
- Browser
- Download file 12.1 kB
-
https://huggingface.co/spaces/Metapp/Agent/resolve/main/index.html
- Command line
-
hf download hf://spaces/Metapp/Agent/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Metapp/Agent/resolve/main/index.html
12.1 kB
| <!-- | |
| ==================================================================================== | |
| ОПЦИОНАЛЬНЫЙ ФАЙЛ (не обязателен для agent.py). | |
| ВАЖНО ПРО ЛОГИН: внутри кадра (iframe) браузер не передаёт сайту агента его | |
| cookie и изолирует хранилище, поэтому вход в аккаунт агента там НЕ сохраняется. | |
| Используйте этот файл только если приоритет - скрыть чужой адрес, а вход в | |
| аккаунт не нужен. Если логин важен - оставьте стандартную страницу /env/<id> | |
| из agent.py (плавный переход в этом же окне, логин сохраняется). | |
| ЗАЧЕМ ОН НУЖЕН: | |
| Сайт агента (arena.ai) отдаёт заголовок: | |
| Content-Security-Policy: frame-ancestors 'self' https://huggingface.co/ https://*.static.hf.space/ | |
| X-Frame-Options: SAMEORIGIN | |
| Это значит: вставить его в iframe можно ТОЛЬКО со страниц доменов huggingface.co | |
| и *.static.hf.space. Со своего домена/VPS/обычного Space (xxx.hf.space) браузер | |
| кадр запретит - тогда agent.py автоматически делает переход в этом же окне. | |
| Если хочется, чтобы посетитель вообще никогда не видел сторонней ссылки и адреса, | |
| нужно поднять маленькую статическую страницу в Hugging Face (Static Space). | |
| У таких страниц адрес вида https://<user>-<space>.static.hf.space/ - он РАЗРЕШЁН | |
| сайтом агента, поэтому кадр внутри него работает. | |
| КАК ПОДНЯТЬ (2 минуты): | |
| 1. huggingface.co -> New -> Space -> имя, например "agent-run" -> SDK: Static. | |
| 2. В созданном репозитории положите этот файл под именем index.html | |
| (Add file -> Upload files -> выбрать этот файл, переименовав в index.html). | |
| 3. Откройте https://<ваш-логин>-agent-run.static.hf.space/ - увидите кнопку | |
| "Uruchom agenta", а агент откроется ВНУТРИ этой же страницы. | |
| НАСТРОЙКА (блок CONFIG ниже в скрипте): | |
| AGENT_URL - адрес агента; | |
| PING_BASE - адрес вашего Flask-приложения из agent.py (для статистики заходов, | |
| необязательно, можно оставить пустым); | |
| DEFAULT_ENV - ID среды из админки (можно передавать ссылкой как ?env=123456). | |
| Заходы будут считаться, если посетитель открыл ссылку с ?env=ID и заполнен PING_BASE. | |
| ==================================================================================== | |
| --> | |
| <html lang="pl"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"> | |
| <meta name="robots" content="noindex, nofollow"> | |
| <title>Uruchom agenta</title> | |
| <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;800&display=swap" rel="stylesheet"> | |
| <style> | |
| html, body { margin: 0; padding: 0; width: 100%; height: 100%; font-family: 'Montserrat', sans-serif; background: #0a0a0c; color: #fff; overflow: hidden; -webkit-font-smoothing: antialiased; } | |
| #btn-container { display: flex; justify-content: center; align-items: center; height: 100%; width: 100%; flex-direction: column; gap: 18px; padding: 20px; box-sizing: border-box; text-align: center; } | |
| .action-btn { | |
| background: linear-gradient(45deg, #c8ff00, #aaff00); color: #000; border: none; | |
| padding: 20px 40px; font-size: 1.5rem; font-weight: 800; border-radius: 14px; cursor: pointer; | |
| text-transform: uppercase; box-shadow: 0 8px 30px rgba(200, 255, 0, 0.4); | |
| transition: transform 0.2s, box-shadow 0.2s; letter-spacing: 1.5px; text-decoration: none; | |
| font-family: inherit; max-width: 90vw; | |
| } | |
| .action-btn:hover { transform: scale(1.05); box-shadow: 0 12px 40px rgba(200, 255, 0, 0.6); } | |
| .action-btn:active { transform: scale(0.98); } | |
| #agent-view { position: fixed; inset: 0; display: none; background: #0a0a0c; } | |
| #agent-view.active { display: block; } | |
| #agent-topbar { | |
| position: absolute; top: 0; left: 0; right: 0; height: 46px; z-index: 3; | |
| display: flex; align-items: center; gap: 10px; padding: 0 12px; box-sizing: border-box; | |
| background: linear-gradient(180deg, rgba(10,10,12,0.92), rgba(10,10,12,0)); | |
| } | |
| #agent-back { | |
| display: flex; align-items: center; justify-content: center; | |
| height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer; | |
| border: 1px solid rgba(255,255,255,0.16); background: rgba(0,0,0,0.55); color: #fff; | |
| font-family: inherit; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.4px; | |
| backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background 0.2s; | |
| } | |
| #agent-back:hover { background: rgba(0,0,0,0.85); } | |
| #agent-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0a0a0c; display: block; } | |
| #agent-loader { | |
| position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; | |
| align-items: center; justify-content: center; gap: 18px; background: #0a0a0c; | |
| transition: opacity 0.3s; text-align: center; padding: 24px; box-sizing: border-box; | |
| } | |
| #agent-loader.hidden { opacity: 0; pointer-events: none; } | |
| .spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(200, 255, 0, 0.18); border-top-color: #c8ff00; animation: spin 0.9s linear infinite; } | |
| @keyframes spin { to { transform: rotate(360deg); } } | |
| .loader-text { font-size: 0.95rem; color: #9a9a9a; letter-spacing: 0.5px; } | |
| #agent-fallback { | |
| position: absolute; inset: 0; z-index: 5; display: none; flex-direction: column; | |
| align-items: center; justify-content: center; gap: 18px; background: #0a0a0c; | |
| text-align: center; padding: 24px; box-sizing: border-box; | |
| } | |
| #agent-fallback.show { display: flex; } | |
| #agent-fallback p { color: #9a9a9a; font-size: 0.95rem; max-width: 420px; margin: 0; line-height: 1.55; } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="btn-container"> | |
| <button class="action-btn" onclick="startAgent()">Uruchom agenta</button> | |
| </div> | |
| <div id="agent-view"> | |
| <div id="agent-topbar"> | |
| <button id="agent-back" onclick="closeAgent()">← Wstecz</button> | |
| </div> | |
| <iframe id="agent-frame" title="Agent" src="about:blank" referrerpolicy="no-referrer" allowfullscreen | |
| allow="clipboard-read; clipboard-write; microphone; camera; autoplay; fullscreen; encrypted-media; geolocation; display-capture"></iframe> | |
| <div id="agent-loader"> | |
| <div class="spinner"></div> | |
| <div class="loader-text">Uruchamianie agenta…</div> | |
| </div> | |
| <div id="agent-fallback"> | |
| <p>Nie udało się uruchomić agenta w tym oknie. Kliknij poniżej, aby spróbować ponownie.</p> | |
| <button class="action-btn" style="font-size: 1.1rem; padding: 16px 30px;" onclick="startAgent()">Uruchom agenta</button> | |
| <button onclick="closeAgent()" style="background: none; border: none; color: #7a7a7a; font-family: inherit; font-size: 0.9rem; cursor: pointer; text-decoration: underline;">Wróć</button> | |
| </div> | |
| </div> | |
| <script> | |
| (function () { | |
| // ================== CONFIG ================== | |
| var AGENT_URL = 'https://arena.ai/agent'; // адрес агента | |
| var PING_BASE = ''; // например 'https://kgshop-agent.hf.space' (для статистики) | |
| var DEFAULT_ENV = ''; // например '123456' (ID среды из админки) | |
| var SUSPECT_MS = 400; // признак блокировки встраивания | |
| var LOAD_TIMEOUT = 20000; | |
| // ============================================ | |
| var params = {}; | |
| try { | |
| window.location.search.replace(/^\?/, '').split('&').forEach(function (pair) { | |
| if (!pair) { return; } | |
| var kv = pair.split('='); | |
| params[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1] || ''); | |
| }); | |
| } catch (e) {} | |
| var ENV_ID = params.env || DEFAULT_ENV; | |
| var startScreen = document.getElementById('btn-container'); | |
| var view = document.getElementById('agent-view'); | |
| var frameEl = document.getElementById('agent-frame'); | |
| var loader = document.getElementById('agent-loader'); | |
| var fallback = document.getElementById('agent-fallback'); | |
| var startedAt = 0; | |
| var firstLoad = false; | |
| var loadTimer = null; | |
| var openState = false; | |
| var fails = 0; | |
| function ping() { | |
| if (!ENV_ID || !PING_BASE) { return; } | |
| var img = new Image(); | |
| img.src = PING_BASE.replace(/\/+$/, '') + '/ping/' + encodeURIComponent(ENV_ID) + '?t=' + Date.now(); | |
| } | |
| window.startAgent = function () { | |
| ping(); | |
| startScreen.style.display = 'none'; | |
| view.classList.add('active'); | |
| loader.classList.remove('hidden'); | |
| fallback.classList.remove('show'); | |
| startedAt = Date.now(); | |
| firstLoad = true; | |
| openState = true; | |
| try { | |
| if (window.history && window.history.pushState) { | |
| window.history.pushState({ agentOpen: true }, ''); | |
| } | |
| } catch (e) {} | |
| frameEl.setAttribute('src', AGENT_URL); | |
| if (loadTimer) { clearTimeout(loadTimer); } | |
| loadTimer = setTimeout(function () { if (openState) { loader.classList.add('hidden'); } }, LOAD_TIMEOUT); | |
| }; | |
| window.closeAgent = function () { | |
| openState = false; | |
| fallback.classList.remove('show'); | |
| loader.classList.remove('hidden'); | |
| view.classList.remove('active'); | |
| startScreen.style.display = 'flex'; | |
| try { frameEl.setAttribute('src', 'about:blank'); } catch (e) {} | |
| if (loadTimer) { clearTimeout(loadTimer); loadTimer = null; } | |
| }; | |
| frameEl.addEventListener('load', function () { | |
| if (!openState || !firstLoad) { return; } | |
| firstLoad = false; | |
| var elapsed = Date.now() - startedAt; | |
| if (loadTimer) { clearTimeout(loadTimer); loadTimer = null; } | |
| if (elapsed < SUSPECT_MS) { // кадр заблокирован (мгновенная "пустая" загрузка) | |
| fails += 1; | |
| if (fails >= 2) { | |
| // дважды не получилось в кадре - главное, чтобы агент работал | |
| window.location.assign(AGENT_URL); | |
| return; | |
| } | |
| fallback.classList.add('show'); | |
| loader.classList.add('hidden'); | |
| return; | |
| } | |
| loader.classList.add('hidden'); | |
| }); | |
| window.addEventListener('popstate', function () { | |
| if (openState) { closeAgent(); } | |
| }); | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |