Add offline analysis and client event tracking to Assistent API

- Introduced `/assistent/analyze-reply` endpoint for offline extraction of patches and client predictions without VRAM.
- Added `/assistent/client-event` and `/assistent/client-events` endpoints for tracking UI interactions and retrieving event history.
- Updated Debug API documentation to reflect new endpoints and their functionalities.
- Enhanced Assistent session handling with improved client prediction logic and diagnostics.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-23 15:18:39 +03:00
co-authored by Cursor
parent 1d431e3a05
commit 322577cf9f
8 changed files with 529 additions and 34 deletions
+42
View File
@@ -145,7 +145,49 @@ def test_debug_server_routes(monkeypatch, tmp_path):
assert "/assistent/extension" in data["paths"]
assert "/assistent/api" in data["paths"]
assert "/assistent/chat-eval" in data["paths"]
assert "/assistent/analyze-reply" in data["paths"]
assert "post" in data["paths"]["/assistent/chat-eval"]
assert "post" in data["paths"]["/assistent/analyze-reply"]
req = urllib.request.Request(
f"http://127.0.0.1:{port}/assistent/analyze-reply",
data=json.dumps(
{
"message": "а ты знаешь какие то промпты с civitai",
"reply": '```json\n{"prompt":"x","generate":true}\n```',
"persona": "neutral",
}
).encode("utf-8"),
headers={"Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(req, timeout=5) as resp:
scored = json.loads(resp.read().decode("utf-8"))
assert scored["ok"] is True
assert scored["client"]["would_generate"] is False
assert scored["client"]["user_asks_generate"] is False
assert scored["client"]["model_generate"] is True
assert scored["client"]["persona_chip"] == "Нормальный"
beacon = urllib.request.Request(
f"http://127.0.0.1:{port}/assistent/client-event",
data=json.dumps(
{
"user": "а ты знаешь какие то промпты с civitai",
"generating": False,
"intent": {"generate": False, "modelAsked": True},
"swarm_prompt": "old prompt",
}
).encode("utf-8"),
headers={"Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(beacon, timeout=5) as resp:
stored = json.loads(resp.read().decode("utf-8"))
assert stored["ok"] is True
code, data = get("/assistent/client-events")
assert data["ok"] is True
assert data["events"][-1]["generating"] is False
code, data = get("/assistent/chat-eval")
assert "ok" in data