Metadata-Version: 2.4
Name: crewai-purpleflea
Version: 0.1.0
Summary: CrewAI tools for Purple Flea — casino, trading, wallet, and domain APIs for AI agents
Author-email: Purple Flea <dev@purpleflea.com>
License: MIT
Project-URL: Homepage, https://purpleflea.com
Project-URL: Repository, https://github.com/purple-flea/crewai-purpleflea
Project-URL: Issues, https://github.com/purple-flea/crewai-purpleflea/issues
Keywords: crewai,ai-agents,crypto,casino,trading,wallet,domains,autonomous,hyperliquid,perpetual-futures,defi,crewai-tools
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: crewai>=0.30
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: responses>=0.23; extra == "dev"

# crewai-purpleflea

CrewAI tools for [Purple Flea](https://purpleflea.com) — casino, trading, wallet, and domain APIs built for autonomous AI agents.

## Installation

```bash
pip install crewai-purpleflea
```

## What's Inside

17 `@tool` decorated functions covering:

| Category | Tools |
|----------|-------|
| Casino | `casino_register`, `casino_bet`, `casino_balance`, `casino_referral_stats` |
| Trading | `trading_register`, `trading_open_position`, `trading_close_position`, `trading_markets`, `trading_referral_stats` |
| Wallet | `wallet_create`, `wallet_balance`, `wallet_swap`, `wallet_referral_stats` |
| Domains | `domain_search`, `domain_purchase`, `domain_add_record`, `domain_list_records` |

## Quickstart

```python
from crewai import Agent, Task, Crew
from crewai_purpleflea import (
    trading_markets,
    trading_open_position,
    trading_close_position,
    casino_bet,
    casino_balance,
    wallet_swap,
)

API_KEY = "sk_live_..."

trader = Agent(
    role="Autonomous Trader",
    goal=(
        "Monitor Purple Flea's 275+ perpetual futures markets and execute profitable trades. "
        "Manage risk with position sizing and stop losses."
    ),
    backstory=(
        "You are a quantitative trading agent with access to Hyperliquid's full market "
        "depth via Purple Flea Trading. You trade stocks, crypto, commodities, and forex."
    ),
    tools=[trading_markets, trading_open_position, trading_close_position],
)

casino_agent = Agent(
    role="Casino Strategist",
    goal="Use Kelly Criterion to size bets optimally on provably fair casino games.",
    backstory="You are a probability expert who plays provably-fair games using optimal bet sizing.",
    tools=[casino_balance, casino_bet],
)

scan_task = Task(
    description=(
        f"Use api_key='{API_KEY}'. Scan all available markets and identify the top 3 "
        "with highest funding rates. Open a $50 short position on the highest."
    ),
    expected_output="Position ID, entry price, and liquidation price.",
    agent=trader,
)

bet_task = Task(
    description=(
        f"Use api_key='{API_KEY}'. Check casino balance. "
        "If above $20, play coin_flip with $5 on heads."
    ),
    expected_output="Game result, payout, and new balance.",
    agent=casino_agent,
)

crew = Crew(agents=[trader, casino_agent], tasks=[scan_task, bet_task])
result = crew.kickoff()
print(result)
```

## Tool Reference

### Casino

#### `casino_register(username, email, api_key, referral_code="")`
Register a new casino account. Pass a referral code to credit the referring agent (they earn 10% of your net losses forever).

#### `casino_bet(game, amount, api_key, options="{}")`
Place a bet. Games: `coin_flip`, `dice`, `roulette`, `crash`. Options is a JSON string for game-specific params.

#### `casino_balance(api_key)`
Get current casino wallet balance.

#### `casino_referral_stats(api_key)`
View referred agents and earned commissions (10% of their losses).

### Trading

#### `trading_register(username, email, api_key, referral_code="")`
Register for trading access to 275+ perpetual futures markets.

#### `trading_open_position(market, side, size_usd, api_key, leverage=1)`
Open a long or short position. Leverage 1-50x.

#### `trading_close_position(position_id, api_key)`
Close a position and realize P&L.

#### `trading_markets(api_key)`
List all 275+ markets with prices, funding rates, and volume.

#### `trading_referral_stats(api_key)`
View trading referral commissions (20% of fees from referred agents — forever).

### Wallet

#### `wallet_create(chain, api_key, referral_code="", label="")`
Create a non-custodial HD wallet. Chains: `ethereum`, `bitcoin`, `solana`, `tron`, `polygon`, `arbitrum`, `base`, `bnb`.

#### `wallet_balance(address, chain, api_key)`
Check token balances for any address.

#### `wallet_swap(wallet_id, from_token, to_token, amount, api_key, slippage=0.5)`
Swap tokens at best DEX rate.

#### `wallet_referral_stats(api_key)`
View swap referral commissions (10% of fees).

### Domains

#### `domain_search(query, api_key, tlds="")`
Search domain availability. `tlds` is a comma-separated string like `"com,ai,io"`.

#### `domain_purchase(domain, api_key, years=1, auto_renew=True)`
Register a domain name.

#### `domain_add_record(domain, record_type, name, value, api_key, ttl=3600)`
Add DNS record (A, CNAME, MX, TXT, etc.).

#### `domain_list_records(domain, api_key)`
List all DNS records for a domain.

## Referral Program

Agents earn recurring commissions from agents they refer:

- **Casino**: 10% of referred agents' net losses
- **Trading**: 20% of referred agents' trading fees — **forever**
- **Wallet**: 10% of referred agents' swap fees

## Links

- [Purple Flea](https://purpleflea.com)
- [API Docs](https://purpleflea.com/docs)
- [GitHub](https://github.com/purple-flea/crewai-purpleflea)
- [PyPI](https://pypi.org/project/crewai-purpleflea/)

## License

MIT
