Skip to content

feat: Add Ops Dashboard API endpoints - #23

Merged
dsactivi-2 merged 2 commits into
mainfrom
feat/ops-api-endpoints
Dec 31, 2025
Merged

feat: Add Ops Dashboard API endpoints#23
dsactivi-2 merged 2 commits into
mainfrom
feat/ops-api-endpoints

Conversation

@dsactivi-2

Copy link
Copy Markdown
Owner

Summary

  • Adds new /api/ops/* endpoints for the Ops Dashboard
  • Provides unified event stream and task history with filtering

New Endpoints

Endpoint Auth Description
GET /api/ops/events User Unified event stream (tasks + audit)
GET /api/ops/tasks/history User Task history with duration & audit data
GET /api/ops/stats Admin Aggregated statistics

Query Parameters

Events:

  • since - ISO timestamp (default: 24h ago)
  • limit - max events (default: 100, max: 500)
  • agentId - filter by agent
  • type - filter by event type

Tasks History:

  • limit - max tasks (default: 50, max: 200)
  • status - filter by status
  • assignee - filter by agent
  • includeAudit - include audit entries

Test plan

  • TypeScript compiles without errors
  • Endpoints tested with curl
  • Deployed to server and verified

🤖 Generated with Claude Code

Backend:
- GET /api/ops/events - Unified event stream from tasks & audit
- GET /api/ops/tasks/history - Task history with duration & audit data
- GET /api/ops/stats - Aggregated statistics (Admin only)

Features:
- Filter events by since, limit, agentId, type
- Filter task history by status, assignee, includeAudit
- Aggregate stats per agent with completion/stop rates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@sentry review

🤖 Auto-fixed by GitHub Actions
Comment thread src/api/ops.ts
Comment on lines +149 to +156
if (agentId && entry.agent && entry.agent !== agentId) continue;

events.push({
id: `audit-${entry.id}`,
type: "audit_decision",
timestamp: entry.created_at,
taskId: entry.task_id,
agentId: entry.agent,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Filtering by agentId on the /api/ops/events endpoint is non-functional because entry.agent is always undefined, as the audit_entries table lacks an agent column.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The /api/ops/events endpoint attempts to filter audit decision events by agentId. This logic relies on the entry.agent property, which is sourced from the audit_entries database table. However, the audit_entries table schema does not include an agent column, causing entry.agent to always be undefined. As a result, the filtering condition entry.agent && entry.agent !== agentId is never met, and the feature fails silently, returning unfiltered results. Additionally, the agentId field in the response for these events is always undefined.

💡 Suggested Fix

Refactor the code to use the newer db.audit.list() function, which queries the audit_events table that correctly includes an agent_id. Alternatively, add an agent column to the audit_entries table and ensure it is populated when entries are created.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/api/ops.ts#L149-L156

Potential issue: The `/api/ops/events` endpoint attempts to filter audit decision events
by `agentId`. This logic relies on the `entry.agent` property, which is sourced from the
`audit_entries` database table. However, the `audit_entries` table schema does not
include an `agent` column, causing `entry.agent` to always be `undefined`. As a result,
the filtering condition `entry.agent && entry.agent !== agentId` is never met, and the
feature fails silently, returning unfiltered results. Additionally, the `agentId` field
in the response for these events is always `undefined`.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 507408

@dsactivi-2
dsactivi-2 merged commit debf799 into main Dec 31, 2025
1 check passed
@dsactivi-2
dsactivi-2 deleted the feat/ops-api-endpoints branch December 31, 2025 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants