abstractgateway 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. abstractgateway/__init__.py +1 -2
  2. abstractgateway/__main__.py +7 -0
  3. abstractgateway/app.py +4 -4
  4. abstractgateway/cli.py +568 -8
  5. abstractgateway/config.py +15 -5
  6. abstractgateway/embeddings_config.py +45 -0
  7. abstractgateway/host_metrics.py +274 -0
  8. abstractgateway/hosts/bundle_host.py +528 -55
  9. abstractgateway/hosts/visualflow_host.py +30 -3
  10. abstractgateway/integrations/__init__.py +2 -0
  11. abstractgateway/integrations/email_bridge.py +782 -0
  12. abstractgateway/integrations/telegram_bridge.py +534 -0
  13. abstractgateway/maintenance/__init__.py +5 -0
  14. abstractgateway/maintenance/action_tokens.py +100 -0
  15. abstractgateway/maintenance/backlog_exec_runner.py +1592 -0
  16. abstractgateway/maintenance/backlog_parser.py +184 -0
  17. abstractgateway/maintenance/draft_generator.py +451 -0
  18. abstractgateway/maintenance/llm_assist.py +212 -0
  19. abstractgateway/maintenance/notifier.py +109 -0
  20. abstractgateway/maintenance/process_manager.py +1064 -0
  21. abstractgateway/maintenance/report_models.py +81 -0
  22. abstractgateway/maintenance/report_parser.py +219 -0
  23. abstractgateway/maintenance/text_similarity.py +123 -0
  24. abstractgateway/maintenance/triage.py +507 -0
  25. abstractgateway/maintenance/triage_queue.py +142 -0
  26. abstractgateway/migrate.py +155 -0
  27. abstractgateway/routes/__init__.py +2 -2
  28. abstractgateway/routes/gateway.py +10817 -179
  29. abstractgateway/routes/triage.py +118 -0
  30. abstractgateway/runner.py +689 -14
  31. abstractgateway/security/gateway_security.py +425 -110
  32. abstractgateway/service.py +213 -6
  33. abstractgateway/stores.py +64 -4
  34. abstractgateway/workflow_deprecations.py +225 -0
  35. abstractgateway-0.1.1.dist-info/METADATA +135 -0
  36. abstractgateway-0.1.1.dist-info/RECORD +40 -0
  37. abstractgateway-0.1.0.dist-info/METADATA +0 -101
  38. abstractgateway-0.1.0.dist-info/RECORD +0 -18
  39. {abstractgateway-0.1.0.dist-info → abstractgateway-0.1.1.dist-info}/WHEEL +0 -0
  40. {abstractgateway-0.1.0.dist-info → abstractgateway-0.1.1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,118 @@
1
+ from __future__ import annotations
2
+
3
+ import html
4
+ import os
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+ from fastapi import APIRouter, HTTPException, Request
9
+ from fastapi.responses import HTMLResponse
10
+
11
+ from ..maintenance.action_tokens import verify_action_token
12
+ from ..maintenance.triage import apply_decision_action
13
+
14
+
15
+ router = APIRouter(prefix="/triage")
16
+
17
+
18
+ def _env(name: str, fallback: Optional[str] = None) -> Optional[str]:
19
+ v = os.getenv(name)
20
+ if v is not None and str(v).strip():
21
+ return str(v).strip()
22
+ if fallback:
23
+ v2 = os.getenv(fallback)
24
+ if v2 is not None and str(v2).strip():
25
+ return str(v2).strip()
26
+ return None
27
+
28
+
29
+ def _action_secret() -> str:
30
+ return str(_env("ABSTRACTGATEWAY_TRIAGE_ACTION_SECRET", "ABSTRACT_TRIAGE_ACTION_SECRET") or "").strip()
31
+
32
+
33
+ @router.get("/action/{token}", response_class=HTMLResponse)
34
+ async def triage_action_preview(token: str):
35
+ secret = _action_secret()
36
+ if not secret:
37
+ raise HTTPException(status_code=503, detail="Triage action links are disabled (missing TRIAGE_ACTION_SECRET)")
38
+
39
+ payload, err = verify_action_token(token=token, secret=secret)
40
+ if err:
41
+ raise HTTPException(status_code=401, detail=err)
42
+ decision_id = str(payload.get("decision_id") or "").strip()
43
+ action = str(payload.get("action") or "").strip()
44
+ days = payload.get("days")
45
+ days_s = f"{days}d" if isinstance(days, int) else ""
46
+
47
+ safe_action = html.escape(action)
48
+ safe_decision = html.escape(decision_id)
49
+
50
+ return HTMLResponse(
51
+ content=(
52
+ "<html><head><title>Triage Action</title>"
53
+ "<meta name=\"robots\" content=\"noindex,nofollow\"/>"
54
+ "</head><body style=\"font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; max-width: 900px; margin: 40px auto;\">"
55
+ "<h2>Confirm triage action</h2>"
56
+ f"<p><b>Decision</b>: <code>{safe_decision}</code></p>"
57
+ f"<p><b>Action</b>: <code>{safe_action}</code> {html.escape(days_s)}</p>"
58
+ "<p>This page exists to avoid accidental activation by link previews.</p>"
59
+ f"<form method=\"post\" action=\"/api/triage/action/{html.escape(token)}\">"
60
+ "<button type=\"submit\" style=\"padding: 10px 14px;\">Confirm</button>"
61
+ "</form>"
62
+ "</body></html>"
63
+ )
64
+ )
65
+
66
+
67
+ @router.post("/action/{token}", response_class=HTMLResponse)
68
+ async def triage_action_apply(token: str, request: Request):
69
+ del request
70
+ secret = _action_secret()
71
+ if not secret:
72
+ raise HTTPException(status_code=503, detail="Triage action links are disabled (missing TRIAGE_ACTION_SECRET)")
73
+
74
+ payload, err = verify_action_token(token=token, secret=secret)
75
+ if err:
76
+ raise HTTPException(status_code=401, detail=err)
77
+
78
+ decision_id = str(payload.get("decision_id") or "").strip()
79
+ action = str(payload.get("action") or "").strip().lower()
80
+ days = payload.get("days")
81
+ defer_days = int(days) if isinstance(days, int) and days > 0 else None
82
+
83
+ data_dir = Path(os.getenv("ABSTRACTGATEWAY_DATA_DIR", "./runtime/gateway")).expanduser().resolve()
84
+ repo_root_raw = _env("ABSTRACT_TRIAGE_REPO_ROOT", "ABSTRACTGATEWAY_TRIAGE_REPO_ROOT")
85
+ repo_root = Path(repo_root_raw).expanduser().resolve() if repo_root_raw else None
86
+
87
+ decision, err2 = apply_decision_action(
88
+ gateway_data_dir=data_dir,
89
+ decision_id=decision_id,
90
+ action=action,
91
+ repo_root=repo_root,
92
+ defer_days=defer_days,
93
+ )
94
+ if err2:
95
+ safe = html.escape(err2)
96
+ return HTMLResponse(
97
+ content=f"<html><body><h3>Failed</h3><pre>{safe}</pre></body></html>",
98
+ status_code=400,
99
+ )
100
+
101
+ safe_status = html.escape(decision.status if decision else "unknown")
102
+ safe_decision = html.escape(decision_id)
103
+ safe_draft = html.escape(decision.draft_relpath if decision and decision.draft_relpath else "")
104
+ draft_line = f"<p><b>Draft</b>: <code>{safe_draft}</code></p>" if safe_draft else ""
105
+
106
+ return HTMLResponse(
107
+ content=(
108
+ "<html><head><title>Triage Applied</title>"
109
+ "<meta name=\"robots\" content=\"noindex,nofollow\"/>"
110
+ "</head><body style=\"font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; max-width: 900px; margin: 40px auto;\">"
111
+ "<h2>Triage action applied</h2>"
112
+ f"<p><b>Decision</b>: <code>{safe_decision}</code></p>"
113
+ f"<p><b>Status</b>: <code>{safe_status}</code></p>"
114
+ f"{draft_line}"
115
+ "</body></html>"
116
+ )
117
+ )
118
+