Metadata-Version: 2.4
Name: lost_sessions
Version: 0.2.0
Summary: Recover agent sessions that a reboot dropped, with pluggable session managers
Author: Steve Morin
Author-email: Steve Morin <steve.morin@gmail.com>
License-Expression: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: click>=8.1.0
Requires-Dist: pluggy>=1.5.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: textual>=8,<9
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/smorinlabs/lost-sessions
Project-URL: Repository, https://github.com/smorinlabs/lost-sessions
Project-URL: Documentation, https://lost-sessions.readthedocs.io/en/latest/
Project-URL: Changelog, https://github.com/smorinlabs/lost-sessions/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/smorinlabs/lost-sessions/issues
Description-Content-Type: text/markdown

# lost-sessions

Recover the agent sessions a reboot dropped. `lost-sessions` finds Claude Code,
Codex, Muse and OpenCode sessions that started before the last boot and that no
session manager will restore, then prints their resume commands or reopens
them in Herdr or Rex.

Agents and session managers are plugins, the way
[`simonw/llm`](https://llm.datasette.io/en/stable/plugins/) does plugins. The
six built-ins use the same interface a third-party `lost-sessions-<name>`
package uses.

## Install

```bash
uv tool install "lost-sessions @ git+https://github.com/smorinlabs/lost-sessions"
```

This installs the latest `main`. Python 3.13 or later. macOS and Linux. Tagged
releases, and a PyPI package, follow once publishing is set up.

## Use

| Command | What it does |
|---|---|
| `lost-sessions recover` | Interactive menu: choose Print, Rex or Herdr for each dropped session, then run them all |
| `lost-sessions list` | Numbered list of the dropped sessions in the window |
| `lost-sessions open REF… --print\|--rex\|--herdr [--focus [REF]]` | Print or open sessions without the menu; `REF@DEST` picks a destination |
| `lost-sessions workspaces` | The Herdr workspaces and Rex sessions you can open sessions in |
| `lost-sessions history [--json]` | Every action taken, from `${XDG_STATE_HOME:-~/.local/state}/lost-sessions/history.jsonl` |
| `lost-sessions inventory [--json]` | Read-only inventory of every agent session on this machine |
| `lost-sessions plugins [--all]` | Installed plugins, as JSON |
| `lost-sessions install PKG…` / `uninstall PKG…` | Add or remove plugins in the `uv tool` install |

The window is every session that started before the last boot and was active
since its start: by default 00:00 on the day before the boot. `--since` sets
that start, as a date (`--since 2026-11-09`) or a duration back from now
(`--since 3d`); pick an earlier start to widen the window. Running sessions
and sessions a manager restores are hidden unless `--all`.

## Library

```python
from lost_sessions.inventory import collect, select

inventory = collect()  # an Inventory: sessions, census, sources, failed
for session in select(inventory, live=True):
    print(session.tool, session.id, session.resume)
```

## Plugins

See [Writing plugins](docs/source/reference/plugins.md) for the hooks, the
`AgentTool` and `SessionManager` contracts, and how to test and install a
plugin. The design is in
[design 0006](docs/design/0006-lost-sessions-plugin-design.md).

## Develop

```bash
make bootstrap   # bare machines only: just + uv
just setup       # dev environment and git hooks
just check       # tests, lint, types, import contracts
```

See [AGENTS.md](AGENTS.md) for the full workflow.
