feat: orchestrator MVP — webhooks, agent launcher, QG checks

This commit is contained in:
Dev Agent
2026-05-19 15:57:00 +03:00
commit daf8cdad9e
19 changed files with 515 additions and 0 deletions

49
src/webhooks/plane.py Normal file
View File

@@ -0,0 +1,49 @@
from fastapi import APIRouter, Request
import json
from ..db import get_db
router = APIRouter()
@router.post("/plane")
async def plane_webhook(request: Request):
"""Handle Plane webhook events."""
body = await request.body()
payload = json.loads(body)
# Log event
conn = get_db()
conn.execute(
"INSERT INTO events (source, event_type, payload) VALUES (?, ?, ?)",
("plane", payload.get("event", "unknown"), body.decode()),
)
conn.commit()
event = payload.get("event")
data = payload.get("data", {})
if event == "work_item.created":
await handle_work_item_created(data, conn)
elif event == "comment.created":
await handle_comment(data, conn)
conn.close()
return {"status": "accepted"}
async def handle_work_item_created(data: dict, conn):
"""New work item -> create task record."""
plane_id = data.get("id", "")
conn.execute(
"INSERT INTO tasks (plane_id, repo, stage) VALUES (?, ?, ?)",
(plane_id, "enduro-trails", "analysis"),
)
conn.commit()
async def handle_comment(data: dict, conn):
"""Check for :approved: reaction -> advance stage."""
comment_body = data.get("comment", "")
if ":approved:" in comment_body:
# TODO: Determine which task, advance QG
pass