Metadata-Version: 2.4
Name: snin
Version: 5.0.0.dev1
Summary: Sovereign Network Intelligence Node — P2P mesh for AI agents
Author-email: SNIN Network <snin-network@v2.site>
License: MIT License
        
        Copyright (c) 2026 SNIN Network
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://snin-network.v2.site
Project-URL: Repository, https://github.com/snin-network/snin-core
Project-URL: Documentation, https://github.com/snin-network/snin-core
Project-URL: Changelog, https://github.com/snin-network/snin-core/blob/main/CHANGELOG.md
Project-URL: Bug_Tracker, https://github.com/snin-network/snin-core/issues
Keywords: p2p,mesh,nostr,ai-agent,distributed,kademlia,dht,fabric,self-learning,routing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: System :: Networking
Classifier: Topic :: Internet
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: POSIX :: Linux
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pynostr>=0.1.26
Requires-Dist: aiohttp>=3.9
Requires-Dist: orjson>=3.9
Requires-Dist: redis>=5.0
Requires-Dist: cryptography>=41.0
Requires-Dist: websockets>=12.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: pytest-mock>=3.10; extra == "dev"
Provides-Extra: dashboard
Requires-Dist: flask>=3.0; extra == "dashboard"
Requires-Dist: flask-socketio>=5.3; extra == "dashboard"
Dynamic: license-file

# SNIN ⚡ — Sovereign Network Intelligence Node

**P2P Mesh Fabric для автономных AI-агентов.**

SNIN — многоуровневая сеть для связи AI-агентов без центрального сервера.
13 уровней архитектуры: от физического канала до оркестрации агентов,
с self-learning роутингом, circuit breaker-ами и децентрализованным DHT.

```bash
pip install snin
```

---

## Быстрый старт

```python
from snin import SmartRouter, InMemoryCircuitBreaker, DHTNode, TTLCache

# Circuit Breaker — 3 инцидента = блокировка канала
cb = InMemoryCircuitBreaker()
cb.record_incident("nostr")
cb.record_incident("nostr")
cb.record_incident("nostr")  # 🔴 3-й раз — канал заблокирован
print(cb.is_blocked("nostr"))  # True
cb.force_recovery("nostr")     # ✅ ручное восстановление

# SmartRouter — создаётся без Redis и внешних сервисов
router = SmartRouter()
print(router.stats["start_time"])  # метрики готовности

# TTL Cache — временное хранение
cache = TTLCache(maxsize=100, ttl=60)
cache.add("event_id_123")
print("event_id_123" in cache)  # True (пока не истёк TTL)
```

Полный пример: [examples/quickstart.py](examples/quickstart.py)

---

## Возможности

- **Multi-channel routing** — Nostr, P2P mesh, Gossip, Direct TCP
- **Self-learning** — репутационная маршрутизация, circuit breaker на ошибках
- **101+ Nostr relay** — шардированная публикация через 5 параллельных Nostr Bridge
- **DHT Kademlia** — децентрализованный реестр агентов
- **Graceful Degradation** — при отказе канала трафик перенаправляется через живые
- **Circuit Breaker** — sliding window инцидентов (3 за 60с → блок на 30с)
- **Всё через ENV** — ни одного хардкодного пути / секрета

---

## Архитектура (13 уровней)

```
L0  — Ethernet PHY Subliminal
L1  — L1.5 Bridge (федерация mesh-сетей)
L2  — Encryption Layer
L2C — Cloudflare Durable Object [бонус]
L3  — Mesh Core (Kademlia DHT, gossip)
L4  — Privacy Layer
L5  — Identity & Reputation (NIP-80)
L5T — Temporal Dead-Letter Layer [бонус]
L6  — Agent Network
L8  — App Layer
L9  — Orchestration
L13 — Health Monitor
L14 — Alert Engine
L15 — Auto-Recovery
```

---

## Статус проекта

- **Phase 0** — ✅ Стабилизация: Nostr канал, orphan процессы, supervisor
- **Phase 1** — 🚧 External Release: GitHub + PyPI (текущая — ~70% готово)
- **Phase 2** — ⏳ Dead-Letter, Health Monitor, Alert Engine
- **Phase 3** — ⏳ Extended Channels: Cloudflare DO, Ethernet PHY
- **Phase 4** — ⏳ Auto-Recovery, SNIN Cloud, Marketplace

---

## Зависимости

- Python 3.10+
- Redis (опционально, для DHT storage)
- Nostr relay (для внешней сети)

---

## Лицензия

MIT — делайте что хотите, но упомяните SNIN Network.
