0.1.14 上线前更改

This commit is contained in:
liaibo
2026-01-11 12:35:53 +08:00
parent be71849aa5
commit 725a60d3aa
44 changed files with 3427 additions and 310 deletions
@@ -0,0 +1,51 @@
import { NextResponse } from "next/server";
import { createSupabaseRouteClient } from "@/lib/supabase/server";
import {
buildClientToolKey,
resolveClientToolCall,
type ClientToolResult,
} from "@/lib/ai-agent/runtime/clientToolBridge";
export const dynamic = "force-dynamic";
type Payload = {
requestId: string;
callId: string;
ok: boolean;
result?: unknown;
error?: string;
};
export async function POST(request: Request) {
const payload = (await request.json().catch(() => null)) as Payload | null;
if (!payload) return NextResponse.json({ error: "缺少请求体" }, { status: 400 });
const requestId = String(payload.requestId ?? "").trim();
const callId = String(payload.callId ?? "").trim();
if (!requestId || !callId) {
return NextResponse.json({ error: "缺少 requestId/callId" }, { status: 400 });
}
const supabase = await createSupabaseRouteClient();
const {
data: { session },
} = await supabase.auth.getSession();
if (!session) return NextResponse.json({ error: "未登录" }, { status: 401 });
const result: ClientToolResult = payload.ok
? { ok: true, result: "result" in payload ? payload.result : null }
: { ok: false, error: String(payload.error ?? "客户端工具执行失败") };
const key = buildClientToolKey(requestId, callId);
const resolved = resolveClientToolCall({
key,
userId: session.user.id,
result,
});
if (!resolved.ok) {
return NextResponse.json({ error: resolved.error }, { status: 404 });
}
return NextResponse.json({ ok: true });
}