[taskboard] add dispatch control plane
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { findAgentByAssignmentKey } from "@/lib/agents";
|
||||
import { createTask, listTasks, validateTaskPayload } from "@/lib/tasks";
|
||||
|
||||
export async function GET() {
|
||||
@@ -13,10 +14,26 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ error: "validation_error", details: errors }, { status: 400 });
|
||||
}
|
||||
|
||||
const assignee = typeof payload.assignee === "string" ? payload.assignee : "";
|
||||
const assigneeAgent = assignee ? await findAgentByAssignmentKey(assignee) : null;
|
||||
const task = await createTask({
|
||||
title: String(payload.title),
|
||||
description: typeof payload.description === "string" ? payload.description : "",
|
||||
assignee: typeof payload.assignee === "string" ? payload.assignee : "",
|
||||
assignee,
|
||||
family: (payload.family as never) || assigneeAgent?.family || null,
|
||||
target_host: typeof payload.target_host === "string" ? payload.target_host : assigneeAgent?.host || "",
|
||||
target_channel:
|
||||
typeof payload.target_channel === "string"
|
||||
? payload.target_channel
|
||||
: assigneeAgent?.channels[0]?.value || "",
|
||||
dispatch_method:
|
||||
(payload.dispatch_method as never) || assigneeAgent?.defaultDispatchMethod || "manual",
|
||||
template_key: typeof payload.template_key === "string" ? payload.template_key : null,
|
||||
repo_slug: typeof payload.repo_slug === "string" ? payload.repo_slug : null,
|
||||
base_branch: typeof payload.base_branch === "string" ? payload.base_branch : null,
|
||||
preferred_agent: typeof payload.preferred_agent === "string" ? payload.preferred_agent : null,
|
||||
reasoning_effort: typeof payload.reasoning_effort === "string" ? payload.reasoning_effort : null,
|
||||
model_hint: typeof payload.model_hint === "string" ? payload.model_hint : null,
|
||||
priority: payload.priority as never,
|
||||
status: (payload.status as never) || "Backlog",
|
||||
tags: Array.isArray(payload.tags) ? payload.tags.filter((tag) => typeof tag === "string") : [],
|
||||
|
||||
Reference in New Issue
Block a user