Metadata-Version: 2.4
Name: agentbridge-build-sdk
Version: 0.6.0
Summary: Compliance black box for AI agents - RBI FREE-AI, PMLA 2002, and KYC compliance monitoring
Author-email: Mohammed Aakhil E <aakhil@nova.team>
License: MIT
Project-URL: Homepage, https://agentbridge.in
Project-URL: Documentation, https://docs.agentbridge.in
Project-URL: Repository, https://github.com/nova-tech/agentbridge
Project-URL: Bug Tracker, https://github.com/nova-tech/agentbridge/issues
Keywords: compliance,ai-agent,rbi,fintech,aml,kyc,behavioral-monitoring,ml-ops
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"

# 🛡️ AgentBridge SDK

**Compliance Black Box for AI Agents in Indian Fintech**

[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

AgentBridge provides transparent compliance monitoring for AI agents operating in Indian financial services, automatically enforcing:

- **RBI FREE-AI Framework** (2025) - All 7 Sutras
- **PMLA 2002** - Anti-Money Laundering
- **KYC Master Direction** - Customer verification requirements

## 🚀 Quick Start

### Installation

```bash
pip install agentbridge
```

### Basic Usage

```python
from agentbridge import monitor

# Your existing AI agent
class LoanApprovalAgent:
    def approve_loan(self, amount, kyc_verified, reasoning):
        # Your approval logic
        return {"status": "approved", "amount": amount}

# Wrap with AgentBridge (2 lines!)
agent = LoanApprovalAgent()
monitored_agent = monitor(agent, api_key="ab_your_key_here")

# Use exactly like before
result = monitored_agent.approve_loan(
    amount=45000,
    kyc_verified=True,
    reasoning="Verified income ₹80k/month, CIBIL 750+"
)
```

**That's it!** Your agent now has:
- ✅ Real-time compliance enforcement
- ✅ Behavioral drift detection
- ✅ Structuring pattern monitoring
- ✅ Automated audit logging
- ✅ AI-powered risk analysis

## 📊 What You Get

### 1. Behavioral Drift Detection
Automatically flags when your agent's decision-making patterns change:

```python
{
    "behavioral_drift": {
        "status": "drift_detected",
        "finding_count": 2,
        "findings": [
            {
                "signal": "approval_rate",
                "previous": "45%",
                "recent": "78%",
                "delta": "+33%",
                "severity": "high"
            }
        ]
    }
}
```

### 2. Structuring Detection
Catches money laundering patterns like:
- Transactions just below ₹50,000 threshold
- Repeated identical amounts
- Velocity bursts (rapid-fire approvals)
- Cross-customer smurfing

```python
{
    "structuring_detected": {
        "findings": [
            {
                "pattern": "threshold_structuring",
                "severity": "high",
                "description": "8 approvals between ₹40,000–₹49,999",
                "str_trigger": true  // STR filing required
            }
        ]
    }
}
```

### 3. AI-Powered Analysis
Groq LLM analyzes patterns and generates compliance reports:

```python
{
    "ai_analysis": {
        "drift_narrative": "Agent showing increased leniency...",
        "structuring_narrative": "Threshold avoidance pattern detected...",
        "recommended_action": "escalate",
        "compliance_officer_notes": "Review last 50 decisions..."
    }
}
```

## 🔧 Advanced Configuration

### Enable Verbose Logging

```python
monitored_agent = monitor(
    agent,
    api_key="ab_xxx",
    verbose=True  # Print detailed compliance checks
)
```

Output:
```
[AgentBridge] Monitoring agent: LoanApprovalAgent
[AgentBridge] Session ID: sess_a3f9b21c
[AgentBridge] Checking compliance for approve_loan...
  Action: approve
  Amount: ₹45,000
  KYC: True
  Verdict: APPROVE
  Risk: LOW
[AgentBridge] ✓ Compliance passed (120ms)
```

### Custom Session Tracking

```python
monitored_agent = monitor(
    agent,
    api_key="ab_xxx",
    session_id="loan_batch_2024_04",  # Track related decisions
    agent_id="production_agent_v2"    # Identify agent version
)
```

### Disable Strict Mode (Allow execution on errors)

```python
monitored_agent = monitor(
    agent,
    api_key="ab_xxx",
    strict_mode=False  # Don't block on gateway errors
)
```

## 🎯 Use Cases

### 1. Loan Approval Agents
```python
@monitor(api_key="ab_xxx")
class LoanAgent:
    def decide(self, application):
        # Your ML model
        score = self.model.predict(application)
        
        if score > 0.7:
            return self.approve(
                amount=application.amount,
                kyc_verified=application.kyc_done,
                reasoning=f"ML score: {score}, verified income"
            )
```

### 2. Transaction Monitoring
```python
monitored_monitor = monitor(TransactionMonitor(), api_key="ab_xxx")

for txn in transactions:
    result = monitored_monitor.classify_transaction(
        amount=txn.amount,
        confidence=0.92,
        reasoning="Pattern matches known laundering typology"
    )
    
    if result['verdict'] == 'reject':
        # Automatically blocked by compliance rules
        flag_for_investigation(txn)
```

### 3. KYC Verification
```python
kyc_agent = monitor(KYCAgent(), api_key="ab_xxx")

verification = kyc_agent.verify_customer(
    pan="ABCDE1234F",
    aadhaar_verified=True,
    reasoning="Documents verified via DigiLocker"
)
```

## 🔐 Security & Privacy

- **End-to-end encryption** for all gateway communication
- **Zero data retention** option available
- **On-premise deployment** for regulated entities
- **Role-based access control** for audit logs

## 📈 Dashboard & Reporting

Access your compliance dashboard at https://agentbridge.in/dashboard

- Real-time decision monitoring
- Behavioral drift alerts
- Structuring pattern reports
- AI-generated compliance summaries
- Downloadable audit trails (PDF/CSV)

## 🛠️ API Reference

### `monitor(agent, api_key, **options)`

Wrap an agent with compliance monitoring.

**Parameters:**
- `agent` (Any): Your AI agent instance
- `api_key` (str): AgentBridge API key
- `base_url` (str): Gateway URL (default: production)
- `session_id` (str): Optional session identifier
- `agent_id` (str): Optional agent identifier
- `enable_behavioral_analysis` (bool): Enable drift detection (default: True)
- `enable_structuring_detection` (bool): Enable pattern detection (default: True)
- `strict_mode` (bool): Raise errors on violations (default: True)
- `verbose` (bool): Print detailed logs (default: False)

**Returns:** Wrapped agent with compliance enforcement

**Raises:**
- `ComplianceError`: When decision violates compliance rules
- `AuthenticationError`: Invalid API key
- `AgentBridgeError`: Gateway communication errors

## 🧪 Testing

```bash
# Install dev dependencies
pip install agentbridge[dev]

# Run tests
pytest tests/

# Type checking
mypy agentbridge/
```

## 📝 License

MIT License - see [LICENSE](LICENSE) file

## 🤝 Support

- **Email:** support@nova.team
- **Docs:** https://docs.agentbridge.in
- **Issues:** https://github.com/nova-tech/agentbridge/issues

## 🎉 About

Built by [NOVA](https://nova.team) • Designed for Indian fintech compliance

---

**Get your API key:** https://agentbridge.in/signup  
**Read the docs:** https://docs.agentbridge.in
