feat(nix): container-aware CLI — auto-route hermes chat into managed container - #27089
Closed
Master-Rensei wants to merge 1 commit into
Closed
feat(nix): container-aware CLI — auto-route hermes chat into managed container#27089Master-Rensei wants to merge 1 commit into
Master-Rensei wants to merge 1 commit into
Conversation
…container When container.enable = true in the NixOS module, running 'hermes chat' on the host now automatically execs into the managed container via docker/podman exec. This means the interactive CLI runs in the same environment as the gateway service, with access to all container-installed packages and tools. Implementation: - NixOS activation script writes .container-mode metadata file to HERMES_HOME with backend, container_name, and hermes_bin path - File is removed when container mode is disabled (nixos-rebuild switch) - hermes_cli/config.py: _is_inside_container() detects Docker/Podman indicators (/.dockerenv, /run/.containerenv, cgroup) - hermes_cli/config.py: get_container_exec_info() reads .container-mode metadata, returns None when already inside a container - hermes_cli/main.py: _exec_in_container() validates the container is running, then os.execvp() replaces the process with the container exec - cmd_chat intercepts before normal flow, checks container info, execs Safety: - --host flag bypasses container routing (run on host regardless) - Falls back to host CLI if: container runtime not found, container not running, inspect fails, or any detection error - Strips --host from forwarded args (not meaningful inside container) - Already-inside-container detection prevents infinite exec loops Closes #7380
Collaborator
|
Duplicate of #7543 (already merged). This PR reopens a previously closed fork branch, but the feature (container-aware CLI) was already landed via a salvage PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
container.enable = truein the NixOS module, runninghermes chaton the host now automatically execs into the managed container viadocker/podman exec. The interactive CLI runs in the same environment as the gateway service — with access to all container-installed packages and tools.Previously, users had to manually run:
Now they just run:
How it works
NixOS activation script writes a
.container-modemetadata file toHERMES_HOMEcontainingbackend,container_name, andhermes_bin. File is removed when container mode is disabled.Host CLI detection (
hermes_cli/config.py):_is_inside_container()— detects/.dockerenv,/run/.containerenv, and cgroup markers to prevent infinite exec loopsget_container_exec_info()— reads.container-mode, returnsNoneif already inside a container or file doesn't existContainer exec (
hermes_cli/main.py):_exec_in_container()validates the container runtime exists and is running, thenos.execvp()replaces the processcmd_chatintercepts before normal flow to check for container routingSafety & fallback
--hostflag bypasses container routing--hostis stripped from forwarded args (not meaningful inside container)Files changed
hermes_cli/config.py_is_inside_container(),get_container_exec_info()hermes_cli/main.py_exec_in_container(),--hostflag,cmd_chatinterceptnix/nixosModules.nix.container-modein activation scripttests/hermes_cli/test_container_aware_cli.pywebsite/docs/getting-started/nix-setup.mdTest plan
container.enable = true+addToSystemPackages = true--hostbypasses container routingCloses #7380
Reopens closed PR #7470 (by @alt-glitch) from fork
Master-Rensei/hermes-agent