evalrouter 0.5.2__tar.gz → 0.5.3__tar.gz

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 (67) hide show
  1. {evalrouter-0.5.2 → evalrouter-0.5.3}/PKG-INFO +7 -7
  2. {evalrouter-0.5.2 → evalrouter-0.5.3}/pyproject.toml +7 -7
  3. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/data/chart_data.py +40 -29
  4. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/chart_specs.py +19 -7
  5. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_account.py +119 -2
  6. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_cli_commands.py +160 -2
  7. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_client_run_cli.py +54 -0
  8. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_comparison.py +3 -4
  9. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_comparison_html.py +3 -6
  10. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_environment_publishing.py +2 -3
  11. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_guided.py +15 -2
  12. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_result_groups.py +1 -1
  13. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_task_recommendation_cli.py +1 -0
  14. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_trace_benchmark_cli.py +20 -6
  15. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_tune.py +22 -64
  16. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/cli.py +69 -6
  17. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/_widgets.py +7 -6
  18. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/live.py +2 -5
  19. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/screens.py +1 -2
  20. {evalrouter-0.5.2 → evalrouter-0.5.3}/LICENSE +0 -0
  21. {evalrouter-0.5.2 → evalrouter-0.5.3}/README.md +0 -0
  22. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter/__main__.py +0 -0
  23. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/__init__.py +0 -0
  24. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/brand.py +0 -0
  25. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/data/__init__.py +0 -0
  26. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/data/document.py +0 -0
  27. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/data/metrics.py +0 -0
  28. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/data/native.py +0 -0
  29. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/data/pareto.py +0 -0
  30. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/__init__.py +0 -0
  31. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/chart_format.py +0 -0
  32. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/chart_select.py +0 -0
  33. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/charts.py +0 -0
  34. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/document.py +0 -0
  35. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/pareto.py +0 -0
  36. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/evalrouter_reports/html/theme.py +0 -0
  37. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/__main__.py +0 -0
  38. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_artifacts.py +0 -0
  39. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_chain_prefetch.py +0 -0
  40. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_comparison_checkpoint.py +0 -0
  41. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_completion.py +0 -0
  42. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_evaluation_jobs_cli.py +0 -0
  43. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_failure_guidance.py +0 -0
  44. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_group_results.py +0 -0
  45. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_group_review.py +0 -0
  46. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_group_summary_prefetch.py +0 -0
  47. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_groups.py +0 -0
  48. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_history_labels.py +0 -0
  49. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_install_repair.py +0 -0
  50. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_listing.py +0 -0
  51. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_read_cache.py +0 -0
  52. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_reasoning_controls.py +0 -0
  53. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_release_cli.py +0 -0
  54. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_subjects_cli.py +0 -0
  55. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_suite_cli.py +0 -0
  56. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_tui.py +0 -0
  57. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_tui_port.py +0 -0
  58. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_tui_session.py +0 -0
  59. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_tui_table.py +0 -0
  60. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_tui_views.py +0 -0
  61. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_update_notice.py +0 -0
  62. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/_workload_cli.py +0 -0
  63. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/__init__.py +0 -0
  64. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/_console.py +0 -0
  65. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/_theme.py +0 -0
  66. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/picker.py +0 -0
  67. {evalrouter-0.5.2 → evalrouter-0.5.3}/src/kimpton_evalrouter/render/tables.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evalrouter
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: The EvalRouter command line and interactive terminal workspace
5
5
  Project-URL: Homepage, https://evalrouter.ai
6
6
  Project-URL: Documentation, https://evalrouter.ai/developers/docs/cli
@@ -14,21 +14,21 @@ Classifier: Programming Language :: Python :: 3 :: Only
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Requires-Python: <3.14,>=3.12
17
- Requires-Dist: evalrouter-sdk==0.5.2
17
+ Requires-Dist: evalrouter-sdk==0.5.3
18
18
  Requires-Dist: rich==15.0.0
19
19
  Requires-Dist: textual==8.2.8
20
20
  Provides-Extra: agents
21
- Requires-Dist: evalrouter-sdk[agents]==0.5.2; extra == 'agents'
21
+ Requires-Dist: evalrouter-sdk[agents]==0.5.3; extra == 'agents'
22
22
  Provides-Extra: benchmark
23
- Requires-Dist: evalrouter-sdk[benchmark]==0.5.2; extra == 'benchmark'
23
+ Requires-Dist: evalrouter-sdk[benchmark]==0.5.3; extra == 'benchmark'
24
24
  Provides-Extra: keyring
25
25
  Requires-Dist: keyring==25.7.0; extra == 'keyring'
26
26
  Provides-Extra: langsmith
27
- Requires-Dist: evalrouter-sdk[langsmith]==0.5.2; extra == 'langsmith'
27
+ Requires-Dist: evalrouter-sdk[langsmith]==0.5.3; extra == 'langsmith'
28
28
  Provides-Extra: strands
29
- Requires-Dist: evalrouter-sdk[strands]==0.5.2; extra == 'strands'
29
+ Requires-Dist: evalrouter-sdk[strands]==0.5.3; extra == 'strands'
30
30
  Provides-Extra: tracing
31
- Requires-Dist: evalrouter-sdk[tracing]==0.5.2; extra == 'tracing'
31
+ Requires-Dist: evalrouter-sdk[tracing]==0.5.3; extra == 'tracing'
32
32
  Description-Content-Type: text/markdown
33
33
 
34
34
  # EvalRouter CLI
@@ -13,7 +13,7 @@ build-backend = "hatchling.build"
13
13
  # with the reviewed public cli.py from public/, for release.
14
14
  [project]
15
15
  name = "evalrouter"
16
- version = "0.5.2"
16
+ version = "0.5.3"
17
17
  description = "The EvalRouter command line and interactive terminal workspace"
18
18
  readme = "README.md"
19
19
  license = "LicenseRef-Kimpton-EvalRouter-SDK"
@@ -31,7 +31,7 @@ classifiers = [
31
31
  # The SDK at the same version, plus terminal rendering: rich for human output
32
32
  # and Textual for the interactive workspace. Exact pins; rich 15.0.0 matches
33
33
  # deploy/experiments/requirements.lock.
34
- dependencies = ["evalrouter-sdk==0.5.2", "rich==15.0.0", "textual==8.2.8"]
34
+ dependencies = ["evalrouter-sdk==0.5.3", "rich==15.0.0", "textual==8.2.8"]
35
35
 
36
36
  [project.urls]
37
37
  Homepage = "https://evalrouter.ai"
@@ -41,16 +41,16 @@ Documentation = "https://evalrouter.ai/developers/docs/cli"
41
41
  # Every extra the combined `evalrouter` 0.4.x offered keeps resolving, so an
42
42
  # existing `evalrouter[tracing]` requirement still installs what it named. The
43
43
  # SDK's own extras forward to `evalrouter-sdk` at the same version.
44
- tracing = ["evalrouter-sdk[tracing]==0.5.2"]
45
- strands = ["evalrouter-sdk[strands]==0.5.2"]
46
- langsmith = ["evalrouter-sdk[langsmith]==0.5.2"]
44
+ tracing = ["evalrouter-sdk[tracing]==0.5.3"]
45
+ strands = ["evalrouter-sdk[strands]==0.5.3"]
46
+ langsmith = ["evalrouter-sdk[langsmith]==0.5.3"]
47
47
  # Offline `benchmark init/validate/bundle`: the SDK's validation extra.
48
- benchmark = ["evalrouter-sdk[benchmark]==0.5.2"]
48
+ benchmark = ["evalrouter-sdk[benchmark]==0.5.3"]
49
49
  # Account sign-in stores tokens in the OS keychain when this extra is
50
50
  # installed; otherwise it uses a private 0600 file.
51
51
  keyring = ["keyring==25.7.0"]
52
52
  # `evalrouter run --agent`: the SDK's client-run ACP controller dependencies.
53
- agents = ["evalrouter-sdk[agents]==0.5.2"]
53
+ agents = ["evalrouter-sdk[agents]==0.5.3"]
54
54
 
55
55
  [project.scripts]
56
56
  evalrouter = "kimpton_evalrouter.cli:main"
@@ -30,6 +30,23 @@ def _number(value: Any) -> int | float | None:
30
30
  return value if isinstance(value, int) else result
31
31
 
32
32
 
33
+ def _micro(value: Any) -> int | None:
34
+ """Whole micro-USD from the wire (a digit string or a non-negative int)."""
35
+ if type(value) is int and value >= 0:
36
+ return value
37
+ return int(value) if isinstance(value, str) and value.isdigit() else None
38
+
39
+
40
+ def _model_cost_microusd(row: Any) -> int | None:
41
+ if not isinstance(row, Mapping):
42
+ return None
43
+ if (micro := _micro(row.get("microusd"))) is not None:
44
+ return micro
45
+ # Results saved before chart inputs carried micro-USD hold only the float.
46
+ usd = _number(row.get("usd"))
47
+ return None if usd is None or usd < 0 else round(usd * 1_000_000)
48
+
49
+
33
50
  def _text(value: Any, default: str = "") -> str:
34
51
  return value.strip() if isinstance(value, str) and value.strip() else default
35
52
 
@@ -236,9 +253,11 @@ def _cost_metric() -> dict:
236
253
  }
237
254
 
238
255
 
239
- def _with_cost(group: dict, series: dict, value: int | float | None) -> None:
240
- if value is None:
256
+ def _with_cost(group: dict, series: dict, microusd: int | None) -> None:
257
+ if microusd is None:
241
258
  return
259
+ value = microusd / 1_000_000
260
+ series["cost_microusd"] = str(microusd)
242
261
  series["cost_usd"] = value
243
262
  series["metrics"].append({"key": "settled_cost_usd", "value": value})
244
263
  if not any(row.get("key") == "settled_cost_usd" for row in group["metrics"]):
@@ -465,9 +484,9 @@ def build_run_chart_data(
465
484
  series["coverage"] = coverage
466
485
  if (tokens := _tokens_per_task(inputs.get("usage"), tasks)) is not None:
467
486
  series["tokens_per_task"] = tokens
468
- model_usd = _number((inputs.get("model_cost") or {}).get("usd"))
469
- if model_usd is not None:
470
- series["model_cost_usd"] = model_usd
487
+ if (model_micro := _model_cost_microusd(inputs.get("model_cost"))) is not None:
488
+ series["model_cost_microusd"] = str(model_micro)
489
+ series["model_cost_usd"] = model_micro / 1_000_000
471
490
  if (latency := _latency(inputs.get("latency"))) is not None:
472
491
  series["latency_s"] = latency
473
492
  if history := _history(inputs.get("history")):
@@ -521,7 +540,7 @@ def build_run_chart_data(
521
540
  continue
522
541
  microusd = item.get("total_cost_microusd")
523
542
  if isinstance(microusd, str) and microusd.isdigit():
524
- cost = int(microusd) / 1_000_000
543
+ cost = int(microusd)
525
544
  break
526
545
  _with_cost(group, series, cost)
527
546
  errors = _count(profile.get("errors"))
@@ -700,31 +719,23 @@ def _run_cost(result: Mapping[str, Any]) -> dict | None:
700
719
  if not isinstance(billing, Mapping):
701
720
  return None
702
721
 
703
- def usd(key: str) -> float | None:
704
- value = billing.get(key)
705
- if isinstance(value, str) and value.isdigit():
706
- return int(value) / 1_000_000
707
- if isinstance(value, int) and not isinstance(value, bool):
708
- return value / 1_000_000
709
- return None
710
-
711
722
  settled = _settled_spend(result) if billing.get("pending") else None
712
- output = {
713
- k: v
714
- for k, v in (
715
- # The snapshot is frozen when the result is finalized, often before the
716
- # last calls and the platform fee settle; the settled costs replace it.
717
- ("spend_usd", settled if settled is not None else usd("spend_microusd")),
718
- ("cap_usd", usd("cap_microusd")),
719
- ("reserved_usd", 0.0 if settled is not None else usd("reserved_microusd")),
720
- )
721
- if v is not None
722
- }
723
+ output = {}
724
+ for name, micro in (
725
+ # The snapshot is frozen when the result is finalized, often before the
726
+ # last calls and the platform fee settle; the settled costs replace it.
727
+ ("spend", settled if settled is not None else _micro(billing.get("spend_microusd"))),
728
+ ("cap", _micro(billing.get("cap_microusd"))),
729
+ ("reserved", 0 if settled is not None else _micro(billing.get("reserved_microusd"))),
730
+ ):
731
+ if micro is not None:
732
+ output[f"{name}_microusd"] = str(micro)
733
+ output[f"{name}_usd"] = micro / 1_000_000
723
734
  return output or None
724
735
 
725
736
 
726
- def _settled_spend(result: Mapping[str, Any]) -> float | None:
727
- """The settled charge in USD once nothing is pending, from the result's `costs`:
737
+ def _settled_spend(result: Mapping[str, Any]) -> int | None:
738
+ """The settled charge in micro-USD once nothing is pending, from the result's `costs`:
728
739
  only when they cover every profile of the result (None otherwise)."""
729
740
  costs = result.get("costs")
730
741
  rows = costs.get("profiles") if isinstance(costs, Mapping) else None
@@ -749,7 +760,7 @@ def _settled_spend(result: Mapping[str, Any]) -> float | None:
749
760
  covered.add(identity(row))
750
761
  if not wanted or not wanted <= covered:
751
762
  return None
752
- return total / 1_000_000
763
+ return total
753
764
 
754
765
 
755
766
  def _coverage(profile: Mapping[str, Any]) -> dict | None:
@@ -1171,7 +1182,7 @@ def build_comparison_chart_data(
1171
1182
  if (type(microusd) is int and microusd >= 0) or (
1172
1183
  isinstance(microusd, str) and microusd.isdigit()
1173
1184
  ):
1174
- cost = int(microusd) / 1_000_000
1185
+ cost = int(microusd)
1175
1186
  _with_cost(group, series, cost)
1176
1187
  errors = _count(profile.get("errors"))
1177
1188
  planned = _count(profile.get("planned"))
@@ -18,8 +18,18 @@ from .chart_select import recommend_charts
18
18
  MIN_SLICE_N = 10
19
19
 
20
20
 
21
+ def dollars(holder: Mapping, name: str) -> float | None:
22
+ """`<name>_microusd` as dollars for plotting; a result saved before the micro-USD
23
+ fields carries only the float `<name>_usd`."""
24
+ micro = holder.get(f"{name}_microusd")
25
+ if isinstance(micro, str) and micro.isdigit():
26
+ return int(micro) / 1_000_000
27
+ saved = holder.get(f"{name}_usd")
28
+ return saved if _finite(saved) else None
29
+
30
+
21
31
  def cost_label(series) -> str:
22
- return "Model cost per task" if any(_finite(s.get("model_cost_usd")) for s in series) else "Cost per task"
32
+ return "Model cost per task" if any(dollars(s, "model_cost") is not None for s in series) else "Cost per task"
23
33
 
24
34
 
25
35
  def _finite(v) -> bool:
@@ -64,8 +74,10 @@ def cost_per_task(series: Mapping, key: str) -> float | None:
64
74
  """Settled cost per task; repeated attempts at one task count once."""
65
75
  tasks = series.get("task_count") or len({s.get("id") for s in _samples(series)}) or (_value(series, key) or {}).get("n")
66
76
  # The model's own inference cost when recorded; a flat per-run fee would make every model look alike.
67
- cost = series.get("model_cost_usd") if _finite(series.get("model_cost_usd")) else series.get("cost_usd")
68
- if not _finite(cost) or not tasks:
77
+ cost = dollars(series, "model_cost")
78
+ if cost is None:
79
+ cost = dollars(series, "cost")
80
+ if cost is None or not tasks:
69
81
  return None
70
82
  return cost / tasks
71
83
 
@@ -675,7 +687,7 @@ def tradeoff_measures(series: Sequence[Mapping], key: str, *, show_cost: bool =
675
687
  if show_cost:
676
688
  measures.append({"id": "cost", "label": cost_label(series), "better": "cheaper", "format": {"kind": "usd"},
677
689
  "note": ("Model cost per task is the settled provider inference charge divided by tasks scored; per-run fees are excluded."
678
- if any(_finite(x.get("model_cost_usd")) for x in series)
690
+ if any(dollars(x, "model_cost") is not None for x in series)
679
691
  else "Cost per task is the settled EvalRouter charge divided by tasks scored."),
680
692
  "of": lambda s: cost_per_task(s, key)})
681
693
  measures.append({"id": "latency", "label": "Median call time", "better": "faster", "format": {"kind": "duration"},
@@ -879,12 +891,12 @@ def run_specs(data: Mapping, *, show_cost: bool = True) -> list[dict]:
879
891
  timings = data.get("timings") if isinstance(data.get("timings"), Mapping) else {}
880
892
  cost = data.get("run") if show_cost and isinstance(data.get("run"), Mapping) else {}
881
893
  tiles = []
882
- spend, cap = cost.get("spend_usd"), cost.get("cap_usd")
894
+ spend, cap = dollars(cost, "spend"), dollars(cost, "cap")
883
895
  # Per-task time is a different scale from per-call phases, so it is a tile, not a bar.
884
896
  whole = next((p for p in timings.get("phases") or [] if p.get("name") == "lane_to_checkpoint_committed" and _finite(p.get("p50_s"))), None)
885
897
  # The page's facts line already gives the charge and run time; the charge earns a tile only against a cap.
886
- if _finite(spend) and _finite(cap) and cap > 0:
887
- rank = f"{round(spend / cap * 100)}% of the ${cap:,.2f} cap" if _finite(cap) and cap > 0 else None
898
+ if spend is not None and cap is not None and cap > 0:
899
+ rank = f"{round(spend / cap * 100)}% of the ${cap:,.2f} cap"
888
900
  tiles.append({"label": "Charge", "value": spend, "format": {"kind": "usd"}, "rank": rank})
889
901
  if whole:
890
902
  p90 = whole["p90_s"]
@@ -353,11 +353,14 @@ def provider_key(args, *, create: bool, stdin_busy: bool = False, reader=None) -
353
353
  """
354
354
  from_stdin = bool(getattr(args, "key_stdin", False))
355
355
  variable = getattr(args, "key_env", None)
356
- if from_stdin and variable is not None:
356
+ reference = getattr(args, "key_ref", None)
357
+ if from_stdin + (variable is not None) + (reference is not None) > 1:
357
358
  raise EvalRouterError(
358
359
  "invalid_input",
359
- "Choose one provider key source: --key-stdin or --key-env NAME, not both.",
360
+ "Use one provider key source, not both: --key-stdin, --key-env NAME or --key-ref REF.",
360
361
  )
362
+ if reference is not None:
363
+ return read_secret_reference(reference)
361
364
  if from_stdin:
362
365
  if stdin_busy:
363
366
  raise EvalRouterError(
@@ -384,6 +387,40 @@ def provider_key(args, *, create: bool, stdin_busy: bool = False, reader=None) -
384
387
  raise EvalRouterError("invalid_input", NO_PROVIDER_KEY)
385
388
 
386
389
 
390
+ def read_secret_reference(reference: str) -> str:
391
+ """A secret manager reference (`op://vault/item/field`) read locally by `op read`.
392
+
393
+ Only the value is sent to EvalRouter; the reference is neither sent nor stored.
394
+ """
395
+ import subprocess
396
+
397
+ if not reference.startswith("op://"):
398
+ raise EvalRouterError(
399
+ "invalid_input", "--key-ref takes a 1Password reference such as op://vault/item/field."
400
+ )
401
+ try:
402
+ read = subprocess.run(
403
+ ["op", "read", "--no-newline", reference],
404
+ capture_output=True,
405
+ text=True,
406
+ timeout=60,
407
+ check=False,
408
+ )
409
+ except FileNotFoundError:
410
+ raise EvalRouterError(
411
+ "invalid_configuration", "--key-ref needs the 1Password CLI (op) on PATH."
412
+ ) from None
413
+ except subprocess.TimeoutExpired:
414
+ raise EvalRouterError("invalid_input", "1Password did not answer within 60 s.") from None
415
+ if read.returncode != 0:
416
+ # Never forward op's output: what it prints is outside this program's control.
417
+ raise EvalRouterError(
418
+ "invalid_input",
419
+ "1Password could not read that reference; run `op read` yourself to see why.",
420
+ )
421
+ return _checked_secret(read.stdout, PROVIDER_KEY, "by that reference")
422
+
423
+
387
424
  def add_provider_key_arguments(parser, *, update: bool) -> None:
388
425
  """`connections create`/`update` key options; the key itself is never an argument."""
389
426
  if update:
@@ -397,6 +434,11 @@ def add_provider_key_arguments(parser, *, update: bool) -> None:
397
434
  action="store_true",
398
435
  help="Read the provider API key from stdin (one trailing newline is removed)",
399
436
  )
437
+ parser.add_argument(
438
+ "--key-ref",
439
+ metavar="REF",
440
+ help="Read the provider API key with `op read REF` (a 1Password reference)",
441
+ )
400
442
  parser.add_argument(
401
443
  "--key-env",
402
444
  metavar="NAME",
@@ -442,6 +484,17 @@ def connection_write(client, args, read_object):
442
484
  Shared by the internal and public command-line interfaces so both read the
443
485
  key the same way and scrub it from errors and output.
444
486
  """
487
+ if args.action == "create" and getattr(args, "provider", None):
488
+ return client.connections.create(
489
+ {
490
+ "name": args.name,
491
+ "account_id": provider_account_id(client, args.provider),
492
+ "model_id": args.model,
493
+ "protocol": args.protocol,
494
+ "max_output_tokens": args.max_output_tokens,
495
+ "context_window": args.context_window,
496
+ }
497
+ ).to_dict()
445
498
  if args.action == "create":
446
499
  credential = provider_key(args, create=True)
447
500
  with scrubbed_errors(credential):
@@ -461,6 +514,7 @@ def connection_write(client, args, read_object):
461
514
  getattr(args, "rotate_key", False)
462
515
  or getattr(args, "key_stdin", False)
463
516
  or getattr(args, "key_env", None) is not None
517
+ or getattr(args, "key_ref", None) is not None
464
518
  )
465
519
  fields = {
466
520
  field: value
@@ -495,6 +549,69 @@ def connection_write(client, args, read_object):
495
549
  return redact(value, secret)
496
550
 
497
551
 
552
+ def provider_account_id(client, value: str) -> str:
553
+ """A provider account's id from its id or its (active) name."""
554
+ import uuid
555
+
556
+ with contextlib.suppress(ValueError):
557
+ return str(uuid.UUID(value))
558
+ for account in client.provider_accounts.list().to_dict()["data"]:
559
+ if value in (account["id"], account["name"]) and not account["disabled_at"]:
560
+ return account["id"]
561
+ raise EvalRouterError("not_found", "No active provider account has that name or id.")
562
+
563
+
564
+ def add_provider_arguments(parser, *, update: bool) -> None:
565
+ """`providers add`/`update` options; the key comes only from a key source."""
566
+ parser.add_argument("--name", required=not update, help="Account name")
567
+ parser.add_argument(
568
+ "--endpoint",
569
+ required=not update,
570
+ metavar="URL",
571
+ help="The OpenAI-compatible API base URL"
572
+ + ("; moving to another host also needs a new key" if update else ""),
573
+ )
574
+ parser.add_argument(
575
+ "--max-concurrency",
576
+ type=int,
577
+ help="Most concurrent requests through this account across your runs"
578
+ + ("; calls already running keep their slots" if update else ""),
579
+ )
580
+ add_provider_key_arguments(parser, update=update)
581
+ if update:
582
+ parser.description = (
583
+ "A new key applies to running evaluations from their next call; a call already "
584
+ "being sent may use the previous key once. A new endpoint stops them until each "
585
+ "model is checked again."
586
+ )
587
+
588
+
589
+ def provider_write(client, args):
590
+ """`providers add` or `providers update`: a rotation keeps runs going on the new key."""
591
+ adding = args.action == "add"
592
+ credential = provider_key(args, create=adding)
593
+ body = {
594
+ "name": args.name,
595
+ "base_url": args.endpoint,
596
+ "api_key": credential,
597
+ "max_concurrency": args.max_concurrency,
598
+ }
599
+ body = {key: value for key, value in body.items() if value is not None}
600
+ if not body:
601
+ raise EvalRouterError(
602
+ "invalid_input",
603
+ "Provide --name, --endpoint or --max-concurrency, or rotate the key with "
604
+ "--rotate-key, --key-stdin, --key-env NAME or --key-ref REF.",
605
+ )
606
+ with scrubbed_errors(credential):
607
+ if adding:
608
+ value = client.provider_accounts.create(body).to_dict()
609
+ else:
610
+ account_id = provider_account_id(client, args.account_id)
611
+ value = client.provider_accounts.update(account_id, body).to_dict()
612
+ return redact(value, credential)
613
+
614
+
498
615
  @contextlib.contextmanager
499
616
  def scrubbed_errors(*secrets):
500
617
  """Remove secrets from a EvalRouterError's message and details before it surfaces.
@@ -596,11 +596,19 @@ COMMANDS = (
596
596
  "repeat": False,
597
597
  "required": False,
598
598
  },
599
+ {
600
+ "name": "generation_policy",
601
+ "flag": "--generation-policy",
602
+ "type": "string",
603
+ "choices": ("deterministic_v1", "provider_default_reasoning_v1"),
604
+ "repeat": False,
605
+ "required": False,
606
+ },
599
607
  {
600
608
  "name": "grader_protocol",
601
609
  "flag": "--grader-protocol",
602
610
  "type": "string",
603
- "choices": ("generic", "tune_rubric_v1"),
611
+ "choices": ("generic", "tune_rubric_v2"),
604
612
  "repeat": False,
605
613
  "required": False,
606
614
  },
@@ -1084,7 +1092,7 @@ COMMANDS = (
1084
1092
  "name": "grader_protocol",
1085
1093
  "flag": "--grader-protocol",
1086
1094
  "type": "string",
1087
- "choices": ("generic", "tune_rubric_v1"),
1095
+ "choices": ("generic", "tune_rubric_v2"),
1088
1096
  "repeat": False,
1089
1097
  "required": False,
1090
1098
  },
@@ -1165,6 +1173,14 @@ COMMANDS = (
1165
1173
  "repeat": False,
1166
1174
  "required": False,
1167
1175
  },
1176
+ {
1177
+ "name": "grading",
1178
+ "flag": "--grading",
1179
+ "type": "string",
1180
+ "choices": ("review", "exact_match", "contains"),
1181
+ "repeat": False,
1182
+ "required": False,
1183
+ },
1168
1184
  {
1169
1185
  "name": "limit",
1170
1186
  "flag": "--limit",
@@ -1189,6 +1205,14 @@ COMMANDS = (
1189
1205
  "repeat": True,
1190
1206
  "required": False,
1191
1207
  },
1208
+ {
1209
+ "name": "validation_share",
1210
+ "flag": "--validation-share",
1211
+ "type": "number",
1212
+ "choices": None,
1213
+ "repeat": False,
1214
+ "required": False,
1215
+ },
1192
1216
  ),
1193
1217
  "paginate": False,
1194
1218
  },
@@ -1297,6 +1321,140 @@ COMMANDS = (
1297
1321
  "body": None,
1298
1322
  "paginate": True,
1299
1323
  },
1324
+ {
1325
+ "command": "providers add",
1326
+ "resource": "provider_accounts",
1327
+ "tier": "public",
1328
+ "args": (),
1329
+ "method": "create",
1330
+ "presenter": "provider_write",
1331
+ "summary": "Add a provider's key and address once",
1332
+ "query": (),
1333
+ "body": (
1334
+ {
1335
+ "name": "api_key",
1336
+ "flag": "--api-key",
1337
+ "type": "string",
1338
+ "choices": None,
1339
+ "repeat": False,
1340
+ "required": True,
1341
+ },
1342
+ {
1343
+ "name": "base_url",
1344
+ "flag": "--base-url",
1345
+ "type": "string",
1346
+ "choices": None,
1347
+ "repeat": False,
1348
+ "required": True,
1349
+ },
1350
+ {
1351
+ "name": "kind",
1352
+ "flag": "--kind",
1353
+ "type": "string",
1354
+ "choices": None,
1355
+ "repeat": False,
1356
+ "required": False,
1357
+ },
1358
+ {
1359
+ "name": "max_concurrency",
1360
+ "flag": "--max-concurrency",
1361
+ "type": "integer",
1362
+ "choices": None,
1363
+ "repeat": False,
1364
+ "required": False,
1365
+ },
1366
+ {
1367
+ "name": "name",
1368
+ "flag": "--name",
1369
+ "type": "string",
1370
+ "choices": None,
1371
+ "repeat": False,
1372
+ "required": True,
1373
+ },
1374
+ ),
1375
+ "paginate": False,
1376
+ },
1377
+ {
1378
+ "command": "providers disable",
1379
+ "resource": "provider_accounts",
1380
+ "tier": "public",
1381
+ "args": ("account_id",),
1382
+ "method": "delete",
1383
+ "presenter": "record",
1384
+ "summary": "Stop using a provider account and its models",
1385
+ "query": (),
1386
+ "body": None,
1387
+ "paginate": False,
1388
+ },
1389
+ {
1390
+ "command": "providers get",
1391
+ "resource": "provider_accounts",
1392
+ "tier": "public",
1393
+ "args": ("account_id",),
1394
+ "method": "get",
1395
+ "presenter": "record",
1396
+ "summary": "Show a provider account",
1397
+ "query": (),
1398
+ "body": None,
1399
+ "paginate": False,
1400
+ },
1401
+ {
1402
+ "command": "providers list",
1403
+ "resource": "provider_accounts",
1404
+ "tier": "public",
1405
+ "args": (),
1406
+ "method": "list",
1407
+ "presenter": "table",
1408
+ "summary": "List provider accounts",
1409
+ "query": (),
1410
+ "body": None,
1411
+ "paginate": True,
1412
+ },
1413
+ {
1414
+ "command": "providers update",
1415
+ "resource": "provider_accounts",
1416
+ "tier": "public",
1417
+ "args": ("account_id",),
1418
+ "method": "update",
1419
+ "presenter": "provider_write",
1420
+ "summary": "Rotate a provider account's key or change its address",
1421
+ "query": (),
1422
+ "body": (
1423
+ {
1424
+ "name": "api_key",
1425
+ "flag": "--api-key",
1426
+ "type": "string",
1427
+ "choices": None,
1428
+ "repeat": False,
1429
+ "required": False,
1430
+ },
1431
+ {
1432
+ "name": "base_url",
1433
+ "flag": "--base-url",
1434
+ "type": "string",
1435
+ "choices": None,
1436
+ "repeat": False,
1437
+ "required": False,
1438
+ },
1439
+ {
1440
+ "name": "max_concurrency",
1441
+ "flag": "--max-concurrency",
1442
+ "type": "integer",
1443
+ "choices": None,
1444
+ "repeat": False,
1445
+ "required": False,
1446
+ },
1447
+ {
1448
+ "name": "name",
1449
+ "flag": "--name",
1450
+ "type": "string",
1451
+ "choices": None,
1452
+ "repeat": False,
1453
+ "required": False,
1454
+ },
1455
+ ),
1456
+ "paginate": False,
1457
+ },
1300
1458
  {
1301
1459
  "command": "quotes create",
1302
1460
  "resource": "quotes",