hermes-atm 1.4.4__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_atm-1.4.4/PKG-INFO +113 -0
- hermes_atm-1.4.4/README.md +93 -0
- hermes_atm-1.4.4/pyproject.toml +28 -0
- hermes_atm-1.4.4/setup.cfg +4 -0
- hermes_atm-1.4.4/src/hermes_atm/__init__.py +17 -0
- hermes_atm-1.4.4/src/hermes_atm/__main__.py +4 -0
- hermes_atm-1.4.4/src/hermes_atm/hook.py +81 -0
- hermes_atm-1.4.4/src/hermes_atm/installer.py +361 -0
- hermes_atm-1.4.4/src/hermes_atm/native_tools.py +238 -0
- hermes_atm-1.4.4/src/hermes_atm/runtime.py +154 -0
- hermes_atm-1.4.4/src/hermes_atm.egg-info/PKG-INFO +113 -0
- hermes_atm-1.4.4/src/hermes_atm.egg-info/SOURCES.txt +16 -0
- hermes_atm-1.4.4/src/hermes_atm.egg-info/dependency_links.txt +1 -0
- hermes_atm-1.4.4/src/hermes_atm.egg-info/requires.txt +1 -0
- hermes_atm-1.4.4/src/hermes_atm.egg-info/top_level.txt +1 -0
- hermes_atm-1.4.4/tests/test_installer.py +400 -0
- hermes_atm-1.4.4/tests/test_native_tools.py +168 -0
- hermes_atm-1.4.4/tests/test_runtime.py +290 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hermes-atm
|
|
3
|
+
Version: 1.4.4
|
|
4
|
+
Summary: Hermes gateway integration for the generic ATM graft receiver
|
|
5
|
+
Author: atm-core contributors
|
|
6
|
+
License: MIT OR Apache-2.0
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: <3.15,>=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: atm-graft<1.5,>=1.4
|
|
20
|
+
|
|
21
|
+
# hermes-atm installation
|
|
22
|
+
|
|
23
|
+
`hermes-atm` is the package-owned Hermes gateway hook for ATM graft nudges.
|
|
24
|
+
It installs one receiver for one Hermes profile and injects delivered nudges
|
|
25
|
+
through the public `GatewayRunner.inject_internal_message(..., mode="queue")`
|
|
26
|
+
API. It does not open an ATM database, select a Hermes adapter, or require any
|
|
27
|
+
post-install source edits.
|
|
28
|
+
|
|
29
|
+
## Required settings
|
|
30
|
+
|
|
31
|
+
Collect these values before installation. Keep the chat identifier in local
|
|
32
|
+
profile configuration or the launch agent; do not put it in source, commits,
|
|
33
|
+
or shared install notes.
|
|
34
|
+
|
|
35
|
+
| Setting | Purpose | Must match |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| `profile` | Hermes profile to receive nudges | Gateway launch profile |
|
|
38
|
+
| `profile_home` | Directory containing that profile's `hooks/` directory | ATM roster `home_dir` |
|
|
39
|
+
| `identity` | ATM agent/member name | ATM roster member name |
|
|
40
|
+
| `team` | ATM team containing the member | ATM roster team |
|
|
41
|
+
| `chat_id` | Hermes session chat binding | Gateway's configured session |
|
|
42
|
+
| `atm_home` | ATM durable home | `ATM_HOME` for the profile |
|
|
43
|
+
| `workspace_root` | Canonical graft endpoint root | ATM roster `workspace_root` exactly |
|
|
44
|
+
| `launch_agent_plist` | Gateway LaunchAgent plist | Its first `ProgramArguments` entry must be the Python running this installer |
|
|
45
|
+
|
|
46
|
+
The `workspace_root` equality is mandatory. ATM post-send delivery resolves a
|
|
47
|
+
recipient endpoint from roster metadata. If the receiver is installed beneath
|
|
48
|
+
one root while the roster names another, `atm send` can persist a message but
|
|
49
|
+
the nudge will fail closed because it cannot find or contact the receiver.
|
|
50
|
+
|
|
51
|
+
## Clean installation sequence
|
|
52
|
+
|
|
53
|
+
1. Install a Hermes Agent version that exposes the public
|
|
54
|
+
`GatewayRunner.inject_internal_message` and `gateway.config.Platform.TELEGRAM`
|
|
55
|
+
host seams.
|
|
56
|
+
2. Configure the profile's launch agent with `ATM_HOME`, `ATM_IDENTITY`,
|
|
57
|
+
`ATM_TEAM`, `ATM_CHAT_ID`, and `ATM_WORKSPACE_ROOT`.
|
|
58
|
+
3. Install the immutable wheels into that launch agent's Python environment:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
python -m pip install --upgrade atm-graft hermes-atm
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
4. Publish the same profile and graft root to ATM's roster. Run this using the
|
|
65
|
+
profile's ATM identity and team:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
atm teams update-member <team> <identity> \
|
|
69
|
+
--home-dir <profile-home> \
|
|
70
|
+
--workspace-root <workspace-root> \
|
|
71
|
+
--harness hermes
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
5. Run the package installer with the launch agent's Python. The command
|
|
75
|
+
validates the public Hermes capability and interpreter match before it writes
|
|
76
|
+
the standard generated hook and the package-owned native-tools plugin. It
|
|
77
|
+
also declaratively enables `hermes-atm-native-tools` and its `atm` toolset
|
|
78
|
+
for every configured Hermes platform in `config.yaml`; do not make those
|
|
79
|
+
configuration edits by hand:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
python -m hermes_atm install \
|
|
83
|
+
--profile <profile> \
|
|
84
|
+
--profile-home <profile-home> \
|
|
85
|
+
--identity <identity> \
|
|
86
|
+
--team <team> \
|
|
87
|
+
--chat-id "$ATM_CHAT_ID" \
|
|
88
|
+
--atm-home "$ATM_HOME" \
|
|
89
|
+
--workspace-root "$ATM_WORKSPACE_ROOT" \
|
|
90
|
+
--launch-agent-plist <gateway-launch-agent.plist>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
6. Reset the profile gateway. The restart loads the generated hook and publishes
|
|
94
|
+
the receiver record under `<workspace-root>/.atm/graft/<team>/<identity>.json`.
|
|
95
|
+
7. From the same profile identity, send a localhost message to the profile and
|
|
96
|
+
require an autonomous reply. Only that reply proves the full path: ATM send,
|
|
97
|
+
receiver, Hermes queue injection, and agent context processing.
|
|
98
|
+
|
|
99
|
+
## Native ATM tools
|
|
100
|
+
|
|
101
|
+
The same installer registers exactly three native Hermes tools through the
|
|
102
|
+
public plugin API: `atm_send`, `atm_read`, and `atm_list`. They use the typed
|
|
103
|
+
`atm-graft` client and the installed profile's identity, team, and workspace;
|
|
104
|
+
tool arguments cannot override those profile settings. `atm_read` is read-only
|
|
105
|
+
and `atm_list` returns bounded metadata. Administrative and advanced CLI
|
|
106
|
+
operations remain `atm` CLI operations.
|
|
107
|
+
|
|
108
|
+
For the reproducible native-tool proof, see [NATIVE_TOOLS_PROOF.md](NATIVE_TOOLS_PROOF.md).
|
|
109
|
+
The implementation checklist and validation record are in [TASKLIST.md](TASKLIST.md).
|
|
110
|
+
|
|
111
|
+
Do not edit `hooks/hermes-atm/handler.py`, `HOOK.yaml`, or `config.json` after
|
|
112
|
+
installation. To change package behavior, publish a new wheel, reinstall it,
|
|
113
|
+
rerun `python -m hermes_atm install`, reset the gateway, and repeat the proof.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# hermes-atm installation
|
|
2
|
+
|
|
3
|
+
`hermes-atm` is the package-owned Hermes gateway hook for ATM graft nudges.
|
|
4
|
+
It installs one receiver for one Hermes profile and injects delivered nudges
|
|
5
|
+
through the public `GatewayRunner.inject_internal_message(..., mode="queue")`
|
|
6
|
+
API. It does not open an ATM database, select a Hermes adapter, or require any
|
|
7
|
+
post-install source edits.
|
|
8
|
+
|
|
9
|
+
## Required settings
|
|
10
|
+
|
|
11
|
+
Collect these values before installation. Keep the chat identifier in local
|
|
12
|
+
profile configuration or the launch agent; do not put it in source, commits,
|
|
13
|
+
or shared install notes.
|
|
14
|
+
|
|
15
|
+
| Setting | Purpose | Must match |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| `profile` | Hermes profile to receive nudges | Gateway launch profile |
|
|
18
|
+
| `profile_home` | Directory containing that profile's `hooks/` directory | ATM roster `home_dir` |
|
|
19
|
+
| `identity` | ATM agent/member name | ATM roster member name |
|
|
20
|
+
| `team` | ATM team containing the member | ATM roster team |
|
|
21
|
+
| `chat_id` | Hermes session chat binding | Gateway's configured session |
|
|
22
|
+
| `atm_home` | ATM durable home | `ATM_HOME` for the profile |
|
|
23
|
+
| `workspace_root` | Canonical graft endpoint root | ATM roster `workspace_root` exactly |
|
|
24
|
+
| `launch_agent_plist` | Gateway LaunchAgent plist | Its first `ProgramArguments` entry must be the Python running this installer |
|
|
25
|
+
|
|
26
|
+
The `workspace_root` equality is mandatory. ATM post-send delivery resolves a
|
|
27
|
+
recipient endpoint from roster metadata. If the receiver is installed beneath
|
|
28
|
+
one root while the roster names another, `atm send` can persist a message but
|
|
29
|
+
the nudge will fail closed because it cannot find or contact the receiver.
|
|
30
|
+
|
|
31
|
+
## Clean installation sequence
|
|
32
|
+
|
|
33
|
+
1. Install a Hermes Agent version that exposes the public
|
|
34
|
+
`GatewayRunner.inject_internal_message` and `gateway.config.Platform.TELEGRAM`
|
|
35
|
+
host seams.
|
|
36
|
+
2. Configure the profile's launch agent with `ATM_HOME`, `ATM_IDENTITY`,
|
|
37
|
+
`ATM_TEAM`, `ATM_CHAT_ID`, and `ATM_WORKSPACE_ROOT`.
|
|
38
|
+
3. Install the immutable wheels into that launch agent's Python environment:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
python -m pip install --upgrade atm-graft hermes-atm
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
4. Publish the same profile and graft root to ATM's roster. Run this using the
|
|
45
|
+
profile's ATM identity and team:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
atm teams update-member <team> <identity> \
|
|
49
|
+
--home-dir <profile-home> \
|
|
50
|
+
--workspace-root <workspace-root> \
|
|
51
|
+
--harness hermes
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
5. Run the package installer with the launch agent's Python. The command
|
|
55
|
+
validates the public Hermes capability and interpreter match before it writes
|
|
56
|
+
the standard generated hook and the package-owned native-tools plugin. It
|
|
57
|
+
also declaratively enables `hermes-atm-native-tools` and its `atm` toolset
|
|
58
|
+
for every configured Hermes platform in `config.yaml`; do not make those
|
|
59
|
+
configuration edits by hand:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
python -m hermes_atm install \
|
|
63
|
+
--profile <profile> \
|
|
64
|
+
--profile-home <profile-home> \
|
|
65
|
+
--identity <identity> \
|
|
66
|
+
--team <team> \
|
|
67
|
+
--chat-id "$ATM_CHAT_ID" \
|
|
68
|
+
--atm-home "$ATM_HOME" \
|
|
69
|
+
--workspace-root "$ATM_WORKSPACE_ROOT" \
|
|
70
|
+
--launch-agent-plist <gateway-launch-agent.plist>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
6. Reset the profile gateway. The restart loads the generated hook and publishes
|
|
74
|
+
the receiver record under `<workspace-root>/.atm/graft/<team>/<identity>.json`.
|
|
75
|
+
7. From the same profile identity, send a localhost message to the profile and
|
|
76
|
+
require an autonomous reply. Only that reply proves the full path: ATM send,
|
|
77
|
+
receiver, Hermes queue injection, and agent context processing.
|
|
78
|
+
|
|
79
|
+
## Native ATM tools
|
|
80
|
+
|
|
81
|
+
The same installer registers exactly three native Hermes tools through the
|
|
82
|
+
public plugin API: `atm_send`, `atm_read`, and `atm_list`. They use the typed
|
|
83
|
+
`atm-graft` client and the installed profile's identity, team, and workspace;
|
|
84
|
+
tool arguments cannot override those profile settings. `atm_read` is read-only
|
|
85
|
+
and `atm_list` returns bounded metadata. Administrative and advanced CLI
|
|
86
|
+
operations remain `atm` CLI operations.
|
|
87
|
+
|
|
88
|
+
For the reproducible native-tool proof, see [NATIVE_TOOLS_PROOF.md](NATIVE_TOOLS_PROOF.md).
|
|
89
|
+
The implementation checklist and validation record are in [TASKLIST.md](TASKLIST.md).
|
|
90
|
+
|
|
91
|
+
Do not edit `hooks/hermes-atm/handler.py`, `HOOK.yaml`, or `config.json` after
|
|
92
|
+
installation. To change package behavior, publish a new wheel, reinstall it,
|
|
93
|
+
rerun `python -m hermes_atm install`, reset the gateway, and repeat the proof.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hermes-atm"
|
|
7
|
+
version = "1.4.4"
|
|
8
|
+
description = "Hermes gateway integration for the generic ATM graft receiver"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11,<3.15"
|
|
11
|
+
dependencies = ["atm-graft>=1.4,<1.5"]
|
|
12
|
+
authors = [{ name = "atm-core contributors" }]
|
|
13
|
+
license = { text = "MIT OR Apache-2.0" }
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.packages.find]
|
|
28
|
+
where = ["src"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Hermes-facing ATM graft composition.
|
|
2
|
+
|
|
3
|
+
The package consumes only the public ``atm_graft`` Python API. The Hermes
|
|
4
|
+
profile supplies its connected Telegram adapter and event-loop capabilities;
|
|
5
|
+
this package owns receiver activation, chat binding, visible host notice, and
|
|
6
|
+
internal Telegram-session injection.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .runtime import HermesAtmRuntime, HermesAtmRuntimeError
|
|
10
|
+
from .installer import HermesAtmInstallError, install_profile
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"HermesAtmInstallError",
|
|
14
|
+
"HermesAtmRuntime",
|
|
15
|
+
"HermesAtmRuntimeError",
|
|
16
|
+
"install_profile",
|
|
17
|
+
]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Gateway hook entry point installed by :mod:`hermes_atm.installer`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import atexit
|
|
6
|
+
import json
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Mapping
|
|
9
|
+
|
|
10
|
+
from .runtime import HermesAtmRuntime, HermesAtmRuntimeError
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
_runtime: HermesAtmRuntime | None = None
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _cleanup(runtime: HermesAtmRuntime) -> None:
|
|
17
|
+
"""Close only the runtime this hook still owns; safe for repeated exit paths."""
|
|
18
|
+
|
|
19
|
+
global _runtime
|
|
20
|
+
if _runtime is runtime:
|
|
21
|
+
runtime.close()
|
|
22
|
+
_runtime = None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _configuration(path: Path) -> Mapping[str, str]:
|
|
26
|
+
try:
|
|
27
|
+
value = json.loads(path.read_text(encoding="utf-8"))
|
|
28
|
+
except (OSError, json.JSONDecodeError) as error:
|
|
29
|
+
raise HermesAtmRuntimeError(
|
|
30
|
+
f"cannot read Hermes ATM hook configuration: {error}"
|
|
31
|
+
) from error
|
|
32
|
+
if not isinstance(value, dict) or value.get("schema_version") != 1:
|
|
33
|
+
raise HermesAtmRuntimeError("unsupported Hermes ATM hook configuration")
|
|
34
|
+
required = ("profile", "atm_home", "identity", "team", "chat_id", "workspace_root")
|
|
35
|
+
if any(
|
|
36
|
+
not isinstance(value.get(name), str) or not value[name].strip()
|
|
37
|
+
for name in required
|
|
38
|
+
):
|
|
39
|
+
raise HermesAtmRuntimeError("invalid Hermes ATM hook configuration")
|
|
40
|
+
return {name: value[name] for name in required}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _gateway_runner(context: Any) -> Any:
|
|
44
|
+
"""Resolve the public host context to its gateway runner.
|
|
45
|
+
|
|
46
|
+
Hermes invokes gateway hooks with the ``GatewayRunner`` itself. Accept a
|
|
47
|
+
mapping wrapper as a compatibility fallback for isolated callers, but do
|
|
48
|
+
not make receiver startup depend on that private wrapper shape.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
if isinstance(context, Mapping):
|
|
52
|
+
return context.get("gateway_runner")
|
|
53
|
+
return context
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
async def handle(event_type: str, context: Any, config_path: Path) -> None:
|
|
57
|
+
"""Activate exactly one profile-owned receiver from the public startup seam."""
|
|
58
|
+
|
|
59
|
+
global _runtime
|
|
60
|
+
if event_type == "gateway:shutdown":
|
|
61
|
+
if _runtime is not None:
|
|
62
|
+
_cleanup(_runtime)
|
|
63
|
+
return
|
|
64
|
+
if event_type != "gateway:startup" or _runtime is not None:
|
|
65
|
+
return
|
|
66
|
+
configuration = _configuration(config_path)
|
|
67
|
+
runner = _gateway_runner(context)
|
|
68
|
+
environment = {
|
|
69
|
+
"ATM_HOME": configuration["atm_home"],
|
|
70
|
+
"ATM_IDENTITY": configuration["identity"],
|
|
71
|
+
"ATM_TEAM": configuration["team"],
|
|
72
|
+
"ATM_CHAT_ID": configuration["chat_id"],
|
|
73
|
+
"ATM_WORKSPACE_ROOT": configuration["workspace_root"],
|
|
74
|
+
}
|
|
75
|
+
runtime = HermesAtmRuntime.from_gateway_runner(
|
|
76
|
+
runner,
|
|
77
|
+
profile=configuration["profile"],
|
|
78
|
+
environment=environment,
|
|
79
|
+
)
|
|
80
|
+
_runtime = runtime
|
|
81
|
+
atexit.register(_cleanup, runtime)
|