// The MiMo release's own views (app/envs/mimo.py), as the MiMo RL Environment Explorer draws them: the agent's prompt, // the systems a General task works through and their data, its workspace files with previews, the grader in full // (hidden tests, the crash to reproduce, rubric checks and the judge prompt, the screenshot judge's bands, the music // scorer's features), and the reward design across the release. // render(kind, data, ctx) -> HTML wire(root, ctx): the clicks (previews, tables, the prompt's fold and copy) import { $, $$, api, esc, fmt, md, bytes, sk, toast, openModal, progress, emptyState, table, sheetGrid } from "../util.js"; import { icon, DOMAIN_ICON, FILE_ICON } from "../icons.js"; const enc = (s) => s.split("/").map(encodeURIComponent).join("/"); const KIND_LABEL = { spreadsheet: "Excel", document: "Word", pdf: "PDF", slides: "PowerPoint", image: "image", web: "web page", text: "text", archive: "archive" }; const SHAPE_IN = { both: "the systems' databases and the workspace files", db: "the systems' databases", workspace: "the workspace files" }; const SHAPE_ACT = { none: "change nothing: its final answer is what gets graded", mutate_db: "update records in the systems' databases", edit_workspace: "edit files in the workspace", both: "update the databases and edit workspace files" }; const pre = (t) => `
${esc(t)}
`; const pct = (x) => `${Math.round(x * 100)}%`; const disclose = (label, inner) => `
${icon("chevronRight", 14, "chev")}${esc(label)}${inner}
`; const fmtNum = (x) => (x == null ? "" : Math.abs(x) >= 100 ? x.toFixed(0) : Math.abs(x) >= 1 ? x.toFixed(2) : x.toFixed(3)); export function render(kind, data, ctx) { return ({ prompt, systems, workspace, grading, rewards }[kind] || (() => ""))(data, ctx); } // ── the agent's first message ──────────────────────────────────────────────── function prompt(p) { const chars = p.parts.reduce((n, [, t]) => n + t.length, 0); const rows = [p.harness ? ["Harness", `OpenCode ${esc(p.harness.version)}, which adds its own system prompt and tool definitions`] : ["Harness", "None. One chat completion: this message is the whole conversation, with no system prompt and no tools"]]; if (p.harness) rows.push(["Tools", `OpenCode's own${p.systems ? `, plus the tools of the ${p.systems} systems over MCP` : ""}; web search and web fetch are denied`]); if (p.steps) rows.push(["Step limit", `${fmt.format(p.steps)} model calls`]); if (p.timeout_min) rows.push(["Time limit", `${p.timeout_min} minutes`]); if (p.max_tokens) rows.push(["Reply length", `up to ${fmt.format(p.max_tokens)} tokens${p.harness ? " per model call" : ""}`]); const body = p.parts.map(([kind, text]) => kind === "task" && p.task_is_brief ? `` : esc(text)).join(""); return `
${rows.map(([k, x]) => `
${k}
${x}
`).join("")}
The message · ${fmt.format(chars)} characters
${body}

Limits are the training harness's defaults; the run panel can change them.

`; } // ── systems: MCP servers and their databases ───────────────────────────────── function systems(list) { return `

The agent can only reach this data through the tools below. Open a table to see the rows it starts with.

${list.map((s, i) => `
${icon("chevronRight", 14, "chev")}${esc(s.label)}${s.tools.length} tools · ${s.tables.length} tables · ${s.tables.reduce((n, t) => n + t.rows, 0).toLocaleString()} rows
Tools
    ${s.tools.map((t) => `
  • ${esc(t.name)}(${t.params.map((p) => esc(p.name) + (p.default != null ? "?" : "")).join(", ")}) ${t.doc ? `

    ${esc(t.doc)}

    ` : ""}
  • `).join("")}
Data
${s.tables.map((t) => ``).join("")}
`).join("")}
`; } // ── workspace files ────────────────────────────────────────────────────────── function workspace(files) { return `
${files.map((f) => ``).join("")}
`; } // ── the grader ─────────────────────────────────────────────────────────────── function diffHtml(patch) { return patch.split("\n").slice(0, 4000).map((l) => { const cls = l.startsWith("+++") || l.startsWith("---") || l.startsWith("diff ") ? "dh" : l.startsWith("+") ? "da" : l.startsWith("-") ? "dd" : l.startsWith("@@") ? "dc" : ""; return `${esc(l)}`; }).join("\n"); } function grading(g) { let body = `

${esc(g.summary)}

`; if (g.steps) body += `
    ${g.steps.map((s) => `
  1. ${md(s).replace(/^

    |<\/p>$/g, "")}

  2. `).join("")}
`; if (g.formula) body += `

${esc(g.formula)}

`; if (g.kind === "tests") { body += `
Hidden tests
${g.files.map((f) => ``).join("")}
FileLines
${esc(f.path)}+${f.added} −${f.removed}${f.new ? 'new' : ""}
`; if (g.script) body += disclose("Test command script", `
${esc(g.script)}
`); if (g.patch) body += disclose(`Full hidden test patch (${g.patch.length.toLocaleString()} characters)`, `
${diffHtml(g.patch)}
`); } if (g.kind === "crash" && g.expected) { const x = g.expected; body += `
${[["Sanitizer", esc(x.sanitizer)], ["Bug class", esc(x.error_type)], ["Function", `${esc(x.function)}`], ["File", `${esc(x.file)}`]] .map(([k, val]) => `
${k}${val}
`).join("")}
`; } if (g.kind === "rubric") { const shape = [["Facts come from", SHAPE_IN[g.shape?.input]], ["The agent must", SHAPE_ACT[g.shape?.act]]].filter(([, x]) => x); if (shape.length) body += `
${shape.map(([k, x]) => `
${k}
${esc(x)}
`).join("")}
`; if (g.rules) body += ``; // verify.py counts a check with no weight as weight 1 (weights are relative, not percentages) const wt = (c) => (c.weight == null ? 1 : Number(c.weight)); const tot = g.checks.reduce((s, c) => s + wt(c), 0) || 1; const top = Math.max(...g.checks.map(wt)) || 1; body += `
${g.checks.length} checks, weighted
    ${g.checks.map((c) => { const share = Math.round((wt(c) / tot) * 100); return `
  1. ${esc(c.tier || "")} ${c.method === "llm" ? `judged by a model${c.files?.length ? ` · reads ${esc(c.files.join(", "))}` : ""}` : "checked by code"} ${share}%

    ${esc(c.question || c.id)}

  2. `; }).join("")}

The answer each check expects is not shown.

`; const bare = g.checks.filter((c) => c.weight == null); if (bare.length && bare.length < g.checks.length) { const set = g.checks.filter((c) => c.weight != null).reduce((s, c) => s + Number(c.weight), 0); body += `

The weights given add up to ${set.toFixed(2).replace(/\.?0+$/, "")}, and ${bare.length === 1 ? "one check has none" : `${bare.length} checks have none`}. verify.py counts a missing weight as 1, so ${bare.length === 1 ? "that check decides" : "those checks decide"} ${pct(bare.length / tot)} of the reward.

`; } const j = g.judge; if (j) { const how = `

The judge gets one such message per model-judged check. This is the one for ${esc(j.check)}, with the expected answer withheld.

`; if (j.english) body += disclose("The judge prompt, in English", how + pre(j.english)); body += disclose("The judge prompt as sent, in Chinese", (j.english ? "" : how) + pre(j.original)); } if (g.grader) body += `

${esc(g.grader)}

`; } if (g.kind === "terminal") { body += `
Hidden test files
${table([["File", "Size"], ...g.files.map((f) => [f.path, bytes(f.size)])])}`; if (g.script) body += disclose("tests/test.sh", `
${esc(g.script)}
`); if (g.tests) body += disclose("tests/test_outputs.py", `
${esc(g.tests)}
`); } if (g.kind === "visual") { const parts = [["visual", "Visual quality", "mean of five criteria"], ["query_fulfillment", "Brief fulfilment", ""], ["premium_assets", "Asset quality", ""]]; body += `
${parts.map(([key, name, how]) => { const ds = g.dims.filter((d) => d.group === key); return ds.length ? `
${name}⅓ of the score${how ? ` · ${how}` : ""}
${ds.map((d) => `
${esc(d.label)}
${esc(d.desc)}
`).join("")}
` : ""; }).join("")}
`; const j = g.judge; if (j?.rules) body += `
The judge's instructions
`; if (j?.bands) body += disclose("Scoring bands for each criterion, from the judge prompt", `
${g.dims.map((d) => j.bands[d.key] ? `
${esc(d.label)}
    ${j.bands[d.key].map((t, i) => `
  1. ${j.edges[i]}${esc(t)}
  2. `).join("")}
` : "").join("")}
`); if (j?.why) body += `
Why these weights
`; body += `
In training

${esc(j?.training || g.note)}

`; if (j?.original) body += disclose("The judge prompt as sent, in Chinese, with this task's brief", `

Sent with the full-page screenshot. The brief is cut to its first ${fmt.format(j.query_cap)} characters.

${pre(j.original)}`); } if (g.kind === "music") { const groups = {}; g.features.forEach((f) => (groups[f.group] ||= []).push(f)); body += `
${icon("alert")}Validity gate first. No notation errors, fewer than 10 bars of the wrong length, no blank lines in the tune, and one instrument per MIDI channel. A piece that fails any of these scores 0.
${Object.entries(groups).map(([gname, fs]) => `
${esc(gname)}${g.weights?.[gname] != null ? ` · ${pct(g.weights[gname])}` : ""}
${fs.map((f) => `
${esc(f.label || f.name)}${f.rule === "band" ? "within the human range" : f.rule === "high" ? "the higher the better" : "the lower the better"} · ${esc(f.name)} ${f.band ? `${fmtNum(f.band[0])} – ${fmtNum(f.band[1])}` : ""}
`).join("")}
`).join("")}
`; if (g.curves) body += `
How a feature scores
${[["Within the human range", g.curves.band], ["The higher the better", g.curves.high], ["The lower the better", g.curves.low], ["Histogram similarity", g.histograms]].filter(([, x]) => x).map(([k, x]) => `
${k}
${esc(x)}
`).join("")}

Group weights are the share of the 85% that the six groups make up together.

`; } if (g.not_scored) body += `
Not scored
${esc(g.not_scored)}${/^Never/.test(g.not_scored) ? "" : " A rollout that isn't scored has no reward, rather than 0."}
`; body += `

Every kind of task side by side, and how the rubrics are built across the dataset

`; return body; } // ── reward design, across the release ──────────────────────────────────────── const VERL = "https://github.com/XiaomiMiMo/verl/tree/a2ad9f6"; const MIMOAGENT = "https://github.com/XiaomiMiMo/mimoagent/tree/467f0a1"; const KINDS = [ { k: "code", d: "code", name: "Code", reward: "1 if the hidden tests pass, otherwise 0", range: "0 or 1", by: "The task's hidden tests, applied after the agent finishes and run in its own image", judge: "–", ns: "The tests can't be applied, or the files they touch can't be reset", train: "Same" }, { k: "cyber", d: "cyber", name: "Cyber", reward: "1 if the last proof of concept crashes in the expected function, otherwise 0", range: "0 or 1", by: "A root-owned server runs the real fuzz target on it, under the sanitizer", judge: "–", ns: "–", train: "Same" }, { k: "general-workplace", d: "general", name: "General, workplace", reward: "Σ weight × score ÷ Σ weight, over the task's rubric checks", range: "0 to 1", by: "Code checks on the systems' databases and the workspace, and a text judge: one 0-or-1 call per check", judge: "text", ns: "The judge can't be reached, or one of the task's systems stops responding", train: "The same verify.py; it first looks for Xiaomi's internal grader, not released" }, { k: "general-terminal", d: "general", name: "General, terminal", reward: "1 if every test passes, otherwise 0", range: "0 or 1", by: "The task's pytest suite, copied in after the agent finishes", judge: "–", ns: "The tests crash before grading, or write no reward", train: "No reference harness in the release; follows the Terminal-Bench convention" }, { k: "webdev", d: "webdev", name: "Webdev", reward: "mean(visual, brief fulfilment, asset quality); visual is the mean of five criteria", range: "0 to 1", by: "A vision judge scores a full-page render against a five-band scale per criterion", judge: "vision", ns: "The page can't be rendered, or the judge can't be reached", train: "Different: a relative pick among up to 8 sibling rollouts, minus a deduction for missing the brief" }, { k: "music", d: "music", name: "Music", reward: "(0.85 × weighted feature groups + 0.15 × histogram similarity) ÷ 100", range: "0 to 1", by: "abc2midi, then 18 features compared with the range of human music", judge: "–", ns: "Never; a piece that can't be read or measured scores 0", train: "Same" }, ]; function rewards({ kinds, stats }, ctx) { const share = (x, of) => (of ? `${Math.round((x / of) * 100)}%` : "–"); const n = (x) => fmt.format(x || 0); const g = stats.general; const rows = KINDS.map((k) => { const c = kinds[k.k] || { count: 0 }; return `${icon(DOMAIN_ICON[k.d], 13)}${esc(k.name)}${c.example ? `
an example` : ""} ${n(c.count)}${esc(k.reward)}${esc(k.range)}${esc(k.by)}${esc(k.judge)} ${esc(k.ns)}${esc(k.train)}`; }).join(""); const m = g.method || {}, t = g.tier || {}, mix = g.mix || {}, inp = g.input || {}, act = g.act || {}; const judged = m.llm || 0; const facts = [ ["Checks", `${n(g.checks)} across ${n(g.tasks)} tasks, ${g.per_task.min} to ${g.per_task.max} per task (median ${g.per_task.median})`], ["Judged by a model", `${n(judged)} (${share(judged, g.checks)}), each in its own call, answered 0 or 1`], ["Checked by code", `${n(m.rule)} (${share(m.rule, g.checks)}), scored 0 to 1 against the databases and the workspace`], ["Tasks", `${n(mix.judge_only)} graded by the judge alone, ${n(mix.both)} by code and the judge, ${n(mix.code_only)} by code alone`], ["Judge's share of a task's reward", `median ${share(g.judge_share_median, 1)}`], ["Tiers", `critical ${n(t.critical)} (${share(t.critical, g.checks)}), important ${n(t.important)} (${share(t.important, g.checks)}), sanity ${n(t.sanity)} (${share(t.sanity, g.checks)}). A label only: tiers don't enter the formula`], ["Weights", `set in ${n(g.weighted_tasks)} tasks; the rest weight every check equally (a check without a weight counts 1)`], ...(g.mixed_weights ? [["Mixed weights", `${n(g.mixed_weights)} tasks give some checks weights that add up to about 1 and leave others without one, which count 1 each. In ${n(g.mixed_heavy)} of them the unweighted checks decide 40% or more of the reward`]] : []), ["Facts come from", `the systems' databases in ${n(inp.db)} tasks, the workspace files in ${n(inp.workspace)}, both in ${n(inp.both)}`], ["The agent must", `change nothing in ${n(act.none)} tasks (its answer is graded), update databases in ${n(act.mutate_db)}, edit workspace files in ${n(act.edit_workspace)}, both in ${n(act.both)}`], ["What the judge reads", (g.judged_files || []).map(([f, c]) => `${esc(f)} for ${n(c)} checks`).join(", ") + ", as extracted text, up to 20,000 characters per file"], ["Gate and tamper checks", `supported by verify.py, used by ${n(g.uses_gates)} tasks`], ]; return `
By kind of task
${rows}
TaskTasksRewardRangeGraded byJudge Not scored whenIn training
General rubrics, across the dataset counted from every task's verifier_meta.json
${facts.map(([k, x]) => `
${esc(k)}
${x}
`).join("")}
Everywhere
`; } // ── clicks: the prompt, previews, tables ───────────────────────────────────── export function wire(root, ctx) { root.addEventListener("click", async (ev) => { const fold = ev.target.closest("[data-pr-expand]"); if (fold) { fold.nextElementSibling.hidden = false; fold.remove(); return; } const cp = ev.target.closest("[data-pr-copy]"); if (cp) { const text = cp.closest(".bl-custom")?.querySelector("[data-pr-text]")?.dataset.prText || ""; try { await navigator.clipboard.writeText(text); toast("Message copied"); } catch { toast("Couldn't copy"); } return; } const f = ev.target.closest(".bl-custom .file[data-path]"); if (f) return previewFile(ctx, f.dataset.path, f.dataset.kind); const t = ev.target.closest(".bl-custom .tbl-btn"); if (t) return previewTable(ctx, t.dataset.sys, t.dataset.table, t.dataset.label); }); } const dataUrl = (ctx, part, params) => `/api/env/${enc(ctx.spec)}/data?${new URLSearchParams({ ref: ctx.ref, part, ...params })}`; const rawUrl = (ctx, path) => `/api/env/${enc(ctx.spec)}/raw?${new URLSearchParams({ ref: ctx.ref, f: path })}`; const previewSkeleton = (kind) => kind === "spreadsheet" ? `
${sk.box(28, "width:90px;border-radius:7px")}${sk.box(28, "width:70px;border-radius:7px")}
${sk.box(360, "border-radius:10px")}` : `
${sk.line(40, 18)}${sk.lines(100, 96, 90, 98, 70)}
${sk.lines(94, 100, 88, 60)}
`; async function previewFile(ctx, path, kind) { const raw = rawUrl(ctx, path); const body = openModal(path, previewSkeleton(kind), { raw, kind }); if (kind === "image") { body.innerHTML = `
${esc(path)}
`; return; } if (kind === "web") { body.innerHTML = ``; return; } let p; try { p = await progress.wrap(api(dataUrl(ctx, "preview", { path }))); } catch (e) { body.innerHTML = emptyState("alert", "Couldn't open this file", esc(e.message)); return; } if (!body.isConnected || $("#modal").hidden) return; if (p.type === "sheets") { body.innerHTML = `
${p.sheets.map((s, i) => ``).join("")}
`; const show = (i) => { $("#pv-sheet", body).innerHTML = sheetGrid(p.sheets[i].rows) + (p.sheets[i].rows.length >= 60 ? `

Showing the first 60 rows and 24 columns. Open the original for the whole workbook.

` : ""); $$(".pv-tabs button", body).forEach((b) => b.setAttribute("aria-selected", String(b.dataset.i == i))); }; body.querySelector(".pv-tabs").addEventListener("click", (e) => { const b = e.target.closest("button"); if (b) show(+b.dataset.i); }); show(0); } else if (p.type === "document") { body.innerHTML = `
${p.blocks.map((b) => b.table ? table(b.table, { header: true }) : b.h ? `${esc(b.text)}` : `

${esc(b.text)}

`).join("")}
`; } else if (p.type === "slides") { body.innerHTML = `${p.repeated?.length ? `
${icon("info")}On every slide, not repeated below: ${p.repeated.map((t) => `${esc(t)}`).join(" · ")}
` : ""}
${p.slides.map((s) => `
${s.n}
${esc(s.title || "Untitled slide")}${s.text.map((t) => `

${esc(t).replace(/\n/g, "
")}

`).join("")} ${(s.tables || []).map((t) => table(t)).join("")}
`).join("")}
`; } else if (p.type === "pdf") { body.innerHTML = `
`; body.querySelector(".pv-tabs").addEventListener("click", (e) => { const b = e.target.closest("button"); if (!b) return; $$(".pv-tabs button", body).forEach((x) => x.setAttribute("aria-selected", String(x === b))); $("#pv-pdf", body).innerHTML = b.dataset.m === "view" ? `` : `
${p.pages.map((pg) => `
Page ${pg.n}
${esc(pg.text)}
`).join("")}
`; }); } else if (p.type === "text") body.innerHTML = `
${esc(p.text)}
`; else if (p.type === "archive") body.innerHTML = table([["Entry", "Size"], ...p.entries.map((x) => [x.name, bytes(x.size)])]); else if (p.type === "error") body.innerHTML = emptyState("alert", "Couldn't preview this file", esc(p.error), `Download`); else body.innerHTML = emptyState("file", "No preview for this file type", "", `Download`); } async function previewTable(ctx, sys, tbl, label) { const body = openModal(`${label || sys} · ${tbl}`, sk.box(420, "border-radius:10px"), { kind: "table" }); try { const d = await progress.wrap(api(dataUrl(ctx, "table", { system: sys, table: tbl, limit: 100 }))); if ($("#modal").hidden) return; body.innerHTML = table([d.columns, ...d.rows.map((r) => r.map((c) => (c == null ? "" : String(c))))]) + `

${d.rows.length >= 100 ? "First 100 rows" : `${d.rows.length} row${d.rows.length === 1 ? "" : "s"}`} · ${d.columns.length} columns · the state of this database when the agent starts

`; } catch (e) { body.innerHTML = emptyState("alert", "Couldn't load this table", esc(e.message)); } }