[taskboard] add completion sync APIs

This commit is contained in:
2026-03-07 12:53:22 -08:00
parent e8e79c7b4c
commit 73da5ae6d2
9 changed files with 249 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
import { NextResponse } from "next/server";
import { syncOpenClawTasks } from "@/lib/openclaw-sync";
export async function POST() {
return NextResponse.json(await syncOpenClawTasks());
}

View File

@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { applyTaskCallback } from "@/lib/tasks";
export async function POST(
request: Request,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;
const numericId = Number(id);
if (!Number.isInteger(numericId) || numericId <= 0) {
return NextResponse.json({ error: "invalid_task_id" }, { status: 400 });
}
const payload = (await request.json()) as {
status?: "Backlog" | "Todo" | "In Progress" | "Review" | "Done";
dispatch_state?: "planned" | "assigned" | "dispatched" | "acknowledged" | "completed" | "failed";
summary?: string | null;
detail?: string | null;
completed_by?: string | null;
last_error?: string | null;
};
const updated = await applyTaskCallback(numericId, payload);
if (!updated) {
return NextResponse.json({ error: "task_not_found" }, { status: 404 });
}
return NextResponse.json(updated);
}

View File

@@ -38,6 +38,18 @@ export async function PATCH(
reasoning_effort:
typeof payload.reasoning_effort === "string" ? payload.reasoning_effort : undefined,
model_hint: typeof payload.model_hint === "string" ? payload.model_hint : undefined,
result_summary:
payload.result_summary === null || typeof payload.result_summary === "string"
? (payload.result_summary as never)
: undefined,
result_detail:
payload.result_detail === null || typeof payload.result_detail === "string"
? (payload.result_detail as never)
: undefined,
completed_by:
payload.completed_by === null || typeof payload.completed_by === "string"
? (payload.completed_by as never)
: undefined,
priority: payload.priority as never,
status: payload.status as never,
last_dispatch_at: