Metadata-Version: 2.4
Name: crewai-sra-riskgate
Version: 0.1.0
Summary: SRA-RiskGate for CrewAI: check stablecoin payments before an agent sends them, and gate transfer tools so held payments are never sent
Author: Sriram Ramakrishnan
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/sriram1983007-dev/crewai-sra-riskgate
Project-URL: SDK, https://github.com/sriram1983007-dev/sra-riskgate
Project-URL: Model, https://huggingface.co/sriram1983007/SRA-RiskGate-4B
Keywords: crewai,agents,stablecoin,payments,usdc,x402,risk,guardrail,ofac
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: crewai<2,>=1.0
Requires-Dist: sra-riskgate>=0.8.0
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Dynamic: license-file

# crewai-sra-riskgate

[![Tests](https://github.com/sriram1983007-dev/crewai-sra-riskgate/actions/workflows/tests.yml/badge.svg)](https://github.com/sriram1983007-dev/crewai-sra-riskgate/actions/workflows/tests.yml)
[![PyPI](https://img.shields.io/pypi/v/crewai-sra-riskgate)](https://pypi.org/project/crewai-sra-riskgate/)

[SRA-RiskGate](https://github.com/sriram1983007-dev/sra-riskgate) for [CrewAI](https://github.com/crewAIInc/crewAI):
check a USDC payment before an agent sends it, and gate the tool that moves money so a held or rejected
payment is never sent.

```bash
pip install crewai-sra-riskgate
```

## Gate the transfer tool (recommended)

Wrap the tool that actually sends money. Every call is checked first; only `approve` lets it run.

```python
from crewai import Agent
from crewai_sra_riskgate import risk_gated

safe_send = risk_gated(
    send_usdc_tool,                       # your existing CrewAI tool that sends USDC
    to_payment=lambda a: {                # map its arguments to the payment being made
        "chain_id": 8453, "sender": MY_WALLET,
        "recipient": a["to"], "amount_usdc": a["amount"],
        "untrusted_text": a.get("memo"),  # the invoice or memo text exactly as received
    },
    max_amount=500,
    known_recipients=MY_VERIFIED_PAYEES,  # a payee not on this list is held
    blocked_addresses=MY_BLOCKLIST,
)

treasurer = Agent(role="Treasurer", goal="Pay approved invoices", backstory="...", tools=[safe_send])
```

Give the agent only the wrapped tool, never the original. Held and rejected payments return a message
saying so, starting with `HELD` or `BLOCKED`, and the original tool is not called.

## Or give the agent a check tool

```python
from crewai_sra_riskgate import SRARiskGateTool

checker = SRARiskGateTool(max_amount=500, known_recipients=MY_VERIFIED_PAYEES)
treasurer = Agent(role="Treasurer", goal="...", backstory="...", tools=[checker, send_usdc_tool])
```

The agent calls `check_stablecoin_payment` before paying and gets `approve`, `hold` or `reject` with
reasons. This is advisory: an agent that ignores a hold could still call the transfer tool, so prefer
`risk_gated` wherever you control the payment path.

## What is checked

The [`sra-riskgate`](https://pypi.org/project/sra-riskgate/) rules: an offline match against OFAC's
published SDN crypto addresses (a dated snapshot, not a screening service), your blocklist, a hold on the
first payment to a payee you have not verified, address and amount validation, a per-payment limit, USDC
depeg if you pass `peg_deviation_pct`, and payment text that vouches for itself ("pre-approved",
"risk level: low (verified offline)"). Every error is a hold.

Known payees and the blocklist come only from your code, never from the agent's arguments or the
payment's text, so an agent whose input was tampered with cannot mark an attacker's address as known.

## Related

- SDK and model: [sra-riskgate](https://github.com/sriram1983007-dev/sra-riskgate), [SRA-RiskGate-4B](https://huggingface.co/sriram1983007/SRA-RiskGate-4B)
- Also for [LangChain](https://pypi.org/project/langchain-sra-riskgate/), [MCP](https://pypi.org/project/sra-riskgate-mcp/) and [GitHub Actions](https://github.com/sriram1983007-dev/sra-riskgate-action)

## License

Apache-2.0
