ocerebro 0.4.2 → 0.4.4

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.
@@ -268,6 +268,16 @@ Se confirmar, chame novamente com dry_run=false.
268
268
  """, encoding="utf-8")
269
269
  print(f"[OK] Slash command criado: {remember_cmd}")
270
270
 
271
+ dashboard_cmd = commands_dir / "cerebro-dashboard.md"
272
+ if not dashboard_cmd.exists():
273
+ dashboard_cmd.write_text("""---
274
+ description: Abrir dashboard visual do OCerebro
275
+ ---
276
+ Use a ferramenta cerebro_dashboard com port=7999.
277
+ Após abrir, confirme ao usuário a URL http://localhost:7999 onde o dashboard está disponível.
278
+ """, encoding="utf-8")
279
+ print(f"[OK] Slash command criado: {dashboard_cmd}")
280
+
271
281
  # Slash commands globais em ~/.claude/commands/
272
282
  if global_commands:
273
283
  global_commands_dir = Path.home() / ".claude" / "commands"
@@ -347,6 +357,16 @@ Se confirmar, chame novamente com dry_run=false.
347
357
  """, encoding="utf-8")
348
358
  print(f"[OK] Slash command global criado: {remember_global}")
349
359
 
360
+ dashboard_global = global_commands_dir / "cerebro-dashboard.md"
361
+ if not dashboard_global.exists():
362
+ dashboard_global.write_text("""---
363
+ description: Abrir dashboard visual do OCerebro (global)
364
+ ---
365
+ Use a ferramenta cerebro_dashboard com port=7999.
366
+ Após abrir, confirme ao usuário a URL http://localhost:7999 onde o dashboard está disponível.
367
+ """, encoding="utf-8")
368
+ print(f"[OK] Slash command global criado: {dashboard_global}")
369
+
350
370
  return True
351
371
 
352
372
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocerebro",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "OCerebro - Sistema de Memoria para Agentes (Claude Code/MCP)",
5
5
  "main": "bin/ocerebro.js",
6
6
  "bin": {
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.2"
7
+ version = "0.4.4"
8
8
  description = "OCerebro - Sistema de Memoria para Agentes (Claude Code/MCP)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1,38 @@
1
+ """Servidor standalone do Dashboard do OCerebro - roda como processo separado"""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ # Adiciona project root ao path
7
+ project_root = Path(__file__).parent.parent.parent
8
+ sys.path.insert(0, str(project_root))
9
+
10
+ from src.dashboard.server import DashboardServer
11
+ from src.mcp.server import CerebroMCP
12
+
13
+ def main():
14
+ """Inicia o servidor standalone"""
15
+ port = int(sys.argv[1]) if len(sys.argv) > 1 else 7999
16
+
17
+ # Inicializa componentes
18
+ mcp = CerebroMCP()
19
+
20
+ dashboard = DashboardServer(
21
+ cerebro_path=mcp.cerebro_path,
22
+ metadata_db=mcp.metadata_db,
23
+ embeddings_db=mcp.embeddings_db,
24
+ entities_db=mcp.entities_db
25
+ )
26
+
27
+ if dashboard.start(port):
28
+ print(f"Dashboard rodando em http://localhost:{port}")
29
+ # Mantém vivo
30
+ import time
31
+ while True:
32
+ time.sleep(3600) # Dorme por 1 hora, loop infinito
33
+ else:
34
+ print(f"Falha ao iniciar dashboard na porta {port}")
35
+ sys.exit(1)
36
+
37
+ if __name__ == "__main__":
38
+ main()
package/src/mcp/server.py CHANGED
@@ -898,26 +898,50 @@ Uma chamada por memória. O sistema salva e indexa automaticamente.
898
898
  def _cerebro_dashboard(self, args: Dict[str, Any]) -> str:
899
899
  """Abre o dashboard visual do OCerebro no browser"""
900
900
  try:
901
- from src.dashboard.server import DashboardServer
901
+ import subprocess
902
+ import sys
902
903
 
903
904
  port = args.get("port", 7999)
904
905
 
905
- # Instancia servidor
906
- dashboard_server = DashboardServer(
907
- cerebro_path=self.cerebro_path,
908
- metadata_db=self.metadata_db,
909
- embeddings_db=self.embeddings_db,
910
- entities_db=self.entities_db
911
- )
906
+ # Verifica se já está rodando
907
+ import socket
908
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
909
+ sock.settimeout(1)
910
+ result = sock.connect_ex(('127.0.0.1', port))
911
+ sock.close()
912
+ is_running = result == 0
913
+
914
+ if not is_running:
915
+ # Inicia como processo separado (persiste após o MCP terminar)
916
+ server_script = Path(__file__).parent.parent / "dashboard" / "standalone_server.py"
917
+ if not server_script.exists():
918
+ return "⚠️ Erro: standalone_server.py não encontrado."
919
+
920
+ # Inicia processo em background
921
+ subprocess.Popen(
922
+ [sys.executable, str(server_script), str(port)],
923
+ cwd=str(Path(__file__).parent.parent.parent),
924
+ stdout=subprocess.DEVNULL,
925
+ stderr=subprocess.DEVNULL,
926
+ start_new_session=True # Desacoplado do processo pai
927
+ )
912
928
 
913
- # Inicia se não estiver rodando
914
- if not dashboard_server.is_running(port):
915
- started = dashboard_server.start(port)
916
- if not started:
917
- return "⚠️ Não foi possível iniciar o servidor do dashboard. Verifique se a porta está disponível."
929
+ # Aguarda servidor estar pronto (até 5s)
930
+ import time
931
+ for _ in range(50):
932
+ time.sleep(0.1)
933
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
934
+ sock.settimeout(1)
935
+ result = sock.connect_ex(('127.0.0.1', port))
936
+ sock.close()
937
+ if result == 0:
938
+ break
939
+ else:
940
+ return "⚠️ Servidor não iniciou em 5 segundos."
918
941
 
919
942
  # Abre browser
920
- dashboard_server.open_browser(port)
943
+ import webbrowser
944
+ webbrowser.open(f"http://localhost:{port}")
921
945
 
922
946
  return f"✅ Dashboard aberto em http://localhost:{port}"
923
947
  except ImportError as e: