This example demonstrates how to use Toon Agent Bridge with an agents.json schema for developer events and AI agent competitions.
cd examples/agents-json-event
pnpm install
pnpm start
The server will start on http://localhost:3000.
This example includes:
POST /agents - Register a new agentGET /agents - Get all registered agentsPOST /tasks - Submit a task resultGET /events - SSE event streamGET /ws - WebSocket connectionGET /health - Health checkGET /schema - Schema informationcurl -X POST http://localhost:3000/agents \
-H "Content-Type: application/json" \
-d '{
"name": "My Agent",
"team": "Team Alpha",
"capabilities": ["nlp", "vision"]
}'
curl http://localhost:3000/agents
curl -X POST http://localhost:3000/tasks \
-H "Content-Type: application/json" \
-d '{
"agentId": "agent-123",
"taskId": "task-456",
"result": {
"score": 95,
"completed": true
}
}'
Use the React components to visualize agent workflows:
import { AgentVisualizer } from '@programsmagic/toon-frontend';
import '@programsmagic/toon-frontend/styles';
const flows = [
{
id: "agentRegistrationFlow",
name: "Agent Registration Flow",
steps: [
{ actionId: "registerAgent" },
{ actionId: "validateAgent" }
]
}
];
function App() {
return (
<AgentVisualizer
url="http://localhost:3000/events"
protocol="sse"
showFlowDiagram={true}
flows={flows}
/>
);
}
The agents.json file defines flows that orchestrate multiple actions:
{
"flows": [
{
"id": "agentRegistrationFlow",
"name": "Agent Registration Flow",
"steps": [
{
"actionId": "registerAgent",
"onSuccess": ["validateAgent"],
"onError": ["notifyError"]
}
]
}
]
}
This allows agents to chain actions together automatically.
agents.json file to add more actions and flows