Complete API reference for Toon Agent Bridge packages.
Parse an OpenAPI 3.0 schema from file or URL.
import { parseOpenAPISchema } from '@programsmagic/toon-core';
const schema = await parseOpenAPISchema('./openapi.json');
Parse an agents.json schema from file or URL.
import { parseAgentsJsonSchema } from '@programsmagic/toon-core';
const schema = await parseAgentsJsonSchema('./agents.json');
AgentSchema: Normalized agent schemaAgentAction: Individual action definitionAgentFlow: Flow definitionAgentEvent: Event typeEventType: Event type enumCreate a Fastify server from a schema.
import { createServer } from '@programsmagic/toon-backend-node';
const server = await createServer({
port: 3000,
schemaSource: './schema.json',
cors: true,
});
await server.start();
port (number, default: 3000): Server porthost (string, default: ‘0.0.0.0’): Server hostschemaSource (string, required): Path to schema fileauth (AuthConfig, optional): Authentication configurationcors (boolean |
object, default: true): CORS configuration |
GET /health: Health checkGET /schema: Schema informationGET /events: SSE event streamGET /ws: WebSocket connection*: Auto-generated routes from schemaCreate a FastAPI server from a schema.
from toon_backend import create_server, ServerOptions
options = ServerOptions(
schema_source="./schema.json",
port=8000,
cors=True,
)
server = await create_server(options)
schema_source (str, required): Path to schema fileport (int, default: 8000): Server porthost (str, default: ‘0.0.0.0’): Server hostcors (bool, default: True): Enable CORScors_origins (list, optional): CORS allowed originsMain visualization component.
<AgentVisualizer
url="http://localhost:3000/events"
protocol="sse"
autoConnect={true}
/>
React hook for event streaming.
const { events, isConnected, connect, disconnect } = useAgentStream({
url: 'http://localhost:3000/events',
protocol: 'sse',
});
Timeline component for events.
<EventTimeline events={events} />
Card component for individual actions.
<ActionCard event={event} />
Flow visualization component.
<FlowDiagram events={events} flows={flows} />
All events follow this structure:
interface AgentEvent {
type: EventType;
id: string;
timestamp: number;
// ... event-specific fields
}
TEXT_MESSAGE_CONTENTTOOL_CALL_STARTTOOL_CALL_ENDACTION_STARTACTION_ENDFLOW_STARTFLOW_ENDSTATE_UPDATEERRORHEARTBEAT