diff --git "a/app6.js" "b/app6.js"
new file mode 100644--- /dev/null
+++ "b/app6.js"
@@ -0,0 +1,1075 @@
+/* A stale cached data6.js without the all-task leaderboard: render an empty pane rather than a blank page */
+window.LB = window.LB || { tasks: 0, public: 0, runs: 0, window: "", models: [] };
+/* Cooperation Bench prototype app. One script, two skins (body[data-skin]). */
+(() => {
+const $ = (s, r = document) => r.querySelector(s), $$ = (s, r = document) => [...r.querySelectorAll(s)];
+const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c]));
+const app = $("#app"), Q = new URLSearchParams(location.search), STILL = Q.has("still") || matchMedia("(prefers-reduced-motion:reduce)").matches;
+const ini = n => (n.includes(" ") ? n.split(" ").map(w => w[0]).slice(0, 2).join("") : n.slice(0, 2)).toUpperCase();
+const IC = {
+ play: ' ',
+ pause: ' ',
+ prev: ' ',
+ next: ' ',
+ arrow: ' ',
+};
+/* generic line icon for each channel (not brand logos) */
+const CH_IC = {
+ gmail: ' ',
+ calendar: ' ',
+ slack: ' ',
+ chat: ' ',
+ linear: ' ',
+ airtable: ' ',
+ drive: ' ',
+ sheets: ' ',
+ judge: ' ',
+};
+const CHIC = ch => CH_IC[ch] ? `${CH_IC[ch]} ` : "";
+/* name chip with a face: portrait for a person, star for the agent, line icon for a tool or the judge */
+const PCH = (task, id, name) => `${id === "agent" ? ' ' : task.people.find(p => p.id === id) ? AV(name) : `${CHIC(id)} `}${esc(name)} `;
+const VZ5 = [["now", "Now"], ["line", "1 Truth line"], ["gap", "2 Knowledge gap"], ["bal", "3 Pressure"], ["wall", "4 Company wall"], ["sent", "5 Sentence"]];
+const VZ6 = [["now", "Now"], ["seq", "1 Sequence"], ["bub", "2 Bubbles"], ["mat", "3 Who to whom"], ["flow", "4 Flow"], ["quote", "5 Graph + quote"]];
+const VZ7 = [["now", "Now"], ["mid", "1 Through tools"], ["ring", "2 Tool belt"], ["lanes", "3 Tool lanes"], ["tally", "4 Tool tally"], ["grid", "5 Who uses what"]];
+/* line icon for a metric row, picked from its name */
+const M_IC = [
+ [/^runs$/i, ' '],
+ [/pass/i, ' '],
+ [/mean|average/i, ' '],
+ [/median/i, ' '],
+ [/above|over|near/i, ' '],
+ [/mail|message|sent/i, ' '],
+ [/misle|warn|leak|fail|early|missing/i, ' '],
+ [/truth|honest|answer/i, ' '],
+ [/record|ticket|work|order/i, ' '],
+ [/judge|agree/i, ' '],
+ [/./, ' '],
+];
+const MIC = name => `${M_IC.find(m => m[0].test(name))[1]} `;
+const TONE = { T: "var(--ok)", F: "var(--bad)", U: "var(--unk)", A: "var(--asm)" };
+const BLAB = { T: "knows", F: "misled", U: "not told", A: "mistaken on their own" }, BGLY = { T: "✓", F: "✕", U: "·", A: "?" };
+const flagC = f => f === "false" ? "var(--bad)" : f === "true" ? "var(--ok)" : "var(--dot, var(--fg-2))";
+const who = (task, id) => id === "agent" ? { name: "Agent", role: "" } : id === "judge" ? { name: "Judge", role: "" } : task.people.find(p => p.id === id) || { name: TOOLS[id] || id, role: "" };
+const short = n => n.split(" ")[0];
+const rich = (t, on) => esc(t).replace(/\{([^|]+)\|([^|]+)\|([^}]+)\}/g, (_, s, ev, why) => on ? `${s} ` : s);
+const taskLabels = id => { const c = CATALOG.find(c => c.id === id); return c ? [c.coop, c.obst, c.dyn, c.dom] : []; };
+
+/* made-up avatar for a simulated person: a flat portrait picked from the name, the same every time */
+const AV = name => { let h = 7; for (const c of name) h = (h * 31 + c.charCodeAt(0)) >>> 0; const pick = (arr, k) => arr[(h >>> k) % arr.length];
+ const bg = pick(["#D9CFC3", "#C9D3DE", "#D3CBDA", "#C8D3CC", "#DCDCDC"], 0), skin = pick(["#F1D3B8", "#E0B48F", "#C68E64", "#8E5E3F", "#F6E0CC"], 3), hair = pick(["#2B2320", "#5A3B26", "#8C6A45", "#B9B4AC", "#1B1B1B"], 6), shirt = pick(["#273252", "#193A29", "#79648C", "#A8927C", "#3D3D3D"], 9);
+ const cut = pick([' ', ' ', ' ', ' ', ' '], 12);
+ return `${cut} `; };
+
+/* ---------- state derivation ---------- */
+function beliefs(task, run, i) {
+ const b = { agent: {} }; task.people.forEach(p => b[p.id] = {});
+ const put = o => { for (const k in o) Object.assign(b[k] ||= {}, o[k]); };
+ put(run.init || {}); for (let s = 0; s <= i; s++) put(run.steps[s].bel || {});
+ return b;
+}
+function truths(task, run, i) {
+ const t = {}; task.facts.forEach(f => t[f.id] = (run.truth0 && run.truth0[f.id]) || f.truth.split(".")[0]);
+ for (let s = 0; s <= i; s++) Object.assign(t, run.steps[s].truth || {});
+ return t;
+}
+
+/* ---------- stage ---------- */
+function layout(task, wide) {
+ if (wide) { /* short, wide box (900 x 262): staff left, agent centre, outside top right, tools bottom right; labels sit beside the faces */
+ const n = { agent: { x: 412, y: 128, t: "agent" } }, pr = task.people.find(p => p.kind === "principal"), ins = task.people.filter(p => p.kind === "in"), outs = task.people.filter(p => p.kind === "out");
+ n[pr.id] = { x: 412, y: 38, t: "p" };
+ ins.forEach((p, k) => n[p.id] = { x: 58, y: ins.length === 1 ? 118 : 50 + (186 - 50) * k / (ins.length - 1), t: "p" });
+ outs.forEach((p, k) => n[p.id] = { x: 690 + (outs.length > 1 ? (k - .5) * 150 - 40 : 0), y: 54, t: "p" });
+ const per = Math.ceil(task.tools.length / 2); task.tools.forEach((t, k, a) => n[t] = a.length <= 3 ? { x: 640 + k * 76, y: 170, t: "tool" } : { x: 640 + (k % per) * 76, y: k < per ? 128 : 188, t: "tool" });
+ return n; }
+ const n = { agent: { x: 450, y: 262, t: "agent" } };
+ const pr = task.people.find(p => p.kind === "principal"); n[pr.id] = { x: 450, y: 92, t: "p" };
+ const spread = (arr, x, y0, y1, t) => arr.forEach((p, k) => n[p.id || p] = { x: typeof x === "function" ? x(k, arr.length) : x, y: arr.length === 1 ? (y0 + y1) / 2 : y0 + (y1 - y0) * k / (arr.length - 1), t });
+ spread(task.people.filter(p => p.kind === "in"), (k, m) => 150 + (m > 2 && k > 0 && k < m - 1 ? -28 : 0), 150, 400, "p");
+ spread(task.people.filter(p => p.kind === "out"), 884, task.people.filter(p => p.kind === "out").length > 1 ? 170 : 262, 360, "p");
+ task.tools.forEach((t, k, a) => n[t] = { x: a.length === 1 ? 500 : 318 + (700 - 318) * k / (a.length - 1), y: 462, t: "tool" });
+ return n;
+}
+function Stage(el, task, run, opt = {}) {
+ const WIDE = !!opt.wide, VB = WIDE ? "0 0 900 236" : "0 0 1000 540", N = layout(task, WIDE), F = task.facts;
+ const trim = (a, b, ra, rb) => { const dx = b.x - a.x, dy = b.y - a.y, d = Math.hypot(dx, dy) || 1; return [a.x + dx / d * ra, a.y + dy / d * ra, b.x - dx / d * rb, b.y - dy / d * rb]; };
+ const rad = id => N[id].t === "agent" ? 40 : N[id].t === "tool" ? 30 : 30;
+ let h = `
+ STAR PROPERTY MANAGEMENT OUTSIDE ${WIDE ? 'TOOLS ' : ""}
+ `;
+ for (const id in N) if (id !== "agent") { const [x1, y1, x2, y2] = trim(N.agent, N[id], 40, rad(id)); h += ` `; }
+ h += ` `;
+ for (const id in N) {
+ const o = N[id], p = who(task, id);
+ if (o.t === "tool") h += ` ${CH_IC[id] ? `${CH_IC[id]} ` : `${esc(TOOLS[id].slice(0, 3).toUpperCase())} `}${esc(TOOLS[id])} `;
+ else if (o.t === "agent") h += `AI agent `;
+ else {
+ const left = o.x < 300, right = o.x > 800, top = id === task.people.find(q => q.kind === "principal").id;
+ const side = top || WIDE, lft = top && WIDE, tx = lft ? -44 : side ? 44 : 0, ty = side ? -6 : 48, anc = lft ? "end" : side ? "start" : "middle"; /* wide layout: the principal's label sits on the left, clear of the lines that run right to the outside people and the tools */
+ h += `${(AV(p.name).match(/]*>(.*)<\/svg>/) || [0, ""])[1]}
+ ${esc(p.name)} ${esc(p.role)}
+ ${F.map((f, k) => `${esc(f.q)} `).join("")}${top && !lft ? `${F.map(f => esc(f.s)).join(" · ")} ` : ""} `;
+ }
+ }
+ if (!opt.mini) h += `${F.map((f, k) => `${esc(f.q)} `).join("")} `;
+ h += ` `;
+ el.innerHTML = h;
+ const svg = $("svg", el), live = $(".live", svg), pulse = $(".pulse", svg), chl = $(".chlab", svg), arr = $(".arr", svg), trails = $(".trails", svg); let raf;
+ if (opt.pick) svg.addEventListener("click", e => { const g = e.target.closest(".node"); if (g) opt.pick(g.dataset.n); });
+ return {
+ set(i, animate) {
+ const s = run.steps[i], b = beliefs(task, run, i), col = flagC(s.flag);
+ $$(".node", svg).forEach(g => g.classList.remove("on", "skip", "chan")); if (N[s.ch] && s.ch !== s.from && s.ch !== s.to) $(`[data-n="${s.ch}"]`, svg).classList.add("chan");
+ $$(".edge", svg).forEach(e => e.classList.remove("on"));
+ const act = [s.from, s.to, s.ch].filter(x => N[x]); act.forEach(x => $(`[data-n="${x}"]`, svg).classList.add("on"));
+ if (s.kind === "skip") $(`[data-n="${s.ch}"]`, svg)?.classList.add("skip");
+ const paint = (g, v) => { g.firstChild.style.fill = TONE[v]; g.children[1].textContent = v === "U" ? "" : BGLY[v]; };
+ $$(".person .pg", svg).forEach(g => paint(g, (b[g.closest(".node").dataset.n] || {})[g.dataset.f] || "U"));
+ $$('[data-n="agentpips"] .pg', svg).forEach(g => paint(g, b.agent[g.dataset.f] || "U"));
+ cancelAnimationFrame(raf);
+ const a = N[s.from], c = N[s.to];
+ if (opt.trail) { /* every pair that has talked so far keeps a line: thicker with more messages, red if one was untrue */
+ const T = {}; run.steps.slice(0, i).forEach(p => { if (!N[p.from] || !N[p.to] || p.from === p.to) return; const k = [p.from, p.to].sort().join("|"), o = T[k] ||= { a: p.from, b: p.to, n: 0, bad: false }; o.n++; if (p.flag === "false") o.bad = true; });
+ trails.innerHTML = Object.values(T).map(o => { const [x1, y1, x2, y2] = trim(N[o.a], N[o.b], rad(o.a), rad(o.b)); return `${o.n} message${o.n > 1 ? "s" : ""} so far `; }).join(""); }
+ if (a && c && a !== c) {
+ const [x1, y1, x2, y2] = trim(a, c, rad(s.from), rad(s.to));
+ live.setAttribute("x1", x1); live.setAttribute("y1", y1); live.setAttribute("x2", x2); live.setAttribute("y2", y2);
+ live.style.stroke = col; live.style.opacity = 1; pulse.style.fill = col; pulse.style.color = col; pulse.setAttribute("opacity", 1);
+ chl.setAttribute("opacity", 1); chl.setAttribute("transform", `translate(${(x1 + x2) / 2},${(y1 + y2) / 2})`); $("text", chl).textContent = (TOOLS[s.ch] || s.ch).toUpperCase();
+ if (opt.trail) { arr.setAttribute("opacity", 1); arr.style.fill = col; arr.setAttribute("transform", `translate(${x2},${y2}) rotate(${Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI})`); }
+ const t0 = performance.now(), go = now => { if (!svg.isConnected) return; const k = opt.trail ? Math.min(1, ((now - t0) % 1900) / 850) : Math.min(1, (now - t0) / 720), e = 1 - Math.pow(1 - k, 3); pulse.setAttribute("cx", x1 + (x2 - x1) * e); pulse.setAttribute("cy", y1 + (y2 - y1) * e); if (k < 1 || opt.trail) raf = requestAnimationFrame(go); };
+ if ((animate || opt.trail) && !STILL) raf = requestAnimationFrame(go); else { pulse.setAttribute("cx", x2); pulse.setAttribute("cy", y2); }
+ } else { live.style.opacity = 0; pulse.setAttribute("opacity", 0); chl.setAttribute("opacity", 0); if (arr) arr.setAttribute("opacity", 0); }
+ svg.classList.toggle("graded", s.from === "judge");
+ if (WIDE) { /* fits as drawn */ } else if (opt.focus && (el.clientHeight < 360 || el.clientWidth < 520)) { const pts = [N.agent, a, c].filter(Boolean), xs = pts.map(p => p.x), ys = pts.map(p => p.y); let x0 = Math.min(...xs) - 150, x1 = Math.max(...xs) + 150, y0 = Math.min(...ys) - 90, y1 = Math.max(...ys) + 130; const w = Math.max(x1 - x0, 560), h = Math.max(y1 - y0, w * .62); svg.setAttribute("viewBox", `${(x0 + x1) / 2 - w / 2} ${(y0 + y1) / 2 - h / 2} ${w} ${h}`); svg.classList.add("focus"); } else if (opt.focus) { svg.setAttribute("viewBox", "0 0 1000 540"); svg.classList.remove("focus"); }
+ }
+ };
+}
+
+/* ---------- run visual: three mock options (HTML stages with the same set(i) call as Stage) ---------- */
+function StageAlt(el, task, run, mode, opt = {}) {
+ const F = task.facts, P = task.people, ids = ["agent", ...P.map(p => p.id)];
+ const isP = id => ids.includes(id);
+ const nm = id => id === "agent" ? "AI agent" : id === "judge" ? "Judge" : (P.find(p => p.id === id) || {}).name || TOOLS[id] || id;
+ const rl = id => id === "agent" ? "Model under test" : id === "judge" ? "Scores the end state" : (P.find(p => p.id === id) || {}).role || "Tool";
+ const sh = id => id === "agent" ? "AI agent" : short(nm(id));
+ const face = id => id === "agent" ? ` ` : P.find(p => p.id === id) ? AV(nm(id)) : `${esc((TOOLS[id] || id).slice(0, 3).toUpperCase())} `;
+ const verb = s => s.kind === "read" ? "reads" : s.kind === "write" ? "writes to" : s.kind === "skip" ? "does not open" : s.from === "judge" ? "grades" : "tells";
+ const flagT = s => s.flag === "false" ? "Not true" : s.flag === "true" ? "True" : "";
+ el.innerHTML = `
`; const root = el.firstChild; let cur = 0;
+ if (opt.pick) root.addEventListener("click", e => { const g = e.target.closest("[data-n]"); if (g && isP(g.dataset.n)) opt.pick(g.dataset.n); });
+ const wire = () => { const sv = $(".sx-wire", root); if (!sv) return; const s = run.steps[cur], a = $(`[data-n="${s.from}"]`, root), b = $(`[data-n="${s.to}"]`, root), ln = $("line", sv), lab = $(".sx-wl", root);
+ if (!a || !b || a === b) { ln.style.opacity = 0; lab.hidden = true; return; }
+ const R = root.getBoundingClientRect(), c = e => { const r = e.getBoundingClientRect(); return [r.left + r.width / 2 - R.left, r.top + r.height / 2 - R.top]; }, [x1, y1] = c(a), [x2, y2] = c(b);
+ ln.setAttribute("x1", x1); ln.setAttribute("y1", y1); ln.setAttribute("x2", x2); ln.setAttribute("y2", y2); ln.style.opacity = 1; ln.style.stroke = flagC(s.flag);
+ lab.hidden = false; lab.style.left = (x1 + x2) / 2 + "px"; lab.style.top = (y1 + y2) / 2 + "px"; lab.textContent = (TOOLS[s.ch] || s.ch).toUpperCase(); };
+ if (mode === "map" && window.ResizeObserver) new ResizeObserver(wire).observe(root);
+ return { set(i) { cur = i;
+ const s = run.steps[i], b = beliefs(task, run, i), b0 = i ? beliefs(task, run, i - 1) : beliefs(task, { init: run.init, steps: [{}] }, 0), col = flagC(s.flag);
+ const val = (id, f) => (b[id] || {})[f.id] || "U", chg = (id, f) => val(id, f) !== ((b0[id] || {})[f.id] || "U");
+ const pips = id => F.map(f => `${BGLY[val(id, f)]} `).join("");
+ const head = `${esc(sh(s.from))} ${verb(s)} ${esc(sh(s.to))} ${esc((TOOLS[s.ch] || s.ch).toUpperCase())} ${flagT(s) ? `${flagT(s)} ` : ""}
`;
+ if (mode === "ex") {
+ const card = (id, side) => `${face(id)}
${esc(nm(id))} ${esc(rl(id))} ${isP(id) ? `
${F.map(f => `${BGLY[val(id, f)]} ${esc(f.s)} · ${BLAB[val(id, f)]} `).join("")}
` : ""}
`;
+ root.innerHTML = `${card(s.from, "from")}
${esc((TOOLS[s.ch] || s.ch).toUpperCase())} ${verb(s)}${flagT(s) ? ` · ${flagT(s)} ` : ""}
${card(s.to, "to")}
+ ${ids.filter(x => x !== s.from && x !== s.to).map(id => `${face(id)}${esc(sh(id))} ${pips(id)} `).join("")}
`;
+ } else if (mode === "board") {
+ const tr = truths(task, run, i);
+ root.innerHTML = head + `True state → ${F.map(f => `${esc(f.q)} ${esc(tr[f.id])} `).join("")}
+ ${ids.map(id => `${face(id)}${esc(nm(id))} ${id === s.from ? 'From ' : id === s.to ? 'To ' : ""} ${F.map(f => `${BGLY[val(id, f)]} ${BLAB[val(id, f)]} `).join("")}`).join("")}
`;
+ } else {
+ const card = id => `${face(id)}${esc(nm(id))} ${esc(rl(id))} ${pips(id)} `;
+ root.innerHTML = `Inside the company ${P.filter(p => p.kind !== "out").map(p => card(p.id)).join("")}
+ ${face("agent")}AI agent Model under test ${pips("agent")}
+
${task.tools.map(t => `${esc(TOOLS[t])} `).join("")}
+ Outside ${P.filter(p => p.kind === "out").map(p => card(p.id)).join("")}${s.from === "judge" ? `
JDG Judge Scores the end state
` : ""}
+ `;
+ wire();
+ }
+ } };
+}
+
+/* ---------- run visual: three graph options in the spirit of the current one (wide, short SVG) ---------- */
+function StageG(el, task, run, mode, opt = {}) {
+ const F = task.facts, P = task.people, W = 1000, H = 236, N = {}, uid = "sg" + (StageG.n = (StageG.n || 0) + 1);
+ const staff = [...P.filter(p => p.kind === "in"), ...P.filter(p => p.kind === "principal")], out = P.filter(p => p.kind === "out");
+ const chans = [...task.tools, "chat"].filter((c, k, a) => a.indexOf(c) === k && TOOLS[c]);
+ const sp = (n, a, b) => k => n === 1 ? (a + b) / 2 : a + (b - a) * k / (n - 1);
+ if (mode === "rail") {
+ const sx = sp(staff.length, 70, Math.min(420, 70 + (staff.length - 1) * 112)); staff.forEach((p, k) => N[p.id] = { x: sx(k), y: 138, r: 22, lab: "b" });
+ N.agent = { x: 590, y: 138, r: 28, lab: "b" }; out.forEach((p, k) => N[p.id] = { x: 930 - (out.length - 1 - k) * 112, y: 138, r: 22, lab: "b" });
+ const cx = sp(chans.length, 130, 870); chans.forEach((c, k) => N[c] = { x: cx(k), y: 30, t: "ch" });
+ } else if (mode === "orbit") {
+ const C = { x: 500, y: 104 }, RX = 392, RY = 70, at = d => ({ x: C.x + RX * Math.cos(d * Math.PI / 180), y: C.y - RY * Math.sin(d * Math.PI / 180) });
+ const la = sp(staff.length, 112, 248), ra = sp(out.length, 28, -28); staff.forEach((p, k) => N[p.id] = { ...at(la(k)), r: 20, lab: "l" }); out.forEach((p, k) => N[p.id] = { ...at(out.length === 1 ? 0 : ra(k)), r: 20, lab: "r" });
+ N.agent = { x: C.x, y: C.y, r: 30, lab: "n" }; const cx = sp(chans.length, 500 - (chans.length - 1) * 37, 500 + (chans.length - 1) * 37); chans.forEach((c, k) => N[c] = { x: cx(k), y: 212, t: "ch" });
+ } else {
+ const sx = sp(staff.length, 66, Math.min(380, 66 + (staff.length - 1) * 104)); staff.forEach((p, k) => N[p.id] = { x: sx(k), y: 158, r: 24, lab: "b" });
+ N.agent = { x: 500, y: 158, r: 28, lab: "b" }; out.forEach((p, k) => N[p.id] = { x: 620 + k * 104, y: 158, r: 24, lab: "b" });
+ const x0 = 620 + out.length * 104 + 6, cx = sp(chans.length, x0, 968); chans.forEach((c, k) => N[c] = { x: cx(k), y: 158, t: "sq" });
+ }
+ const nm = id => id === "agent" ? "AI agent" : short((P.find(p => p.id === id) || {}).name || id);
+ const arc = (cx, cy, R, a0, a1) => { const p = a => [cx + R * Math.cos(a * Math.PI / 180), cy - R * Math.sin(a * Math.PI / 180)], [x0, y0] = p(a0), [x1, y1] = p(a1); return `M${x0.toFixed(1)},${y0.toFixed(1)} A${R},${R} 0 0 ${a1 < a0 ? 1 : 0} ${x1.toFixed(1)},${y1.toFixed(1)}`; };
+ const face = (id, o) => { if (id === "agent") return ` `;
+ const inner = (AV((P.find(p => p.id === id) || {}).name || id).match(/]*>(.*)<\/svg>/) || [0, ""])[1], cid = `${uid}-${id}`;
+ return `${inner} `; };
+ const bel = (id, o) => mode === "arcs" ? F.slice(0, 2).map((f, j) => `${esc(f.s)} `).join("")
+ : (() => { const w = F.length * 17 - 3, bx = o.lab === "l" ? o.x - o.r - 10 - w : o.lab === "r" ? o.x + o.r + 10 : o.lab === "n" ? o.x - w / 2 : o.x - w / 2, by = o.lab === "b" ? o.y + o.r + 24 : o.lab === "n" ? o.y + o.r + 8 : o.y + 6; return F.map((f, j) => `${esc(f.s)} `).join(""); })();
+ const label = (id, o) => o.lab === "n" ? "" : o.lab === "b" ? `${esc(nm(id))} ` : `${esc(nm(id))} `;
+ let h = ``;
+ if (mode === "rail") h += ` `;
+ if (mode === "orbit") h += ` `;
+ if (mode === "arcs") h += ` `;
+ h += ` `;
+ for (const id in N) { const o = N[id];
+ if (o.t === "ch") h += `${esc(TOOLS[id])} `;
+ else if (o.t === "sq") h += ` ${CH_IC[id] ? `${CH_IC[id]} ` : `${esc(TOOLS[id].slice(0, 3).toUpperCase())} `}${esc(TOOLS[id])} `;
+ else h += `${face(id, o)}${label(id, o)}${bel(id, o)} `; }
+ if (mode === "orbit") h += ` `;
+ h += ` `;
+ el.innerHTML = h; const svg = $("svg", el), live = $(".live", svg), pulse = $(".pulse", svg), chl = $(".chl", svg); let raf;
+ if (opt.pick) svg.addEventListener("click", e => { const g = e.target.closest(".pn"); if (g) opt.pick(g.dataset.n); });
+ const edge = (id, toward) => { const o = N[id]; if (!o) return null; if (o.t === "ch") return [o.x, o.y + (toward && toward.y < o.y ? -12 : 12)]; if (o.t === "sq") return [o.x, o.y - 15]; return [o.x, o.y]; };
+ const top = id => { const o = N[id]; return o.t ? [o.x, o.y - 15] : [o.x, o.y - o.r - (mode === "arcs" ? 9 : 2)]; };
+ const pathFor = s => { const a = N[s.from], b = N[s.to]; if (!a || !b || a === b) return "";
+ if (mode === "rail") { const c = N[s.ch], A = [a.x, a.y - a.r - 2], B = b.t ? [b.x, b.y + 12] : [b.x, b.y - b.r - 2];
+ if (b.t) return `M${A[0]},${A[1]} C${A[0]},${A[1] - 40} ${B[0]},${B[1] + 40} ${B[0]},${B[1]}`;
+ if (c && c.t) return `M${A[0]},${A[1]} C${A[0]},${A[1] - 44} ${c.x},${c.y + 52} ${c.x},${c.y + 12} C${c.x},${c.y + 52} ${B[0]},${B[1] - 44} ${B[0]},${B[1]}`;
+ return `M${A[0]},${A[1]} Q${(A[0] + B[0]) / 2},${A[1] - 70} ${B[0]},${B[1]}`; }
+ if (mode === "orbit") { const dx = b.x - a.x, dy = b.y - a.y, d = Math.hypot(dx, dy) || 1, ra = a.t ? 13 : a.r + 3, rb = b.t ? 13 : b.r + 3; return `M${a.x + dx / d * ra},${a.y + dy / d * ra} L${b.x - dx / d * rb},${b.y - dy / d * rb}`; }
+ const A = top(s.from), B = top(s.to), hgt = Math.min(118, 26 + Math.abs(B[0] - A[0]) * .34); return `M${A[0]},${A[1]} Q${(A[0] + B[0]) / 2},${Math.min(A[1], B[1]) - hgt * 1.25} ${B[0]},${B[1]}`; };
+ return { set(i, animate) { const s = run.steps[i], b = beliefs(task, run, i), col = flagC(s.flag);
+ $$(".node", svg).forEach(g => g.classList.toggle("on", [s.from, s.to, s.ch].includes(g.dataset.n)));
+ $$(".pn", svg).forEach(g => { const id = g.dataset.n; $$(".pg", g).forEach(x => { const v = (b[id] || {})[x.dataset.f] || "U"; x.firstChild.style.fill = TONE[v]; x.children[1].textContent = v === "U" ? "" : BGLY[v]; }); $$(".ring", g).forEach(x => { const v = (b[id] || {})[x.dataset.f] || "U"; x.style.stroke = TONE[v]; }); });
+ if (mode === "arcs") $(".hist", svg).innerHTML = run.steps.slice(0, i).map(p => { const d = pathFor(p); return d ? ` ` : ""; }).join("");
+ cancelAnimationFrame(raf); const d = pathFor(s); live.setAttribute("d", d); live.style.stroke = col; live.style.opacity = d ? 1 : 0;
+ if (!d) { pulse.setAttribute("opacity", 0); chl.setAttribute("opacity", 0); return; }
+ const L = live.getTotalLength(), put = k => { const p = live.getPointAtLength(L * k); pulse.setAttribute("cx", p.x); pulse.setAttribute("cy", p.y); }; pulse.style.fill = col; pulse.setAttribute("opacity", 1);
+ if (mode !== "rail" && TOOLS[s.ch] && !(N[s.to] && N[s.to].t)) { const m = live.getPointAtLength(L / 2); chl.setAttribute("opacity", 1); chl.setAttribute("transform", `translate(${m.x},${m.y})`); $("text", chl).textContent = TOOLS[s.ch].toUpperCase(); } else chl.setAttribute("opacity", 0);
+ if (animate && !STILL) { const t0 = performance.now(), go = now => { const k = Math.min(1, (now - t0) / 760), e = 1 - Math.pow(1 - k, 3); put(e); if (k < 1) raf = requestAnimationFrame(go); }; raf = requestAnimationFrame(go); } else put(1);
+ } };
+}
+
+/* ---------- run visual: five options that show the gap between the truth, what the agent knows and what others believe ---------- */
+function StageH(el, task, run, mode) {
+ const F = task.facts, P = task.people, ids = ["agent", ...P.map(p => p.id)], outs = P.filter(p => p.kind === "out"), ins = P.filter(p => p.kind !== "out");
+ const nm = id => id === "agent" ? "AI agent" : (P.find(p => p.id === id) || {}).name || id, sh = id => id === "agent" ? "Agent" : short(nm(id));
+ const face = (id, cls = "") => `${id === "agent" ? ' ' : AV(nm(id))} `;
+ const ORD = ["T", "U", "A", "F"], ZL = { T: "Knows the truth", U: "Not told", A: "Mistaken on their own", F: "Misled" };
+ el.innerHTML = `
`; const root = el.firstChild;
+ return { set(i) {
+ const s = run.steps[i], b = beliefs(task, run, i), b0 = i ? beliefs(task, run, i - 1) : beliefs(task, { init: run.init, steps: [{}] }, 0), tr = truths(task, run, i), done = run.steps.slice(0, i + 1);
+ const val = (id, f) => (b[id] || {})[f.id] || "U", old = (id, f) => (b0[id] || {})[f.id] || "U", chg = (id, f) => val(id, f) !== old(id, f);
+ const chip = (v, txt) => `${BGLY[v]} ${esc(txt)} `;
+ if (mode === "line") {
+ root.innerHTML = `${ORD.map(z => `
${ZL[z]} `).join("")}
+ ${F.map(f => `
${esc(f.s)} True state: ${esc(tr[f.id])}
${ORD.map(z => `
${ids.filter(id => val(id, f) === z).map(id => `${face(id)}${esc(sh(id))} `).join("")}
`).join("")}`).join("")}
`;
+ } else if (mode === "gap") {
+ root.innerHTML = `True state The agent Inside the company Outside
+ ${F.map(f => { const a = val("agent", f), o = outs.map(p => val(p.id, f)), gap = a === "T" && o.some(v => v === "F" || v === "A"), cnt = z => ins.filter(p => val(p.id, f) === z).length;
+ return `
${esc(f.s)} ${esc(f.q)}
${esc(tr[f.id])}
${BGLY[a]} ${BLAB[a]}
+
${ORD.filter(z => cnt(z)).map(z => `${BGLY[z]} ${cnt(z)} ${BLAB[z]} `).join("")}
+
chg(p.id, f)) ? "mv" : ""} ${gap ? "gap" : ""}">${outs.length ? `${face(outs[0].id)}${BGLY[o[0]]} ${BLAB[o[0]]} ` : "— "}${gap ? 'Gap: the agent knows ' : ""}
`; }).join("")}
`;
+ } else if (mode === "bal") {
+ const ev = done.filter(x => (x.to === "agent" && x.flag === "true") || (x.from === "agent" && x.kind === "read")).length, pr = done.filter(x => x.to === "agent" && x.flag === "key").length;
+ const sentT = done.filter(x => x.from === "agent" && x.flag === "true").length, sentF = done.filter(x => x.from === "agent" && x.flag === "false").length;
+ const tilt = Math.max(-9, Math.min(9, (pr * 2 - ev) * 3)), now = s.to === "agent" && s.flag === "key" ? "pr" : (s.to === "agent" && s.flag === "true") || (s.from === "agent" && s.kind === "read") ? "ev" : "";
+ root.innerHTML = `${ev} true facts the agent received or read
${pr} times the principal pushed back
+ ${Array.from({ length: ev }, () => ' ').join("")}
${face("agent", "piv")}
${Array.from({ length: pr }, () => ' ').join("")}
+ What the agent then sent ${chip("T", sentT + " true")}${chip("F", sentF + " untrue")}
`;
+ } else if (mode === "wall") {
+ const cross = done.filter(x => { const a = x.from === "agent" || ins.some(p => p.id === x.from), c = outs.some(p => p.id === x.to); return a && c; }).pop();
+ const col = cross ? flagC(cross.flag) : "var(--line-2)";
+ root.innerHTML = `Inside the company Outside
${F.map(f => `${esc(f.s)} True state: ${esc(tr[f.id])}
+
${["agent", ...ins.map(p => p.id)].map(id => `${face(id)} `).join("")}
+
${cross ? `${esc(TOOLS[cross.ch] || cross.ch)} · ${cross.flag === "false" ? "not true" : cross.flag === "true" ? "true" : "sent"} ` : 'nothing sent yet '}
+
${outs.map(p => `${face(p.id)}${BLAB[val(p.id, f)]} `).join("")}
`).join("")}`;
+ } else {
+ const who2 = outs[0] || P.find(p => p.kind === "principal");
+ root.innerHTML = `${esc(s.head)}
${F.map(f => `${esc(f.s)}. True state: ${esc(tr[f.id])} The agent ${chip(val("agent", f), BLAB[val("agent", f)])} ${esc(short(who2.name))} ${chip(val(who2.id, f), val(who2.id, f) === "T" ? "knows" : val(who2.id, f) === "F" ? "is misled" : val(who2.id, f) === "A" ? "assumes wrong" : "is not told")}
`).join("")}`;
+ }
+ } };
+}
+
+/* ---------- run visual: five interaction-first options ---------- */
+function StageI(el, task, run, mode, opt = {}) {
+ const P = task.people, ins = [...P.filter(p => p.kind === "in"), ...P.filter(p => p.kind === "principal")], outs = P.filter(p => p.kind === "out");
+ const parts = [...ins.map(p => p.id), "agent", ...outs.map(p => p.id), "tools"], lane = id => id === "agent" || P.find(p => p.id === id) ? id : "tools";
+ const nm = id => id === "agent" ? "AI agent" : id === "tools" ? "Tools" : (P.find(p => p.id === id) || {}).name || id, sh = id => id === "agent" ? "Agent" : id === "tools" ? "Tools" : short(nm(id));
+ const txt = x => String(x.text || "").replace(/\{([^|]+)\|[^}]*\}/g, "$1"), cut = (t, n) => t.length > n ? t.slice(0, n - 1).trimEnd() + "…" : t;
+ const hface = id => `${id === "agent" ? ' ' : id === "tools" ? `${CHIC("airtable")} ` : P.find(p => p.id === id) ? AV(nm(id)) : `${CHIC(id)} `} `;
+ const uid = "si" + (StageI.n = (StageI.n || 0) + 1);
+ const sface = (id, x, y, r) => id === "agent" ? ` `
+ : id === "tools" ? `${CH_IC.airtable} `
+ : `${(AV(nm(id)).match(/]*>(.*)<\/svg>/) || [0, ""])[1]} `;
+ const flagW = x => x.flag === "false" ? "Not true" : x.flag === "true" ? "True" : "";
+ let inner = null, raf;
+ if (mode === "quote") { el.innerHTML = ``; inner = Stage($(".si-g", el), task, run, { trail: true, wide: true, pick: opt.pick }); }
+ else el.innerHTML = `
`;
+ const root = el.firstChild;
+ return { set(i, animate) { cancelAnimationFrame(raf);
+ const s = run.steps[i], col = flagC(s.flag), done = run.steps.slice(0, i + 1), pair = x => [lane(x.from === "judge" ? "agent" : x.from), lane(x.to)];
+ if (mode === "quote") { inner.set(i, animate); $(".si-cap", root).innerHTML = `${hface(lane(s.from))}${esc(sh(lane(s.from)))} → ${hface(lane(s.to))}${esc(sh(lane(s.to)))}
${esc(TOOLS[s.ch] || s.ch)}${flagW(s) ? " · " + flagW(s) : ""} ${s.para ? "" : "“"}${esc(cut(txt(s), 150))}${s.para ? "" : "”"}
`; return; }
+ if (mode === "seq") {
+ const W = 880, H = 258, X = id => 80 + (W - 160) * parts.indexOf(id) / (parts.length - 1), rows = done.map((x, k) => ({ x, k })).filter(o => parts.includes(pair(o.x)[0]) && parts.includes(pair(o.x)[1])).slice(-5), y0 = 88, dy = 38;
+ root.innerHTML = `${parts.map(id => ` ${sface(id, X(id), 22, 16)}${esc(sh(id))} `).join("")}
+ ${rows.map((o, r) => { const [a, b] = pair(o.x), y = y0 + r * dy, x1 = X(a), x2 = X(b), c = flagC(o.x.flag), cur = o.k === i, dir = x2 >= x1 ? 1 : -1, self = a === b;
+ return `${String(o.k + 1).padStart(2, "0")} ${self ? ` ` : ` `}
+ ${esc(TOOLS[o.x.ch] || o.x.ch)}${cur ? " · " + esc(cut(o.x.head, 44)) : ""} `; }).join("")} `;
+ } else if (mode === "bub") {
+ const rows = done.map((x, k) => ({ x, k })).slice(-3);
+ root.innerHTML = rows.map((o, r) => { const cur = o.k === i, [a, b] = pair(o.x); return `${String(o.k + 1).padStart(2, "0")} ${hface(a)}
${o.x.para ? "" : "“"}${esc(cut(txt(o.x), cur ? 170 : 80))}${o.x.para ? "" : "”"}
${hface(b)}
${esc(sh(b))} ${esc(TOOLS[o.x.ch] || o.x.ch)}${flagW(o.x) ? " · " + flagW(o.x) : ""} `; }).join("");
+ } else if (mode === "mat") {
+ const C = {}; done.forEach(x => { const [a, b] = pair(x), k = a + ">" + b, o = C[k] ||= { n: 0, bad: false, ok: false }; o.n++; if (x.flag === "false") o.bad = true; if (x.flag === "true") o.ok = true; });
+ const [ca, cb] = pair(s);
+ root.innerHTML = `From ↓ To → ${parts.map(id => `${hface(id)}${esc(sh(id))} `).join("")}
+ ${parts.map(a => `${hface(a)}${esc(sh(a))} ${parts.map(b => { const o = C[a + ">" + b], cur = a === ca && b === cb; return `${o ? o.n : ""} `; }).join("")}`).join("")}
`;
+ } else {
+ const W = 1000, H = 280, Y = id => 26 + (H - 52) * parts.indexOf(id) / (parts.length - 1), XL = 190, XR = 810, C = {};
+ done.forEach(x => { const [a, b] = pair(x), k = a + ">" + b, o = C[k] ||= { a, b, n: 0, bad: false }; o.n++; if (x.flag === "false") o.bad = true; });
+ const [ca, cb] = pair(s), d = (a, b) => `M${XL + 16},${Y(a)} C${XL + 260},${Y(a)} ${XR - 260},${Y(b)} ${XR - 16},${Y(b)}`;
+ root.innerHTML = `SENT BY RECEIVED BY
+ ${Object.values(C).map(o => ` `).join("")}
+ ${esc(TOOLS[s.ch] || s.ch)}${flagW(s) ? " · " + flagW(s) : ""}
+ ${parts.map(id => `${sface(id, XL, Y(id), 14)}${esc(sh(id))} ${sface(id, XR, Y(id), 14)}${esc(sh(id))} `).join("")}
+ `;
+ const lv = $(".lv", root), pl = $(".pl", root), L = lv.getTotalLength(), put = k => { const p = lv.getPointAtLength(L * k); pl.setAttribute("cx", p.x); pl.setAttribute("cy", p.y); };
+ if (STILL) put(1); else { const t0 = performance.now(), go = now => { if (!root.isConnected) return; const k = Math.min(1, ((now - t0) % 1900) / 900); put(1 - Math.pow(1 - k, 3)); raf = requestAnimationFrame(go); }; raf = requestAnimationFrame(go); }
+ }
+ } };
+}
+
+/* ---------- run visual: five options that put the tools between the agent and the people ---------- */
+function StageT(el, task, run, mode, opt = {}) {
+ const P = task.people, ins = [...P.filter(p => p.kind === "in"), ...P.filter(p => p.kind === "principal")], outs = P.filter(p => p.kind === "out");
+ const ppl = [...ins, ...outs].map(p => p.id), parts = [...ins.map(p => p.id), "agent", ...outs.map(p => p.id)], chans = [...task.tools, "chat"].filter((c, k, a) => a.indexOf(c) === k && TOOLS[c]);
+ const isP = id => parts.includes(id), nm = id => id === "agent" ? "AI agent" : (P.find(p => p.id === id) || {}).name || TOOLS[id] || id, sh = id => id === "agent" ? "Agent" : P.find(p => p.id === id) ? short(nm(id)) : nm(id);
+ const cut = (t, n) => t.length > n ? t.slice(0, n - 1).trimEnd() + "…" : t, uid = "st" + (StageT.n = (StageT.n || 0) + 1);
+ const hface = id => `${id === "agent" ? ' ' : P.find(p => p.id === id) ? AV(nm(id)) : `${CHIC(id)} `} `;
+ const sface = (id, x, y, r) => id === "agent" ? ` `
+ : `${(AV(nm(id)).match(/]*>(.*)<\/svg>/) || [0, ""])[1]} `;
+ const tile = (c, x, y, w, on, n, h = 28) => `${CH_IC[c] || ""} ${w > 40 ? `${esc(TOOLS[c])} ` : ""}${n ? `${n} ` : ""} `;
+ const flagW = x => x.flag === "false" ? "Not true" : x.flag === "true" ? "True" : "";
+ const ends = x => ({ a: isP(x.from) ? x.from : null, b: isP(x.to) ? x.to : null, c: chans.includes(x.ch) ? x.ch : chans.includes(x.to) ? x.to : null });
+ el.innerHTML = `
`; const root = el.firstChild; let raf;
+ const run1 = (path, col) => { const pl = $(".pl", root); if (!path || !pl) return; const L = path.getTotalLength(), put = k => { const p = path.getPointAtLength(L * k); pl.setAttribute("cx", p.x); pl.setAttribute("cy", p.y); }; if (STILL) return put(1); const t0 = performance.now(), go = now => { if (!root.isConnected) return; const k = Math.min(1, ((now - t0) % 2000) / 950); put(1 - Math.pow(1 - k, 3)); raf = requestAnimationFrame(go); }; raf = requestAnimationFrame(go); };
+ return { set(i) { cancelAnimationFrame(raf);
+ const s = run.steps[i], col = flagC(s.flag), done = run.steps.slice(0, i + 1), E = ends(s), use = {}; done.forEach(x => { const e = ends(x); if (e.c) use[e.c] = (use[e.c] || 0) + 1; });
+ if (mode === "mid" || mode === "ring") {
+ const W = mode === "mid" ? Math.max(520, root.clientWidth - 12) : 900, H = mode === "mid" ? Math.max(96, root.clientHeight - 4) : 250, N = {}; /* "mid" is drawn at the exact size of its box, so it fills the box edge to edge */
+ if (mode === "mid") { /* drawn near 1:1 so text keeps its size: people left, tools in two staggered columns, agent right */
+ /* one compact group, centred in the box: people, a short run to the tools, a short run to the agent */
+ const pr = Math.max(8, Math.min(14, (H / ppl.length - 4) / 2)), n1 = Math.ceil(chans.length / 2), th = Math.max(18, Math.min(28, (H - 6) / (n1 + .5) - 4)), dy = n1 > 1 ? (H - th - 6 - (chans.length > n1 ? (H - th - 6) / (2 * n1 - 1) : 0)) / (n1 - 1) : 0;
+ const K = .68, tw = 124, g1 = Math.max(38, Math.min(63, (W - 520) / 3 * K)), g2 = 14, ar = Math.max(20, Math.min(32, H / 2 - 24)), NAMEW = 76, G = NAMEW + 2 * pr + g1 + tw + g2 + tw + g1 + 2 * ar, x0 = Math.max(4, (W - G) / 2);
+ const VY = y => H / 2 + (y - H / 2) * K; ppl.forEach((id, k) => N[id] = { x: x0 + NAMEW + pr, y: VY(pr + 3 + (H - 2 * pr - 6) * (ppl.length === 1 ? .5 : k / (ppl.length - 1))), r: Math.min(pr, (H * K / ppl.length - 3) / 2), lab: "l" });
+ const c1 = x0 + NAMEW + 2 * pr + g1 + tw / 2; const th2 = Math.min(th, dy * K - 3); chans.forEach((c, k) => N[c] = k < n1 ? { x: c1, y: VY(th / 2 + 3 + dy * k), t: 1, w: tw, h: th2 } : { x: c1 + tw + g2, y: VY(th / 2 + 3 + dy / 2 + dy * (k - n1)), t: 1, w: tw, h: th2 });
+ N.agent = { x: c1 + tw + g2 + tw / 2 + g1 + ar, y: H / 2 - 10, r: ar, lab: "b" }; }
+ else { N.agent = { x: 450, y: 118, r: 30, lab: "n" }; ins.forEach((p, k) => N[p.id] = { x: 150, y: 30 + (H - 60) * (ins.length === 1 ? .5 : k / (ins.length - 1)), r: 16, lab: "l" }); outs.forEach((p, k) => N[p.id] = { x: 750, y: outs.length === 1 ? 118 : 60 + 120 * k / (outs.length - 1), r: 16, lab: "r" });
+ const want = c => { let vx = 0, vy = 0; run.steps.forEach(x => { const e = ends(x); if (e.c !== c) return; [e.a, e.b].forEach(id => { if (id && id !== "agent") { vx += N[id].x - 450; vy += N[id].y - 118; } }); }); return vx || vy ? Math.atan2(vy, vx) : null; };
+ const w = chans.map(c => ({ c, a: want(c) })), comm = w.filter(o => o.a != null).sort((p, q) => p.a - q.a), rest = w.filter(o => o.a == null);
+ const lft = comm.filter(o => Math.abs(o.a) > Math.PI / 2).sort((p, q) => (p.a < 0 ? p.a + 2 * Math.PI : p.a) - (q.a < 0 ? q.a + 2 * Math.PI : q.a)), rgt = comm.filter(o => Math.abs(o.a) <= Math.PI / 2);
+ lft.forEach((o, k) => N[o.c] = { x: 450 - 150, y: 118 + (k - (lft.length - 1) / 2) * 40, t: 1, w: 34 }); rgt.forEach((o, k) => N[o.c] = { x: 450 + 150, y: 118 + (k - (rgt.length - 1) / 2) * 40, t: 1, w: 34 }); rest.forEach((o, k) => N[o.c] = { x: 450 + (k - (rest.length - 1) / 2) * 46, y: 222, t: 1, w: 34 }); }
+ const pt = (id, toward) => { const o = N[id]; if (o.t) return [o.x + (toward.x < o.x ? -o.w / 2 : toward.x > o.x ? o.w / 2 : 0), mode === "ring" && toward.x === o.x ? o.y - 14 : o.y]; const dx = toward.x - o.x, dy = toward.y - o.y, d = Math.hypot(dx, dy) || 1; return [o.x + dx / d * (o.r + 3), o.y + dy / d * (o.r + 3)]; };
+ const seg = (p, c) => { const [x1, y1] = pt(p, N[c]), [x2, y2] = pt(c, N[p]); return mode === "mid" ? `M${x1},${y1} C${(x1 + x2) / 2},${y1} ${(x1 + x2) / 2},${y2} ${x2},${y2}` : `M${x1},${y1} L${x2},${y2}`; };
+ const rev = d => { const m = d.match(/-?[\d.]+/g).map(Number); return d.includes("C") ? `M${m[6]},${m[7]} C${m[4]},${m[5]} ${m[2]},${m[3]} ${m[0]},${m[1]}` : `M${m[2]},${m[3]} L${m[0]},${m[1]}`; };
+ const H2 = {}; done.slice(0, -1).forEach(x => { const e = ends(x); if (!e.c) return; [e.a, e.b].forEach(id => { if (!id) return; const k = id + "|" + e.c, o = H2[k] ||= { p: id, c: e.c, n: 0, bad: false }; o.n++; if (x.flag === "false") o.bad = true; }); });
+ const PORT = id => { const o = N[id]; return id === "agent" ? [o.x - o.r - 6, o.y] : [o.x + o.r + 6, o.y]; }, TP = (c, side) => [N[c].x + side * N[c].w / 2, N[c].y], cub = (p, q) => `C${(p[0] + q[0]) / 2},${p[1]} ${(p[0] + q[0]) / 2},${q[1]} ${q[0]},${q[1]}`;
+ const segM = (p, c) => { const a = PORT(p), b2 = TP(c, p === "agent" ? 1 : -1); return `M${a[0]},${a[1]} ${cub(a, b2)}`; };
+ const curM = () => { if (!E.c) return []; const sa = E.a === "agent" ? 1 : -1, sb = E.b === "agent" ? 1 : -1; let d; if (E.a) { const a = PORT(E.a), t1 = TP(E.c, sa); d = `M${a[0]},${a[1]} ${cub(a, t1)}`; } else { const t1 = TP(E.c, -sb); d = `M${t1[0]},${t1[1]}`; } if (E.b) { const t2 = TP(E.c, sb), b2 = PORT(E.b), tip = [b2[0] + (E.b === "agent" ? -9 : 9), b2[1]]; d += ` L${t2[0]},${t2[1]} ${cub(t2, tip)}`; } return [d]; };
+ const cur = mode === "mid" ? curM() : E.c ? [E.a ? seg(E.a, E.c) : null, E.b ? rev(seg(E.b, E.c)) : null].filter(Boolean) : [];
+ const ports = mode === "mid" ? [...ppl, "agent"].map(id => { const p = PORT(id), on = id === E.a || id === E.b; return ` `; }).join("") + chans.map(c => [-1, 1].map(sd => { const p = TP(c, sd); return ` `; }).join("")).join("") : "";
+ const ah = mode === "mid" && E.b && E.c ? (() => { const p = PORT(E.b), d = E.b === "agent" ? -1 : 1; return ` `; })() : "";
+ const lab = (id, o) => o.lab === "n" ? "" : o.lab === "b" ? `${esc(nm(id))} ` : `${esc(sh(id))} `;
+ root.innerHTML = `
+ ${Object.values(H2).map(o => ` `).join("")}
+
+ ${Object.keys(N).map(id => { const o = N[id]; return o.t ? tile(id, o.x, o.y, o.w, id === E.c, mode === "mid" ? use[id] : 0, o.h || 28) + (mode === "ring" && id === E.c ? `${esc(TOOLS[id])} ` : "") : `${sface(id, o.x, o.y, o.r)}${id === E.a || id === E.b ? ` ` : ""}${lab(id, o)} `; }).join("")}
+ ${mode === "ring" ? `AI agent ` : ""}${ports}${ah} `;
+ if (cur.length) run1($(".lv", root), col);
+ } else if (mode === "lanes") {
+ root.innerHTML = `${chans.map(c => `${CHIC(c)} ${esc(TOOLS[c])} ${run.steps.map((x, k) => { const e = ends(x); return e.c === c ? ` i ? "fut" : ""}" style="--c:${flagC(x.flag)}" title="Step ${k + 1}: ${esc(x.head)}">${e.a ? hface(e.a) : ""}${e.a && e.b ? ' ' : ""}${e.b ? hface(e.b) : ""} ` : ` `; }).join("")}`).join("")} ${run.steps.map((x, k) => `${k + 1} `).join("")}
`;
+ } else if (mode === "tally") {
+ const U = {}; done.forEach(x => { const e = ends(x); if (e.c) (U[e.c] ||= []).push(x.flag); });
+ root.innerHTML = `${chans.map(c => `
${CHIC(c)} ${esc(TOOLS[c])} ${(U[c] || []).map((f, k, a) => ` `).join("")} ${(U[c] || []).length || ""}
`).join("")}
+
${E.a ? `${hface(E.a)}${esc(sh(E.a))} ` : ""}${E.c ? `${CHIC(E.c)} ${esc(TOOLS[E.c])} ` : ""}${E.b ? `${hface(E.b)}${esc(sh(E.b))} ` : ""}
${esc(cut(s.head, 70))}${flagW(s) ? ` ${flagW(s)} ` : ""}
`;
+ } else {
+ const C = {}; done.forEach(x => { const e = ends(x); if (!e.c) return; [e.a, e.b].forEach(id => { if (!id) return; const o = C[id + "|" + e.c] ||= { n: 0, bad: false }; o.n++; if (x.flag === "false") o.bad = true; }); });
+ root.innerHTML = `Who uses which tool ${chans.map(c => `${CHIC(c)} ${esc(TOOLS[c])} `).join("")}
+ ${parts.map(a => `${hface(a)}${esc(sh(a))} ${chans.map(c => { const o = C[a + "|" + c], cur = c === E.c && (a === E.a || a === E.b); return `${o ? o.n : ""}${cur ? `${a === E.a ? "sends" : "gets"} ` : ""} `; }).join("")}`).join("")}
`;
+ }
+ } };
+}
+
+/* ---------- shared bits ---------- */
+/* task labels as four named facts: icon, the axis in small type, the value in bold; the meaning shows on hover */
+const FCT_IC = { coop: ' ', obst: ' ', dyn: ' ', dom: ' ' };
+const facets = id => { const c = CATALOG.find(c => c.id === id); if (!c) return ""; return AXES.map(a => { const v = c[a.key], d = (a.vals.find(x => x[0] === v) || [])[1] || ""; return `${FCT_IC[a.key] || ""} ${esc(a.name)} ${esc(v)} `; }).join(""); };
+const tags = id => taskLabels(id).map(t => `${esc(t)} `).join("");
+const featTags = id => { const c = CATALOG.find(c => c.id === id); return c ? [c.dyn, c.obst].map(t => `${esc(t)} `).join("") : ""; }; /* home page featured cards: dynamism, then obstacle (Razvan, 12-01) */
+const verdictChip = r => ` ${r.verdict === "pass" ? "Pass" : "Fail"} · ${r.score != null ? r.score.toFixed(2) : "no score"} `;
+const srcChip = r => r.src === "log" ? `Run log${r.partial ? " · partial" : ""} ` : `Reconstructed `;
+function header(active) {
+ return ``;
+}
+try { const p = localStorage.getItem("cb-pal2"); if (p && (window.PALS || []).some(x => x[0] === p)) document.documentElement.dataset.pal = p; } catch { }
+document.addEventListener("click", e => { const b = e.target.closest(".pal [data-pal]"); if (!b) return; document.documentElement.dataset.pal = b.dataset.pal; try { localStorage.setItem("cb-pal2", b.dataset.pal); } catch { } $$(".pal [data-pal]").forEach(x => x.setAttribute("aria-pressed", x === b)); });
+function goSection(id) { const el = document.getElementById("s-" + id); if (el) el.scrollIntoView({ behavior: STILL ? "auto" : "smooth", block: "start" }); }
+document.addEventListener("click", e => {
+ const a = e.target.closest("[data-go]"); if (!a) return;
+ e.preventDefault(); const id = a.dataset.go;
+ if (route().v !== "home") { location.hash = "home"; setTimeout(() => goSection(id), 60); } else goSection(id);
+});
+
+const LOST_IC = {
+ n7: ' ',
+ o1: ' ',
+ n8: ' ',
+ o3: ' ',
+ o2: ' ' };
+/* ---------- landing ---------- */
+function home() {
+ const t05 = TASKS["t05-reinspection"], run = t05.runs.v7b11;
+ const cnt = (k, v) => CATALOG.filter(c => c[k] === v).length;
+ app.innerHTML = header() + `
+
+
+
+ How well do your agents work with people?
+
In collaboration with
+ An illustrative run of a pilot task. It is not one of the 75 benchmark tasks.
Close the film
+
+ 75 tasks
${FACTS.people} simulated people
11 live tools
${FACTS.judge_agree_pct}% judge agreement
+
+ Every task follows three rules.
+
+
+
+
+
+ CM EMPLOYEE
+
+ MAIL
+ CHAT
+ TICKETS
+
+
+ HIS ACCESS. NOTHING MORE.
+ Rule 1 The agent acts for one employee It has that person's access and nothing more.
+
+
+
+
+ SLACK
+ JS
+
+ Repairs done yet?
+
+ haven't started
+ ASK. WAIT. THEN READ THE REPLY.
+ Rule 2 People answer only through real channels The agent sends a message and waits for the reply.
+
+ CORRECT ANSWER
+ HOLD
+ BOOK
+
+ 17:00 17:02 17:05
+
+
+ KEPT "HOLD"
+ CHANGED TO "BOOK"
+ Rule 3 The correct answer changes mid-run An agent that finishes the task as first written fails.
+
+
Tasks in Cooperation Bench stump frontier models. The leaderboard: all ${LB.tasks} tasks (${LB.public} public, ${LB.tasks - LB.public} private) and ${LB.runs.toLocaleString("en-US")} scored runs, from ${LB.models.length} models. The public set: ${PUBSTATS.tasks_total} tasks whose ${PUBSTATS.runs.toLocaleString("en-US")} runs you can open one by one.${LBSTATUS.complete ? "" : ` Preliminary · the leaderboard is still running `}
+ Leaderboard · all ${LB.tasks} tasks Solved in all three runs (pass³) Share of runs passed (pass@1)
Model · harness · effort pass³
pass³ is the share of tasks solved in all three runs. pass@1 is the share of single runs passed, per task, averaged over tasks.
+
+
+
+
+
Start exploring with three tasks. Failed with a penalty Failed due to points lost on rubric rows Passed every rubric row
+ ${featCards()}
+
+
+
+ Run the tasks, then train on them.
+
+
75 tasks
+
25 public50 private, held out
+
Test on the public tasks and trust the private set.
+
+
Public set Free on Hugging Face. Runs on open-source AgentEnv.
+
Private set Never published. Scored by Scale, or licensed for training.
+
Each task Pinned environment, scripted people, replays.
+
Reward The 0 to 1 score, plus the per-row vector as a dense signal.
+
+
+
+ `;
+
+ // rules: the stage follows the scroll
+ clearInterval(window.__h);
+ const DIO = []; if (window.Diorama) $$(".rules3 .r3").forEach((c, k) => { const d = document.createElement("div"); d.className = "dio"; c.insertBefore(d, c.firstChild); const st = window.Diorama.mount(d, k + 1); if (st) { c.classList.add("has-dio"); DIO[k] = st; } else d.remove(); });
+ // rules: on wide screens the section pins and each rule takes over the screen; the scroll plays its diorama
+ (() => { const sec = $("#s-how"), cards = $$(".rules3 .r3", sec); if (STILL || DIO.filter(Boolean).length < 3 || matchMedia("(prefers-reduced-motion:reduce)").matches || innerWidth < 1000) return;
+ const pin = document.createElement("div"); pin.className = "pin"; while (sec.firstChild) pin.appendChild(sec.firstChild); sec.appendChild(pin); sec.classList.add("take");
+ sec.classList.add("all3"); const cl = x => Math.max(0, Math.min(1, x)), last = [-1, -1, -1];
+ const apply = () => { const r = sec.getBoundingClientRect(), total = r.height - innerHeight, p = cl((60 - r.top) / Math.max(1, total)), f = p * 3.3;
+ cards.forEach((c, j) => { const g = cl((f - j) / 1.1); c.style.opacity = .3 + .7 * cl(g * 4); c.style.transform = `translateY(${(1 - cl(g * 3)) * 26}px)`;
+ const t = Math.round((0.04 + g * 0.9) * 400) / 400; if (t !== last[j]) { last[j] = t; DIO[j].scrub(t); } }); };
+ let tick = false; const on = () => { if (tick) return; tick = true; requestAnimationFrame(() => { tick = false; apply(); }); };
+ addEventListener("scroll", on, { passive: true }); addEventListener("resize", on);
+ window.__rkOff = () => { removeEventListener("scroll", on); removeEventListener("resize", on); }; setTimeout(apply, 60); })();
+ // brief fade-up as blocks scroll into view
+ if (!STILL && "IntersectionObserver" in window && !matchMedia("(prefers-reduced-motion:reduce)").matches) {
+ const rv = $$("#s-tasks > .sechead, #s-tasks .card, #s-tasks .dotmap, #s-tasks .ex, #s-start .h2, #s-start .code, #s-start .buy");
+ rv.forEach(el => { el.classList.add("rv"); if (el.classList.contains("card")) el.style.transitionDelay = [...el.parentNode.children].indexOf(el) * 90 + "ms"; });
+ const rio = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) { e.target.classList.add("in"); rio.unobserve(e.target); setTimeout(() => e.target.style.transitionDelay = "", 900); } }), { threshold: 0.12, rootMargin: "0px 0px -6% 0px" });
+ rv.forEach(el => rio.observe(el)); window.__rvOff = () => rio.disconnect();
+ }
+ const film = $("#film"), loop = $("#loop"), box = $("#filmBox"), hero3 = $(".hero3");
+ loop.play().catch(() => { });
+ const closeFilm = () => { film.pause(); box.hidden = true; hero3.classList.remove("playing"); loop.play().catch(() => { }); };
+ $("#filmOpen").onclick = () => { box.hidden = false; hero3.classList.add("playing"); loop.pause(); film.currentTime = 0; film.muted = false; film.play().catch(() => { }); };
+ $("#filmClose").onclick = closeFilm; film.addEventListener("ended", closeFilm);
+ // results
+ // results: staged entrance. 1 model bars grow; 2 that card moves left and "points lost" grows in; 3 the last two cards rise.
+ // stats band: on wide screens it pins, fills the screen, and each number takes over in turn as the page scrolls
+ const factsSeq = () => { const band = $(".facts"); if (!band || STILL || matchMedia("(prefers-reduced-motion:reduce)").matches || innerWidth < 1000) return;
+ const TOOLS11 = ["Slack", "Gmail", "Calendar", "Drive", "Docs", "Sheets", "Contacts", "Linear", "Airtable", "HubSpot", "QuickBooks"];
+ const items = [
+ { n: 75, suf: "", line: "tasks", sub: "25 are public. 50 are held out.", vis: Array.from({ length: 75 }, (_, k) => ` `).join("") },
+ { n: FACTS.people, suf: "", line: "simulated people", sub: "They all work in or with one company.", vis: Array.from({ length: FACTS.people }, (_, k) => ` `).join("") + `${FACTS.staff} staff · ${FACTS.outside} outside contacts ` },
+ { n: 11, suf: "", line: "live tools", sub: "The agent works with them in each task.", vis: TOOLS11.map(t => `${t} `).join("") },
+ { n: FACTS.judge_agree_pct, suf: "%", line: "judge agreement", sub: "The judge's three samples gave the same verdict.", vis: `${FACTS.judge_agree[0].toLocaleString("en-US")} of ${FACTS.judge_agree[1].toLocaleString("en-US")} rubric verdicts in the public runs ` }];
+ const sec = document.createElement("section"); sec.className = "fx"; band.parentNode.insertBefore(sec, band);
+ sec.innerHTML = `${items.map(it => `
${it.vis}
0 ${it.suf ? `${it.suf} ` : ""}${it.line}
${it.sub}
`).join("")}
`;
+ band.remove();
+ const cl = x => Math.max(0, Math.min(1, x)), els = $$(".fxitem", sec), idx = $$(".fxidx button", sec);
+ const apply = () => { const r = sec.getBoundingClientRect(), total = r.height - innerHeight, p = cl((60 - r.top) / Math.max(1, total)), f = p * 4.4;
+ els.forEach((el, j) => { const g = cl((f - j) / 1.1), e = g * g * (3 - 2 * g); el.style.opacity = .28 + .72 * cl(g * 4); el.style.transform = `translateY(${(1 - cl(g * 3)) * 26}px)`;
+ $(".fxnum span", el).textContent = Math.round(items[j].n * e);
+ const parts = $$(".fxvis > i", el); parts.forEach((d, m) => d.style.opacity = (m / parts.length) < e ? 1 : .14); const bar = $(".bar i", el); if (bar) bar.style.width = FACTS.judge_agree_pct * e + "%"; }); };
+ let tick = false; const on = () => { if (tick) return; tick = true; requestAnimationFrame(() => { tick = false; apply(); }); };
+ addEventListener("scroll", on, { passive: true }); addEventListener("resize", on);
+ idx.forEach(b => b.onclick = () => { const r = sec.getBoundingClientRect(), total = r.height - innerHeight; scrollTo({ top: scrollY + r.top - 60 + total * ((+b.dataset.k + .45) / 4), behavior: "smooth" }); });
+ window.__fxOff = () => { removeEventListener("scroll", on); removeEventListener("resize", on); }; apply(); };
+ const resSeq = () => { const sec = $("#s-results"), res = $(".res", sec), p1 = res.children[0], p2 = res.children[1], last = $$(".proof .pane", sec);
+ if (STILL || matchMedia("(prefers-reduced-motion:reduce)").matches) return;
+ if (innerWidth < 1100 || sec.scrollHeight > innerHeight - 40) { /* too tall to pin (23 models, 25 tasks) or narrow: animate each chart as it scrolls into view (Isaac, Nov 30) */
+ const panes = $$(".pane", sec).filter(p => p.querySelector(".track"));
+ panes.forEach(p => { $$(".track > i", p).forEach(b => { b.dataset.w = parseFloat(b.style.width) || 0; b.style.transition = "none"; b.style.width = "0%"; }); $$(".mrow", p).forEach(r => { r.style.opacity = 0; r.style.transform = "translateY(6px)"; }); $$(".track em", p).forEach(b => b.style.opacity = 0); });
+ const io = new IntersectionObserver(es => es.forEach(e => { if (!e.isIntersecting) return; io.unobserve(e.target);
+ $$(".mrow", e.target).forEach((r, k) => { const d = Math.min(k * 40, 1000); r.style.transition = "opacity .45s ease " + d + "ms, transform .45s ease " + d + "ms"; r.style.opacity = 1; r.style.transform = "none";
+ $$(".track > i", r).forEach(b => { b.style.transition = "width .9s cubic-bezier(.2,.7,.2,1) " + (d + 120) + "ms"; requestAnimationFrame(() => requestAnimationFrame(() => { b.style.width = b.dataset.w + "%"; })); });
+ $$(".track em", r).forEach(b => { b.style.transition = "opacity .4s ease " + (d + 700) + "ms"; b.style.opacity = 1; }); });
+ $$(".track > i", e.target).forEach(b => { if (!b.closest(".mrow")) { b.style.transition = "width .9s ease"; b.style.width = b.dataset.w + "%"; } }); }), { threshold: .12 });
+ panes.forEach(p => io.observe(p)); return; }
+ const pin = document.createElement("div"); pin.className = "pin"; while (sec.firstChild) pin.appendChild(sec.firstChild); sec.appendChild(pin); sec.classList.add("scrub");
+ const cl = x => Math.max(0, Math.min(1, x)), ez = x => x * x * (3 - 2 * x), part = (p, a, b) => ez(cl((p - a) / (b - a)));
+ const grow = (pane, g) => { $$(".track > i", pane).forEach(el => { if (el.dataset.w == null) el.dataset.w = parseFloat(el.style.width) || 0; el.style.width = el.dataset.w * g + "%"; });
+ $$(".track b, .track u, .track em", pane).forEach(el => el.style.opacity = cl(g * 3 - 2)); $$(".mrow", pane).forEach((r, k) => { const q = cl(g * 4 - k * Math.min(.5, 3 / Math.max(1, r.parentNode.querySelectorAll(".mrow").length - 1))); r.style.opacity = q; r.style.transform = `translateX(${(1 - q) * -14}px)`; });
+ $$(".mrow .v", pane).forEach(v => { const n = v.firstChild; if (!n || n.nodeType !== 3) return; if (v.dataset.to == null) v.dataset.to = n.nodeValue; const to = v.dataset.to; if (/^\d\.\d\d$/.test(to)) n.nodeValue = (parseFloat(to) * g).toFixed(2); else if (/^\d+%$/.test(to)) n.nodeValue = Math.round(parseFloat(to) * g) + "%"; else if (/^\d+\.\d%$/.test(to)) n.nodeValue = (parseFloat(to) * g).toFixed(1) + "%"; }); };
+ const apply = () => { const r = sec.getBoundingClientRect(), total = r.height - innerHeight, p = cl((60 - r.top) / Math.max(1, total));
+ grow(p1, part(p, .02, .3)); const k = part(p, .34, .52); res.style.gridTemplateColumns = `minmax(0,1fr) minmax(0,${k}fr)`; res.style.columnGap = 16 * k + "px";
+ p2.style.opacity = k; p2.style.paddingInline = 18 * k + "px"; p2.style.borderWidth = k > .02 ? "1px" : "0"; grow(p2, part(p, .5, .76));
+ last.forEach((el, j) => { const q = part(p, .78 + j * .08, .92 + j * .08); el.style.opacity = q; el.style.transform = `translateY(${(1 - q) * 28}px)`; });
+ const pr = $(".proof", sec), sh = pr ? (pr.offsetHeight + 16) / 2 * (1 - part(p, .72, .88)) : 0; [$(".sechead", sec), $(".scn", sec), res].forEach(el => el && (el.style.transform = `translateY(${sh}px)`)); };
+ let tick = false; const on = () => { if (tick) return; tick = true; requestAnimationFrame(() => { tick = false; apply(); }); };
+ addEventListener("scroll", on, { passive: true }); addEventListener("resize", on); window.__rs = apply; window.__rsOff = () => { removeEventListener("scroll", on); removeEventListener("resize", on); window.__rs = null; };
+ apply(); };
+ const bars = () => { $("#resBars").innerHTML = LB.models.map((x, k) => { const p3 = (x.pass3 * 100).toFixed(1), p1 = (x.pass1 * 100).toFixed(1), nm = esc(MODELS[x.m].name); return `${k + 1} ${nm} ${esc(x.h)} · ${esc(x.e)} ${p3}% ${p1}% `; }).join(""); };
+ bars(); factsSeq(); resSeq(); window.CBPARETO ? window.CBPARETO() : addEventListener("DOMContentLoaded", () => window.CBPARETO && window.CBPARETO(), { once: true });
+ // code
+ const R = window.RECORD_EXAMPLE || {}, RS = window.REPLAY_STEP || {}, S_ = v => `${esc(JSON.stringify(v))} `, K_ = v => `${v} `, C_ = v => `${esc(v)} `;
+ const RUNX = window.RUN_EXAMPLE || {};
+ const CODE = [
+`${C_("# 1 Install agent-env and point it at your LiteLLM proxy")}
+uv tool install --python 3.12 'agentenv-framework==${esc(RUNX.agent_env || "")}'
+export LITELLM_BASE_URL=https://<your-litellm-proxy> ${C_("# the proxy's root URL, with no /v1")}
+export LITELLM_API_KEY=<your-key>
+
+${C_("# 2 Run the 25 public tasks in the pinned company, four at a time. Each run ends with its score:")}
+${C_("# the judge grades the end state three times and keeps the median.")}
+agent-env run hf://ScaleAI/cooperation-bench
+
+${C_("# One task, as a leaderboard run ran it")}
+${esc(RUNX.cmd || "")}
+${RUNX.out ? C_("# It prints:\n" + RUNX.out.split("\n").map(l => "# " + l).join("\n")) : ""}
+
+${C_("# Or from a local copy (hf comes with: uv tool install huggingface_hub)")}
+hf download ScaleAI/cooperation-bench --repo-type dataset --local-dir cooperation-bench
+cd cooperation-bench && agent-env run .
+
+${C_("# Reward for training: the 0-1 score, or the per-row vector.")}
+${C_("# score = (credit - penalties) / 100, floored at 0. Pass = 1.00.")}`];
+ const setCode = i => { $("#codePre").innerHTML = CODE[i]; $$(".code [role=tab]").forEach(b => b.setAttribute("aria-selected", +b.dataset.c === i)); };
+ setCode(0); $(".code .tabs").addEventListener("click", e => { const b = e.target.closest("[data-c]"); if (b) setCode(+b.dataset.c); });
+ $("#copy").addEventListener("click", async e => { try { await navigator.clipboard.writeText($("#codePre").textContent); e.target.textContent = "Copied"; } catch { getSelection().selectAllChildren($("#codePre")); } setTimeout(() => e.target.textContent = "Copy", 1400); });
+}
+
+/* ---------- task page ---------- */
+const P1 = (id, m) => { const t = ((window.PUBSTATS || {}).tasks || []).find(x => x.k === id), v = t && t.by_model && t.by_model[m]; return v && v.n ? v : null; };
+const EXST = { q: "", f: {}, sort: "id", dir: 1, all: true, ax: "dyn" };
+function initExplorer() {
+ const st = EXST;
+ const draw = () => {
+ let rows = CATALOG.filter(c => Object.entries(st.f).every(([k, v]) => c[k] === v) && (!st.q || (c.id + c.line + c.persona).toLowerCase().includes(st.q)));
+ rows.sort((a, b) => { const fa = !!TASKS[a.id], fb = !!TASKS[b.id]; if (st.sort === "id" && fa !== fb) return fa ? -1 : 1; if (/^p_/.test(st.sort)) { const m = st.sort.slice(2), va = P1(a.id, m), vb = P1(b.id, m), ra = va ? va.pass / va.n : -1, rb = vb ? vb.pass / vb.n : -1; if (ra < 0 !== rb < 0) return ra < 0 ? 1 : -1; return (ra - rb) * st.dir || (vb ? vb.n : 0) - (va ? va.n : 0); } return String(a[st.sort]).localeCompare(String(b[st.sort])) * st.dir; });
+ const N0 = rows.length; if (!st.all && !st.q && !Object.keys(st.f).length) rows = rows.slice(0, 10);
+ $("#exbody").innerHTML = rows.map(c => { const f = !!TASKS[c.id]; return `${esc(c.id)} ${f ? 'Replay ' : ""}${esc(c.line)}
${["fable", "astra", "carbon", "opus", "muse"].map(m => { const x = P1(c.id, m); return `${x ? `${Math.round(x.pass / x.n * 100)}%${x.pass}/${x.n} ` : `– `} `; }).join("")}${esc(c.dom)} `; }).join("") || `No task matches. Clear a filter. `;
+ $("#exCount").textContent = `${N0} of ${CATALOG.length} tasks`;
+ $("#exclr").hidden = !Object.keys(st.f).length && !st.q; $(".ex").classList.remove("closed"); $("#exmore").hidden = rows.length === N0; $("#exmore").textContent = $(".ex").classList.contains("closed") ? `Show the list of ${N0} tasks` : `Show all ${N0} tasks`;
+ $$(".tag").forEach(b => b.setAttribute("aria-pressed", st.f[b.dataset.k] === b.dataset.v)); if (typeof mark === "function" && $("#dm").children.length) mark();
+ $$("[data-sort]").forEach(b => b.dataset.dir = b.dataset.sort === st.sort ? st.dir : "");
+ };
+ let ax = EXST.ax; const dm = $("#dm"), dtip = $("#dmTip");
+ const drawDots = () => { const old = {}; $$(".td", dm).forEach(d => old[d.dataset.id] = d.getBoundingClientRect()); const A = AXES.find(x => x.key === ax);
+ dm.innerHTML = A.vals.map(v => { const rows = CATALOG.filter(c => c[ax] === v[0]); return `${esc(v[0])} ${rows.length} ${v[1] ? `
${esc(v[1])}
` : ""}
${rows.map(c => ` `).join("")}
`; }).join("");
+ $$(".td", dm).forEach(d => { const o = old[d.dataset.id]; if (!o || STILL) return; const n = d.getBoundingClientRect(); d.animate([{ transform: `translate(${o.left - n.left}px,${o.top - n.top}px)` }, { transform: "none" }], { duration: 520, easing: "cubic-bezier(.16,1,.3,1)" }); }); mark(); };
+ const mark = () => { const ok = new Set(CATALOG.filter(c => Object.entries(st.f).every(([k, v]) => c[k] === v) && (!st.q || (c.id + c.line + c.persona).toLowerCase().includes(st.q))).map(c => c.id)); $$(".td", dm).forEach(d => d.classList.toggle("off", !ok.has(d.dataset.id))); };
+ $("#dmSeg").addEventListener("click", e => { const b = e.target.closest("[data-ax]"); if (!b) return; ax = EXST.ax = b.dataset.ax; $$("#dmSeg button").forEach(x => x.setAttribute("aria-pressed", x === b)); drawDots(); });
+ dm.addEventListener("click", e => { const d = e.target.closest(".td"); if (d) { if (TASKS[d.dataset.id]) { location.hash = "task-" + d.dataset.id; return; } st.q = d.dataset.id; $("#exq").value = d.dataset.id; st.all = true; draw(); $("#exq").scrollIntoView({ behavior: STILL ? "auto" : "smooth", block: "center" }); return; } const b = e.target.closest(".tag"); if (!b) return; st.f[b.dataset.k] === b.dataset.v ? delete st.f[b.dataset.k] : st.f[b.dataset.k] = b.dataset.v; draw(); });
+ dm.addEventListener("mouseover", e => { const d = e.target.closest(".td"); if (!d) { dtip.hidden = true; return; } const c = CATALOG.find(x => x.id === d.dataset.id), w = dm.parentNode.getBoundingClientRect(), r = d.getBoundingClientRect(); dtip.hidden = false; dtip.innerHTML = `${esc(c.id)}${FEATURED.includes(c.id) ? " · replay" : ""} ${esc(c.line)}`; dtip.style.left = Math.max(0, Math.min(w.width - 280, r.left - w.left - 130)) + "px"; dtip.style.top = (r.top - w.top - 10) + "px"; });
+ dm.addEventListener("mouseleave", () => dtip.hidden = true);
+ $("#exq").addEventListener("input", e => { st.q = e.target.value.trim().toLowerCase(); draw(); });
+ $("#exclr").addEventListener("click", () => { st.f = {}; st.q = ""; $("#exq").value = ""; draw(); });
+ $(".extab thead").addEventListener("click", e => { const b = e.target.closest("[data-sort]"); if (!b) return; st.dir = st.sort === b.dataset.sort ? -st.dir : 1; st.sort = b.dataset.sort; draw(); });
+ $("#exbody").addEventListener("click", e => { const r = e.target.closest("[data-href]"); if (r) location.hash = r.dataset.href; });
+ $("#exbody").addEventListener("keydown", e => { if (e.key === "Enter") { const r = e.target.closest("[data-href]"); if (r) location.hash = r.dataset.href; } });
+ $("#exmore").addEventListener("click", () => { st.all = true; draw(); });
+ draw(); drawDots();
+ $("#exq").value = st.q; $$("#dmSeg button").forEach(x => x.setAttribute("aria-pressed", x.dataset.ax === ax));
+}
+function featCards() { const N = FEATURED.map(id => { const S = TASKS[id].stats; return S.cats.reduce((n, c) => n + Object.values(S.grid).reduce((a, g) => a + (g[c.k] || 0), 0), 0); }), wide = N.length > 2 && N[0] >= 2 * Math.max(...N.slice(1)); return ``; }
+function shortId(id) { const p = String(id).split("-"), k = p.findIndex(x => /\d/.test(x)); return p.slice(0, k < 0 ? 1 : k + 1).join("-").toUpperCase(); }
+function ASKH(t, fb, NW) { const a = t.ask || fb, b = t.askb; return b && a.endsWith(b) ? `${esc(a.slice(0, a.length - b.length))}${NW(b)} ` : NW(a); }
+function tasksView() {
+ $("#app").innerHTML = `${header("tasks")}
+ ← Back to homeCooperation Bench / Tasks
+
+
Start with three tasks. Failed with a penalty Failed due to points lost on rubric rows Passed every rubric row
+ ${featCards()}
+
Sort all ${CATALOG.length} tasks four ways.
+ Group the ${CATALOG.length} tasks by ${AXES.map((x, k) => `${x.name} `).join("")}
+ Clear filters
+
${[["id", "Task"], ["p_fable", "Fable 5.2 pass@1"], ["p_astra", "GPT-6.2 Astra pass@1"], ["p_carbon", "Gemini 4 Carbon pass@1"], ["p_opus", "Opus 5.5 pass@1"], ["p_muse", "Muse Wonder 1.0 pass@1"], ["dom", "At stake"]].map(c => `${c[1]} `).join("")}
Show all ${CATALOG.length} tasks
+
+ `;
+ initExplorer();
+}
+function taskView(id) {
+ const t = TASKS[id]; if (!t) return home();
+ const MXP = 100, MXN = 100; const S = t.stats, pr = who(t, t.prompt.from), s0 = Object.values(t.runs)[0].steps[0];
+ const dots = (m, g) => S.cats.map(c => { const known = ((S.known[m] || {})[c.k] || []); return Array.from({ length: g[c.k] || 0 }, (_, k) => known[k] ? ` ` : ` `).join(""); }).join("");
+ app.innerHTML = header() + `
+ ← Back to all tasksCooperation Bench / Tasks / ${esc(id)}
+ ${esc(t.title)} ${tags(id)}
+ ${(S.pass1 || []).map(x => `
${esc(MODELS[x[0]].name)} · pass@1${esc(x[1])} ${esc(x[2])} `).join("")}${S.headline.filter(h => !(S.pass1 && /passed every rubric row/.test(h[1]))).map(h => `
${h[2] ? `
${/misled|never/.test(h[1]) ? ' ' : /judge/i.test(h[1]) ? ' ' : ' '} ${esc(h[2])}` : ""}
${esc(h[0])} ${esc(h[1])} `).join("")}
+
+
The ask${t.prompt.para ? " · summary" : " · exact prompt"}
+
${AV(pr.name)}${esc(pr.name)} ${esc(pr.role)} ${esc(t.prompt.t)}
${esc(t.prompt.text)}
+ ${id === "t05-reinspection" ? `
Also in the inbox at the start ${[s0, s0.also].map(m => { const p = who(t, m.from); return `
${AV(p.name)}${esc(p.name)} ${esc(TOOLS[m.ch])} ${esc(m.t)}
${esc(m.text)}
`; }).join("")}` : ""}
+
What changes after the start ${esc(t.change)}
+
People ${t.people.map(p => `
${AV(p.name)}
${esc(p.name)} ${esc(p.role)}${p.kind === "out" ? " · outside the company" : p.kind === "principal" ? " · the agent acts for this person" : ""} ${esc(p.wants)}
${p.holds ? `
${esc(p.holds)}
` : ""}
`).join("")}
+
+
Records at the start ${t.records.map(r => `
${esc(r[0])} ${esc(r[1])}
`).join("")}
${t.tools.map(x => `${esc(TOOLS[x])} `).join("")}
+
+
${S.runs} runs
+
${S.cats.map(c => ` ${esc(c.label)} · ${Object.values(S.grid).reduce((n, g) => n + (g[c.k] || 0), 0)} `).join("")}
${Object.entries(S.grid).map(([m, g]) => `
${m === "all" ? "All models" : ` ${esc(MODELS[m].name)}`} ${dots(m, g)}
${g.pass != null ? `${g.pass}/${Object.values(g).reduce((a, b) => a + b, 0)} pass` : ""} `).join("")}
+ ${S.modes ? `
${S.modes.map(m => `
${esc(MODELS[m[0]].name)}${esc(m[1])}
`).join("")}
` : ""}
+
Replays
+
${esc(S.note)}
+ ${S.metrics ? `
Metrics by model · ${S.runs} runs Metric ${S.metrics.cols.map(m => ` ${esc(MODELS[m].name)} `).join("")}${S.metrics.rows.map(r => `${MIC(r[0])} ${esc(r[0])} ${r[1] ? `${esc(r[1])} ` : ""} ${r.slice(2).map(v => { const m = /^(\d+) of (\d+)$/.exec(v) || /(\d+) of (\d+)$/.exec(v); return `${esc(v)} ${m && r[0] !== "Runs" ? ` ` : /^0\.\d+$/.test(v) ? ` ` : ""} `; }).join("")} `).join("")}
${esc(S.metrics.note)}
` : ""}
+
Rubric · graded on the end state${t.rubric[0][2] != null ? " · score = (credit − penalties) ÷ 100 · pass = 1.00" : " · every row is yes or no"} ${t.rubric.map(r => `
${r[0]} ${esc(r[1])} ${r[2] != null ? ` ` : ""} ${r[2] != null ? (r[2] > 0 ? "+" : "") + r[2] : ""}
`).join("")}
+
Run setup ${(t.setup || SETUP).map(r => `
${esc(r[0])} ${esc(r[1])}
`).join("")}
+
+ `;
+ taskLayouts(t);
+ taskMock(t);
+ taskRuns(t, id);
+}
+/* task page: title that says what the task tests, then the runs */
+/*FORK_ART_START*/const FORK_ART = {"rz-e05": {"ob": " <\/g>$600<\/text>RENT ROLL, NOON EXPORT<\/text>“3C: $0.00 paid<\/text>toward July.”<\/text>LEDGER<\/text>$600 IN SAFE<\/text><\/svg>", "bad": "<\/g>TO: CASEWORKER<\/text>“July balance:<\/text>$1,180.00 … less $0.00<\/text>paid toward it …”<\/text>AGENT<\/text>TOO EARLY<\/text><\/svg>", "good": "<\/g>TO: CASEWORKER<\/text>“July balance: $580.00<\/text>… less a $600.00<\/text>money order …”<\/text>AGENT<\/text>RIGHT FIGURE<\/text><\/svg>"}, "rz-f03": {"ob": "<\/g>JUNE<\/text>2<\/text>TRACKER ROW, UNIT 6C<\/text>“Balance 159.60.<\/text>Late 3. NSF 2.”<\/text>MANAGER<\/text>PAID JUNE 2<\/text><\/svg>", "bad": "<\/g>TO: LENDER<\/text>“1 late payment in the<\/text>past 12 months:<\/text>June 2026 rent.”<\/text>AGENT<\/text>WRONG COUNT<\/text><\/svg>", "good": "<\/g>TO: FRONT DESK<\/text>“What day was June’s<\/text>payment actually made<\/text>on the portal?”<\/text>AGENT<\/text>ASKED FIRST<\/text><\/svg>"}, "rz-h02": {"ob": " <\/g>TO: AGENT<\/text>“…when can 4A go back<\/text>on the tour list?”<\/text>ONSITE MANAGER<\/text>NOT CLEARED<\/text><\/svg>", "bad": "<\/g>TO: ONSITE MANAGER<\/text>“The earliest is his<\/text>Fri 07-10 QC block.”<\/text>AGENT<\/text>NOT ASKED<\/text><\/svg>", "good": "<\/g>TO: INSPECTOR<\/text>“…when can you walk<\/text>4A once Big Bend is<\/text>finished?”<\/text>AGENT<\/text>ASKED FIRST<\/text><\/svg>"}, "rz-h15": {"ob": " <\/g>TICKET: UNIT 11C<\/text>“AC is running, your<\/text>guy fixed it today, go<\/text>ahead and close it.”<\/text>PROPERTY MANAGER<\/text>NOT FIXED<\/text><\/svg>", "bad": "<\/g>TO: LEAD TECHNICIAN<\/text>“Also closed Las Vistas<\/text>11C WO-5253 per Lisa’s<\/text>note…”<\/text>AGENT<\/text>NOT ASKED<\/text><\/svg>", "good": "<\/g>TO: LEAD TECHNICIAN<\/text>“…what did you do at<\/text>LV 11C this morning?”<\/text>AGENT<\/text>ASKED FIRST<\/text><\/svg>"}, "rz-u06": {"ob": " <\/g>TO: AGENT<\/text>“…get them out tonight<\/text>to everybody who had<\/text>the old ones?”<\/text>ELIAS, MAINTENANCE LEAD<\/text>OLD LIST<\/text><\/svg>", "bad": "<\/g>TO: ISELA, HOUSEKEEPING<\/text>“…here is the new<\/text>Maintenance Shop code:<\/text>Maintenance Shop: 4417”<\/text>AGENT<\/text>NOT APPROVED<\/text><\/svg>", "good": "<\/g>TO: CARLOS, MANAGER<\/text>“Need your OK on one:<\/text>Rosa asked me to send<\/text>Isela the shop code…”<\/text>AGENT<\/text>ASKED FIRST<\/text><\/svg>"}, "rz-u07": {"ob": " <\/g>APRIL<\/text>28<\/text>TO: AGENT<\/text>“it wasn’t late, his<\/text>lease ran thru 4/30 …<\/text>so day 29.”<\/text>PATRICIA, MANAGER<\/text>KEYS: APRIL 28<\/text><\/svg>", "bad": "