Skip to main content

hermes-sfw

CI License: MIT Python 3.11+

Socket Firewall Free plugin for Hermes Agent.

Block known malicious dependencies during supported dependency operations. Route those operations through sfw for automatic protection — no API key, no config.

sfw action=run command="npm install express"
sfw action=status

quick start

Requires Python 3.11+, Hermes Agent, and the Socket Firewall Free sfw CLI.

Install the prerequisite and the plugin:

npm i -g sfw
python -m pip install hermes-sfw
hermes plugins enable hermes-sfw --no-allow-tool-override

Run /reset or restart Hermes, then verify without installing a throwaway dependency:

sfw --version
python -m pip show hermes-sfw
hermes plugins list --enabled --plain

Inside Hermes:

sfw action=status

If Hermes cannot see the package, install it with the Python environment that owns the hermes executable. See AGENTS.md.

For source development:

git clone https://github.com/TheEpTic/hermes-plugins.git
cd hermes-plugins/hermes-sfw
./deploy.sh
hermes plugins enable hermes-sfw --no-allow-tool-override

Run /reset or restart Hermes after changing the source tree.

Features

sfw run — Execute Commands

Run supported dependency operations through sfw. Known malicious packages are blocked automatically.

# Install a package
sfw action=run command="npm install express"

# Uninstall
sfw action=run command="npm uninstall lodash"

# Python packages
sfw action=run command="pip install flask"
sfw action=run command="uv pip install -r requirements.txt"

# Rust crates
sfw action=run command="cargo add serde"

# With verbose output
sfw action=run command="pnpm add -D vitest" verbose=true

# In a specific directory
sfw action=run command="npm install" workdir="/path/to/project"

Supported package managers: npm, yarn, and pnpm for JavaScript/TypeScript; pip, pip3, and uv for Python; cargo for Rust. npx, rustup, and runner-style subcommands are intentionally blocked because they can execute arbitrary programs.

Blocked packages: When sfw detects a malicious package, the install is blocked and the package name is returned in the response. Non-package-manager commands (like cat, rm, curl) are rejected by the prefix allowlist.

Output truncation: Output exceeding 10,000 characters is intentionally truncated with a size note. The discarded suffix is not returned in another field.

automatic terminal guard

When enabled, the plugin watches Hermes terminal calls. A supported dependency operation such as npm install, uv pip install, or cargo fetch is blocked before raw execution and the agent is directed to use the sfw tool instead.

Set HERMES_SFW_ENFORCE_DIRECT=off before starting Hermes only when you deliberately want direct terminal dependency operations.

sfw status — Check Installation

Verify sfw is installed and get the version.

sfw action=status

Returns: installed (bool), version (string), binary (path).

How It Works

hermes-sfw is a thin wrapper around the sfw CLI. It:

  1. Validates the command starts with an allowed package manager prefix
  2. Resolves and validates the working directory (if specified)
  3. Executes the command through sfw with timeout protection
  4. Parses stdout/stderr for blocked and installed package indicators
  5. Returns structured JSON with success status, output, and parsed results

Configuration

All settings live in src/hermes_sfw/manager.py as an SFWConfig dataclass:

Setting Default Description
sfw_bin sfw Path to the sfw binary
timeout 300s Max seconds per command

Architecture

src/hermes_sfw/
├── __init__.py          # Plugin registration + Hermes hooks
├── manager.py           # SFWManager — command execution + output parsing
├── schemas.py           # Tool schema (what the LLM sees)
├── utils.py             # ok(), err(), require() helpers
├── py.typed             # PEP 561 marker
└── handlers/
    ├── __init__.py
    └── sfw.py           # sfw tool handler

Key design decisions:

  • SFWManager owns all state. No module-level mutable state.
  • Command prefix allowlist prevents arbitrary command execution through sfw.
  • shlex.split() parsing with error handling catches malformed commands early.
  • Output sanitization truncates long outputs to prevent context overflow.
  • OSError errno mapping provides clean error messages without leaking internals.

Security

See SECURITY.md for the full picture.

Defaults you should know about:

  • Only package manager commands are allowed (prefix allowlist: npm, yarn, pnpm, pip, cargo, etc.)
  • Non-package-manager commands (cat, rm, curl, etc.) are rejected
  • Commands run with the permissions of the Hermes agent process

Hardening applied:

  • Command prefix validation via allowlist before execution
  • Commands are passed as an argument vector without invoking a shell
  • shlex.split() handles quoting and rejects malformed command strings early
  • Working directories are expanded, resolved, and checked to be existing directories
  • Output truncated at 10K chars to prevent context overflow
  • Timeout protection prevents hanging installs

Requirements

Troubleshooting

"sfw is not installed" Install sfw globally: npm i -g sfw. The plugin searches PATH and common locations (~/.local/share/pnpm/bin/, /usr/local/bin/, ~/.npm-global/bin/).

Command rejected with "not allowed" Only the documented dependency operations are allowed. Runner-style commands and unsupported subcommands are intentionally rejected; use the regular Hermes terminal only when you deliberately do not want SFW protection.

Command timeout Default timeout is 5 minutes (300s). For very large installs, this may not be enough. Override via SFWConfig(timeout=...) when creating the manager.

Output looks truncated This is intentional. Outputs over 10K characters are truncated to protect context, and the discarded suffix is not retained by the plugin.

Development

git clone https://github.com/TheEpTic/hermes-plugins.git
cd hermes-plugins/hermes-sfw
python -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'

# Run checks
black --check src/hermes_sfw/ tests/
mypy src/hermes_sfw/
pytest

See CONTRIBUTING.md for guidelines.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hermes_sfw-0.2.3.tar.gz (45.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hermes_sfw-0.2.3-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file hermes_sfw-0.2.3.tar.gz.

File metadata

  • Download URL: hermes_sfw-0.2.3.tar.gz
  • Upload date:
  • Size: 45.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for hermes_sfw-0.2.3.tar.gz
Algorithm Hash digest
SHA256 7afad9d0000f93a8e1f6a8d82de5491679fa6ff2effa986ed36e1ba21ce98622
MD5 fca3334c65cd9d4fbb83533f5266a386
BLAKE2b-256 a73df71c4472fc2ed72bcf97c2e57a03be3da041b02a0cf5f2b90cd98dcbe51c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hermes_sfw-0.2.3.tar.gz:

Publisher: pypi-publish-sfw.yml on TheEpTic/hermes-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hermes_sfw-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: hermes_sfw-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for hermes_sfw-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5a7fcbfeeb71de5ce113db8e2fb935bb625661f916677787f52e2a49088c2a24
MD5 78e7da8079ca31aa0246e4d7a3473405
BLAKE2b-256 ccfd764df58881dc91bbd871616a940b3d59dba431f8167f2a4c1498a2e957e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hermes_sfw-0.2.3-py3-none-any.whl:

Publisher: pypi-publish-sfw.yml on TheEpTic/hermes-plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.12

2 files

0.2.11

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

This release

0.2.3 This release

2 files

0.2.2

2 files

0.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page