Spaces:
Sleeping
Sleeping
Ruthvik4257 commited on
Commit ·
e8e221a
1
Parent(s): cbc702c
Fix quick actions (supervisor take_action any turn), API URL path resolution, sidebar log upload
Browse filesFiles changed (2)
- frontend/index.html+42-21
- server/environment.py+6-1
133 unmodified lines1341351361371381391401413 unmodified lines14514614714814915074 unmodified lines22522622722822923023123223323423523645 unmodified lines28228328428528628728828929029129229329429529629729829930030130230330433 unmodified lines33833934034134234334477 unmodified lines422423424425426427428429430431432133 unmodified lines<header><h1>SOC Analyst · Incident console</h1><nav class="links"><a href="/docs" target="_blank" rel="noopener">API docs</a><a href="/healthz" target="_blank" rel="noopener">healthz</a></nav></header>3 unmodified lines<input id="apiBase" type="text" placeholder="e.g. http://127.0.0.1:8000" autocomplete="off" /><button type="button" class="secondary" id="btnHealth" style="width:100%;">Check /healthz</button><div id="healthOut"></div></aside><main>74 unmodified lines<section id="panel-datasets" class="soc-panel" role="tabpanel" aria-labelledby="soc-t-datasets"><div class="card"><h2>Upload logs</h2><input type="file" id="fileLogs" accept=".log,.txt,.csv,.json,.jsonl" /><div style="margin-top:0.5rem"><button type="button" class="primary" id="btnUpload">Upload</button></div><div id="upMsg"></div></div><div class="card"><h2>Search in uploaded logs</h2>45 unmodified linesa.textContent = (a.textContent + "\n" + line).split("\n").slice(-100).join("\n");};function baseUrl() {return (el("apiBase").value || "").trim().replace(/\/+$/, "");}function apiCall(path) {const b = baseUrl();if (b) return b + path;return path;}async function jsonFetch(path, options) {const url = apiCall(path);const r = await fetch(url, options);const text = await r.text();let data;try { data = text ? JSON.parse(text) : null; } catch { data = { _raw: text }; }if (!r.ok) {const err = new Error(data && data.message || text || "HTTP " + r.status);err.status = r.status; err.data = data; throw err;}return data;33 unmodified lines});function stepWithDecision(decision) {if (!episodeId) return;const body = {episode_id: episodeId,action: {77 unmodified linesconst fd = new FormData();fd.append("file", f);try {const url = apiCall("/api/datasets/logs/upload");const r = await fetch(url, { method: "POST", body: fd });const text = await r.text();const d = text ? JSON.parse(text) : {};m.innerHTML = '<p class="msg ' + (r.ok && d.ok !== false ? "ok" : "error") + '">' + (d.message || text) + "</p>";} catch (e) {m.innerHTML = '<p class="msg error">' + e.message + "</p>";}133 unmodified lines1341351361371381391401413 unmodified lines14514614714814915015115215315415574 unmodified lines23023123223323423523623745 unmodified lines28328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332433 unmodified lines35835936036136236336477 unmodified lines442443444445446447448449450451452453133 unmodified lines<header><h1>SOC Analyst · Incident console</h1><nav class="links"><a id="aDocs" href="docs" target="_blank" rel="noopener">API docs</a><a id="aHealth" href="healthz" target="_blank" rel="noopener">healthz</a></nav></header>3 unmodified lines<input id="apiBase" type="text" placeholder="e.g. http://127.0.0.1:8000" autocomplete="off" /><button type="button" class="secondary" id="btnHealth" style="width:100%;">Check /healthz</button><div id="healthOut"></div><hr style="border-color: var(--border); margin: 1rem 0;" /><label for="fileLogs" style="color: var(--muted);">Log upload (works when hidden in tabs)</label><input type="file" id="fileLogs" accept=".log,.txt,.csv,.json,.jsonl" style="max-width:100%; margin: 0.35rem 0 0.5rem;" /><button type="button" class="primary" id="btnUpload" style="width:100%;">Upload logs</button><div id="upMsg" style="margin-top:0.5rem; font-size:0.8rem;"></div></aside><main>74 unmodified lines<section id="panel-datasets" class="soc-panel" role="tabpanel" aria-labelledby="soc-t-datasets"><div class="card"><h2>Upload</h2><p style="color:var(--muted); font-size:0.88rem; margin:0 0 0.5rem;">Use the <strong>sidebar</strong> to choose a file and upload (avoids hidden-panel browser limits).</p></div><div class="card"><h2>Search in uploaded logs</h2>45 unmodified linesa.textContent = (a.textContent + "\n" + line).split("\n").slice(-100).join("\n");};/** Resolves api/... under the current page path (fixes path-based hosting; avoids fetch('/api/') hitting wrong path). */function apiUrl(path) {const raw = (path || "").replace(/^\/+/, "");const custom = (el("apiBase") && el("apiBase").value || "").trim().replace(/\/+$/, "");if (custom) return custom + "/" + raw;const loc = new URL(window.location.href);let p = loc.pathname;if (!p.endsWith("/")) {const last = p.split("/").pop() || "";if (last && /\.[a-z0-9]+$/i.test(last)) p = p.replace(/\/[^/]*$/, "/");else p += "/";}if (!p.endsWith("/")) p += "/";return loc.origin + p + raw;}function relLink(path) {return apiUrl(path.replace(/^\//, ""));}document.getElementById("aDocs").setAttribute("href", relLink("docs"));document.getElementById("aHealth").setAttribute("href", relLink("healthz"));async function jsonFetch(path, options) {const url = apiUrl(path);const r = await fetch(url, options);const text = await r.text();let data;try { data = text ? JSON.parse(text) : null; } catch { data = { _raw: text }; }if (!r.ok) {let m = (data && data.message) || "";if (!m && data && data.detail !== undefined) {m = typeof data.detail === "string" ? data.detail : JSON.stringify(data.detail);}if (!m) m = text || ("HTTP " + r.status);const err = new Error(m);err.status = r.status; err.data = data; throw err;}return data;33 unmodified lines});function stepWithDecision(decision) {if (!episodeId) return Promise.resolve(null);const body = {episode_id: episodeId,action: {77 unmodified linesconst fd = new FormData();fd.append("file", f);try {const url = apiUrl("api/datasets/logs/upload");const r = await fetch(url, { method: "POST", body: fd, credentials: "same-origin" });const text = await r.text();let d = {};try { d = text ? JSON.parse(text) : {}; } catch { d = { _raw: text }; }m.innerHTML = '<p class="msg ' + (r.ok && d.ok !== false ? "ok" : "error") + '">' + (d.message || text || r.status) + "</p>";} catch (e) {m.innerHTML = '<p class="msg error">' + e.message + "</p>";}
381 unmodified lines382383384385386387388381 unmodified linesdone = Falsemessage = ""if role != self._state.active_agent:self._state.episode_metrics.invalid_actions += 1self._state.episode_metrics.mistakes_made += 1self._state.mistake_made = True381 unmodified lines382383384385386387388389390391392393381 unmodified linesdone = Falsemessage = ""# Analyst UI: supervisor take_action may finalize on any turn (turn order still applies to other actions).supervisor_take = (action.action_type == "take_action"and (action.agent_role or "supervisor") == "supervisor")if not supervisor_take and role != self._state.active_agent:self._state.episode_metrics.invalid_actions += 1self._state.episode_metrics.mistakes_made += 1self._state.mistake_made = True
frontend/index.html+42-21
server/environment.py+6-1