Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/ghost-uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if [ -x "$ENG/.hermes/bin/hermes" ]; then
HERMES_HOME="$GHOST_HOME" "$ENG/.hermes/bin/hermes" -p uncensored gateway stop </dev/null >/dev/null 2>&1
UNIT="$HOME/Library/LaunchAgents/ai.hermes.gateway-uncensored.plist"
[ -f "$UNIT" ] || UNIT="$HOME/.config/systemd/user/hermes-gateway-uncensored.service"
if [ -f "$UNIT" ] && grep -qF "$ENG/" "$UNIT"; then
if [ -f "$UNIT" ] && grep -qF -e "$ENG/" -e "$GHOST_HOME/" "$UNIT"; then
HERMES_HOME="$GHOST_HOME" "$ENG/.hermes/bin/hermes" -p uncensored gateway uninstall </dev/null >/dev/null 2>&1
fi
fi
Expand Down
3 changes: 2 additions & 1 deletion scripts/fork-engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ case "$(uname -s)" in
*) UNIT="$HOME/.config/systemd/user/hermes-gateway-uncensored.service"
service_running() { systemctl --user is-active --quiet hermes-gateway-uncensored.service 2>/dev/null; } ;;
esac
service_installed() { [ -f "$UNIT" ] && grep -qF "$ENG/" "$UNIT"; }
# Ours, whichever engine it runs: an old ghost on Linux ran its gateway from ~/.hermes, with ghost's state.
service_installed() { [ -f "$UNIT" ] && grep -qF -e "$ENG/" -e "$GHOST_HOME/" "$UNIT"; }

# The engine's package manager must see only its own toolchain: install.sh exports
# UV_PROJECT_ENVIRONMENT for ghost's privacy venv, and uv would happily sync the engine into it.
Expand Down
20 changes: 18 additions & 2 deletions tests/test_fork_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def process(self, shape, *args):
time.sleep(0.05)
return proc

def service(self, running):
def service(self, running, runs=None):
if running:
(self.home / "gateway-on").touch()
rel = ("Library/LaunchAgents/ai.hermes.gateway-uncensored.plist" if platform.system() == "Darwin"
else ".config/systemd/user/hermes-gateway-uncensored.service")
unit = self.home / rel
unit.parent.mkdir(parents=True)
unit.write_text(f"{self.engine}/.hermes/bin/hermes --profile uncensored gateway run")
unit.write_text(runs or f"{self.engine}/.hermes/bin/hermes --profile uncensored gateway run")


@pytest.fixture
Expand Down Expand Up @@ -236,6 +236,22 @@ def test_running_gateway_is_stopped_then_restarted_on_the_new_engine(box):
assert not box.restart.exists()


def test_a_gateway_an_old_ghost_ran_from_elsewhere_is_moved_too(box):
"""On Linux it ran from ~/.hermes/hermes-agent, with ghost's state. Left alone it stayed stopped."""
assert box.run(src=box.source("one")).returncode == 0
box.service(running=True, runs=f"HERMES_HOME={box.state}/profiles/uncensored\n{box.home}/.hermes/hermes-agent/venv/bin/python -m hermes_cli.main")
assert box.run(src=box.source("two")).returncode == 0 and box.restart.exists()
assert box.run("--refresh-gateway").returncode == 0
assert box.calls()[-1] == "-p uncensored gateway install --force --start-now --start-on-login"


def test_someone_elses_gateway_is_not_touched(box):
assert box.run(src=box.source("one")).returncode == 0
box.service(running=True, runs=f"HERMES_HOME={box.home}/.hermes/profiles/uncensored\n{box.home}/.hermes/hermes-agent/venv/bin/python")
assert box.run(src=box.source("two")).returncode == 0 and not box.restart.exists()
assert box.run("--refresh-gateway").returncode == 0 and not [c for c in box.calls() if "gateway install" in c]


def test_gateway_is_started_again_when_the_build_fails(box):
assert box.run(src=box.source("one")).returncode == 0
box.service(running=True)
Expand Down
Loading