Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -374,6 +374,21 @@ async def api_health():
|
|
| 374 |
conn=get_db(); n=conn.execute("SELECT COUNT(*) FROM traces").fetchone()[0]; conn.close()
|
| 375 |
return JSONResponse({"ok":True,"total_traces":n,"retain_days":RETAIN_DAYS})
|
| 376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
@app.get("/mcp/sse")
|
| 378 |
async def mcp_sse(request:Request):
|
| 379 |
async def gen():
|
|
|
|
| 374 |
conn=get_db(); n=conn.execute("SELECT COUNT(*) FROM traces").fetchone()[0]; conn.close()
|
| 375 |
return JSONResponse({"ok":True,"total_traces":n,"retain_days":RETAIN_DAYS})
|
| 376 |
|
| 377 |
+
@app.delete("/api/traces/delete_person")
|
| 378 |
+
async def delete_person_traces(person_id: str):
|
| 379 |
+
conn = get_db()
|
| 380 |
+
# Scrub person_id from payload JSON rather than full delete
|
| 381 |
+
rows = conn.execute("SELECT id, payload FROM traces").fetchall()
|
| 382 |
+
scrubbed = 0
|
| 383 |
+
for row in rows:
|
| 384 |
+
p = row["payload"] or ""
|
| 385 |
+
if person_id in p:
|
| 386 |
+
new_p = p.replace(person_id, "[ERASED]")
|
| 387 |
+
conn.execute("UPDATE traces SET payload=? WHERE id=?", (new_p, row["id"]))
|
| 388 |
+
scrubbed += 1
|
| 389 |
+
conn.commit()
|
| 390 |
+
return JSONResponse({"scrubbed": scrubbed})
|
| 391 |
+
|
| 392 |
@app.get("/mcp/sse")
|
| 393 |
async def mcp_sse(request:Request):
|
| 394 |
async def gen():
|