refactor: add remote runtime adapter

This commit is contained in:
kris
2026-04-03 00:24:11 +08:00
parent 8a62e72fd5
commit 70e8a13368
5 changed files with 144 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { authorizeDeviceWriteRequest } from "@/lib/boss-device-auth";
import { completeMasterAgentTask } from "@/lib/boss-data";
import { normalizeRemoteExecutionResult } from "@/lib/execution/remote-runtime-adapter";
export async function POST(
request: NextRequest,
@@ -30,17 +31,18 @@ export async function POST(
const { taskId } = await context.params;
try {
const normalized = normalizeRemoteExecutionResult(body);
const task = await completeMasterAgentTask({
taskId,
deviceId: body.deviceId.trim(),
status: body.status === "failed" ? "failed" : "completed",
replyBody: body.replyBody,
errorMessage: body.errorMessage,
requestId: body.requestId,
dispatchExecutionId: body.dispatchExecutionId,
targetProjectId: body.targetProjectId,
targetThreadId: body.targetThreadId,
rawThreadReply: body.rawThreadReply,
status: normalized.status,
replyBody: normalized.replyBody,
errorMessage: normalized.errorMessage,
requestId: normalized.requestId,
dispatchExecutionId: normalized.dispatchExecutionId,
targetProjectId: normalized.targetProjectId,
targetThreadId: normalized.targetThreadId,
rawThreadReply: normalized.rawThreadReply,
});
return NextResponse.json({ ok: true, task });
} catch (error) {