Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
Expand Down Expand Up @@ -47,6 +51,20 @@ jobs:
with:
name: python-distributions
path: dist/*
updates:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install build psutil packaging
- run: python -m build --wheel
- run: python scripts/test_update_release.py dist
hermes:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog

## 0.2.0.dev0 — unreleased
## 0.2.0a1 — coordinated release updates

- Add `/sloth update check` and `/sloth update`, plus equivalent terminal commands.
- Verify official GitHub release wheel hashes and compatibility before installation; retain a rollback wheel and configuration backups.
- Drain inference and save resident state before proxy replacement, keep the model backend running, and verify the replacement before reopening inference.
- Roll back package and proxy on handled installation/startup failures; report recovery paths when rollback fails.
- Restart supported Hermes gateways through their native lifecycle after a successful package update; show installed, loaded, and running versions.
- Add isolated real-package upgrade and failed-start rollback acceptance.

- Add the portable `/sloth` alias, preserve Telegram chat identity when parking, and document Telegram menu priority; cover dispatch and menu visibility in Hermes integration tests.

Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ sloth-memory saves a local model's conversation inference state to disk and rest
it when you return. Built for people running open-weight models on their own hardware.
MIT licensed. No cloud service or account. The portable runtime uses psutil.

**Current `main` · development version `0.2.0.dev0`.** Supports Linux, macOS, and
**Alpha release `0.2.0a1`.** Supports Linux, macOS, and
Windows startup, automatic free-port selection, and routing adapters for llama.cpp,
Ollama, vLLM, and MLX-LM. Disk park/resume through this adapter still requires the
managed patched llama.cpp runtime and one slot. See [backend capabilities](docs/backends.md).
The published [alpha.2](https://github.com/uncrayon/sloth-memory/releases/tag/v0.1.0-alpha.2)
is the older Linux version; install from `main` below to test the merged changes.
Download the [current alpha](https://github.com/uncrayon/sloth-memory/releases/tag/v0.2.0a1).
Existing users: follow the [update guide](docs/updates.md), including the one-time
proxy replacement for installations older than this release.
The service is independent of Hermes. A native Hermes adapter provides startup,
slash-command onboarding, and cleanup controls. Other agents integrate through
an HTTP proxy and explicit session metadata; a plain Python example is included.
Expand Down Expand Up @@ -49,7 +50,7 @@ instead of creating the standalone environment below.
Standalone installation on macOS/Linux:

```bash
git clone --branch main https://github.com/uncrayon/sloth-memory.git
git clone --branch v0.2.0a1 https://github.com/uncrayon/sloth-memory.git
cd sloth-memory
python3 -m venv .venv
source .venv/bin/activate
Expand Down Expand Up @@ -99,6 +100,16 @@ Storage defaults to `~/Library/Application Support/sloth-memory` on macOS,
`XDG_DATA_HOME` overrides these. To change it, pass the **same** `--archive-dir` to
the backend, proxy, and control commands.

## Updates

In Hermes, use `/sloth update check` to compare installed, loaded, and running
versions, then `/sloth update` to install a published release. The updater saves
resident state, replaces its proxy, verifies health, and attempts rollback on
failure. Hermes gateways restart through their native restart lifecycle.

For terminal use on any OS: `python -m sloth_memory update check` and
`python -m sloth_memory update`. See [updates and recovery](docs/updates.md).

## Use with Hermes

Install sloth-memory in Hermes' Python environment, enable it with
Expand Down
4 changes: 2 additions & 2 deletions docs/backends.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Backends and operating systems

This describes the current `main` development version (`0.2.0.dev0`). The published
alpha.2 remains Linux-only with its original llama.cpp integration.
This describes alpha `0.2.0a1`. Older alpha.2 installations retain their original
Linux-only scope until upgraded.

## Capability contract

Expand Down
4 changes: 2 additions & 2 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Runtime compatibility

This page describes the current `main` development version. See [backends](backends.md)
for routing capabilities; published alpha.2 retains its older Linux-only scope.
This page describes alpha `0.2.0a1`. See [backends](backends.md) for routing
capabilities. Older alpha.2 installations retain their original Linux-only scope.

## Runtime

Expand Down
29 changes: 21 additions & 8 deletions docs/hermes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Hermes adapter and onboarding

These instructions install the current `main` development version (`0.2.0.dev0`),
including portable startup and automatic port selection. The published alpha.2
does not contain those changes. See [backend setup](backends.md) for capabilities.
These instructions install alpha `0.2.0a1`, including portable startup, automatic
port selection, and release updates. See [backend setup](backends.md) for capabilities.

The adapter ships inside sloth-memory as a native Hermes plugin. It uses plugin
discovery, request middleware, commands, and profile settings. It does not patch
Expand All @@ -14,7 +13,7 @@ Install into **the same Python environment that runs Hermes**:

```bash
# With your Hermes virtual environment activated:
git clone --branch main https://github.com/uncrayon/sloth-memory.git
git clone --branch v0.2.0a1 https://github.com/uncrayon/sloth-memory.git
cd sloth-memory
python -m pip install --upgrade .
hermes plugins enable sloth-memory
Expand All @@ -24,10 +23,11 @@ If Hermes asks whether the plugin may replace built-in tools, answer **No**.
sloth-memory registers commands and middleware; it needs no tool overrides.
Use `hermes plugins list --plain --no-bundled` to check that it is enabled.

For an existing checkout, use `git pull --ff-only origin main` on its `main`
branch, then repeat the pip install command. Run `sloth-memory --version` in
Hermes' environment to confirm `0.2.0.dev0`. Restart Hermes after installation or
upgrade to load the entry point. The adapter is tested against Hermes
For an existing installation, follow [updates and recovery](updates.md). Versions
older than `0.2.0a1` need a one-time package installation and proxy replacement;
subsequent releases can use `/sloth update`. Run `sloth-memory --version` in
Hermes' environment to confirm `0.2.0a1`. Restart Hermes after installation to
load the entry point. The adapter is tested against Hermes
0.21.0, upstream commit `9dd6634c5635321cf38840cc30e9b51226689128`.
Use Python 3.11–3.13 for Hermes; the standalone service also supports 3.10/3.14.

Expand All @@ -54,6 +54,19 @@ printed by the build; Windows typically places `llama-server.exe` under
`runtime/build/bin/Release`. Onboarding does not download weights or compile a
backend. Connecting an existing server in routing mode requires no build.

## Persistence and updates

The installed package, plugin enablement, profile configuration, and saved slots
persist across a computer restart. When Hermes launches, the enabled plugin
starts its managed services if autostart is on. Starting Hermes itself at boot or
login is a separate Hermes service setting. The cleanup policy still expires old
snapshots; rebooting does not reset their age.

A gateway restart reuses an existing compatible proxy so it does not interrupt
shared inference. It does not automatically replace that proxy's Python code.
Use `/sloth update check` to see all three versions and `/sloth update` for the
coordinated release update. See [updates and recovery](updates.md).

## Guided setup

`/sloth` is a shortcut for `/sloth-memory` on every platform. Use `/sloth` in
Expand Down
2 changes: 1 addition & 1 deletion docs/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Never publish keys, transcript files, or archive directories.
`POST /_sloth/settings` atomically persists any subset of those settings.
`POST /_sloth/cleanup` runs a manual sweep with the saved age/budget rules.
Unknown keys, invalid booleans, negative ages, and nonpositive budgets are refused.
Status includes `service: "sloth-memory"` and `control_version: 2` for adapters.
Status includes the running package `version`, `maintenance`, `service: "sloth-memory"` and `control_version: 4` for adapters.

## Hermes

Expand Down
131 changes: 131 additions & 0 deletions docs/updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Updates and recovery

Use these commands after installing `0.2.0a1` or newer:

```text
/sloth update check
/sloth update
```

`check` is read-only. It reports the installed package, the adapter loaded in this
Hermes process, the running proxy, and the newest release available to the
installation's channel. An alpha installation includes prereleases; a stable
installation stays on stable releases. Only published releases with a matching
universal wheel and GitHub SHA-256 digest are offered. Installing from `main`
does not enable automatic tracking of new commits. Checks happen on command;
there is no background upgrade or notification schedule.

`update` downloads and verifies the selected release, validates its Python,
dependency, snapshot-format, and updater-protocol compatibility, and backs up the
installed package and configuration. Dependencies must already satisfy the new
release; the updater does not change Hermes' other packages. There is no sudo
prompt: run it in a writable Python environment owned by the account running
Hermes. Editable installations must be updated from their source checkout.

The proxy pauses new inference, waits up to 60 seconds for the current request,
and saves verified resident foreground state in native mode. If draining or
saving fails, the update stops before installing. During this brief maintenance
period, new inference receives HTTP 503 and should be retried after the update.
Routing mode preserves backend-managed state by retaining the backend process.

After installation, the proxy is replaced at the same address, checked for the
expected version and backend health, and reopened. A busy address causes recovery
rather than silently changing a route during an update. The model binary,
weights, backend process, saved settings, and existing compatible slots are kept.
Saving resident state starts a new seven-day snapshot lifetime under the default
policy. Updating does not rebuild a patched runtime or migrate cache formats.

In supported Hermes gateways, the command replies and then requests Hermes'
native draining restart, as `/restart` does. In an interactive Hermes CLI, or
when the gateway restart hook is unavailable, the reply tells you to restart
Hermes yourself. Reopen an interactive CLI after updating it. If several agents
or profiles share the Python environment, restart their other adapters and
update their proxies separately. `/sloth update check` shows a pending restart
until this adapter has loaded the installed version.

From a terminal, with the same environment activated:

```bash
python -m sloth_memory update check
python -m sloth_memory update
```

Pass `--archive-dir /your/archive` to either command for a custom archive. The
module invocation also works on Windows, where an active `sloth-memory.exe`
launcher cannot safely replace itself. Externally managed proxies must be
updated through their service owner. On shared bots, keep `/sloth` and
`/sloth-memory` restricted to administrators using Hermes' slash-command access
settings: these commands can install code in the bot's Python environment.

## One-time upgrade from older alphas or development installs

Old installations do not contain an updater or a proxy drain endpoint. A
package reinstall alone leaves their old proxy process running. To bootstrap:

1. Stop Hermes and other clients of this proxy. For a managed Hermes gateway,
run `hermes gateway stop` from a separate terminal; close interactive clients.
2. Activate the Python environment that runs Hermes and install the release:

```bash
python -m pip install --upgrade https://github.com/uncrayon/sloth-memory/releases/download/v0.2.0a1/sloth_memory-0.2.0a1-py3-none-any.whl
```

3. With all inference clients still stopped, save any resident state and stop
the old proxy. Set `archive` explicitly if you use a custom archive directory.
Use the proxy's `SLOTH_API_KEY` environment setting if authentication is enabled.

```python
from sloth_memory.cli import request
from sloth_memory.network import proxy_record
from sloth_memory.runtime import directory
from sloth_memory.updates import stop_proxy

archive = directory()
record = proxy_record(archive)
if record:
status = request(record["base_url"], "status")
if status["activity"]["phase"] != "idle":
raise RuntimeError("Wait for inference to finish before upgrading")
if status.get("resident_key"):
request(record["base_url"], "park", {"key": status["resident_key"]})
stop_proxy(record)
```

Run this Python snippet with the same environment's interpreter. It validates
the recorded process identity before stopping it. Do not kill arbitrary
listeners on port 8080 or stop the model backend.

The oldest alpha.2 proxy did not publish `proxy.json`. Stop that proxy through
the terminal or service that launched it after parking the conversation; an
absent record does not prove that an older proxy is stopped.

4. Start Hermes again (`hermes gateway start` for a managed gateway). The enabled
plugin starts the new proxy and discovers its selected port. Run
`/sloth update check`; installed, loaded, and proxy versions should agree.

## If an update fails

For handled installation or replacement-startup failures, the updater attempts
to reinstall the previous wheel and restart its proxy. It reports `rolled_back`
only when recovery succeeds. `recovery_required` means manual attention is
needed; the error includes the backup directory. New inference remains paused
while a replacement is being verified; a surviving proxy's maintenance lease
expires after five minutes if the updater disappears unexpectedly.

The archive's `update.json` records the last transaction. Backups are under
`updates/<transaction>/`, including the previous wheel, configuration copies,
and installation logs. They are private and are not part of seven-day snapshot
cleanup. Keep the latest successful rollback backup; older update backups can
be removed manually when no transaction is using them.

A power loss or process kill during pip installation cannot guarantee automatic
rollback. From the same Python environment, reinstall the previous wheel named
in the backup directory, then restart Hermes:

```bash
python -m pip install --no-index --no-deps --force-reinstall /path/to/backup/sloth_memory-PREVIOUS-py3-none-any.whl
```

This alpha does not apply configuration or snapshot-format migrations. A release
requiring them is refused with a pointer to its release notes rather than
silently invalidating saved state.
22 changes: 22 additions & 0 deletions docs/validation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Alpha validation

## Coordinated updates — 0.2.0a1

Local release checks on September 6, 2026:

- 77 Python tests: 76 passed, one optional model test skipped.
- 18 Hermes integration tests: 17 passed, one optional model test skipped,
against both the installed Hermes and pinned upstream source.
- Real wheel installation in a disposable Python 3.14 virtual environment:
upgrade succeeded; a subsequent package with a deliberately broken proxy
startup rolled back to the previous wheel and a healthy proxy. The proxy
address and upstream backend were retained. No production model was used.
- Tests cover maintenance gating, drain timeout, failed snapshot saves, invalid
release hashes/formats, wrong Python environments, interrupted installation,
failed replacement shutdown, and a lost acknowledgement when reopening traffic.
- Release wheel and source archive passed package metadata validation.

Package upgrade and failed-start rollback acceptance passed in CI on Linux,
macOS, and Windows. Tests also cover Python environment aliases and native
launchers whose process differs from the running proxy. Native gateway restart scheduling is covered through
Hermes' real dispatch with the final restart operation mocked. This is separate
from the earlier live model park/resume evidence below.

## Live Hermes migration — main development version

On 2026-09-05, sloth-memory was installed into the existing Hermes Python 3.11
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"

[project]
name = "sloth-memory"
version = "0.2.0.dev0"
version = "0.2.0a1"
description = "Let your local AI nap. Resume long conversations from saved inference state."
readme = "README.md"
requires-python = ">=3.10"
dependencies = ["psutil>=5.9"]
dependencies = ["psutil>=5.9", "packaging>=23"]
license = {text = "MIT"}
authors = [{name = "Ulises Rayon"}]
keywords = ["llama.cpp", "kv-cache", "local-ai", "open-weights", "agents"]
Expand All @@ -33,3 +33,6 @@ sloth-memory = "sloth_memory.hermes"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
sloth_memory = ["update_compat.json"]
Loading
Loading