@runflow-ai/cli 0.2.11 → 0.2.12

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/CLI-DOCS.md CHANGED
@@ -396,6 +396,95 @@ rf executions list
396
396
  rf traces list
397
397
  ```
398
398
 
399
+ ---
400
+
401
+ ## 🧪 Test (Local Testing)
402
+
403
+ Inicia servidor local de observabilidade e abre o portal cloud para testar agentes.
404
+
405
+ ```bash
406
+ rf test [options]
407
+ ```
408
+
409
+ **Opções:**
410
+ - `-p, --port <port>` - Porta base do servidor (default: aleatória entre 3000-4000)
411
+ - `--no-browser` - Não abre o navegador automaticamente
412
+
413
+ **Características:**
414
+ - ✅ Zero configuração - detecta `agentId` automaticamente do `.runflow/rf.json`
415
+ - ✅ Portas aleatórias - evita conflitos tentando até 3 portas
416
+ - ✅ Portal cloud - usa `platform.runflow.ai` sempre atualizado
417
+ - ✅ Dados locais - traces armazenados em `.runflow/traces/`
418
+ - ✅ Monitoramento real-time - visualize threads, execuções e traces
419
+
420
+ **Exemplo básico:**
421
+ ```bash
422
+ # Simplesmente rode (detecta tudo automaticamente)
423
+ rf test
424
+
425
+ # Output:
426
+ # 🧪 Runflow Test Server
427
+ # ✓ Found agent config
428
+ # Agent: Agent com RAG (Agentic)
429
+ # ✓ Local server running on port 3421
430
+ # ✓ Opening browser...
431
+ #
432
+ # 📊 Test Portal Ready!
433
+ # 🌐 Portal: https://platform.runflow.ai/agents/abc.../test-monitor?...
434
+ # 📡 API: http://localhost:3421
435
+ # 💾 Storage: .runflow/traces/
436
+ ```
437
+
438
+ **Com opções:**
439
+ ```bash
440
+ # Porta customizada
441
+ rf test --port 4500
442
+
443
+ # Sem abrir navegador
444
+ rf test --no-browser
445
+ ```
446
+
447
+ **Como funciona:**
448
+
449
+ 1. **Lê configuração** do `.runflow/rf.json` (agentId, agentName)
450
+ 2. **Inicia servidor local** com 3 APIs de observabilidade
451
+ 3. **Tenta até 3 portas** caso a primeira esteja ocupada
452
+ 4. **Abre portal cloud** (`platform.runflow.ai`) com parâmetros corretos
453
+ 5. **Portal conecta** ao servidor local para buscar dados
454
+
455
+ **APIs disponíveis:**
456
+ - `GET /health` - Health check
457
+ - `GET /api/v1/observability/threads` - Lista threads
458
+ - `GET /api/v1/observability/threads/:threadId/executions` - Lista execuções
459
+ - `GET /api/v1/observability/executions/:executionId` - Detalhes de traces
460
+
461
+ **Estrutura de armazenamento:**
462
+ ```
463
+ .runflow/
464
+ ├── rf.json # Configuração do agente
465
+ └── traces/ # Armazenamento de traces
466
+ ├── 2025-11-06/ # Pastas por data
467
+ │ └── session-*.json
468
+ └── 2025-11-07/
469
+ └── ...
470
+ ```
471
+
472
+ **Fluxo típico de uso:**
473
+ ```bash
474
+ # Terminal 1: Inicie o servidor de teste
475
+ cd meu-agente/
476
+ rf test
477
+
478
+ # Terminal 2: Execute seu agente
479
+ npm run dev
480
+ # ou
481
+ node agent.ts
482
+ ```
483
+
484
+ **📚 Documentação completa:** [`docs/TEST-COMMAND.md`](docs/TEST-COMMAND.md)
485
+
486
+ ---
487
+
399
488
  ## Troubleshooting
400
489
 
401
490
  ### Problemas de Autenticação
@@ -0,0 +1,273 @@
1
+ # 🚀 Quick Test Guide - rf test
2
+
3
+ ## TL;DR
4
+
5
+ ```bash
6
+ cd seu-agente/
7
+ rf test
8
+ ```
9
+
10
+ That's it! 🎉
11
+
12
+ ---
13
+
14
+ ## Passo a Passo Completo
15
+
16
+ ### 1. Instale ou atualize a CLI
17
+
18
+ ```bash
19
+ # Se ainda não tem instalado
20
+ npm install -g @runflow-ai/cli
21
+
22
+ # Se já tem, atualize
23
+ npm update -g @runflow-ai/cli
24
+ ```
25
+
26
+ ### 2. Entre no diretório do agente
27
+
28
+ ```bash
29
+ cd smartfit-agents/agent-com-rag/
30
+ # ou qualquer agente com .runflow/rf.json
31
+ ```
32
+
33
+ ### 3. Execute o comando test
34
+
35
+ ```bash
36
+ rf test
37
+ ```
38
+
39
+ **Output esperado:**
40
+
41
+ ```
42
+ 🧪 Runflow Test Server
43
+ Starting local observability server...
44
+
45
+ ✓ Found agent config
46
+ Agent: Agent com RAG (Agentic)
47
+
48
+ ✓ Local server running on port 3421
49
+
50
+ ✓ Opening browser...
51
+
52
+ 📊 Test Portal Ready!
53
+
54
+ 🌐 Portal: https://platform.runflow.ai/local-test/agents/fbc4c76d-57b3-40c3-a165-c4edcbf28434/test-monitor?apiUrl=http://localhost:3421&agentName=Agent%20com%20RAG
55
+ 📡 API: http://localhost:3421
56
+ 💾 Storage: /Users/danrleymorais/projects/runflow/runflow-sdk-repo/smartfit-agents/agent-com-rag/.runflow/traces
57
+
58
+ ⚠️ Note: Your browser may show a warning about
59
+ mixed content (HTTPS → HTTP). Click "Allow" if prompted.
60
+
61
+ Press Ctrl+C to stop
62
+ ```
63
+
64
+ ### 4. Teste no navegador
65
+
66
+ O portal abre automaticamente em `https://platform.runflow.ai` com:
67
+ - Interface de teste (40% esquerda)
68
+ - Monitoramento em tempo real (60% direita)
69
+
70
+ **Features disponíveis:**
71
+ - ✅ Enviar mensagens para o agente
72
+ - ✅ Ver lista de threads (conversas)
73
+ - ✅ Ver execuções por thread
74
+ - ✅ Visualizar traces detalhados (árvore hierárquica)
75
+ - ✅ Métricas: tokens, custo, duração
76
+
77
+ ### 5. Execute seu agente (em outro terminal)
78
+
79
+ ```bash
80
+ # Terminal 2
81
+ cd seu-agente/
82
+ npm run dev
83
+ # ou
84
+ node agent.ts
85
+ ```
86
+
87
+ As execuções aparecerão automaticamente no portal! 🎯
88
+
89
+ ---
90
+
91
+ ## 🧪 Testando com dados de exemplo
92
+
93
+ Para testar a visualização sem executar o agente, use o trace de exemplo:
94
+
95
+ ```bash
96
+ # 1. Crie o diretório de traces
97
+ mkdir -p .runflow/traces/2025-11-06
98
+
99
+ # 2. Copie o arquivo de exemplo
100
+ cp /path/to/runflow-cli/docs/trace-example.json .runflow/traces/2025-11-06/session-test-1730894400000.json
101
+
102
+ # 3. Edite o agentId no arquivo para corresponder ao seu
103
+ # Substitua "fbc4c76d-..." pelo agentId do seu .runflow/rf.json
104
+
105
+ # 4. Inicie o servidor
106
+ rf test
107
+ ```
108
+
109
+ Agora você verá threads e execuções de exemplo no portal! ✨
110
+
111
+ ---
112
+
113
+ ## 🎛️ Opções Avançadas
114
+
115
+ ### Porta customizada
116
+
117
+ ```bash
118
+ rf test --port 5000
119
+ ```
120
+
121
+ ### Sem abrir navegador
122
+
123
+ ```bash
124
+ rf test --no-browser
125
+
126
+ # Depois abra manualmente:
127
+ open https://platform.runflow.ai/agents/SEU_AGENT_ID/test-monitor?apiUrl=http://localhost:3421&mode=local
128
+ ```
129
+
130
+ ### Múltiplos agentes simultaneamente
131
+
132
+ ```bash
133
+ # Terminal 1
134
+ cd agent-1/
135
+ rf test --port 3500
136
+
137
+ # Terminal 2
138
+ cd agent-2/
139
+ rf test --port 3600
140
+
141
+ # Terminal 3
142
+ cd agent-3/
143
+ rf test --port 3700
144
+ ```
145
+
146
+ Cada um abrirá em uma aba diferente do navegador! 🔥
147
+
148
+ ---
149
+
150
+ ## 🐛 Troubleshooting
151
+
152
+ ### Erro: "No agentId found"
153
+
154
+ ```bash
155
+ ❌ No agentId found in .runflow/rf.json
156
+ Run "rf clone <agentId>" first
157
+ ```
158
+
159
+ **Solução:**
160
+ ```bash
161
+ # Clone um agente primeiro
162
+ rf agents list
163
+ # Selecione um agente e clone
164
+ ```
165
+
166
+ ### Erro: "Failed to start server after 3 attempts"
167
+
168
+ ```bash
169
+ ❌ Failed to start server after 3 attempts
170
+ All ports are busy. Try again later.
171
+ ```
172
+
173
+ **Solução:**
174
+ ```bash
175
+ # Tente porta específica
176
+ rf test --port 5000
177
+
178
+ # Ou mate processos ocupando portas
179
+ lsof -ti:3000,3001,3002 | xargs kill
180
+ ```
181
+
182
+ ### Portal não mostra dados
183
+
184
+ **Verificações:**
185
+ 1. ✅ Servidor está rodando? `curl http://localhost:3421/health`
186
+ 2. ✅ Diretório de traces existe? `ls .runflow/traces/`
187
+ 3. ✅ AgentId correto na URL?
188
+ 4. ✅ Console do navegador tem erros?
189
+
190
+ **Solução comum:**
191
+ ```bash
192
+ # Recarregue a página permitindo mixed content
193
+ # Chrome: Click no shield icon → "Load unsafe scripts"
194
+ # Firefox: Click no shield icon → "Disable protection"
195
+ ```
196
+
197
+ ### Mixed Content Warning
198
+
199
+ O navegador pode avisar sobre **mixed content** (HTTPS → HTTP):
200
+
201
+ **Chrome:**
202
+ 1. Click no ícone de shield na barra de endereço
203
+ 2. Click em "Load unsafe scripts"
204
+
205
+ **Firefox:**
206
+ 1. Click no ícone de shield
207
+ 2. Click em "Disable protection for now"
208
+
209
+ **Safari:**
210
+ 1. Safari → Preferences → Advanced
211
+ 2. Enable "Show Develop menu"
212
+ 3. Develop → Disable Cross-Origin Restrictions
213
+
214
+ ---
215
+
216
+ ## 📊 Estrutura de Dados
217
+
218
+ ### Storage Local
219
+
220
+ ```
221
+ .runflow/
222
+ ├── rf.json # Config do agente
223
+ └── traces/ # Traces
224
+ ├── 2025-11-06/
225
+ │ ├── session-abc123-1730894400000.json # Sessão 1
226
+ │ └── session-xyz789-1730894500000.json # Sessão 2
227
+ └── 2025-11-07/
228
+ └── ...
229
+ ```
230
+
231
+ ### Formato de Trace
232
+
233
+ Ver [`docs/trace-example.json`](docs/trace-example.json) para exemplo completo.
234
+
235
+ **Estrutura básica:**
236
+ ```json
237
+ {
238
+ "sessionId": "session-uuid-timestamp",
239
+ "agentId": "agent-uuid",
240
+ "createdAt": "2025-11-06T10:00:00Z",
241
+ "threads": {
242
+ "user@email.com": {
243
+ "threadId": "user@email.com",
244
+ "executions": [
245
+ {
246
+ "executionId": "exec-uuid",
247
+ "inputMessage": "Hello",
248
+ "outputMessage": "Hi!",
249
+ "status": "success",
250
+ "traces": [ /* árvore de traces */ ]
251
+ }
252
+ ]
253
+ }
254
+ }
255
+ }
256
+ ```
257
+
258
+ ---
259
+
260
+ ## ✨ Próximos Passos
261
+
262
+ 1. **Teste básico:** `rf test` e envie mensagens no portal
263
+ 2. **Execute agente:** Em outro terminal, rode seu agente
264
+ 3. **Monitore:** Veja execuções em tempo real
265
+ 4. **Debug:** Analise traces detalhados
266
+ 5. **Itere:** Faça mudanças e teste novamente
267
+
268
+ **Happy testing!** 🚀
269
+
270
+ Para mais detalhes, veja:
271
+ - [`docs/TEST-COMMAND.md`](docs/TEST-COMMAND.md) - Documentação completa
272
+ - [`CLI-DOCS.md`](CLI-DOCS.md) - Todos os comandos da CLI
273
+
@@ -1,24 +1,31 @@
1
1
  import { CommandRunner } from 'nest-commander';
2
2
  interface TestCommandOptions {
3
3
  port?: number;
4
- host?: string;
5
- open?: boolean;
6
- verbose?: boolean;
4
+ noBrowser?: boolean;
7
5
  }
8
6
  export declare class TestCommand extends CommandRunner {
9
7
  private server;
10
- private frontend;
8
+ private app;
9
+ private storageDir;
11
10
  run(passedParam: string[], options?: TestCommandOptions): Promise<void>;
12
11
  parsePort(val: string): number;
13
- parseHost(val: string): string;
14
- parseOpen(): boolean;
15
- parseVerbose(val: string): boolean;
12
+ parseNoBrowser(): boolean;
16
13
  private loadRunflowConfig;
17
- private ensureDependencies;
18
- private startTestServer;
19
- private startFrontend;
20
- private waitForServer;
21
- private runCommand;
14
+ private executeAgent;
15
+ private getRandomPort;
16
+ private generateSessionId;
17
+ private generateUserId;
18
+ private createFingerprint;
19
+ private ensureStorageDir;
20
+ private startObservabilityServer;
21
+ private setupObservabilityEndpoints;
22
+ private getThreads;
23
+ private getThreadExecutions;
24
+ private getExecutionTraces;
25
+ private countAllTraces;
26
+ private getAllTraceFiles;
27
+ private getSDKTraces;
28
+ private buildTraceHierarchy;
22
29
  private openBrowser;
23
30
  private setupCleanupHandlers;
24
31
  private cleanup;