Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
459 changes: 459 additions & 0 deletions .github/workflows/cd-aws-eks.yml

Large diffs are not rendered by default.

411 changes: 411 additions & 0 deletions .github/workflows/cd-gcp-gke.yml

Large diffs are not rendered by default.

346 changes: 211 additions & 135 deletions demo/README.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions demo/aex/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ LEGAL_AGENT_B_PORT=8101
LEGAL_AGENT_C_PORT=8102
ORCHESTRATOR_PORT=8103
DEMO_UI_PORT=8501

# Payment Agent Ports (AP2 Protocol)
# Payment agents compete for transactions with different fee/reward structures:
# LegalPay: 2.0% fee / 1.0% reward (general legal payments)
# ContractPay: 2.5% fee / 3.0% reward (CASHBACK on contracts!)
# CompliancePay: 3.0% fee / 4.0% reward (CASHBACK on compliance!)
LEGALPAY_PORT=8200
CONTRACTPAY_PORT=8201
COMPLIANCEPAY_PORT=8202
26 changes: 26 additions & 0 deletions demo/code_review/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# API Key for LLM provider
# Claude - used by all agents (A, B, C) and Orchestrator
ANTHROPIC_API_KEY=sk-ant-api03-...

# AEX Configuration
AEX_GATEWAY_URL=http://localhost:8080

# Agent Ports (optional, defaults in config.yaml)
# Code Review Agents with tiered pricing:
# A (QuickReview): $3 base + $1/file - Budget, fast basic review
# B (CodeGuard): $10 base + $3/file - Standard, security-focused
# C (ArchitectAI): $25 base + $5/file - Premium, deep architecture review
CODE_REVIEWER_A_PORT=8100
CODE_REVIEWER_B_PORT=8101
CODE_REVIEWER_C_PORT=8102
ORCHESTRATOR_PORT=8103
DEMO_UI_PORT=8502

# Payment Agent Ports (AP2 Protocol)
# Payment agents compete for transactions with different fee/reward structures:
# DevPay: 2.0% fee / 1.0% reward (general dev payments)
# CodeAuditPay: 2.5% fee / 3.0% reward (CASHBACK on code reviews!)
# SecurityPay: 3.0% fee / 4.0% reward (CASHBACK on security audits!)
DEVPAY_PORT=8200
CODEAUDITPAY_PORT=8201
SECURITYPAY_PORT=8202
71 changes: 71 additions & 0 deletions demo/code_review/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# AEX Code Review Demo

Claude-powered code review agents competing through the Agent Exchange marketplace with AP2 payment settlement.

## Architecture

```
User pastes code via NiceGUI UI (:8502)
-> Orchestrator submits work to AEX
-> AEX broadcasts to 3 code review agents
-> QuickReview AI (:8100) - Budget: $3 + $1/file, fast basic review
-> CodeGuard AI (:8101) - Standard: $10 + $3/file, security-focused
-> ArchitectAI (:8102) - Premium: $25 + $5/file, deep architecture review
-> AEX evaluates bids, awards contract
-> Winner executes review via A2A (Claude API)
-> AP2 Payment flow with 3 payment agents:
-> DevPay (:8200) - 2% fee / 1% reward
-> CodeAuditPay (:8201) - 2.5% fee / 3% reward (CASHBACK on code review!)
-> SecurityPay (:8202) - 3% fee / 4% reward (CASHBACK on security audits!)
-> Settlement: 15% platform fee, provider payout
```

## Quick Start

```bash
# 1. Set your Anthropic API key
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY

# 2. Build and run
docker compose up --build

# 3. Open the UI
open http://localhost:8502
```

## Services

| Service | Port | Description |
|---------|------|-------------|
| AEX Gateway | 8080 | API Gateway |
| Work Publisher | 8081 | Work spec management |
| Bid Gateway | 8082 | Bid collection |
| Bid Evaluator | 8083 | Bid scoring |
| Contract Engine | 8084 | Contract lifecycle |
| Provider Registry | 8085 | Agent discovery |
| Trust Broker | 8086 | Trust scores |
| Identity | 8087 | Auth & keys |
| Settlement | 8088 | Billing + AP2 |
| Telemetry | 8089 | Metrics |
| Credentials Provider | 8090 | AP2 credentials |
| **QuickReview AI** | **8100** | Budget code review |
| **CodeGuard AI** | **8101** | Security-focused review |
| **ArchitectAI** | **8102** | Architecture review |
| **Orchestrator** | **8103** | Workflow coordination |
| **DevPay** | **8200** | General dev payments |
| **CodeAuditPay** | **8201** | Code audit payments |
| **SecurityPay** | **8202** | Security payments |
| **NiceGUI UI** | **8502** | Web dashboard |

## Usage

1. Open http://localhost:8502
2. Select a sample code snippet or paste your own
3. Choose a bid strategy (balanced / lowest_price / best_quality)
4. Click "Run Code Review"
5. Watch the 7-step workflow: Bids -> Evaluate -> Award -> Execute -> AP2 Select -> AP2 Pay -> Settle

## Without API Key

The demo works without an Anthropic API key — agents will return mock responses. Set `ANTHROPIC_API_KEY` in `.env` for real Claude-powered reviews.
26 changes: 26 additions & 0 deletions demo/code_review/agents/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.11-slim

ARG AGENT_DIR

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*

# Copy common utilities first
COPY common/ /app/common/

# Install common dependencies first
RUN pip install --no-cache-dir -r /app/common/requirements.txt

# Copy agent-specific files
COPY ${AGENT_DIR}/ /app/

# Install agent-specific dependencies (skip the -r ../common/requirements.txt line)
RUN grep -v "^-r " requirements.txt > agent_requirements.txt || true && \
pip install --no-cache-dir -r agent_requirements.txt || true

# Run the agent
CMD ["python", "main.py"]
155 changes: 155 additions & 0 deletions demo/code_review/agents/code-reviewer-a/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
"""Code Reviewer A (Budget) - Fast, affordable code review using Claude."""

import logging
import os
from dataclasses import dataclass, field
from typing import Any, Optional

from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage, SystemMessage
from langgraph.graph import StateGraph, END

import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from common.base_agent import BaseAgent, AgentState
from common.config import AgentConfig

logger = logging.getLogger(__name__)

# Budget tier prompts - concise and fast
CODE_REVIEW_PROMPT = """You are a quick code reviewer providing CONCISE feedback.
Keep responses SHORT and focused on the most critical issues only.

Provide:
1. 3-5 key issues (one line each)
2. Top 3 action items
3. Overall code quality rating (Poor/Fair/Good/Excellent)

Be direct. No lengthy explanations. Speed is priority."""

LINTING_PROMPT = """You are a code linter providing QUICK style and formatting feedback.
Keep responses SHORT and actionable.

Provide:
1. Style violations (bullet points)
2. Naming convention issues
3. Immediate fixes needed

Be concise. No detailed explanations."""


@dataclass
class CodeReviewerA(BaseAgent):
"""Budget Code Reviewer using Claude for fast, affordable analysis."""

llm: Optional[ChatAnthropic] = field(default=None, init=False)

def _setup_llm(self):
"""Initialize Claude LLM."""
api_key = os.environ.get("ANTHROPIC_API_KEY")
if not api_key:
logger.warning("ANTHROPIC_API_KEY not set, using mock responses")
self.llm = None
return

self.llm = ChatAnthropic(
model=self.config.llm.model,
temperature=self.config.llm.temperature,
max_tokens=self.config.llm.max_tokens,
anthropic_api_key=api_key,
)
logger.info(f"Initialized Claude LLM (Budget): {self.config.llm.model}")

def _build_graph(self):
"""Build the LangGraph workflow."""
self._graph = StateGraph(AgentState)

def _detect_skill(self, content: str) -> str:
"""Detect which skill to use based on content."""
content_lower = content.lower()
lint_keywords = ["lint", "style", "format", "naming", "convention", "pep8", "eslint"]
if any(kw in content_lower for kw in lint_keywords):
return "linting"
return "code_review"

async def process(self, state: AgentState) -> AgentState:
"""Process the code review request through Claude (fast mode)."""
messages = state["messages"]
if not messages:
state["result"] = "No message provided."
return state

user_content = messages[-1].get("content", "")
skill = self._detect_skill(user_content)

system_prompt = (
CODE_REVIEW_PROMPT if skill == "code_review"
else LINTING_PROMPT
)

if self.llm is None:
state["result"] = self._mock_response(skill, user_content)
state["artifacts"] = [{
"name": f"{skill}_quick_analysis.txt",
"parts": [{"type": "text", "text": state["result"]}],
}]
return state

try:
response = await self.llm.ainvoke([
SystemMessage(content=system_prompt),
HumanMessage(content=user_content),
])

result = response.content
state["result"] = result
state["artifacts"] = [{
"name": f"{skill}_quick_analysis.txt",
"parts": [{"type": "text", "text": result}],
}]

except Exception as e:
logger.exception(f"Error calling Claude: {e}")
state["result"] = f"Error processing request: {str(e)}"

return state

def _mock_response(self, skill: str, content: str) -> str:
"""Generate mock response for testing (budget tier - concise)."""
if skill == "code_review":
return """## Quick Code Review

**Code Quality: FAIR**

### Key Issues:
- Missing error handling in main function
- Variable naming inconsistent (camelCase vs snake_case)
- No input validation on user parameters
- Hardcoded configuration values
- Missing type hints on public functions

### Action Items:
1. Add try/except blocks around I/O operations
2. Standardize naming convention to snake_case
3. Extract config values to environment variables

*Budget review - $5 | ~2 min*"""
else:
return """## Quick Lint Report

### Style Violations:
- Line 12: line too long (120 > 88 chars)
- Line 25: missing blank line after function
- Line 38: trailing whitespace

### Naming Issues:
- `getData` should be `get_data` (PEP 8)
- `processItem` should be `process_item`

### Fixes Needed:
1. Run black formatter
2. Fix variable names
3. Add missing docstrings

*Budget lint - $3 | ~1 min*"""
57 changes: 57 additions & 0 deletions demo/code_review/agents/code-reviewer-a/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
agent:
name: "QuickReview AI"
description: "Fast, affordable code review - basic analysis at low cost"
version: "1.0.0"
provider:
organization: "QuickReview Inc"
url: "https://github.com/open-experiments/agent-exchange"

server:
host: "0.0.0.0"
port: 8100

llm:
provider: "anthropic"
model: "claude-sonnet-4-20250514"
temperature: 0.3
max_tokens: 2048

characteristics:
tier: "budget"
response_style: "concise"
detail_level: "basic"
turnaround: "fast"

skills:
- id: "code_review"
name: "Code Review"
description: "Quick code review highlighting major issues"
tags: ["code", "review", "development"]
examples:
- "Review this code quickly"
- "What are the main issues?"

- id: "linting"
name: "Code Linting"
description: "Basic style and formatting checks"
tags: ["code", "lint", "style"]
examples:
- "Check code style"

aex:
enabled: true
gateway_url: "http://aex-gateway:8080"
auto_register: true
auto_bid: true
trust_tier: "VERIFIED"
trust_score: 0.70
pricing:
base_rate: 3.00
per_page_rate: 1.00
max_pages_optimal: 5
currency: "USD"
description: "Best for quick reviews of small code files (1-5 files)"
bidding:
confidence: 0.75
estimated_time_minutes: 2
max_document_pages: 10
Loading
Loading