The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(bench): correct viewer HTML to load benchmark script
Steven Enamakela0d1f255bbe0
diff --git a/bench/harnesses/viewer/index.html b/bench/harnesses/viewer/index.htmlindex c2d1a1249a..3f5505afd6 100644--- a/bench/harnesses/viewer/index.html+++ b/bench/harnesses/viewer/index.html@@ -22,6 +22,10 @@ pre{background:var(--card);border:1px solid var(--line);padding:10px;overflow:au.bad{color:var(--bad)}.ok{color:var(--ok)}.mut{color:var(--mut)}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:8px}.card{background:var(--card);border:1px solid var(--line);padding:10px;border-radius:6px}+.md h1,.md h2,.md h3,.md h4{margin:16px 0 6px}.md h1{font-size:17px}.md h2{font-size:15px}.md h3{font-size:14px}.md h4{font-size:13px;color:var(--mut)}+.md p{margin:6px 0}.md ul{margin:6px 0;padding-left:22px}.md code{background:var(--card);border:1px solid var(--line);border-radius:3px;padding:0 4px;font-size:12.5px}+.md pre{margin:6px 0;max-height:320px;position:relative}.md pre code{background:none;border:0;padding:0}.md .lang{position:absolute;top:2px;right:8px;color:var(--mut);font-size:11px}+.tabs button{margin-right:4px}.tabs button.on{font-weight:600;outline:2px solid var(--acc)}details{margin:6px 0}summary{cursor:pointer}.role{font-weight:600;text-transform:uppercase;font-size:12px;color:var(--mut)}</style>@@ -41,6 +45,7 @@ const h = (tag, attrs = {}, ...kids) => {};const api = async (p) => { const r = await fetch(p); if (!r.ok) throw new Error(`${p}: ${r.status}`); return r.json(); };const e = encodeURIComponent;+const pct = (a, b) => (a == null || !b ? "–" : `${((100 * a) / b).toFixed(1)}%`);const fmt = (n, d = 0) => n == null ? "–" : Number(n).toLocaleString(undefined, { maximumFractionDigits: d });const link = (href, text) => h("a", { href }, text);const crumbs = (...parts) => h("div", { class: "crumbs" }, parts.flatMap((p, i) => i ? [" / ", p] : [p]));@@ -84,7 +89,7 @@ async function run(id) {const d = await api(`/api/runs/${e(id)}`);const kids = [h("h1", {}, id), crumbs(link("#/", "runs"), id), h("h2", {}, "Harnesses (from the meter proxy, on the wire)")];kids.push(table(- ["harness", "tasks", "calls", "prompt tok", "completion tok", "cache %", "cost $", "system tok", "tool schema tok", "tools", "errors", "overridden", "system prompt"],+ ["harness", "tasks", "turns", "prompt tok", "completion tok", "cached %", "cost $", "system tok", "tool schema tok", "tools", "errors", "overridden", "system prompt"],d.harnesses.map((x) => [x.harness, x.tasks, x.calls, fmt(x.prompt_tokens), fmt(x.completion_tokens), fmt(x.cache_pct, 1), fmt(x.cost_usd, 4),fmt(x.system_prompt_tokens), fmt(x.tool_schema_tokens), fmt(x.tool_count),@@ -98,7 +103,7 @@ async function run(id) {for (const x of withTasks) {const tasks = await api(`/api/runs/${e(id)}/tasks/${e(x.harness)}`);grid.append(h("div", { class: "card" }, h("b", {}, x.harness), h("div", {},- tasks.map((t) => h("div", {}, link(`#/task/${e(id)}/${e(x.harness)}/${e(t.task)}`, t.task), h("span", { class: "mut" }, ` ${t.calls} calls`))))));+ tasks.map((t) => h("div", {}, link(`#/task/${e(id)}/${e(x.harness)}/${e(t.task)}`, t.task), h("span", { class: "mut" }, ` ${t.calls} ${t.calls === 1 ? "turn" : "turns"}`))))));}kids.push(grid);} else kids.push(h("p", { class: "mut" }, "No request captures for this run (it predates capture, or METER_CAPTURE=0)."));@@ -114,42 +119,93 @@ async function task(id, harness, t) {crumbs(link("#/", "runs"), link(`#/run/${e(id)}`, id), harness, t),h("h2", {}, "Full task transcript (Markdown)"),transcriptBox(`/api/runs/${e(id)}/transcript/${e(harness)}/${e(t)}/last`),- h("p", { class: "mut" }, "‘prefix reused’ is how many of the previous call’s messages this call re-sent byte-for-byte; below the previous count, history was rewritten and provider prefix caching is lost from there."),- table(["#", "status", "msgs", "prefix reused", "system", "tools", "cache ctl", "prompt", "cached", "completion", "first token ms", "total ms", "cost $", "req KB"],+ h("p", { class: "mut" }, "A turn is one request to the model and its response; a task is made of several. ‘prefix reused’ is how many of the previous call’s messages this call re-sent byte-for-byte; below the previous count, history was rewritten and provider prefix caching is lost from there."),+ table(["turn", "status", "messages", "prefix reused", "system", "tools", "cache ctl", "prompt tok", "cached tok", "cached %", "completion", "first token ms", "total ms", "cost $", "req KB"],calls.map((c, i) => [link(`#/call/${e(id)}/${e(harness)}/${e(t)}/${c.seq}`, i + 1), c.status ?? "–", c.messages,c.prefix_reused_messages == null ? "–" : `${c.prefix_reused_messages}/${c.prev_messages}`,flag(c.same_system_as_prev), flag(c.same_tools_as_prev), c.cache_control_markers,- fmt(c.usage?.prompt_tokens), fmt(c.usage?.cached_tokens), fmt(c.usage?.completion_tokens),+ fmt(c.usage?.prompt_tokens), fmt(c.usage?.cached_tokens), pct(c.usage?.cached_tokens, c.usage?.prompt_tokens), fmt(c.usage?.completion_tokens),fmt(c.first_token_ms ?? c.ttfb_ms), fmt(c.total_ms), fmt(c.cost_usd, 5), fmt(c.request_bytes / 1024, 1),])));}const text = (c) => typeof c === "string" ? c : Array.isArray(c) ? c.map((p) => p?.text ?? p?.content ?? JSON.stringify(p)).join("\n") : JSON.stringify(c, null, 2);-// Collapsed by default (it can be large); loads on first open. Same text the Copy and Download buttons use.+// A small, safe Markdown renderer for the transcripts: headings, bullets, tables, paragraphs,+// `code`, **bold** and fenced blocks. It builds DOM nodes from text only (no innerHTML, no links,+// no images), so prompts and model output can never inject markup or load anything.+function inline(text) {+ return text.split(/(`[^`]+`|\*\*[^*]+\*\*)/).filter(Boolean).map((p) =>+ p.startsWith("`") && p.length > 2 ? h("code", {}, p.slice(1, -1))+ : p.startsWith("**") && p.length > 4 ? h("strong", {}, p.slice(2, -2)) : p);+}+function renderMarkdown(src) {+ const out = h("div", { class: "md" });+ const lines = src.split("\n");+ let para = [], list = null, rows = [];+ const flush = () => {+ if (para.length) out.append(h("p", {}, inline(para.join(" ")))); para = [];+ if (list) out.append(list); list = null;+ if (rows.length) { const [head, , ...body] = rows; out.append(table(head, body.map((r) => r.map(inline)))); rows = []; }+ };+ for (let i = 0; i < lines.length; i += 1) {+ const line = lines[i];+ const fenceOpen = line.match(/^(`{3,})(.*)$/);+ if (fenceOpen) {+ flush();+ const body = [];+ for (i += 1; i < lines.length && lines[i].trim() !== fenceOpen[1]; i += 1) body.push(lines[i]);+ const lang = fenceOpen[2].trim();+ out.append(h("pre", {}, lang ? h("span", { class: "lang" }, lang) : null, h("code", {}, body.join("\n"))));+ continue;+ }+ const head = line.match(/^(#{1,6})\s+(.*)$/);+ if (head) { flush(); out.append(h(`h${Math.min(head[1].length, 4)}`, {}, inline(head[2]))); continue; }+ if (line.startsWith("|")) { if (para.length || list) flush(); rows.push(line.split("|").slice(1, -1).map((c) => c.trim())); continue; }+ const li = line.match(/^\s*[-*]\s+(.*)$/);+ if (li) { if (para.length || rows.length) flush(); (list ??= h("ul", {})).append(h("li", {}, inline(li[1]))); continue; }+ if (!line.trim()) { flush(); continue; }+ if (list) flush();+ para.push(line.trim());+ }+ flush();+ return out;+}++// Collapsed by default (it can be large); loads on first open. Rendered Markdown by default, with+// the exact Markdown source one click away; Copy and "open as .md" use the same source text.function transcriptBox(apiPath) {- const box = h("div", {});const d = h("details", {}, h("summary", {}, "Show exactly what the provider received and returned"));const holder = h("div", {});d.append(holder);d.addEventListener("toggle", async () => {if (!d.open || holder.childNodes.length) return;const { markdown } = await api(apiPath);- const copy = h("button", {}, "Copy");+ const view = h("div", {});+ const show = (mode) => {+ view.replaceChildren(mode === "rendered" ? renderMarkdown(markdown) : pre(markdown));+ rendered.className = mode === "rendered" ? "on" : "";+ source.className = mode === "source" ? "on" : "";+ };+ const rendered = h("button", {}, "Rendered");+ const source = h("button", {}, "Markdown");+ const copy = h("button", {}, "Copy markdown");+ rendered.onclick = () => show("rendered");+ source.onclick = () => show("source");copy.onclick = () => navigator.clipboard.writeText(markdown).then(() => { copy.textContent = "Copied"; });- holder.append(h("div", {}, copy, " ", h("a", { href: `${apiPath}?format=md`, target: "_blank" }, "open as .md")), pre(markdown));+ holder.append(h("div", { class: "tabs" }, rendered, source, copy, " ", h("a", { href: `${apiPath}?format=md`, target: "_blank" }, "open as .md")), view);+ show("rendered");});- box.append(d);- return box;+ return d;}async function call(id, harness, t, seq) {const mine = nav;const c = await api(`/api/runs/${e(id)}/call/${e(harness)}/${e(t)}/${seq}`);- const kids = [h("h1", {}, `${harness} · ${t} · call ${seq}`),+ const kids = [h("h1", {}, `${harness} · ${t} · turn ${seq}`),crumbs(link("#/", "runs"), link(`#/run/${e(id)}`, id), link(`#/task/${e(id)}/${e(harness)}/${e(t)}`, `${harness}/${t}`), `call ${seq}`),- h("div", {}, [["format", c.format], ["status", c.status], ["msgs", c.message_shas.length], ["tools", c.tool_count],+ h("div", {}, [["format", c.format], ["status", c.status], ["messages", c.message_shas.length], ["tools", c.tool_count],["cache_control markers", c.cache_control_markers], ["prompt_cache_key", c.prompt_cache_key]].map(([k, v]) => h("span", { class: "tag" }, `${k}: ${v ?? "–"}`))),h("h2", {}, "Raw transcript (Markdown)"),transcriptBox(`/api/runs/${e(id)}/transcript/${e(harness)}/${e(t)}/${seq}`),