@areumtecnologia/autonomouscustomerserviceagent 2.0.5 → 2.1.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Autonomous Customer Service Agent
2
2
 
3
- > **v2.0.5** — Agente autônomo de atendimento ao cliente baseado em IA, desenvolvido com Google Gemini. Suporta múltiplas sessões concorrentes, ferramentas customizadas, retry com backoff exponencial e modos de tratamento de falhas `sync` e `async`.
3
+ > **v2.0.6** — Agente autônomo de atendimento ao cliente baseado em IA, desenvolvido com Google Gemini. Suporta múltiplas sessões concorrentes, ferramentas customizadas, retry com backoff exponencial e modos de tratamento de falhas `sync` e `async`.
4
4
 
5
5
  ---
6
6
 
@@ -142,15 +142,15 @@ Constrói a configuração do agente. **Obrigatório** — o construtor de `Auto
142
142
  | `sessionTTL` | `number` | `1800000` | TTL da sessão em ms (padrão: 30 min) |
143
143
  | `turnTimeoutMs` | `number` | `90000` | Timeout por turno do loop em ms |
144
144
  | `maxVulnerabilityAttempts` | `number` | `3` | Tentativas antes de encerrar a sessão |
145
- | `temperature` | `number` | `0.1` | Temperatura do modelo (0–1) |
145
+ | `temperature` | `number` | `1` | Temperatura do modelo (0–1) |
146
146
  | `topP` | `number` | `0.95` | Probabilidade de núcleo (top-p sampling) |
147
- | `thinkingLevel` | `string` | `'MINIMAL'` | Nível de raciocínio interno do modelo |
147
+ | `thinkingLevel` | `string` | `'HIGH'` | Nível de raciocínio interno do modelo |
148
148
  | `maxOutputTokens` | `number` | `32768` | Tokens máximos na resposta |
149
149
  | `failureHandlingMode` | `'sync' \| 'async'` | `'sync'` | Modo de tratamento de falhas |
150
150
  | `retryScheduleMinutes` | `number` | `5` | Intervalo entre tentativas agendadas (min) |
151
151
  | `retryScheduleAttempts` | `number` | `24` | Máximo de tentativas agendadas |
152
152
  | `retryScheduleWindowMs` | `number` | `86400000` | Janela total de retentativas (24h) |
153
- | `unavailabilityMessage` | `string` | Mensagem padrão em inglês | Mensagem exibida ao usuário em caso de indisponibilidade |
153
+ | `unavailabilityMessage` | `string` | `'We are experiencing a temporary outage. We will contact you as soon as the problem is resolved.'` | Mensagem exibida ao usuário em caso de indisponibilidade |
154
154
  | `retryOptions` | `object` | `{ maxAttempts: 3, baseDelayMs: 900, maxDelayMs: 9000 }` | Opções do retry com backoff exponencial |
155
155
 
156
156
  ---
@@ -186,16 +186,16 @@ console.log(response.sent_at); // Timestamp no fuso de Brasília
186
186
 
187
187
  Retorna um snapshot read-only da sessão.
188
188
 
189
- #### `agent.getSessionByLead(leadFilter)` → `SessionSnapshot | null`
189
+ #### `agent.getSessionByUser(filter)` → `SessionSnapshot | null`
190
190
 
191
- Busca uma sessão por nome, telefone ou origem. Aceita string (nome ou telefone) ou objeto de filtro.
191
+ Busca uma sessão por nome, telefone ou origem do usuário. Aceita string (nome ou telefone) ou objeto de filtro.
192
192
 
193
193
  ```javascript
194
194
  // Por telefone (string)
195
- const s1 = agent.getSessionByLead('5511999999999');
195
+ const s1 = agent.getSessionByUser('5511999999999');
196
196
 
197
197
  // Por objeto de filtro composto
198
- const s2 = agent.getSessionByLead({
198
+ const s2 = agent.getSessionByUser({
199
199
  name: 'Maria Souza',
200
200
  origin: { type: 'instagram' },
201
201
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@areumtecnologia/autonomouscustomerserviceagent",
3
- "version": "2.0.5",
3
+ "version": "2.1.0",
4
4
  "description": "Agente autônomo de atendimento ao cliente baseado em IA com Google Gemini API. Suporta múltiplas sessões, ferramentas customizadas e retry com backoff exponencial.",
5
5
  "license": "ISC",
6
6
  "author": "Áreum Tecnologia",
@@ -26,7 +26,7 @@
26
26
  "start": "node tests/test.js"
27
27
  },
28
28
  "dependencies": {
29
- "@google/genai": "^2.6.0"
29
+ "@google/genai": "^2.8.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "dotenv": "^17.4.2"
@@ -3,7 +3,7 @@
3
3
  // AgentConfig — construtor de configuração para o agente, usado internamente para complementar o prompt de sistema
4
4
  // ──────────────────────────────────────────────────────────────────────────────
5
5
  class AgentConfig {
6
- constructor(agentName, agentCompanyName, agentCompanyDetails, missionObjective, missionInstructions, reasoningLanguage = 'en_us') {
6
+ constructor(agentName, agentCompanyName, agentCompanyDetails, missionObjective, missionInstructions, reasoningLanguage = 'en-US') {
7
7
  this.agentName = agentName;
8
8
  this.agentCompanyName = agentCompanyName;
9
9
  this.agentCompanyDetails = agentCompanyDetails;
@@ -74,7 +74,7 @@ class AutonomousCustomerServiceAgent extends EventEmitter {
74
74
  unavailabilityMessage = 'We are experiencing a temporary outage. We will contact you as soon as the problem is resolved.',
75
75
  maxVulnerabilityAttempts = 3,
76
76
  temperature = 1,
77
- topP = 0.75,
77
+ topP = 0.95,
78
78
  thinkingLevel = "HIGH",
79
79
  maxOutputTokens = 32_768,
80
80
  } = {}) {
@@ -155,36 +155,36 @@ class AutonomousCustomerServiceAgent extends EventEmitter {
155
155
 
156
156
  /**
157
157
  * Retorna a primeira sessão encontrada para as informações do user.
158
- * @param {object|string} leadFilter Objeto com { name?, phone?, origin? } ou uma string de telefone/nome
158
+ * @param {object|string} filter Objeto com { name?, phone?, origin? } ou uma string de telefone/nome
159
159
  * @returns {object|null}
160
160
  */
161
- getSessionByLead(leadFilter) {
161
+ getSessionByUser(filter) {
162
162
  const session = Array.from(this.#sessions.values()).find((session) => {
163
- if (typeof leadFilter === 'string') {
164
- const normalizedFilter = String(leadFilter).trim().toLowerCase();
165
- const leadName = String(session.user.name || '').trim().toLowerCase();
166
- const leadPhone = this.#normalizePhone(String(session.user.phone || ''));
167
- return leadName === normalizedFilter || leadPhone === this.#normalizePhone(leadFilter);
163
+ if (typeof filter === 'string') {
164
+ const normalizedFilter = String(filter).trim().toLowerCase();
165
+ const userName = String(session.user.name || '').trim().toLowerCase();
166
+ const userPhone = this.#normalizePhone(String(session.user.phone || ''));
167
+ return userName === normalizedFilter || userPhone === this.#normalizePhone(filter);
168
168
  }
169
169
 
170
- if (typeof leadFilter !== 'object' || leadFilter === null) {
170
+ if (typeof filter !== 'object' || filter === null) {
171
171
  return false;
172
172
  }
173
173
 
174
- if (leadFilter.name) {
175
- const normalizedFilter = String(leadFilter.name).trim().toLowerCase();
176
- const leadName = String(session.user.name || '').trim().toLowerCase();
177
- if (leadName !== normalizedFilter) return false;
174
+ if (filter.name) {
175
+ const normalizedFilter = String(filter.name).trim().toLowerCase();
176
+ const userName = String(session.user.name || '').trim().toLowerCase();
177
+ if (userName !== normalizedFilter) return false;
178
178
  }
179
179
 
180
- if (leadFilter.phone) {
181
- if (this.#normalizePhone(String(session.user.phone || '')) !== this.#normalizePhone(String(leadFilter.phone))) {
180
+ if (filter.phone) {
181
+ if (this.#normalizePhone(String(session.user.phone || '')) !== this.#normalizePhone(String(filter.phone))) {
182
182
  return false;
183
183
  }
184
184
  }
185
185
 
186
- if (leadFilter.origin) {
187
- const originFilter = leadFilter.origin;
186
+ if (filter.origin) {
187
+ const originFilter = filter.origin;
188
188
  const sessionOrigin = session.user.origin || {};
189
189
 
190
190
  if (typeof originFilter === 'string') {
@@ -559,11 +559,11 @@ class AutonomousCustomerServiceAgent extends EventEmitter {
559
559
  // ── Helpers ───────────────────────────────────────────────────────────────
560
560
 
561
561
  #emitSemanticEvents(parsed, session) {
562
- // Eventos semânticos baseados na resposta do modelo - Atualmente sem uso, mas podem ser enriquecidos com base nas necessidades de negócio (ex: classificação de leads, detecção de intenções, etc)
562
+ // Eventos semânticos baseados na resposta do modelo - Atualmente sem uso, mas podem ser enriquecidos com base nas necessidades de negócio (ex: classificação de users, detecção de intenções, etc)
563
563
  }
564
564
 
565
565
  /**
566
- * Consciência temporal do Lead:
566
+ * Consciência temporal do User:
567
567
  * Insere de forma explícita na mensagem do usuário a data e hora em que foi recebida.
568
568
  */
569
569
  #buildUserTurn(session, message) {
@@ -781,7 +781,11 @@ class AutonomousCustomerServiceAgent extends EventEmitter {
781
781
  - Creator: Áreum Tecnologia (Software and AI Development Team)
782
782
  </identity>
783
783
 
784
- ${this.#agent.company.name ? `<work_context>
784
+ <language>
785
+ - Reasoning: ${this.#agent.reasoningLanguage || 'en-US'}
786
+ </language>
787
+
788
+ ${this.#agent.company.name ? `<work_context>
785
789
  - Company: ${this.#agent.company.name}
786
790
  - Company Details: ${this.#agent.company.details || 'No additional company details provided.'}
787
791
  </work_context>` : ''}