- Extract src/lib/agent/ bounded context with types, registry, messaging - Add comments_count to BeadIssue for SSE comment detection - Create batch endpoints for mail/reservations APIs - Add memory validation to session-preflight - Remove unused empty dirs (mockup, sessions, timeline) - Move stashes to docs/references, gitignore them
29 lines
981 B
TypeScript
29 lines
981 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { inboxAgentMessages } from '../../../../../lib/agent-mail';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET(request: Request): Promise<Response> {
|
|
const { searchParams } = new URL(request.url);
|
|
const agentsParam = searchParams.get('agents') ?? '';
|
|
const limitParam = searchParams.get('limit');
|
|
const limit = limitParam ? Number.parseInt(limitParam, 10) : 25;
|
|
|
|
if (!agentsParam) {
|
|
return NextResponse.json({ ok: true, data: [] }, { status: 200 });
|
|
}
|
|
|
|
const agentNames = agentsParam.split(',').map(a => a.trim()).filter(Boolean);
|
|
|
|
const results = await Promise.all(
|
|
agentNames.map(async (agent) => {
|
|
const result = await inboxAgentMessages({ agent, limit });
|
|
if (!result.ok) {
|
|
return { agent, messages: [] };
|
|
}
|
|
return { agent, messages: result.data ?? [] };
|
|
})
|
|
);
|
|
|
|
return NextResponse.json({ ok: true, data: results }, { status: 200 });
|
|
}
|