- PEP-37: change hub (runner/live.ts) woken by notify() (new 'web' subscriber) and PRAGMA data_version; per-scope fingerprints; GET /api/live SSE (no-transform, ping 15 s); LiveRefresh replaces AutoRefresh with a connection indicator and polling fallback - PEP-33: async PostToolUse/PostToolUseFailure hook -> 'step' events (last 200 per session), AgentSteps live feed on the story page and runner panel, tasks.md progress on board cards and the story header - PEP-32: story page header + tabs Proposal/Design/Specs/Tasks/Comments/Tests/Merge request/Activity, safe Markdown renderer, PM comments visible in get_task, edit title/description/epic, accept-and-merge (acceptStory) - OpenSpec changes archived; specs live-updates, agent-steps, story-page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
944 B
TypeScript
22 lines
944 B
TypeScript
// Live updates (PEP-37): SSE of `change` (a watched scope changed — refresh) and `step`
|
|
// (an agent's tool call, PEP-33) events. ?scope=home | runners | project:<id> | task:<id> | steps:<sessionId>, comma-separated.
|
|
import { LiveError, liveSse, parseScopes } from "@peppa/runner";
|
|
import { currentUser } from "@/lib/auth";
|
|
import { db } from "@/lib/db";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
const fail = (status: number, error: string) => Response.json({ error }, { status, headers: { "Cache-Control": "no-store" } });
|
|
|
|
export async function GET(req: Request) {
|
|
const user = await currentUser();
|
|
if (!user) return fail(401, "Нужен вход");
|
|
try {
|
|
return await liveSse(db, user, parseScopes(new URL(req.url).searchParams.get("scope")), req.signal);
|
|
} catch (e) {
|
|
if (e instanceof LiveError) return fail(e.status, e.message);
|
|
console.error("live:", e);
|
|
return fail(500, "Ошибка потока");
|
|
}
|
|
}
|