@runflow-ai/sdk 1.0.0 → 1.0.1

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SessionManager = exports.RunflowSDK = void 0;
4
+ const config_1 = require("./config");
4
5
  class RunflowSDK {
5
6
  constructor(context) {
6
7
  // =============================================================================
@@ -11,16 +12,16 @@ class RunflowSDK {
11
12
  // companyId vem automaticamente do context injetado pela plataforma
12
13
  const companyId = this.context.companyId || this.context.tenantId;
13
14
  return new SessionManager(sessionId, companyId, this.context, this.getApiUrl(), this.getApiKey());
14
- }
15
+ },
15
16
  };
17
+ // Tentar carregar configurações do arquivo .runflow automaticamente
18
+ (0, config_1.loadRunflowConfig)();
16
19
  // Context é SEMPRE injetado pela plataforma via env vars
17
20
  this.context = context || {
18
- tenantId: this.getRequiredEnv('RUNFLOW_TENANT_ID'),
19
- projectId: this.getRequiredEnv('RUNFLOW_PROJECT_ID'),
20
- agentId: this.getRequiredEnv('RUNFLOW_AGENT_ID'),
21
+ tenantId: this.getRequiredEnv("RUNFLOW_TENANT_ID"),
22
+ agentId: this.getRequiredEnv("RUNFLOW_AGENT_ID"),
21
23
  requestId: process.env.RUNFLOW_REQUEST_ID || `req_${Date.now()}`,
22
24
  sessionId: process.env.RUNFLOW_SESSION_ID,
23
- companyId: process.env.RUNFLOW_COMPANY_ID // Injetado automaticamente
24
25
  };
25
26
  }
26
27
  getRequiredEnv(key) {
@@ -31,42 +32,266 @@ class RunflowSDK {
31
32
  return value;
32
33
  }
33
34
  getApiUrl() {
34
- return process.env.RUNFLOW_API_URL || 'http://localhost:3001';
35
+ return process.env.RUNFLOW_API_URL || "http://localhost:3001";
35
36
  }
36
37
  getApiKey() {
37
38
  const key = process.env.RUNFLOW_API_KEY;
38
39
  if (!key) {
39
- throw new Error('RUNFLOW_API_KEY não definida. Certifique-se de que o agente está sendo executado na plataforma Runflow.');
40
+ throw new Error("RUNFLOW_API_KEY não definida. Certifique-se de que o agente está sendo executado na plataforma Runflow.");
40
41
  }
41
42
  return key;
42
43
  }
43
44
  getHeaders(includeCompany = false) {
44
45
  const headers = {
45
- 'Authorization': `Bearer ${this.getApiKey()}`,
46
- 'Content-Type': 'application/json',
47
- 'X-Runflow-Tenant-Id': this.context.tenantId,
48
- 'X-Runflow-Project-Id': this.context.projectId,
49
- 'X-Runflow-Agent-Id': this.context.agentId,
46
+ "x-api-key": this.getApiKey(),
47
+ "Content-Type": "application/json",
48
+ "X-Runflow-Tenant-Id": this.context.tenantId,
49
+ "X-Runflow-Agent-Id": this.context.agentId,
50
50
  };
51
- if (includeCompany && this.context.companyId) {
52
- headers['X-Runflow-Company-Id'] = this.context.companyId;
53
- }
54
51
  return headers;
55
52
  }
56
53
  // =============================================================================
54
+ // ⚙️ COMANDOS GERAIS
55
+ // =============================================================================
56
+ async login(apiKey) {
57
+ this.log("Validando API key");
58
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/login`, {
59
+ method: "POST",
60
+ headers: {
61
+ Authorization: `Bearer ${apiKey}`,
62
+ "Content-Type": "application/json",
63
+ },
64
+ });
65
+ if (!response.ok) {
66
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
67
+ }
68
+ return response.json();
69
+ }
70
+ async health() {
71
+ this.log("Verificando saúde da API");
72
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/health`, {
73
+ method: "GET",
74
+ headers: this.getHeaders(),
75
+ });
76
+ if (!response.ok) {
77
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
78
+ }
79
+ return response.json();
80
+ }
81
+ async tenants() {
82
+ this.log("Listando tenants");
83
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/tenants`, {
84
+ method: "GET",
85
+ headers: this.getHeaders(),
86
+ });
87
+ if (!response.ok) {
88
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
89
+ }
90
+ return response.json();
91
+ }
92
+ async agents() {
93
+ this.log("Listando agentes");
94
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/agents`, {
95
+ method: "GET",
96
+ headers: this.getHeaders(),
97
+ });
98
+ if (!response.ok) {
99
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
100
+ }
101
+ return response.json();
102
+ }
103
+ async getAgent(id) {
104
+ this.log(`Buscando agente: ${id}`);
105
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/agents/${id}`, {
106
+ method: "GET",
107
+ headers: this.getHeaders(),
108
+ });
109
+ if (!response.ok) {
110
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
111
+ }
112
+ return response.json();
113
+ }
114
+ async createAgent(data) {
115
+ this.log("Criando agente", data);
116
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/agents`, {
117
+ method: "POST",
118
+ headers: this.getHeaders(),
119
+ body: JSON.stringify(data),
120
+ });
121
+ if (!response.ok) {
122
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
123
+ }
124
+ return response.json();
125
+ }
126
+ async updateAgent(id, data) {
127
+ this.log(`Atualizando agente: ${id}`, data);
128
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/agents/${id}`, {
129
+ method: "PUT",
130
+ headers: this.getHeaders(),
131
+ body: JSON.stringify(data),
132
+ });
133
+ if (!response.ok) {
134
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
135
+ }
136
+ return response.json();
137
+ }
138
+ async deleteAgent(id) {
139
+ this.log(`Removendo agente: ${id}`);
140
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/agents/${id}`, {
141
+ method: "DELETE",
142
+ headers: this.getHeaders(),
143
+ });
144
+ if (!response.ok) {
145
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
146
+ }
147
+ }
148
+ async cloneAgent(id) {
149
+ this.log(`Clonando agente: ${id}`);
150
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/agents/${id}/clone`, {
151
+ method: "POST",
152
+ headers: this.getHeaders(),
153
+ });
154
+ if (!response.ok) {
155
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
156
+ }
157
+ return response.json();
158
+ }
159
+ async deployAgent(id) {
160
+ this.log(`Publicando agente: ${id}`);
161
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/agents/${id}/deploy`, {
162
+ method: "POST",
163
+ headers: this.getHeaders(),
164
+ });
165
+ if (!response.ok) {
166
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
167
+ }
168
+ return response.json();
169
+ }
170
+ async connectors() {
171
+ this.log("Listando conectores");
172
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/connectors`, {
173
+ method: "GET",
174
+ headers: this.getHeaders(),
175
+ });
176
+ if (!response.ok) {
177
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
178
+ }
179
+ return response.json();
180
+ }
181
+ async credentials() {
182
+ this.log("Listando credenciais");
183
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/credentials`, {
184
+ method: "GET",
185
+ headers: this.getHeaders(),
186
+ });
187
+ if (!response.ok) {
188
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
189
+ }
190
+ return response.json();
191
+ }
192
+ async datasources() {
193
+ this.log("Listando fontes de dados");
194
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/datasources`, {
195
+ method: "GET",
196
+ headers: this.getHeaders(),
197
+ });
198
+ if (!response.ok) {
199
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
200
+ }
201
+ return response.json();
202
+ }
203
+ async triggers() {
204
+ this.log("Listando triggers");
205
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/triggers`, {
206
+ method: "GET",
207
+ headers: this.getHeaders(),
208
+ });
209
+ if (!response.ok) {
210
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
211
+ }
212
+ return response.json();
213
+ }
214
+ async executions() {
215
+ this.log("Listando execuções");
216
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/executions`, {
217
+ method: "GET",
218
+ headers: this.getHeaders(),
219
+ });
220
+ if (!response.ok) {
221
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
222
+ }
223
+ return response.json();
224
+ }
225
+ async users() {
226
+ this.log("Listando usuários");
227
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/users`, {
228
+ method: "GET",
229
+ headers: this.getHeaders(),
230
+ });
231
+ if (!response.ok) {
232
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
233
+ }
234
+ return response.json();
235
+ }
236
+ async getUser(id) {
237
+ this.log(`Buscando usuário: ${id}`);
238
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/users/${id}`, {
239
+ method: "GET",
240
+ headers: this.getHeaders(),
241
+ });
242
+ if (!response.ok) {
243
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
244
+ }
245
+ return response.json();
246
+ }
247
+ async createUser(data) {
248
+ this.log("Criando usuário", data);
249
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/users`, {
250
+ method: "POST",
251
+ headers: this.getHeaders(),
252
+ body: JSON.stringify(data),
253
+ });
254
+ if (!response.ok) {
255
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
256
+ }
257
+ return response.json();
258
+ }
259
+ async updateUser(id, data) {
260
+ this.log(`Atualizando usuário: ${id}`, data);
261
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/users/${id}`, {
262
+ method: "PUT",
263
+ headers: this.getHeaders(),
264
+ body: JSON.stringify(data),
265
+ });
266
+ if (!response.ok) {
267
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
268
+ }
269
+ return response.json();
270
+ }
271
+ async deleteUser(id) {
272
+ this.log(`Removendo usuário: ${id}`);
273
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/users/${id}`, {
274
+ method: "DELETE",
275
+ headers: this.getHeaders(),
276
+ });
277
+ if (!response.ok) {
278
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
279
+ }
280
+ }
281
+ // =============================================================================
57
282
  // 🔐 CREDENCIAIS
58
283
  // =============================================================================
59
284
  async getCredential(name) {
60
285
  this.log(`Buscando credencial: ${name}`);
61
286
  try {
62
287
  const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/credentials/${name}`, {
63
- method: 'GET',
64
- headers: this.getHeaders()
288
+ method: "GET",
289
+ headers: this.getHeaders(),
65
290
  });
66
291
  if (!response.ok) {
67
292
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
68
293
  }
69
- const credential = await response.json();
294
+ const credential = (await response.json());
70
295
  this.log(`Credencial obtida: ${credential.name} (${credential.type})`);
71
296
  return credential;
72
297
  }
@@ -82,22 +307,22 @@ class RunflowSDK {
82
307
  this.log(`Buscando prompt: ${name}`, variables ? { variables } : undefined);
83
308
  try {
84
309
  let url = `${this.getApiUrl()}/api/v1/sdk/prompts/${name}`;
85
- let method = 'GET';
310
+ let method = "GET";
86
311
  let body = undefined;
87
312
  // Se há variáveis, usar POST para renderização
88
313
  if (variables && Object.keys(variables).length > 0) {
89
- method = 'POST';
314
+ method = "POST";
90
315
  body = JSON.stringify({ variables });
91
316
  }
92
317
  const response = await fetch(url, {
93
318
  method,
94
319
  headers: this.getHeaders(),
95
- body
320
+ body,
96
321
  });
97
322
  if (!response.ok) {
98
323
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
99
324
  }
100
- const promptResponse = await response.json();
325
+ const promptResponse = (await response.json());
101
326
  this.log(`Prompt obtido: ${promptResponse.name}`);
102
327
  return promptResponse.content;
103
328
  }
@@ -110,11 +335,11 @@ class RunflowSDK {
110
335
  // 🔍 SEARCH & VECTOR STORES
111
336
  // =============================================================================
112
337
  async getAvailableVectorStores() {
113
- this.log('Listando vector stores disponíveis');
338
+ this.log("Listando vector stores disponíveis");
114
339
  try {
115
340
  const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/search-tools`, {
116
- method: 'GET',
117
- headers: this.getHeaders()
341
+ method: "GET",
342
+ headers: this.getHeaders(),
118
343
  });
119
344
  if (!response.ok) {
120
345
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
@@ -123,7 +348,7 @@ class RunflowSDK {
123
348
  return data.vector_stores || [];
124
349
  }
125
350
  catch (error) {
126
- this.log('Erro ao listar vector stores:', error);
351
+ this.log("Erro ao listar vector stores:", error);
127
352
  throw error;
128
353
  }
129
354
  }
@@ -132,14 +357,14 @@ class RunflowSDK {
132
357
  this.log(`Buscando em ${vectorStore}: "${query}"`, { k, threshold });
133
358
  try {
134
359
  const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/search-tools/${vectorStore}/search`, {
135
- method: 'POST',
360
+ method: "POST",
136
361
  headers: this.getHeaders(),
137
- body: JSON.stringify({ query, k, threshold })
362
+ body: JSON.stringify({ query, k, threshold }),
138
363
  });
139
364
  if (!response.ok) {
140
365
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
141
366
  }
142
- const searchResponse = await response.json();
367
+ const searchResponse = (await response.json());
143
368
  this.log(`Busca realizada: ${searchResponse.results.length} resultados`);
144
369
  return searchResponse;
145
370
  }
@@ -148,6 +373,73 @@ class RunflowSDK {
148
373
  throw error;
149
374
  }
150
375
  }
376
+ async addDocument(request) {
377
+ this.log(`Adicionando documento ao vector store: ${request.vectorStore}`, {
378
+ contentLength: request.content.length,
379
+ hasMetadata: !!request.metadata
380
+ });
381
+ try {
382
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/search-tools/documents`, {
383
+ method: "POST",
384
+ headers: this.getHeaders(),
385
+ body: JSON.stringify(request),
386
+ });
387
+ if (!response.ok) {
388
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
389
+ }
390
+ const result = (await response.json());
391
+ this.log(`Documento adicionado: ${result.id}`);
392
+ return result;
393
+ }
394
+ catch (error) {
395
+ this.log("Erro ao adicionar documento:", error);
396
+ throw error;
397
+ }
398
+ }
399
+ async listDocuments(vectorStore, options = {}) {
400
+ const { limit = 10, offset = 0 } = options;
401
+ this.log(`Listando documentos do vector store: ${vectorStore}`, { limit, offset });
402
+ try {
403
+ const params = new URLSearchParams({
404
+ limit: limit.toString(),
405
+ ...(offset > 0 && { offset: offset.toString() })
406
+ });
407
+ const url = `${this.getApiUrl()}/api/v1/sdk/search-tools/${vectorStore}/documents?${params}`;
408
+ const response = await fetch(url, {
409
+ method: "GET",
410
+ headers: this.getHeaders(),
411
+ });
412
+ if (!response.ok) {
413
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
414
+ }
415
+ const result = (await response.json());
416
+ this.log(`Documentos listados: ${result.documents.length} de ${result.total}`);
417
+ return result;
418
+ }
419
+ catch (error) {
420
+ this.log(`Erro ao listar documentos do vector store ${vectorStore}:`, error);
421
+ throw error;
422
+ }
423
+ }
424
+ async deleteDocument(documentId) {
425
+ this.log(`Removendo documento: ${documentId}`);
426
+ try {
427
+ const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/search-tools/documents/${documentId}`, {
428
+ method: "DELETE",
429
+ headers: this.getHeaders(),
430
+ });
431
+ if (!response.ok) {
432
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
433
+ }
434
+ const result = (await response.json());
435
+ this.log(`Documento removido: ${documentId}`);
436
+ return result;
437
+ }
438
+ catch (error) {
439
+ this.log(`Erro ao remover documento ${documentId}:`, error);
440
+ throw error;
441
+ }
442
+ }
151
443
  // =============================================================================
152
444
  // 📊 LOGS & TRACES
153
445
  // =============================================================================
@@ -161,26 +453,86 @@ class RunflowSDK {
161
453
  console.log(logEntry);
162
454
  }
163
455
  }
164
- async trace(traceData = {}) {
165
- this.log('Enviando trace para LangSmith', { operation: traceData.operation || 'agent.invoke' });
456
+ async trace(traceData) {
457
+ this.log("Enviando trace para LangSmith", { operation: "agent.invoke" });
166
458
  try {
459
+ // Converte dados legados para o formato padronizado
460
+ const standardizedData = this.standardizeTraceData(traceData);
167
461
  const response = await fetch(`${this.getApiUrl()}/api/v1/sdk/traces`, {
168
- method: 'POST',
462
+ method: "POST",
169
463
  headers: this.getHeaders(),
170
- body: JSON.stringify(traceData)
464
+ body: JSON.stringify(standardizedData),
171
465
  });
172
466
  if (!response.ok) {
173
467
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
174
468
  }
175
- const result = await response.json();
176
- this.log(`Trace enviado: ${result.traceId}`, { langsmith: result.langsmith });
469
+ const result = (await response.json());
470
+ this.log(`Trace enviado: ${result.traceId}`, {
471
+ langsmith: result.langsmith,
472
+ });
177
473
  return result;
178
474
  }
179
475
  catch (error) {
180
- this.log('Erro ao enviar trace:', error);
476
+ this.log("Erro ao enviar trace:", error);
181
477
  throw error;
182
478
  }
183
479
  }
480
+ standardizeTraceData(data) {
481
+ // Se já está no formato padrão, retorna como está
482
+ if (this.isStandardTraceData(data)) {
483
+ return data;
484
+ }
485
+ // Converte formato legado para o padronizado
486
+ const legacyData = data;
487
+ // Converte inputs para o formato de array com type e content
488
+ const input = [];
489
+ if (legacyData.inputs) {
490
+ // Se inputs é um objeto, converte cada chave em uma mensagem
491
+ for (const [key, value] of Object.entries(legacyData.inputs)) {
492
+ input.push({
493
+ type: key === 'message' || key === 'query' ? 'human' : 'system',
494
+ content: typeof value === 'string' ? value : JSON.stringify(value)
495
+ });
496
+ }
497
+ }
498
+ // Se não há inputs, cria um input padrão
499
+ if (input.length === 0) {
500
+ input.push({
501
+ type: 'human',
502
+ content: 'No input provided'
503
+ });
504
+ }
505
+ // Converte outputs para string
506
+ let output = '';
507
+ if (legacyData.outputs) {
508
+ if (typeof legacyData.outputs === 'string') {
509
+ output = legacyData.outputs;
510
+ }
511
+ else if (legacyData.outputs.message) {
512
+ output = legacyData.outputs.message;
513
+ }
514
+ else if (legacyData.outputs.answer) {
515
+ output = legacyData.outputs.answer;
516
+ }
517
+ else {
518
+ output = JSON.stringify(legacyData.outputs);
519
+ }
520
+ }
521
+ else {
522
+ output = 'No output provided';
523
+ }
524
+ return {
525
+ input,
526
+ output,
527
+ status: legacyData.status || 'success'
528
+ };
529
+ }
530
+ isStandardTraceData(data) {
531
+ return (data &&
532
+ Array.isArray(data.input) &&
533
+ typeof data.output === 'string' &&
534
+ typeof data.status === 'string');
535
+ }
184
536
  }
185
537
  exports.RunflowSDK = RunflowSDK;
186
538
  // =============================================================================
@@ -196,27 +548,26 @@ class SessionManager {
196
548
  }
197
549
  getHeaders() {
198
550
  return {
199
- 'Authorization': `Bearer ${this.apiKey}`,
200
- 'Content-Type': 'application/json',
201
- 'X-Runflow-Tenant-Id': this.context.tenantId,
202
- 'X-Runflow-Project-Id': this.context.projectId,
203
- 'X-Runflow-Agent-Id': this.context.agentId,
204
- 'X-Runflow-Company-Id': this.companyId,
551
+ "x-api-key": this.apiKey,
552
+ "Content-Type": "application/json",
553
+ "X-Runflow-Tenant-Id": this.context.tenantId,
554
+ "X-Runflow-Agent-Id": this.context.agentId,
555
+ "X-Runflow-Company-Id": this.companyId,
205
556
  };
206
557
  }
207
558
  async addMessage(role, content, metadata) {
208
559
  try {
209
560
  const response = await fetch(`${this.apiUrl}/api/v1/sdk/sessions/${this.sessionId}/messages`, {
210
- method: 'POST',
561
+ method: "POST",
211
562
  headers: this.getHeaders(),
212
563
  body: JSON.stringify({
213
564
  role,
214
565
  content,
215
566
  metadata: {
216
567
  timestamp: new Date().toISOString(),
217
- ...metadata
218
- }
219
- })
568
+ ...metadata,
569
+ },
570
+ }),
220
571
  });
221
572
  if (!response.ok) {
222
573
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
@@ -233,16 +584,16 @@ class SessionManager {
233
584
  try {
234
585
  const params = new URLSearchParams({
235
586
  limit: limit.toString(),
236
- offset: offset.toString()
587
+ offset: offset.toString(),
237
588
  });
238
589
  const response = await fetch(`${this.apiUrl}/api/v1/sdk/sessions/${this.sessionId}/history?${params}`, {
239
- method: 'GET',
240
- headers: this.getHeaders()
590
+ method: "GET",
591
+ headers: this.getHeaders(),
241
592
  });
242
593
  if (!response.ok) {
243
594
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
244
595
  }
245
- const historyResponse = await response.json();
596
+ const historyResponse = (await response.json());
246
597
  console.log(`📚 Histórico obtido: ${historyResponse.messages.length} mensagens`);
247
598
  return historyResponse.messages;
248
599
  }
@@ -254,8 +605,8 @@ class SessionManager {
254
605
  async clear() {
255
606
  try {
256
607
  const response = await fetch(`${this.apiUrl}/api/v1/sdk/sessions/${this.sessionId}`, {
257
- method: 'DELETE',
258
- headers: this.getHeaders()
608
+ method: "DELETE",
609
+ headers: this.getHeaders(),
259
610
  });
260
611
  if (!response.ok) {
261
612
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);