Metadata-Version: 2.4
Name: sigui-sdk
Version: 0.2.0
Summary: Python SDK for Sigui Protocol — Autonomous Security for the Agentic Economy
Project-URL: Homepage, https://sigui.io
Project-URL: Documentation, https://docs.sigui.io
Project-URL: Repository, https://github.com/diass/Sigui
Project-URL: Issues, https://github.com/diass/Sigui/issues
Project-URL: Changelog, https://github.com/diass/Sigui/blob/main/sdk/python/CHANGELOG.md
Author-email: Sigui Protocol <sdk@sigui.io>
License: MIT
Keywords: agentic,agents,ai,arc,autogen,crewai,depin,langchain,langgraph,openai-agents,security,smolagents,usdc,web3,x402
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: loguru>=0.7.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.12.0
Provides-Extra: all
Requires-Dist: autogen-agentchat>=0.4.0; extra == 'all'
Requires-Dist: autogen-core>=0.4.0; extra == 'all'
Requires-Dist: crewai>=0.80.0; extra == 'all'
Requires-Dist: google-adk>=0.1.0; extra == 'all'
Requires-Dist: langchain-core>=0.3.0; extra == 'all'
Requires-Dist: langchain>=0.3.0; extra == 'all'
Requires-Dist: langgraph>=0.2.0; extra == 'all'
Requires-Dist: llama-index>=0.10.0; extra == 'all'
Requires-Dist: openai-agents>=0.0.5; extra == 'all'
Requires-Dist: smolagents>=1.0.0; extra == 'all'
Provides-Extra: autogen
Requires-Dist: autogen-agentchat>=0.4.0; extra == 'autogen'
Requires-Dist: autogen-core>=0.4.0; extra == 'autogen'
Provides-Extra: circle
Provides-Extra: crewai
Requires-Dist: crewai>=0.80.0; extra == 'crewai'
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: google-adk
Requires-Dist: google-adk>=0.1.0; extra == 'google-adk'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.3.0; extra == 'langchain'
Requires-Dist: langchain>=0.3.0; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: langchain-core>=0.3.0; extra == 'langgraph'
Requires-Dist: langgraph>=0.2.0; extra == 'langgraph'
Provides-Extra: llamaindex
Requires-Dist: llama-index>=0.10.0; extra == 'llamaindex'
Provides-Extra: openai-agents
Requires-Dist: openai-agents>=0.0.5; extra == 'openai-agents'
Provides-Extra: smolagents
Requires-Dist: smolagents>=1.0.0; extra == 'smolagents'
Description-Content-Type: text/markdown

# Sigui SDK — Autonomous Security for AI Agents

[![PyPI version](https://img.shields.io/pypi/v/sigui-sdk.svg)](https://pypi.org/project/sigui-sdk/)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://python.org)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Model](https://img.shields.io/badge/Model-Qwen2--VL--7B-orange)](https://huggingface.co/Ibonon/imina_na_v2_lora)
[![Dataset](https://img.shields.io/badge/Dataset-1M%20Graphs-purple)](https://huggingface.co/datasets/Ibonon/sigui-depin-1mn)

**Sigui** is an open-source security oracle that protects AI agents from sending erroneous or malicious crypto payments. 

Add a security evaluation layer to any AI agent in **3 lines of code**. Every transaction is analyzed by a 5-layer AI security pipeline (including a fine-tuned Vision Language Model) in **< 50 ms** before execution.

---

## ⚡ The Problem & The Solution

**The Problem:** Autonomous agents (LangChain, CrewAI, AutoGen) can now execute USDC transfers and interact with DeFi protocols. But a single hallucination, prompt injection, or misconfigured tool means the agent can send $5,000 to the wrong address. There is no middleware to stop it.

**The Solution:** `sigui-sdk` intercepts the payment intent, evaluates it against a 5-layer security pipeline, and returns a strict verdict (`ALLOW`, `BLOCK`, `ESCALATE`).

---

## 📦 Installation

```bash
pip install sigui-sdk
```

Install the specific extras for the framework you are using:

```bash
pip install "sigui-sdk[langchain]"       # LangChain & LangGraph
pip install "sigui-sdk[crewai]"          # CrewAI
pip install "sigui-sdk[autogen]"         # Microsoft AutoGen (AG2)
pip install "sigui-sdk[openai-agents]"   # OpenAI Agents SDK
pip install "sigui-sdk[smolagents]"      # HuggingFace smolagents

pip install "sigui-sdk[all]"             # Install all integrations
```

---

## 🚀 Quickstart (2 lines)

```python
from sigui import SiguiClient

async with SiguiClient(api_url="http://localhost:8000") as client:
    result = await client.evaluate(amount=5.0, destination="0xRecipient...")

    if result.is_safe:
        print(f"✅ Authorized   risk={result.risk_score:.3f}")
    elif result.is_blocked:
        print(f"🚫 Blocked      {result.reason}")
    else:
        print(f"⚠️  Escalation required")
```

*(Note: Sigui requires the backend security engine to be running locally. See the **Backend Setup** section below).*

---

## 🧩 Framework Integrations

Sigui provides native Tools for all major agent frameworks. Drop them into your agent's tool list with zero refactoring.

### 🦜 LangChain / LangGraph
```python
from sigui import SiguiClient
from sigui.integrations.langchain import create_langchain_tool

client = SiguiClient(api_url="http://localhost:8000")
sigui_tool = create_langchain_tool(client, auto_escalate=True)

# Drop into any LangChain agent
agent = initialize_agent(tools=[sigui_tool, ...], llm=llm)
```

### 🤖 CrewAI
```python
from sigui import SiguiClientSync
from sigui.integrations.crewai import SiguiEvaluationTool

client = SiguiClientSync(api_url="http://localhost:8000", agent_id="my_crew")
tool = SiguiEvaluationTool(sigui_client=client, auto_escalate=True)

payment_agent = Agent(role="DeFi Agent", tools=[tool], ...)
```

### 🧩 Microsoft AutoGen (AG2)
```python
from autogen_agentchat.agents import AssistantAgent
from sigui import SiguiClient
from sigui.integrations.autogen import create_autogen_tool

client = SiguiClient(api_url="http://localhost:8000")
sigui_tool = create_autogen_tool(client, auto_escalate=True)

agent = AssistantAgent(name="payment_agent", tools=[sigui_tool], ...)
```

### 🤗 HuggingFace smolagents
```python
from smolagents import CodeAgent
from sigui import SiguiClient
from sigui.integrations.smolagents import SiguiTool

client = SiguiClient(api_url="http://localhost:8000")
tool = SiguiTool(client, auto_escalate=True)

agent = CodeAgent(tools=[tool], model=...)
```

---

## 🛡️ Framework-Agnostic Decorator

If you don't want to use agent Tools, you can gate **any async Python function** directly:

```python
from sigui.decorators import sigui_protect

client = SiguiClient(api_url="http://localhost:8000")

@sigui_protect(client, amount_arg="usdc", destination_arg="to")
async def transfer(to: str, usdc: float, memo: str = ""):
    # This code ONLY executes if Sigui returns ALLOW
    await wallet.send(to, usdc)

# Usage (raises SiguiBlockedError if flagged as malicious)
await transfer(to="0xAttacker...", usdc=500.0)
```

---

## 🧠 How it Works: The 5-Layer Pipeline

When your agent calls `client.evaluate()`, the backend runs a comprehensive security check in under 50ms:

1. **MemoClaw**: Episodic behavioral memory. (Is this agent acting weird compared to its history?)
2. **Sirige**: Rule-based anomaly detection (spikes in amounts, blacklisted addresses).
3. **Anti-splitting**: Cross-chain flow analysis to detect smurfing.
4. **Imina Na (Vision)**: A fine-tuned Vision model that renders the transaction graph topology as an image and classifies the attack pattern.
5. **Kanaga Risk Aggregator**: Final risk scoring.

### 🤗 Open-Source Vision Model & Dataset
The **Imina Na** vision layer is powered by **Qwen2-VL-7B-Instruct**, fine-tuned using Unsloth on AMD MI300X GPUs. 
Both the model and the 1-million sample training dataset are open-source and available on HuggingFace:
* **Model**: [Ibonon/imina_na_v2_lora](https://huggingface.co/Ibonon/imina_na_v2_lora)
* **Dataset**: [Ibonon/sigui-depin-1mn](https://huggingface.co/datasets/Ibonon/sigui-depin-1mn)

---

## ⚙️ Backend Setup (Required)

`sigui-sdk` requires the Sigui Security Engine to be running. We do not currently provide a public hosted API. 

You can run the backend locally in 2 minutes using Docker:

```bash
# 1. Clone the main repository
git clone https://github.com/ibonon/Sigui.git
cd Sigui

# 2. Configure for local dev (no crypto keys required)
cp .env.example .env
# Ensure DEMO_MODE=true is set in .env

# 3. Launch the security oracle
docker compose up
```

Once running, your SDK can connect to `http://localhost:8000`.

---

## 📄 License

MIT © Sigui Protocol.

*Built for the Agentic Economy.*
