Restore active run state on session replay

This commit is contained in:
武阳
2026-05-07 16:37:14 +08:00
parent 9d7d496443
commit 2ba67ead00
4 changed files with 147 additions and 2 deletions
@@ -0,0 +1,27 @@
import { getCurrentAccount } from "@/lib/claw-auth";
const CLAW_API_URL = process.env.CLAW_API_URL ?? "http://127.0.0.1:8765";
export async function GET(req: Request) {
const account = await getCurrentAccount();
if (!account)
return Response.json({ error: "请先登录账号" }, { status: 401 });
const incoming = new URL(req.url);
const sessionId = incoming.searchParams.get("session_id")?.trim();
if (!sessionId)
return Response.json({ error: "Missing session_id" }, { status: 400 });
const url = new URL(`${CLAW_API_URL}/api/runs/latest`);
url.searchParams.set("account_id", account.id);
url.searchParams.set("session_id", sessionId);
const response = await fetch(url, { cache: "no-store" });
const payload = await response.text();
return new Response(payload, {
status: response.status,
headers: {
"content-type":
response.headers.get("content-type") ?? "application/json",
},
});
}