home_data_layout.py 1.3 KB

12345678910111213141516171819202122232425
  1. """Machine-specific state excluded from portable home transfers."""
  2. from __future__ import annotations
  3. # Dependency generations, downloaded tools, and partial transfers belong to this machine.
  4. PM_RUNTIME_ROOT_DIRS = frozenset({"installs", "tools", "cache"})
  5. # Bitwarden / 1Password secret-value caches and the Photon sidecar auth token, as POSIX paths relative to
  6. # a home. They sit at its top, where a sandbox can hide a file by path (a writable folder above a hidden
  7. # file can be renamed). Hermes regenerates them on use, so backups leave them out.
  8. SECRET_CACHE_FILES = ("bws_cache.json", "bws_cache.enc.json", "op_cache.json", "photon-sidecar.json")
  9. # Where earlier releases kept the same files, in folders the agent can write. Hermes deletes a copy
  10. # there unread on first use.
  11. LEGACY_SECRET_CACHE_PATHS = (
  12. "cache/bws_cache.json", "cache/bws_cache.enc.json", "cache/op_cache.json", "runtime/photon-sidecar.json",
  13. )
  14. # Credential stores for every guard that lists them.
  15. SECRET_CACHE_STORES = (*SECRET_CACHE_FILES, *LEGACY_SECRET_CACHE_PATHS)
  16. def profile_root_entry(parts: tuple[str, ...]) -> str | None:
  17. """Locate a home-root entry without excluding same-named skill/plugin data."""
  18. if len(parts) >= 3 and parts[0] == "profiles":
  19. return parts[2]
  20. return parts[0] if parts else None