@parhelia/benchmark 0.4.12784

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +9 -0
  3. package/dist/agentLink.d.ts +2 -0
  4. package/dist/agentLink.d.ts.map +1 -0
  5. package/dist/agentLink.js +7 -0
  6. package/dist/components/ActiveRunBanner.d.ts +9 -0
  7. package/dist/components/ActiveRunBanner.d.ts.map +1 -0
  8. package/dist/components/ActiveRunBanner.js +10 -0
  9. package/dist/components/BenchmarkCostCorrectnessChart.d.ts +5 -0
  10. package/dist/components/BenchmarkCostCorrectnessChart.d.ts.map +1 -0
  11. package/dist/components/BenchmarkCostCorrectnessChart.js +36 -0
  12. package/dist/components/BenchmarkLeaderboard.d.ts +30 -0
  13. package/dist/components/BenchmarkLeaderboard.d.ts.map +1 -0
  14. package/dist/components/BenchmarkLeaderboard.js +29 -0
  15. package/dist/components/BenchmarkPanel.d.ts +2 -0
  16. package/dist/components/BenchmarkPanel.d.ts.map +1 -0
  17. package/dist/components/BenchmarkPanel.js +103 -0
  18. package/dist/components/BenchmarkRunDetail.d.ts +8 -0
  19. package/dist/components/BenchmarkRunDetail.d.ts.map +1 -0
  20. package/dist/components/BenchmarkRunDetail.js +21 -0
  21. package/dist/components/BenchmarkRunsList.d.ts +10 -0
  22. package/dist/components/BenchmarkRunsList.d.ts.map +1 -0
  23. package/dist/components/BenchmarkRunsList.js +19 -0
  24. package/dist/components/BenchmarkTasksList.d.ts +5 -0
  25. package/dist/components/BenchmarkTasksList.d.ts.map +1 -0
  26. package/dist/components/BenchmarkTasksList.js +8 -0
  27. package/dist/components/NotPreparedState.d.ts +7 -0
  28. package/dist/components/NotPreparedState.d.ts.map +1 -0
  29. package/dist/components/NotPreparedState.js +6 -0
  30. package/dist/components/RecoveryBanner.d.ts +7 -0
  31. package/dist/components/RecoveryBanner.d.ts.map +1 -0
  32. package/dist/components/RecoveryBanner.js +14 -0
  33. package/dist/components/RunStatusBadge.d.ts +5 -0
  34. package/dist/components/RunStatusBadge.d.ts.map +1 -0
  35. package/dist/components/RunStatusBadge.js +9 -0
  36. package/dist/components/StartBenchmarkDialog.d.ts +11 -0
  37. package/dist/components/StartBenchmarkDialog.d.ts.map +1 -0
  38. package/dist/components/StartBenchmarkDialog.js +48 -0
  39. package/dist/components/TaskChecksList.d.ts +5 -0
  40. package/dist/components/TaskChecksList.d.ts.map +1 -0
  41. package/dist/components/TaskChecksList.js +22 -0
  42. package/dist/format.d.ts +7 -0
  43. package/dist/format.d.ts.map +1 -0
  44. package/dist/format.js +22 -0
  45. package/dist/hooks/useBenchmarkRunUpdates.d.ts +6 -0
  46. package/dist/hooks/useBenchmarkRunUpdates.d.ts.map +1 -0
  47. package/dist/hooks/useBenchmarkRunUpdates.js +15 -0
  48. package/dist/hooks/useBenchmarkStatus.d.ts +7 -0
  49. package/dist/hooks/useBenchmarkStatus.d.ts.map +1 -0
  50. package/dist/hooks/useBenchmarkStatus.js +31 -0
  51. package/dist/hooks/useRunIdParam.d.ts +2 -0
  52. package/dist/hooks/useRunIdParam.d.ts.map +1 -0
  53. package/dist/hooks/useRunIdParam.js +11 -0
  54. package/dist/index.d.ts +5 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +21 -0
  57. package/dist/services/benchmarkService.d.ts +45 -0
  58. package/dist/services/benchmarkService.d.ts.map +1 -0
  59. package/dist/services/benchmarkService.js +30 -0
  60. package/dist/types.d.ts +146 -0
  61. package/dist/types.d.ts.map +1 -0
  62. package/dist/types.js +1 -0
  63. package/package.json +62 -0
  64. package/styles.css +3 -0
package/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ Parhelia - AI-Powered Editor for Sitecore
2
+
3
+ Copyright © 2025 Canvas REPLY GmbH. All rights reserved.
4
+
5
+ For full license terms and legal notice, please visit:
6
+ https://parhelia.ai/license
7
+
8
+ This software is proprietary and confidential.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @parhelia/benchmark
2
+
3
+ Optional model benchmark Settings UI. Install the matching `Parhelia.Benchmark` Sitecore module and call `configureBenchmark(configuration)` before `configureForUser`. Import `@parhelia/benchmark/styles.css` alongside the core stylesheet. The panel is visible only to administrators when the backend advertises the `benchmark` module.
4
+
5
+ Prepare the environment, select a model, and start one or more sequential runs. Models without configured pricing require explicit consent to run without cost tracking. Subsets and older suites do not enter the current leaderboard. Correctness remains comparable when cost or optional judge results are unavailable.
6
+
7
+ The panel consumes Parhelia's authenticated HTTP and realtime transport. Recovery retains task copies until the backend confirms execution has stopped.
8
+
9
+ Development: `npm run test --workspace=@parhelia/benchmark`, `npm run check-types --workspace=@parhelia/benchmark`, and `npm run lint --workspace=@parhelia/benchmark` from `frontend`.
@@ -0,0 +1,2 @@
1
+ export declare function agentLink(agentId: string): string;
2
+ //# sourceMappingURL=agentLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentLink.d.ts","sourceRoot":"","sources":["../src/agentLink.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKjD"}
@@ -0,0 +1,7 @@
1
+ export function agentLink(agentId) {
2
+ const url = new URL(window.location.href);
3
+ url.searchParams.set("workspace", "agents");
4
+ url.searchParams.set("agentId", agentId);
5
+ url.searchParams.delete("benchmarkRunId");
6
+ return url.pathname + url.search + url.hash;
7
+ }
@@ -0,0 +1,9 @@
1
+ import type { BenchmarkRun } from "../types";
2
+ export declare function ActiveRunBanner({ run, queued, open, cancel, busy }: {
3
+ run?: BenchmarkRun;
4
+ queued: BenchmarkRun[];
5
+ open: (id: string) => void;
6
+ cancel: (id: string) => void;
7
+ busy: boolean;
8
+ }): import("react").JSX.Element | null;
9
+ //# sourceMappingURL=ActiveRunBanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActiveRunBanner.d.ts","sourceRoot":"","sources":["../../src/components/ActiveRunBanner.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,wBAAgB,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,sCAuB3L"}
@@ -0,0 +1,10 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Alert, AlertDescription, AlertTitle, Button, Progress } from "@parhelia/core";
3
+ import { Loader2 } from "lucide-react";
4
+ export function ActiveRunBanner({ run, queued, open, cancel, busy }) {
5
+ if (!run && !queued.length)
6
+ return null;
7
+ const progress = run && run.taskCount > 0 ? (run.tasksCompleted / run.taskCount) * 100 : 0;
8
+ const queuedText = queued.length ? `${queued.length} ${queued.length === 1 ? "run" : "runs"} queued` : "";
9
+ return _jsxs(Alert, { "data-testid": "benchmark-active-run", variant: "info", role: "status", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin", strokeWidth: 1.5 }), _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-6 gap-y-3", children: [_jsx("div", { className: "min-w-0 flex-1", children: run ? _jsxs(_Fragment, { children: [_jsx(AlertTitle, { children: run.modelName }), _jsxs(AlertDescription, { className: "text-neutral-grey-50", children: [run.tasksCompleted, " / ", run.taskCount, " tasks completed", queuedText && ` · ${queuedText}`] }), _jsx(Progress, { "aria-label": "Benchmark progress", value: progress, showValue: false, className: "bg-feedback-blue/15 mt-2 h-1.5 max-w-md", indicatorClassName: "bg-feedback-blue" })] }) : _jsxs(_Fragment, { children: [_jsx(AlertTitle, { children: "Benchmark queued" }), _jsxs(AlertDescription, { className: "text-neutral-grey-50", children: [queuedText, ". The first run starts as soon as the runner is free."] })] }) }), run && _jsxs("div", { className: "flex shrink-0 gap-2", children: [_jsx(Button, { size: "sm", variant: "outline", onClick: () => open(run.runId), children: "View run" }), _jsx(Button, { size: "sm", variant: "destructive", "data-testid": `benchmark-run-cancel-${run.runId}`, disabled: busy || !!run.cancelRequestedAt, onClick: () => cancel(run.runId), children: run.cancelRequestedAt ? "Stopping…" : "Cancel" })] })] })] });
10
+ }
@@ -0,0 +1,5 @@
1
+ import type { LeaderboardEntry } from "../types";
2
+ export declare function BenchmarkCostCorrectnessChart({ entries }: {
3
+ entries: LeaderboardEntry[];
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=BenchmarkCostCorrectnessChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenchmarkCostCorrectnessChart.d.ts","sourceRoot":"","sources":["../../src/components/BenchmarkCostCorrectnessChart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAMjD,wBAAgB,6BAA6B,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAAE,+BAmEzF"}
@@ -0,0 +1,36 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useState } from "react";
3
+ import { cost, percent } from "../format";
4
+ const colors = ["text-feedback-blue", "text-feedback-green", "text-highlight-100", "text-feedback-orange", "text-highlight-secondary-100"];
5
+ const plot = { left: 76, top: 36, width: 608, height: 224 };
6
+ const keyOf = (entry) => `${entry.modelItemId}:${entry.modelConfigFingerprint}`;
7
+ export function BenchmarkCostCorrectnessChart({ entries }) {
8
+ const titleId = useId();
9
+ const descriptionId = useId();
10
+ const [activeKey, setActiveKey] = useState();
11
+ const points = entries.filter((entry) => entry.costKnown && entry.medianCoreCost != null && Number.isFinite(entry.medianCoreCost) && entry.medianCoreCost >= 0 &&
12
+ Number.isFinite(entry.medianCorrectnessPercent) && entry.medianCorrectnessPercent >= 0 && entry.medianCorrectnessPercent <= 100);
13
+ const omitted = entries.length - points.length;
14
+ const maxCost = Math.max(0, ...points.map(entry => entry.medianCoreCost));
15
+ // Leave room for markers at the right edge, including when every cost is zero.
16
+ const costLimit = maxCost > 0 ? maxCost * 1.1 : 0.01;
17
+ const active = points.find(entry => keyOf(entry) === activeKey);
18
+ const describe = (entry) => `${entry.modelName} · ${entry.providerName} · ${entry.configLabel}: ${cost(entry.medianCoreCost)} core cost, ${percent(entry.medianCorrectnessPercent)} correctness, ${entry.runCount} ${entry.runCount === 1 ? "run" : "runs"}, ${percent(entry.coveragePercent)} coverage`;
19
+ return _jsxs("section", { "aria-labelledby": titleId, className: "border-border-default rounded-lg border p-4", "data-testid": "benchmark-cost-correctness-chart", children: [_jsx("h4", { id: titleId, className: "text-neutral-grey-100 text-sm font-medium", children: "Cost / correctness" }), _jsx("p", { id: descriptionId, className: "text-neutral-grey-50 mt-1 text-xs", children: "Median core cost and correctness per model configuration. Upper left means lower cost and higher correctness." }), !points.length ? _jsx("p", { className: "text-neutral-grey-50 py-8 text-center text-sm", children: "Complete a full-suite run with known cost to compare models here." }) : _jsxs(_Fragment, { children: [_jsx("div", { className: "overflow-x-auto", children: _jsxs("svg", { viewBox: "0 0 720 324", className: "mt-3 w-full min-w-[480px]", role: "img", "aria-labelledby": titleId, "aria-describedby": descriptionId, children: [_jsx("text", { x: plot.left, y: 16, className: "fill-current text-neutral-grey-50", fontSize: 11, children: "Correctness (%)" }), [0, 25, 50, 75, 100].map(value => {
20
+ const y = plot.top + plot.height * (1 - value / 100);
21
+ return _jsxs("g", { children: [_jsx("line", { x1: plot.left, x2: plot.left + plot.width, y1: y, y2: y, className: "text-border-default", stroke: "currentColor", strokeDasharray: "3 4" }), _jsxs("text", { x: plot.left - 18, y: y + 4, textAnchor: "end", className: "fill-current text-neutral-grey-50", fontSize: 11, children: [value, "%"] })] }, value);
22
+ }), [0, 1, 2, 3, 4].map(tick => {
23
+ const x = plot.left + plot.width * tick / 4;
24
+ const value = costLimit * tick / 4;
25
+ // Preserve distinct tick labels for very small benchmark costs.
26
+ const label = value > 0 && value < 0.0001 ? `$${value.toExponential(1)}` : cost(value);
27
+ return _jsxs("g", { children: [_jsx("line", { x1: x, x2: x, y1: plot.top, y2: plot.top + plot.height, className: "text-border-default", stroke: "currentColor", strokeDasharray: "3 4" }), _jsx("text", { x: x, y: plot.top + plot.height + 24, textAnchor: "middle", className: "fill-current text-neutral-grey-50", fontSize: 11, children: label })] }, tick);
28
+ }), _jsx("text", { x: plot.left + plot.width / 2, y: 316, textAnchor: "middle", className: "fill-current text-neutral-grey-50", fontSize: 11, children: "Core cost (USD)" }), points.map((entry, index) => ({ entry, index }))
29
+ .sort((a, b) => Number(keyOf(a.entry) === activeKey) - Number(keyOf(b.entry) === activeKey))
30
+ .map(({ entry, index }) => {
31
+ const key = keyOf(entry);
32
+ const x = plot.left + entry.medianCoreCost / costLimit * plot.width;
33
+ const y = plot.top + (1 - entry.medianCorrectnessPercent / 100) * plot.height;
34
+ return _jsxs("g", { className: colors[index % colors.length], opacity: active && activeKey !== key ? 0.3 : 1, onMouseEnter: () => setActiveKey(key), onMouseLeave: () => setActiveKey(undefined), onClick: () => setActiveKey(key), children: [_jsx("title", { children: describe(entry) }), _jsx("circle", { cx: x, cy: y, r: activeKey === key ? 13 : 11, fill: "currentColor" }), _jsx("text", { x: x, y: y, dy: "0.35em", textAnchor: "middle", className: "fill-current text-white", fontSize: 10, fontWeight: 600, children: index + 1 })] }, key);
35
+ })] }) }), _jsx("p", { className: "text-neutral-grey-50 mt-2 min-h-8 text-xs", "aria-live": "polite", children: active ? describe(active) : "Hover a point or focus a configuration below to inspect its results." }), _jsx("div", { className: "mt-2 grid gap-1 sm:grid-cols-2", children: points.map((entry, index) => _jsxs("button", { type: "button", "aria-label": describe(entry), className: `flex min-w-0 items-start gap-2 rounded p-2 text-left text-xs hover:bg-neutral-grey-5 focus-visible:outline-2 focus-visible:outline-offset-2 ${activeKey === keyOf(entry) ? "bg-neutral-grey-5" : ""}`, onMouseEnter: () => setActiveKey(keyOf(entry)), onMouseLeave: () => setActiveKey(undefined), onFocus: () => setActiveKey(keyOf(entry)), onBlur: () => setActiveKey(undefined), onClick: () => setActiveKey(keyOf(entry)), children: [_jsx("span", { className: `w-5 shrink-0 text-center font-semibold tabular-nums ${colors[index % colors.length]}`, children: index + 1 }), _jsxs("span", { className: "min-w-0 break-words", children: [_jsx("span", { className: "text-neutral-grey-100 font-medium", children: entry.modelName }), _jsxs("span", { className: "text-neutral-grey-50 block", children: [entry.providerName, " \u00B7 ", entry.configLabel] })] })] }, keyOf(entry))) })] }), omitted > 0 && _jsxs("p", { className: "text-neutral-grey-50 mt-3 text-xs", children: [omitted, " ", omitted === 1 ? "configuration is" : "configurations are", " not plotted because cost or correctness is unavailable."] })] });
36
+ }
@@ -0,0 +1,30 @@
1
+ import type { LeaderboardEntry } from "../types";
2
+ declare const metrics: readonly [{
3
+ readonly value: "medianCorrectnessPercent";
4
+ readonly label: "Correctness";
5
+ }, {
6
+ readonly value: "medianEfficiencyPercent";
7
+ readonly label: "Efficiency";
8
+ }, {
9
+ readonly value: "medianFullScorePercent";
10
+ readonly label: "Full score";
11
+ }, {
12
+ readonly value: "medianCoreCost";
13
+ readonly label: "Core cost";
14
+ }, {
15
+ readonly value: "medianCostPerCorrectnessPoint";
16
+ readonly label: "Cost per correctness point";
17
+ }, {
18
+ readonly value: "medianTokens";
19
+ readonly label: "Tokens";
20
+ }, {
21
+ readonly value: "medianWallDurationMs";
22
+ readonly label: "Duration";
23
+ }];
24
+ type Metric = typeof metrics[number]["value"];
25
+ export declare function sortedEntries(entries: LeaderboardEntry[], metric: Metric): LeaderboardEntry[];
26
+ export declare function BenchmarkLeaderboard({ entries }: {
27
+ entries: LeaderboardEntry[];
28
+ }): import("react").JSX.Element;
29
+ export {};
30
+ //# sourceMappingURL=BenchmarkLeaderboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenchmarkLeaderboard.d.ts","sourceRoot":"","sources":["../../src/components/BenchmarkLeaderboard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,QAAA,MAAM,OAAO;aACT,KAAK,EAAE,0BAA0B;aAAE,KAAK,EAAE,aAAa;;aAAM,KAAK,EAAE,yBAAyB;aAAE,KAAK,EAAE,YAAY;;aAClH,KAAK,EAAE,wBAAwB;aAAE,KAAK,EAAE,YAAY;;aAAM,KAAK,EAAE,gBAAgB;aAAE,KAAK,EAAE,WAAW;;aACrG,KAAK,EAAE,+BAA+B;aAAE,KAAK,EAAE,4BAA4B;;aAAM,KAAK,EAAE,cAAc;aAAE,KAAK,EAAE,QAAQ;;aAAM,KAAK,EAAE,sBAAsB;aAAE,KAAK,EAAE,UAAU;EACvK,CAAC;AACX,KAAK,MAAM,GAAG,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAC9C,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,MAAM,EAAE,MAAM,sBAGxE;AAED,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAAE,+BAsBhF"}
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import { Badge, Select, SimpleTable } from "@parhelia/core";
4
+ import { cost, count, duration, percent } from "../format";
5
+ import { BenchmarkCostCorrectnessChart } from "./BenchmarkCostCorrectnessChart";
6
+ const metrics = [
7
+ { value: "medianCorrectnessPercent", label: "Correctness" }, { value: "medianEfficiencyPercent", label: "Efficiency" },
8
+ { value: "medianFullScorePercent", label: "Full score" }, { value: "medianCoreCost", label: "Core cost" },
9
+ { value: "medianCostPerCorrectnessPoint", label: "Cost per correctness point" }, { value: "medianTokens", label: "Tokens" }, { value: "medianWallDurationMs", label: "Duration" },
10
+ ];
11
+ export function sortedEntries(entries, metric) {
12
+ const costMetric = metric === "medianCoreCost" || metric === "medianCostPerCorrectnessPoint";
13
+ return entries.filter(e => e[metric] != null && (!costMetric || e.costKnown)).sort((a, b) => ((a[metric] ?? 0) - (b[metric] ?? 0)) * (metric.endsWith("Percent") ? -1 : 1));
14
+ }
15
+ const numeric = "text-neutral-grey-100 tabular-nums";
16
+ export function BenchmarkLeaderboard({ entries }) {
17
+ const [metric, setMetric] = useState("medianCorrectnessPercent");
18
+ const rows = useMemo(() => sortedEntries(entries, metric), [entries, metric]);
19
+ const metricValue = (e) => metric.endsWith("Percent") ? percent(e[metric]) : metric === "medianTokens" ? count(e[metric]) : metric === "medianWallDurationMs" ? duration(e[metric]) : cost(e[metric], e.costKnown);
20
+ return _jsxs("div", { "data-testid": "benchmark-leaderboard", className: "space-y-4", children: [_jsx(BenchmarkCostCorrectnessChart, { entries: entries }), _jsx("div", { className: "flex flex-wrap items-center justify-end gap-3", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("label", { htmlFor: "benchmark-leaderboard-metric", className: "text-neutral-grey-50 text-xs font-medium", children: "Rank by" }), _jsx(Select, { id: "benchmark-leaderboard-metric", "data-testid": "benchmark-leaderboard-metric", className: "w-56", value: metric, onValueChange: v => setMetric(v), options: [...metrics] })] }) }), !rows.length ? _jsx("p", { className: "text-neutral-grey-50 py-10 text-center text-sm", children: "No comparable runs for this metric yet. Complete a full-suite run to see models ranked here." }) : _jsx("div", { className: "overflow-x-auto", children: _jsx(SimpleTable, { items: rows, rowKey: r => r.modelItemId + r.modelConfigFingerprint, rowTestId: () => "benchmark-leaderboard-row", columns: [
21
+ { header: "#", body: r => _jsx("span", { className: "text-neutral-grey-50 tabular-nums", children: rows.indexOf(r) + 1 }), className: "w-8" },
22
+ { header: "Model / configuration", body: r => _jsxs("div", { children: [_jsx("p", { className: "text-neutral-grey-100 text-sm font-medium", children: r.modelName }), _jsxs("p", { className: "text-neutral-grey-50", children: [r.providerName, " \u00B7 ", r.configLabel] })] }) },
23
+ { header: metrics.find(m => m.value === metric)?.label, body: r => _jsx("span", { className: `${numeric} text-sm font-medium`, children: metricValue(r) }), align: "right" },
24
+ ...(metric !== "medianCorrectnessPercent" ? [{ header: "Correctness", body: (r) => _jsx("span", { className: numeric, children: percent(r.medianCorrectnessPercent) }), align: "right" }] : []),
25
+ ...(metric !== "medianEfficiencyPercent" ? [{ header: "Efficiency", body: (r) => _jsx("span", { className: numeric, children: percent(r.medianEfficiencyPercent) }), align: "right" }] : []),
26
+ ...(metric !== "medianCoreCost" ? [{ header: "Core cost", body: (r) => _jsx("span", { className: numeric, children: cost(r.medianCoreCost, r.costKnown) }), align: "right" }] : []),
27
+ { header: "Evidence", body: r => _jsxs("div", { className: "flex flex-wrap gap-1", children: [_jsxs(Badge, { children: [r.runCount, " ", r.runCount === 1 ? "run" : "runs"] }), _jsxs(Badge, { variant: "secondary", children: [percent(r.coveragePercent), " coverage"] }), !r.costKnown && _jsx(Badge, { variant: "secondary", children: "Cost unknown" }), r.staleRunCount > 0 && _jsxs(Badge, { variant: "outline", children: [r.staleRunCount, " older suite"] })] }) },
28
+ ] }) })] });
29
+ }
@@ -0,0 +1,2 @@
1
+ export declare function BenchmarkPanel(): import("react").JSX.Element;
2
+ //# sourceMappingURL=BenchmarkPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenchmarkPanel.d.ts","sourceRoot":"","sources":["../../src/components/BenchmarkPanel.tsx"],"names":[],"mappings":"AAuBA,wBAAgB,cAAc,gCAoF7B"}
@@ -0,0 +1,103 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { Alert, AlertDescription, AlertTitle, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, LoadingState, MultiSwitchButton, SettingsPanelLayout, useRequiredSettingsHeaderActions } from "@parhelia/core";
4
+ import { AlertCircle, History, ListChecks, Trash2, Trophy } from "lucide-react";
5
+ const views = [
6
+ { value: "leaderboard", label: "Leaderboard", icon: Trophy, description: "Medians of completed full-suite runs on the current suite. Each model configuration is ranked separately." },
7
+ { value: "runs", label: "Runs", icon: History, description: "Every benchmark run, newest first. Open a run to inspect its tasks, checks and agent conversations." },
8
+ { value: "tasks", label: "Tasks", icon: ListChecks, description: "The task suite. Every task runs on a fresh, isolated content copy with its own tool-call, cost and time budget." },
9
+ ];
10
+ import { toast } from "sonner";
11
+ import { benchmarkService } from "../services/benchmarkService";
12
+ import { useBenchmarkStatus } from "../hooks/useBenchmarkStatus";
13
+ import { useBenchmarkRunUpdates } from "../hooks/useBenchmarkRunUpdates";
14
+ import { useRunIdParam } from "../hooks/useRunIdParam";
15
+ import { NotPreparedState } from "./NotPreparedState";
16
+ import { RecoveryBanner } from "./RecoveryBanner";
17
+ import { ActiveRunBanner } from "./ActiveRunBanner";
18
+ import { StartBenchmarkDialog } from "./StartBenchmarkDialog";
19
+ import { BenchmarkLeaderboard } from "./BenchmarkLeaderboard";
20
+ import { BenchmarkRunsList } from "./BenchmarkRunsList";
21
+ import { BenchmarkRunDetail } from "./BenchmarkRunDetail";
22
+ import { BenchmarkTasksList } from "./BenchmarkTasksList";
23
+ export function BenchmarkPanel() {
24
+ const { status, error: statusError, refresh: refreshStatus } = useBenchmarkStatus();
25
+ const [entries, setEntries] = useState([]);
26
+ const [runs, setRuns] = useState([]);
27
+ const [tasks, setTasks] = useState([]);
28
+ const [total, setTotal] = useState(0);
29
+ const [pages, setPages] = useState(1);
30
+ const [detail, setDetail] = useState();
31
+ const [runId, selectRun] = useRunIdParam();
32
+ const [view, setView] = useState("leaderboard");
33
+ const [startOpen, setStartOpen] = useState(false);
34
+ const [busy, setBusy] = useState(false);
35
+ const [error, setError] = useState();
36
+ const [confirmation, setConfirmation] = useState();
37
+ const setActions = useRequiredSettingsHeaderActions();
38
+ const generation = useRef(0);
39
+ const ready = status?.prepared.ready === true;
40
+ const canStart = ready && !busy && !status?.activeRun && !status?.queuedRuns.length && !status?.tasksAwaitingRecovery.length;
41
+ const refresh = useCallback(async () => {
42
+ if (!ready)
43
+ return;
44
+ const version = ++generation.current;
45
+ try {
46
+ const [leaderboard, catalog, history, selected] = await Promise.all([
47
+ benchmarkService.leaderboard(), benchmarkService.tasks(),
48
+ Promise.all(Array.from({ length: pages }, (_, i) => benchmarkService.runs(i * 25))),
49
+ runId ? benchmarkService.run(runId) : Promise.resolve(undefined),
50
+ ]);
51
+ if (version !== generation.current)
52
+ return;
53
+ setEntries(leaderboard.entries);
54
+ setTasks(catalog.tasks);
55
+ setRuns(history.flatMap(h => h.runs));
56
+ setTotal(history[0]?.total ?? 0);
57
+ setDetail(selected);
58
+ setError(undefined);
59
+ }
60
+ catch (e) {
61
+ if (version === generation.current)
62
+ setError(e instanceof Error ? e.message : "Cannot load benchmark results");
63
+ }
64
+ }, [pages, ready, runId]);
65
+ useEffect(() => {
66
+ const initial = setTimeout(refresh, 0);
67
+ const invalidate = () => { generation.current++; };
68
+ return () => { clearTimeout(initial); invalidate(); };
69
+ }, [refresh]);
70
+ useBenchmarkRunUpdates(refresh, !!status?.activeRun || !!status?.queuedRuns.length);
71
+ useEffect(() => { setActions(_jsx(Button, { "data-testid": "benchmark-start-button", disabled: !canStart, onClick: () => setStartOpen(true), children: "Start benchmark" })); return () => setActions(null); }, [canStart, setActions]);
72
+ const perform = async (operation) => {
73
+ setBusy(true);
74
+ try {
75
+ await operation();
76
+ await Promise.all([refreshStatus(), refresh()]);
77
+ }
78
+ catch (e) {
79
+ const message = e instanceof Error ? e.message : "Benchmark operation failed";
80
+ toast.error(message);
81
+ setError(message);
82
+ throw e;
83
+ }
84
+ finally {
85
+ setBusy(false);
86
+ }
87
+ };
88
+ const act = (action, id) => {
89
+ if (action === "deleteRun") {
90
+ setConfirmation({ action, id });
91
+ return;
92
+ }
93
+ void perform(() => benchmarkService[action](id)).catch(() => undefined);
94
+ };
95
+ const start = async (request) => { await perform(async () => { const result = await benchmarkService.start(request); setStartOpen(false); selectRun(result.runIds[0] ?? null); toast.success("Benchmark queued"); }); };
96
+ const open = (id) => { setDetail(undefined); selectRun(id); };
97
+ const purge = confirmation?.action === "purge";
98
+ const current = views.find(v => v.value === view) ?? views[0];
99
+ return _jsxs(SettingsPanelLayout, { testId: "benchmark-panel", contentClassName: "flex flex-col gap-4", children: [(statusError || error) && _jsxs(Alert, { variant: "destructive", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { children: [_jsx(AlertTitle, { children: "Benchmark unavailable" }), _jsx(AlertDescription, { children: statusError || error })] }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => { void refreshStatus(); void refresh(); }, children: "Retry" })] })] }), !status && !statusError && _jsx(LoadingState, { message: "Loading benchmark\u2026" }), status && _jsxs(_Fragment, { children: [!ready && _jsx(NotPreparedState, { status: status, busy: busy, prepare: () => { void perform(benchmarkService.prepare).catch(() => undefined); } }), _jsx(RecoveryBanner, { tasks: status.tasksAwaitingRecovery, busy: busy, recover: () => { void perform(() => benchmarkService.recover()).catch(() => undefined); } }), !runId && _jsx(ActiveRunBanner, { run: status.activeRun, queued: status.queuedRuns, busy: busy, open: open, cancel: id => act("cancel", id) }), ready && (runId ? detail ? _jsx(BenchmarkRunDetail, { detail: detail, busy: busy, cancel: id => act("cancel", id), back: () => { selectRun(null); setView("runs"); } }) : _jsx(LoadingState, { message: "Loading run\u2026" }) : _jsxs("section", { className: "overflow-hidden rounded-lg bg-white", "data-testid": `benchmark-view-${view}`, children: [_jsx("div", { className: "border-border-default border-b px-4 py-3", children: _jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx(current.icon, { className: "text-neutral-grey-50 h-4 w-4 shrink-0", strokeWidth: 1 }), _jsxs("div", { className: "min-w-0", children: [_jsx("h3", { className: "text-neutral-grey-100 text-sm font-medium", children: current.label }), _jsx("p", { className: "text-neutral-grey-50 text-xs", children: current.description })] })] }), _jsx(MultiSwitchButton, { value: view, onValueChange: setView, options: views.map(({ value, label }) => ({ value, label })), className: "w-full shrink-0 sm:w-80", "aria-label": "Benchmark view", testId: "benchmark-view-switch" })] }) }), _jsxs("div", { className: "p-4", children: [view === "leaderboard" && _jsx(BenchmarkLeaderboard, { entries: entries }), view === "runs" && _jsxs("div", { className: "space-y-6", children: [_jsx(BenchmarkRunsList, { runs: runs, total: total, busy: busy, open: open, act: act, more: () => setPages(p => p + 1) }), !!runs.length && _jsxs("div", { className: "border-border-default flex flex-wrap items-center justify-between gap-3 border-t pt-4", children: [_jsx("p", { className: "text-neutral-grey-50 text-xs", children: "Completed runs keep their agent conversations until they are deleted." }), _jsxs(Button, { size: "sm", variant: "outline", disabled: busy, onClick: () => setConfirmation({ action: "purge" }), children: [_jsx(Trash2, { strokeWidth: 1.5 }), "Purge completed history"] })] })] }), view === "tasks" && _jsx(BenchmarkTasksList, { tasks: tasks })] })] }))] }), _jsx(StartBenchmarkDialog, { open: startOpen, onOpenChange: setStartOpen, start: start, busy: busy }), _jsx(Dialog, { open: !!confirmation, onOpenChange: value => { if (!value)
100
+ setConfirmation(undefined); }, children: _jsxs(DialogContent, { className: "max-w-lg gap-6", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: purge ? "Purge completed benchmark history?" : "Delete this benchmark run?" }), _jsx(DialogDescription, { children: purge ? "This deletes eligible completed run records and their retained agent conversations. Active runs and tasks awaiting safe cleanup are kept." : "This permanently deletes the run record and task results. Runs with retained copies must be cleaned up first." })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => setConfirmation(undefined), children: "Cancel" }), _jsx(Button, { variant: "destructive", disabled: busy, onClick: () => { const choice = confirmation; if (!choice)
101
+ return; void perform(() => choice.action === "purge" ? benchmarkService.purge() : benchmarkService.deleteRun(choice.id)).then(() => { setConfirmation(undefined); if (choice.id === runId)
102
+ selectRun(null); }).catch(() => undefined); }, children: purge ? "Purge history" : "Delete run" })] })] }) })] });
103
+ }
@@ -0,0 +1,8 @@
1
+ import type { RunDetail } from "../types";
2
+ export declare function BenchmarkRunDetail({ detail, back, cancel, busy }: {
3
+ detail: RunDetail;
4
+ back: () => void;
5
+ cancel: (id: string) => void;
6
+ busy: boolean;
7
+ }): import("react").JSX.Element;
8
+ //# sourceMappingURL=BenchmarkRunDetail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenchmarkRunDetail.d.ts","sourceRoot":"","sources":["../../src/components/BenchmarkRunDetail.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAiB1C,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,+BAkEtJ"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, Button, SettingsCard, Tooltip, TooltipContent, TooltipTrigger } from "@parhelia/core";
3
+ import { AlertCircle, ArrowLeft, Gauge, Info, ListChecks, Loader2, MessageSquare, Square } from "lucide-react";
4
+ import { agentLink } from "../agentLink";
5
+ import { cost, count, duration, parseGraderReport, parseJson, percent } from "../format";
6
+ import { RunStatusBadge } from "./RunStatusBadge";
7
+ import { TaskChecksList } from "./TaskChecksList";
8
+ const efficiencyExplanation = "Points for staying within tool-call and known-cost budgets: 100% at or below budget, decreasing linearly to 0% at twice the budget. A task must pass at least one work check worth points to earn efficiency points. Unknown-cost checks are excluded; — means no efficiency checks were evaluated.";
9
+ const correctnessExplanation = "Percentage of work and preservation points earned. A critical check failure or safety violation makes that task’s correctness zero. Efficiency and judge points are separate.";
10
+ function Stat({ label, value, hint, explanation }) {
11
+ return _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("div", { role: "group", "aria-label": `${label}: ${value}`, tabIndex: 0, className: "bg-neutral-grey-5 focus-visible:ring-ring cursor-help rounded p-3 outline-none focus-visible:ring-2", children: [_jsxs("dt", { className: "text-neutral-grey-50 flex items-center gap-1.5 text-xs font-medium", children: [label, _jsx(Info, { "aria-hidden": "true", className: "h-3.5 w-3.5 shrink-0", strokeWidth: 1.5 })] }), _jsx("dd", { className: "text-neutral-grey-100 mt-1 text-base font-medium tabular-nums", children: value }), hint && _jsx("dd", { className: "text-neutral-grey-50 mt-0.5 text-xs", children: hint })] }) }), _jsx(TooltipContent, { className: "max-w-xs", sideOffset: 6, children: explanation })] });
12
+ }
13
+ export function BenchmarkRunDetail({ detail, back, cancel, busy }) {
14
+ const run = detail.run;
15
+ if (!run)
16
+ return _jsxs(Alert, { variant: "warning", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsxs(AlertDescription, { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsx("span", { children: "This run no longer exists." }), _jsx(Button, { size: "sm", variant: "outline", onClick: back, children: "Back to runs" })] })] });
17
+ const tokens = run.inputTokens + run.outputTokens + run.cachedTokens + run.cacheWriteTokens;
18
+ const completed = detail.tasks.filter(t => t.status === "Completed").length;
19
+ const active = run.status === "Running" || run.status === "Queued";
20
+ return _jsxs("div", { "data-testid": "benchmark-run-detail", className: "space-y-4", children: [_jsx("div", { children: _jsxs(Button, { variant: "ghost", size: "sm", className: "text-neutral-grey-50 hover:text-neutral-grey-100 -ml-2", onClick: back, children: [_jsx(ArrowLeft, { strokeWidth: 1.5 }), "Back to runs"] }) }), _jsx(SettingsCard, { icon: _jsx(Gauge, { className: "h-5 w-5", strokeWidth: 1 }), title: _jsxs("span", { className: "flex flex-wrap items-center gap-2", children: [run.modelName, _jsx(RunStatusBadge, { status: run.status })] }), description: `${run.providerName} · Configuration ${run.configLabel} · ${run.isFullSuite ? "Full suite" : "Task subset"} · Started ${new Date(run.createdAt).toLocaleString()}`, children: _jsxs("div", { className: "space-y-4", children: [active && _jsxs("div", { className: "bg-feedback-blue/10 flex flex-wrap items-center justify-between gap-3 rounded p-3", children: [_jsxs("div", { role: "status", className: "text-neutral-grey-100 flex items-center gap-2 text-sm", children: [_jsx(Loader2, { "aria-hidden": "true", className: "h-4 w-4 shrink-0 animate-spin", strokeWidth: 1.5 }), _jsxs("span", { children: [run.cancelRequestedAt ? "Stopping benchmark…" : run.status === "Queued" ? "Waiting for the runner…" : "Benchmark running…", " \u00B7 ", run.tasksCompleted, " / ", run.taskCount, " tasks completed"] })] }), _jsxs(Button, { size: "sm", variant: "destructive", "data-testid": `benchmark-run-cancel-${run.runId}`, disabled: busy || !!run.cancelRequestedAt, onClick: () => cancel(run.runId), children: [_jsx(Square, { "aria-hidden": "true", strokeWidth: 1.5 }), run.cancelRequestedAt ? "Stopping…" : "Stop benchmark"] })] }), _jsxs("dl", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-4", children: [_jsx(Stat, { label: "Correctness", value: percent(run.correctnessPercent), explanation: `Weighted score across graded core tasks. ${correctnessExplanation}` }), _jsx(Stat, { label: "Efficiency", value: percent(run.efficiencyPercent), explanation: `Weighted score across graded core tasks. ${efficiencyExplanation}` }), _jsx(Stat, { label: "Coverage", value: percent(run.coveragePercent), explanation: "Percentage of all possible weighted grading points in this run that have been evaluated. Unfinished tasks and skipped checks, including unknown-cost or unavailable judge checks, reduce coverage. This measures grading coverage, not correctness or the percentage of tasks completed." }), _jsx(Stat, { label: "Full score", value: percent(run.fullScorePercent), hint: run.fullScorePercent == null ? "Available at 100% grading coverage" : undefined, explanation: "Combined weighted correctness, efficiency and judge points across all selected tasks, divided by their evaluated points. Available only at 100% grading coverage; skipped checks can keep it unavailable even after the run completes." }), _jsx(Stat, { label: "Model cost", value: cost(run.totalCost, run.costKnown), explanation: "Total model cost in USD across this run\u2019s tasks, excluding judge cost. Shown as unknown if complete cost information is unavailable." }), _jsx(Stat, { label: "Judge cost", value: cost(run.judgeCost), explanation: "Recorded cost in USD of the separate AI judge used to grade task results. This is separate from model cost; $0.0000 can mean no judge was used." }), _jsx(Stat, { label: "Tokens", value: count(tokens), hint: `${count(run.cachedTokens)} cached`, explanation: "Total recorded model tokens across tasks: input, output, cache reads and cache writes. The cached count shows cache-read tokens. Judge usage is separate." }), _jsx(Stat, { label: "Tool calls", value: count(run.toolExecutions), explanation: "Total recorded tool calls across this run\u2019s tasks, including read and write operations. Each task\u2019s tool-call budget contributes to its efficiency score." }), _jsx(Stat, { label: "Duration", value: duration(run.wallDurationMs), explanation: "Elapsed wall-clock time from the run\u2019s start until it ends, or until the latest update while running. Includes task setup, execution, grading and cleanup; time queued before starting is excluded." }), _jsx(Stat, { label: "Safety violations", value: count(run.safetyViolations), explanation: "Total recorded safety violations across tasks, such as attempts to modify content outside the permitted benchmark scope. A safety violation makes the affected task\u2019s correctness zero." })] }), run.errorMessage && _jsxs(Alert, { variant: "destructive", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx(AlertDescription, { children: run.errorMessage })] })] }) }), _jsx(SettingsCard, { icon: _jsx(ListChecks, { className: "h-5 w-5", strokeWidth: 1 }), title: "Tasks", description: `${completed} of ${run.taskCount || detail.tasks.length} tasks completed`, children: !detail.tasks.length ? _jsx("p", { className: "text-neutral-grey-50 text-sm", children: "No task results yet." }) : _jsx(Accordion, { type: "multiple", className: "-mt-2", children: detail.tasks.map(t => _jsxs(AccordionItem, { value: t.taskKey, "data-testid": `benchmark-task-row-${t.taskKey}`, className: "border-border-default last:border-b-0", children: [_jsx(AccordionTrigger, { className: "py-3 hover:no-underline", children: _jsxs("span", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1", children: [_jsx("span", { className: "text-neutral-grey-100 text-sm font-medium", children: t.taskTitle }), _jsx(RunStatusBadge, { status: t.status }), _jsxs("span", { className: "text-neutral-grey-50 hidden text-xs md:inline", children: [cost(t.cost, t.costKnown), " \u00B7 ", count(t.toolCalls), " tool calls \u00B7 ", duration(t.wallDurationMs)] }), _jsx("span", { className: "text-neutral-grey-100 ml-auto text-sm font-medium tabular-nums", children: percent(t.correctnessPercent) })] }) }), _jsx(AccordionContent, { children: _jsxs("div", { className: "space-y-4 pb-3", children: [_jsxs("dl", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-4", children: [_jsx(Stat, { label: "Correctness", value: percent(t.correctnessPercent), explanation: correctnessExplanation }), _jsx(Stat, { label: "Efficiency", value: percent(t.efficiencyPercent), explanation: efficiencyExplanation }), _jsx(Stat, { label: "Cost", value: cost(t.cost, t.costKnown), hint: t.judgeCost ? `${cost(t.judgeCost)} judge` : undefined, explanation: "Model cost in USD for this task, excluding judge cost. Any judge cost is shown separately below. Shown as unknown if complete model cost information is unavailable." }), _jsx(Stat, { label: "Tool calls", value: `${count(t.toolCalls)} · ${duration(t.wallDurationMs)}`, explanation: "Recorded tool calls for this task, followed by its elapsed wall-clock duration. Tool calls count against the task\u2019s efficiency budget; duration is reported separately and does not affect that score." })] }), t.skipReason && _jsxs(Alert, { variant: "info", children: [_jsx(Info, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx(AlertDescription, { children: t.skipReason })] }), t.errorMessage && _jsxs(Alert, { variant: "destructive", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx(AlertDescription, { children: t.errorMessage })] }), t.keptUntil && _jsxs("p", { className: "text-neutral-grey-50 text-xs", children: ["Content copy retained until ", new Date(t.keptUntil).toLocaleString(), "."] }), _jsx(TaskChecksList, { report: parseGraderReport(t.graderReportJson) }), _jsxs("details", { children: [_jsx("summary", { className: "text-neutral-grey-50 hover:text-neutral-grey-100 cursor-pointer text-xs font-medium select-none", children: "Task diagnostics" }), _jsx("dl", { className: "mt-2", children: _jsx(Stat, { label: "Shutdown", value: t.agentId ? (t.shutdownState === "None" ? "Pending" : t.shutdownState) : "Not executed", explanation: "Whether the task\u2019s agent has stopped. Pending: shutdown has not been requested. Requested: waiting for confirmation. Confirmed: the agent has stopped. Unconfirmed: shutdown could not be verified. Not executed: no agent was created." }) }), t.auditJson && _jsxs("div", { className: "mt-3", children: [_jsx("p", { className: "text-neutral-grey-50 text-xs font-medium", children: "Mutation and tool audit" }), _jsx("pre", { className: "bg-neutral-grey-5 text-neutral-grey-100 mt-2 max-h-80 overflow-auto rounded p-3 font-mono text-xs whitespace-pre-wrap", children: JSON.stringify(parseJson(t.auditJson) ?? t.auditJson, null, 2) })] })] }), t.agentId && _jsx("div", { children: _jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsxs("a", { "data-testid": `benchmark-task-open-agent-${t.taskKey}`, href: agentLink(t.agentId), children: [_jsx(MessageSquare, { strokeWidth: 1.5 }), "Open agent conversation"] }) }) })] }) })] }, t.taskKey)) }) })] });
21
+ }
@@ -0,0 +1,10 @@
1
+ import type { BenchmarkRun } from "../types";
2
+ export declare function BenchmarkRunsList({ runs, total, busy, open, act, more }: {
3
+ runs: BenchmarkRun[];
4
+ total: number;
5
+ busy: boolean;
6
+ open: (id: string) => void;
7
+ act: (action: "cancel" | "deleteRun" | "recover", id: string) => void;
8
+ more: () => void;
9
+ }): import("react").JSX.Element;
10
+ //# sourceMappingURL=BenchmarkRunsList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenchmarkRunsList.d.ts","sourceRoot":"","sources":["../../src/components/BenchmarkRunsList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,+BAcpP"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Badge, Button, SimpleTable } from "@parhelia/core";
3
+ import { cost, duration, percent } from "../format";
4
+ import { RunStatusBadge } from "./RunStatusBadge";
5
+ const numeric = "text-neutral-grey-100 tabular-nums";
6
+ export function BenchmarkRunsList({ runs, total, busy, open, act, more }) {
7
+ if (!runs.length)
8
+ return _jsx("p", { "data-testid": "benchmark-runs-table", className: "text-neutral-grey-50 py-10 text-center text-sm", children: "No benchmark runs yet. Start one from the button above." });
9
+ return _jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "overflow-x-auto", children: _jsx(SimpleTable, { "data-testid": "benchmark-runs-table", items: runs, rowKey: r => r.runId, columns: [
10
+ { header: "Model / configuration", body: r => _jsxs("div", { children: [_jsx(Button, { variant: "link", size: "sm", className: "h-auto p-0 text-sm font-medium", onClick: () => open(r.runId), children: r.modelName }), _jsxs("p", { className: "text-neutral-grey-50", children: [r.providerName, " \u00B7 ", r.configLabel] })] }) },
11
+ { header: "Started", body: r => _jsx("span", { className: "text-neutral-grey-100", children: new Date(r.createdAt).toLocaleString() }), className: "whitespace-nowrap" },
12
+ { header: "Status", body: r => _jsxs("div", { className: "flex flex-wrap gap-1", children: [_jsx(RunStatusBadge, { status: r.status }), !r.isFullSuite && _jsx(Badge, { variant: "secondary", children: "Subset" })] }) },
13
+ { header: "Tasks", body: r => _jsxs("span", { className: numeric, children: [r.tasksCompleted, " / ", r.taskCount] }), align: "right", className: "whitespace-nowrap" },
14
+ { header: "Correctness", body: r => _jsx("span", { className: `${numeric} font-medium`, children: percent(r.correctnessPercent) }), align: "right", className: "whitespace-nowrap" },
15
+ { header: "Cost", body: r => _jsx("span", { className: numeric, children: cost(r.totalCost, r.costKnown) }), align: "right", className: "whitespace-nowrap" },
16
+ { header: "Duration", body: r => _jsx("span", { className: numeric, children: duration(r.wallDurationMs) }), align: "right", className: "whitespace-nowrap" },
17
+ { header: "", body: r => _jsx("div", { className: "flex justify-end gap-2", children: ["Queued", "Running"].includes(r.status) ? _jsx(Button, { size: "xs", variant: "destructive", "data-testid": `benchmark-run-cancel-${r.runId}`, disabled: busy || !!r.cancelRequestedAt, onClick: () => act("cancel", r.runId), children: r.cancelRequestedAt ? "Stopping…" : "Cancel" }) : r.status === "NeedsRecovery" ? _jsx(Button, { size: "xs", "data-testid": `benchmark-run-recover-${r.runId}`, disabled: busy, onClick: () => act("recover", r.runId), children: "Recover" }) : _jsx(Button, { size: "xs", variant: "outline", "data-testid": `benchmark-run-delete-${r.runId}`, disabled: busy, onClick: () => act("deleteRun", r.runId), children: "Delete" }) }), align: "right" },
18
+ ] }) }), runs.length < total && _jsx("div", { className: "flex justify-center", children: _jsxs(Button, { size: "sm", variant: "outline", disabled: busy, onClick: more, children: ["Load more (", total - runs.length, " remaining)"] }) })] });
19
+ }
@@ -0,0 +1,5 @@
1
+ import type { BenchmarkTask } from "../types";
2
+ export declare function BenchmarkTasksList({ tasks }: {
3
+ tasks: BenchmarkTask[];
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=BenchmarkTasksList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BenchmarkTasksList.d.ts","sourceRoot":"","sources":["../../src/components/BenchmarkTasksList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,+BA0BvE"}
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Badge } from "@parhelia/core";
3
+ import { cost, duration } from "../format";
4
+ export function BenchmarkTasksList({ tasks }) {
5
+ if (!tasks.length)
6
+ return _jsx("p", { className: "text-neutral-grey-50 py-10 text-center text-sm", children: "No tasks are defined in the current suite." });
7
+ return _jsx("div", { className: "space-y-4", children: _jsx(Accordion, { type: "multiple", className: "-mt-2", children: tasks.map(t => _jsxs(AccordionItem, { value: t.key, className: "border-border-default last:border-b-0", children: [_jsx(AccordionTrigger, { className: "py-3 hover:no-underline", children: _jsxs("span", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1", children: [_jsx("span", { className: "text-neutral-grey-100 text-sm font-medium", children: t.title }), _jsx(Badge, { variant: "secondary", children: t.isCore ? "Core" : "Vision" }), t.requiresJudge && _jsx(Badge, { variant: "outline", children: "Optional judge" }), _jsx("span", { className: "text-neutral-grey-50 ml-auto hidden text-xs md:inline", children: t.category })] }) }), _jsx(AccordionContent, { children: _jsxs("div", { className: "space-y-3 pb-3", children: [t.description && t.description !== t.category && _jsx("p", { className: "text-neutral-grey-100 text-sm", children: t.description }), _jsxs("dl", { className: "grid gap-3 sm:grid-cols-3", children: [_jsxs("div", { className: "bg-neutral-grey-5 rounded p-3", children: [_jsx("dt", { className: "text-neutral-grey-50 text-xs font-medium", children: "Tool-call budget" }), _jsxs("dd", { className: "text-neutral-grey-100 mt-1 text-sm font-medium tabular-nums", children: [t.toolCallBudget, " calls"] })] }), _jsxs("div", { className: "bg-neutral-grey-5 rounded p-3", children: [_jsx("dt", { className: "text-neutral-grey-50 text-xs font-medium", children: "Cost budget" }), _jsx("dd", { className: "text-neutral-grey-100 mt-1 text-sm font-medium tabular-nums", children: cost(t.costBudgetUsd) })] }), _jsxs("div", { className: "bg-neutral-grey-5 rounded p-3", children: [_jsx("dt", { className: "text-neutral-grey-50 text-xs font-medium", children: "Timeout" }), _jsx("dd", { className: "text-neutral-grey-100 mt-1 text-sm font-medium tabular-nums", children: duration(t.timeoutSeconds * 1000) })] })] }), _jsxs("div", { children: [_jsx("h4", { className: "text-neutral-grey-50 mb-1.5 text-xs font-medium tracking-wide uppercase", children: "Prompt" }), _jsx("p", { className: "bg-neutral-grey-5 text-neutral-grey-100 rounded p-3 text-sm whitespace-pre-wrap", children: t.prompt })] })] }) })] }, t.key)) }) });
8
+ }
@@ -0,0 +1,7 @@
1
+ import type { BenchmarkStatus } from "../types";
2
+ export declare function NotPreparedState({ status, busy, prepare }: {
3
+ status: BenchmarkStatus;
4
+ busy: boolean;
5
+ prepare: () => void;
6
+ }): import("react").JSX.Element;
7
+ //# sourceMappingURL=NotPreparedState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotPreparedState.d.ts","sourceRoot":"","sources":["../../src/components/NotPreparedState.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,+BAS1H"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Alert, AlertDescription, Button, SettingsCard } from "@parhelia/core";
3
+ import { AlertCircle, ShieldCheck } from "lucide-react";
4
+ export function NotPreparedState({ status, busy, prepare }) {
5
+ return _jsx("div", { "data-testid": "benchmark-not-prepared", children: _jsx(SettingsCard, { icon: _jsx(ShieldCheck, { className: "h-5 w-5", strokeWidth: 1 }), title: "Prepare the benchmark environment", description: "Create the restricted service account, permissions, quota and folders used for isolated task copies.", children: _jsxs("div", { className: "space-y-4", children: [status.prepared.error && _jsxs(Alert, { variant: "destructive", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx(AlertDescription, { children: status.prepared.error })] }), !status.migrationsApplied && _jsxs(Alert, { variant: "warning", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsxs(AlertDescription, { children: ["Missing database tables: ", status.missingTables.join(", "), ". Apply the module migrations before preparing."] })] }), _jsxs("p", { className: "text-neutral-grey-50 text-sm", children: ["Preparation runs once per environment", status.runnerUser ? ` and creates the runner user ${status.runnerUser}` : "", ". Existing content is not touched."] }), _jsx("div", { children: _jsx(Button, { "data-testid": "benchmark-prepare-button", disabled: busy || !status.migrationsApplied, onClick: prepare, children: "Prepare environment" }) })] }) }) });
6
+ }
@@ -0,0 +1,7 @@
1
+ import type { BenchmarkTaskResult } from "../types";
2
+ export declare function RecoveryBanner({ tasks, busy, recover }: {
3
+ tasks: BenchmarkTaskResult[];
4
+ busy: boolean;
5
+ recover: () => void;
6
+ }): import("react").JSX.Element | null;
7
+ //# sourceMappingURL=RecoveryBanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecoveryBanner.d.ts","sourceRoot":"","sources":["../../src/components/RecoveryBanner.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,UAAU,CAAC;AAOnE,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,sCAe5H"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Alert, AlertDescription, AlertTitle, Button } from "@parhelia/core";
3
+ import { AlertTriangle } from "lucide-react";
4
+ const recoveryReasons = {
5
+ None: "Agent still needs to be stopped",
6
+ Requested: "Waiting for the agent to stop",
7
+ Unconfirmed: "Agent could not be confirmed stopped",
8
+ Confirmed: "Agent stopped; test data cleanup required",
9
+ };
10
+ export function RecoveryBanner({ tasks, busy, recover }) {
11
+ if (!tasks.length)
12
+ return null;
13
+ return _jsxs(Alert, { "data-testid": "benchmark-recovery-banner", variant: "warning", role: "status", children: [_jsx(AlertTriangle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsxs("div", { className: "flex flex-wrap items-start justify-between gap-x-6 gap-y-3", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs(AlertTitle, { children: [tasks.length, " ", tasks.length === 1 ? "task needs" : "tasks need", " recovery"] }), _jsxs(AlertDescription, { className: "text-neutral-grey-50", children: [_jsx("p", { children: "Recover these tasks to safely stop any remaining agents and clean up their test data before starting another benchmark." }), _jsx("ul", { className: "mt-2 space-y-0.5", children: tasks.map(t => _jsxs("li", { className: "text-neutral-grey-100", children: [t.taskTitle, " ", _jsxs("span", { className: "text-neutral-grey-50", children: ["\u00B7 ", recoveryReasons[t.shutdownState]] })] }, t.taskResultId)) })] })] }), _jsx(Button, { size: "sm", disabled: busy, onClick: recover, children: "Recover now" })] })] });
14
+ }
@@ -0,0 +1,5 @@
1
+ export declare function RunStatusBadge({ status, className }: {
2
+ status: string;
3
+ className?: string;
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=RunStatusBadge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunStatusBadge.d.ts","sourceRoot":"","sources":["../../src/components/RunStatusBadge.tsx"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,+BAG3F"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Badge, cn } from "@parhelia/core";
3
+ const labels = { NeedsRecovery: "Needs recovery", TimedOut: "Timed out", CostLimit: "Cost limit", TokenLimit: "Token limit" };
4
+ const failed = ["Failed", "NeedsRecovery", "Unconfirmed", "TimedOut", "CostLimit", "TokenLimit"];
5
+ const active = ["Running", "Queued"];
6
+ export function RunStatusBadge({ status, className }) {
7
+ const variant = failed.includes(status) ? "destructive" : active.includes(status) ? "default" : "secondary";
8
+ return _jsx(Badge, { variant: variant, className: cn(status === "Completed" && "bg-feedback-green-light text-feedback-green", className), children: labels[status] ?? status });
9
+ }
@@ -0,0 +1,11 @@
1
+ import type { BenchmarkModel, StartRequest } from "../types";
2
+ export declare function VisionNote({ model }: {
3
+ model: BenchmarkModel;
4
+ }): import("react").JSX.Element;
5
+ export declare function StartBenchmarkDialog({ open, onOpenChange, start, busy }: {
6
+ open: boolean;
7
+ onOpenChange: (open: boolean) => void;
8
+ start: (request: StartRequest) => Promise<void>;
9
+ busy: boolean;
10
+ }): import("react").JSX.Element;
11
+ //# sourceMappingURL=StartBenchmarkDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartBenchmarkDialog.d.ts","sourceRoot":"","sources":["../../src/components/StartBenchmarkDialog.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAiB,YAAY,EAAE,MAAM,UAAU,CAAC;AAc5E,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,+BAU9D;AAED,wBAAgB,oBAAoB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,+BAmGjM"}
@@ -0,0 +1,48 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { Alert, AlertDescription, Button, Checkbox, Dialog, DialogContent, DialogFooter, Input, Label, MultiSwitchButton, Select, StyledDialogTitle, Switch } from "@parhelia/core";
4
+ import { AlertCircle, CircleHelp, Gauge, Image, ImageOff } from "lucide-react";
5
+ import { benchmarkService } from "../services/benchmarkService";
6
+ const runPresets = ["1", "2", "3", "5", "10"];
7
+ function formatUsd(value) { return value == null ? "–" : `$${value}`; }
8
+ function PriceTile({ label, value }) {
9
+ return _jsxs("div", { className: "min-w-0 px-4 py-3", children: [_jsx("p", { className: "text-neutral-grey-50 text-2xs font-medium tracking-wide uppercase", children: label }), _jsx("p", { className: "text-neutral-grey-100 mt-0.5 truncate text-base font-semibold tabular-nums", children: formatUsd(value) })] });
10
+ }
11
+ export function VisionNote({ model }) {
12
+ const state = model.supportsImageInput;
13
+ const Icon = state === true ? Image : state === false ? ImageOff : CircleHelp;
14
+ const text = state === true ? "Accepts image input. The hero image task will run."
15
+ : state === false ? "Does not accept images. The hero image task will be skipped."
16
+ : "Image input capability is not recorded in Parhelia. The hero image task will still run.";
17
+ return _jsxs("div", { className: "text-neutral-grey-50 flex items-start gap-2 text-xs", children: [_jsx(Icon, { className: "mt-px h-3.5 w-3.5 shrink-0", strokeWidth: 1.5 }), _jsx("p", { children: text })] });
18
+ }
19
+ export function StartBenchmarkDialog({ open, onOpenChange, start, busy }) {
20
+ const [models, setModels] = useState([]);
21
+ const [tasks, setTasks] = useState([]);
22
+ const [modelId, setModelId] = useState("");
23
+ const [runCount, setRunCount] = useState(1);
24
+ const [subset, setSubset] = useState(false);
25
+ const [selected, setSelected] = useState([]);
26
+ const [allowUnknown, setAllowUnknown] = useState(false);
27
+ const [error, setError] = useState();
28
+ useEffect(() => {
29
+ if (!open)
30
+ return;
31
+ let alive = true;
32
+ Promise.all([benchmarkService.models(), benchmarkService.tasks()]).then(([m, t]) => { if (alive) {
33
+ setModels(m.models);
34
+ setTasks(t.tasks);
35
+ setSelected(t.tasks.map(x => x.id));
36
+ setError(undefined);
37
+ } }).catch(e => { if (alive)
38
+ setError(String(e)); });
39
+ return () => { alive = false; };
40
+ }, [open]);
41
+ const model = models.find(m => m.id === modelId);
42
+ const valid = !!model && (model.hasPricing || allowUnknown) && runCount >= 1 && runCount <= 10 && Number.isInteger(runCount) && (!subset || selected.length > 0);
43
+ const pricing = model?.pricing;
44
+ const preset = runPresets.find(p => Number(p) === runCount);
45
+ const taskCount = subset ? selected.length : tasks.length;
46
+ const summary = model ? `${taskCount} task${taskCount === 1 ? "" : "s"} × ${runCount} run${runCount === 1 ? "" : "s"}` : undefined;
47
+ return _jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-testid": "benchmark-start-dialog", className: "flex max-h-[85vh] max-w-xl flex-col gap-0 overflow-hidden p-0", children: [_jsx(StyledDialogTitle, { icon: _jsx(Gauge, { strokeWidth: 1 }), title: "Start benchmark", subtitle: "Every task runs on a fresh content and media copy with the same model and configuration" }), _jsxs("div", { className: "min-h-0 flex-1 space-y-6 overflow-y-auto px-6 py-5", children: [error && _jsxs(Alert, { variant: "destructive", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx(AlertDescription, { children: error })] }), _jsxs("section", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "benchmark-model", children: "Model" }), _jsx(Select, { id: "benchmark-model", "data-testid": "benchmark-start-model-select", searchable: true, placeholder: "Choose a model", value: modelId, options: models.map(m => ({ value: m.id, label: `${m.name} · ${m.providerName}`, description: m.hasPricing ? "Pricing available" : "Cost unknown" })), onValueChange: id => { setModelId(id); setAllowUnknown(false); } }), model && _jsxs("div", { className: "border-border-default overflow-hidden rounded-lg border", children: [model.hasPricing ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "border-border-default flex items-center justify-between border-b px-4 py-2", children: [_jsx("p", { className: "text-neutral-grey-100 text-xs font-medium", children: "Pricing" }), _jsx("p", { className: "text-neutral-grey-50 text-xs", children: "USD per million tokens" })] }), _jsxs("div", { className: "divide-border-default grid grid-cols-3 divide-x", children: [_jsx(PriceTile, { label: "Input", value: pricing?.inputCostPer1MTokens }), _jsx(PriceTile, { label: "Output", value: pricing?.outputCostPer1MTokens }), _jsx(PriceTile, { label: "Cached input", value: pricing?.cachedInputCostPer1MTokens })] })] }) : _jsxs("div", { className: "space-y-3 px-4 py-3", children: [_jsxs("div", { className: "text-neutral-grey-100 flex items-start gap-2 text-xs", children: [_jsx(AlertCircle, { className: "text-feedback-orange mt-px h-3.5 w-3.5 shrink-0", strokeWidth: 1.5 }), _jsx("p", { children: "No pricing is configured for this model, so cost cannot be tracked. Token and time limits still apply." })] }), _jsxs("label", { className: "text-neutral-grey-100 flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { "data-testid": "benchmark-start-allow-unknown-cost", checked: allowUnknown, onCheckedChange: v => setAllowUnknown(v === true) }), "Run without cost tracking"] })] }), _jsx("div", { className: "border-border-default bg-neutral-grey-5 border-t px-4 py-2.5", children: _jsx(VisionNote, { model: model }) })] })] }), _jsxs("section", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "benchmark-count", children: "Runs" }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(MultiSwitchButton, { value: preset ?? "", options: runPresets.map(value => ({ value, label: value })), onValueChange: value => setRunCount(Number(value)), className: "w-56 shrink-0", "aria-label": "Number of runs", testId: "benchmark-start-run-presets" }), _jsx("span", { className: "text-neutral-grey-50 text-xs", children: "or" }), _jsx(Input, { id: "benchmark-count", className: "w-16 text-center tabular-nums", type: "number", min: 1, max: 10, value: runCount, onChange: e => setRunCount(Number(e.target.value)), "aria-label": "Custom number of runs" })] }), _jsx("p", { className: "text-neutral-grey-50 text-xs", children: "Between 1 and 10. Repeated runs improve the leaderboard median." })] }), _jsxs("section", { className: "border-border-default overflow-hidden rounded-lg border", children: [_jsxs("label", { className: "flex cursor-pointer items-center justify-between gap-4 px-4 py-3", children: [_jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "text-neutral-grey-100 block text-sm font-medium", children: "Choose a task subset" }), _jsx("span", { className: "text-neutral-grey-50 block text-xs", children: "Run only selected tasks. Subset runs are excluded from the leaderboard." })] }), _jsx(Switch, { checked: subset, onCheckedChange: setSubset, "data-testid": "benchmark-start-subset" })] }), subset && _jsxs("div", { className: "border-border-default bg-neutral-grey-5 space-y-3 border-t px-4 py-3", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("p", { className: "text-neutral-grey-50 text-xs tabular-nums", children: [selected.length, " of ", tasks.length, " selected"] }), _jsxs("div", { className: "flex gap-1", children: [_jsx(Button, { size: "xs", variant: "ghost", onClick: () => setSelected(tasks.map(t => t.id)), disabled: selected.length === tasks.length, children: "Select all" }), _jsx(Button, { size: "xs", variant: "ghost", onClick: () => setSelected([]), disabled: !selected.length, children: "Clear" })] })] }), _jsxs("table", { "aria-label": "Task subset", className: "w-full table-fixed border-collapse text-left", children: [_jsx("thead", { className: "text-neutral-grey-50 text-xs", children: _jsxs("tr", { className: "border-border-default border-b", children: [_jsx("th", { scope: "col", className: "w-1/2 px-2 py-2 font-medium", children: "Task" }), _jsx("th", { scope: "col", className: "px-2 py-2 font-medium", children: "Category" })] }) }), _jsx("tbody", { children: tasks.map(t => _jsxs("tr", { className: "border-border-default border-b last:border-b-0", children: [_jsx("td", { className: "px-2 py-2 align-top", children: _jsxs("label", { className: "text-neutral-grey-100 flex cursor-pointer items-start gap-2 text-sm", children: [_jsx(Checkbox, { className: "mt-0.5 shrink-0", checked: selected.includes(t.id), onCheckedChange: v => setSelected(old => v === true ? [...old, t.id] : old.filter(id => id !== t.id)) }), _jsx("span", { className: "min-w-0 break-words", children: t.title })] }) }), _jsxs("td", { className: "text-neutral-grey-50 break-words px-2 py-2 align-top text-xs", children: [t.category, t.requiresVision ? " · vision" : "", t.isCore ? "" : " · optional"] })] }, t.id)) })] })] })] })] }), _jsxs(DialogFooter, { className: "border-border-default shrink-0 items-center border-t px-6 py-4 sm:justify-between", children: [_jsx("p", { className: "text-neutral-grey-50 text-xs tabular-nums", children: summary }), _jsxs("div", { className: "flex flex-col-reverse gap-3 sm:flex-row", children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), disabled: busy, children: "Cancel" }), _jsx(Button, { "data-testid": "benchmark-start-submit", disabled: !valid || busy, onClick: () => { setError(undefined); void start({ modelItemId: modelId, runCount, taskIds: subset ? selected : undefined, allowUnknownCost: allowUnknown }).catch(e => setError(String(e))); }, children: busy ? "Starting…" : "Start benchmark" })] })] })] }) });
48
+ }
@@ -0,0 +1,5 @@
1
+ import type { GraderReport } from "../types";
2
+ export declare function TaskChecksList({ report }: {
3
+ report?: GraderReport;
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=TaskChecksList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskChecksList.d.ts","sourceRoot":"","sources":["../../src/components/TaskChecksList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,UAAU,CAAC;AAQxD,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAE,+BAkBnE"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Alert, AlertDescription, Badge } from "@parhelia/core";
3
+ import { AlertCircle, CheckCircle2, MinusCircle, XCircle } from "lucide-react";
4
+ const groups = [{ key: "work", label: "Work" }, { key: "preservation", label: "Preservation" }, { key: "efficiency", label: "Efficiency" }, { key: "judge", label: "Judge" }];
5
+ const points = (value) => Number.isInteger(value) ? String(value) : value.toFixed(1);
6
+ function CheckIcon({ check }) {
7
+ if (check.skipped)
8
+ return _jsx(MinusCircle, { "aria-label": "Skipped", className: "text-neutral-grey-50 mt-0.5 h-4 w-4 shrink-0", strokeWidth: 1.5 });
9
+ if (check.passed)
10
+ return _jsx(CheckCircle2, { "aria-label": "Passed", className: "text-feedback-green mt-0.5 h-4 w-4 shrink-0", strokeWidth: 1.5 });
11
+ return _jsx(XCircle, { "aria-label": "Failed", className: "text-feedback-red mt-0.5 h-4 w-4 shrink-0", strokeWidth: 1.5 });
12
+ }
13
+ export function TaskChecksList({ report }) {
14
+ if (!report)
15
+ return _jsx("p", { className: "text-neutral-grey-50 text-sm", children: "Grading is not available for this task." });
16
+ return _jsxs("div", { className: "space-y-4", children: [report.criticalFailed && _jsxs(Alert, { variant: "destructive", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx(AlertDescription, { children: "A critical check failed. Correctness is zero." })] }), groups.map(group => {
17
+ const checks = report.checks.filter(c => c.class === group.key);
18
+ if (!checks.length)
19
+ return null;
20
+ return _jsxs("section", { children: [_jsx("h4", { className: "text-neutral-grey-50 mb-1.5 text-xs font-medium tracking-wide uppercase", children: group.label }), _jsx("ul", { className: "border-border-default divide-border-default divide-y rounded border", children: checks.map(c => _jsxs("li", { "data-testid": `benchmark-task-check-${c.key}`, className: "flex items-start gap-3 px-3 py-2 text-sm", children: [_jsx(CheckIcon, { check: c }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "text-neutral-grey-100", children: c.description }), c.reason && _jsx("span", { className: "text-neutral-grey-50 mt-0.5 block text-xs", children: c.reason })] }), c.critical && _jsx(Badge, { variant: "outline", size: "sm", children: "Critical" }), _jsxs("span", { className: "text-neutral-grey-50 w-16 shrink-0 text-right text-xs whitespace-nowrap tabular-nums", children: [points(c.awarded), " / ", points(c.points)] })] }, c.key)) })] }, group.key);
21
+ })] });
22
+ }
@@ -0,0 +1,7 @@
1
+ export declare const percent: (value?: number | null) => string;
2
+ export declare const cost: (value?: number | null, known?: boolean) => string;
3
+ export declare const count: (value?: number) => string;
4
+ export declare const duration: (milliseconds?: number) => string;
5
+ export declare function parseJson<T>(value?: string): T | undefined;
6
+ export declare function parseGraderReport(value?: string): import("./types").GraderReport | undefined;
7
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAY,MAAM,GAAG,IAAI,WAAiD,CAAC;AAC/F,eAAO,MAAM,IAAI,WAAY,MAAM,GAAG,IAAI,4BAAoF,CAAC;AAC/H,eAAO,MAAM,KAAK,4BAAwC,CAAC;AAC3D,eAAO,MAAM,QAAQ,mCAA6K,CAAC;AACnM,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAA2F;AACtJ,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,SAAS,EAAE,YAAY,GAAG,SAAS,CAS5F"}
package/dist/format.js ADDED
@@ -0,0 +1,22 @@
1
+ export const percent = (value) => value == null ? "—" : `${value.toFixed(1)}%`;
2
+ export const cost = (value, known = true) => !known || value == null ? "Cost unknown" : `$${value.toFixed(4)}`;
3
+ export const count = (value = 0) => value.toLocaleString();
4
+ export const duration = (milliseconds = 0) => milliseconds < 60_000 ? `${Math.round(milliseconds / 1000)}s` : `${Math.floor(milliseconds / 60_000)}m ${Math.round(milliseconds % 60_000 / 1000)}s`;
5
+ export function parseJson(value) { try {
6
+ return value ? JSON.parse(value) : undefined;
7
+ }
8
+ catch {
9
+ return undefined;
10
+ } }
11
+ export function parseGraderReport(value) {
12
+ const raw = parseJson(value);
13
+ if (!raw)
14
+ return undefined;
15
+ // Stored report JSON uses .NET property casing; the surrounding API uses camelCase.
16
+ const camel = (record) => Object.fromEntries(Object.entries(record).map(([key, entry]) => [key.charAt(0).toLowerCase() + key.slice(1), entry]));
17
+ const report = camel(raw);
18
+ if (!Array.isArray(report.checks))
19
+ return undefined;
20
+ report.checks = report.checks.map(check => camel(check));
21
+ return report;
22
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Uses the editor's authenticated transport, including its SSE fallback. Polling is only a safety
3
+ * net for missed socket messages: frequent while a run is active, sparse otherwise.
4
+ */
5
+ export declare function useBenchmarkRunUpdates(refresh: () => void, active?: boolean): void;
6
+ //# sourceMappingURL=useBenchmarkRunUpdates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBenchmarkRunUpdates.d.ts","sourceRoot":"","sources":["../../src/hooks/useBenchmarkRunUpdates.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,MAAM,UAAO,QAQxE"}
@@ -0,0 +1,15 @@
1
+ import { useEffect } from "react";
2
+ /**
3
+ * Uses the editor's authenticated transport, including its SSE fallback. Polling is only a safety
4
+ * net for missed socket messages: frequent while a run is active, sparse otherwise.
5
+ */
6
+ export function useBenchmarkRunUpdates(refresh, active = true) {
7
+ useEffect(() => {
8
+ let pending;
9
+ const update = () => { if (!pending)
10
+ pending = setTimeout(() => { pending = undefined; refresh(); }, 200); };
11
+ window.addEventListener("parhelia:benchmark-run-status", update);
12
+ const poll = setInterval(refresh, active ? 5000 : 30000);
13
+ return () => { window.removeEventListener("parhelia:benchmark-run-status", update); clearInterval(poll); clearTimeout(pending); };
14
+ }, [refresh, active]);
15
+ }
@@ -0,0 +1,7 @@
1
+ import type { BenchmarkStatus } from "../types";
2
+ export declare function useBenchmarkStatus(): {
3
+ status: BenchmarkStatus | undefined;
4
+ error: string | undefined;
5
+ refresh: () => Promise<void>;
6
+ };
7
+ //# sourceMappingURL=useBenchmarkStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBenchmarkStatus.d.ts","sourceRoot":"","sources":["../../src/hooks/useBenchmarkStatus.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,wBAAgB,kBAAkB;;;;EAYjC"}
@@ -0,0 +1,31 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ import { benchmarkService } from "../services/benchmarkService";
3
+ import { useBenchmarkRunUpdates } from "./useBenchmarkRunUpdates";
4
+ export function useBenchmarkStatus() {
5
+ const [status, setStatus] = useState();
6
+ const [error, setError] = useState();
7
+ const alive = useRef(false);
8
+ const pending = useRef(false);
9
+ const refresh = useCallback(async () => {
10
+ if (pending.current)
11
+ return;
12
+ pending.current = true;
13
+ try {
14
+ const result = await benchmarkService.status();
15
+ if (alive.current) {
16
+ setStatus(result);
17
+ setError(undefined);
18
+ }
19
+ }
20
+ catch (e) {
21
+ if (alive.current)
22
+ setError(e instanceof Error ? e.message : "Cannot load benchmark status");
23
+ }
24
+ finally {
25
+ pending.current = false;
26
+ }
27
+ }, []);
28
+ useEffect(() => { alive.current = true; const initial = setTimeout(refresh, 0); return () => { clearTimeout(initial); alive.current = false; }; }, [refresh]);
29
+ useBenchmarkRunUpdates(refresh, !!status?.activeRun || !!status?.queuedRuns?.length || !!status?.tasksAwaitingRecovery?.length);
30
+ return { status, error, refresh };
31
+ }
@@ -0,0 +1,2 @@
1
+ export declare function useRunIdParam(): readonly [string | null, (id: string | null) => void];
2
+ //# sourceMappingURL=useRunIdParam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRunIdParam.d.ts","sourceRoot":"","sources":["../../src/hooks/useRunIdParam.ts"],"names":[],"mappings":"AACA,wBAAgB,aAAa,kCAIK,MAAM,GAAG,IAAI,WAE9C"}
@@ -0,0 +1,11 @@
1
+ import { useCallback, useEffect, useState } from "react";
2
+ export function useRunIdParam() {
3
+ const read = () => typeof window === "undefined" ? null : new URL(window.location.href).searchParams.get("benchmarkRunId");
4
+ const [runId, setRunId] = useState(read);
5
+ useEffect(() => { const update = () => setRunId(read()); window.addEventListener("popstate", update); return () => window.removeEventListener("popstate", update); }, []);
6
+ const select = useCallback((id) => { const url = new URL(window.location.href); if (id)
7
+ url.searchParams.set("benchmarkRunId", id);
8
+ else
9
+ url.searchParams.delete("benchmarkRunId"); window.history.pushState(window.history.state, "", url); setRunId(id); }, []);
10
+ return [runId, select];
11
+ }
@@ -0,0 +1,5 @@
1
+ import type { EditorConfiguration } from "@parhelia/core";
2
+ export { BenchmarkPanel } from "./components/BenchmarkPanel";
3
+ export * from "./types";
4
+ export declare function configureBenchmark(configuration: EditorConfiguration): EditorConfiguration;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,cAAc,SAAS,CAAC;AACxB,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,mBAAmB,GAAG,mBAAmB,CAQ1F"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Gauge } from "lucide-react";
3
+ import { BenchmarkPanel } from "./components/BenchmarkPanel";
4
+ export { BenchmarkPanel } from "./components/BenchmarkPanel";
5
+ export * from "./types";
6
+ export function configureBenchmark(configuration) {
7
+ if (configuration.settings.groups.some(g => g.panels.some(p => p.id === "model-benchmark")))
8
+ return configuration;
9
+ const panel = { id: "model-benchmark", title: "Model Benchmark", subtitle: "Compare models on isolated Sitecore editing tasks", icon: _jsx(Gauge, { strokeWidth: 1 }), content: _jsx(BenchmarkPanel, {}), requiresAdministrator: true, requiresModule: "benchmark" };
10
+ const groups = configuration.settings.groups.map(g => ({ ...g, panels: [...g.panels] }));
11
+ const ai = groups.find(g => g.title === "AI");
12
+ if (ai) {
13
+ const quota = ai.panels.findIndex(p => p.id === "ai-quota");
14
+ ai.panels.splice(quota >= 0 ? quota + 1 : ai.panels.length, 0, panel);
15
+ }
16
+ else {
17
+ const about = groups.findIndex(g => g.title === "About");
18
+ groups.splice(about >= 0 ? about : groups.length, 0, { title: "Benchmark", icon: _jsx(Gauge, { strokeWidth: 1 }), panels: [panel] });
19
+ }
20
+ return { ...configuration, settings: { ...configuration.settings, groups } };
21
+ }
@@ -0,0 +1,45 @@
1
+ import { type ExecutionResult } from "@parhelia/core";
2
+ import type { BenchmarkStatus, BenchmarkModel, BenchmarkTask, BenchmarkRun, LeaderboardEntry, RunDetail, StartRequest } from "../types";
3
+ export declare class BenchmarkApiError extends Error {
4
+ readonly status?: number | undefined;
5
+ constructor(message: string, status?: number | undefined);
6
+ }
7
+ export declare function unwrap<T>(request: Promise<ExecutionResult<T>>): Promise<T>;
8
+ export declare const benchmarkService: {
9
+ status: () => Promise<BenchmarkStatus>;
10
+ models: () => Promise<{
11
+ models: BenchmarkModel[];
12
+ }>;
13
+ tasks: () => Promise<{
14
+ tasks: BenchmarkTask[];
15
+ suiteHash: string;
16
+ }>;
17
+ prepare: () => Promise<{
18
+ prepared: boolean;
19
+ messages: string[];
20
+ }>;
21
+ start: (request: StartRequest) => Promise<{
22
+ runIds: string[];
23
+ batchId: string;
24
+ }>;
25
+ cancel: (runId: string) => Promise<unknown>;
26
+ recover: (runId?: string) => Promise<{
27
+ recovered: number;
28
+ pending: number;
29
+ }>;
30
+ runs: (skip?: number) => Promise<{
31
+ runs: BenchmarkRun[];
32
+ total: number;
33
+ }>;
34
+ run: (runId: string) => Promise<RunDetail>;
35
+ deleteRun: (runId: string) => Promise<unknown>;
36
+ purge: () => Promise<{
37
+ deletedRuns: number;
38
+ deletedAgents: number;
39
+ }>;
40
+ leaderboard: () => Promise<{
41
+ entries: LeaderboardEntry[];
42
+ suiteHash: string;
43
+ }>;
44
+ };
45
+ //# sourceMappingURL=benchmarkService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmarkService.d.ts","sourceRoot":"","sources":["../../src/services/benchmarkService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExI,qBAAa,iBAAkB,SAAQ,KAAK;aACG,MAAM,CAAC,EAAE,MAAM;IAA5D,YAAY,OAAO,EAAE,MAAM,EAAkB,MAAM,CAAC,EAAE,MAAM,YAAA,EAAsD;CACnH;AACD,wBAAsB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAIhF;AACD,eAAO,MAAM,gBAAgB;IAC3B,MAAM;IACN,MAAM;gBAA6B,cAAc,EAAE;;IACnD,KAAK;eAA4B,aAAa,EAAE;mBAAa,MAAM;;IACnE,OAAO;kBAAgC,OAAO;kBAAY,MAAM,EAAE;;IAClE,KAAK,YAAY,YAAY;gBAA2B,MAAM,EAAE;iBAAW,MAAM;;IACjF,MAAM,UAAU,MAAM;IACtB,OAAO,WAAW,MAAM;mBAA8B,MAAM;iBAAW,MAAM;;IAC7E,IAAI;cAAmC,YAAY,EAAE;eAAS,MAAM;;IACpE,GAAG,UAAU,MAAM;IACnB,SAAS,UAAU,MAAM;IACzB,KAAK;qBAAmC,MAAM;uBAAiB,MAAM;;IACrE,WAAW;iBAA8B,gBAAgB,EAAE;mBAAa,MAAM;;CAC/E,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { get, post } from "@parhelia/core";
2
+ const root = "/parhelia/benchmark/";
3
+ export class BenchmarkApiError extends Error {
4
+ status;
5
+ constructor(message, status) {
6
+ super(message);
7
+ this.status = status;
8
+ this.name = "BenchmarkApiError";
9
+ }
10
+ }
11
+ export async function unwrap(request) {
12
+ const result = await request;
13
+ if (result.type !== "success" || result.data === undefined)
14
+ throw new BenchmarkApiError(result.summary ?? "Benchmark request failed", result.response?.status);
15
+ return result.data;
16
+ }
17
+ export const benchmarkService = {
18
+ status: () => unwrap(get(root + "status")),
19
+ models: () => unwrap(get(root + "models")),
20
+ tasks: () => unwrap(get(root + "tasks")),
21
+ prepare: () => unwrap(post(root + "prepare", {})),
22
+ start: (request) => unwrap(post(root + "start", request)),
23
+ cancel: (runId) => unwrap(post(root + "cancel", { runId })),
24
+ recover: (runId) => unwrap(post(root + "recover", { runId })),
25
+ runs: (skip = 0) => unwrap(get(root + `runs?skip=${skip}&take=25`)),
26
+ run: (runId) => unwrap(get(root + `run?runId=${encodeURIComponent(runId)}`)),
27
+ deleteRun: (runId) => unwrap(post(root + "deleteRun", { runId })),
28
+ purge: () => unwrap(post(root + "purge", { deleteAgents: true })),
29
+ leaderboard: () => unwrap(get(root + "leaderboard")),
30
+ };
@@ -0,0 +1,146 @@
1
+ export type RunStatus = "Queued" | "Running" | "Completed" | "Failed" | "Cancelled" | "NeedsRecovery";
2
+ export type ShutdownState = "None" | "Requested" | "Confirmed" | "Unconfirmed";
3
+ export type BenchmarkRun = {
4
+ runId: string;
5
+ batchId: string;
6
+ suiteHash: string;
7
+ modelItemId: string;
8
+ modelName: string;
9
+ providerName: string;
10
+ modelConfigFingerprint: string;
11
+ configLabel: string;
12
+ status: RunStatus;
13
+ isFullSuite: boolean;
14
+ costKnown: boolean;
15
+ createdAt: string;
16
+ completedAt?: string;
17
+ taskCount: number;
18
+ tasksCompleted: number;
19
+ correctnessPercent: number;
20
+ efficiencyPercent?: number;
21
+ fullScorePercent?: number;
22
+ coveragePercent: number;
23
+ coreCost: number;
24
+ totalCost: number;
25
+ judgeCost: number;
26
+ inputTokens: number;
27
+ outputTokens: number;
28
+ cachedTokens: number;
29
+ cacheWriteTokens: number;
30
+ toolExecutions: number;
31
+ wallDurationMs: number;
32
+ safetyViolations: number;
33
+ errorMessage?: string;
34
+ cancelRequestedAt?: string;
35
+ };
36
+ export type TaskCheck = {
37
+ key: string;
38
+ description: string;
39
+ class: "work" | "preservation" | "efficiency" | "judge";
40
+ passed: boolean;
41
+ skipped: boolean;
42
+ critical: boolean;
43
+ points: number;
44
+ awarded: number;
45
+ reason?: string;
46
+ };
47
+ export type GraderReport = {
48
+ checks: TaskCheck[];
49
+ criticalFailed: boolean;
50
+ violations?: string[];
51
+ };
52
+ export type BenchmarkTaskResult = {
53
+ taskResultId: string;
54
+ taskKey: string;
55
+ taskTitle: string;
56
+ runId: string;
57
+ agentId?: string;
58
+ status: string;
59
+ shutdownState: ShutdownState;
60
+ correctnessPercent: number;
61
+ efficiencyPercent?: number;
62
+ cost: number;
63
+ costKnown: boolean;
64
+ judgeCost: number;
65
+ toolCalls: number;
66
+ wallDurationMs: number;
67
+ skipReason?: string;
68
+ errorMessage?: string;
69
+ graderReportJson?: string;
70
+ auditJson?: string;
71
+ keptUntil?: string;
72
+ };
73
+ export type BenchmarkTask = {
74
+ id: string;
75
+ key: string;
76
+ title: string;
77
+ description: string;
78
+ category: string;
79
+ isCore: boolean;
80
+ prompt: string;
81
+ toolCallBudget: number;
82
+ costBudgetUsd: number;
83
+ timeoutSeconds: number;
84
+ requiresJudge: boolean;
85
+ requiresVision: boolean;
86
+ };
87
+ /** supportsImageInput is null when image input capability is absent or unknown in the model configuration. */
88
+ export type BenchmarkModel = {
89
+ id: string;
90
+ name: string;
91
+ providerName: string;
92
+ hasPricing: boolean;
93
+ supportsImageInput?: boolean | null;
94
+ pricing?: {
95
+ inputCostPer1MTokens?: number;
96
+ outputCostPer1MTokens?: number;
97
+ cachedInputCostPer1MTokens?: number;
98
+ };
99
+ configFingerprint: string;
100
+ };
101
+ export type BenchmarkStatus = {
102
+ installed: boolean;
103
+ version: string;
104
+ migrationsApplied: boolean;
105
+ missingTables: string[];
106
+ prepared: {
107
+ ready: boolean;
108
+ error?: string;
109
+ };
110
+ runnerUser: string;
111
+ suiteHash?: string;
112
+ activeRun?: BenchmarkRun;
113
+ queuedRuns: BenchmarkRun[];
114
+ tasksAwaitingRecovery: BenchmarkTaskResult[];
115
+ };
116
+ export type LeaderboardEntry = {
117
+ modelItemId: string;
118
+ modelName: string;
119
+ providerName: string;
120
+ modelConfigFingerprint: string;
121
+ configLabel: string;
122
+ runCount: number;
123
+ staleRunCount: number;
124
+ costKnown: boolean;
125
+ medianCorrectnessPercent: number;
126
+ bestCorrectnessPercent: number;
127
+ medianEfficiencyPercent?: number;
128
+ medianFullScorePercent?: number;
129
+ coveragePercent: number;
130
+ medianCoreCost?: number;
131
+ medianTotalCost?: number;
132
+ medianCostPerCorrectnessPoint?: number;
133
+ medianTokens: number;
134
+ medianWallDurationMs: number;
135
+ };
136
+ export type RunDetail = {
137
+ run: BenchmarkRun | null;
138
+ tasks: BenchmarkTaskResult[];
139
+ };
140
+ export type StartRequest = {
141
+ modelItemId: string;
142
+ runCount: number;
143
+ taskIds?: string[];
144
+ allowUnknownCost: boolean;
145
+ };
146
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@parhelia/benchmark",
3
+ "version": "0.4.12784",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "development": "./src/index.tsx",
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./styles.css": "./styles.css"
18
+ },
19
+ "files": [
20
+ "dist/",
21
+ "styles.css",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.build.json",
27
+ "build:native": "tsgo -p tsconfig.build.json",
28
+ "lint": "eslint . --max-warnings 0",
29
+ "check-types": "tsc --noEmit",
30
+ "check-types:native": "tsgo --noEmit",
31
+ "test": "vitest run"
32
+ },
33
+ "devDependencies": {
34
+ "@eslint/compat": "^2.1.1",
35
+ "@repo/eslint-config": "*",
36
+ "@repo/typescript-config": "*",
37
+ "@tailwindcss/postcss": "^4.3.3",
38
+ "@testing-library/dom": "^10.4.1",
39
+ "@testing-library/react": "^16.3.3",
40
+ "@types/node": "^26.4.0",
41
+ "@types/react": "19.2.18",
42
+ "@types/react-dom": "19.2.5",
43
+ "@typescript/native": "npm:typescript@7.0.2",
44
+ "eslint": "^10.9.1",
45
+ "jsdom": "^30.0.1",
46
+ "tailwindcss": "^4.3.3",
47
+ "typescript": "npm:@typescript/typescript6@6.0.2",
48
+ "vitest": "^4.1.11"
49
+ },
50
+ "dependencies": {
51
+ "@parhelia/core": "*",
52
+ "lucide-react": "^1.38.0",
53
+ "postcss": "^8.5.26",
54
+ "react": "19.2.8",
55
+ "react-dom": "19.2.8",
56
+ "sonner": "^2.0.8"
57
+ },
58
+ "overrides": {
59
+ "@types/react": "19.2.18",
60
+ "@types/react-dom": "19.2.5"
61
+ }
62
+ }
package/styles.css ADDED
@@ -0,0 +1,3 @@
1
+ /* Benchmark package styles */
2
+ @source "./src/**/*.{js,ts,jsx,tsx}";
3
+ @source "./dist/**/*.js";