n8n-nodes-tembory 1.0.30 → 1.0.31
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 +7 -1
- package/dist/nodes/Mem0/Mem0Memory.node.js +27 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Node de memoria operacional da Tembory para agentes de IA no n8n.
|
|
4
4
|
|
|
5
|
-
Versao atual: `1.0.
|
|
5
|
+
Versao atual: `1.0.31`.
|
|
6
|
+
|
|
7
|
+
## 1.0.31
|
|
8
|
+
|
|
9
|
+
- Considera pre-reserva recente no transcript como estado operacional valido quando `tool_history` ainda nao foi recuperado no turno.
|
|
10
|
+
- Evita chamar `agenda_pre_reservar_horario` novamente antes de confirmar quando a mensagem recente ja diz que houve pre-reserva.
|
|
11
|
+
- Direciona confirmacoes como "pode confirmar" direto para `agenda_confirmar_agendamento` quando existe pre-reserva recente pendente.
|
|
6
12
|
|
|
7
13
|
## 1.0.30
|
|
8
14
|
|
|
@@ -427,6 +427,25 @@ const availabilityFromRecentMessages = (recentMessages = []) => {
|
|
|
427
427
|
source: latest.source || 'recent_message',
|
|
428
428
|
};
|
|
429
429
|
};
|
|
430
|
+
const preReservationFromRecentMessages = (recentMessages = []) => {
|
|
431
|
+
const messages = Array.isArray(recentMessages) ? recentMessages : [];
|
|
432
|
+
const candidates = [...messages].reverse().filter((message) => {
|
|
433
|
+
const role = String(message.role || '').toLowerCase();
|
|
434
|
+
const text = String(message.content || message.text || message.memory || '');
|
|
435
|
+
if (role && role !== 'assistant' && role !== 'ai' && role !== 'system')
|
|
436
|
+
return false;
|
|
437
|
+
return /\b(pr[eé][-\s]?reservad[oa]|pre[-\s]?reservad[oa]|reservation_id|RES-[A-Z0-9-]+)\b/i.test(text)
|
|
438
|
+
&& !/\b(confirmad[oa]|confirmation_id|CONF-[A-Z0-9-]+)\b/i.test(text);
|
|
439
|
+
});
|
|
440
|
+
const latest = candidates[0];
|
|
441
|
+
if (!latest)
|
|
442
|
+
return null;
|
|
443
|
+
return {
|
|
444
|
+
text: truncate(String(latest.content || latest.text || latest.memory || ''), 900),
|
|
445
|
+
at: latest.at || latest.created_at || latest.createdAt || nowIso(),
|
|
446
|
+
source: latest.source || 'recent_message',
|
|
447
|
+
};
|
|
448
|
+
};
|
|
430
449
|
const deriveOperationalState = (toolHistory = [], profileFacts = {}, recentMessages = [], includeResults = true) => {
|
|
431
450
|
const tools = Array.isArray(toolHistory) ? toolHistory : [];
|
|
432
451
|
const successfulTools = tools.filter((tool) => tool.ok !== false);
|
|
@@ -435,15 +454,17 @@ const deriveOperationalState = (toolHistory = [], profileFacts = {}, recentMessa
|
|
|
435
454
|
const recentAvailability = availability.length ? null : availabilityFromRecentMessages(recentMessages);
|
|
436
455
|
const hasAvailability = availability.length > 0 || Boolean(recentAvailability);
|
|
437
456
|
const reservations = byName('agenda_pre_reservar_horario');
|
|
457
|
+
const recentPreReservation = reservations.length ? null : preReservationFromRecentMessages(recentMessages);
|
|
458
|
+
const hasPreReservation = reservations.length > 0 || Boolean(recentPreReservation);
|
|
438
459
|
const confirmations = byName('agenda_confirmar_agendamento');
|
|
439
460
|
const lastTool = tools[tools.length - 1] || null;
|
|
440
461
|
const lastReservation = reservations[reservations.length - 1] || null;
|
|
441
462
|
const lastConfirmation = confirmations[confirmations.length - 1] || null;
|
|
442
|
-
const hasPendingReservation = Boolean(lastReservation && (!lastConfirmation || String(lastReservation.at || '') > String(lastConfirmation.at || '')));
|
|
463
|
+
const hasPendingReservation = Boolean((lastReservation && (!lastConfirmation || String(lastReservation.at || '') > String(lastConfirmation.at || ''))) || (recentPreReservation && !lastConfirmation));
|
|
443
464
|
const blockedWithoutContext = [];
|
|
444
465
|
if (!hasAvailability)
|
|
445
466
|
blockedWithoutContext.push('agenda_pre_reservar_horario');
|
|
446
|
-
if (!
|
|
467
|
+
if (!hasPreReservation)
|
|
447
468
|
blockedWithoutContext.push('agenda_confirmar_agendamento');
|
|
448
469
|
const guidance = [];
|
|
449
470
|
if (!hasAvailability)
|
|
@@ -467,12 +488,13 @@ const deriveOperationalState = (toolHistory = [], profileFacts = {}, recentMessa
|
|
|
467
488
|
},
|
|
468
489
|
agenda_state: {
|
|
469
490
|
has_availability: hasAvailability,
|
|
470
|
-
has_pre_reservation:
|
|
491
|
+
has_pre_reservation: hasPreReservation,
|
|
471
492
|
has_confirmation: confirmations.length > 0,
|
|
472
493
|
has_pending_pre_reservation: hasPendingReservation,
|
|
473
494
|
latest_availability_result: availability.length ? maybeToolResult(availability[availability.length - 1], includeResults) : (recentAvailability && includeResults !== false ? recentAvailability.text : null),
|
|
474
495
|
latest_availability_source: availability.length ? 'tool_history' : (recentAvailability ? recentAvailability.source : null),
|
|
475
|
-
latest_pre_reservation_result: lastReservation ? maybeToolResult(lastReservation, includeResults) : null,
|
|
496
|
+
latest_pre_reservation_result: lastReservation ? maybeToolResult(lastReservation, includeResults) : (recentPreReservation && includeResults !== false ? recentPreReservation.text : null),
|
|
497
|
+
latest_pre_reservation_source: lastReservation ? 'tool_history' : (recentPreReservation ? recentPreReservation.source : null),
|
|
476
498
|
latest_confirmation_result: lastConfirmation ? maybeToolResult(lastConfirmation, includeResults) : null,
|
|
477
499
|
},
|
|
478
500
|
blocked_without_context: Array.from(new Set(blockedWithoutContext)),
|
|
@@ -3691,6 +3713,7 @@ exports.__private = {
|
|
|
3691
3713
|
toolHistoryFromMemory,
|
|
3692
3714
|
cleanAssistantTranscriptText,
|
|
3693
3715
|
availabilityFromRecentMessages,
|
|
3716
|
+
preReservationFromRecentMessages,
|
|
3694
3717
|
buildActionDirective,
|
|
3695
3718
|
recentMessageFromMemory,
|
|
3696
3719
|
previousUserFallbackFromWorkingMemory,
|
package/package.json
CHANGED