agent-runtime/agent/__init__.py
Nico acc0dff4e5 v0.9.9: deterministic UI — Thinker declares actions, UI renders without LLM
- Thinker emits ACTIONS: JSON line with follow-up buttons
- UI node is now pure code (no LLM call) — renders actions as buttons,
  extracts tables from pipe-separated tool output, labels for single values
- Controls only in workspace panel, not duplicated in chat
- Process cards only in awareness panel, failed auto-remove after 30s
- Auth expiry detection: 403/1006 shows login button, stops reconnect loop
- Sensor timezone fix: zoneinfo.ZoneInfo("Europe/Berlin") for proper DST
- Cache-Control: no-cache on index.html
- Markdown rendering in chat messages

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 15:06:24 +01:00

41 lines
1.1 KiB
Python

"""Cognitive Agent Runtime — modular package.
uvicorn entrypoint: agent:app
"""
import logging
from pathlib import Path
from dotenv import load_dotenv
load_dotenv(Path(__file__).parent.parent / ".env")
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(name)s] %(message)s", datefmt="%H:%M:%S")
from fastapi import FastAPI
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
from starlette.responses import Response
from .api import register_routes
STATIC_DIR = Path(__file__).parent.parent / "static"
app = FastAPI(title="cog")
# Register all API + WS routes
register_routes(app)
# Serve index.html explicitly, then static assets
@app.get("/")
async def index():
resp = FileResponse(STATIC_DIR / "index.html")
resp.headers["Cache-Control"] = "no-cache"
return resp
@app.get("/callback")
async def callback():
"""OIDC callback — serves the same SPA, JS handles the code exchange."""
return FileResponse(STATIC_DIR / "index.html")
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")