2026-02-14 00:20:41 -08:00
|
|
|
import { NextResponse } from 'next/server';
|
|
|
|
|
import { readIssuesFromDisk } from '../../../lib/read-issues';
|
|
|
|
|
import { activityEventBus } from '../../../lib/realtime';
|
2026-02-14 10:43:02 -08:00
|
|
|
import { buildSessionTaskFeed, getCommunicationSummary, getAgentLivenessMap } from '../../../lib/agent-sessions';
|
2026-02-14 00:20:41 -08:00
|
|
|
|
|
|
|
|
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();
|
2026-02-14 10:43:02 -08:00
|
|
|
const livenessMap = await getAgentLivenessMap();
|
2026-02-14 00:20:41 -08:00
|
|
|
|
2026-02-14 10:43:02 -08:00
|
|
|
const feed = buildSessionTaskFeed(issues, activity, communication, livenessMap);
|
2026-02-14 00:20:41 -08:00
|
|
|
|
|
|
|
|
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 },
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|