Skip to content

The agent that grows with you

docs(honcho): prune comments in the oauth persist commits

Erosikad3b599f37487
diff --git a/plugins/memory/honcho/cli.py b/plugins/memory/honcho/cli.py
index b7c63e102ee..b453ad8a455 100644
--- a/plugins/memory/honcho/cli.py
+++ b/plugins/memory/honcho/cli.py
@@ -75,8 +75,8 @@ class ConfigWriteRefused(Exception):
def _refuse_unparseable(path: Path) -> None:
- """Raise ``ConfigWriteRefused`` when ``path`` exists but cannot be read or parsed. ``_read_config``
- returns ``{}`` for such a file, and writing that back would drop every other host and root key."""
+ """Raise ConfigWriteRefused when ``path`` exists but cannot be parsed: writing back the ``{}`` a
+ tolerant read returns would drop every other host."""
from plugins.memory.honcho.oauth import _read_config_strict
try:
_read_config_strict(path)
@@ -128,10 +128,8 @@ def _default_block_and_key(cfg: dict) -> tuple[dict, bool]:
def _resolve_api_key(cfg: dict, block: dict | None = None) -> str:
- """API key for ``block`` (default: the active host's block) with host -> root -> env fallback.
- A self-hosted ``baseUrl`` without a key yields ``"local"`` so credential guards accept it: the
- URL must be http/https (so ``baseUrl: true`` can't pass) or a schemeless host:port (legacy
- ``localhost:8000``; the SDK rejects those itself)."""
+ """API key for ``block`` (default: the active host's block), host -> root -> env. A self-hosted
+ http(s) or host:port ``baseUrl`` without a key yields "local" so credential guards accept it."""
block = _host_block(cfg, _host_key()) if block is None else block
key = block.get("apiKey") or cfg.get("apiKey", "") or os.environ.get("HONCHO_API_KEY", "")
if key:
@@ -234,8 +232,7 @@ def clone_honcho_for_profile(profile_name: str) -> bool:
# AI peer is profile-specific (bare profile name: Honcho peer IDs allow no dots);
# workspace is shared so all profiles see the same context.
new_block.update(aiPeer=profile_name, workspace=_pref(default_block, cfg, "workspace") or HOST)
- # The default host's apiKey is not inherited (#66125): without a credential of its own the block
- # stays unenabled until 'hermes honcho setup --target-profile' signs the profile in.
+ # The default host's apiKey is not inherited; the block stays unenabled until this profile signs in.
if _resolve_api_key(cfg, new_block):
new_block["enabled"] = default_block.get("enabled", True)
cfg.setdefault("hosts", {})[new_host] = new_block
@@ -295,8 +292,7 @@ def _no_credential_hint(host: str) -> str:
def cmd_enable(args) -> None:
- """Enable Honcho for the active profile. Refuses to write ``enabled: true`` for a block that
- cannot authenticate, so an enabled block always has a credential behind it."""
+ """Enable Honcho for the active profile; refuses a block that cannot authenticate."""
cfg = _read_config()
host = _host_key()
label = _label(host)
@@ -653,7 +649,7 @@ def _setup_cloud_auth(cfg: dict, hermes_host: dict, write_path: Path) -> bool:
return _setup_device_login(hermes_host, write_path, open_browser=can_browse and not is_remote)
if method in {"oauth", "o"}:
return _setup_browser_login(hermes_host, write_path)
- # A grant left on the host block shadows the key (#97990): its access token is not "current".
+ # A leftover grant on the host block would shadow the pasted key.
stale_grant = existing_oauth is not None or is_oauth_access_token(hermes_host.get("apiKey"))
current = ("" if stale_grant else hermes_host.get("apiKey", "")) or cfg.get("apiKey", "")
print(f"\n Current API key: {_mask(current)}")
diff --git a/plugins/memory/honcho/oauth.py b/plugins/memory/honcho/oauth.py
index 66fb9e71ac1..e3e45d0b88b 100644
--- a/plugins/memory/honcho/oauth.py
+++ b/plugins/memory/honcho/oauth.py
@@ -108,9 +108,8 @@ def _mark_grant_dead(key: tuple[str, str], cred: OAuthCredential) -> None:
_reauth_check_cache.pop(key, None) # verdict changed without a config rewrite
def _read_config_strict(path: Path) -> dict[str, Any]:
- """Reader for the WRITE paths. A missing file reads as ``{}``. A file that exists but cannot be read
- or parsed raises so the caller leaves it alone: ``atomic_json_write`` replaces the whole file, and a
- write seeded from ``{}`` would erase every other host's credentials and the root keys."""
+ """Reader for the write paths: a missing file is ``{}``, an unreadable one raises. A write seeded
+ from ``{}`` would replace every other host's credentials."""
try:
return json.loads(path.read_text(encoding="utf-8-sig"))
except FileNotFoundError:
@@ -302,9 +301,8 @@ def _deep_merge(base: dict[str, Any], overlay: dict[str, Any]) -> dict[str, Any]
return base
def _persist_credential(path: Path, host: str, cred: OAuthCredential, raw: dict[str, Any] | None = None) -> None:
- """Write ``cred`` into ``host``'s block (apiKey + oauth) of ``raw`` (default: a strict read of the
- file), leaving the rest intact; marks the grant live. "Leaving the rest intact" is only true when the
- existing store was actually read, so an unreadable file raises instead of becoming a single-host file."""
+ """Write ``cred`` into ``host``'s block of ``raw`` (default: a strict read of the file) and mark
+ the grant live."""
from utils import atomic_json_write
raw = _read_config_strict(path) if raw is None else raw
@@ -395,7 +393,7 @@ def install_grant(
now = time.time() if now is None else now
cred = OAuthCredential.from_token_response(grant, now=now, client_id=client_id, token_endpoint=token_endpoint)
with _refresh_lock, _config_refresh_lock(path):
- # Strict: a fresh login must not seed its root-merge from a store that exists but could not be read.
+ # Strict read: a login must not seed its root merge from a store it could not read.
raw = _read_config_strict(path)
granted_config = grant.get("config")
if isinstance(granted_config, dict):