evalrouter 0.3.1__tar.gz → 0.3.2__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.
- {evalrouter-0.3.1 → evalrouter-0.3.2}/PKG-INFO +4 -5
- {evalrouter-0.3.1 → evalrouter-0.3.2}/README.md +3 -4
- {evalrouter-0.3.1 → evalrouter-0.3.2}/pyproject.toml +1 -1
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/__init__.py +1 -1
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/__init__.py +1 -1
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/_account.py +59 -8
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/cli.py +1 -2
- {evalrouter-0.3.1 → evalrouter-0.3.2}/LICENSE +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/bundle.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/components.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/models.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/protocol.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/py.typed +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/templates.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/evalrouter_contracts/validation.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/__main__.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/_boundary.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/_guided.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/_helpers.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/_listing.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/_resources.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/_transport.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/py.typed +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/__init__.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/_console.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/_theme.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/_widgets.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/live.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/picker.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/screens.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/render/tables.py +0 -0
- {evalrouter-0.3.1 → evalrouter-0.3.2}/src/kimpton_evalrouter/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: evalrouter
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Typed Kimpton evaluation client and command-line interface
|
|
5
5
|
License-Expression: LicenseRef-Kimpton-EvalRouter-SDK
|
|
6
6
|
License-File: LICENSE
|
|
@@ -38,8 +38,7 @@ the `kimpton_evalrouter` import and every API are unchanged. To switch, run
|
|
|
38
38
|
`pip uninstall -y kimpton-evalrouter-sdk evalrouter`) and install `evalrouter`.
|
|
39
39
|
|
|
40
40
|
The package supplies the `evalrouter` command; no repository checkout is needed.
|
|
41
|
-
|
|
42
|
-
and follow the browser sign-in below.
|
|
41
|
+
Run the browser sign-in below to sign in or create your account.
|
|
43
42
|
Package installation does not grant account access or evaluation credit.
|
|
44
43
|
|
|
45
44
|
Sign in with your account:
|
|
@@ -49,8 +48,8 @@ evalrouter login
|
|
|
49
48
|
evalrouter whoami
|
|
50
49
|
```
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
The browser guides you through sign-up or sign-in, email verification and
|
|
52
|
+
terminal approval. The CLI resumes automatically and selects your only workspace.
|
|
54
53
|
Production is the default API, with `--base-url` available for other environments.
|
|
55
54
|
No API key or credential-storage setup is needed for a normal sign-in.
|
|
56
55
|
|
|
@@ -23,8 +23,7 @@ the `kimpton_evalrouter` import and every API are unchanged. To switch, run
|
|
|
23
23
|
`pip uninstall -y kimpton-evalrouter-sdk evalrouter`) and install `evalrouter`.
|
|
24
24
|
|
|
25
25
|
The package supplies the `evalrouter` command; no repository checkout is needed.
|
|
26
|
-
|
|
27
|
-
and follow the browser sign-in below.
|
|
26
|
+
Run the browser sign-in below to sign in or create your account.
|
|
28
27
|
Package installation does not grant account access or evaluation credit.
|
|
29
28
|
|
|
30
29
|
Sign in with your account:
|
|
@@ -34,8 +33,8 @@ evalrouter login
|
|
|
34
33
|
evalrouter whoami
|
|
35
34
|
```
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
The browser guides you through sign-up or sign-in, email verification and
|
|
37
|
+
terminal approval. The CLI resumes automatically and selects your only workspace.
|
|
39
38
|
Production is the default API, with `--base-url` available for other environments.
|
|
40
39
|
No API key or credential-storage setup is needed for a normal sign-in.
|
|
41
40
|
|
|
@@ -37,7 +37,7 @@ import webbrowser
|
|
|
37
37
|
from dataclasses import dataclass
|
|
38
38
|
from pathlib import Path
|
|
39
39
|
from types import SimpleNamespace
|
|
40
|
-
from urllib.parse import urlsplit, urlunsplit
|
|
40
|
+
from urllib.parse import urlencode, urlsplit, urlunsplit
|
|
41
41
|
|
|
42
42
|
import httpx
|
|
43
43
|
|
|
@@ -51,6 +51,12 @@ FILE_STORE_NAME = "credentials.json"
|
|
|
51
51
|
REFRESH_MARGIN_SECONDS = 60
|
|
52
52
|
MAX_POLL_INTERVAL = 60
|
|
53
53
|
DEFAULT_API_ORIGIN = "https://api.evalrouter.ai"
|
|
54
|
+
CONNECT_WEBSITES = {
|
|
55
|
+
"api.evalrouter.ai": "https://evalrouter.ai",
|
|
56
|
+
"api.dev.evalrouter.ai": "https://dev.evalrouter.ai",
|
|
57
|
+
"kimpton-evalrouter-dev--evalrouter-service-api.us-east.modal.direct":
|
|
58
|
+
"https://dev.evalrouter.ai",
|
|
59
|
+
}
|
|
54
60
|
LOGIN_HINT = "Run `evalrouter login` or set EVALROUTER_API_KEY."
|
|
55
61
|
#: Largest secret accepted on stdin or at a prompt (bytes of UTF-8).
|
|
56
62
|
MAX_SECRET_BYTES = 16 * 1024
|
|
@@ -537,12 +543,37 @@ def start_device_authorization(http: httpx.Client, config: dict) -> dict:
|
|
|
537
543
|
required = ("device_code", "user_code", "verification_uri")
|
|
538
544
|
if not isinstance(value, dict) or not all(isinstance(value.get(k), str) for k in required):
|
|
539
545
|
raise ClientError("login_unavailable", "Sign-in could not be started. Try again later.")
|
|
546
|
+
if not re.fullmatch(r"[A-Za-z0-9-]{4,32}", value["user_code"]):
|
|
547
|
+
raise ClientError("login_unavailable", "Sign-in returned an unusable terminal code.")
|
|
540
548
|
for key in ("verification_uri", "verification_uri_complete"):
|
|
541
|
-
if value.get(key)
|
|
549
|
+
if not value.get(key):
|
|
550
|
+
continue
|
|
551
|
+
address = value[key]
|
|
552
|
+
if not isinstance(address, str) or any(ord(c) < 33 or ord(c) > 126 for c in address):
|
|
553
|
+
raise ClientError("login_unavailable", "Sign-in returned an unsafe verification URL.")
|
|
554
|
+
try:
|
|
555
|
+
parsed = urlsplit(address)
|
|
556
|
+
except ValueError:
|
|
557
|
+
raise ClientError("login_unavailable", "Sign-in returned an unsafe verification URL.") from None
|
|
558
|
+
if (parsed.scheme != "https" or parsed.netloc != urlsplit(config["issuer"]).netloc
|
|
559
|
+
or parsed.username or parsed.password or parsed.fragment):
|
|
542
560
|
raise ClientError("login_unavailable", "Sign-in returned an unsafe verification URL.")
|
|
543
561
|
return value
|
|
544
562
|
|
|
545
563
|
|
|
564
|
+
def connect_target(base: str, device: dict) -> str:
|
|
565
|
+
"""Prepare the browser account before approving the existing OAuth request.
|
|
566
|
+
|
|
567
|
+
Only the user-facing code reaches the website, never the device secret,
|
|
568
|
+
access token or refresh token. Custom servers keep their provider's flow.
|
|
569
|
+
"""
|
|
570
|
+
website = CONNECT_WEBSITES.get(urlsplit(base).netloc)
|
|
571
|
+
code = device["user_code"]
|
|
572
|
+
if website and re.fullmatch(r"[A-Za-z0-9]{4}-[A-Za-z0-9]{4}", code):
|
|
573
|
+
return website + "/activate?" + urlencode({"code": code.upper()})
|
|
574
|
+
return device.get("verification_uri_complete") or device["verification_uri"]
|
|
575
|
+
|
|
576
|
+
|
|
546
577
|
def _jwt_expiry(token: str) -> float | None:
|
|
547
578
|
"""Scheduling hint only; the server verifies every token."""
|
|
548
579
|
try:
|
|
@@ -672,10 +703,29 @@ class Credentials:
|
|
|
672
703
|
device_secret: str | None = None
|
|
673
704
|
|
|
674
705
|
|
|
706
|
+
CLIENT_HEADER = "X-EvalRouter-Client"
|
|
707
|
+
# Coding agents that set a recognizable variable when they run a subprocess.
|
|
708
|
+
AGENT_ENVIRONMENT = ("CLAUDECODE", "CODEX_SANDBOX", "CURSOR_AGENT", "GEMINI_CLI")
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
def client_label() -> str:
|
|
712
|
+
"""`cli/<version>`, or `agent/<version>` when a coding agent runs the CLI."""
|
|
713
|
+
try:
|
|
714
|
+
from importlib.metadata import version
|
|
715
|
+
|
|
716
|
+
release = version("evalrouter")
|
|
717
|
+
except Exception:
|
|
718
|
+
release = "unknown"
|
|
719
|
+
name = "agent" if any(os.environ.get(key) for key in AGENT_ENVIRONMENT) else "cli"
|
|
720
|
+
return f"{name}/{release}"
|
|
721
|
+
|
|
722
|
+
|
|
675
723
|
def attach(client, credentials: Credentials):
|
|
676
|
-
"""Add the device-grant
|
|
724
|
+
"""Add the device-grant and client headers to a constructed Client; returns the client."""
|
|
677
725
|
if credentials.device_secret:
|
|
678
726
|
client._http.headers[DEVICE_HEADER] = credentials.device_secret
|
|
727
|
+
# Product analytics attribution only: a client name and package version.
|
|
728
|
+
client._http.headers[CLIENT_HEADER] = client_label()
|
|
679
729
|
return client
|
|
680
730
|
|
|
681
731
|
|
|
@@ -1107,14 +1157,15 @@ def login(
|
|
|
1107
1157
|
store.update_server(base, login_advertised=True)
|
|
1108
1158
|
config = auth0_config(base, advertisement)
|
|
1109
1159
|
device = start_device_authorization(http, config)
|
|
1110
|
-
target =
|
|
1111
|
-
notice(
|
|
1112
|
-
notice(
|
|
1160
|
+
target = connect_target(base, device)
|
|
1161
|
+
notice("Open this link to sign in or create an account:")
|
|
1162
|
+
notice(target)
|
|
1163
|
+
notice(f"Your terminal code: {device['user_code']}")
|
|
1113
1164
|
if not getattr(args, "no_browser", False) and _interactive():
|
|
1114
1165
|
with contextlib.suppress(Exception):
|
|
1115
1166
|
if open_browser(target):
|
|
1116
|
-
notice("Opened your browser.
|
|
1117
|
-
notice("Waiting for
|
|
1167
|
+
notice("Opened your browser. Finish connecting there.")
|
|
1168
|
+
notice("Waiting for you to finish in the browser...")
|
|
1118
1169
|
tokens = poll_for_tokens(http, config, device, sleep=sleep)
|
|
1119
1170
|
finally:
|
|
1120
1171
|
if owned:
|
|
@@ -523,8 +523,7 @@ def benchmark_human_result(action, value):
|
|
|
523
523
|
|
|
524
524
|
|
|
525
525
|
ONBOARDING = """Get started:
|
|
526
|
-
1. Run evalrouter login
|
|
527
|
-
New to EvalRouter? Create your account at https://evalrouter.ai/register.
|
|
526
|
+
1. Run evalrouter login to sign in or create your account in the browser.
|
|
528
527
|
2. Run evalrouter catalog to choose a benchmark, or catalog --models for models.
|
|
529
528
|
3. Run evalrouter run to review a quote before starting an evaluation.
|
|
530
529
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|