n8n-nodes-tembory 1.1.2 → 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.
- package/README.md +2 -2
- package/dist/nodes/Tembory/TemboryMemory.node.js +22 -28
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Node de memoria operacional da Tembory para agentes de IA no n8n.
|
|
4
4
|
|
|
5
|
-
Versao atual: `1.1.
|
|
5
|
+
Versao atual: `1.1.2`.
|
|
6
6
|
|
|
7
|
-
## 1.1.
|
|
7
|
+
## 1.1.2
|
|
8
8
|
|
|
9
9
|
- Torna a entrada `LLM` obrigatoria no node.
|
|
10
10
|
- Remove opcoes visiveis de vetor, grafo e configuracao legada da interface do node.
|
|
@@ -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
|
};
|
|
@@ -2267,30 +2271,15 @@ const wrapTemboryMemory = (memory, ctx, memoryKey) => new Proxy(memory, {
|
|
|
2267
2271
|
const chatHistory = cacheHit
|
|
2268
2272
|
? [{ cached: true, messages: Array.isArray(response[memoryKey] || response.chatHistory) ? (response[memoryKey] || response.chatHistory).length : 0 }]
|
|
2269
2273
|
: snapshotJson(response[memoryKey] || response.chatHistory || []);
|
|
2274
|
+
const messages = Array.isArray(response[memoryKey] || response.chatHistory) ? (response[memoryKey] || response.chatHistory).length : 0;
|
|
2270
2275
|
ctx.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiMemory, index, [
|
|
2271
2276
|
[{
|
|
2272
2277
|
json: {
|
|
2273
2278
|
action: 'loadMemoryVariables',
|
|
2274
2279
|
cached: cacheHit || undefined,
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
summary: response.temborySummary,
|
|
2279
|
-
activeSummary: response.temboryActiveSummary,
|
|
2280
|
-
connectedModelSummary: response.temboryConnectedModelSummary,
|
|
2281
|
-
workingMemory: response.temboryWorkingMemory,
|
|
2282
|
-
decisionState: response.temboryDecisionState,
|
|
2283
|
-
memoryCompression: response.temboryMemoryCompression,
|
|
2284
|
-
profileFacts: response.temboryProfileFacts,
|
|
2285
|
-
operationalState: response.temboryOperationalState,
|
|
2286
|
-
actionLedger: response.temboryActionLedger,
|
|
2287
|
-
entityTimeline: response.temboryEntityTimeline,
|
|
2288
|
-
vectorMemories: response.temboryVectorMemories,
|
|
2289
|
-
graph: response.temboryGraph,
|
|
2290
|
-
recentMessages: response.temboryRecentMessages,
|
|
2291
|
-
recentHighlights: response.temboryRecentHighlights,
|
|
2292
|
-
toolHistory: response.temboryToolHistory,
|
|
2293
|
-
diagnostics: response.temboryDiagnostics,
|
|
2280
|
+
messages,
|
|
2281
|
+
contextQualityScore: response.temboryContextQualityScore,
|
|
2282
|
+
contextStatus: response.temboryContextHealth && response.temboryContextHealth.status,
|
|
2294
2283
|
},
|
|
2295
2284
|
}],
|
|
2296
2285
|
]);
|
|
@@ -2311,7 +2300,15 @@ const wrapTemboryMemory = (memory, ctx, memoryKey) => new Proxy(memory, {
|
|
|
2311
2300
|
const response = await target.saveContext(input, output);
|
|
2312
2301
|
const chatHistory = snapshotJson(await target.chatHistory.getMessages());
|
|
2313
2302
|
ctx.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiMemory, index, [
|
|
2314
|
-
[{
|
|
2303
|
+
[{
|
|
2304
|
+
json: {
|
|
2305
|
+
action: 'saveContext',
|
|
2306
|
+
saved: true,
|
|
2307
|
+
inputChars: JSON.stringify(input || {}).length,
|
|
2308
|
+
outputChars: JSON.stringify(output || {}).length,
|
|
2309
|
+
messages: Array.isArray(chatHistory) ? chatHistory.length : 0,
|
|
2310
|
+
},
|
|
2311
|
+
}],
|
|
2315
2312
|
]);
|
|
2316
2313
|
return response;
|
|
2317
2314
|
}
|
|
@@ -2921,11 +2918,8 @@ class TemboryMemory {
|
|
|
2921
2918
|
}
|
|
2922
2919
|
}
|
|
2923
2920
|
const chatHistory = (result.response[memoryKey] || []).map(toBaseMessage);
|
|
2924
|
-
const extra = { ...(result.response || {}) };
|
|
2925
|
-
delete extra[memoryKey];
|
|
2926
2921
|
currentMessages = chatHistory;
|
|
2927
2922
|
return {
|
|
2928
|
-
...extra,
|
|
2929
2923
|
[memoryKey]: chatHistory,
|
|
2930
2924
|
chatHistory,
|
|
2931
2925
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-tembory",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Tembory node for n8n AI Agents with operational memory, tool history and decision state",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://tembory.com",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"main": "index.js",
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "
|
|
20
|
+
"build": "node --check index.js && node --check dist/credentials/TemboryApi.credentials.js && node --check dist/nodes/Tembory/GenericFunctions.js && node --check dist/nodes/Tembory/TemboryMemory.node.js",
|
|
21
21
|
"dev": "tsc --watch",
|
|
22
22
|
"format": "prettier nodes credentials --write",
|
|
23
23
|
"lint": "tslint -p tsconfig.json -c tslint.json",
|