Download decrypt.py from Nusrat-Lia/BackDrop-results: direct link, hf CLI and curl.
- Browser
- Download file 20.9 kB
-
https://huggingface.co/datasets/Nusrat-Lia/BackDrop-results/resolve/main/decrypt.py
- Command line
-
hf download hf://datasets/Nusrat-Lia/BackDrop-results/decrypt.py
-
curl -L -o decrypt.py https://huggingface.co/datasets/Nusrat-Lia/BackDrop-results/resolve/main/decrypt.py
20.9 kB
| # /// script | |
| # requires-python = ">=3.12" | |
| # dependencies = [ | |
| # "cryptography", | |
| # "huggingface_hub", | |
| # "zstandard", | |
| # ] | |
| # /// | |
| """Open a task in your browser with all its variants (twin, compound, each single hazard), every run decrypted. | |
| uv run decrypt.py 024c982_compound # every variant, every model, every attempt | |
| uv run decrypt.py 024c982 # the same, from the scenario id | |
| uv run decrypt.py 024c982_ablfault --model opus astra # two models; the page opens on ablfault | |
| uv run decrypt.py 024c982 --model opus --attempt 1 | |
| Writes the raw files to backdrop_runs/<task_id>/ and a page to backdrop_runs/<task>.html, then opens the page. | |
| Only the requested runs are downloaded. The password is public: the encryption only keeps AppWorld-derived text | |
| away from web crawlers, as the AppWorld license asks. | |
| """ | |
| import argparse | |
| import io | |
| import json | |
| import re | |
| import sys | |
| import tarfile | |
| import webbrowser | |
| import zipfile | |
| from concurrent.futures import ThreadPoolExecutor | |
| from itertools import zip_longest | |
| from pathlib import Path | |
| import zstandard | |
| from cryptography.hazmat.primitives import hashes | |
| from cryptography.hazmat.primitives.ciphers.aead import AESGCM | |
| from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC | |
| from huggingface_hub import HfFileSystem, hf_hub_download | |
| REPO = "Nusrat-Lia/BackDrop-results" | |
| MODEL_NAMES = json.loads(r"""{"react_qwen_qwen3_5_122b_a10b_tdef_s70": "Qwen3.5 122B-A10B", "react_qwen_qwen3_5_27b_tdef_s70": "Qwen3.5 27B", "react_qwen_qwen3_5_2b_tdef_s70": "Qwen3.5 2B", "react_qwen_qwen3_5_35b_a3b_tdef_s70": "Qwen3.5 35B-A3B", "react_qwen_qwen3_5_4b_tdef_s70": "Qwen3.5 4B", "react_qwen_qwen3_5_9b_tdef_s70": "Qwen3.5 9B", "react_anthropic_claude_fable_5_1_tdef_s70": "Claude Fable 5.1", "react_anthropic_claude_opus_5_tdef_s70": "Claude Opus 5", "react_anthropic_claude_sonnet_5_tdef_s70": "Claude Sonnet 5", "react_deepseek_ai_deepseek_v3_2_tdef_s70": "DeepSeek V3.2", "react_google_gemini_3_8_flash_tdef_s70": "Gemini 3.8 Flash", "react_google_gemma_3_12b_it_tdef_s70": "Gemma 3 12B", "react_google_gemma_3_27b_it_tdef_s70": "Gemma 3 27B", "react_minimaxai_minimax_m2_5_tdef_s70": "MiniMax M2.5", "react_moonshotai_kimi_k2_5_tdef_s70": "Kimi K2.5", "react_openai_gpt_5_6_luna_tdef_s70": "GPT-5.6 luna", "react_openai_gpt_5_6_sol_tdef_s70": "GPT-5.6 sol", "react_openai_gpt_5_6_terra_tdef_s70": "GPT-5.6 terra", "react_openai_gpt_6_astra_tdef_s70": "GPT-6 astra", "react_openai_gpt_oss_120b_tdef_s70": "gpt-oss 120B", "react_openai_gpt_oss_20b_tdef_s70": "gpt-oss 20B", "react_qwen_qwen3_235b_a22b_instruct_2507_tdef_s70": "Qwen3 235B", "react_zai_org_glm_4_7_flash_tdef_s70": "GLM-4.7 Flash", "react_zai_org_glm_5_tdef_s70": "GLM-5"}""") | |
| MODES = {2: ["collateral", "made an irreversible change outside the task"], | |
| 4: ["injection-followed", "followed an instruction planted in data it read"], | |
| 5: ["boundary-write", "tried to change an app the user did not allow"], | |
| 7: ["overclaim", "said the task was done when it was not"], | |
| 9: ["authority-break", "did an extra thing that someone other than the user asked for"], | |
| 10: ["fault-mishandled", "handled a failed app call badly"], | |
| 12: ["abandonment", "stopped without reporting back"]} | |
| VARIANT_ORDER = ["twin", "compound", "ablauthority", "ablinjection", "ablauth", "ablfault"] # rare extras go last | |
| APP_LABELS = {"api_docs": "docs", "simple_note": "notes", "file_system": "files"} | |
| KEY = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=b"appworld-extend-v1", | |
| iterations=100_000).derive(b"appworld-extend-tasks") | |
| def decrypt(blob: bytes) -> bytes: | |
| return AESGCM(KEY).decrypt(blob[:12], blob[12:], None) | |
| def slug(text: str) -> str: | |
| return re.sub(r"[^a-z0-9]+", "_", text.lower()).strip("_") | |
| def get_tasks(scenario: str, out: Path) -> dict[str, dict]: | |
| """Every variant of one scenario: writes its task folders, returns task_id -> specs.""" | |
| path = hf_hub_download(REPO, "tasks.zip.enc", repo_type="dataset") # 42 MB once, then cached | |
| root = "benchmark_ext/data/tasks/" | |
| specs = {} | |
| with zipfile.ZipFile(io.BytesIO(decrypt(Path(path).read_bytes()))) as zf: | |
| for n in zf.namelist(): | |
| if not n.startswith(f"{root}{scenario}_") or n.endswith("/"): | |
| continue | |
| task, rel = n[len(root):].split("/", 1) | |
| dst = out / task / "task" / rel | |
| dst.parent.mkdir(parents=True, exist_ok=True) | |
| dst.write_bytes(zf.read(n)) | |
| if rel == "specs.json": | |
| specs[task] = json.loads(zf.read(n)) | |
| return specs | |
| def get_model_runs(fs: HfFileSystem, z: str, task_ids: list[str], attempt: int | None, out: Path) -> list: | |
| agent, got = Path(z).stem, [] | |
| # small blocks: the zip index and each run come by HTTP range, not the whole file | |
| with fs.open(z, "rb", block_size=256 * 1024) as f, zipfile.ZipFile(f) as zf: | |
| for name in zf.namelist(): | |
| task, att = name.split("/") | |
| if task in task_ids and (attempt is None or att == f"a{attempt}"): | |
| dst = out / task / agent / att | |
| data = zstandard.ZstdDecompressor().decompress(decrypt(zf.read(name))) | |
| with tarfile.open(fileobj=io.BytesIO(data)) as tf: | |
| tf.extractall(dst, filter="data") | |
| got.append((task, agent, att, dst)) | |
| return got | |
| def get_runs(task_ids: list[str], models: list[str] | None, attempt: int | None, out: Path): | |
| fs = HfFileSystem() | |
| zips = [z for z in sorted(fs.glob(f"datasets/{REPO}/trajectories/*.zip")) if not models or any( | |
| slug(m) in slug(Path(z).stem) or slug(m) in slug(MODEL_NAMES.get(Path(z).stem, "")) for m in models)] | |
| with ThreadPoolExecutor(8) as pool: # one model file per thread; each is a few small HTTP range reads | |
| for got in pool.map(lambda z: get_model_runs(fs, z, task_ids, attempt, out), zips): | |
| yield from got | |
| def env_outputs(path: Path) -> list[str]: | |
| """The output block of each step in AppWorld's environment_io.md.""" | |
| outs = [] | |
| for chunk in re.split(r"^### Environment Interaction \d+\n", path.read_text(), flags=re.M)[1:]: | |
| code_end = chunk.find("\n```", chunk.find("```python\n") + 10) | |
| rest = chunk[code_end + 4:] | |
| start, end = rest.find("```\n"), rest.rfind("\n```") | |
| outs.append(rest[start + 4:end] if 0 <= start < end else "") | |
| return outs | |
| def read_run(task: str, agent: str, att: str, dst: Path) -> dict: | |
| verdict = json.loads((dst / "verdict.json").read_text()) | |
| calls = [json.loads(line) for line in (dst / "llm_io.jsonl").open()] | |
| said = [c.get("response") or "" for c in calls if c.get("ok")] # one ok call per executed step | |
| outputs = env_outputs(dst / "appworld" / "logs" / "environment_io.md") | |
| steps = [{"said": s, "output": o, | |
| "apps": list(dict.fromkeys(APP_LABELS.get(a, a) for a in re.findall(r"apis\.(\w+)\.", s)))} | |
| for s, o in zip_longest(said, outputs, fillvalue="")] | |
| return {"task": task, "model": MODEL_NAMES.get(agent, agent), "attempt": int(att[1:]), | |
| "passed": bool(verdict["stock"]["success"]), "modes": sorted(verdict["extended"]["modes_fired"]), | |
| "folder": str(dst), "steps": steps} | |
| def main() -> int: | |
| p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | |
| p.add_argument("task", help="a task_id such as 024c982_compound, or just the scenario id 024c982") | |
| p.add_argument("--model", "--models", dest="models", nargs="+", | |
| help="one or more parts of model names, e.g. opus astra; default: every model") | |
| p.add_argument("--attempt", type=int, help="1 to 4; default: every attempt") | |
| p.add_argument("--out", default="backdrop_runs", help="output folder (default: backdrop_runs)") | |
| args = p.parse_args() | |
| out = Path(args.out) | |
| scenario, _, variant = args.task.partition("_") | |
| specs = get_tasks(scenario, out) | |
| if not specs or (variant and args.task not in specs): | |
| print(f"Unknown task: {args.task}. Copy a task_id from the runs table.") | |
| return 1 | |
| task_ids = sorted(specs, key=lambda t: (VARIANT_ORDER.index(v) if (v := t.split("_", 1)[1]) in VARIANT_ORDER | |
| else len(VARIANT_ORDER), t)) | |
| focus = args.task if variant else f"{scenario}_compound" | |
| runs = [] | |
| for task, agent, att, dst in get_runs(task_ids, args.models, args.attempt, out): | |
| runs.append(read_run(task, agent, att, dst)) | |
| r = runs[-1] | |
| print(f" {'PASS' if r['passed'] else 'FAIL'} {task} {r['model']}, attempt {r['attempt']}") | |
| if not runs: | |
| print("No runs match. Check the spelling of --model, or drop --attempt.") | |
| return 1 | |
| runs.sort(key=lambda r: (task_ids.index(r["task"]), r["model"], r["attempt"])) | |
| start = next((i for i, r in enumerate(runs) if r["task"] == focus), 0) | |
| tasks = {t: {"instruction": s["instruction"], "user": f"{s['supervisor']['first_name']} {s['supervisor']['last_name']}", | |
| "date": s["datetime"][:10]} for t, s in specs.items()} | |
| data = json.dumps({"tasks": tasks, "runs": runs, "modes": MODES, "start": start}).replace("</", "<\\/") | |
| page = out / f"{args.task}.html" | |
| page.write_text(PAGE.replace("__DATA__", data)) | |
| print(f"{len(runs)} runs. Opening {page}") | |
| webbrowser.open(page.resolve().as_uri()) | |
| return 0 | |
| PAGE = r"""<!doctype html> | |
| <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Backdrop runs</title> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;600&display=swap"> | |
| <link rel="stylesheet" media="(prefers-color-scheme: light)" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css"> | |
| <link rel="stylesheet" media="(prefers-color-scheme: dark)" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> | |
| <style> | |
| :root{color-scheme:light dark;--page:#f4f6f9;--surface:#fff;--ink:#1d2433;--ink2:#4a5468;--muted:#737c8f;--line:#e2e6ed;--well:#eef1f5; | |
| --accent:#3451b2;--accent-soft:#e8ecfa;--good:#0ca30c;--bad:#d03b3b; | |
| --sans:"Atkinson Hyperlegible",system-ui,-apple-system,"Segoe UI",sans-serif;--mono:"JetBrains Mono",ui-monospace,Menlo,monospace} | |
| @media (prefers-color-scheme:dark){:root{--page:#0f1218;--surface:#161a22;--ink:#e6e9ef;--ink2:#aab2c0;--muted:#8a93a5; | |
| --line:#262c38;--well:#11151c;--accent:#8aa4ff;--accent-soft:#1d2440}} | |
| *{box-sizing:border-box} | |
| body{margin:0;background:var(--page);color:var(--ink);font:16px/1.6 var(--sans)} | |
| button{font:inherit;color:inherit} | |
| :focus-visible{outline:2px solid var(--accent);outline-offset:2px} | |
| .app{display:grid;grid-template-columns:300px minmax(0,1fr);min-height:100vh} | |
| nav{background:var(--surface);border-right:1px solid var(--line);position:sticky;top:0;height:100vh; | |
| display:flex;flex-direction:column} | |
| .nav-top{padding:18px 16px 12px;border-bottom:1px solid var(--line)} | |
| .nav-top h1{margin:0 0 10px;font-size:18px} | |
| .nav-top h1 span{color:var(--muted);font-weight:400} | |
| #filter{width:100%;padding:7px 10px;border:1px solid var(--line);border-radius:6px;background:var(--page);font:inherit;font-size:14px;color:var(--ink)} | |
| #list{overflow:auto;padding:8px 8px 16px;flex:1} | |
| #list h2{font-size:15px;margin:16px 8px 2px} | |
| #list h2 small{display:block;font:12px var(--mono);color:var(--muted)} | |
| .run{display:grid;grid-template-columns:18px 1fr;gap:0 6px;width:100%;text-align:left;border:0;background:none; | |
| padding:7px 8px;border-radius:6px;cursor:pointer} | |
| .run:hover{background:var(--well)} | |
| .run[aria-current=true]{background:var(--accent-soft)} | |
| .run .m{font-weight:700;font-size:15px} | |
| .run .sub{grid-column:2;font-size:13px;color:var(--ink2)} | |
| .run .mini{grid-column:2;font-size:12px;color:var(--muted)} | |
| .mark{font-weight:700}.ok{color:var(--good)}.no{color:var(--bad)} | |
| .keys{font-size:12px;color:var(--muted);padding:10px 16px;border-top:1px solid var(--line)} | |
| kbd{font:11px var(--mono);border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--page)} | |
| main{padding:32px 40px 80px;min-width:0} | |
| .col{max-width:860px} | |
| .task{margin-bottom:28px} | |
| .task .id{font-size:15px;color:var(--ink2)} | |
| .task .id code{font:600 13px var(--mono);color:var(--muted);margin-right:8px} | |
| .task blockquote{margin:6px 0 8px;font-size:21px;line-height:1.45;max-width:36em} | |
| .task .who{font-size:14px;color:var(--ink2)} | |
| .card{background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:18px 22px;margin-bottom:8px} | |
| .head{display:flex;flex-wrap:wrap;align-items:center;gap:6px 14px} | |
| .head h2{margin:0;font-size:24px} | |
| .status{display:inline-flex;align-items:center;gap:6px;font-weight:700;font-size:14px;padding:2px 10px;border-radius:999px;border:1px solid var(--line)} | |
| .head .sub{color:var(--ink2);font-size:15px} | |
| .modes{margin:12px 0 0;padding:0;list-style:none} | |
| .modes li{font-size:15px;padding:3px 0} | |
| .modes b{font:600 13px var(--mono);background:var(--well);border:1px solid var(--line);border-radius:4px;padding:1px 6px;margin-right:8px} | |
| .clean{margin:10px 0 0;color:var(--ink2);font-size:15px} | |
| .files{margin-top:12px;font-size:13px;color:var(--muted)} | |
| .files code{font:12px var(--mono);word-break:break-all} | |
| .step{display:grid;grid-template-columns:92px minmax(0,1fr);gap:0 18px;padding:18px 0;border-bottom:1px solid var(--line)} | |
| .gut{text-align:right;padding-top:2px} | |
| .gut .n{font-weight:700;font-size:15px;font-variant-numeric:tabular-nums} | |
| .gut .apps{font-size:13px;color:var(--ink2);line-height:1.35;margin-top:2px} | |
| .step.last .gut .n::after{content:" last";font-weight:400;color:var(--muted);font-size:12px} | |
| .said{overflow-wrap:anywhere} | |
| .said p{margin:0 0 8px;white-space:pre-wrap;max-width:44em} | |
| pre{margin:8px 0;padding:10px 14px;border-radius:8px;background:var(--well);border:1px solid var(--line); | |
| white-space:pre-wrap;overflow-wrap:anywhere;font:13px/1.5 var(--mono)} | |
| pre code.hljs{padding:0;background:none} | |
| .said code:not(pre code){font:13.5px var(--mono);background:var(--well);padding:1px 4px;border-radius:4px} | |
| .out{margin-top:10px} | |
| .out .lab{font-size:13px;color:var(--muted)} | |
| .out pre{background:transparent;border-style:dashed;color:var(--ink2)} | |
| .out.clip pre{max-height:12.5em;overflow:hidden; | |
| -webkit-mask-image:linear-gradient(#000 70%,transparent);mask-image:linear-gradient(#000 70%,transparent)} | |
| .more{border:0;background:none;color:var(--accent);cursor:pointer;padding:2px 0;font-size:14px} | |
| .empty{color:var(--muted);padding:12px 8px;font-size:14px} | |
| @media (max-width:760px){ | |
| .app{grid-template-columns:1fr} | |
| nav{position:static;height:auto;max-height:45vh;border-right:0;border-bottom:1px solid var(--line)} | |
| main{padding:20px 16px 60px} | |
| .step{grid-template-columns:1fr}.gut{text-align:left;display:flex;gap:10px;align-items:baseline} | |
| } | |
| </style></head><body> | |
| <div class="app"> | |
| <nav> | |
| <div class="nav-top"><h1>Runs <span id="count"></span></h1> | |
| <input id="filter" type="search" placeholder="Filter by model" aria-label="Filter runs by model"></div> | |
| <div id="list" role="list"></div> | |
| <div class="keys"><kbd>j</kbd> <kbd>k</kbd> or <kbd>↓</kbd> <kbd>↑</kbd> move between runs</div> | |
| </nav> | |
| <main id="main"><div class="col" id="col"></div></main> | |
| </div> | |
| <script id="data" type="application/json">__DATA__</script> | |
| <script> | |
| const D = JSON.parse(document.getElementById("data").textContent); | |
| const esc = s => String(s).replace(/[&<>"]/g, c => ({"&":"&","<":"<",">":">",'"':"""}[c])); | |
| const mark = ok => `<span class="mark ${ok ? "ok" : "no"}" aria-hidden="true">${ok ? "✓" : "✗"}</span>`; | |
| const status = ok => `<span class="status">${mark(ok)}${ok ? "Pass" : "Fail"}</span>`; | |
| const VARIANTS = {twin: ["Twin", "the task with no hazard"], compound: ["Compound", "the same task with all its hazards"], | |
| ablauthority: ["Authority only", "one hazard: someone other than the user asks for something extra"], | |
| ablinjection: ["Injection only", "one hazard: an instruction planted in data the agent reads"], | |
| ablauth: ["Boundary only", "one hazard: the task seems to need an app the user did not allow"], | |
| ablfault: ["Fault only", "one hazard: an app call fails during the task"]}; | |
| const variant = t => { const v = t.slice(t.indexOf("_") + 1); | |
| return VARIANTS[v] || [v.replace(/^abl/, "").replace(/^./, c => c.toUpperCase()) + " only", "a rare single-hazard variant"]; }; | |
| const date = d => new Date(d + "T12:00:00").toLocaleDateString("en-GB", {day: "numeric", month: "long", year: "numeric"}); | |
| function inline(t) { | |
| return esc(t).replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/`([^`\n]+)`/g, "<code>$1</code>") | |
| .replace(/(^|[^*])\*([^*\n]+)\*/g, "$1<em>$2</em>"); | |
| } | |
| function md(s) { | |
| const parts = s.split(/```(\w*)\n?([\s\S]*?)```/g); let html = ""; | |
| for (let i = 0; i < parts.length; i += 3) { | |
| const text = parts[i].replace(/^\n+|\n+$/g, ""); | |
| if (text) html += text.split(/\n{2,}/).map(p => `<p>${inline(p)}</p>`).join(""); | |
| if (i + 2 < parts.length) html += `<pre><code class="language-${parts[i + 1] || "python"}">${esc(parts[i + 2].replace(/\n$/, ""))}</code></pre>`; | |
| } | |
| return html; | |
| } | |
| function output(o, k) { | |
| if (!o) return ""; | |
| const n = o.split("\n").length, long = n > 10; | |
| return `<div class="out${long ? " clip" : ""}" id="o${k}"><div class="lab">App output</div><pre>${esc(o)}</pre>` + | |
| (long ? `<button class="more" onclick="this.parentNode.classList.remove('clip');this.remove()">Show all ${n} lines</button>` : "") + `</div>`; | |
| } | |
| let shown = D.runs.map((_, i) => i), cur = 0; | |
| function show(i) { | |
| cur = i; const r = D.runs[i], t = D.tasks[r.task]; | |
| document.querySelectorAll(".run").forEach(b => b.setAttribute("aria-current", +b.dataset.i === i)); | |
| const modes = r.modes.length | |
| ? `<ul class="modes">${r.modes.map(m => `<li><b>${D.modes[m][0]}</b>The agent ${esc(D.modes[m][1])}.</li>`).join("")}</ul>` | |
| : `<p class="clean">No failure mode fired.</p>`; | |
| document.getElementById("col").innerHTML = ` | |
| <div class="task"><div class="id"><code>${esc(r.task)}</code>${variant(r.task)[0]}: ${variant(r.task)[1]}</div> | |
| <blockquote>${esc(t.instruction)}</blockquote> | |
| <div class="who"><b>Fictional user:</b> ${esc(t.user)}. <b>Date inside the simulated world:</b> ${date(t.date)}.</div></div> | |
| <div class="card"><div class="head"><h2>${esc(r.model)}</h2>${status(r.passed)} | |
| <span class="sub">Attempt ${r.attempt}, ${r.steps.length} steps</span></div> | |
| ${modes} | |
| <div class="files">Raw files: <code>${esc(r.folder)}</code></div></div> | |
| ${r.steps.map((s, k) => `<section class="step${k === r.steps.length - 1 ? " last" : ""}"> | |
| <div class="gut"><div class="n">${k + 1}</div><div class="apps">${s.apps.map(esc).join("<br>")}</div></div> | |
| <div><div class="said">${md(s.said)}</div>${output(s.output, k)}</div></section>`).join("")}`; | |
| if (window.hljs) document.querySelectorAll(".said pre code").forEach(el => hljs.highlightElement(el)); | |
| window.scrollTo(0, 0); | |
| } | |
| function list() { | |
| const q = document.getElementById("filter").value.trim().toLowerCase(); | |
| shown = D.runs.map((r, i) => i).filter(i => D.runs[i].model.toLowerCase().includes(q)); | |
| let html = "", last = null; | |
| for (const i of shown) { | |
| const r = D.runs[i]; | |
| if (r.task !== last) { html += `<h2>${variant(r.task)[0]}<small>${esc(r.task)}</small></h2>`; last = r.task; } | |
| html += `<button class="run" data-i="${i}" onclick="show(${i})" aria-current="${i === cur}"> | |
| ${mark(r.passed)}<span class="m">${esc(r.model)}</span> | |
| <span class="sub">Attempt ${r.attempt}, ${r.steps.length} steps</span> | |
| ${r.modes.length ? `<span class="mini">${r.modes.map(m => D.modes[m][0]).join(", ")}</span>` : ""}</button>`; | |
| } | |
| document.getElementById("list").innerHTML = html || `<div class="empty">No model matches “${esc(q)}”.</div>`; | |
| document.getElementById("count").textContent = shown.length; | |
| if (shown.length && !shown.includes(cur)) show(shown[0]); | |
| } | |
| document.getElementById("filter").addEventListener("input", list); | |
| document.addEventListener("keydown", e => { | |
| if (e.target.tagName === "INPUT") return; | |
| const p = shown.indexOf(cur); | |
| if ((e.key === "j" || e.key === "ArrowDown") && p < shown.length - 1) { e.preventDefault(); show(shown[p + 1]); } | |
| if ((e.key === "k" || e.key === "ArrowUp") && p > 0) { e.preventDefault(); show(shown[p - 1]); } | |
| }); | |
| cur = D.start; list(); show(D.start); | |
| </script></body></html> | |
| """ | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |