The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bundle): packaged installs run their own hermes and name their own app (review)
alt-glitch73133c88c0aa
diff --git a/apps/desktop/electron/desktop-uninstall.test.ts b/apps/desktop/electron/desktop-uninstall.test.tsindex a28c6045ae4..23a7a939ed5 100644--- a/apps/desktop/electron/desktop-uninstall.test.ts+++ b/apps/desktop/electron/desktop-uninstall.test.ts@@ -70,7 +70,11 @@ test('nativeRemovalInstructions names the steward per kind and OS', () => {assert.match(nativeRemovalInstructions('nix', 'linux'), /installed by Nix/)assert.match(nativeRemovalInstructions('nix', 'darwin'), /flake or profile/)assert.match(nativeRemovalInstructions('bundled', 'win32'), /Installed apps/)- assert.match(nativeRemovalInstructions('bundled', 'darwin'), /Trash/)+ assert.equal(+ nativeRemovalInstructions('bundled', 'darwin', '/Applications/Hermes Agent Canary.app'),+ 'Quit the app and drag Hermes Agent Canary.app from /Applications to the Trash.'+ )+ assert.match(nativeRemovalInstructions('bundled', 'darwin'), /drag the Hermes app from Applications to the Trash/)assert.match(nativeRemovalInstructions('bundled', 'linux', '/home/x/Apps/Hermes.AppImage'),/\/home\/x\/Apps\/Hermes\.AppImage/diff --git a/apps/desktop/electron/desktop-uninstall.ts b/apps/desktop/electron/desktop-uninstall.tsindex 452d8408e3d..049b93985cd 100644--- a/apps/desktop/electron/desktop-uninstall.ts+++ b/apps/desktop/electron/desktop-uninstall.ts@@ -190,7 +190,8 @@ function allowedUninstallModes(kind: InstallKind): string[] {* through Apps & Features, macOS through the Trash, a Linux AppImage is a* single file the user placed somewhere, and a Nix install belongs to the* flake / profile that made it. `appPath` is the resolveRemovableAppPath()- * result (the AppImage path on Linux), used only to name the exact file.+ * result (the .app bundle on macOS, the AppImage path on Linux), used only to+ * name the exact bundle or file.*/function nativeRemovalInstructions(kind, platform, appPath = null) {if (kind === 'nix') {@@ -205,7 +206,11 @@ function nativeRemovalInstructions(kind, platform, appPath = null) {}if (platform === 'darwin') {- return 'Quit the app and drag Hermes.app from Applications to the Trash.'+ // Name the running bundle: channel builds ship under different .app names.+ const bundle = appPath ? path.posix.basename(String(appPath)) : 'the Hermes app'+ const folder = appPath ? path.posix.dirname(String(appPath)) : 'Applications'++ return `Quit the app and drag ${bundle} from ${folder} to the Trash.`}if (appPath && /\.appimage$/i.test(String(appPath))) {diff --git a/apps/desktop/src/app/settings/uninstall-section.test.tsx b/apps/desktop/src/app/settings/uninstall-section.test.tsxindex 9f800ae0119..7e2759bbdc0 100644--- a/apps/desktop/src/app/settings/uninstall-section.test.tsx+++ b/apps/desktop/src/app/settings/uninstall-section.test.tsx@@ -18,7 +18,7 @@ function Surface(): React.JSX.Element {function summary(allowed: boolean): DesktopUninstallSummary {return {code_removal_allowed: allowed,- native_removal_instructions: allowed ? null : 'Quit the app and drag Hermes.app from Applications to the Trash.',+ native_removal_instructions: allowed ? null : 'Quit the app and drag Hermes Agent.app from /Applications to the Trash.',hermes_home: '/test/home',agent_installed: true,gui_installed: true,diff --git a/pm/environments.py b/pm/environments.pyindex c7a9323f216..8a685bfc4f2 100644--- a/pm/environments.py+++ b/pm/environments.py@@ -151,7 +151,8 @@ def _payload_manifest(root: Path) -> dict | None:"""The manifest of the sealed payload whose tree is the resolved *root*, or ``None``.Every install asks, so a ``manifest.json`` that some other tool left beside a- checkout must read as "not a payload", never as an error.+ checkout, or one with a mistyped field, must read as "not a payload", never as an+ error. Readers then take each field with ``.get`` and treat an absent one as unset."""try:manifest = json.loads((root.parent / "manifest.json").read_text(encoding="utf-8-sig"))@@ -159,7 +160,12 @@ def _payload_manifest(root: Path) -> dict | None:return Noneif not isinstance(manifest, dict) or not isinstance(manifest.get("repo"), str):return None- return manifest if (root.parent / manifest["repo"]).resolve() == root else None+ runtime = manifest.get("runtime", {})+ commands = runtime.get("commands", {}) if isinstance(runtime, dict) else None+ well_formed = (isinstance(commands, dict)+ and isinstance(commands.get("hermes", ""), str)+ and all(isinstance(manifest.get(key, ""), str) for key in ("venv", "store")))+ return manifest if well_formed and (root.parent / manifest["repo"]).resolve() == root else Nonedef _payload_path(root: Path, relative: str, what: str) -> Path:@@ -173,13 +179,12 @@ def _payload_path(root: Path, relative: str, what: str) -> Path:def payload_venv(project_root: Path) -> Path | None:"""The environment a sealed payload ships beside its tree, or ``None``."""root = Path(project_root).resolve()- manifest = _payload_manifest(root)- return _payload_path(root, manifest["venv"], "environment") if manifest else None+ venv = (_payload_manifest(root) or {}).get("venv")+ return _payload_path(root, venv, "environment") if venv else Nonedef _payload_hermes_command(root: Path) -> Path | None:- manifest = _payload_manifest(root)- command = manifest.get("runtime", {}).get("commands", {}).get("hermes") if manifest else None+ command = (_payload_manifest(root) or {}).get("runtime", {}).get("commands", {}).get("hermes")return _payload_path(root, command, "launcher") if command else None@@ -217,9 +222,9 @@ def store_root(project_root: Path, *, honor_runtime_override: bool = True) -> Paif override:return Path(override).resolve()root = Path(project_root).resolve()- manifest = _payload_manifest(root)- if manifest is not None:- return _payload_path(root, manifest["store"], "store")+ store = (_payload_manifest(root) or {}).get("store")+ if store:+ return _payload_path(root, store, "store")from pm.paths import install_stamp_pathfor directory in (root, *root.parents):diff --git a/tools/environments/local.py b/tools/environments/local.pyindex d4b205c8bfc..53e82f90d2e 100644--- a/tools/environments/local.py+++ b/tools/environments/local.py@@ -596,6 +596,8 @@ _SANE_PATH = ("/opt/homebrew/bin:/opt/homebrew/sbin:"# ``_SENTINEL`` distinguishes "not resolved yet" from a resolved ``None``._SENTINEL = object()_HERMES_BIN_DIR: "str | None | object" = _SENTINEL+# True when the cached dir is a sealed payload's own launcher dir (see below).+_HERMES_BIN_DIR_IS_PAYLOAD = Falsedef _resolve_hermes_bin_dir() -> str | None:@@ -604,7 +606,7 @@ def _resolve_hermes_bin_dir() -> str | None:``hermes`` exits 127. Order: a sealed payload's own launcher dir; ``which``; absolute``sys.argv[0]`` naming a real hermes executable; ``sys.executable``'s dir if it holdsthe shim."""- global _HERMES_BIN_DIR+ global _HERMES_BIN_DIR, _HERMES_BIN_DIR_IS_PAYLOADif _HERMES_BIN_DIR is not _SENTINEL:return _HERMES_BIN_DIR # type: ignore[return-value]from pm.environments import payload_command_dir@@ -613,7 +615,7 @@ def _resolve_hermes_bin_dir() -> str | None:# build machine's interpreter, so PATH order must not decide which copy children get.payload_dir = payload_command_dir(Path(__file__).resolve().parents[2])if payload_dir is not None and payload_dir.is_dir():- _HERMES_BIN_DIR = str(payload_dir)+ _HERMES_BIN_DIR, _HERMES_BIN_DIR_IS_PAYLOAD = str(payload_dir), Truereturn _HERMES_BIN_DIRwhich = shutil.which("hermes")argv0 = sys.argv[0] if sys.argv else ""@@ -628,12 +630,18 @@ def _resolve_hermes_bin_dir() -> str | None:else:candidate = exe_dir if exe_dir and os.path.isfile(os.path.join(exe_dir, shim)) else None_HERMES_BIN_DIR = candidate if candidate and os.path.isdir(candidate) else None+ _HERMES_BIN_DIR_IS_PAYLOAD = Falsereturn _HERMES_BIN_DIRdef _prepend_hermes_bin_dir(existing_path: str) -> str:- """Prepend the hermes install dir to ``existing_path`` if missing."""+ """Prepend the hermes install dir to ``existing_path`` if missing. A sealed payload's+ launcher dir moves to the front even when already listed: a login PATH can list+ another install's ``hermes`` ahead of it."""bin_dir = _resolve_hermes_bin_dir()+ if bin_dir and _HERMES_BIN_DIR_IS_PAYLOAD:+ rest = [entry for entry in existing_path.split(os.pathsep) if entry and entry != bin_dir]+ return os.pathsep.join([bin_dir, *rest])return _prepend_missing_path_entries(existing_path, [bin_dir] if bin_dir else [])