feat: Add GET /api/status endpoint with job stats and update PROJECT.md

This commit is contained in:
Vibn Agent Runner
2026-02-26 23:30:15 +00:00
parent 24b18e98bd
commit 7d426c36e2
2 changed files with 143 additions and 27 deletions

View File

@@ -6,54 +6,141 @@ The `vibn-agent-runner` is a service responsible for executing tasks or "agents"
## API Endpoints
(Note: These are example endpoints. Please refer to the source code or API documentation for exact details.)
### `GET /api/status`
### `POST /run-agent`
Retrieves server status and job statistics.
Initiates the execution of an agent.
- **Method:** `GET`
- **URL:** `/api/status`
- **Response Body Example:**
```json
{
"total_jobs": 100,
"by_status": {
"queued": 10,
"running": 5,
"completed": 80,
"failed": 5
},
"uptime_seconds": 3600,
"agents": ["Coder", "PM", "Marketing"]
}
```
### `GET /health`
Health check endpoint.
- **Method:** `GET`
- **URL:** `/health`
- **Response Body Example:**
```json
{
"status": "ok",
"timestamp": "2023-10-27T10:00:00.000Z"
}
```
### `GET /api/agents`
Lists available agents.
- **Method:** `GET`
- **URL:** `/api/agents`
- **Response Body Example:**
```json
[
{
"name": "Coder",
"description": "An agent that writes and modifies code.",
"tools": ["read_file", "write_file", "replace_in_file", "list_directory", "find_files", "search_code", "execute_command", "git_commit_and_push", "gitea_create_issue", "gitea_list_issues", "gitea_close_issue"]
}
]
```
### `POST /api/agent/run`
Submits a new job to run an agent.
- **Method:** `POST`
- **URL:** `/run-agent`
- **URL:** `/api/agent/run`
- **Request Body Example:**
```json
{
"agentId": "your-agent-id",
"payload": {
"param1": "value1",
"param2": "value2"
}
"agent": "Coder",
"task": "Fix bug in user authentication",
"repo": "owner/repo-name"
}
```
- **Response Body Example (Success):**
```json
{
"status": "success",
"runId": "unique-run-id",
"message": "Agent execution started."
}
```
- **Response Body Example (Error):**
```json
{
"status": "error",
"message": "Failed to start agent execution.",
"details": "Error message details"
"jobId": "unique-job-id",
"status": "queued"
}
```
### `GET /agent-status/{runId}`
### `GET /api/jobs/:id`
Retrieves the status of a running or completed agent.
Retrieves the status of a specific job.
- **Method:** `GET`
- **URL:** `/agent-status/{runId}`
- **URL:** `/api/jobs/:id`
- **Response Body Example:**
```json
{
"runId": "unique-run-id",
"status": "running", // or "completed", "failed"
"progress": "50%",
"results": {} // or actual results if completed
"id": "unique-job-id",
"agent": "Coder",
"task": "Fix bug in user authentication",
"repo": "owner/repo-name",
"status": "running",
"progress": "Executing tests...",
"createdAt": "2023-10-27T10:00:00.000Z"
}
```
### `GET /api/jobs`
Lists recent jobs.
- **Method:** `GET`
- **URL:** `/api/jobs`
- **Query Parameters:**
- `limit`: (Optional) Number of jobs to return (default: 20)
- **Response Body Example:**
```json
[
{
"id": "job-id-1",
"agent": "Coder",
"task": "Implement feature X",
"status": "completed"
},
{
"id": "job-id-2",
"agent": "PM",
"task": "Write project brief",
"status": "running"
}
]
```
### `POST /webhook/gitea`
Gitea webhook endpoint to trigger agents from issue events.
- **Method:** `POST`
- **URL:** `/webhook/gitea`
- **Headers:**
- `X-Gitea-Event`: e.g., `issues`
- `X-Gitea-Signature`: HMAC-SHA256 signature (if `WEBHOOK_SECRET` is set)
- **Request Body:** Gitea webhook payload (JSON)
- **Response Body Example:**
```json
{
"jobId": "unique-job-id",
"agent": "Coder",
"event": "issues"
}
```