mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(docker): auto-mount host CWD to /workspace
Fixes #1445 — When using Docker backend, the user's current working directory is now automatically bind-mounted to /workspace inside the container. This allows users to run `cd my-project && hermes` and have their project files accessible to the agent without manual volume config. Changes: - Add host_cwd and auto_mount_cwd parameters to DockerEnvironment - Capture original host CWD in _get_env_config() before container fallback - Pass host_cwd through _create_environment() to Docker backend - Add TERMINAL_DOCKER_NO_AUTO_MOUNT env var to disable if needed - Skip auto-mount when /workspace is already explicitly mounted - Add tests for auto-mount behavior - Add documentation for the new feature The auto-mount is skipped when: 1. TERMINAL_DOCKER_NO_AUTO_MOUNT=true is set 2. User configured docker_volumes with :/workspace 3. persistent_filesystem=true (persistent sandbox mode) This makes the Docker backend behave more intuitively — the agent operates on the user's actual project directory by default.
This commit is contained in:
parent
ce660a4413
commit
8cdbbcaaa2
4 changed files with 222 additions and 2 deletions
|
|
@ -520,6 +520,42 @@ This is useful for:
|
|||
|
||||
Can also be set via environment variable: `TERMINAL_DOCKER_VOLUMES='["/host:/container"]'` (JSON array).
|
||||
|
||||
### Docker Auto-Mount Current Directory
|
||||
|
||||
When using the Docker backend, Hermes **automatically mounts your current working directory** to `/workspace` inside the container. This means you can:
|
||||
|
||||
```bash
|
||||
cd ~/projects/my-app
|
||||
hermes
|
||||
# The agent can now see and edit files in ~/projects/my-app via /workspace
|
||||
```
|
||||
|
||||
No manual volume configuration needed — just `cd` to your project and run `hermes`.
|
||||
|
||||
**How it works:**
|
||||
- If you're in `/home/user/projects/my-app`, that directory is mounted to `/workspace`
|
||||
- The container's working directory is set to `/workspace`
|
||||
- Files you edit on the host are immediately visible to the agent, and vice versa
|
||||
|
||||
**Disabling auto-mount:**
|
||||
|
||||
If you prefer the old behavior (empty `/workspace` with tmpfs or persistent sandbox), disable auto-mount:
|
||||
|
||||
```bash
|
||||
export TERMINAL_DOCKER_NO_AUTO_MOUNT=true
|
||||
```
|
||||
|
||||
**Precedence:**
|
||||
|
||||
Auto-mount is skipped when:
|
||||
1. `TERMINAL_DOCKER_NO_AUTO_MOUNT=true` is set
|
||||
2. You've explicitly configured a volume mount to `/workspace` in `docker_volumes`
|
||||
3. `container_persistent: true` is set (persistent sandbox mode uses its own `/workspace`)
|
||||
|
||||
:::tip
|
||||
Auto-mount is ideal for project-based work where you want the agent to operate on your actual files. For isolated sandboxing where the agent shouldn't access your filesystem, set `TERMINAL_DOCKER_NO_AUTO_MOUNT=true`.
|
||||
:::
|
||||
|
||||
### Persistent Shell
|
||||
|
||||
By default, each terminal command runs in its own subprocess — working directory, environment variables, and shell variables reset between commands. When **persistent shell** is enabled, a single long-lived bash process is kept alive across `execute()` calls so that state survives between commands.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue