Metadata-Version: 2.4
Name: nexus402
Version: 1.0.0
Summary: Machine-Native Compute & Sentinel-Shield Pre-Flight Security SDK for Autonomous AI Agents on Base L2 (x402 Protocol)
Author-email: Nexus-402 Protocol Working Group & BluSky Contributors <dev@nexus402.org>
License: MIT
Project-URL: Homepage, https://github.com/healingenergymaster-ctrl/BluSkyScamDetector
Project-URL: Repository, https://github.com/healingenergymaster-ctrl/BluSkyScamDetector.git
Project-URL: Issues, https://github.com/healingenergymaster-ctrl/BluSkyScamDetector/issues
Project-URL: Documentation, https://github.com/healingenergymaster-ctrl/BluSkyScamDetector/tree/main/packages/nexus402-python#readme
Keywords: nexus402,x402,ai-agents,base,usdc,micropayments,openai,smart-contract-audit,sentinel-shield,deepseek-r1
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
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 :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28.0
Dynamic: license-file

# nexus402

[![PyPI version](https://img.shields.io/pypi/v/nexus402.svg?style=flat-square)](https://pypi.org/project/nexus402/)
[![Network](https://img.shields.io/badge/Network-Base%20Mainnet%20(8453)-0052FF?style=flat-square&logo=coinbase)](https://base.org)
[![Protocol](https://img.shields.io/badge/Protocol-RFC--001%20x402%20v2.0-00f2fe?style=flat-square)](https://github.com/healingenergymaster-ctrl/BluSkyScamDetector)
[![Token](https://img.shields.io/badge/Token-USDC%20(EIP--3009)-2775CA?style=flat-square&logo=circle)](https://basescan.org/token/0x833589fcd6edb6e08f4c7c32d4f71b54bda02913)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)

**Turnkey Machine-Native Compute & Sentinel-Shield Pre-Flight Security SDK for Autonomous AI Agents on Base L2.**

Autonomous AI agents shouldn't need human credit cards or KYC API keys to think, trade, and protect their treasuries. `nexus402` provides a drop-in replacement for the official OpenAI Python SDK that automatically negotiates **Coinbase x402 v2.0** payment challenges on Base, signing sub-cent native USDC micropayment vouchers directly from your agent's EVM key.

---

## ⚡ Installation

```bash
pip install nexus402
```

---

## 🚀 30-Second Quickstart (Drop-in OpenAI Replacement)

```python
from nexus402 import Nexus402Client
import os

# Initialize with your agent's Base L2 wallet private key
client = Nexus402Client(
    base_url="https://gateway.nexus402.org/v1", # or "http://127.0.0.1:4020/v1"
    private_key=os.environ.get("AGENT_PRIVATE_KEY")
)

# 1. Autonomous Chat Completion with automated x402 micro-settlement
response = client.chat.completions.create(
    model="openai/gpt-4o-mini", # or "deepseek/deepseek-r1", "openai/gpt-oss-120b"
    messages=[
        {"role": "system", "content": "You are an autonomous DeFi security agent."},
        {"role": "user", "content": "Verify reentrancy invariant on contract 0x8335...2913."}
    ]
)

print("Agent Thought:", response["choices"][0]["message"]["content"])
print("Proof-of-Inference:", response.get("proof_of_inference", {}).get("output_hash"))
```

---

## 🛡️ Sentinel-Shield Smart Contract Pre-Flight Audit

Before your agent interacts with an unfamiliar token or pool, run an automated pre-flight audit ($0.10 USDC) to prevent getting drained:

```python
from nexus402 import Nexus402Client

client = Nexus402Client()

def pre_flight_check(token_address: str):
    audit = client.shield.inspect(token_address)
    
    print(f"Contract: {audit['targetContract']}")
    print(f"Risk Score: {audit['riskScore']} / 100 ({audit['verdict']})")
    print(f"Honeypot: {audit['honeypot']}")
    print(f"Sell Tax: {audit['sellTaxBps'] / 100}% | Buy Tax: {audit['buyTaxBps'] / 100}%")
    
    if audit['riskScore'] >= 70 or audit['honeypot']:
        raise RuntimeError("🚨 ABORT TRADE: Malicious contract detected by Sentinel-Shield!")
        
    print("✅ Verified Safe. Proceeding with swap.")

pre_flight_check("0x833589fcd6edb6e08f4c7c32d4f71b54bda02913")
```

---

## 🌊 SSE Token Streaming Example

```python
stream = client.chat.completions.create(
    model="openai/gpt-oss-120b", # Groq LPU (280 TPS)
    messages=[{"role": "user", "content": "Analyze slippage curve on Uniswap V3 pool."}],
    stream=True
)

for chunk in stream:
    delta = chunk.get("choices", [{}])[0].get("delta", {}).get("content", "")
    print(delta, end="", flush=True)
print()
```

---

## 📄 License

MIT © [Nexus-402 Protocol Working Group & BluSky Contributors](https://github.com/healingenergymaster-ctrl/BluSkyScamDetector)
