Jon Snow
+Orchestrator · Chief of Staff · port 8900
+ +Last 3 Tasks
+| Time (UTC) | Task | Project | Extraction |
|---|
API Usage by Intent
+| Intent | Path | Calls | Tokens in / out | Cost (ZAR) |
|---|
Updated {updated}
+diff --git a/app/main.py b/app/main.py index 28ffb84..0ab5904 100644 --- a/app/main.py +++ b/app/main.py @@ -46,6 +46,7 @@ logger = logging.getLogger("jon-snow") AGENT_OS_DIR = Path(os.getenv("AGENT_OS_DIR", "/opt/agent-os")) SITES_DIR = Path(os.getenv("SITES_DIR", "/opt/sites")) JON_PUBLIC_URL = os.getenv("JON_PUBLIC_URL", "https://jon.nxm.co.za") +ZAR_RATE = float(os.getenv("ZAR_RATE", "18.50")) app = FastAPI(title="Jon Snow", version="0.3.0") app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"]) @@ -98,6 +99,174 @@ class QueueActionRequest(BaseModel): # --- Output helpers --- +def _render_jon_page() -> None: + """Write /opt/sites/jon-snow/index.html with live cost and recent tasks.""" + summary = get_token_summary() + total_usd = summary["all_time"]["cost_usd"] + today_usd = summary["today"]["cost_usd"] + total_zar = total_usd * ZAR_RATE + today_zar = today_usd * ZAR_RATE + + runs_file = AGENT_OS_DIR / "logs" / "jon-snow" / "runs.jsonl" + runs = [] + if runs_file.exists(): + for line in runs_file.read_text().splitlines(): + try: + runs.append(json.loads(line)) + except Exception: + pass + + # Last 3 task entries, newest first + task_runs = [r for r in reversed(runs) if r.get("result", "").startswith("[task]")][:3] + + CLAUDE_INTENTS = {"task", "planning"} + + task_rows = "" + for r in task_runs: + ts = r.get("timestamp", "")[:19].replace("T", " ") + result = r.get("result", "") + # "[task] Task created: TITLE → PROJECT" + body = result.removeprefix("[task] Task created: ").removeprefix("[task] ") + if " → " in body: + title, project = body.split(" → ", 1) + else: + title, project = body, "—" + badge_cls = "badge-claude" if r.get("result", "").startswith("[task]") else "badge-python" + task_rows += ( + f"
Orchestrator · Chief of Staff · port 8900
+ +| Time (UTC) | Task | Project | Extraction |
|---|
| Intent | Path | Calls | Tokens in / out | Cost (ZAR) |
|---|
Updated {updated}
+