@danhachuel/leadmaster 0.1.9 → 0.1.11

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.
Files changed (25) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +1 -1
  3. package/backend/__pycache__/main.cpython-311.pyc +0 -0
  4. package/backend/main.py +46 -14
  5. package/backend/services/__pycache__/__init__.cpython-311.pyc +0 -0
  6. package/backend/services/__pycache__/agents.cpython-311.pyc +0 -0
  7. package/backend/services/__pycache__/crm_agent.cpython-311.pyc +0 -0
  8. package/backend/services/__pycache__/extractors.cpython-311.pyc +0 -0
  9. package/backend/services/__pycache__/flags.cpython-311.pyc +0 -0
  10. package/backend/services/__pycache__/llm.cpython-311.pyc +0 -0
  11. package/backend/services/__pycache__/storage.cpython-311.pyc +0 -0
  12. package/backend/services/extractors.py +47 -0
  13. package/backend/services/storage.py +5 -2
  14. package/backend/tests/__pycache__/conftest.cpython-311-pytest-8.4.2.pyc +0 -0
  15. package/backend/tests/__pycache__/test_crm_routes.cpython-311-pytest-8.4.2.pyc +0 -0
  16. package/backend/tests/__pycache__/test_launcher_protections.cpython-311-pytest-8.4.2.pyc +0 -0
  17. package/backend/tests/__pycache__/test_maps_extractor.cpython-311-pytest-8.4.2.pyc +0 -0
  18. package/backend/tests/__pycache__/test_process_flags.cpython-311-pytest-8.4.2.pyc +0 -0
  19. package/backend/tests/test_launcher_protections.py +41 -3
  20. package/backend/tests/test_maps_extractor.py +45 -0
  21. package/frontend/dist/assets/{index-DVFFIa5O.css → index-D53_Dmef.css} +1 -1
  22. package/frontend/dist/assets/{index-ZsRPRMCF.js → index-lA_S1NDH.js} +18 -18
  23. package/frontend/dist/index.html +2 -2
  24. package/package.json +1 -1
  25. package/scripts/cli.mjs +47 -2
@@ -5,8 +5,8 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>LeadMaster — Painel</title>
8
- <script type="module" crossorigin src="/assets/index-ZsRPRMCF.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-DVFFIa5O.css">
8
+ <script type="module" crossorigin src="/assets/index-lA_S1NDH.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/index-D53_Dmef.css">
10
10
  </head>
11
11
  <body class="bg-gray-100 min-h-screen">
12
12
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/leadmaster",
3
- "version": "0.1.09",
3
+ "version": "0.1.11",
4
4
  "description": "SaaS local de prospecção e automação: CRM, extratores de leads e agentes de IA — 100% local.",
5
5
  "license": "MIT",
6
6
  "author": "Dan Hachuel",
package/scripts/cli.mjs CHANGED
@@ -30,6 +30,21 @@ import path from 'node:path';
30
30
  import { fileURLToPath } from 'node:url';
31
31
  import http from 'node:http';
32
32
 
33
+ // ---------------------------------------------------------------------------
34
+ // Erros globais (blindagem anti-encerramento silencioso)
35
+ // Rejeições e exceções não tratadas são APENAS LOGADAS — nunca devem derrubar
36
+ // o launcher sem explicação (era assim que o MobaXterm perdia o processo sem
37
+ // deixar rastro). O launcher só termina pelo fluxo normal: erro acionável,
38
+ // parada legítima (SIGTERM/SIGBREAK) ou morte do servidor Python filho.
39
+ // NUNCA REMOVER (regra inviolável do AGENTS.md).
40
+ // ---------------------------------------------------------------------------
41
+ process.on('unhandledRejection', (reason) => {
42
+ console.error('Unhandled Rejection:', reason);
43
+ });
44
+ process.on('uncaughtException', (err) => {
45
+ console.error('Uncaught Exception:', err);
46
+ });
47
+
33
48
  const PKG_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
34
49
 
35
50
  // Porta padrão da UI/API local; se estiver ocupada, o launcher avança
@@ -372,6 +387,10 @@ function cmdStart(args) {
372
387
  const url = `http://127.0.0.1:${porta}`;
373
388
  if (jaRodando) {
374
389
  console.log(`ℹ LeadMaster já está rodando em ${url} — abra o endereço no navegador.`);
390
+ // Saída INFORMATIVA (antes de qualquer inicialização própria): não há
391
+ // servidor filho para supervisionar nem terminal para prender — o
392
+ // launcher não deve chamar process.exit(0) no caminho de SUCESSO da
393
+ // inicialização (regra inviolável do AGENTS.md).
375
394
  process.exit(0);
376
395
  return;
377
396
  }
@@ -438,6 +457,14 @@ function cmdStart(args) {
438
457
  process.exit(code === null ? 1 : code);
439
458
  });
440
459
 
460
+ // Ciclo de vida vinculado (regra inviolável do AGENTS.md): se o Python
461
+ // cai, o launcher cai junto — nunca fica preso ao terminal sem servidor.
462
+ // O worker NUNCA é criado com .unref(): o pai não pode morrer sozinho.
463
+ child.on('close', (code) => {
464
+ console.log('Servidor encerrado');
465
+ process.exit(code === null ? 1 : code);
466
+ });
467
+
441
468
  const stop = () => {
442
469
  console.log('\nEncerrando LeadMaster...');
443
470
  if (platform() === 'win32' && child.pid) {
@@ -447,6 +474,16 @@ function cmdStart(args) {
447
474
  }
448
475
  };
449
476
 
477
+ // Morte do launcher → morte do filho (e vice-versa, via close acima):
478
+ // o uvicorn nunca fica órfão no terminal quando o Node é encerrado.
479
+ process.on('exit', () => {
480
+ try {
481
+ child.kill('SIGTERM');
482
+ } catch {
483
+ /* filho já encerrou — nada a fazer */
484
+ }
485
+ });
486
+
450
487
  console.log(`→ Subindo servidor local em ${url} ...`);
451
488
  const health = await waitForHealth(porta, 120000);
452
489
  if (!health) {
@@ -476,10 +513,18 @@ function cmdStart(args) {
476
513
  process.on('SIGBREAK', naoAbsorver);
477
514
  }
478
515
 
479
- // Keep-alive: mantém o event loop ativo mesmo sem I/O de console (MobaXterm
480
- // minimizado / sem stream ativo) — evita o encerramento silencioso.
516
+ // Keep-alive (regra inviolável do AGENTS.md): mantém o event loop ativo
517
+ // mesmo sem I/O de console (MobaXterm minimizado / sem stream ativo).
481
518
  setInterval(() => {}, 1000);
482
519
 
520
+ // Terminal preso (regra inviolável do AGENTS.md) — SOLUÇÃO DEFINITIVA:
521
+ // ao retomar a entrada padrão IMEDIATAMENTE antes das mensagens finais
522
+ // de sucesso, o Node permanece vivo indefinidamente aguardando qualquer
523
+ // digitação do usuário. O prompt do MobaXterm NUNCA é devolvido e a PTY
524
+ // (e com ela o uvicorn) não é fechada. Esta linha NÃO depende de timers
525
+ // nem de npx — NUNCA REMOVER.
526
+ process.stdin.resume();
527
+
483
528
  console.log(`✓ LeadMaster no ar em ${url} (dados: ${home})`);
484
529
  console.log('');
485
530
  console.log(`ℹ Abra ${url} no navegador quando quiser — o LeadMaster nunca abre janelas sozinho.`);