-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Agent Observability Core Features - Dashboard and Sessions with Real-Time Data #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ae69950
Initial plan
Copilot 256be19
Add dashboard and sessions API routes with real-time data integration
Copilot a72cbb6
Add implementation summary documentation
Copilot fe58a7d
Add comprehensive README for agent observability core features
Copilot 17d182b
Update documentation with current progress and detailed next steps roβ¦
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * API endpoint for recent agent activity | ||
| * | ||
| * Returns a timeline of recent agent events across all projects | ||
| */ | ||
|
|
||
| import { NextRequest, NextResponse } from 'next/server'; | ||
| import { AgentEventService } from '@codervisor/devlog-core/server'; | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| try { | ||
| const searchParams = request.nextUrl.searchParams; | ||
| const limit = parseInt(searchParams.get('limit') || '20'); | ||
|
|
||
| // Get all projects (for now, using projectId 1 as default) | ||
| // TODO: Query across all user's projects | ||
| const projectId = 1; | ||
|
|
||
| const eventService = AgentEventService.getInstance(projectId); | ||
| await eventService.initialize(); | ||
|
|
||
| // Get recent events | ||
| const events = await eventService.getEvents({ | ||
| projectId, | ||
| limit, | ||
| }); | ||
|
|
||
| return NextResponse.json({ | ||
| success: true, | ||
| data: events, | ||
| }); | ||
| } catch (error) { | ||
| console.error('Error fetching recent activity:', error); | ||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: error instanceof Error ? error.message : 'Failed to fetch recent activity', | ||
| }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||
| /** | ||||||
| * API endpoint for dashboard statistics | ||||||
| * | ||||||
| * Provides aggregated metrics for the main dashboard: | ||||||
| * - Active sessions count | ||||||
| * - Total events today | ||||||
| * - Average session duration | ||||||
| * - Events per minute rate | ||||||
| */ | ||||||
|
|
||||||
| import { NextRequest, NextResponse } from 'next/server'; | ||||||
| import { AgentSessionService, AgentEventService } from '@codervisor/devlog-core/server'; | ||||||
|
|
||||||
| export async function GET(request: NextRequest) { | ||||||
|
||||||
| export async function GET(request: NextRequest) { | |
| export async function GET(_request: NextRequest) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * API endpoint for global agent sessions | ||
| * | ||
| * Returns agent sessions across all projects with filtering and search | ||
| */ | ||
|
|
||
| import { NextRequest, NextResponse } from 'next/server'; | ||
| import { AgentSessionService } from '@codervisor/devlog-core/server'; | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| try { | ||
| const searchParams = request.nextUrl.searchParams; | ||
|
|
||
| // Parse query parameters | ||
| const agentId = searchParams.get('agentId') || undefined; | ||
| const outcome = searchParams.get('outcome') || undefined; | ||
| const status = searchParams.get('status') || undefined; // 'active' or 'completed' | ||
| const startTimeFrom = searchParams.get('startTimeFrom') || undefined; | ||
| const startTimeTo = searchParams.get('startTimeTo') || undefined; | ||
| const limit = parseInt(searchParams.get('limit') || '50'); | ||
| const offset = parseInt(searchParams.get('offset') || '0'); | ||
|
|
||
| // Get all projects (for now, using projectId 1 as default) | ||
| // TODO: Query across all user's projects | ||
| const projectId = 1; | ||
|
|
||
| const sessionService = AgentSessionService.getInstance(projectId); | ||
| await sessionService.initialize(); | ||
|
|
||
| // Build filter | ||
| const filter: any = { projectId, limit, offset }; | ||
| if (agentId) filter.agentId = agentId; | ||
| if (outcome) filter.outcome = outcome; | ||
| if (startTimeFrom) filter.startTimeFrom = new Date(startTimeFrom); | ||
| if (startTimeTo) filter.startTimeTo = new Date(startTimeTo); | ||
|
|
||
| // Get sessions based on status | ||
| let sessions; | ||
| if (status === 'active') { | ||
| sessions = await sessionService.getActiveSessions(); | ||
| } else { | ||
| sessions = await sessionService.listSessions(filter); | ||
| } | ||
|
|
||
| return NextResponse.json({ | ||
| success: true, | ||
| data: sessions, | ||
| pagination: { | ||
| limit, | ||
| offset, | ||
| total: sessions.length, | ||
| }, | ||
| }); | ||
| } catch (error) { | ||
| console.error('Error fetching sessions:', error); | ||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: error instanceof Error ? error.message : 'Failed to fetch sessions', | ||
| }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function parameter
requestis only used to extractsearchParams. Consider destructuring directly or using_requestif the full request object might be needed for future middleware.