Spaces:
Sleeping
Sleeping
| import { readFileSync } from 'node:fs'; | |
| import { resolve } from 'node:path'; | |
| import { createTemplateAgentHttpServer } from './a2a-http.js'; | |
| import { runMcpServer } from './mcp-server.js'; | |
| import { executeGitHubAgentAction } from './runtime.js'; | |
| const cmd = process.argv[2]; | |
| if (cmd === 'serve-a2a') { | |
| createTemplateAgentHttpServer().start().catch(err => { | |
| console.error(err); | |
| process.exit(1); | |
| }); | |
| } else if (cmd === 'serve-mcp') { | |
| runMcpServer().catch(err => { | |
| console.error(err); | |
| process.exit(1); | |
| }); | |
| } else if (cmd === 'print-card') { | |
| const cardPath = resolve(process.cwd(), 'A2A-CARD.md'); | |
| console.log(readFileSync(cardPath, 'utf8')); | |
| } else if (cmd === 'run-action') { | |
| const payload = process.argv[3]; | |
| if (!payload) { | |
| console.error('Usage: run-action \'{"action":"sin.github.health"}\''); | |
| process.exit(1); | |
| } | |
| executeGitHubAgentAction(JSON.parse(payload)) | |
| .then(res => console.log(JSON.stringify(res, null, 2))) | |
| .catch(err => { | |
| console.error(err); | |
| process.exit(1); | |
| }); | |
| } else { | |
| console.error('Usage: <cli> [serve-mcp|print-card|run-action]'); | |
| process.exit(1); | |
| } | |