ocerebro 0.4.7 → 0.4.8
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.
- package/package.json +1 -1
- package/pyproject.toml +4 -1
- package/src/dashboard/server.py +15 -5
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ocerebro"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.8"
|
|
8
8
|
description = "OCerebro - Sistema de Memoria para Agentes (Claude Code/MCP)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -72,6 +72,9 @@ ocerebro-setup = "cerebro.cerebro_setup:main"
|
|
|
72
72
|
where = ["."]
|
|
73
73
|
include = ["src*", "cerebro*"]
|
|
74
74
|
|
|
75
|
+
[tool.setuptools.package-data]
|
|
76
|
+
"src.dashboard" = ["static/*", "static/**/*"]
|
|
77
|
+
|
|
75
78
|
[tool.pytest.ini_options]
|
|
76
79
|
testpaths = ["tests"]
|
|
77
80
|
python_files = "test_*.py"
|
package/src/dashboard/server.py
CHANGED
|
@@ -5,6 +5,7 @@ import threading
|
|
|
5
5
|
import webbrowser
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from typing import Any, Optional
|
|
8
|
+
import importlib.resources
|
|
8
9
|
|
|
9
10
|
from fastapi import FastAPI
|
|
10
11
|
from fastapi.middleware.cors import CORSMiddleware
|
|
@@ -44,6 +45,16 @@ class DashboardServer:
|
|
|
44
45
|
self.embeddings_db = embeddings_db
|
|
45
46
|
self.entities_db = entities_db
|
|
46
47
|
|
|
48
|
+
# Usa importlib.resources para encontrar static files corretamente
|
|
49
|
+
# Funciona tanto em desenvolvimento quanto em pacote instalado
|
|
50
|
+
try:
|
|
51
|
+
# Python 3.9+
|
|
52
|
+
static_path = importlib.resources.files("src.dashboard") / "static"
|
|
53
|
+
self._static_path = Path(str(static_path))
|
|
54
|
+
except AttributeError:
|
|
55
|
+
# Fallback para Python < 3.9
|
|
56
|
+
self._static_path = Path(__file__).parent / "static"
|
|
57
|
+
|
|
47
58
|
self.app = self._create_app()
|
|
48
59
|
self._server_thread: Optional[threading.Thread] = None
|
|
49
60
|
self._port: Optional[int] = None
|
|
@@ -66,9 +77,8 @@ class DashboardServer:
|
|
|
66
77
|
)
|
|
67
78
|
|
|
68
79
|
# Monta static files
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
app.mount("/static", StaticFiles(directory=str(static_path)), name="static")
|
|
80
|
+
if self._static_path.exists():
|
|
81
|
+
app.mount("/static", StaticFiles(directory=str(self._static_path)), name="static")
|
|
72
82
|
|
|
73
83
|
# Monta API router
|
|
74
84
|
from src.dashboard.api import create_router
|
|
@@ -84,10 +94,10 @@ class DashboardServer:
|
|
|
84
94
|
@app.get("/")
|
|
85
95
|
async def root():
|
|
86
96
|
from fastapi.responses import FileResponse
|
|
87
|
-
index_path =
|
|
97
|
+
index_path = self._static_path / "index.html"
|
|
88
98
|
if index_path.exists():
|
|
89
99
|
return FileResponse(str(index_path))
|
|
90
|
-
return {"error": "index.html not found"}
|
|
100
|
+
return {"error": "index.html not found", "path": str(index_path)}
|
|
91
101
|
|
|
92
102
|
return app
|
|
93
103
|
|