Skip to content

feat: add SimpleX Chat gateway adapter (#2557)#2558

Closed
Mibayy wants to merge 1 commit into
NousResearch:mainfrom
Mibayy:feature/simplex-adapter
Closed

feat: add SimpleX Chat gateway adapter (#2557)#2558
Mibayy wants to merge 1 commit into
NousResearch:mainfrom
Mibayy:feature/simplex-adapter

Conversation

@Mibayy

@Mibayy Mibayy commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Closes #2557

Adds full SimpleX Chat support as a gateway messaging platform. SimpleX is a private, decentralised messenger with no persistent user IDs — a natural complement to the existing Signal adapter.

SimpleX runs a local simplex-chat daemon that exposes a WebSocket API. Hermes connects to it, listens for inbound messages, and sends replies.

Changes

Core adapter (gateway/platforms/simplex.py):

  • Persistent WebSocket connection to the simplex-chat daemon (-p 5225)
  • Reconnect loop with exponential backoff + 20% jitter
  • Health monitor that force-reconnects on stale connections
  • Inbound: handles newChatItem / newChatItems events for DMs and groups
  • Outbound: sends @[contact-id] / #[group-id] commands via WS
  • File attachment support with local cache (image/audio/document)
  • Filters own echoes via corrId prefix
  • Requires: pip install websockets

All 16 ADDING_A_PLATFORM.md touch points covered:

  • gateway/config.py — Platform.SIMPLEX enum + env var loading
  • gateway/run.py — _create_adapter() factory + both auth allowlist maps
  • agent/prompt_builder.py — PLATFORM_HINTS["simplex"]
  • toolsets.py — hermes-simplex toolset + hermes-gateway include
  • cron/scheduler.py — platform_map entry
  • tools/send_message_tool.py — platform_map + _send_simplex() standalone fn
  • gateway/channel_directory.py — session-based contact discovery
  • hermes_cli/status.py — status display
  • hermes_cli/gateway.py — _PLATFORMS entry + _setup_simplex() wizard
  • website/docs/user-guide/messaging/simplex.md — setup guide
  • tests/gateway/test_simplex.py — test suite

Environment variables:
SIMPLEX_WS_URL WebSocket URL (default ws://127.0.0.1:5225)
SIMPLEX_ALLOWED_USERS Comma-separated allowed contact IDs
SIMPLEX_ALLOW_ALL_USERS Set true to allow all contacts
SIMPLEX_HOME_CHANNEL Default contact for cron delivery
SIMPLEX_HOME_CHANNEL_NAME Human label for home channel

Quick start:
simplex-chat -p 5225
hermes setup gateway # select SimpleX Chat

Tests:
python -m pytest tests/gateway/test_simplex.py -v

Closes NousResearch#2557

SimpleX Chat is a private, decentralised messaging platform where
users own their contacts and groups without persistent identifiers.

This PR adds full gateway support following the ADDING_A_PLATFORM.md
checklist (all 16 points covered):

Core adapter (gateway/platforms/simplex.py):
- WebSocket-based connection to the simplex-chat daemon (-p 5225)
- Persistent WS listener with exponential-backoff reconnect + jitter
- Health monitor that force-reconnects on stale connections
- Inbound: handles newChatItem / newChatItems events, DMs and groups
- Outbound: send() via WS JSON commands (@[id] msg / #[id] msg)
- File attachment support with local path cache (image/audio/document)
- Filters own echoes via corrId prefix
- Requires: pip install websockets

Integration points:
- gateway/config.py        — Platform.SIMPLEX enum + env var loading
- gateway/run.py           — _create_adapter() + both auth allowlist maps
- toolsets.py              — hermes-simplex toolset + hermes-gateway include
- cron/scheduler.py        — platform_map for cron delivery
- tools/send_message_tool.py — platform_map + _send_simplex() standalone fn
- agent/prompt_builder.py  — PLATFORM_HINTS["simplex"]
- gateway/channel_directory.py — session-based contact discovery
- hermes_cli/status.py     — SIMPLEX_WS_URL status display
- hermes_cli/gateway.py    — _PLATFORMS entry + _setup_simplex() wizard

Tests (tests/gateway/test_simplex.py):
- Platform enum value
- Env var config loading (with/without home channel)
- Adapter init (default URL, custom URL)
- check_simplex_requirements()
- Auth allowlist map coverage
- Helper functions (_guess_extension, _is_image_ext, _is_audio_ext)
- _make_corr_id uniqueness
- send() DM and group routing (mock WS)

Docs (website/docs/user-guide/messaging/simplex.md):
- Install and start the daemon
- Setup wizard and env var reference
- Authorization model (allowlist / DM pairing)
- Cron delivery examples
- Privacy notes and troubleshooting

Environment variables:
  SIMPLEX_WS_URL             WebSocket URL of daemon (default: ws://127.0.0.1:5225)
  SIMPLEX_ALLOWED_USERS      Comma-separated allowed contact IDs
  SIMPLEX_ALLOW_ALL_USERS    Set true to allow all contacts
  SIMPLEX_HOME_CHANNEL       Default contact ID for cron delivery
  SIMPLEX_HOME_CHANNEL_NAME  Human label for home channel
@Tim-Rambo

Copy link
Copy Markdown

Wow, that was fast. I wanted someone with more experience to the programming. I am more or less having fun building things and trying to get as much experience as I can, I am getting there. Thank you. 🙏

@marospekarik

Copy link
Copy Markdown

Indeed, I have built a similar setup today and happy to see already a PR. +1

@alumbigi

Copy link
Copy Markdown

+1

@ElonSatoshi

Copy link
Copy Markdown
image

@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have labels May 3, 2026
teknium1 pushed a commit that referenced this pull request May 15, 2026
SimpleX Chat (https://simplex.chat) is a private, decentralised messenger
with no persistent user IDs — every contact is identified by an opaque
internal ID generated at connection time. This adds it as a Hermes
gateway platform via the plugin system.

The adapter connects to a local simplex-chat daemon via WebSocket,
listens for inbound messages, and sends replies. Originally proposed in
PR #2558 as a core-modifying integration; reshaped here as a self-
contained plugin under plugins/platforms/simplex/ with no edits to any
core file. Discovery is filesystem-based (scanned by gateway.config),
and the platform identity is resolved on demand via Platform("simplex").

Plugin contract:
- check_requirements() requires SIMPLEX_WS_URL AND the websockets package
- validate_config() / is_connected() accept env or config.yaml input
- _env_enablement() seeds PlatformConfig.extra (ws_url + home_channel)
- _standalone_send() supports out-of-process cron delivery
- interactive_setup() provides a stdin wizard for hermes gateway setup
- register() wires the adapter into the registry with required_env,
  install_hint, cron_deliver_env_var, allowed_users_env, and a
  platform_hint for the LLM.

Lazy dependency: the websockets Python package is imported inside the
functions that need it. The plugin is importable and discoverable even
when websockets is missing — check_requirements() simply returns False
until `pip install websockets` is run. No new pyproject extras are
introduced.

Environment variables:
  SIMPLEX_WS_URL             WebSocket URL of the daemon (required)
  SIMPLEX_ALLOWED_USERS      Comma-separated allowed contact IDs
  SIMPLEX_ALLOW_ALL_USERS    Set true to allow all contacts
  SIMPLEX_HOME_CHANNEL       Default contact for cron delivery
  SIMPLEX_HOME_CHANNEL_NAME  Human label for the home channel

Closes #2557.
@teknium1

Copy link
Copy Markdown
Contributor

Salvaged onto current main and merged via #26232 — reshaped from the original 12-file core integration into a self-contained platform plugin under plugins/platforms/simplex/ (zero core edits), with lazy websockets import gated by check_requirements(), 27 new tests, and your authorship preserved on the feat commit. Thanks for the SimpleX adapter @Mibayy!

@teknium1 teknium1 closed this May 15, 2026
DIZ-admin pushed a commit to DIZ-admin/hermes-agent that referenced this pull request May 16, 2026
SimpleX Chat (https://simplex.chat) is a private, decentralised messenger
with no persistent user IDs — every contact is identified by an opaque
internal ID generated at connection time. This adds it as a Hermes
gateway platform via the plugin system.

The adapter connects to a local simplex-chat daemon via WebSocket,
listens for inbound messages, and sends replies. Originally proposed in
PR NousResearch#2558 as a core-modifying integration; reshaped here as a self-
contained plugin under plugins/platforms/simplex/ with no edits to any
core file. Discovery is filesystem-based (scanned by gateway.config),
and the platform identity is resolved on demand via Platform("simplex").

Plugin contract:
- check_requirements() requires SIMPLEX_WS_URL AND the websockets package
- validate_config() / is_connected() accept env or config.yaml input
- _env_enablement() seeds PlatformConfig.extra (ws_url + home_channel)
- _standalone_send() supports out-of-process cron delivery
- interactive_setup() provides a stdin wizard for hermes gateway setup
- register() wires the adapter into the registry with required_env,
  install_hint, cron_deliver_env_var, allowed_users_env, and a
  platform_hint for the LLM.

Lazy dependency: the websockets Python package is imported inside the
functions that need it. The plugin is importable and discoverable even
when websockets is missing — check_requirements() simply returns False
until `pip install websockets` is run. No new pyproject extras are
introduced.

Environment variables:
  SIMPLEX_WS_URL             WebSocket URL of the daemon (required)
  SIMPLEX_ALLOWED_USERS      Comma-separated allowed contact IDs
  SIMPLEX_ALLOW_ALL_USERS    Set true to allow all contacts
  SIMPLEX_HOME_CHANNEL       Default contact for cron delivery
  SIMPLEX_HOME_CHANNEL_NAME  Human label for the home channel

Closes NousResearch#2557.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
SimpleX Chat (https://simplex.chat) is a private, decentralised messenger
with no persistent user IDs — every contact is identified by an opaque
internal ID generated at connection time. This adds it as a Hermes
gateway platform via the plugin system.

The adapter connects to a local simplex-chat daemon via WebSocket,
listens for inbound messages, and sends replies. Originally proposed in
PR NousResearch#2558 as a core-modifying integration; reshaped here as a self-
contained plugin under plugins/platforms/simplex/ with no edits to any
core file. Discovery is filesystem-based (scanned by gateway.config),
and the platform identity is resolved on demand via Platform("simplex").

Plugin contract:
- check_requirements() requires SIMPLEX_WS_URL AND the websockets package
- validate_config() / is_connected() accept env or config.yaml input
- _env_enablement() seeds PlatformConfig.extra (ws_url + home_channel)
- _standalone_send() supports out-of-process cron delivery
- interactive_setup() provides a stdin wizard for hermes gateway setup
- register() wires the adapter into the registry with required_env,
  install_hint, cron_deliver_env_var, allowed_users_env, and a
  platform_hint for the LLM.

Lazy dependency: the websockets Python package is imported inside the
functions that need it. The plugin is importable and discoverable even
when websockets is missing — check_requirements() simply returns False
until `pip install websockets` is run. No new pyproject extras are
introduced.

Environment variables:
  SIMPLEX_WS_URL             WebSocket URL of the daemon (required)
  SIMPLEX_ALLOWED_USERS      Comma-separated allowed contact IDs
  SIMPLEX_ALLOW_ALL_USERS    Set true to allow all contacts
  SIMPLEX_HOME_CHANNEL       Default contact for cron delivery
  SIMPLEX_HOME_CHANNEL_NAME  Human label for the home channel

Closes NousResearch#2557.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add SimpleX Chat, Chat Adapter

7 participants