@menuia/core 1.5.0 → 1.5.2
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/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.mjs +9 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -63,6 +63,15 @@ interface ChatResponse {
|
|
|
63
63
|
toolsUsed: string[];
|
|
64
64
|
tokensUsed: number;
|
|
65
65
|
ticketId?: string;
|
|
66
|
+
/**
|
|
67
|
+
* `true` quando a IA NAO respondeu de proposito: um atendente assumiu a conversa, o widget
|
|
68
|
+
* esta em modo humano, o canal esta com a resposta automatica desligada ou o plano venceu.
|
|
69
|
+
* Nesse caso `message` vem VAZIA — a mensagem do visitante foi recebida e esta no inbox,
|
|
70
|
+
* aguardando uma pessoa. O servidor sempre mandou este campo; faltava tipa-lo.
|
|
71
|
+
*/
|
|
72
|
+
aiPaused?: boolean;
|
|
73
|
+
/** Enquanto a IA consulta a equipe: ate quando esperar por uma resposta. */
|
|
74
|
+
aiCheckingUntil?: string;
|
|
66
75
|
};
|
|
67
76
|
}
|
|
68
77
|
interface StreamEvent {
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,15 @@ interface ChatResponse {
|
|
|
63
63
|
toolsUsed: string[];
|
|
64
64
|
tokensUsed: number;
|
|
65
65
|
ticketId?: string;
|
|
66
|
+
/**
|
|
67
|
+
* `true` quando a IA NAO respondeu de proposito: um atendente assumiu a conversa, o widget
|
|
68
|
+
* esta em modo humano, o canal esta com a resposta automatica desligada ou o plano venceu.
|
|
69
|
+
* Nesse caso `message` vem VAZIA — a mensagem do visitante foi recebida e esta no inbox,
|
|
70
|
+
* aguardando uma pessoa. O servidor sempre mandou este campo; faltava tipa-lo.
|
|
71
|
+
*/
|
|
72
|
+
aiPaused?: boolean;
|
|
73
|
+
/** Enquanto a IA consulta a equipe: ate quando esperar por uma resposta. */
|
|
74
|
+
aiCheckingUntil?: string;
|
|
66
75
|
};
|
|
67
76
|
}
|
|
68
77
|
interface StreamEvent {
|
package/dist/index.js
CHANGED
|
@@ -63,6 +63,7 @@ var MenuIAClient = class {
|
|
|
63
63
|
this.session.started = true;
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
+
let sessaoRecusada = null;
|
|
66
67
|
try {
|
|
67
68
|
const response = await fetch(`${this.config.apiUrl}/widget/${this.config.widgetId}/session`, {
|
|
68
69
|
method: "POST",
|
|
@@ -99,9 +100,17 @@ var MenuIAClient = class {
|
|
|
99
100
|
}));
|
|
100
101
|
this.lastMessageCount = this.session.messages.length;
|
|
101
102
|
}
|
|
103
|
+
} else {
|
|
104
|
+
sessaoRecusada = response.status;
|
|
102
105
|
}
|
|
103
106
|
} catch {
|
|
104
107
|
}
|
|
108
|
+
if (sessaoRecusada) {
|
|
109
|
+
this.config.onError?.(new Error(
|
|
110
|
+
sessaoRecusada === 401 ? "Este chat exige autenticacao e o token de sessao nao foi aceito. Peca um token novo ao seu servidor." : `Nao foi possivel abrir a sessao do chat (HTTP ${sessaoRecusada}).`
|
|
111
|
+
));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
105
114
|
this.session.started = true;
|
|
106
115
|
this.saveSession();
|
|
107
116
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -37,6 +37,7 @@ var MenuIAClient = class {
|
|
|
37
37
|
this.session.started = true;
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
+
let sessaoRecusada = null;
|
|
40
41
|
try {
|
|
41
42
|
const response = await fetch(`${this.config.apiUrl}/widget/${this.config.widgetId}/session`, {
|
|
42
43
|
method: "POST",
|
|
@@ -73,9 +74,17 @@ var MenuIAClient = class {
|
|
|
73
74
|
}));
|
|
74
75
|
this.lastMessageCount = this.session.messages.length;
|
|
75
76
|
}
|
|
77
|
+
} else {
|
|
78
|
+
sessaoRecusada = response.status;
|
|
76
79
|
}
|
|
77
80
|
} catch {
|
|
78
81
|
}
|
|
82
|
+
if (sessaoRecusada) {
|
|
83
|
+
this.config.onError?.(new Error(
|
|
84
|
+
sessaoRecusada === 401 ? "Este chat exige autenticacao e o token de sessao nao foi aceito. Peca um token novo ao seu servidor." : `Nao foi possivel abrir a sessao do chat (HTTP ${sessaoRecusada}).`
|
|
85
|
+
));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
79
88
|
this.session.started = true;
|
|
80
89
|
this.saveSession();
|
|
81
90
|
}
|