Core tests / core (push) Successful in 9m57s
Full verification / application (push) Failing after 5m16s
Full verification / local-brain (push) Failing after 6m15s
Realm simulation / simulated-live-world (push) Failing after 5m32s
WoW integration lab / real-worldserver (push) Canceled after 17m23s
Source branch: feature/ai-brain-router Source commit: c2a09e0460465201a58aaab56c71424e9a96405e
7 lines
847 B
TypeScript
7 lines
847 B
TypeScript
import { D1Store } from '@/core/store';
|
|
// Reconnectable SSE batches with Last-Event-ID replay. Closing each batch avoids
|
|
// tying a Worker invocation to an unbounded loop; EventSource reconnects in 3s.
|
|
export async function GET(request:Request){
|
|
try{const s=await new D1Store().load();const raw=request.headers.get('last-event-id')??new URL(request.url).searchParams.get('after')??'0';const after=Math.max(0,Number(raw)||0);let data='retry: 3000\n\n';if(after&&s.events[0]?.seq>after+1)data+='event: gap\ndata: {"reload":true}\n\n';for(const e of s.events.filter(e=>e.seq>after))data+=`id: ${e.seq}\nevent: realm\ndata: ${JSON.stringify(e)}\n\n`;return new Response(data+': heartbeat\n\n',{headers:{'Content-Type':'text/event-stream','Cache-Control':'no-cache'}});}catch{return Response.json({error:'Event stream unavailable'},{status:503});}
|
|
}
|