- 将 3000 主入口继续收口到 mnote-web,补齐 /favicon.ico、/api/auth、session alias、AI run 等 Rust Web 路由边界。 - 更新登录页与 Convex Auth 代理,支持测试账号快速登录写入真实 Convex Auth cookie。 - 推进页面设置、Wolai 对齐、Phase 7 AI kernel/CLI-first 设计文档与相关 smoke 脚本。 - 更新 leptos-tiptap 生成资产、mnote-cli/bridge-runtime、前端依赖和 dev/prod 启动脚本。
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { errorResponses, safeGetJsonBody, validateRequestBody } from "@/lib/api-utils";
|
|
import { isConvexEnabled } from "@/lib/convex/enabled";
|
|
import { getAuthedConvexClient } from "@/lib/convex/route";
|
|
import {
|
|
startMnoteCliAgentHostRun,
|
|
type MnoteCliAgentRunPayload,
|
|
} from "@/lib/server/mnote-cli-agent-host";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function POST(request: Request) {
|
|
const payload = await safeGetJsonBody<MnoteCliAgentRunPayload>(request);
|
|
if (!payload) {
|
|
return errorResponses.badRequest("请求体不能为空");
|
|
}
|
|
const validationError = validateRequestBody(payload, ["messages"] as const);
|
|
if (validationError) return validationError;
|
|
if (!Array.isArray(payload.messages) || payload.messages.length === 0) {
|
|
return errorResponses.badRequest("缺少 messages");
|
|
}
|
|
|
|
let userId = "";
|
|
let userEmail: string | undefined;
|
|
let userName: string | undefined;
|
|
if (isConvexEnabled()) {
|
|
const { auth } = await getAuthedConvexClient();
|
|
userId = auth.userId ?? "";
|
|
userEmail = auth.email;
|
|
userName = auth.name;
|
|
}
|
|
if (!userId) {
|
|
return errorResponses.unauthorized();
|
|
}
|
|
|
|
return startMnoteCliAgentHostRun({
|
|
request,
|
|
userId,
|
|
userEmail,
|
|
userName,
|
|
payload,
|
|
});
|
|
}
|