Metadata-Version: 2.4
Name: fiderail
Version: 2.3.5
Summary: Non-custodial AI Agent payment control plane, pre-flight firewall, anti-sybil cloud client, and concurrent SQLite edge ledger (zero dependencies).
Author-email: FideRail Contributors <founder@fiderail.com>
License-Expression: MIT
Project-URL: Homepage, https://fiderail.com
Project-URL: Documentation, https://fiderail.com/docs
Project-URL: Repository, https://gitlab.com/fiderail/fiderail
Project-URL: GitHub, https://github.com/fiderail/fiderail
Project-URL: Issues, https://gitlab.com/fiderail/fiderail/-/issues
Keywords: fiderail,ai-agent,payment-control-plane,firewall,x402,anti-sybil,base,solana,arbitrum,polygon,usdc,sqlite
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# FideRail Python SDK

Non-custodial AI Agent payment control plane, pre-flight risk firewall, anti-sybil trust client, and concurrent SQLite WAL edge ledger.

- **Zero third-party dependencies** (Python standard library only, Python `>= 3.9`)
- **100% non-custodial** (never holds private keys, session keys, or user funds)
- **4 Chains x 2 Stablecoins**: Base (`USDC`, `EURC`), Solana (`USDC`, `USDT`), Arbitrum (`USDC`, `USDT0`), and Polygon (`USDC`, `USDT`)
- **PEP 561 typed** (`py.typed` included)

## Installation

```bash
pip install fiderail
```

## Quickstart

### Pre-Flight Payment Guard & Trust Lookup

```python
from fiderail import FideRailClient

client = FideRailClient(
    "https://api.fiderail.com",
    ledger_path="./edge-ledger.db",
    on_outage="fail-closed",
)

try:
    profile = client.get_trust("base", "0x7284d41b5b852f2bd4c99bdf95043d84452d299c")
    verdict = client.preflight_guard(
        chain="base",
        counterparty="0x7284d41b5b852f2bd4c99bdf95043d84452d299c",
        amount_usdc=0.05,
        policy={"maxSingleTxUsdc": 1.0, "maxDailyUsdc": 10.0, "minTrustScore": 40},
    )
    print(verdict["decision"], verdict["reasons"])
finally:
    client.close()
```

### Guarded x402 Request

`guarded_x402_request` scans outbound requests for leaked secrets, checks the endpoint circuit breaker, parses HTTP 402 payment challenges, enforces host/agent policy clamps and mandate attenuation chains, reserves atomic daily budget holds in `SqliteSpendLedger`, and generates verifiable `fiderail-sar-v2` delivery receipts.

```python
result = client.guarded_x402_request(
    "https://api.example.com/paid-endpoint",
    preferred_chain="base",
    policy={"maxSingleTxUsdc": 0.25, "maxDailyUsdc": 5.0, "allowedAssets": ["USDC"]},
    signer=lambda option, guard: my_wallet_sign_x402(option),
)
```

Omit `signer` to run a dry-run pre-flight check without executing a payment.

## Important Integration Semantics

- **Strict blocking of unknown / low-trust addresses (including micro-payments)**: `DEFAULT_FIREWALL_POLICY` sets `allowUnknownMaxUsdc: 0.05` so unindexed or low-score addresses are permitted up to `$0.05 USDC` with `WARN`. **To hard-block all unknown or low-trust addresses including micro-payments, explicitly pass `allowUnknownMaxUsdc: 0` alongside `minTrustScore` in `policy`.**
- **`on_outage` scope**: **`on_outage` (`"fail-closed"` / `"fail-open-micro"`) applies only to `preflight_guard` and `guarded_x402_request`; `get_trust` always raises `RuntimeError` when the cloud oracle is unreachable and no fresh cache hit exists.**
- **Remote seller buyer-activity screening**: **Like `RemoteTrustClient.getPayerActivity` returning `null` remotely by default, remote seller-side buyer screening should call `POST /v1/trust-provider/before-settle`.**
- **Outbound Secret Scrubber Threat Model**: `scan_outbound_secrets()` is a deterministic **accidental-leakage guardrail** for plaintext credentials, not an adversarial exfiltration sandbox against prompt-injection encoding or obfuscation. Never place high-privilege secrets inside LLM prompt context.

## Included Modules & Helpers

- `FideRailClient`: `get_health`, `get_trust`, `get_history`, `list_agents`, `discover_services`, `diagnose_endpoint`, `preflight_guard`, `guarded_x402_request`, `report_delivery_telemetry`
- `SqliteSpendLedger`: concurrent WAL-mode daily budget reservations, idempotency window, endpoint circuit breaker, mandate revocation/spend tracking, and TTL trust cache
- Policy & cryptography helpers: `clamp_policy`, `scan_outbound_secrets`, `validate_mandate_chain`, `create_salted_receipt_v2`, `verify_salted_receipt_v2`, `canonicalize_jcs`, `hash_jcs`, `parse_x402_challenge`
- Network registry: `CHAIN_SPECS`, `ALL_CHAIN_KEYS`, `normalize_chain_name`, `normalize_chain_address`, `is_valid_address`, `get_asset_spec`, `get_primary_asset`

## Links

- Portal & Live Grader: [https://fiderail.com](https://fiderail.com)
- Documentation: [https://fiderail.com/docs](https://fiderail.com/docs)
- REST API & Streamable HTTP MCP: [https://api.fiderail.com](https://api.fiderail.com)
- Source (GitLab): [https://gitlab.com/fiderail/fiderail](https://gitlab.com/fiderail/fiderail)
- Mirror (GitHub): [https://github.com/fiderail/fiderail](https://github.com/fiderail/fiderail)
- Security & Contact: `security@fiderail.com` · `founder@fiderail.com`

## License

[MIT](https://gitlab.com/fiderail/fiderail/-/blob/main/LICENSE)
