@artil-ai/hermes 0.0.0-stage → 0.1.1

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.
package/README.md CHANGED
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # @artil-ai/hermes
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Artil platform for the [Hermes](https://hermes-agent.nousresearch.com)
4
+ gateway. New email and texts to the agent account, and wake-ups from its team,
5
+ reach the gateway as notices that `artil internal hermes-channel` prints, from
6
+ where it left off; the agent answers them with the `artil` CLI.
7
+
8
+ ## Usage
9
+
10
+ Install the [Artil CLI](https://artil.dev/INSTALL.md), sign in as the agent with
11
+ `artil auth login`, and let it set up the plugin and the `artil` skill:
12
+
13
+ ```sh
14
+ artil plugin install hermes
15
+ ```
16
+
17
+ Or install the plugin with Hermes:
18
+
19
+ ```sh
20
+ hermes plugins install artilai/plugins/plugins/hermes --enable
21
+ ```
22
+
23
+ The gateway runs the `artil` that `platforms.artil.extra.command` names in
24
+ Hermes' `config.yaml`, else the one on its PATH, else `~/.local/bin/artil`. See
25
+ [Hermes](https://docs.artil.dev/hermes) in the docs.
26
+
27
+ While the gateway runs, the plugin keeps `artil internal hermes-channel`
28
+ running, which reaches Artil with the CLI's login. The plugin sends nothing
29
+ itself: the agent answers with `artil` commands.
30
+
31
+ | Entry point | What it is |
32
+ | ------------- | ------------------------------------------------------- |
33
+ | `plugin.yaml` | The plugin manifest; Hermes 0.21.5 or later loads it |
34
+ | `__init__.py` | The `artil` gateway platform and its system-prompt hint |
35
+
36
+ ## Development
37
+
38
+ From the repository root, lint and format the plugin with
39
+ [ruff](https://docs.astral.sh/ruff), then validate and test it inside the Hermes
40
+ image:
41
+
42
+ ```sh
43
+ uvx ruff check && uvx ruff format --check
44
+ docker run --rm -v "$PWD/plugins/hermes:/plugin" -w /plugin --entrypoint hermes nousresearch/hermes-agent:latest plugins validate .
45
+ docker run --rm -v "$PWD/plugins/hermes:/plugin" -w /plugin --entrypoint sh nousresearch/hermes-agent:latest -c \
46
+ 'uv pip install -q --python /opt/hermes/.venv/bin/python pytest && PYTHONPATH=/opt/hermes /opt/hermes/.venv/bin/python -m pytest -p no:cacheprovider tests'
47
+ ```
package/__init__.py ADDED
@@ -0,0 +1,157 @@
1
+ """Artil for Hermes: notices about an agent account's new email and texts reach the gateway."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ import dataclasses
7
+ import json
8
+ import shutil
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ from gateway.config import Platform, PlatformConfig
13
+ from gateway.platform_registry import PlatformEntry
14
+ from gateway.platforms.base import BasePlatformAdapter, MessageEvent, MessageType, SendResult
15
+
16
+ PLATFORM = "artil"
17
+
18
+ HINT = (
19
+ "Notices about new email and texts to this Artil agent account, and wake-ups from its team, "
20
+ "arrive here. Read each message with the artil command its notice names, and answer it with "
21
+ "`artil email send --reply-to` or `artil sms send --reply-to`. "
22
+ "Nobody outside reads what you write in this conversation."
23
+ )
24
+
25
+
26
+ class ArtilAdapter(BasePlatformAdapter):
27
+ """Runs `artil internal hermes-channel` and hands each notice it prints to the gateway."""
28
+
29
+ STOP_GRACE_SECONDS = 2.0
30
+
31
+ def __init__(self, config: PlatformConfig) -> None:
32
+ config.extra = {**(config.extra or {}), "allow_from": [PLATFORM]}
33
+ super().__init__(config, Platform(PLATFORM))
34
+ # A gateway service may not have the PATH that finds artil where its installer put it.
35
+ self._command = str(
36
+ config.extra.get("command") or shutil.which("artil") or Path.home() / ".local/bin/artil"
37
+ )
38
+ self._process: asyncio.subprocess.Process | None = None
39
+ self._listening: asyncio.Task | None = None
40
+
41
+ async def connect(self, *, is_reconnect: bool = False) -> bool:
42
+ try:
43
+ process = await asyncio.create_subprocess_exec(
44
+ self._command,
45
+ "internal",
46
+ "hermes-channel",
47
+ stdin=asyncio.subprocess.PIPE,
48
+ stdout=asyncio.subprocess.PIPE,
49
+ stderr=asyncio.subprocess.PIPE,
50
+ start_new_session=True,
51
+ )
52
+ except OSError as error:
53
+ self._set_fatal_error(
54
+ "artil_missing", f"Could not run {self._command}: {error}", retryable=False
55
+ )
56
+ return False
57
+
58
+ self._process = process
59
+ self._listening = asyncio.create_task(self._listen(process))
60
+ self._mark_connected()
61
+ return True
62
+
63
+ async def _listen(self, process: asyncio.subprocess.Process) -> None:
64
+ problem = asyncio.create_task(process.stderr.read())
65
+
66
+ async for line in process.stdout:
67
+ await self._deliver(json.loads(line))
68
+
69
+ reason = (await problem).decode().strip()
70
+ code = await process.wait()
71
+ asked_to_stop = code in (0, -2, -15)
72
+
73
+ if asked_to_stop:
74
+ await asyncio.sleep(self.STOP_GRACE_SECONDS)
75
+
76
+ if process is not self._process or getattr(
77
+ self.gateway_runner, "_stop_requested_by_signal", False
78
+ ):
79
+ return
80
+
81
+ self._process = None
82
+ self._set_fatal_error(
83
+ "artil_stopped", reason or f"{self._command} stopped", retryable=asked_to_stop
84
+ )
85
+ await self._notify_fatal_error()
86
+
87
+ async def _deliver(self, notice: dict[str, Any]) -> None:
88
+ meta = notice.get("meta") or {}
89
+ source = self.build_source(
90
+ chat_id=PLATFORM,
91
+ chat_name="Artil",
92
+ chat_type="dm",
93
+ user_id=PLATFORM,
94
+ user_name="Artil",
95
+ )
96
+
97
+ await self.handle_message(
98
+ MessageEvent(
99
+ text=notice["content"],
100
+ message_type=MessageType.TEXT,
101
+ source=source,
102
+ message_id=meta.get("message_id"),
103
+ allow_gateway_control=False,
104
+ )
105
+ )
106
+
107
+ async def disconnect(self) -> None:
108
+ process, self._process = self._process, None
109
+
110
+ if process is not None and process.returncode is None:
111
+ process.stdin.close()
112
+
113
+ try:
114
+ await asyncio.wait_for(process.wait(), 5)
115
+ except TimeoutError:
116
+ process.kill()
117
+
118
+ if self._listening is not None:
119
+ self._listening.cancel()
120
+
121
+ self._mark_disconnected()
122
+
123
+ async def send(
124
+ self,
125
+ chat_id: str,
126
+ content: str,
127
+ reply_to: str | None = None,
128
+ metadata: dict[str, Any] | None = None,
129
+ ) -> SendResult:
130
+ """The agent answers senders with the artil CLI, so its words here stay in the session."""
131
+ return SendResult(success=True)
132
+
133
+ async def get_chat_info(self, chat_id: str) -> dict[str, Any]:
134
+ return {"name": "Artil", "type": "dm"}
135
+
136
+
137
+ def _needs_nothing() -> bool:
138
+ return True
139
+
140
+
141
+ def _service_fields() -> dict[str, Any]:
142
+ known = {field.name for field in dataclasses.fields(PlatformEntry)}
143
+ wanted = {"trusted_inbound": True, "display_tier": "minimal"}
144
+ return {name: value for name, value in wanted.items() if name in known}
145
+
146
+
147
+ def register(ctx: Any) -> None:
148
+ ctx.register_platform(
149
+ name=PLATFORM,
150
+ label="Artil",
151
+ adapter_factory=ArtilAdapter,
152
+ check_fn=_needs_nothing,
153
+ platform_hint=HINT,
154
+ allow_update_command=False,
155
+ emoji="📨",
156
+ **_service_fields(),
157
+ )
package/package.json CHANGED
@@ -1,6 +1,27 @@
1
1
  {
2
2
  "name": "@artil-ai/hermes",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Hear about your Artil agent's new messages in the Hermes gateway, and answer them with the artil CLI.",
5
+ "keywords": [
6
+ "artil",
7
+ "hermes-agent"
8
+ ],
9
+ "homepage": "https://docs.artil.dev/hermes",
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/artilai/plugins.git",
14
+ "directory": "plugins/hermes"
15
+ },
16
+ "files": [
17
+ "plugin.yaml",
18
+ "__init__.py"
19
+ ],
20
+ "exports": {
21
+ "./plugin.yaml": "./plugin.yaml",
22
+ "./__init__.py": "./__init__.py"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
27
+ }
package/plugin.yaml ADDED
@@ -0,0 +1,11 @@
1
+ name: artil
2
+ label: Artil
3
+ kind: platform
4
+ version: 0.1.1
5
+ description: >
6
+ New email and texts to an Artil agent account, and wake-ups from its team,
7
+ reach the Hermes gateway through the artil CLI. The agent answers them with
8
+ the CLI.
9
+ author: Artil
10
+ homepage: https://docs.artil.dev/hermes
11
+ requires_hermes: ">=0.21.5"