Metadata-Version: 2.4
Name: enigmind-agent
Version: 0.1.0
Summary: Enigmind Agent Python SDK for secure IoT connectivity.
Author: Enigmind
License: Proprietary
Project-URL: Homepage, https://enigmind.ai
Keywords: iot,mqtt,telemetry,enigmind
Classifier: Development Status :: 3 - Alpha
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
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: paho-mqtt<3,>=2.1.0
Requires-Dist: platformdirs>=4.5.1
Requires-Dist: typer[standard]>=0.21.1
Provides-Extra: health
Requires-Dist: psutil>=7.2.2; extra == "health"
Provides-Extra: dev
Requires-Dist: pytest>=9.0.2; extra == "dev"

# Enigmind Agent Python SDK

A lightweight Python SDK for secure IoT device connectivity.

## Quick Start

```python
from enigmind_agent import Agent, AgentConfig

config = AgentConfig(
    broker_url="mqtts://broker.enigmind.ai:8883",
    device_id="device-123",
    api_key="YOUR_API_KEY",
)

agent = Agent(config)
agent.start()
agent.send_telemetry({"temp": 22.4, "vibration": 0.12})
```

## Device Claim Flow (Zero-Touch Setup)

If the agent starts without credentials (`device_id` + `api_key`/`password`), it automatically enters the claim flow:

1. Generates a stable hardware fingerprint and a human-readable claim token.
2. Calls the claim API (`/api/claims/initiate`).
3. Polls `/api/claims/{token}/status` until approved.
4. Stores the returned credentials locally and connects to MQTT.

The claim token is printed at startup when using the CLI, and is also stored locally for retrieval.
By default the state file is saved under your user data directory as `enigmind_agent/state.json`.
If you embed the SDK directly, enable Python logging at INFO level to see claim output.

### CLI Example

```bash
ENIGMIND_CLAIM_BASE_URL=https://api.enigmind.ai enigmind-cli run
```

Check claim status and token:

```bash
enigmind-cli claim status
```

### JSON Config Example

```json
{
  "broker_url": "mqtts://broker.enigmind.ai:8883",
  "claim": {
    "base_url": "https://api.enigmind.ai",
    "poll_interval_s": 5,
    "timeout_s": 300
  }
}
```

## Installation & Setup

```powershell
py -3.12 -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -U pip
pip install -e .[dev]
```

Optional Health plugin:

```powershell
pip install -e .[health]
```

## CLI

```bash
enigmind-cli send --data '{"temp": 22.4}' --config ./enigmind.json
```

## Releasing

Releases are published to PyPI automatically via GitHub Actions when you create a GitHub Release.

1. Bump `version` in `pyproject.toml`.
2. Commit and push to `main`.
3. Go to **GitHub → Releases → Draft a new release**.
4. Create a new tag (e.g. `v0.1.0`), add release notes, and click **Publish release**.
5. The `release.yml` workflow will build and publish the package to PyPI.

## Plugins

- Health plugin: CPU/memory/disk metrics (requires optional dependency `psutil`).
- Geo plugin: local geofencing hooks (no extra dependencies).
