Your Name 4b820f8ff4
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
Add canvas agent mode and management
2026-03-10 19:56:25 +08:00

37 lines
1.1 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/(auth)/auth";
import { ChatSDKError } from "@/lib/errors";
import { getAccessibleAgentPresetExecutionSnapshotById } from "@/lib/db/queries";
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await auth();
if (!session?.user?.id) {
return NextResponse.json({ success: false, error: "未登录" }, { status: 401 });
}
const { id } = await params;
const snapshot = await getAccessibleAgentPresetExecutionSnapshotById({
id,
userId: session.user.id,
});
if (!snapshot) {
return NextResponse.json({ success: false, error: "执行快照不存在" }, { status: 404 });
}
return NextResponse.json({ success: true, data: snapshot });
} catch (error) {
if (error instanceof ChatSDKError) {
return error.toResponse();
}
return NextResponse.json(
{ success: false, error: "获取执行快照失败" },
{ status: 500 }
);
}
}