fix(agent): set explicit User-Agent on register POST

Python's `urllib.request.Request` defaults to `Python-urllib/<ver>`,
which Cloudflare's Browser Integrity Check on `riahub.ai` blacklists
(HTTP 403 with edge error code 1010). The register POST never reached
the hub. Any non-default UA passes the check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
J jrhughes003 2026-05-26 12:06:00 -04:00
parent 84f3a63e8b
commit 5f68fd936d

View File

@ -43,12 +43,16 @@ def _cmd_register(args: argparse.Namespace) -> int:
hub_url = args.hub.rstrip("/") hub_url = args.hub.rstrip("/")
url = f"{hub_url}/screens/agents/register" url = f"{hub_url}/screens/agents/register"
body = json.dumps({"name": args.name or ""}).encode() body = json.dumps({"name": args.name or ""}).encode()
# Explicit User-Agent: Python's default `Python-urllib/<ver>` is blocked
# by Cloudflare's Browser Integrity Check on `riahub.ai` (HTTP 403 code
# 1010), so register() never reached the hub. Any non-default UA passes.
req = urllib.request.Request( req = urllib.request.Request(
url, url,
data=body, data=body,
headers={ headers={
"Content-Type": "application/json", "Content-Type": "application/json",
"X-API-Key": args.api_key, "X-API-Key": args.api_key,
"User-Agent": "ria-agent/0.1 (+https://github.com/RIA-Toolkit/ria-toolkit-oss)",
}, },
) )
try: try: