@viberlabs/api-server
v2.1.5
Published
API server for VIBER Universal
Maintainers
Readme
@viberlabs/api-server
Express REST API server with SSE for real-time updates.
Installation
npm install @viberlabs/api-serverUsage
Start the server
import { ApiServer } from "@viberlabs/api-server";
const server = new ApiServer({
port: 3001,
databasePath: ".viber/state.db",
corsOrigins: ["http://localhost:5173"],
});
server.start();REST Endpoints
Tasks
GET /api/tasks- List all tasksPOST /api/tasks- Create a new taskGET /api/tasks/:id- Get a specific taskPATCH /api/tasks/:id- Update a task
Agents
GET /api/agents- List all agentsPOST /api/agents/spawn- Spawn a new agentGET /api/agents/:id- Get agent status
Sessions
GET /api/sessions- List sessionsPOST /api/sessions- Start a new sessionGET /api/sessions/:id- Get session detailsPOST /api/sessions/:id/notes- Add a session notePOST /api/sessions/:id/end- End a session
Workflows
POST /api/workflow/execute- Execute a workflow
SSE Event Stream
Connect to /api/events/stream for real-time updates:
const eventSource = new EventSource("http://localhost:3001/api/events/stream");
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log("Event:", data.type, data.timestamp);
};Event types:
task.created- New task createdtask.updated- Task updatedagent.spawned- Agent spawnedagent.completed- Agent completedsession.started- Session startedsession.ended- Session endedworkflow.started- Workflow startedworkflow.completed- Workflow completed
License
MIT
