feat(observability): chronological timeline and agent productivity APIs

We added the third major surface to the BeadBoard workspace: the Chronological Timeline. This provides the 'Audit' layer of our operational hierarchy.

Triumphs:
- Built the /timeline route with sticky date grouping and polymorphic EventCards.
- Integrated the ActivityPersistence library to bridge the gap between ephemeral SSE events and persistent project history.
- Implemented real-time Agent Stats endpoints (/api/agents/[id]/stats) that derive throughput and 'Wins' from the project stream.

Raw Honest Moment:
We almost shipped this without persistence, which would have meant the project history would disappear every time the server restarted. Realizing that 'Observability' requires 'Survivability' led us to build the .beadboard/activity.json buffer, a small but vital piece of engineering that makes the timeline actually useful.
This commit is contained in:
zenchantlive 2026-02-14 00:21:02 -08:00
parent f3558dc0d1
commit bfe4f853f0
8 changed files with 428 additions and 0 deletions

View file

@ -0,0 +1,10 @@
import { activityEventBus } from '../../../lib/realtime';
export async function GET(request: Request): Promise<Response> {
const url = new URL(request.url);
const projectRoot = url.searchParams.get('projectRoot') || undefined;
const history = activityEventBus.getHistory(projectRoot);
return Response.json(history);
}

View file

@ -0,0 +1,25 @@
import { NextResponse } from 'next/server';
import { readIssuesFromDisk } from '../../../../../lib/read-issues';
import { activityEventBus } from '../../../../../lib/realtime';
import { getAgentMetrics } from '../../../../../lib/agent-sessions';
export async function GET(
request: Request,
{ params }: { params: Promise<{ agentId: string }> }
): Promise<Response> {
const { agentId } = await params;
const url = new URL(request.url);
const projectRoot = url.searchParams.get('projectRoot') ?? process.cwd();
try {
const issues = await readIssuesFromDisk({ projectRoot, preferBd: true });
const activity = activityEventBus.getHistory(projectRoot);
const metrics = await getAgentMetrics(agentId, issues, activity);
return NextResponse.json({ ok: true, metrics });
} catch (error) {
console.error('[API/Agents/Stats] Failed:', error);
return NextResponse.json({ ok: false, error: String(error) }, { status: 500 });
}
}