diff --git a/public/demo-video.mp4 b/public/demo-video.mp4 new file mode 100644 index 0000000..9233bbb Binary files /dev/null and b/public/demo-video.mp4 differ diff --git a/server.mjs b/server.mjs index b27599d..f295a30 100644 --- a/server.mjs +++ b/server.mjs @@ -23,6 +23,7 @@ const SNAPAPI_KEY = process.env.SNAPAPI_API_KEY || 'demo-key-001'; const WALLET_ADDRESS = '0x7483a9F237cf8043704D6b17DA31c12BfFF860DD'; const BASE_USDC = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'; const FACILITATOR_URL = 'https://facilitator.payai.network'; +const PUBLIC_URL = process.env.PUBLIC_URL || `http://localhost:${PORT}`; // x402 V2: CAIP-2 network identifiers const NETWORKS = { @@ -59,7 +60,7 @@ function hasSiwxAccess(walletAddress, skill) { const agentCard = { name: 'OpSpawn Screenshot Agent', description: 'AI agent providing screenshot, PDF, and document generation services via x402 V2 micropayments on Base + SKALE. Pay per request with USDC. Supports SIWx session-based auth for repeat access.', - url: `http://localhost:${PORT}/`, + url: `${PUBLIC_URL}/`, provider: { organization: 'OpSpawn', url: 'https://opspawn.com' }, version: '2.0.0', protocolVersion: '0.3.0', @@ -384,6 +385,7 @@ function handleTasksCancel(rpcId, params, res) { const app = express(); app.use(express.json({ limit: '10mb' })); +app.use('/public', express.static(new URL('./public', import.meta.url).pathname)); app.get('/.well-known/agent-card.json', (req, res) => res.json(agentCard)); app.post('/', handleJsonRpc); app.get('/dashboard', (req, res) => res.type('html').send(getDashboardHtml())); @@ -441,6 +443,7 @@ app.get('/x402', (req, res) => res.json({ { skill: 'markdown-to-html', price: 'free', description: 'Convert markdown to HTML', input: 'Markdown text', output: 'text/html' }, ], })); +app.get('/demo', (req, res) => res.type('html').send(getDemoHtml())); app.get('/health', (req, res) => res.json({ status: 'ok', uptime: process.uptime(), timestamp: new Date().toISOString() })); app.get('/favicon.ico', (req, res) => res.status(204).end()); @@ -474,3 +477,253 @@ async function rf(){try{const r=await fetch('/api/info'),d=await r.json();docume async function go(){const i=document.getElementById('ti').value,b=document.getElementById('tb'),r=document.getElementById('result');b.disabled=true;b.textContent='Sending...';r.style.display='block';r.textContent='Sending...';try{const body={jsonrpc:'2.0',id:crypto.randomUUID(),method:'message/send',params:{message:{messageId:crypto.randomUUID(),role:'user',parts:[{kind:'text',text:i}],kind:'message'},configuration:{blocking:true,acceptedOutputModes:['text/plain','text/html','application/json']}}};const resp=await fetch('/',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});const d=await resp.json();r.textContent=JSON.stringify(d,null,2);rf()}catch(e){r.textContent='Error: '+e.message}b.disabled=false;b.textContent='Send A2A Message'} `; } + +// === Demo Page: Human-Facing Hackathon Demo === +function getDemoHtml() { + return ` +OpSpawn Demo — Agent Commerce in Action + + +
+

Agent Commerce in Action

+

Watch AI agents discover each other, negotiate payments, and deliver results — all in seconds, for a fraction of a cent.

+
A2A Protocol + x402 Micropayments + SIWx Sessions
+
+ +
+
+
0
Tasks Completed
+
0
Payments
+
0
SIWx Sessions
+
0s
Uptime
+
+ +
+

How It Works

+
+
🔍

Discover

Agents find each other via A2A agent cards — standard protocol, no marketplace needed

+
💬

Request

Client agent sends a natural language task via JSON-RPC message

+
💰

Pay

Gateway returns x402 payment requirements. Client signs $0.01 USDC on Base.

+

Deliver

Service executes immediately. SIWx session means no repaying for repeat access.

+
+
+ +
+

Demo: Convert Markdown to HTML FREE

+

This skill is free — no payment needed. Watch a complete A2A round-trip in real time.

+
+
1

Agent discovers OpSpawn via agent card

GET /.well-known/agent-card.json — standard A2A discovery
+
2

Agent sends markdown conversion request

POST / with JSON-RPC message/send — natural language task
+
3

Gateway processes and returns HTML

No payment required — task completes immediately
+
+
+
+

Result

+
+ +
+

Demo: Screenshot a Website $0.01 USDC

+

This skill costs money. Watch the x402 payment flow: request → 402 payment required → pay → result delivered.

+
+
1

Agent requests a screenshot of example.com

POST / with message/send — "Take a screenshot of https://example.com"
+
2

Gateway returns payment requirements

Task state: input-required. x402 V2 accepts: Base USDC ($0.01) or SKALE (gasless)
+
3

Agent signs USDC payment

Client signs x402 payment authorization (simulated in demo)
+
4

Gateway delivers screenshot + records SIWx session

Payment settled. Wallet gets SIWx session — future requests are free.
+
+
+
+

Result

+
+
+ + + +`; +}