From a92d4c199c0215dc231ebbc08753ace5b6e48618 Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 11 Nov 2026 07:17:42 -0700 Subject: [PATCH] Mac: Hermes quick fixes from the setup review Via hermes_settings (now compared structurally, with null = unset, and a gateway restart on change): - timezone America/Denver (was unset) - auth.adopt_external_logins false: never borrow Claude Code's login - terminal.cwd unset: stops the /workspace warnings (#140527) - agent.disabled_toolsets [kanban]: unused, 25 KB of tool schema per call - skills.write_approval true - approvals.deny: force-push, curl|sh, dd to devices (docs' examples) - streaming.enabled true, stt.local.model small - terminal.container_memory 3072, inside a 4 GB Podman VM (was 2 GB VM with a 5 GB container limit), set by a new podman task Co-Authored-By: Claude Opus 5.5 --- group_vars/mac/main.yml | 24 ++++++++++++++++++++++++ roles/mac/README.md | 10 ++++++++-- roles/mac/handlers/main.yml | 6 ++++++ roles/mac/tasks/hermes-settings.yml | 15 ++++++++++++--- roles/mac/tasks/main.yml | 4 ++++ roles/mac/tasks/podman.yml | 16 ++++++++++++++++ 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 roles/mac/tasks/podman.yml diff --git a/group_vars/mac/main.yml b/group_vars/mac/main.yml index 0c6c78c..8ddfcb2 100644 --- a/group_vars/mac/main.yml +++ b/group_vars/mac/main.yml @@ -27,8 +27,32 @@ hermes_dashboard_username: admin # Individual Hermes settings, set with `hermes config set`. The rest of # ~/.hermes/config.yaml stays Hermes's own (its updates migrate that file). +# A value of null removes the key (back to Hermes's default). hermes_settings: updates.pre_update_backup: full # zip of ~/.hermes before every update + timezone: America/Denver # cron schedules and the time in the prompt + # Never borrow Claude Code's login: subscription use outside Anthropic's own + # apps breaks its terms, and refreshing it can break Claude Code's login. + auth.adopt_external_logins: false + # Container path the host checks and warns about (hermes-agent #140527); + # the sandbox uses its own home directory without it. + terminal.cwd: null + terminal.container_memory: 3072 # MB; must fit in the Podman VM (podman_machine_memory) + # Kanban is for multi-agent boards (unused here) and its 14 tools were 25 KB + # of the 65 KB of tool definitions sent with every message. + agent.disabled_toolsets: [kanban] + skills.write_approval: true # skills Hermes writes wait for your approval + # Never run these, even in the sandbox and even under /yolo (examples from + # Hermes's hardening guide). Case-insensitive globs over the whole command. + approvals.deny: + - "git push --force*" + - "*curl*|*sh*" + - "dd if=* of=/dev/*" + streaming.enabled: true # replies stream into Telegram as they're written + stt.local.model: small # voice notes: more accurate than base + +# Podman VM that runs Hermes's sandbox containers. +podman_machine_memory: 4096 # MB # Hermes cron jobs. `script` is a file in roles/mac/files/hermes-scripts/, # copied to ~/.hermes/scripts/. Jobs are created when missing; to change one, diff --git a/roles/mac/README.md b/roles/mac/README.md index f402db5..24c3d24 100644 --- a/roles/mac/README.md +++ b/roles/mac/README.md @@ -24,8 +24,14 @@ Manages cogitator-02, an Apple Silicon Mac on the tailnet (`mac.yml`, demands a login through it; if not, it turns Serve off and fails. - **Hermes settings** (tag `hermes-settings`): the individual keys in `hermes_settings` (`group_vars/mac/main.yml`), checked with - `hermes config get` and fixed with `hermes config set`. Today: a full - backup of `~/.hermes` before every `hermes update`. + `hermes config get` and fixed with `hermes config set` (or `unset` for a + null value); any change restarts the gateway with `hermes gateway restart`. + Covers update backups, timezone, not borrowing Claude Code's login, sandbox + memory, disabled toolsets, skill-write approval, deny rules, streaming and + voice-note transcription. Leave `agent.reasoning_effort` out: `config set` + refuses it without `--force` (hermes-agent #140221). +- **Podman VM** (tag `podman`): `podman_machine_memory` for the VM that runs + Hermes's sandbox. A change stops and restarts the VM. - **Hermes cron jobs** (tag `hermes-cron`): `hermes_cron_jobs` in `group_vars/mac/main.yml`, with their scripts from `files/hermes-scripts/` copied to `~/.hermes/scripts/`. Missing jobs are created; existing ones are diff --git a/roles/mac/handlers/main.yml b/roles/mac/handlers/main.yml index f75ec39..9dd9e22 100644 --- a/roles/mac/handlers/main.yml +++ b/roles/mac/handlers/main.yml @@ -4,3 +4,9 @@ state: restarted # Nothing to restart in a dry run (on the first deploy the plist isn't there). when: not ansible_check_mode + +# Lets running turns finish first (unlike launchctl kickstart -k). +- name: Restart Hermes gateway + ansible.builtin.command: + argv: ["{{ hermes_cli }}", gateway, restart] + when: not ansible_check_mode diff --git a/roles/mac/tasks/hermes-settings.yml b/roles/mac/tasks/hermes-settings.yml index 367df8c..2f1ca4a 100644 --- a/roles/mac/tasks/hermes-settings.yml +++ b/roles/mac/tasks/hermes-settings.yml @@ -1,3 +1,6 @@ +# `hermes config get` prints the value as YAML (or "Config key not set"), so +# it's compared structurally; `hermes config set` takes JSON for lists and +# booleans. A null value means the key should not be set at all. - name: Read Hermes settings ansible.builtin.command: argv: ["{{ hermes_cli }}", config, get, "{{ item.key }}"] @@ -8,8 +11,14 @@ - name: Set Hermes settings ansible.builtin.command: - argv: ["{{ hermes_cli }}", config, set, "{{ item.item.key }}", "{{ item.item.value }}"] + argv: >- + {{ [hermes_cli, 'config', 'unset', item.item.key] if item.item.value is none else + [hermes_cli, 'config', 'set', item.item.key, + item.item.value if item.item.value is string else item.item.value | to_json] }} loop: "{{ hermes_settings_current.results }}" loop_control: - label: "{{ item.item.key }} = {{ item.item.value }}" - when: (item.stdout_lines | last | default('')) != (item.item.value | string) + label: "{{ item.item.key }} = {{ item.item.value | to_json }}" + when: >- + (none if item.stdout is search('^Config key not set') else item.stdout | from_yaml) + != item.item.value + notify: Restart Hermes gateway diff --git a/roles/mac/tasks/main.yml b/roles/mac/tasks/main.yml index cd31323..ba14aad 100644 --- a/roles/mac/tasks/main.yml +++ b/roles/mac/tasks/main.yml @@ -41,3 +41,7 @@ - name: Hermes cron jobs ansible.builtin.import_tasks: hermes-cron.yml tags: hermes-cron + +- name: Podman VM + ansible.builtin.import_tasks: podman.yml + tags: podman diff --git a/roles/mac/tasks/podman.yml b/roles/mac/tasks/podman.yml new file mode 100644 index 0000000..8f828c9 --- /dev/null +++ b/roles/mac/tasks/podman.yml @@ -0,0 +1,16 @@ +# Memory for the Podman VM that runs Hermes's sandbox. Changing it means a +# stop/start, which ends any sandbox containers that are running. +- name: Read Podman VM memory + ansible.builtin.command: + argv: [/opt/podman/bin/podman, machine, inspect, --format, !unsafe "{{.Resources.Memory}}"] + register: podman_memory + changed_when: false + check_mode: false + +- name: Resize the Podman VM + ansible.builtin.shell: | + set -e + /opt/podman/bin/podman machine stop + /opt/podman/bin/podman machine set --memory {{ podman_machine_memory }} + /opt/podman/bin/podman machine start + when: podman_memory.stdout | int != podman_machine_memory