dsh-livebench-panel 0.1.10 → 0.1.11

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 (2) hide show
  1. package/lib/index.js +21 -10
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -502,6 +502,22 @@ function asInt(value, min, max, fallback) {
502
502
  return Math.min(max, Math.max(min, Math.trunc(n)));
503
503
  }
504
504
 
505
+ /**
506
+ * Validate one bench path: "live_bench", "live_bench/<category>" or
507
+ * "live_bench/<category>/<task>". Task names are mixed-case in LiveBench
508
+ * (AMPS_Hard, LCB_generation, …), so segments allow A-Za-z0-9_.
509
+ * @returns {string|null} error description, or null when valid.
510
+ */
511
+ function validateBenchName(bn) {
512
+ const parts = bn.split("/").filter((s) => s.length > 0);
513
+ if (parts[0] !== "live_bench") return "must start with live_bench";
514
+ if (parts.length > 3) return "too deep";
515
+ for (const seg of parts) {
516
+ if (!/^[A-Za-z0-9_]{1,80}$/.test(seg)) return `bad segment "${seg}"`;
517
+ }
518
+ return null;
519
+ }
520
+
505
521
  function apply(ctx) {
506
522
  /** The single run slot. */
507
523
  let run = null;
@@ -545,14 +561,9 @@ function apply(ctx) {
545
561
  benchNames = [];
546
562
  for (const bn of body.benchNames) {
547
563
  if (typeof bn !== "string") return { status: 400, payload: { ok: false, error: "invalid bench name" } };
548
- const parts = bn.split("/").filter((s) => s.length > 0);
549
- if (parts[0] !== "live_bench" || parts.length > 3) {
550
- return { status: 400, payload: { ok: false, error: `invalid bench path: ${bn}` } };
551
- }
552
- for (const seg of parts) {
553
- if (!/^[a-z0-9_]+$/.test(seg)) return { status: 400, payload: { ok: false, error: `invalid bench path: ${bn}` } };
554
- }
555
- benchNames.push(parts.join("/"));
564
+ const error = validateBenchName(bn);
565
+ if (error) return { status: 400, payload: { ok: false, error: `invalid bench path: ${bn} (${error})` } };
566
+ benchNames.push(bn.split("/").filter((s) => s.length > 0).join("/"));
556
567
  }
557
568
  }
558
569
 
@@ -886,7 +897,7 @@ function apply(ctx) {
886
897
  const task = typeof row.task === "string" ? row.task : "";
887
898
  // path-safety: membership in the scanned task list + charset guards
888
899
  if (!/^[A-Za-z0-9._@-]{1,160}$/.test(model)) continue;
889
- if (!/^[a-z0-9_]{1,60}$/.test(category) || !/^[a-z0-9_]{1,60}$/.test(task)) continue;
900
+ if (!/^[A-Za-z0-9_]{1,80}$/.test(category) || !/^[A-Za-z0-9_]{1,80}$/.test(task)) continue;
890
901
  if (!(tasks[category] && tasks[category][task])) continue;
891
902
  const taskDir = join(layout.dataDir, category, task);
892
903
  removed += filterJsonlByModel(join(taskDir, "model_answer", `${model}.jsonl`), "model_id", model);
@@ -902,4 +913,4 @@ function runsAlive() {
902
913
  return 1;
903
914
  }
904
915
 
905
- export { name, inject, apply, writeGeneratedModelConfig, readProviders };
916
+ export { name, inject, apply, writeGeneratedModelConfig, readProviders, validateBenchName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-livebench-panel",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "DSH web plugin: a LiveBench tab in the Trajectory view (right of 对话/轨迹). Run LiveBench evaluations against every model configured in the DeepSeek Harness — pick provider/model, category, task, release and question range from dropdowns, watch progress, and read scores in place.",
5
5
  "license": "MIT",
6
6
  "type": "module",