Skip to content

Commit 3027997

Browse files
authored
feat: tag hermes harness on agent self-signup (#19)
Pass harness="hermes" to Inkbox.signup so self-signups from this plugin are attributed to the harness. Bumps the inkbox SDK pin to >=0.4.10.
1 parent 2cfc72a commit 3027997

5 files changed

Lines changed: 73 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 5
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
20+
# inkbox is mocked in the tests, so install only what they import.
21+
- name: Install test deps
22+
run: pip install pytest aiohttp
23+
24+
- name: Test
25+
run: pytest -q

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ hermes gateway restart
7575

7676
`hermes inkbox setup` walks the active Hermes install through Inkbox configuration:
7777

78-
1. Installs or upgrades `inkbox>=0.4.7` and `aiohttp>=3.9` in the Hermes Python environment when needed.
78+
1. Installs or upgrades `inkbox>=0.4.10` and `aiohttp>=3.9` in the Hermes Python environment when needed.
7979
2. Authenticates to Inkbox, or starts self-signup if you do not have an API key yet.
8080
3. Resolves or creates the Inkbox agent identity for this Hermes gateway.
8181
4. Optionally provisions a local US phone number so SMS and voice are available.
@@ -96,13 +96,13 @@ The setup wizard installs dependencies into the Python environment that runs Her
9696
If the wizard prints a missing-SDK warning, use the exact command it prints. It will look like this:
9797

9898
```bash
99-
/path/to/hermes/venv/bin/python3 -m pip install 'inkbox>=0.4.7' 'aiohttp>=3.9'
99+
/path/to/hermes/venv/bin/python3 -m pip install 'inkbox>=0.4.10' 'aiohttp>=3.9'
100100
```
101101

102102
When `uv` is available, the wizard prefers:
103103

104104
```bash
105-
uv pip install --python /path/to/hermes/venv/bin/python3 'inkbox>=0.4.7' 'aiohttp>=3.9'
105+
uv pip install --python /path/to/hermes/venv/bin/python3 'inkbox>=0.4.10' 'aiohttp>=3.9'
106106
```
107107

108108
Do not use plain `pip install inkbox aiohttp` unless the wizard tells you to; plain `pip` may point at pyenv, Homebrew, system Python, or another virtualenv.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description = "Inkbox platform plugin for Hermes Agent"
66
requires-python = ">=3.11"
77
dependencies = [
88
"aiohttp>=3.9",
9-
"inkbox>=0.4.7",
9+
"inkbox>=0.4.10",
1010
"segno>=1.5",
1111
]
1212

setup_wizard.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import asyncio
66
import getpass
77
import importlib
8+
import importlib.metadata
89
import json
910
import os
1011
import re
@@ -57,7 +58,8 @@ def print_warning(message: str) -> None:
5758
masked_secret_prompt = None
5859

5960

60-
INKBOX_REQUIREMENTS = ("inkbox>=0.4.7", "aiohttp>=3.9", "segno>=1.5")
61+
INKBOX_MIN_VERSION = "0.4.10"
62+
INKBOX_REQUIREMENTS = (f"inkbox>={INKBOX_MIN_VERSION}", "aiohttp>=3.9", "segno>=1.5")
6163
_BRACKETED_PASTE_PATTERN = re.compile(r"\x1b\[\s*200~|\x1b\[\s*201~")
6264
_AVATAR_PATH = Path(__file__).resolve().parent / "assets" / "hermes_with_iphone.png"
6365
OPENAI_REALTIME_TEST_MODEL = "gpt-realtime-2"
@@ -290,9 +292,44 @@ def _load_inkbox_symbols() -> dict[str, Any]:
290292
}
291293

292294

295+
def _parse_version(value: str) -> tuple[int, ...]:
296+
# Best-effort numeric parse of "X.Y.Z" so we can compare without packaging.
297+
parts: list[int] = []
298+
for chunk in value.split("."):
299+
digits = ""
300+
for char in chunk:
301+
if char.isdigit():
302+
digits += char
303+
else:
304+
break
305+
if digits == "":
306+
break
307+
parts.append(int(digits))
308+
return tuple(parts)
309+
310+
311+
def _inkbox_version_ok() -> bool:
312+
try:
313+
installed = importlib.metadata.version("inkbox")
314+
except Exception:
315+
return False
316+
try:
317+
from packaging.version import Version
318+
319+
return Version(installed) >= Version(INKBOX_MIN_VERSION)
320+
except Exception:
321+
# Fall back to a simple parsed-tuple comparison when packaging is unavailable.
322+
return _parse_version(installed) >= _parse_version(INKBOX_MIN_VERSION)
323+
324+
293325
def _ensure_inkbox_sdk() -> dict[str, Any] | None:
294326
try:
295-
return _load_inkbox_symbols()
327+
symbols = _load_inkbox_symbols()
328+
if _inkbox_version_ok():
329+
return symbols
330+
first_error = (
331+
f"inkbox SDK is older than {INKBOX_MIN_VERSION}; an upgrade is required."
332+
)
296333
except Exception as exc:
297334
first_error = exc
298335

@@ -951,6 +988,7 @@ def _self_signup_flow(base_url: str, Inkbox: Any, InkboxAPIError: Any) -> tuple[
951988
note_to_human=note,
952989
agent_handle=handle,
953990
base_url=base_url,
991+
harness="hermes",
954992
)
955993
break
956994
except InkboxAPIError as exc:

tests/test_setup_wizard.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_install_command_prefers_uv_when_available(monkeypatch):
2121
"install",
2222
"--python",
2323
"/tmp/hermes/venv/bin/python",
24-
"inkbox>=0.4.7",
24+
"inkbox>=0.4.10",
2525
"aiohttp>=3.9",
2626
"segno>=1.5",
2727
]]
@@ -32,10 +32,10 @@ def test_install_command_falls_back_to_pip_and_ensurepip(monkeypatch):
3232
monkeypatch.setattr(setup_wizard.shutil, "which", lambda _name: None)
3333

3434
assert setup_wizard._install_commands() == [
35-
[["/tmp/hermes/venv/bin/python", "-m", "pip", "install", "inkbox>=0.4.7", "aiohttp>=3.9", "segno>=1.5"]],
35+
[["/tmp/hermes/venv/bin/python", "-m", "pip", "install", "inkbox>=0.4.10", "aiohttp>=3.9", "segno>=1.5"]],
3636
[
3737
["/tmp/hermes/venv/bin/python", "-m", "ensurepip", "--upgrade"],
38-
["/tmp/hermes/venv/bin/python", "-m", "pip", "install", "inkbox>=0.4.7", "aiohttp>=3.9", "segno>=1.5"],
38+
["/tmp/hermes/venv/bin/python", "-m", "pip", "install", "inkbox>=0.4.10", "aiohttp>=3.9", "segno>=1.5"],
3939
],
4040
]
4141

@@ -54,7 +54,7 @@ def fail_import():
5454
out = capsys.readouterr().out
5555
assert "/tmp/hermes/venv/bin/python" in out
5656
assert "uv pip install --python" in out
57-
assert "inkbox>=0.4.7" in out
57+
assert "inkbox>=0.4.10" in out
5858
assert "aiohttp>=3.9" in out
5959

6060

0 commit comments

Comments
 (0)