# Vendoring chattolib

This plugin includes a **vendored copy of chattolib** in the `chattolib_vendor/` directory.
This means you don't need to install chattolib separately — it's bundled with the plugin.

## Why Vendoring?

- **No dependencies to install**: `hermes plugin install` works immediately
- **No lazy-import complexity**: No need for `ensure()` or `lazy_import` mechanisms
- **Isolated**: The vendored chattolib won't conflict with any system-installed version
- **Offline-friendly**: Works in air-gapped environments

## Updating the Vendored chattolib

To update to a new version of chattolib:

```bash
# Run the vendoring script
./vendor_chattolib.sh [version]

# Example: update to 0.5.0
./vendor_chattolib.sh 0.5.0

# Or use default (latest known stable)
./vendor_chattolib.sh
```

The script will:
1. Download the chattolib wheel from PyPI
2. Extract it to `chattolib_vendor/`
3. Also download the `websockets` dependency (needed for realtime features)

## Development without Vendoring

If you're developing and want to use your system-installed chattolib instead:

```bash
pip install chattolib[realtime]
```

The adapter will automatically fall back to the system-installed version if the vendored copy is not found.

## Structure

```
chattolib_vendor/
├── __init__.py           # Marker file
├── chattolib/           # The chattolib package
│   ├── __init__.py
│   ├── src/
│   │   └── chattolib/
│   │       ├── _pb/        # Protobuf generated files
│   │       ├── _transport.py
│   │       ├── client.py
│   │       ├── realtime.py
│   │       ├── types.py
│   │       └── ...
│   └── ...
└── websockets/          # Dependency for realtime features
    └── ...
```

## License

The vendored chattolib is licensed under **MPL-2.0 + Apache-2.0** (see `chattolib/LICENSE`).
The original source is available at: https://github.com/chattocorp/chatto

## Manual Vendoring (Alternative)

If the script doesn't work for your environment:

```bash
# Create directory
mkdir -p chattolib_vendor

# Download and extract chattolib
pip download chattolib==0.4.19 --no-deps -d /tmp
cd /tmp
unzip chattolib-*.whl -d chattolib_extracted
cp -r chattolib_extracted/chattolib* ../chattolib_vendor/

# Download websockets
pip download websockets -d /tmp
cd /tmp
unzip websockets-*.whl -d websockets_extracted
mkdir -p ../chattolib_vendor/websockets
cp -r websockets_extracted/websockets* ../chattolib_vendor/websockets/

# Add __init__.py
echo "# Vendored chattolib" > chattolib_vendor/__init__.py
```
