Metadata-Version: 2.4
Name: lange-python
Version: 0.5.0
Summary: A bundeld set of tools, clients for the lange-suite of tools and more.
Author: contact@robertlange.me
Requires-Python: >=3.10
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: certifi (>=2026.0.0)
Requires-Dist: click (>=8.0.0,<9.0.0)
Requires-Dist: httpx (>=0.28.1,<0.29.0)
Requires-Dist: idna (>=3.15)
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
Requires-Dist: websockets (>=12.0,<20.0)
Description-Content-Type: text/markdown

# lange-python

Python helpers for Lange services.

## Mesh Relay Worker

`MeshRelay` connects a local HTTP service to the Lange mesh relay and forwards
public relay requests to your local target.

```bash
pip install lange-python
```

```python
from lange.mesh.relay import MeshRelay

relay = MeshRelay(
    host="wss://api.lange-labs.com",
    key="default",
    target="http://localhost:3000",
)

relay.start()

try:
    print(relay.status)
    print(relay.remote_relay_address)
finally:
    relay.stop()
```

By default, `MeshRelay` reads authentication from the `LANGE_LABS_API_KEY`
environment variable. Keep API keys in the environment or a local secret store
instead of hardcoding them in application code.

```bash
export LANGE_LABS_API_KEY="your-api-key"
```

The relay exposes lifecycle state for integrations:

- `status`: one of `unauthenticated`, `off`, `pending`, `connected`, or `failed`
- `connected`: whether the relay websocket is currently connected
- `remote_relay_address`: public REST relay address returned by the API
- `worker_config`: full worker configuration returned by the API

Reload authentication or reconnect the worker without rebuilding it:

```python
relay.reload()
relay.reload(api_key=None)
relay.reconnect()
```

