mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-09 03:11:58 +00:00
auth: use get_default_hermes_root() for shared nous_auth.json path
Replace hardcoded ~/.hermes/shared/ references with get_default_hermes_root() / 'shared' so the cross-profile Nous auth store lands in the correct location on every platform: - Linux/macOS: ~/.hermes/shared/ - native Windows: %LOCALAPPDATA%\hermes\shared- Docker / custom HERMES_HOME: <root>/shared/ Updates _nous_shared_auth_dir(), the pytest seat-belt in _nous_shared_store_path(), and the auth_add_command comment to match. Previously Windows installs wrote to ~/.hermes/shared/ even though the rest of the CLI uses %LOCALAPPDATA%\hermes, so profiles couldn't see each other's shared credential.
This commit is contained in:
parent
b9bac87d5a
commit
c34884ea20
2 changed files with 19 additions and 8 deletions
|
|
@ -2827,9 +2827,12 @@ def _poll_for_token(
|
||||||
# import instead of running the full device-code flow every time.
|
# import instead of running the full device-code flow every time.
|
||||||
#
|
#
|
||||||
# File lives at ${HERMES_SHARED_AUTH_DIR}/nous_auth.json, defaulting to
|
# File lives at ${HERMES_SHARED_AUTH_DIR}/nous_auth.json, defaulting to
|
||||||
# ~/.hermes/shared/nous_auth.json. It is OUTSIDE any named profile's
|
# ``<hermes-root>/shared/nous_auth.json`` where ``<hermes-root>`` is what
|
||||||
# HERMES_HOME so named profiles (which typically live under
|
# ``get_default_hermes_root()`` returns — ``~/.hermes`` on Linux/macOS,
|
||||||
# ~/.hermes/profiles/<name>/) all see the same file.
|
# ``%LOCALAPPDATA%\hermes`` on native Windows, or the Docker/custom root.
|
||||||
|
# It is OUTSIDE any named profile's HERMES_HOME so named profiles (which
|
||||||
|
# typically live under ``<hermes-root>/profiles/<name>/``) all see the
|
||||||
|
# same file.
|
||||||
#
|
#
|
||||||
# Written on successful login and on every runtime refresh so the stored
|
# Written on successful login and on every runtime refresh so the stored
|
||||||
# refresh_token stays current even if one profile refreshes and rotates it.
|
# refresh_token stays current even if one profile refreshes and rotates it.
|
||||||
|
|
@ -2846,25 +2849,33 @@ def _nous_shared_auth_dir() -> Path:
|
||||||
|
|
||||||
Honors ``HERMES_SHARED_AUTH_DIR`` so tests can redirect it to a tmp
|
Honors ``HERMES_SHARED_AUTH_DIR`` so tests can redirect it to a tmp
|
||||||
path without touching the real user's home. Defaults to
|
path without touching the real user's home. Defaults to
|
||||||
``~/.hermes/shared/``.
|
``<hermes-root>/shared/``, where ``<hermes-root>`` is what
|
||||||
|
:func:`hermes_constants.get_default_hermes_root` returns — so
|
||||||
|
Linux/macOS classic installs land at ``~/.hermes/shared/``, native
|
||||||
|
Windows installs at ``%LOCALAPPDATA%\\hermes\\shared\\``, and
|
||||||
|
Docker / custom ``HERMES_HOME`` deployments at
|
||||||
|
``<HERMES_HOME>/shared/``. Sits outside any named profile so all
|
||||||
|
profiles under the same root share the store.
|
||||||
"""
|
"""
|
||||||
override = os.getenv("HERMES_SHARED_AUTH_DIR", "").strip()
|
override = os.getenv("HERMES_SHARED_AUTH_DIR", "").strip()
|
||||||
if override:
|
if override:
|
||||||
return Path(override).expanduser()
|
return Path(override).expanduser()
|
||||||
return Path.home() / ".hermes" / "shared"
|
from hermes_constants import get_default_hermes_root
|
||||||
|
return get_default_hermes_root() / "shared"
|
||||||
|
|
||||||
|
|
||||||
def _nous_shared_store_path() -> Path:
|
def _nous_shared_store_path() -> Path:
|
||||||
path = _nous_shared_auth_dir() / NOUS_SHARED_STORE_FILENAME
|
path = _nous_shared_auth_dir() / NOUS_SHARED_STORE_FILENAME
|
||||||
# Seat belt: if pytest is running and this resolves to a path under the
|
# Seat belt: if pytest is running and this resolves to a path under the
|
||||||
# real user's home, refuse rather than silently corrupt cross-profile
|
# real user's Hermes root, refuse rather than silently corrupt cross-profile
|
||||||
# state. Tests must set HERMES_SHARED_AUTH_DIR to a tmp_path (conftest
|
# state. Tests must set HERMES_SHARED_AUTH_DIR to a tmp_path (conftest
|
||||||
# does not do this automatically — mirror the _auth_file_path() guard
|
# does not do this automatically — mirror the _auth_file_path() guard
|
||||||
# so forgetting to set it fails loudly instead of writing to the real
|
# so forgetting to set it fails loudly instead of writing to the real
|
||||||
# shared store).
|
# shared store).
|
||||||
if os.environ.get("PYTEST_CURRENT_TEST"):
|
if os.environ.get("PYTEST_CURRENT_TEST"):
|
||||||
|
from hermes_constants import get_default_hermes_root
|
||||||
real_home_shared = (
|
real_home_shared = (
|
||||||
Path.home() / ".hermes" / "shared" / NOUS_SHARED_STORE_FILENAME
|
get_default_hermes_root() / "shared" / NOUS_SHARED_STORE_FILENAME
|
||||||
).resolve(strict=False)
|
).resolve(strict=False)
|
||||||
try:
|
try:
|
||||||
resolved = path.resolve(strict=False)
|
resolved = path.resolve(strict=False)
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ def auth_add_command(args) -> None:
|
||||||
|
|
||||||
if provider == "nous":
|
if provider == "nous":
|
||||||
# Codex-style auto-import: if a shared Nous credential lives at
|
# Codex-style auto-import: if a shared Nous credential lives at
|
||||||
# ~/.hermes/shared/nous_auth.json (written by any previous
|
# <hermes-root>/shared/nous_auth.json (written by any previous
|
||||||
# successful login), offer to import it instead of running the
|
# successful login), offer to import it instead of running the
|
||||||
# full device-code flow. This makes `hermes --profile <name>
|
# full device-code flow. This makes `hermes --profile <name>
|
||||||
# auth add nous --type oauth` a one-tap operation for users who
|
# auth add nous --type oauth` a one-tap operation for users who
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue