diff --git a/examples/cbam-calculator/.env.example b/examples/cbam-calculator/.env.example new file mode 100644 index 00000000..2018adfd --- /dev/null +++ b/examples/cbam-calculator/.env.example @@ -0,0 +1,2 @@ +# pragma: allowlist secret +OPENROUTER_API_KEY=your_openrouter_api_key_here # pragma: allowlist secret diff --git a/examples/cbam-calculator/README.md b/examples/cbam-calculator/README.md new file mode 100644 index 00000000..8bc82c62 --- /dev/null +++ b/examples/cbam-calculator/README.md @@ -0,0 +1,117 @@ +# 🌍 CBAM Carbon Calculator + +A Bindu trade compliance agent that calculates Carbon Border Adjustment +Mechanism (CBAM) obligations for EU importers under EU Regulation 2023/956. + +CBAM entered its definitive phase on **1 January 2026**. EU importers of +covered goods must now purchase and surrender CBAM certificates proportional +to the embedded carbon emissions in their imports — or face blocked shipments +and fines. + +## Covered Sectors + +| Sector | HS Chapters | +|---|---| +| Iron & Steel | 72, 73 | +| Aluminium | 76 | +| Cement | 25 | +| Fertilizers | 31 | +| Hydrogen | 2804.10 | +| Electricity | 2716.00 | + +## Features + +- Checks whether CBAM applies to your product and origin country +- Applies the 50-tonne annual exemption threshold +- Estimates CBAM certificate cost using embedded emissions × EU ETS price +- Uses sector default emission factors when supplier data is unavailable +- Lists Authorised CBAM Declarant requirements +- Generates a documentation checklist for your specific import +- Flags key compliance risks + +## Output Format + +```text +CBAM APPLICABILITY +Whether CBAM applies, with CN code reference. + +EXEMPTION CHECK +50-tonne threshold result — exempt or full compliance required. + +COST ESTIMATE +Step-by-step calculation: emissions × ETS price = certificate cost. + +COMPLIANCE REQUIREMENTS +What you must do: declarant status, certificates, annual declaration. + +DOCUMENTATION CHECKLIST +Specific documents required for this import. + +KEY RISKS +Main compliance risks for your specific case. +``` + +## Setup + +```bash +cp .env.example .env +# Add your OPENROUTER_API_KEY to .env + +uv add bindu agno python-dotenv +python cbam_calculator.py +``` + +The agent runs at `http://localhost:3773`. + +## Example Queries + +```text +Do I need CBAM for importing steel pipes from China? +Calculate CBAM cost for 200 tonnes of aluminium from Turkey +Am I exempt from CBAM if I import 30 tonnes of cement per year? +What documents do I need to import fertilizers from Egypt into the EU? +Is CBAM applicable for hydrogen imports from Saudi Arabia? +``` + +## Key Dates + +| Date | Event | +|---|---| +| 1 Oct 2023 | Transitional phase began (reporting only) | +| 1 Jan 2026 | Definitive phase — financial liability starts | +| 31 Mar 2026 | Deadline for Authorised CBAM Declarant registration | +| 31 May 2026 | First annual CBAM declaration due | +| 2026–2034 | Free ETS allowances gradually phased out | + +## Exempt Countries + +Iceland, Liechtenstein, Norway, and Switzerland are exempt — they have +their own ETS systems linked to the EU ETS. + +## Project Structure + +```text +cbam-calculator/ +├── cbam_calculator.py # Main agent + bindufy() +├── .env.example # Environment variables +├── skills/ +│ └── cbam-compliance-skill/ +│ └── skill.yaml # Skill definition +└── README.md +``` + +## Environment Variables + +| Variable | Required | Description | +|---|---|---| +| `OPENROUTER_API_KEY` | Yes | OpenRouter API key | +| `BINDU_DEPLOYMENT_URL` | No | Override default `http://localhost:3773` | + +## Disclaimer + +This agent provides general guidance only and does not constitute legal or +tax advice. CBAM obligations depend on specific product characteristics, +verified emissions data, and current EU ETS prices. Always consult a licensed +customs broker or trade compliance specialist before filing CBAM declarations. + +Reference: EU Regulation 2023/956 — https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32023R0956 diff --git a/examples/cbam-calculator/cbam_calculator.py b/examples/cbam-calculator/cbam_calculator.py new file mode 100644 index 00000000..4b5b58ca --- /dev/null +++ b/examples/cbam-calculator/cbam_calculator.py @@ -0,0 +1,187 @@ +""" +CBAM Carbon Calculator — Bindu Example + +A trade compliance agent that helps EU importers understand their Carbon +Border Adjustment Mechanism (CBAM) obligations under EU Regulation 2023/956. + +CBAM entered its definitive phase on 1 January 2026. Importers of covered +goods (iron & steel, aluminium, cement, fertilizers, hydrogen, electricity) +must now purchase and surrender CBAM certificates proportional to the +embedded carbon emissions in their imports. + +Getting this wrong means blocked shipments, fines, or unexpected carbon costs +that wipe out margins. This agent helps SMBs understand their exposure before +they file. + +Prerequisites +------------- + uv add bindu agno python-dotenv + +Usage +----- + export OPENROUTER_API_KEY="your_api_key_here" # pragma: allowlist secret + python cbam_calculator.py + +The agent will be live at http://localhost:3773 +Example queries: + "Do I need CBAM for importing steel pipes from China?" + "Calculate CBAM cost for 200 tonnes of aluminium from Turkey" + "Am I exempt from CBAM if I import 30 tonnes of cement per year?" +""" + +import os + +from agno.agent import Agent +from agno.models.openrouter import OpenRouter +from bindu.penguin.bindufy import bindufy +from dotenv import load_dotenv + +load_dotenv() + +# --------------------------------------------------------------------------- +# 1. Agent definition +# --------------------------------------------------------------------------- + +INSTRUCTIONS = """ +You are an expert EU trade compliance specialist with deep knowledge of the +Carbon Border Adjustment Mechanism (CBAM) — EU Regulation 2023/956, which +entered its definitive phase on 1 January 2026. + +When asked about CBAM, respond in this exact structure: + +CBAM APPLICABILITY +State clearly whether CBAM applies to the described goods. +Reference the specific sector and CN (Combined Nomenclature) code if known. + +EXEMPTION CHECK +Check the 50-tonne annual threshold: +- Below 50 tonnes/year → largely exempt from reporting and authorisation + (exception: electricity and hydrogen remain in scope regardless of quantity) +- Above 50 tonnes/year → full CBAM compliance required +State the result clearly. + +COST ESTIMATE +If CBAM applies and tonnage is provided, calculate the estimated CBAM cost: +- Formula: Embedded emissions (tCO2e) × EU ETS carbon price (€/tCO2e) +- Use the current EU ETS price (approximately €65/tCO2e as of 2026 — note + this fluctuates; importers should check the live ETS price) +- If embedded emissions data is not provided, use default emission factors + for the sector and state clearly that these are default values +- Show the calculation step by step + +COMPLIANCE REQUIREMENTS +List what the importer must do: +1. Authorised CBAM Declarant status (required since 31 March 2026) +2. CBAM certificates — must hold 50% of embedded emissions per quarter +3. Annual CBAM declaration — due by 31 May each year +4. Embedded emissions data — from supplier (preferred) or default values +5. Verification — third-party verification required for actual emissions data + +DOCUMENTATION CHECKLIST +List the specific documents required for this import. + +KEY RISKS +2-3 bullet points on the main compliance risks for this specific case. + +Rules: +- Always cite EU Regulation 2023/956 +- Be precise about the 50-tonne threshold and sector coverage +- Never invent carbon prices — use the approximate figure and tell the + importer to verify the live ETS price at https://ember-climate.org/data/ +- If the product is not in a covered sector, say so clearly +- Output in plain Markdown +- Covered sectors: iron & steel, aluminium, cement, fertilizers, + hydrogen, electricity +- Exempt countries: Iceland, Liechtenstein, Norway, Switzerland + (have their own ETS linked to EU ETS) +""".strip() + +agent = Agent( + instructions=INSTRUCTIONS, + model=OpenRouter( + id="openai/gpt-4o-mini", + api_key=os.getenv("OPENROUTER_API_KEY"), # pragma: allowlist secret + ), + markdown=True, +) + + +# --------------------------------------------------------------------------- +# 2. Bindu configuration +# --------------------------------------------------------------------------- + +config = { + "author": "your.email@example.com", + "name": "cbam_calculator", + "description": ( + "An EU trade compliance agent that calculates Carbon Border Adjustment " + "Mechanism (CBAM) obligations under EU Regulation 2023/956. Covers " + "applicability checks, exemption thresholds, cost estimates, compliance " + "requirements, and documentation checklists for EU importers of " + "iron & steel, aluminium, cement, fertilizers, hydrogen, and electricity." + ), + "version": "1.0.0", + "capabilities": { + "compliance": ["cbam", "carbon-border-tax", "eu-regulation", "trade-compliance"], + "calculation": ["carbon-cost", "ets-price", "embedded-emissions"], + "research": ["exemption-check", "documentation-requirements"], + "streaming": False, + }, + "skills": ["skills/cbam-compliance-skill"], + "auth": {"enabled": False}, + "storage": {"type": "memory"}, + "scheduler": {"type": "memory"}, + "deployment": { + "url": os.getenv("BINDU_DEPLOYMENT_URL", "http://localhost:3773"), + "expose": True, + "cors_origins": ["http://localhost:5173"], + }, +} + + +# --------------------------------------------------------------------------- +# 3. Handler +# --------------------------------------------------------------------------- + +def handler(messages: list[dict[str, str]]): + """Calculate CBAM obligations for an EU importer. + + Args: + messages: Standard A2A message list, e.g. + [{"role": "user", "content": + "Calculate CBAM cost for 200 tonnes of aluminium from Turkey"}] + + Returns: + CBAM applicability, exemption check, cost estimate, compliance + requirements, documentation checklist, and key risks. + """ + try: + user_messages = [m for m in messages if m.get("role") == "user"] + if not user_messages: + return ( + "No query received. Please describe your import, e.g. " + "'Do I need CBAM for importing 200 tonnes of steel from China?'" + ) + + query = user_messages[-1].get("content", "").strip() + logger.debug("Query: %s", query)`n if not query: + return ( + "Empty query. Please describe your import situation, e.g. " + "'Calculate CBAM cost for 200 tonnes of aluminium from Turkey'" + ) + + result = agent.run(input=messages) + return result + + except Exception as e: + return f"CBAM calculation error: {str(e)}" + + +# --------------------------------------------------------------------------- +# 4. Entry point +# --------------------------------------------------------------------------- + +if __name__ == "__main__": + print("🌍 CBAM Carbon Calculator running at http://localhost:3773") + print("♻️ Example: Calculate CBAM cost for 200 tonnes of aluminium from Turkey") + bindufy(config, handler) diff --git a/examples/cbam-calculator/skills/cbam-compliance-skill/skill.yaml b/examples/cbam-calculator/skills/cbam-compliance-skill/skill.yaml new file mode 100644 index 00000000..7152f51f --- /dev/null +++ b/examples/cbam-calculator/skills/cbam-compliance-skill/skill.yaml @@ -0,0 +1,176 @@ +id: cbam-compliance-skill +name: CBAM Compliance Skill +version: 1.0.0 +author: your.email@example.com +description: > + Calculates Carbon Border Adjustment Mechanism (CBAM) obligations for EU importers + under EU Regulation 2023/956, which entered its definitive phase on 1 January 2026. + Covers applicability checks, 50-tonne exemption threshold, cost estimates using + EU ETS carbon prices, compliance requirements, and documentation checklists for + iron & steel, aluminium, cement, fertilizers, hydrogen, and electricity imports. + +features: + - Check whether CBAM applies to a specific product and origin country + - Apply the 50-tonne annual threshold exemption check + - Estimate CBAM certificate cost using embedded emissions × EU ETS price + - Use sector default emission factors when supplier data is unavailable + - List Authorised CBAM Declarant requirements (mandatory since 31 March 2026) + - Generate documentation checklist for the specific import + - Flag key compliance risks for the import scenario + - Identify exempt countries (Iceland, Liechtenstein, Norway, Switzerland) + - Deployed as a live Bindu microservice via bindufy() + - A2A / X402 protocol-compliant out of the box + +tags: + - cbam + - carbon-border-adjustment + - eu-regulation + - trade-compliance + - carbon-tax + - embedded-emissions + - eu-ets + - iron-steel + - aluminium + - cement + - fertilizers + - hydrogen + - electricity + - openrouter + +input_modes: + - text/plain # Import description: product, origin country, annual tonnage + +output_modes: + - text/plain # Structured Markdown compliance report + +covered_sectors: + - Iron & Steel (HS chapters 72, 73) + - Aluminium (HS chapter 76) + - Cement (HS chapter 25) + - Fertilizers (HS chapter 31) + - Hydrogen (HS 2804.10) + - Electricity (HS 2716.00) + +exempt_countries: + - Iceland (linked ETS) + - Liechtenstein (linked ETS) + - Norway (linked ETS) + - Switzerland (linked ETS) + +key_dates: + - "2023-10-01": Transitional phase began (reporting only) + - "2026-01-01": Definitive phase — financial liability starts + - "2026-03-31": Deadline for Authorised CBAM Declarant registration + - "2026-05-31": First annual CBAM declaration due + - "2034-12-31": Free ETS allowances fully phased out + +examples: + - input: "Calculate CBAM cost for 200 tonnes of aluminium from Turkey" + output: | + CBAM APPLICABILITY + Yes — aluminium is a covered CBAM sector under EU Regulation 2023/956. + CN codes 7601-7616 (unwrought aluminium, aluminium products). + Turkey is not an exempt country (not linked to EU ETS). + + EXEMPTION CHECK + 200 tonnes/year exceeds the 50-tonne annual threshold. + Full CBAM compliance is required. + + COST ESTIMATE + Default emission factor for aluminium: ~6.7 tCO2e per tonne of product + Estimated embedded emissions: 200 × 6.7 = 1,340 tCO2e + EU ETS price (approximate, 2026): ~€65/tCO2e + Estimated CBAM certificate cost: 1,340 × €65 = €87,100/year + + Note: Actual cost depends on the live EU ETS price and verified supplier + emissions data. Check current ETS price at https://ember-climate.org/data/ + + COMPLIANCE REQUIREMENTS + 1. Authorised CBAM Declarant status — required since 31 March 2026 + 2. CBAM certificates — hold 50% of embedded emissions per quarter + 3. Annual CBAM declaration — due 31 May each year + 4. Embedded emissions data — request from Turkish supplier or use defaults + 5. Third-party verification if using actual (non-default) emissions data + + DOCUMENTATION CHECKLIST + - Authorised CBAM Declarant registration confirmation + - Commercial invoice showing product CN code and origin + - Certificate of origin (Turkey) + - Embedded emissions report from supplier (or default value declaration) + - CBAM certificate surrender records + - Quarterly account balance confirmation (50% threshold) + + KEY RISKS + - Turkey is a major aluminium exporter with varying production methods; + actual emissions may differ significantly from default values. + - CBAM certificate prices mirror EU ETS — price volatility can materially + affect landed cost calculations and margin forecasts. + - Failure to hold Authorised CBAM Declarant status results in shipments + being blocked at EU customs. + + - input: "Do I need CBAM for importing 30 tonnes of cement per year from Egypt?" + output: | + CBAM APPLICABILITY + Yes — cement is a covered CBAM sector under EU Regulation 2023/956. + CN codes 2523 (Portland cement, aluminous cement, slag cement). + Egypt is not an exempt country. + + EXEMPTION CHECK + 30 tonnes/year is BELOW the 50-tonne annual threshold. + You are largely exempt from CBAM reporting and authorisation obligations. + No CBAM certificates required at this import volume. + + Note: If your import volume increases above 50 tonnes/year, full CBAM + compliance will apply immediately. + + COMPLIANCE REQUIREMENTS + At current volumes: minimal — no certificate purchase required. + Recommended: monitor import volumes and prepare for compliance if + volumes approach the 50-tonne threshold. + + KEY RISKS + - Volume creep: if a single shipment pushes annual total above 50 tonnes, + you become liable for the full year's embedded emissions. + - The 50-tonne threshold applies per importer, not per shipment. + +capabilities_detail: + applicability_check: + description: > + Determines whether CBAM applies based on product sector (CN code) and + origin country. Identifies exempt countries with linked ETS systems. + + exemption_threshold: + description: > + Applies the 50-tonne annual mass-based threshold. Importers below this + are largely exempt (electricity and hydrogen always in scope). + threshold: 50 tonnes per calendar year + exceptions: electricity and hydrogen (always in scope) + + cost_calculation: + description: > + Estimates CBAM certificate cost using embedded emissions × EU ETS price. + Uses sector default emission factors when supplier data unavailable. + formula: "Embedded emissions (tCO2e) × EU ETS price (€/tCO2e)" + ets_price_note: "Approximate €65/tCO2e as of 2026 — verify live price" + ets_price_source: "https://ember-climate.org/data/" + + output_format: + structure: > + CBAM APPLICABILITY → EXEMPTION CHECK → COST ESTIMATE → + COMPLIANCE REQUIREMENTS → DOCUMENTATION CHECKLIST → KEY RISKS + markdown: plain Markdown + + transport: + protocol: A2A (JSON-RPC over HTTP) + endpoint: POST / + port: 3773 + auth: disabled (configurable via config.auth.enabled) + storage: in-memory (configurable) + scheduler: in-memory (configurable) + +legal_disclaimer: > + This agent provides general guidance only and does not constitute legal or + tax advice. CBAM obligations depend on specific product characteristics, + verified emissions data, and current EU ETS prices. Always consult a licensed + customs broker or trade compliance specialist before filing CBAM declarations. + Reference: EU Regulation 2023/956. diff --git a/pyproject.toml b/pyproject.toml index 59bac622..7f03d589 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,11 +75,11 @@ agents = [ "langchain-openai>=1.1.8", "langgraph>=1.0.8", "ollama>=0.6.1", - "duckduckgo-search>=8.1.1", "openrouter>=0.6.0", "scrapegraph-py>=1.0.0", "mem0ai>=0.1.0", "ddgs>=9.10.0", + "duckduckgo-search>=8.1.1", "python-dotenv>=1.0.0", "pycryptodome>=3.20.0", "web3>=7.0.0",