peppa/apps/web/app/api/hooks/gitea/route.ts
Асель 14916079bc PEP-5/43/47/48: usage and limits, story budgets, factory metrics, audit journal
- PEP-5: statusLine hook (cost, context, 5h/7d limit windows), transcript tokens,
  sessions.usage, usage strip over every page, runner usage, bot /status, MCP get_usage
- PEP-43: project/story budgets in settings, watchdog pause (Escape, question to the PM:
  extend x2 / remove limit / stop), start/resume guard, budget on the story card
- PEP-47: project metrics tab (cycle time, first pass, review returns, questions, runner
  hours, PM wait, limits, spend by week/agent/epic), MCP get_metrics
- PEP-48: event authors (actor columns, AsyncLocalStorage context), question_answered,
  /journal for superadmins, project journal tab, authors in the story feed
- Migration 0007_usage_audit; OpenSpec changes archived

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:52:13 +05:00

22 lines
787 B
TypeScript

import { enterActor } from "@peppa/core";
import { handleGiteaHook } from "@peppa/runner";
import { db } from "@/lib/db";
export const dynamic = "force-dynamic";
/**
* Gitea webhooks and CI step reports of project repos (PEP-57). No login: each request is
* signed (X-Gitea-Signature, HMAC-SHA256 of the body) with the project's secret.
*/
export async function POST(req: Request) {
// PEP-48: CI results and Gitea events act as Peppa itself.
enterActor({ kind: "system", channel: "gitea" });
const body = await req.text();
const r = await handleGiteaHook(db, {
event: req.headers.get("x-peppa-event") ?? req.headers.get("x-gitea-event") ?? "",
signature: req.headers.get("x-gitea-signature"),
body,
});
return Response.json(r.body, { status: r.status });
}