beadboard/src/app/api/sessions/route.ts
zenchantlive 965d11c0b9 feat(protocol): wire session aggregation and API with liveness
Finalizing the backend engine for the Operative Protocol.
- Updated agent-sessions.ts to use the deriveLiveness logic and the 15m protocol threshold.
- Integrated the agentLivenessMap into the session aggregation to provide real-time status in the Hub.
- Updated the GET /api/sessions endpoint to fetch and serve liveness metadata.
- Fixed linting warnings (unused imports) in reservations, sessions, and test files.

This commit completes the backend contract for bb-u6f.6.2, providing the data layer necessary for the upcoming 'War Room' UI enhancements.

OPERATIVE: silver-castle
SESSION: 2026-02-14-1145
2026-02-14 10:43:02 -08:00

34 lines
1.2 KiB
TypeScript

import { NextResponse } from 'next/server';
import { readIssuesFromDisk } from '../../../lib/read-issues';
import { activityEventBus } from '../../../lib/realtime';
import { buildSessionTaskFeed, getCommunicationSummary, getAgentLivenessMap } from '../../../lib/agent-sessions';
export const dynamic = 'force-dynamic';
export async function GET(request: Request): Promise<Response> {
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 communication = await getCommunicationSummary();
const livenessMap = await getAgentLivenessMap();
const feed = buildSessionTaskFeed(issues, activity, communication, livenessMap);
return NextResponse.json({ ok: true, feed });
} catch (error) {
console.error('[API/Sessions] Failed to load session feed:', error);
return NextResponse.json(
{
ok: false,
error: {
classification: 'unknown',
message: error instanceof Error ? error.message : 'Failed to load session feed.',
},
},
{ status: 500 },
);
}
}