fleet(tower): 0.18 — Tasks-View (Spool/Dead-Letter/Alarm) + Task-Detail-Modal + /healthz + /api/status; Fleet-Views 0.13-0.18 erstmals versioniert

This commit is contained in:
Hermes CEO
2026-10-30 04:55:35 +00:00
parent fa3d5d0a8f
commit 9e94512214
33 changed files with 3498 additions and 3 deletions
+63
View File
@@ -0,0 +1,63 @@
import { NextResponse } from "next/server"
import { mcpCallTool, FLEET_BOARD_MCP_URL, readChatThreads } from "@/app/lib/fleet/fleetSource"
export const dynamic = "force-dynamic"
/**
* GET /api/fleet/owner/chat — Thread-Liste + Nachrichten (Kernfeature 5).
* POST /api/fleet/owner/chat — neue Owner-Nachricht in einen Thread via
* board-service submit_owner_task (type=chat, thread_id, topic) — der Tower
* schreibt NIE direkt in den Spool (Single-Writer-Disziplin via board-service).
* from=tower-owner, to=ceo; CEO-Antworten erscheinen als ceo->tower-owner?
* NEIN: to muss 9er-Org sein -> CEO-Antworten sind Tasks von ceo mit
* thread_id + reply_to; der Chat-View rendert alle type=chat-Tasks eines
* thread_id unabhaengig von from/to (solange from in 9er-Org oder tower-owner).
*/
export async function GET() {
try {
const threads = readChatThreads()
return NextResponse.json(
{ threads, count: threads.length },
{ headers: { "Cache-Control": "no-store" } }
)
} catch (err) {
return NextResponse.json(
{ error: `OWNER_CHAT_FAILED: ${err instanceof Error ? err.message : String(err)}` },
{ status: 500 }
)
}
}
export async function POST(request: Request) {
try {
const body = (await request.json()) as { thread_id?: string; topic?: string; message?: string }
const thread_id = String(body.thread_id || "").trim()
const topic = String(body.topic || "").trim()
const message = String(body.message || "").trim()
if (!thread_id || !message) {
return NextResponse.json({ error: "thread_id und message sind Pflicht" }, { status: 400 })
}
const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "submit_owner_task", {
to: "ceo",
type: "chat",
priority: "P3",
topic: topic || thread_id,
thread_id,
body: message,
requires_ack: false,
})
if (!res.ok) {
return NextResponse.json({ error: `submit_owner_task: ${res.error}` }, { status: 500 })
}
return NextResponse.json(res.data, { headers: { "Cache-Control": "no-store" } })
} catch (err) {
getErrLog(err)
}
}
function getErrLog(err: unknown) {
return NextResponse.json(
{ error: `OWNER_CHAT_POST_FAILED: ${err instanceof Error ? err.message : String(err)}` },
{ status: 500 }
)
}
+37
View File
@@ -0,0 +1,37 @@
import { NextResponse } from "next/server"
import { mcpCallTool, FLEET_BOARD_MCP_URL } from "@/app/lib/fleet/fleetSource"
export const dynamic = "force-dynamic"
/**
* POST /api/fleet/owner/decide — Owner-Entscheidung über einen NAR/Owner-Inbox-Task
* via board-service decide_owner_task (approve|decline). Der Tower schreibt nie
* direkt in den Spool — alles läuft über den board-service (Single-Writer).
* Response enthält folge_task (an den Antragsteller).
*/
export async function POST(request: Request) {
try {
const body = (await request.json()) as { task_id?: string; decision?: string; note?: string }
const task_id = String(body.task_id || "").trim()
const decision = String(body.decision || "").trim()
const note = String(body.note || "")
if (!task_id || !decision) {
return NextResponse.json({ error: "task_id und decision sind Pflicht" }, { status: 400 })
}
const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "decide_owner_task", {
task_id,
decision,
note,
})
if (!res.ok) {
return NextResponse.json({ error: `decide_owner_task: ${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: `OWNER_DECIDE_FAILED: ${err instanceof Error ? err.message : String(err)}` },
{ status: 500 }
)
}
}
+46
View File
@@ -0,0 +1,46 @@
import { NextResponse } from "next/server"
import { mcpCallTool, FLEET_BOARD_MCP_URL } from "@/app/lib/fleet/fleetSource"
export const dynamic = "force-dynamic"
/**
* POST /api/fleet/owner/idea — Owner-Idee -> board-service add_backlog_card
* (ursprung=owner, immer markiert). Kernfeature 5, E-V3: "Ideen -> VS-Backlog".
* Fail loud: unbekannte VS / ungueltige Werte -> 500 mit Klartext.
*/
export async function POST(request: Request) {
try {
const body = (await request.json()) as {
vs?: string
karte_id?: string
titel?: string
wert?: number
machbarkeit?: number
}
const vs = String(body.vs || "").trim()
const karte_id = String(body.karte_id || "").trim()
const titel = String(body.titel || "").trim()
const wert = Number(body.wert)
const machbarkeit = Number(body.machbarkeit)
if (!vs || !karte_id || !titel) {
return NextResponse.json({ error: "vs, karte_id und titel sind Pflicht" }, { status: 400 })
}
const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "add_backlog_card", {
vs,
karte_id,
titel,
wert,
machbarkeit,
ursprung: "owner",
})
if (!res.ok) {
return NextResponse.json({ error: `add_backlog_card: ${res.error}` }, { status: 500 })
}
return NextResponse.json(res.data, { headers: { "Cache-Control": "no-store" } })
} catch (err) {
return NextResponse.json(
{ error: `OWNER_IDEA_FAILED: ${err instanceof Error ? err.message : String(err)}` },
{ status: 500 }
)
}
}
+25
View File
@@ -0,0 +1,25 @@
import { NextResponse } from "next/server"
import { mcpCallTool, FLEET_BOARD_MCP_URL } from "@/app/lib/fleet/fleetSource"
export const dynamic = "force-dynamic"
/**
* GET /api/fleet/owner/inbox — Owner-Inbox (NAR-Verfahren §1.3):
* Alle Tasks an 'tower-owner' via board-service list_owner_inbox.
* status=submitted = wartet auf Owner-Entscheidung.
*/
export async function GET() {
try {
const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "list_owner_inbox", {})
if (!res.ok) {
return NextResponse.json({ error: `list_owner_inbox: ${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: `OWNER_INBOX_FAILED: ${err instanceof Error ? err.message : String(err)}` },
{ status: 500 }
)
}
}
+38
View File
@@ -0,0 +1,38 @@
import { NextResponse } from "next/server"
import { mcpCallTool, FLEET_BOARD_MCP_URL } from "@/app/lib/fleet/fleetSource"
export const dynamic = "force-dynamic"
/**
* POST /api/fleet/owner/new-vs — "Neuer Value Stream" -> CEO-Task (type=build, P2)
* via board-service submit_owner_task (neuer Tool, Phase 0.13). E-V3:
* Owner-Chat verdraengt nie den Task-Flow; VS-Gruendung ist ein formaler Task.
* Fail loud bei unbekanntem CEO oder Spool-Fehler.
*/
export async function POST(request: Request) {
try {
const body = (await request.json()) as { topic?: string; ziel?: string }
const topic = String(body.topic || "").trim()
const ziel = String(body.ziel || "").trim()
if (!topic || topic.length > 200) {
return NextResponse.json({ error: "topic Pflicht (max 200 Zeichen)" }, { status: 400 })
}
const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "submit_owner_task", {
to: "ceo",
type: "build",
priority: "P2",
topic,
body: ziel || topic,
requires_ack: true,
})
if (!res.ok) {
return NextResponse.json({ error: `submit_owner_task: ${res.error}` }, { status: 500 })
}
return NextResponse.json(res.data, { headers: { "Cache-Control": "no-store" } })
} catch (err) {
return NextResponse.json(
{ error: `OWNER_NEW_VS_FAILED: ${err instanceof Error ? err.message : String(err)}` },
{ status: 500 }
)
}
}