n8n-nodes-tembory 1.0.38 → 1.0.40
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.
|
@@ -1113,8 +1113,50 @@ const userKeyFrom = (threadId, adv, project = '') => {
|
|
|
1113
1113
|
return namespace ? `${namespace}::${base}` : base;
|
|
1114
1114
|
};
|
|
1115
1115
|
const applyOperationalPreset = (advanced = {}) => {
|
|
1116
|
-
const preset = String(advanced.operationPreset || '
|
|
1116
|
+
const preset = String(advanced.operationPreset || 'productionFast');
|
|
1117
1117
|
const presets = {
|
|
1118
|
+
productionFast: {
|
|
1119
|
+
summarySource: 'activeContext',
|
|
1120
|
+
includeConnectedModelSummary: true,
|
|
1121
|
+
includeActiveSummary: true,
|
|
1122
|
+
persistActiveSummary: true,
|
|
1123
|
+
activeSummaryMaxChars: 1800,
|
|
1124
|
+
activeSummaryRetentionDays: 30,
|
|
1125
|
+
enableTransientSummaryCache: true,
|
|
1126
|
+
transientSummaryCacheTTLSeconds: 300,
|
|
1127
|
+
compactStateSections: true,
|
|
1128
|
+
useVectorMemory: false,
|
|
1129
|
+
persistBackendMemories: true,
|
|
1130
|
+
includeRecentMessageProbe: false,
|
|
1131
|
+
includeToolLedgerProbe: false,
|
|
1132
|
+
includeContextHeader: true,
|
|
1133
|
+
includeSummary: true,
|
|
1134
|
+
includeScores: false,
|
|
1135
|
+
includeDiagnostics: false,
|
|
1136
|
+
includeRelations: false,
|
|
1137
|
+
includeToolHistory: true,
|
|
1138
|
+
includeToolResults: true,
|
|
1139
|
+
persistToolFactsToMem0: false,
|
|
1140
|
+
includeToolHistorySemanticFallback: false,
|
|
1141
|
+
includeProfileFacts: true,
|
|
1142
|
+
includeOperationalState: true,
|
|
1143
|
+
includeActionLedger: true,
|
|
1144
|
+
includeEntityTimeline: false,
|
|
1145
|
+
includeWorkingMemory: true,
|
|
1146
|
+
includeDecisionState: true,
|
|
1147
|
+
includeMemoryCompression: true,
|
|
1148
|
+
includeRecentMessages: true,
|
|
1149
|
+
includeRecentHighlights: false,
|
|
1150
|
+
topK: 0,
|
|
1151
|
+
lastN: 0,
|
|
1152
|
+
maxReturn: 0,
|
|
1153
|
+
toolHistoryLastN: 15,
|
|
1154
|
+
recentMessagesLastN: 50,
|
|
1155
|
+
vectorMemoryMaxChars: 220,
|
|
1156
|
+
contextMaxChars: 9000,
|
|
1157
|
+
connectedModelSummaryMaxChars: 1200,
|
|
1158
|
+
connectedModelSummaryInputMaxChars: 4200,
|
|
1159
|
+
},
|
|
1118
1160
|
diagnostic: {
|
|
1119
1161
|
summarySource: 'auto',
|
|
1120
1162
|
includeConnectedModelSummary: true,
|
|
@@ -1689,13 +1731,13 @@ const deriveContextHealth = ({ userId = '', project = '', vectorMemories = [], r
|
|
|
1689
1731
|
namespace_stable: Boolean(userId && !/^mcp-session-\d+$/i.test(String(userId))),
|
|
1690
1732
|
has_recent_messages: Array.isArray(recentMessages) && recentMessages.length > 0,
|
|
1691
1733
|
has_tool_history: Array.isArray(toolHistory) && toolHistory.length > 0,
|
|
1692
|
-
has_vector_memories: Array.isArray(vectorMemories) && vectorMemories.length > 0,
|
|
1734
|
+
has_vector_memories: diagnostics.vectorMemoryEnabled === false ? true : Array.isArray(vectorMemories) && vectorMemories.length > 0,
|
|
1693
1735
|
has_working_memory: Boolean(workingMemory && Object.keys(workingMemory).length),
|
|
1694
1736
|
has_decision_state: Boolean(decisionState && Object.keys(decisionState).length),
|
|
1695
1737
|
has_memory_compression: Boolean(memoryCompression && Object.keys(memoryCompression).length),
|
|
1696
1738
|
has_operational_state: Boolean(operationalState && Object.keys(operationalState).length),
|
|
1697
1739
|
connected_language_model: Boolean(diagnostics.connectedAi && diagnostics.connectedAi.languageModel),
|
|
1698
|
-
connected_embedding: Boolean(diagnostics.connectedAi && diagnostics.connectedAi.embedding),
|
|
1740
|
+
connected_embedding: diagnostics.vectorMemoryEnabled === false ? true : Boolean(diagnostics.connectedAi && diagnostics.connectedAi.embedding),
|
|
1699
1741
|
no_connected_ai_errors: !((diagnostics.connectedAi && diagnostics.connectedAi.errors) || []).length,
|
|
1700
1742
|
};
|
|
1701
1743
|
const weights = {
|
|
@@ -2523,12 +2565,13 @@ class Mem0Memory {
|
|
|
2523
2565
|
options: [
|
|
2524
2566
|
{ name: 'Custom', value: 'custom' },
|
|
2525
2567
|
{ name: 'Diagnóstico Completo', value: 'diagnostic' },
|
|
2568
|
+
{ name: 'Produção Rápida (Thread + SLM)', value: 'productionFast' },
|
|
2526
2569
|
{ name: 'Produção Balanceada', value: 'productionBalanced' },
|
|
2527
2570
|
{ name: 'Produção Econômica', value: 'productionCheap' },
|
|
2528
2571
|
{ name: 'Produção Nano/SLM', value: 'productionNano' },
|
|
2529
2572
|
{ name: 'Auditoria', value: 'audit' },
|
|
2530
2573
|
],
|
|
2531
|
-
default: '
|
|
2574
|
+
default: 'productionFast',
|
|
2532
2575
|
description: 'Preenche defaults seguros para contexto, historico de tools e memoria ativa.',
|
|
2533
2576
|
},
|
|
2534
2577
|
{ displayName: 'Incluir Cabeçalho de Contexto', name: 'includeContextHeader', type: 'boolean', default: true },
|
|
@@ -2555,6 +2598,10 @@ class Mem0Memory {
|
|
|
2555
2598
|
{ displayName: 'Máximo de Relações', name: 'maxRelations', type: 'number', default: 10 },
|
|
2556
2599
|
{ displayName: 'Incluir Action Ledger', name: 'includeActionLedger', type: 'boolean', default: true },
|
|
2557
2600
|
{ displayName: 'Incluir Entity Timeline', name: 'includeEntityTimeline', type: 'boolean', default: true },
|
|
2601
|
+
{ displayName: 'Usar Memória Vetorial no Caminho Quente', name: 'useVectorMemory', type: 'boolean', default: false },
|
|
2602
|
+
{ displayName: 'Persistir Memórias no Backend', name: 'persistBackendMemories', type: 'boolean', default: false },
|
|
2603
|
+
{ displayName: 'Probe Vetorial de Mensagens Recentes', name: 'includeRecentMessageProbe', type: 'boolean', default: false },
|
|
2604
|
+
{ displayName: 'Probe Vetorial de Tool Ledger', name: 'includeToolLedgerProbe', type: 'boolean', default: false },
|
|
2558
2605
|
],
|
|
2559
2606
|
},
|
|
2560
2607
|
{
|
|
@@ -2635,18 +2682,21 @@ class Mem0Memory {
|
|
|
2635
2682
|
options: [
|
|
2636
2683
|
{ name: 'Custom', value: 'custom' },
|
|
2637
2684
|
{ name: 'Diagnóstico Completo', value: 'diagnostic' },
|
|
2685
|
+
{ name: 'Produção Rápida (Thread + SLM)', value: 'productionFast' },
|
|
2638
2686
|
{ name: 'Produção Balanceada', value: 'productionBalanced' },
|
|
2639
2687
|
{ name: 'Produção Econômica', value: 'productionCheap' },
|
|
2640
2688
|
{ name: 'Produção Nano/SLM', value: 'productionNano' },
|
|
2641
2689
|
{ name: 'Auditoria', value: 'audit' },
|
|
2642
2690
|
],
|
|
2643
|
-
default: '
|
|
2691
|
+
default: 'productionFast',
|
|
2644
2692
|
description: 'Preenche defaults seguros para contexto, diagnostico, historico de tools e mensagens recentes. Valores definidos manualmente continuam tendo prioridade.',
|
|
2645
2693
|
},
|
|
2646
2694
|
{ displayName: 'Agent ID', name: 'agentId', type: 'string', default: '' },
|
|
2647
2695
|
{ displayName: 'App ID', name: 'appId', type: 'string', default: '' },
|
|
2648
2696
|
{ displayName: 'Run ID', name: 'runId', type: 'string', default: '' },
|
|
2649
2697
|
{ displayName: 'Top K', name: 'topK', type: 'number', typeOptions: { minValue: 1 }, default: 25, description: 'Quantidade de memórias a recuperar (modos semânticos e limites de recentes)' },
|
|
2698
|
+
{ displayName: 'Usar Memória Vetorial no Caminho Quente', name: 'useVectorMemory', type: 'boolean', default: false, description: 'Quando desligado, o padrão usa thread estruturada, tools e SLM sem buscar/vetorizar a cada turno.' },
|
|
2699
|
+
{ displayName: 'Persistir Memórias no Backend', name: 'persistBackendMemories', type: 'boolean', default: false, description: 'Quando desligado, mantém o estado no workflow/static data para reduzir latência.' },
|
|
2650
2700
|
{ displayName: 'Rerank', name: 'rerank', type: 'boolean', default: true, description: 'Reordenação por relevância (modos semânticos)', displayOptions: { show: { '/retrievalMode': ['semantic', 'semanticV2', 'hybrid'] } } },
|
|
2651
2701
|
{ displayName: 'Fields (lista separada por vírgula)', name: 'fields', type: 'string', default: '', description: 'Campos específicos a retornar da API (modos semânticos)', displayOptions: { show: { '/retrievalMode': ['semantic', 'semanticV2', 'hybrid'] } } },
|
|
2652
2702
|
{ displayName: 'Filters (JSON)', name: 'filters', type: 'json', default: '{}', description: 'Objeto de filtros avançados para busca v2', displayOptions: { show: { '/retrievalMode': ['semanticV2', 'hybrid'] } } },
|
|
@@ -2945,6 +2995,8 @@ class Mem0Memory {
|
|
|
2945
2995
|
if (!messages.length)
|
|
2946
2996
|
return;
|
|
2947
2997
|
const body = { messages };
|
|
2998
|
+
if (adv.useVectorMemory === false)
|
|
2999
|
+
body.infer = false;
|
|
2948
3000
|
body.user_id = key;
|
|
2949
3001
|
if (adv.agentId)
|
|
2950
3002
|
body.agent_id = String(adv.agentId);
|
|
@@ -2952,7 +3004,9 @@ class Mem0Memory {
|
|
|
2952
3004
|
body.app_id = String(adv.appId);
|
|
2953
3005
|
if (adv.runId)
|
|
2954
3006
|
body.run_id = String(adv.runId);
|
|
2955
|
-
|
|
3007
|
+
if (adv.persistBackendMemories === false)
|
|
3008
|
+
return;
|
|
3009
|
+
const connectedEmbedding = adv.useVectorMemory === false ? null : await getConnectedEmbedding(this, itemIndex);
|
|
2956
3010
|
if (connectedEmbedding) {
|
|
2957
3011
|
const ids = { user_id: body.user_id, agent_id: body.agent_id, run_id: body.run_id };
|
|
2958
3012
|
const clientMemories = [];
|
|
@@ -3220,6 +3274,8 @@ class Mem0Memory {
|
|
|
3220
3274
|
const project = this.getNodeParameter('project', itemIndex, '');
|
|
3221
3275
|
const adv = applyOperationalPreset(readAdvancedOptions(this, itemIndex));
|
|
3222
3276
|
payloadFormat = adv.payloadFormat || payloadFormat;
|
|
3277
|
+
const vectorMemoryEnabled = adv.useVectorMemory !== false;
|
|
3278
|
+
const backendPersistenceEnabled = adv.persistBackendMemories !== false;
|
|
3223
3279
|
const store = getMemoryStore(this);
|
|
3224
3280
|
const key = userKeyFrom(threadId, adv, project);
|
|
3225
3281
|
const queryParam = this.getNodeParameter('query', itemIndex, '');
|
|
@@ -3240,12 +3296,14 @@ class Mem0Memory {
|
|
|
3240
3296
|
catch (error) {
|
|
3241
3297
|
connectedAi.errors.push(`languageModel: ${error.message || String(error)}`);
|
|
3242
3298
|
}
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3299
|
+
if (vectorMemoryEnabled) {
|
|
3300
|
+
try {
|
|
3301
|
+
connectedEmbedding = await this.getInputConnectionData(n8n_workflow_1.NodeConnectionTypes.AiEmbedding, itemIndex);
|
|
3302
|
+
connectedAi.embedding = true;
|
|
3303
|
+
}
|
|
3304
|
+
catch (error) {
|
|
3305
|
+
connectedAi.errors.push(`embedding: ${error.message || String(error)}`);
|
|
3306
|
+
}
|
|
3249
3307
|
}
|
|
3250
3308
|
if (connectedEmbedding && typeof connectedEmbedding.embedQuery === 'function' && String(query || '').trim()) {
|
|
3251
3309
|
try {
|
|
@@ -3267,7 +3325,7 @@ class Mem0Memory {
|
|
|
3267
3325
|
catch { }
|
|
3268
3326
|
let payload;
|
|
3269
3327
|
let vectorMemories = [];
|
|
3270
|
-
if (retrievalMode === 'semantic' || retrievalMode === 'semanticV2' || retrievalMode === 'hybrid') {
|
|
3328
|
+
if (vectorMemoryEnabled && (retrievalMode === 'semantic' || retrievalMode === 'semanticV2' || retrievalMode === 'hybrid')) {
|
|
3271
3329
|
const body = { query: String(query || '') };
|
|
3272
3330
|
// IDs
|
|
3273
3331
|
body.user_id = key;
|
|
@@ -3404,7 +3462,7 @@ class Mem0Memory {
|
|
|
3404
3462
|
payload = semMemories.map((m) => { var _a, _b; return ({ role: 'system', content: (_b = (_a = m.memory) !== null && _a !== void 0 ? _a : m.text) !== null && _b !== void 0 ? _b : JSON.stringify(m) }); });
|
|
3405
3463
|
}
|
|
3406
3464
|
}
|
|
3407
|
-
else {
|
|
3465
|
+
else if (backendPersistenceEnabled) {
|
|
3408
3466
|
const qs = {};
|
|
3409
3467
|
qs.user_id = key;
|
|
3410
3468
|
if (adv.agentId)
|
|
@@ -3440,7 +3498,7 @@ class Mem0Memory {
|
|
|
3440
3498
|
connectedAi.errors.push(`graph.relations: ${error.message || String(error)}`);
|
|
3441
3499
|
}
|
|
3442
3500
|
}
|
|
3443
|
-
if (connectedEmbedding && adv.includeRecentMessages !== false) {
|
|
3501
|
+
if (vectorMemoryEnabled && connectedEmbedding && adv.includeRecentMessages !== false && adv.includeRecentMessageProbe !== false) {
|
|
3444
3502
|
try {
|
|
3445
3503
|
const transcriptProbe = [
|
|
3446
3504
|
'recent conversation transcript',
|
|
@@ -3475,7 +3533,7 @@ class Mem0Memory {
|
|
|
3475
3533
|
connectedAi.errors.push(`recentMessageProbe: ${error.message || String(error)}`);
|
|
3476
3534
|
}
|
|
3477
3535
|
}
|
|
3478
|
-
if (connectedEmbedding && adv.includeToolHistory !== false) {
|
|
3536
|
+
if (vectorMemoryEnabled && connectedEmbedding && adv.includeToolHistory !== false && adv.includeToolLedgerProbe !== false) {
|
|
3479
3537
|
try {
|
|
3480
3538
|
const toolProbe = [
|
|
3481
3539
|
'Tool history ledger',
|
|
@@ -3513,7 +3571,7 @@ class Mem0Memory {
|
|
|
3513
3571
|
let persistedRecentMessages = [];
|
|
3514
3572
|
let persistedToolHistory = [];
|
|
3515
3573
|
let persistedMemoryItems = [];
|
|
3516
|
-
if (adv.includeRecentMessages !== false || adv.includeToolHistory !== false) {
|
|
3574
|
+
if (backendPersistenceEnabled && (adv.includeRecentMessages !== false || adv.includeToolHistory !== false)) {
|
|
3517
3575
|
try {
|
|
3518
3576
|
const qs = { user_id: key, limit: Math.max(Number(adv.recentMessagesLastN || 50) * 8, Number(adv.toolHistoryLastN || 10) * 12, 200) };
|
|
3519
3577
|
if (adv.agentId)
|
|
@@ -3660,6 +3718,8 @@ class Mem0Memory {
|
|
|
3660
3718
|
graph: graph.length,
|
|
3661
3719
|
project: project || null,
|
|
3662
3720
|
memoryNamespace: key,
|
|
3721
|
+
vectorMemoryEnabled,
|
|
3722
|
+
backendPersistenceEnabled,
|
|
3663
3723
|
captureState: store.captureState[key] || {
|
|
3664
3724
|
last_save_at: null,
|
|
3665
3725
|
last_save_had_input: false,
|
package/package.json
CHANGED