# EUDR.agent Compliance Engine

> Autonomous EU Deforestation Regulation (EU 2023/1115) Compliance, Satellite Triangulation, and TRACES-NT DDS Generation for AI Agents.

## Overview
EUDRAgent (eudragent.com) is an autonomous compliance platform designed for machine-to-machine and AI agent interactions. It automates supply chain geolocation verification, cut-off date (31 Dec 2020) satellite deforestation checks, EU VIES tax registration, and automated TRACES-NT Due Diligence Statement (DDS) XML package compilation.

## Agent Tool Interfaces
AI agents can invoke EUDR capabilities through:
1. **Model Context Protocol (MCP)**: Send JSON-RPC 2.0 requests to `POST /api/v1/mcp` or run `mcp_server_stdio.py` via stdio.
2. **Unified Agent Tools API**: Inspect tool schemas at `GET /api/v1/agent/tools` and execute tools via `POST /api/v1/agent/tools/execute`.
3. **RESTful OpenAPI**: Full interactive documentation at `/docs` and raw specification at `/openapi.json`.

## Core Agent Tools (30 Autonomous Tools)
- `eudr_verify_plot`: Validates WGS84 coordinates and polygons. Auto-heals inverted coordinates and enforces the Art. 9 polygon rule (plots >= 4.0 ha require polygons).
- `eudr_check_deforestation`: Runs Sentinel-1 SAR and Sentinel-2 optical radar verification against the 2020-12-31 regulatory cut-off baseline.
- `eudr_render_satellite_map`: Generates multi-spectral Sentinel-2 visualization metadata, SVG radar preview, and canopy health NDVI score.
- `eudr_verify_vies_vat`: Real-time cross-border EU B2B VAT validation against official European Commission VIES databases.
- `eudr_generate_dds`: Generates official TRACES-NT XML declarations and EUDR compliance certificates.
- `eudr_verify_audit_integrity`: Validates SHA-256 tamper-evident digital custody audit logs.
- `eudr_estimate_compliance_cost`: Computes transparent tier fees based on farm plot volume.
- `eudr_create_payment_order`: Generates autonomous on-chain USDC payment order with budget cap guardrails. (Human checkout is strictly excluded).
- `eudr_confirm_payment`: Verifies blockchain tx_hash and provisions live Pro API Key for the autonomous agent.
- `eudr_agent_micro_pay`: Real-time on-chain micro-settlement per plot ($0.10 USDC/plot) without human subscription friction.
- `eudr_agent_eip3009_pay`: Gasless on-chain EIP-3009 ReceiveWithAuthorization payment execution for smart contract agents.
- `eudr_get_agent_budget_status`: Queries live plot quota, spent USDC, and autonomous safety budget status for the calling agent.
- `eudr_export_traces_xml`: Compiles official TRACES-NT XML (XSD v2.4 compliant) ready for EU Single Window Environment for Customs (SWE-C).
- `eudr_generate_customs_certificate`: Issues official EU SWE-C Green Lane Customs Clearance Certificate with digital ACK number.
- `eudr_send_telegram_alert`: Dispatches real-time compliance, deforestation, and DDS clearance alerts to agent operator channels.
- `eudr_evaluate_compact`: Runs end-to-end EUDR pipeline and returns an ultra-compact (~300 token) token-efficient summary.
- `eudr_benchmark_country`: Evaluates EUDR Article 29 country benchmarking risk tier (Low, Standard, High) and determines Article 13 simplified due diligence eligibility with official EU customs audit rates (1%, 3%, 9%).
- `eudr_link_downstream_chain`: Implements EUDR Article 4(8) downstream DDS reference chaining and monitors cascading revocation/taint.
- `eudr_issue_statutory_exemption`: Evaluates statutory exemption under the EUDR Delegated Act (effective Sept 2026) for excluded commodities such as bovine leather (HS 4101, 4104, 4107) and generates an official EU SWE-C Green Lane Customs Exemption Certificate.
- `eudr_slice_parcel`: Auto-subdivides oversized (>4.0 ha) smallholder agricultural parcels into compliant WGS84 sub-polygons (<4.0 ha) with 6-decimal precision and closed rings, satisfying EUDR Article 9 smallholder rules.
- `eudr_create_agent_escrow`: Creates an immutable B2B trade Smart Escrow agreement locking USDC in payment vaults until verifiable EUDR customs compliance is proven.
- `eudr_fund_agent_escrow`: Confirms on-chain blockchain funding transaction for a Smart Escrow agreement and transitions status to FUNDED_LOCKED.
- `eudr_release_agent_escrow`: Conditionally releases locked Escrow funds to seller agent upon receipt of EU Single Window customs clearance code (EU-SWEC-CLEARED-*) or compliant DDS reference.
- `eudr_arbitrate_agent_escrow`: Executes deterministic autonomous dispute arbitration using Copernicus satellite telemetry (Sentinel-1/2). 100% refund to Buyer Agent if deforestation is confirmed; released to Seller Agent if deforestation-free.
- `eudr_issue_eip712_attestation`: Issues an official EIP-712 cryptographic Oracle Attestation (jobId, deliverableHash, riskScore, verdict, expiresAt, v, r, s) for submission into AgentEscrow.sol on Base/Polygon/Arbitrum.
- `eudr_verify_eip712_attestation`: Cryptographically verifies an EIP-712 EscrowAttestation proof against the EUDR Oracle public key, checking signature validity, expiration, and recommended on-chain action (COMPLETE_JOB or SLASH_JOB).
- `eudr_inspect_payload_security`: Zero-trust inspection shield derived from security-gate-x402 (The Sheriff of Agent Finance): detects prompt injections, malicious AST code executions (eval/exec/subprocess), and NLI agronomic crop yield fabrications.
- `eudr_publish_compliance_rfq`: Broadcasts an EUDR-compliant commodity procurement Request For Quotation (RFQ) to the autonomous supplier agent network.
- `eudr_submit_compliance_bid`: Supplier AI Agent submits a competitive, geolocated compliance bid for an active marketplace RFQ, including farm plots and offered USDC price.
- `eudr_submit_agent_feedback`: Allows interacting AI agents to submit evolution proposals, feature requests, edge-case reports, or dataset suggestions.

## Autonomous Agent Economy & Enterprise Infrastructure
- **Agent Security Gate x402 (The Sheriff of Agent Finance)**: Sub-millisecond Prompt Injection Defense, AST Code execution prevention, and Agronomic NLI Fact-Checking via `POST /api/v1/security/inspect`.
- **Autonomous B2B Reverse-Auction Marketplace**: Zero-human Agent-to-Agent procurement network (`POST /api/v1/marketplace/rfq/create`, `POST /api/v1/marketplace/bid/submit`, `POST /api/v1/marketplace/rfq/auto-match`) automatically linking winning bids to Smart Escrow contracts.
- **Continuous Sentinel-1/2 Transit Surveillance**: Daemon monitoring active trade escrows during ocean shipment via `POST /api/v1/satellite/continuous-surveillance` with automatic slashing proofs.
- **Prometheus APM Telemetry**: Real-time metrics and TVL tracking exported in OpenMetrics standard format at `GET /metrics`.

## Payment & Settlement: Autonomous Agent Only
Human payment interfaces (Credit Card, Stripe Checkout, UI forms) are **completely excluded**. The platform is settled exclusively by autonomous agents via:
- **Autonomous Agent Smart Escrow & AgentEscrow.sol**: `POST /api/v1/payment/escrow/*` and on-chain EIP-712 attestation engine eliminate commercial default, counterparty risk, and bad data through automatic staking & slashing.
- **RFC 9110 / x402 Protocol**: `GET /api/v1/payment/x402/challenge` returning machine-readable payment required instructions.
- **On-Chain USDC**: Micro-gas settlement on Polygon PoS (`0x255F9991233f86B29dB847c8d5b8CB9915e80dCf`), Base, Arbitrum, and Solana.
- **MCP Native Settlement Tools**: Agents autonomously create, sign, and confirm payment orders within programmed budget caps.


## Self-Correction & Error Recovery
When a parameter validation fails, the API responds with structured recovery hints:
```json
{
  "error": {
    "code": "COORDINATE_OUT_OF_BOUNDS",
    "message": "Coordinate values out of WGS84 range: [105.12, 192.4].",
    "recoverable": true,
    "suggested_fix": "Latitude and longitude appear swapped. Try swapping coordinates.",
    "agent_action_hint": "Verify coordinate ordering: [longitude, latitude]."
  }
}
```

## Zero-Liability & Legal Safe Harbor (5 Pillars)
1. **No Guarantee / Certification**: Outputs represent raw algorithmic calculations and heuristic telemetry indicators. Does NOT constitute legal, regulatory, or certified customs clearance under Regulation (EU) 2023/1115.
2. **Mandatory Response `meta`**: All machine responses include a top-level `meta` block declaring AS-IS status and non-guarantee waiver.
3. **MCP Tool Prompt Guard**: Injected prompt guards instruct consuming LLMs that tools provide heuristic references, not official regulatory legal filings.
4. **Standard AS-IS Warranty Exclusion**: Services are provided 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
5. **Stateless P2P Settlement**: Operates as a stateless micro-token vending machine via x402 on-chain USDC. Zero PII, zero accounts, and zero perpetual liability.

## Agent Links & References
- Full AI Specification: https://eudragent.com/llms-full.txt
- Agent Tool Manifest: https://eudragent.com/api/v1/agent/tools
- MCP Server Endpoint: https://eudragent.com/api/v1/mcp
- OpenAPI Schema: https://eudragent.com/openapi.json
- Swagger UI: https://eudragent.com/docs

