|
|
@@ -238,9 +238,36 @@ async def _on_startup():
|
|
|
async def health():
|
|
|
return {"status": "ok", "version": "0.1.0"}
|
|
|
|
|
|
-# Serve built Web UI static files when webui-dist/ exists
|
|
|
-_WEBUI_DIST = os.path.join(os.path.dirname(__file__), "..", "..", "webui-dist")
|
|
|
-_WEBUI_DIST = os.path.normpath(_WEBUI_DIST)
|
|
|
+# Serve built Web UI static files when webui-dist/ exists.
|
|
|
+#
|
|
|
+# Path resolution broke during the Phase 1 src-layout migration (this file
|
|
|
+# moved from agentpaas/api/app.py to agentpaas/src/agentpaas/api/app.py,
|
|
|
+# adding one directory level — the old `../../webui-dist` started pointing
|
|
|
+# at agentpaas/src/webui-dist, which doesn't exist; caught by dogfooding,
|
|
|
+# not unit tests, since the import test only checks routes load). Resolve
|
|
|
+# robustly by probing a list of candidate locations:
|
|
|
+# 1. AGENTPAAS_WEBUI_DIST env (explicit override)
|
|
|
+# 2. /app/webui-dist (Docker layout — Dockerfile COPYs it there)
|
|
|
+# 3. <repo_root>/webui-dist (dev: 4 levels up from this file's dir)
|
|
|
+# 4. <cwd>/webui-dist (running from repo root)
|
|
|
+def _resolve_webui_dist() -> str:
|
|
|
+ explicit = os.getenv("AGENTPAAS_WEBUI_DIST", "")
|
|
|
+ here = os.path.dirname(os.path.abspath(__file__))
|
|
|
+ candidates = [
|
|
|
+ explicit,
|
|
|
+ "/app/webui-dist",
|
|
|
+ # agentpaas/src/agentpaas/api -> up 4 -> repo root
|
|
|
+ os.path.normpath(os.path.join(here, "..", "..", "..", "..", "webui-dist")),
|
|
|
+ os.path.normpath(os.path.join(os.getcwd(), "webui-dist")),
|
|
|
+ ]
|
|
|
+ for c in candidates:
|
|
|
+ if c and os.path.isdir(c):
|
|
|
+ return c
|
|
|
+ # Return the dev default even if missing, so the `else` branch logs it.
|
|
|
+ return os.path.normpath(os.path.join(here, "..", "..", "..", "..", "webui-dist"))
|
|
|
+
|
|
|
+
|
|
|
+_WEBUI_DIST = _resolve_webui_dist()
|
|
|
|
|
|
if os.path.isdir(_WEBUI_DIST):
|
|
|
app.mount("/assets", StaticFiles(directory=os.path.join(_WEBUI_DIST, "assets")), name="assets")
|