Skip to content

The agent that grows with you

feat(plugins): a re-pin that moves an OAuth entry's authorize host asks first

Ilya Balobanovc3d3b15cc570
diff --git a/hermes_cli/plugin_oauth.py b/hermes_cli/plugin_oauth.py
index 3dc92580723..8974588fe78 100644
--- a/hermes_cli/plugin_oauth.py
+++ b/hermes_cli/plugin_oauth.py
@@ -160,10 +160,13 @@ def oauth_notice(manifest: Mapping[str, Any]) -> str:
def oauth_surface(manifest: Mapping[str, Any]) -> set[str]:
- """One line per client for the re-pin consent delta: a new entry, or a changed token host, hosts or scopes,
- shows up as added. Any other change only alters the fingerprint, so the user signs in again."""
- return {f"{c.id} ({urlparse(c.token_url).hostname} -> {', '.join(c.hosts)}; {' '.join(c.scopes)})"
- for c in parse_oauth_clients(manifest)[0]}
+ """One line per client for the re-pin consent delta: a new entry, or a changed authorize host, token host,
+ hosts or scopes, shows up as added. Any other change only alters the fingerprint, so the user signs in again."""
+ lines: set[str] = set()
+ for c in parse_oauth_clients(manifest)[0]:
+ idp_hosts = ", ".join(dict.fromkeys(urlparse(url).hostname for url in (c.authorize_url, c.token_url)))
+ lines.add(f"{c.id} ({idp_hosts} -> {', '.join(c.hosts)}; {' '.join(c.scopes)})")
+ return lines
def _declared_env_names(manifest: Mapping[str, Any]) -> set[str]:
diff --git a/tests/hermes_cli/test_plugin_oauth.py b/tests/hermes_cli/test_plugin_oauth.py
index 6b54e991a72..5b8d32e0f1b 100644
--- a/tests/hermes_cli/test_plugin_oauth.py
+++ b/tests/hermes_cli/test_plugin_oauth.py
@@ -445,6 +445,18 @@ def test_install_notice_and_repin_delta_name_the_oauth_entry(idp, tmp_path):
assert len(lines) == 1 and lines[0].startswith("your OAuth sign-in for") and "collect.example.net" in lines[0]
+def test_repin_delta_names_a_changed_authorize_host(idp, tmp_path):
+ from hermes_cli.plugins_cmd_catalog import plugin_surface, surface_delta, surface_delta_lines
+
+ installed = plugin_surface({"name": "voice", "oauth": [_entry(idp)]}, tmp_path)
+ moved = {"name": "voice", "oauth": [_entry(idp, authorize_url="https://signin.example.net/authorize")]}
+ lines = surface_delta_lines(surface_delta(installed, plugin_surface(moved, tmp_path)))
+ assert len(lines) == 1 and "signin.example.net" in lines[0]
+
+ same_host = {"name": "voice", "oauth": [_entry(idp, authorize_url=f"{idp.base}/v2/authorize")]}
+ assert surface_delta(installed, plugin_surface(same_host, tmp_path)) == {}
+
+
def test_the_notice_command_finds_a_plugin_whose_name_differs_from_its_directory(idp, api):
allowed, _ = api
plugin = _plugin("voice-dir", oauth=[_entry(idp)], display="gemini-voice")
diff --git a/website/docs/developer-guide/plugins/index.md b/website/docs/developer-guide/plugins/index.md
index e137ff1412c..4cff5c141c8 100644
--- a/website/docs/developer-guide/plugins/index.md
+++ b/website/docs/developer-guide/plugins/index.md
@@ -530,8 +530,8 @@ The Codex rules above apply, plus:
- **The grant follows the declaration.** It remembers the entry it was made
for: a plugin version that changes the token URL, hosts, scopes or client
variables gets `ProviderNotSignedIn` until the user signs in again, and a
- catalog re-pin that adds an `oauth` entry or changes its token host, hosts or
- scopes asks before updating.
+ catalog re-pin that adds an `oauth` entry or changes its authorize host, token
+ host, hosts or scopes asks before updating.
- **Errors.** `ProviderNotSignedIn`: not signed in, revoked, or the entry
changed since sign-in. `AuthError` codes: `oauth_client_id_missing` and
`oauth_client_secret_missing` (the variable is not set), `invalid_client`,