Metadata-Version: 2.4
Name: chatops-sdk
Version: 1.0.0
Summary: SDK para conectar aplicaciones Python al Relay Hub de ChatOps como bots con comandos slash
Author-email: Francisco Manzano <keoh77@gmail.com>
License-Expression: MIT
Keywords: chatops,bot,websocket,slash-commands,pydantic
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
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: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic<3,>=2.6
Requires-Dist: websockets>=13
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
Dynamic: license-file

# chatops-sdk

SDK de Python para convertir cualquier aplicación en un bot del **ChatOps Bot Control Center**.
Declaras funciones con `@bot.command()` y el SDK genera el manifiesto de comandos a partir de sus
type hints. El bot abre un WebSocket **saliente** hacia el Relay Hub, así que no necesita puertos
abiertos ni IP pública.

## Instalación

```bash
pip install chatops-sdk
```

Requiere Python 3.11 o superior.

## Uso

```python
import os
from typing import Literal

from fastapi import FastAPI
from chatops_sdk import BotAgent, CommandContext, UIBlock

os.environ.setdefault("CHATOPS_HUB_URL", "ws://localhost:8000/ws/bot")
os.environ.setdefault("CHATOPS_BOT_TOKEN", "bot_xxxxxxxxxxxx:secreto")

bot = BotAgent(name="Mi-Bot", version="1.0.0", environment="production", project="Pagos")


@bot.command(name="deploy", description="Despliega un servicio")
async def deploy(ctx: CommandContext, service: str, env: Literal["staging", "prod"] = "staging", dry_run: bool = False):
    await ctx.report_progress(40, f"Construyendo {service}...")
    return [
        UIBlock.header(f"✅ {service} desplegado en {env}"),
        UIBlock.metrics([("Duración", "42s"), ("Réplicas", "3", "up")]),
    ]


app = FastAPI(lifespan=bot.lifespan)   # conecta al arrancar y reconecta con backoff
```

- `CHATOPS_HUB_URL`: URL del Hub (`ws://…/ws/bot` o `wss://…/ws/bot`).
- `CHATOPS_BOT_TOKEN`: token del bot (`bot_<id>:<secreto>`), que se obtiene en el Control Center con **+ Nuevo Bot**.

## Versiones

Sigue [semver](https://semver.org). El protocolo con el Relay Hub es un contrato cerrado: un cambio
incompatible en los sobres o en los `UIBlock` implica subir la versión mayor.

## Licencia

MIT.
