toon-package

Agents.json Event Example

This example demonstrates how to use Toon Agent Bridge with an agents.json schema for developer events and AI agent competitions.

Prerequisites

Setup

  1. Install dependencies:
cd examples/agents-json-event
pnpm install
  1. Start the server:
pnpm start

The server will start on http://localhost:3000.

Features

This example includes:

API Endpoints

Testing the API

Register an Agent

curl -X POST http://localhost:3000/agents \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Agent",
    "team": "Team Alpha",
    "capabilities": ["nlp", "vision"]
  }'

Get All Agents

curl http://localhost:3000/agents

Submit a Task

curl -X POST http://localhost:3000/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "agent-123",
    "taskId": "task-456",
    "result": {
      "score": 95,
      "completed": true
    }
  }'

Frontend Integration

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}
    />
  );
}

Understanding 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.

Next Steps