Intelligence
Artifacts
Browse the repository, read documents, and manage the governance folders. Source, runtime, and infrastructure are read-only.
Repository
repositories/aaf-holdings/hq01/app/api/sessions/[id]/stop/route.ts
850 B
import { NextResponse } from "next/server";
import { stopSession, SessionError } from "@/lib/sessions/manager";
/**
* Stop endpoint.
*
* POST /api/sessions/:id/stop → gracefully terminate the session process
* (SIGTERM, escalating to SIGKILL) and update its recorded state.
*/
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function POST(
_request: Request,
{ params }: { params: { id: string } },
) {
try {
const session = await stopSession(params.id);
return NextResponse.json({ session });
} catch (err) {
if (err instanceof SessionError) {
return NextResponse.json({ error: err.message }, { status: err.status });
}
const message = err instanceof Error ? err.message : "Unknown error";
return NextResponse.json({ error: message }, { status: 500 });
}
}
root · /srv/aaf