screens-connection #33

Merged
gillian merged 8 commits from screens-connection into main 2026-05-26 15:32:17 -04:00
J
Member

Title: fix(agent): improve ria-agent register UX (User-Agent, structured errors, human-readable names)

Summary

Three small, focused improvements to the ria-agent register flow that make it actually work against a Cloudflare-fronted hub and surface useful feedback when it doesn't.

  • Set an explicit User-Agent on the register POST. Python's default Python-urllib/<ver> is blocked by Cloudflare's Browser Integrity Check on riahub.ai (HTTP 403 edge code 1010), so the register call never reached the hub. Any non-default UA passes the check.
  • Surface structured failure reasons from the hub. The controller's per-user key auth path returns JSON like {"detail": {"reason": "expired"}}; the CLI now maps the known reasons (invalid_key, expired, revoked, already_consumed) and rate-limit responses into human-readable messages. Previously users only saw HTTP 4xx and had to guess.
  • Human-readable default agent names. When --name is omitted, the agent is given an adjective-noun-N style name via the new namegen.py module instead of being registered with an empty string.

Changes

File What
src/ria_toolkit_oss/agent/cli.py _cmd_register now generates a default name, sets a User-Agent, and routes HTTP errors through _explain_registration_failure(). New REGISTRATION_REASON_MESSAGES table maps controller reason codes to messages.
src/ria_toolkit_oss/agent/namegen.py New: generate_agent_name() producing pronounceable defaults.
tests/agent/test_cli_register_errors.py New: covers the structured-error reason mapping and rate-limit formatting.
poetry.lock Regenerated against current pyproject.toml.

Test plan

  • pytest tests/agent/test_cli_register_errors.py passes
  • ria-agent register --hub https://riahub.ai --api-key ria_reg_… against a hub with the matching public route exposed (PR fix/screens-agent-register-public-route on qoherent/ria-hub) completes and writes ~/.ria/agent.json
  • Registering with an already-consumed key prints the human-readable message rather than HTTP 403
  • Registering without --name produces a non-empty adjective-noun-N agent name in the config

Notes for reviewers

  • The branch was rebased onto current main (which includes v0.1.6, datatypes/data/, getting-started overhaul, etc.) — diff is now narrowly scoped.
  • The CLI fix only resolves the client side of the registration issue. The hub-side route (POST /screens/agents/register exposed without reqSignIn) lands in a separate PR on qoherent/ria-hub (branch fix/screens-agent-register-public-route).
**Title:** `fix(agent): improve ria-agent register UX (User-Agent, structured errors, human-readable names)` ## Summary Three small, focused improvements to the `ria-agent register` flow that make it actually work against a Cloudflare-fronted hub and surface useful feedback when it doesn't. - **Set an explicit `User-Agent` on the register POST.** Python's default `Python-urllib/<ver>` is blocked by Cloudflare's Browser Integrity Check on `riahub.ai` (HTTP 403 edge code 1010), so the register call never reached the hub. Any non-default UA passes the check. - **Surface structured failure reasons from the hub.** The controller's per-user key auth path returns JSON like `{"detail": {"reason": "expired"}}`; the CLI now maps the known reasons (`invalid_key`, `expired`, `revoked`, `already_consumed`) and rate-limit responses into human-readable messages. Previously users only saw `HTTP 4xx` and had to guess. - **Human-readable default agent names.** When `--name` is omitted, the agent is given an `adjective-noun-N` style name via the new `namegen.py` module instead of being registered with an empty string. ## Changes | File | What | |---|---| | `src/ria_toolkit_oss/agent/cli.py` | `_cmd_register` now generates a default name, sets a `User-Agent`, and routes HTTP errors through `_explain_registration_failure()`. New `REGISTRATION_REASON_MESSAGES` table maps controller `reason` codes to messages. | | `src/ria_toolkit_oss/agent/namegen.py` | New: `generate_agent_name()` producing pronounceable defaults. | | `tests/agent/test_cli_register_errors.py` | New: covers the structured-error reason mapping and rate-limit formatting. | | `poetry.lock` | Regenerated against current `pyproject.toml`. | ## Test plan - [ ] `pytest tests/agent/test_cli_register_errors.py` passes - [ ] `ria-agent register --hub https://riahub.ai --api-key ria_reg_…` against a hub with the matching public route exposed (PR `fix/screens-agent-register-public-route` on `qoherent/ria-hub`) completes and writes `~/.ria/agent.json` - [ ] Registering with an already-consumed key prints the human-readable message rather than `HTTP 403` - [ ] Registering without `--name` produces a non-empty `adjective-noun-N` agent name in the config ## Notes for reviewers - The branch was rebased onto current `main` (which includes v0.1.6, `datatypes/` → `data/`, getting-started overhaul, etc.) — diff is now narrowly scoped. - The CLI fix only resolves the *client* side of the registration issue. The hub-side route (`POST /screens/agents/register` exposed without `reqSignIn`) lands in a separate PR on `qoherent/ria-hub` (branch `fix/screens-agent-register-public-route`).
jonny added 5 commits 2026-05-26 12:31:45 -04:00
J agent register: surface structured hub failure reasons
Map the hub's structured `{detail: {reason}}` responses (invalid_key,
expired, revoked, already_consumed) and 429 rate-limits to actionable
CLI messages so users know to mint a fresh key from Settings → RIA
Agents instead of seeing a raw HTTPError.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2f6b5ced18
J poetry.lock: refresh
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
99447a581a
J 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>
5f68fd936d
J Merge remote-tracking branch 'origin/agent-naming-fix' into screens-connection
# Conflicts:
#	src/ria_toolkit_oss/agent/cli.py
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 27s
Test with tox / Test with tox (3.12) (pull_request) Successful in 7m45s
Test with tox / Test with tox (3.11) (pull_request) Successful in 8m3s
Build Project / Build Project (3.12) (pull_request) Successful in 13m8s
Build Project / Build Project (3.11) (pull_request) Successful in 13m13s
Build Project / Build Project (3.10) (pull_request) Successful in 13m15s
Test with tox / Test with tox (3.10) (pull_request) Failing after 13m16s
febb1bd6cf
J jonny requested review from gillian 2026-05-26 12:33:36 -04:00
jonny added 3 commits 2026-05-26 12:46:02 -04:00
J fix(agent): address review findings on register flow
- Restore agent_id in success output. Pre-PR the user saw the hub's
  canonical identifier; the merge had reduced this to just `(name)`,
  which made it impossible to correlate the registered agent with
  anything on the hub side without inspecting the config file.
- Add a 15s timeout to the register POST. urllib's default is none,
  so a stuck hub would block the CLI indefinitely.
- Read User-Agent version from package metadata instead of hardcoding
  "0.1", so it tracks releases. Also corrected the URL to the canonical
  Source URL listed in pyproject.toml (was pointing at a likely-404
  github.com path).
- Add two tests guarding the User-Agent. The whole point of the Cloudflare
  fix was to set a non-default UA; previously no test asserted this, so
  a refactor could silently reintroduce the 403 code 1010 bug.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
543517f0ca
J docs(changelog): add 0.1.7 entry for ria-agent register fixes
Covers the User-Agent / Cloudflare fix, request timeout, structured
error reasons, human-readable default agent names, and updated CLI
help text for the per-user `ria_reg_*` registration key flow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 23s
Build Project / Build Project (3.12) (pull_request) Successful in 2m57s
Build Project / Build Project (3.11) (pull_request) Successful in 3m9s
Build Project / Build Project (3.10) (pull_request) Successful in 3m11s
Test with tox / Test with tox (3.11) (pull_request) Successful in 3m3s
Test with tox / Test with tox (3.12) (pull_request) Successful in 3m37s
Test with tox / Test with tox (3.10) (pull_request) Failing after 4m6s
53f912f21a
G gillian approved these changes 2026-05-26 15:31:55 -04:00
G gillian merged commit b27b04dbc0 into main 2026-05-26 15:32:17 -04:00
G gillian deleted branch screens-connection 2026-05-26 15:32:17 -04:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: qoherent/ria-toolkit-oss#33
No description provided.