ocerebro 0.4.13 → 0.4.15
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 +1 -1
- package/src/dashboard/static/index.html +1 -1
- package/src/mcp/server.py +48 -66
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>🧠 OCerebro Dashboard</title>
|
|
7
|
-
<link rel="stylesheet" href="style.css">
|
|
7
|
+
<link rel="stylesheet" href="static/style.css">
|
|
8
8
|
<!-- Cytoscape.js -->
|
|
9
9
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.28.1/cytoscape.min.js"></script>
|
|
10
10
|
<!-- Chart.js -->
|
package/src/mcp/server.py
CHANGED
|
@@ -932,75 +932,57 @@ Uma chamada por memória. O sistema salva e indexa automaticamente.
|
|
|
932
932
|
|
|
933
933
|
port = args.get("port", 7999)
|
|
934
934
|
|
|
935
|
-
#
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
sock.settimeout(1)
|
|
939
|
-
result = sock.connect_ex(('127.0.0.1', port))
|
|
940
|
-
sock.close()
|
|
941
|
-
is_running = result == 0
|
|
942
|
-
|
|
943
|
-
if is_running:
|
|
944
|
-
# Verifica se o servidor está usando o cerebro_path correto
|
|
935
|
+
# SEMPRE mata o processo antigo e reinicia - garante cerebro_path correto
|
|
936
|
+
pid_file = Path.home() / ".ocerebro_dashboard.pid"
|
|
937
|
+
if pid_file.exists():
|
|
945
938
|
try:
|
|
946
|
-
|
|
947
|
-
import
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
if running_path != current_path:
|
|
956
|
-
# Path diferente - precisa reiniciar o servidor
|
|
957
|
-
# Lê o PID e mata o processo antigo
|
|
958
|
-
pid_file = Path.home() / ".ocerebro_dashboard.pid"
|
|
959
|
-
if pid_file.exists():
|
|
960
|
-
try:
|
|
961
|
-
old_pid = int(pid_file.read_text(encoding="utf-8").strip())
|
|
962
|
-
import os
|
|
963
|
-
# WINDOWS FIX: usa taskkill no Windows
|
|
964
|
-
if sys.platform == "win32":
|
|
965
|
-
import subprocess
|
|
966
|
-
subprocess.call(["taskkill", "/F", "/PID", str(old_pid)])
|
|
967
|
-
else:
|
|
968
|
-
os.kill(old_pid, 9) # SIGKILL
|
|
969
|
-
pid_file.unlink() # Remove o arquivo PID
|
|
970
|
-
except Exception:
|
|
971
|
-
pass # Processo já morreu ou erro ao matar
|
|
972
|
-
|
|
973
|
-
# Agora is_running será False e vamos reiniciar abaixo
|
|
974
|
-
is_running = False
|
|
939
|
+
old_pid = int(pid_file.read_text(encoding="utf-8").strip())
|
|
940
|
+
import os
|
|
941
|
+
# WINDOWS FIX: usa taskkill no Windows
|
|
942
|
+
if sys.platform == "win32":
|
|
943
|
+
subprocess.call(["taskkill", "/F", "/PID", str(old_pid)],
|
|
944
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
945
|
+
else:
|
|
946
|
+
os.kill(old_pid, 9) # SIGKILL
|
|
947
|
+
pid_file.unlink() # Remove o arquivo PID
|
|
975
948
|
except Exception:
|
|
976
|
-
pass #
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
949
|
+
pass # Processo já morreu ou erro ao matar
|
|
950
|
+
|
|
951
|
+
# Aguarda porta liberar (até 2s)
|
|
952
|
+
import time
|
|
953
|
+
for _ in range(20):
|
|
954
|
+
time.sleep(0.1)
|
|
955
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
956
|
+
sock.settimeout(1)
|
|
957
|
+
result = sock.connect_ex(('127.0.0.1', port))
|
|
958
|
+
sock.close()
|
|
959
|
+
if result != 0:
|
|
960
|
+
break
|
|
961
|
+
|
|
962
|
+
# Inicia como processo separado (persiste após o MCP terminar)
|
|
963
|
+
server_script = Path(__file__).parent.parent / "dashboard" / "standalone_server.py"
|
|
964
|
+
if not server_script.exists():
|
|
965
|
+
return "⚠️ Erro: standalone_server.py não encontrado."
|
|
966
|
+
|
|
967
|
+
# Inicia processo em background
|
|
968
|
+
subprocess.Popen(
|
|
969
|
+
[sys.executable, str(server_script), str(port), str(self.cerebro_path.absolute())],
|
|
970
|
+
stdout=subprocess.DEVNULL,
|
|
971
|
+
stderr=subprocess.DEVNULL,
|
|
972
|
+
start_new_session=True # Desacoplado do processo pai
|
|
973
|
+
)
|
|
991
974
|
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
return "⚠️ Servidor não iniciou em 5 segundos."
|
|
975
|
+
# Aguarda servidor estar pronto (até 5s)
|
|
976
|
+
for _ in range(50):
|
|
977
|
+
time.sleep(0.1)
|
|
978
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
979
|
+
sock.settimeout(1)
|
|
980
|
+
result = sock.connect_ex(('127.0.0.1', port))
|
|
981
|
+
sock.close()
|
|
982
|
+
if result == 0:
|
|
983
|
+
break
|
|
984
|
+
else:
|
|
985
|
+
return "⚠️ Servidor não iniciou em 5 segundos."
|
|
1004
986
|
|
|
1005
987
|
# Abre browser
|
|
1006
988
|
import webbrowser
|