hermes-irc-extras 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hermes_irc_extras-0.2.0/LICENSE +21 -0
- hermes_irc_extras-0.2.0/PKG-INFO +137 -0
- hermes_irc_extras-0.2.0/README.md +104 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras/__init__.py +50 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras/patches.py +583 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras/py.typed +1 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras/storage.py +580 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras/tools.py +385 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras.egg-info/PKG-INFO +137 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras.egg-info/SOURCES.txt +16 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras.egg-info/dependency_links.txt +1 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras.egg-info/entry_points.txt +2 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras.egg-info/requires.txt +7 -0
- hermes_irc_extras-0.2.0/hermes_irc_extras.egg-info/top_level.txt +1 -0
- hermes_irc_extras-0.2.0/pyproject.toml +58 -0
- hermes_irc_extras-0.2.0/setup.cfg +4 -0
- hermes_irc_extras-0.2.0/tests/test_channel_logging.py +971 -0
- hermes_irc_extras-0.2.0/tests/test_irc_extras.py +296 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 b3nw
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hermes-irc-extras
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Hermes Agent plugin: Additional features and security extensions for the IRC relay (unverified SSL, SASL).
|
|
5
|
+
Author-email: b3nw <b3nw@duck.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/b3nw/hermes-irc-extras
|
|
8
|
+
Project-URL: Repository, https://github.com/b3nw/hermes-irc-extras
|
|
9
|
+
Project-URL: Issues, https://github.com/b3nw/hermes-irc-extras/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/b3nw/hermes-irc-extras/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: hermes-agent,plugin,irc,relay,ssl,sasl
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-timeout>=2; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
31
|
+
Requires-Dist: pyyaml>=6; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# hermes-irc-extras
|
|
35
|
+
|
|
36
|
+
A plugin for [Hermes Agent](https://hermes-agent.nousresearch.com/) that adds features and security options to the IRC gateway adapter.
|
|
37
|
+
|
|
38
|
+
The first feature implements an option to **Accept Invalid or Self-Signed TLS Certificates** (`IRC_ALLOW_INVALID_SSL`) for connections to private IRC bouncers (such as ZNC), InspIRCd, or ergo test networks.
|
|
39
|
+
|
|
40
|
+
The second adds opt-in **passive channel logging** (`IRC_ENABLE_CHANNEL_LOGGING`) so the agent can search channel scrollback without spending a turn on every message it sees.
|
|
41
|
+
|
|
42
|
+
## Features & Configuration
|
|
43
|
+
|
|
44
|
+
- **Precedence-Aware:** Environment variables (`IRC_ALLOW_INVALID_SSL`) override `config.yaml` (`allow_invalid_ssl`) parameters.
|
|
45
|
+
- **Defensive Boolean Parsing:** Unquoted or quoted string values in configuration (e.g. `"true"`, `"yes"`, `"1"`, `"false"`, `"0"`, `"no"`) are defensively parsed.
|
|
46
|
+
- **Dynamic UI Integration:** Automatic integration with Hermes WebUI and Desktop UI configuration cards.
|
|
47
|
+
|
|
48
|
+
### Setup
|
|
49
|
+
|
|
50
|
+
Configure the option in your `.env` or `config.yaml`:
|
|
51
|
+
|
|
52
|
+
#### Environment Variables (`.env`)
|
|
53
|
+
```bash
|
|
54
|
+
IRC_ALLOW_INVALID_SSL=true
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Configuration File (`config.yaml`)
|
|
58
|
+
```yaml
|
|
59
|
+
gateway:
|
|
60
|
+
platforms:
|
|
61
|
+
irc:
|
|
62
|
+
enabled: true
|
|
63
|
+
server: "irc.mybouncer.internal"
|
|
64
|
+
port: 6697
|
|
65
|
+
use_tls: true
|
|
66
|
+
allow_invalid_ssl: true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Passive Channel Logging (opt-in, default OFF)
|
|
70
|
+
|
|
71
|
+
Lets the agent monitor channels and query scrollback **without spending LLM turns on
|
|
72
|
+
messages nobody addressed to it**. Every `PRIVMSG` is written to a local SQLite database
|
|
73
|
+
before the adapter's own addressing/authorization gates run; those gates are unchanged, so
|
|
74
|
+
unaddressed traffic and traffic from users outside `IRC_ALLOWED_USERS` is recorded and then
|
|
75
|
+
dropped — zero agent turns, zero API cost, no reply to the channel.
|
|
76
|
+
|
|
77
|
+
When enabled, two read-only tools are registered for the agent:
|
|
78
|
+
|
|
79
|
+
- `search_irc_logs(query, channel?, nick?, hours?, limit?)` — FTS5 keyword/phrase search.
|
|
80
|
+
- `get_channel_history(channel, nick?, hours?, limit?)` — recent chronological scrollback.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
IRC_ENABLE_CHANNEL_LOGGING=true # default: false
|
|
84
|
+
IRC_CHANNEL_LOG_DB_PATH= # default: {profile}/state/irc_channel_logs.db
|
|
85
|
+
IRC_CHANNEL_LOG_RETENTION_DAYS=14 # 0 keeps everything; pruning is automatic
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
gateway:
|
|
90
|
+
platforms:
|
|
91
|
+
irc:
|
|
92
|
+
extra:
|
|
93
|
+
enable_channel_logging: true
|
|
94
|
+
channel_log_db_path: null
|
|
95
|
+
channel_log_retention_days: 14
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
⚠️ **This records other people's conversations.** Enabling it logs every message in the
|
|
99
|
+
channels the bot sits in, including from users who cannot instruct the agent at all — and
|
|
100
|
+
every direct message sent to the bot. Each row keeps the sender's nick and their
|
|
101
|
+
`user@host` (their hostname or cloak) next to the message text, the channel and the
|
|
102
|
+
timestamp; direct messages are filed under the sender's nick and are readable through the
|
|
103
|
+
same two tools. Old rows are pruned on the retention schedule above, and a new database
|
|
104
|
+
file is created with owner-only (`0600`) permissions — but any account that can read the
|
|
105
|
+
profile directory can still read the log. Check local expectations, any network policy and
|
|
106
|
+
any data-protection obligation before turning it on. Nothing is written while the flag is
|
|
107
|
+
off — the database is not even created.
|
|
108
|
+
|
|
109
|
+
⚠️ **Log contents are untrusted input.** Tool results are framed in the host's
|
|
110
|
+
`<untrusted_tool_result>` data boundary (with the boundary token defanged inside the
|
|
111
|
+
payload) so a passer-by in a logged channel cannot use the log as an indirect
|
|
112
|
+
prompt-injection channel into the agent.
|
|
113
|
+
|
|
114
|
+
## Installation
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Clone the repository
|
|
118
|
+
git clone https://github.com/b3nw/hermes-irc-extras.git ~/.hermes/plugins/hermes-irc-extras
|
|
119
|
+
|
|
120
|
+
# Install in editable mode
|
|
121
|
+
pip install -e ~/.hermes/plugins/hermes-irc-extras
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Running Tests
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install -e ".[dev]"
|
|
128
|
+
pytest tests/test_irc_extras.py
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Security Warning
|
|
132
|
+
|
|
133
|
+
⚠️ **Disabling TLS verification leaves the connection vulnerable to Man-in-the-Middle (MITM) attacks.** The traffic remains encrypted but is no longer authenticated. Enable this option only with servers and networks you control.
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT License — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# hermes-irc-extras
|
|
2
|
+
|
|
3
|
+
A plugin for [Hermes Agent](https://hermes-agent.nousresearch.com/) that adds features and security options to the IRC gateway adapter.
|
|
4
|
+
|
|
5
|
+
The first feature implements an option to **Accept Invalid or Self-Signed TLS Certificates** (`IRC_ALLOW_INVALID_SSL`) for connections to private IRC bouncers (such as ZNC), InspIRCd, or ergo test networks.
|
|
6
|
+
|
|
7
|
+
The second adds opt-in **passive channel logging** (`IRC_ENABLE_CHANNEL_LOGGING`) so the agent can search channel scrollback without spending a turn on every message it sees.
|
|
8
|
+
|
|
9
|
+
## Features & Configuration
|
|
10
|
+
|
|
11
|
+
- **Precedence-Aware:** Environment variables (`IRC_ALLOW_INVALID_SSL`) override `config.yaml` (`allow_invalid_ssl`) parameters.
|
|
12
|
+
- **Defensive Boolean Parsing:** Unquoted or quoted string values in configuration (e.g. `"true"`, `"yes"`, `"1"`, `"false"`, `"0"`, `"no"`) are defensively parsed.
|
|
13
|
+
- **Dynamic UI Integration:** Automatic integration with Hermes WebUI and Desktop UI configuration cards.
|
|
14
|
+
|
|
15
|
+
### Setup
|
|
16
|
+
|
|
17
|
+
Configure the option in your `.env` or `config.yaml`:
|
|
18
|
+
|
|
19
|
+
#### Environment Variables (`.env`)
|
|
20
|
+
```bash
|
|
21
|
+
IRC_ALLOW_INVALID_SSL=true
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Configuration File (`config.yaml`)
|
|
25
|
+
```yaml
|
|
26
|
+
gateway:
|
|
27
|
+
platforms:
|
|
28
|
+
irc:
|
|
29
|
+
enabled: true
|
|
30
|
+
server: "irc.mybouncer.internal"
|
|
31
|
+
port: 6697
|
|
32
|
+
use_tls: true
|
|
33
|
+
allow_invalid_ssl: true
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Passive Channel Logging (opt-in, default OFF)
|
|
37
|
+
|
|
38
|
+
Lets the agent monitor channels and query scrollback **without spending LLM turns on
|
|
39
|
+
messages nobody addressed to it**. Every `PRIVMSG` is written to a local SQLite database
|
|
40
|
+
before the adapter's own addressing/authorization gates run; those gates are unchanged, so
|
|
41
|
+
unaddressed traffic and traffic from users outside `IRC_ALLOWED_USERS` is recorded and then
|
|
42
|
+
dropped — zero agent turns, zero API cost, no reply to the channel.
|
|
43
|
+
|
|
44
|
+
When enabled, two read-only tools are registered for the agent:
|
|
45
|
+
|
|
46
|
+
- `search_irc_logs(query, channel?, nick?, hours?, limit?)` — FTS5 keyword/phrase search.
|
|
47
|
+
- `get_channel_history(channel, nick?, hours?, limit?)` — recent chronological scrollback.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
IRC_ENABLE_CHANNEL_LOGGING=true # default: false
|
|
51
|
+
IRC_CHANNEL_LOG_DB_PATH= # default: {profile}/state/irc_channel_logs.db
|
|
52
|
+
IRC_CHANNEL_LOG_RETENTION_DAYS=14 # 0 keeps everything; pruning is automatic
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
gateway:
|
|
57
|
+
platforms:
|
|
58
|
+
irc:
|
|
59
|
+
extra:
|
|
60
|
+
enable_channel_logging: true
|
|
61
|
+
channel_log_db_path: null
|
|
62
|
+
channel_log_retention_days: 14
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
⚠️ **This records other people's conversations.** Enabling it logs every message in the
|
|
66
|
+
channels the bot sits in, including from users who cannot instruct the agent at all — and
|
|
67
|
+
every direct message sent to the bot. Each row keeps the sender's nick and their
|
|
68
|
+
`user@host` (their hostname or cloak) next to the message text, the channel and the
|
|
69
|
+
timestamp; direct messages are filed under the sender's nick and are readable through the
|
|
70
|
+
same two tools. Old rows are pruned on the retention schedule above, and a new database
|
|
71
|
+
file is created with owner-only (`0600`) permissions — but any account that can read the
|
|
72
|
+
profile directory can still read the log. Check local expectations, any network policy and
|
|
73
|
+
any data-protection obligation before turning it on. Nothing is written while the flag is
|
|
74
|
+
off — the database is not even created.
|
|
75
|
+
|
|
76
|
+
⚠️ **Log contents are untrusted input.** Tool results are framed in the host's
|
|
77
|
+
`<untrusted_tool_result>` data boundary (with the boundary token defanged inside the
|
|
78
|
+
payload) so a passer-by in a logged channel cannot use the log as an indirect
|
|
79
|
+
prompt-injection channel into the agent.
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Clone the repository
|
|
85
|
+
git clone https://github.com/b3nw/hermes-irc-extras.git ~/.hermes/plugins/hermes-irc-extras
|
|
86
|
+
|
|
87
|
+
# Install in editable mode
|
|
88
|
+
pip install -e ~/.hermes/plugins/hermes-irc-extras
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Running Tests
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install -e ".[dev]"
|
|
95
|
+
pytest tests/test_irc_extras.py
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Security Warning
|
|
99
|
+
|
|
100
|
+
⚠️ **Disabling TLS verification leaves the connection vulnerable to Man-in-the-Middle (MITM) attacks.** The traffic remains encrypted but is no longer authenticated. Enable this option only with servers and networks you control.
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT License — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""hermes-irc-extras — Additional features and security extensions for the IRC relay.
|
|
2
|
+
|
|
3
|
+
A standalone, fork-free Hermes Agent plugin.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
__version__ = "0.2.0"
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def register(ctx=None) -> None:
|
|
16
|
+
"""Plugin entry point — called once at startup by the Hermes plugin loader.
|
|
17
|
+
|
|
18
|
+
Safely installs the IRC extras monkeypatches onto the core adapter modules
|
|
19
|
+
without modifying the core files on disk. If the host environment does not
|
|
20
|
+
support these extensions, logs a warning and exits cleanly without throwing.
|
|
21
|
+
|
|
22
|
+
When channel logging is enabled — in the environment or in ``config.yaml``
|
|
23
|
+
— also registers the log inspection tools so the agent can query scrollback
|
|
24
|
+
on demand. With logging off (the default) no tools are registered at all.
|
|
25
|
+
The context is handed to the patch module as well: an adapter whose own
|
|
26
|
+
config turns logging on can then register the tools itself, late.
|
|
27
|
+
"""
|
|
28
|
+
from .patches import apply_patches, note_plugin_context
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
active = apply_patches()
|
|
32
|
+
except Exception:
|
|
33
|
+
logger.exception("hermes-irc-extras: unexpected error during initialization")
|
|
34
|
+
return
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
from .tools import register_tools
|
|
38
|
+
|
|
39
|
+
note_plugin_context(ctx, register_tools(ctx))
|
|
40
|
+
except Exception:
|
|
41
|
+
# A tool-registration failure must not cost the host the SSL patches.
|
|
42
|
+
logger.exception("hermes-irc-extras: failed to register IRC channel log tools")
|
|
43
|
+
|
|
44
|
+
if active:
|
|
45
|
+
logger.info("hermes-irc-extras v%s active", __version__)
|
|
46
|
+
else:
|
|
47
|
+
logger.warning(
|
|
48
|
+
"hermes-irc-extras v%s loaded but INACTIVE (host unavailable "
|
|
49
|
+
"or unsupported adapter signature)", __version__
|
|
50
|
+
)
|