n8n-nodes-tembory 1.1.3 → 1.1.4
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.
|
@@ -1737,6 +1737,8 @@ const inferUserIntent = (query = '', recentMessages = []) => {
|
|
|
1737
1737
|
return 'operational_status_question';
|
|
1738
1738
|
if (/^(ok|sim|pode|pode sim|isso|isso mesmo|confirmo|confirmar)$/.test(normalizedQuery))
|
|
1739
1739
|
return 'affirm';
|
|
1740
|
+
if (/^(\d{1,2}|\d{1,2}[:h]\d{0,2}|\d{1,2}[/-]\d{1,2}(?:[/-]\d{2,4})?)$/.test(normalizedQuery))
|
|
1741
|
+
return 'selection_or_slot';
|
|
1740
1742
|
if (hasCommitIntent(text))
|
|
1741
1743
|
return 'commit_or_continue';
|
|
1742
1744
|
if (/\b(buscar|busca|criar|cria|atualizar|atualiza|consultar|consulta|reservar|reserva|agendar|agenda|abrir|abre|cancelar|cancela|enviar|envia|gerar|gera|validar|valida|processar|processa|executar|executa)\b/.test(text))
|
|
@@ -1748,7 +1750,7 @@ const inferUserIntent = (query = '', recentMessages = []) => {
|
|
|
1748
1750
|
return 'unknown';
|
|
1749
1751
|
};
|
|
1750
1752
|
const deriveNextExpectedAction = (intent, operationalState = {}) => {
|
|
1751
|
-
if (['affirm', 'commit_or_continue', 'tool_action_candidate'].includes(intent))
|
|
1753
|
+
if (['affirm', 'commit_or_continue', 'tool_action_candidate', 'selection_or_slot'].includes(intent))
|
|
1752
1754
|
return 'continue according to the agent prompt using conversation_frame, tool_state, tool_history and action_ledger; do not apply domain-specific memory rules';
|
|
1753
1755
|
if (intent === 'profile_update')
|
|
1754
1756
|
return 'save stable profile facts and continue the conversation';
|
|
@@ -1756,8 +1758,9 @@ const deriveNextExpectedAction = (intent, operationalState = {}) => {
|
|
|
1756
1758
|
return 'answer directly using conversation_history_chronological/all_user_messages_chronological; do not call tools for recall-only questions';
|
|
1757
1759
|
if (intent === 'operational_status_question')
|
|
1758
1760
|
return 'answer status questions from tool_state, tool_history and action_ledger; do not call tools unless the agent prompt requires it';
|
|
1759
|
-
return '
|
|
1761
|
+
return 'continue according to the agent prompt using retrieved context; call tools when the agent prompt or tool policy requires them';
|
|
1760
1762
|
};
|
|
1763
|
+
const isGenericMemoryNextAction = (value = '') => /answer using retrieved context and avoid unnecessary tool calls|continue according to the agent prompt using retrieved context/i.test(String(value || ''));
|
|
1761
1764
|
const deriveWorkingMemory = ({ query = '', profileFacts = {}, recentMessages = [], toolHistory = [], operationalState = {}, previous = {} }) => {
|
|
1762
1765
|
const intent = inferUserIntent(query, recentMessages);
|
|
1763
1766
|
const lastUser = [...(recentMessages || [])].reverse().find((msg) => /^(user|human)$/i.test(String(msg.role || '')));
|
|
@@ -1767,15 +1770,16 @@ const deriveWorkingMemory = ({ query = '', profileFacts = {}, recentMessages = [
|
|
|
1767
1770
|
activeEntities.push({ type: key, value: profileFacts[key] });
|
|
1768
1771
|
}
|
|
1769
1772
|
const lastTool = toolHistory && toolHistory.length ? toolHistory[toolHistory.length - 1] : null;
|
|
1773
|
+
const nextExpectedAction = deriveNextExpectedAction(intent, operationalState);
|
|
1770
1774
|
return {
|
|
1771
|
-
current_goal: previous.current_goal
|
|
1772
|
-
current_task:
|
|
1775
|
+
current_goal: previous.current_goal && !isGenericMemoryNextAction(previous.current_goal) ? previous.current_goal : nextExpectedAction,
|
|
1776
|
+
current_task: nextExpectedAction,
|
|
1773
1777
|
last_user_intent: intent,
|
|
1774
1778
|
last_user_message: lastUser ? truncate(lastUser.content, 500) : truncate(query, 500),
|
|
1775
1779
|
active_entities: activeEntities,
|
|
1776
1780
|
open_decisions: previous.open_decisions || [],
|
|
1777
1781
|
last_error: lastTool && lastTool.ok === false ? { tool: lastTool.name, at: lastTool.at, result: lastTool.result } : null,
|
|
1778
|
-
next_expected_action:
|
|
1782
|
+
next_expected_action: nextExpectedAction,
|
|
1779
1783
|
updated_at: nowIso(),
|
|
1780
1784
|
};
|
|
1781
1785
|
};
|
package/package.json
CHANGED