Der Rueckstau war bisher eine Zahl ('94 offene Tasks'). Diese View zeigt nur
Tasks mit attention-Block, also die, bei denen ein Agent ohne eine
Mensch-Entscheidung nicht weiterkommt.
- /api/fleet/attention: GET ruft attention_summary, POST ruft answer_attention.
- AttentionPanel: Frage, Optionen als Buttons, Freitextfeld, Rueckmeldung
(OK / OK_ALREADY / OK_JOURNAL_ONLY), Poll 10 s, fail loud.
- Sidebar-View 'attention' + Verdrahtung in page.tsx.
Die Antwort geht ueber board-service answer_attention: Frage wird am Task
geschlossen (answered_at) und der Agent bekommt einen fyi-Reply-Task mit
reply_to. Kein Chat, kein Bauauftrag.
53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
import { NextResponse } from "next/server"
|
|
import { mcpCallTool, FLEET_BOARD_MCP_URL } from "@/app/lib/fleet/fleetSource"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
/**
|
|
* GET /api/fleet/attention — strukturierte Attention-Fragen.
|
|
* Ruft attention_summary() im board-service: wie viele offene Tasks warten
|
|
* wirklich auf einen MENSCHEN (Frage + Optionen), nicht nur "offen".
|
|
*/
|
|
export async function GET() {
|
|
try {
|
|
const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "attention_summary", {})
|
|
if (!res.ok) {
|
|
return NextResponse.json({ error: `attention_summary: ${res.error}` }, { status: 500 })
|
|
}
|
|
const payload = typeof res.data === "string" ? JSON.parse(res.data) : res.data
|
|
return NextResponse.json(payload, { headers: { "Cache-Control": "no-store" } })
|
|
} catch (err) {
|
|
return NextResponse.json(
|
|
{ error: `ATTENTION_FAILED: ${err instanceof Error ? err.message : String(err)}` },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* POST /api/fleet/attention — Antwort des Owners auf eine Attention-Frage.
|
|
* Geht ueber board-service answer_attention: setzt attention.answer am Task
|
|
* und legt beim fragenden Agenten einen fyi-Reply-Task ab.
|
|
*/
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const body = (await request.json()) as { task_id?: string; answer?: string }
|
|
const task_id = String(body.task_id || "").trim()
|
|
const answer = String(body.answer || "").trim()
|
|
if (!task_id || !answer) {
|
|
return NextResponse.json({ error: "task_id und answer sind Pflicht" }, { status: 400 })
|
|
}
|
|
const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "answer_attention", { task_id, answer })
|
|
if (!res.ok) {
|
|
return NextResponse.json({ error: `answer_attention: ${res.error}` }, { status: 500 })
|
|
}
|
|
const payload = typeof res.data === "string" ? JSON.parse(res.data) : res.data
|
|
return NextResponse.json(payload, { headers: { "Cache-Control": "no-store" } })
|
|
} catch (err) {
|
|
return NextResponse.json(
|
|
{ error: `ATTENTION_ANSWER_FAILED: ${err instanceof Error ? err.message : String(err)}` },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|