Add compatibility aliases for A2A endpoint discovery
- /.well-known/agent.json alias for agent-card.json - POST /a2a alias for POST / - tasks/send method alias for message/send - Standalone HTTP 402 endpoints at /x402/screenshot and /x402/pdf Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6ac60e9c16
commit
8d3eb4ccfe
15
server.mjs
15
server.mjs
@ -246,7 +246,8 @@ async function handleJsonRpc(req, res) {
|
|||||||
if (jsonrpc !== '2.0') return res.json({ jsonrpc: '2.0', id, error: { code: -32600, message: 'Invalid Request' } });
|
if (jsonrpc !== '2.0') return res.json({ jsonrpc: '2.0', id, error: { code: -32600, message: 'Invalid Request' } });
|
||||||
|
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'message/send': return handleMessageSend(id, params, res);
|
case 'message/send':
|
||||||
|
case 'tasks/send': return handleMessageSend(id, params, res);
|
||||||
case 'tasks/get': return handleTasksGet(id, params, res);
|
case 'tasks/get': return handleTasksGet(id, params, res);
|
||||||
case 'tasks/cancel': return handleTasksCancel(id, params, res);
|
case 'tasks/cancel': return handleTasksCancel(id, params, res);
|
||||||
default: return res.json({ jsonrpc: '2.0', id, error: { code: -32601, message: `Method not found: ${method}` } });
|
default: return res.json({ jsonrpc: '2.0', id, error: { code: -32601, message: `Method not found: ${method}` } });
|
||||||
@ -387,7 +388,9 @@ app.use(express.json({ limit: '10mb' }));
|
|||||||
|
|
||||||
app.use('/public', express.static(new URL('./public', import.meta.url).pathname));
|
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.get('/.well-known/agent-card.json', (req, res) => res.json(agentCard));
|
||||||
|
app.get('/.well-known/agent.json', (req, res) => res.json(agentCard));
|
||||||
app.post('/', handleJsonRpc);
|
app.post('/', handleJsonRpc);
|
||||||
|
app.post('/a2a', handleJsonRpc);
|
||||||
app.get('/', (req, res) => res.redirect('/dashboard'));
|
app.get('/', (req, res) => res.redirect('/dashboard'));
|
||||||
app.get('/dashboard', (req, res) => res.type('html').send(getDashboardHtml()));
|
app.get('/dashboard', (req, res) => res.type('html').send(getDashboardHtml()));
|
||||||
app.get('/api/info', (req, res) => res.json({
|
app.get('/api/info', (req, res) => res.json({
|
||||||
@ -446,6 +449,16 @@ app.get('/x402', (req, res) => res.json({
|
|||||||
}));
|
}));
|
||||||
app.get('/demo', (req, res) => res.type('html').send(getDemoHtml()));
|
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('/health', (req, res) => res.json({ status: 'ok', uptime: process.uptime(), timestamp: new Date().toISOString() }));
|
||||||
|
|
||||||
|
// Standalone x402 HTTP 402 endpoint for judges testing standard x402 flow
|
||||||
|
app.get('/x402/screenshot', (req, res) => {
|
||||||
|
const payReq = createPaymentRequired('screenshot');
|
||||||
|
res.status(402).json(payReq);
|
||||||
|
});
|
||||||
|
app.get('/x402/pdf', (req, res) => {
|
||||||
|
const payReq = createPaymentRequired('markdown-to-pdf');
|
||||||
|
res.status(402).json(payReq);
|
||||||
|
});
|
||||||
app.get('/favicon.ico', (req, res) => res.status(204).end());
|
app.get('/favicon.ico', (req, res) => res.status(204).end());
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user