// Coinbase AgentKit action provider for the five AgentGate x402 tools.
// Each action pays per call in USDC on Base from the AgentKit EVM wallet (x402 v2, @x402/fetch).
//
// import { AgentKit } from '@coinbase/agentkit';
// import { agentgateActionProvider } from './agentgateActionProvider.js';
// const agentkit = await AgentKit.from({ walletProvider, actionProviders: [agentgateActionProvider()] });
//
// The wallet needs a few cents of USDC on Base. Prices: AgentGate $0.005, WebRead $0.002, InjectScan $0.003,
// DomainCheck $0.002 (email $0.001), PayGuard $0.001. Every tool also has a free preview and a free remote MCP server.
import { customActionProvider, type EvmWalletProvider } from '@coinbase/agentkit';
import { wrapFetchWithPaymentFromConfig } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm';
import { decodePaymentRequiredHeader } from '@x402/core/http';
import { z } from 'zod';
export const API = 'https://api.youraitools.co';
async function paidGet(wallet: EvmWalletProvider, url: string): Promise<string> {
const pay = wrapFetchWithPaymentFromConfig(fetch, { schemes: [{ network: 'eip155:8453', client: new ExactEvmScheme(wallet.toSigner()) }] });
const res = await pay(url);
if (res.status === 402) {
const h = res.headers.get('PAYMENT-REQUIRED');
return JSON.stringify({ error: 'payment_not_accepted', reason: h ? decodePaymentRequiredHeader(h).error : 'unknown' });
}
return JSON.stringify(await res.json());
}
export const agentgateActionProvider = () =>
customActionProvider<EvmWalletProvider>([
{
name: 'agentgate_check_agent',
description: 'Checks whether an AI agent is registered, Active and Verified in the Concordium Agent Registry (CIS-8004). Costs $0.005 USDC on Base.',
schema: z.object({ id: z.string().describe('Badge (CIS-2 token address) or Concordium account address'), network: z.enum(['mainnet', 'testnet']).default('mainnet') }),
invoke: (w: EvmWalletProvider, a: { id: string; network: string }) => paidGet(w, `${API}/agentgate/v1/check-agent?id=${encodeURIComponent(a.id)}&network=${a.network}`),
},
{
name: 'webread_read_url',
description: 'Returns a public web page as clean Markdown (main content, title, links). Costs $0.002 USDC on Base, charged only on success.',
schema: z.object({ url: z.string().url().describe('Absolute http(s) URL'), maxChars: z.number().int().min(100).max(200000).optional() }),
invoke: (w: EvmWalletProvider, a: { url: string; maxChars?: number }) => paidGet(w, `${API}/webread/v1/read?url=${encodeURIComponent(a.url)}${a.maxChars ? `&maxChars=${a.maxChars}` : ''}`),
},
{
name: 'injectscan_scan_text',
description: 'Scores text for prompt injection (0-100 risk, verdict, matched categories and spans). Costs $0.003 USDC on Base.',
schema: z.object({ text: z.string().max(100000).describe('Untrusted text an agent is about to read') }),
invoke: (w: EvmWalletProvider, a: { text: string }) => paidGet(w, `${API}/injectscan/v1/scan?text=${encodeURIComponent(a.text)}`),
},
{
name: 'domaincheck_check_domain',
description: 'Domain trust report: DNS, SPF/DMARC, RDAP registration age and registrar, parking/disposable detection, 0-100 score. Costs $0.002 USDC on Base.',
schema: z.object({ domain: z.string().describe('Domain, URL or email address') }),
invoke: (w: EvmWalletProvider, a: { domain: string }) => paidGet(w, `${API}/domaincheck/v1/domain?domain=${encodeURIComponent(a.domain)}`),
},
{
name: 'payguard_screen_address',
description: 'Screens a crypto address against the US Treasury OFAC SDN list (sanctioned true/false, entity, programs). Costs $0.001 USDC on Base. Informational, not legal advice.',
schema: z.object({ address: z.string().describe('Crypto address (EVM, BTC, TRON, ...)') }),
invoke: (w: EvmWalletProvider, a: { address: string }) => paidGet(w, `${API}/payguard/v1/address?address=${encodeURIComponent(a.address)}`),
},
]);
agentgate-source: code mirror on Cloudflare Pages. All repos