kumarabhirup 912e7711bb
fix tests, add telemetry, deploy v2.0.4
- Fix bootstrap-command test: mock ensureManagedWebRuntime to probe
  directly instead of requiring standalone build on disk
- Add PostHog telemetry to CLI and web app with opt-out support
- Add dench alias package (npm rejects name; kept for future use)
- Bump version to 2.0.4 and publish to npm
2026-03-04 17:33:27 -08:00

33 lines
1.0 KiB
TypeScript

/**
* POST /api/chat/stop
*
* Abort an active agent run. Called by the Stop button.
* Works for both parent sessions (by sessionId) and subagent sessions (by sessionKey).
*/
import { abortRun, getActiveRun } from "@/lib/active-runs";
import { trackServer } from "@/lib/telemetry";
export const runtime = "nodejs";
export async function POST(req: Request) {
const body: { sessionId?: string; sessionKey?: string } = await req
.json()
.catch(() => ({}));
const isSubagentSession = typeof body.sessionKey === "string" && body.sessionKey.includes(":subagent:");
const runKey = isSubagentSession && body.sessionKey ? body.sessionKey : body.sessionId;
if (!runKey) {
return new Response("sessionId or subagent sessionKey required", { status: 400 });
}
const run = getActiveRun(runKey);
const canAbort =
run?.status === "running" || run?.status === "waiting-for-subagents";
const aborted = canAbort ? abortRun(runKey) : false;
if (aborted) {
trackServer("chat_stopped");
}
return Response.json({ aborted });
}