refactor(hermes_cli): middleware/mcp_picker/mcp_security/mcp_startup/memory_oauth — hoist _DownstreamExecutionError, compact layout and docstrings

This commit is contained in:
Teknium
2026-09-02 20:33:09 -07:00
parent 890029b5d4
commit ff5d0c4312
5 changed files with 102 additions and 283 deletions
+4 -6
View File
@@ -23,8 +23,8 @@ def _resolve_flow(provider: str):
@contextmanager
def _scope_to_profile(profile: Optional[str]):
"""Scope config resolution to ``profile`` so the flow's eager path resolve
targets that profile's honcho.json. None/""/"current" leaves it untouched."""
"""Scope config resolution to ``profile`` so the flow's eager path resolve targets that profile's
honcho.json. None/""/"current" leaves it untouched."""
requested = (profile or "").strip()
if not requested or requested.lower() == "current":
yield
@@ -49,12 +49,10 @@ def _scope_to_profile(profile: Optional[str]):
@router.post("/{provider}/oauth/start")
async def start_memory_oauth(provider: str, profile: Optional[str] = None):
"""Begin a provider's zero-CLI OAuth flow — opens the browser and captures
the grant via the loopback listener. Returns immediately; poll status."""
"""Begin a provider's zero-CLI OAuth flow (browser + loopback listener). Returns immediately; poll status."""
flow = _resolve_flow(provider)
try:
# The flow resolves its config path eagerly inside this scope; the worker
# thread it spawns outlives the request and the override.
# The flow resolves its config path eagerly inside this scope; its worker thread outlives it.
with _scope_to_profile(profile):
return flow.start_loopback_flow_background()
except HTTPException: