Metadata-Version: 2.5
Name: sessionknit
Version: 0.0.3
Summary: Durable, DAG-shaped session persistence that survives parallel tool calls and mid-turn interruption.
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# SessionKnit (Python)

Part of [LoopEngine](https://github.com/evanyan22/loopengine) — a runtime
for defining and running AI agents through a transparent ReAct loop —
handling durable, DAG-shaped session logs with crash-interruption
detection. Works standalone too, no dependency on LoopEngine itself.

Ported line-for-line from the TypeScript implementation. See the
[root README](../README.md) for the pitch, the prior-art table, and the
scope decisions — this file only covers what's specific to running the
Python code.

## Install

```bash
pip install -e ".[dev]"
```

## Quickstart

```bash
PYTHONPATH=src python3 examples/quickstart.py
```

```python
from sessionknit import FileStorage, SessionKnit, SessionEntry

sessionknit = SessionKnit(
    FileStorage("./sessions"),
    has_unresolved_tool_call=lambda m: m.has_tool_call,
    build_continuation=lambda m: Message(role="user", content="Continue from where you left off."),
)

await sessionknit.append(session_id, SessionEntry(id=id, parent_id=parent_id, message=message))

result = await sessionknit.resume(session_id)
# result.messages, result.resumed_after_interruption
```

## Test

```bash
pytest
```

## Status

Chain reconstruction, topology repair, the async write-behind queue, and
interruption detection are real and tested. Published as
[`sessionknit`](https://pypi.org/project/sessionknit/) on PyPI.
