Skip to content

The agent that grows with you

fix(cli): connectors registers on its own, retired accounts can be removed

Siddharth Balyand216e425a438
diff --git a/hermes_cli/connectors_cmd.py b/hermes_cli/connectors_cmd.py
index 2d2c6dd90f6..670ca8378e9 100644
--- a/hermes_cli/connectors_cmd.py
+++ b/hermes_cli/connectors_cmd.py
@@ -102,8 +102,8 @@ def _wait_for_link(start, app: str) -> dict[str, Any]:
target = snapshot["targets"][0]
url = target.get("connect_url")
if url and not printed_url:
- print(url)
- print("Open this link in your browser to finish.")
+ print(url, flush=True)
+ print("Open this link in your browser to finish.", flush=True)
printed_url = True
if target.get("state") in _DONE_STATES or snapshot.get("settled_at") is not None:
return target
@@ -183,10 +183,11 @@ def _rename(args) -> int:
return 0
-def _pick_account(app: str, alias: str | None) -> dict[str, Any]:
+def _pick_account(app: str, alias: str | None, *, retired: bool = False) -> dict[str, Any]:
+ """``retired``: a retired account may be picked by name (removal); a repair never targets one."""
rows = _app_accounts(app)
if alias:
- return _match_named(app, [r for r in rows if not r.get("disabled")], alias)
+ return _match_named(app, [r for r in rows if retired or not r.get("disabled")], alias)
live_rows = [r for r in rows if not r.get("disabled")]
if len(live_rows) == 1:
return live_rows[0]
@@ -199,7 +200,7 @@ def _disconnect(args) -> int:
from tools.connectors.portal.client import PortalConnectorClient
app = args.app.strip().lower()
- row = _pick_account(app, args.alias)
+ row = _pick_account(app, args.alias, retired=True)
name = _account_name(row)
if not args.yes:
if not sys.stdin.isatty():
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index e4be6cdd64e..ff938bf627b 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -389,6 +389,7 @@ from hermes_cli.subcommands.skills import build_skills_parser
from hermes_cli.subcommands.pairing import build_pairing_parser
from hermes_cli.subcommands.plugins import build_plugins_parser
from hermes_cli.subcommands.mcp import build_mcp_parser
+from hermes_cli.subcommands.connectors import build_connectors_parser
from hermes_cli.subcommands.claw import build_claw_parser
from hermes_cli.subcommands.vault import build_vault_parser
from hermes_cli.subcommands.moa import build_moa_parser
@@ -405,7 +406,7 @@ from hermes_cli.subcommands.curator import build_curator_parser
from hermes_cli.subcommands.pets import build_pets_parser
from hermes_cli.subcommands.journey import build_journey_parser
from hermes_cli.subcommands.computer_use import build_computer_use_parser
-from hermes_cli.subcommands.sessions import build_sessions_parser
+from hermes_cli.subcommands.sessions import build_sessions_parser, cmd_sessions_lazy
from hermes_cli.subcommands.completion import build_completion_parser
@@ -3356,13 +3357,6 @@ def _register_plugin_cli_commands(subparsers) -> None:
logging.getLogger(__name__).debug("Plugin CLI discovery failed: %s", _exc)
-def _cmd_sessions_lazy(args, **kwargs):
- """``hermes sessions`` handler; sessions_cmd imports only when the subcommand runs."""
- from hermes_cli.sessions_cmd import cmd_sessions
-
- return cmd_sessions(args, **kwargs)
-
-
def _build_cli_parser():
"""Build the full ``hermes`` argparse tree -> ``(parser, subparsers)``.
@@ -3452,7 +3446,8 @@ def _build_cli_parser():
build_tools_parser(subparsers, cmd_tools=cmd_tools)
build_computer_use_parser(subparsers)
build_mcp_parser(subparsers, cmd_mcp=cmd_mcp)
- build_sessions_parser(subparsers, cmd_sessions=_cmd_sessions_lazy)
+ build_connectors_parser(subparsers)
+ build_sessions_parser(subparsers, cmd_sessions=cmd_sessions_lazy)
build_insights_parser(subparsers, cmd_insights=cmd_insights)
build_usage_parser(subparsers)
build_monitoring_parser(subparsers, cmd_monitoring=cmd_monitoring)
diff --git a/hermes_cli/subcommands/mcp.py b/hermes_cli/subcommands/mcp.py
index 8b03dbf60eb..9702d7be16b 100644
--- a/hermes_cli/subcommands/mcp.py
+++ b/hermes_cli/subcommands/mcp.py
@@ -77,8 +77,3 @@ def build_mcp_parser(subparsers, *, cmd_mcp: Callable) -> None:
add_accept_hooks_flag(mcp_parser)
mcp_parser.set_defaults(func=cmd_mcp)
-
- # Hosted connector accounts sit next to MCP servers in `hermes --help`.
- from hermes_cli.subcommands.connectors import build_connectors_parser
-
- build_connectors_parser(subparsers)
diff --git a/hermes_cli/subcommands/sessions.py b/hermes_cli/subcommands/sessions.py
index 0500ef1d413..26269a84f05 100644
--- a/hermes_cli/subcommands/sessions.py
+++ b/hermes_cli/subcommands/sessions.py
@@ -12,6 +12,13 @@ def _flag(parser, *names, help, **kw):
parser.add_argument(*names, action="store_true", help=help, **kw)
+def cmd_sessions_lazy(args, **kwargs):
+ """``hermes sessions`` handler; sessions_cmd imports only when the subcommand runs."""
+ from hermes_cli.sessions_cmd import cmd_sessions
+
+ return cmd_sessions(args, **kwargs)
+
+
def build_sessions_parser(subparsers, *, cmd_sessions: Callable) -> None:
"""Attach the ``sessions`` subcommand to ``subparsers``."""
sessions_parser = subparsers.add_parser(
diff --git a/tests/hermes_cli/test_connectors_cmd.py b/tests/hermes_cli/test_connectors_cmd.py
index 4c66f5a9563..c4412da6b87 100644
--- a/tests/hermes_cli/test_connectors_cmd.py
+++ b/tests/hermes_cli/test_connectors_cmd.py
@@ -29,8 +29,14 @@ def portal(monkeypatch):
"alias": "home", "active": True},
{"connectionId": "conn-old", "connector": "gmail", "status": "revoked", "label": "[email protected]",
"alias": None, "active": False},
+ {"connectionId": "conn-retired", "connector": "gmail", "status": "inactive", "label": "[email protected]",
+ "alias": None, "active": False, "disabled": True},
]
+ def delete_account(self, connection_id):
+ calls.append((connection_id, "deleted"))
+ return {"connectionId": connection_id, "connector": "gmail", "status": "removed"}
+
def rename_account(self, connection_id, alias):
calls.append((connection_id, alias))
return {"connectionId": connection_id, "connector": "gmail", "alias": alias, "label": "[email protected]"}
@@ -77,3 +83,10 @@ def test_reconnect_repairs_an_unnamed_account_by_its_id(portal, monkeypatch):
cmd_connectors(_parse("connectors", "connect", "gmail", "--reconnect", "--alias", "[email protected]"))
assert started == [{"names": ["gmail"], "action": "reconnect", "profile_home": None, "repair_id": "conn-old"}]
+
+
+def test_disconnect_can_remove_a_retired_account_by_its_label(portal):
+ rc = cmd_connectors(_parse("connectors", "disconnect", "gmail", "--alias", "[email protected]", "--yes"))
+
+ assert rc == 0
+ assert portal == [("conn-retired", "deleted")]
diff --git a/website/docs/user-guide/features/tool-gateway.md b/website/docs/user-guide/features/tool-gateway.md
index 61886df87a9..41f87ba55c5 100644
--- a/website/docs/user-guide/features/tool-gateway.md
+++ b/website/docs/user-guide/features/tool-gateway.md
@@ -137,8 +137,8 @@ If the agent leaves it out when several accounts are named, or names one that do
Manage accounts in any of these places:
- The desktop app's **Connectors** page.
-- The TUI: `/connectors` (see [Slash Commands](../reference/slash-commands.md#tools--skills)).
-- The CLI: `hermes connectors` (see [CLI Commands](../reference/cli-commands.md#hermes-connectors)).
+- The TUI: `/connectors` (see [Slash Commands](../../reference/slash-commands.md#tools--skills)).
+- The CLI: `hermes connectors` (see [CLI Commands](../../reference/cli-commands.md#hermes-connectors)).
- [Nous Portal](https://portal.nousresearch.com).
---