n8n-nodes-tembory 1.0.14 → 1.0.15
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 +9 -1
- package/dist/nodes/Mem0/Mem0Memory.node.js +207 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
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.15`.
|
|
6
|
+
|
|
7
|
+
## 1.0.15
|
|
8
|
+
|
|
9
|
+
- Reorganiza a interface do node em `Configuração Tembory`, com grupos para Essenciais, Mais Inteligência, Controles Avançados de Busca, Resumo e Estado Persistente, e Diagnóstico e Auditoria.
|
|
10
|
+
- Mantém a coleção legada `Avançado` para compatibilidade com workflows já existentes.
|
|
11
|
+
- Define `Produção Balanceada` como preset padrão para novas configurações.
|
|
12
|
+
- Prioriza IDs estáveis de thread/conversa/contato/cliente antes de `sessionId` na expressão padrão do `ID da Thread`.
|
|
13
|
+
- Adiciona teste para validar a mesclagem dos grupos da nova UI com os presets operacionais.
|
|
6
14
|
|
|
7
15
|
## 1.0.14
|
|
8
16
|
|
|
@@ -883,7 +883,7 @@ const userKeyFrom = (threadId, adv, project = '') => {
|
|
|
883
883
|
return namespace ? `${namespace}::${base}` : base;
|
|
884
884
|
};
|
|
885
885
|
const applyOperationalPreset = (advanced = {}) => {
|
|
886
|
-
const preset = String(advanced.operationPreset || '
|
|
886
|
+
const preset = String(advanced.operationPreset || 'productionBalanced');
|
|
887
887
|
const presets = {
|
|
888
888
|
diagnostic: {
|
|
889
889
|
summarySource: 'auto',
|
|
@@ -1053,6 +1053,30 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1053
1053
|
};
|
|
1054
1054
|
return { ...(presets[preset === 'lab' ? 'diagnostic' : preset] || {}), ...advanced };
|
|
1055
1055
|
};
|
|
1056
|
+
const flattenAdvancedGroups = (groups = {}) => {
|
|
1057
|
+
const flattened = {};
|
|
1058
|
+
const groupNames = ['essentials', 'intelligence', 'retrievalControls', 'summaryState', 'diagnosticsAudit'];
|
|
1059
|
+
for (const groupName of groupNames) {
|
|
1060
|
+
const value = groups === null || groups === void 0 ? void 0 : groups[groupName];
|
|
1061
|
+
const groupValue = Array.isArray(value) ? value[0] : value;
|
|
1062
|
+
if (groupValue && typeof groupValue === 'object')
|
|
1063
|
+
Object.assign(flattened, groupValue);
|
|
1064
|
+
}
|
|
1065
|
+
return flattened;
|
|
1066
|
+
};
|
|
1067
|
+
const readAdvancedOptions = (ctx, itemIndex) => {
|
|
1068
|
+
let legacy = {};
|
|
1069
|
+
let grouped = {};
|
|
1070
|
+
try {
|
|
1071
|
+
legacy = ctx.getNodeParameter('advanced', itemIndex, {}) || {};
|
|
1072
|
+
}
|
|
1073
|
+
catch { }
|
|
1074
|
+
try {
|
|
1075
|
+
grouped = flattenAdvancedGroups(ctx.getNodeParameter('advancedGroups', itemIndex, {}) || {});
|
|
1076
|
+
}
|
|
1077
|
+
catch { }
|
|
1078
|
+
return { ...legacy, ...grouped };
|
|
1079
|
+
};
|
|
1056
1080
|
const pruneByLimit = (items, limit) => items.slice(Math.max(0, items.length - Math.max(1, Number(limit) || 1)));
|
|
1057
1081
|
const dedupeRecentMessages = (items) => {
|
|
1058
1082
|
const seen = new Set();
|
|
@@ -2058,7 +2082,7 @@ class Mem0Memory {
|
|
|
2058
2082
|
displayName: 'ID da Thread',
|
|
2059
2083
|
name: 'threadId',
|
|
2060
2084
|
type: 'string',
|
|
2061
|
-
default: '={{ $json.threadId || $json.
|
|
2085
|
+
default: '={{ $json.threadId || $json.body?.threadId || $json.body?.conversationId || $json.conversationId || $json.body?.messages?.[0]?.contactId || $json.body?.contactId || $json.contactId || $json.customerId || $json.body?.customerId || $json.from || $json.sender || $json.sessionId || $executionId }}',
|
|
2062
2086
|
description: 'Identificador estável desta conversa/thread. Usado como user_id se nenhum User ID explícito for informado.',
|
|
2063
2087
|
},
|
|
2064
2088
|
{
|
|
@@ -2115,11 +2139,186 @@ class Mem0Memory {
|
|
|
2115
2139
|
description: 'Como o contexto recuperado será entregue ao agente antes da LLM.',
|
|
2116
2140
|
},
|
|
2117
2141
|
{
|
|
2118
|
-
displayName: '
|
|
2142
|
+
displayName: 'Configuração Tembory',
|
|
2143
|
+
name: 'advancedGroups',
|
|
2144
|
+
type: 'fixedCollection',
|
|
2145
|
+
placeholder: 'Adicionar Grupo',
|
|
2146
|
+
default: {
|
|
2147
|
+
essentials: {
|
|
2148
|
+
operationPreset: 'productionBalanced',
|
|
2149
|
+
includeContextHeader: true,
|
|
2150
|
+
compactStateSections: true,
|
|
2151
|
+
contextMaxChars: 10000,
|
|
2152
|
+
includeToolHistory: true,
|
|
2153
|
+
includeToolResults: true,
|
|
2154
|
+
includeWorkingMemory: true,
|
|
2155
|
+
includeDecisionState: true,
|
|
2156
|
+
includeOperationalState: true,
|
|
2157
|
+
includeMemoryCompression: true,
|
|
2158
|
+
},
|
|
2159
|
+
intelligence: {
|
|
2160
|
+
includeProfileFacts: true,
|
|
2161
|
+
includeRecentMessages: true,
|
|
2162
|
+
recentMessagesLastN: 6,
|
|
2163
|
+
includeRecentHighlights: true,
|
|
2164
|
+
recentHighlightsMaxItems: 6,
|
|
2165
|
+
includeRelations: true,
|
|
2166
|
+
maxRelations: 10,
|
|
2167
|
+
includeActionLedger: true,
|
|
2168
|
+
includeEntityTimeline: true,
|
|
2169
|
+
},
|
|
2170
|
+
retrievalControls: {
|
|
2171
|
+
topK: 6,
|
|
2172
|
+
rerank: true,
|
|
2173
|
+
lastN: 8,
|
|
2174
|
+
alpha: 0.65,
|
|
2175
|
+
halfLifeHours: 48,
|
|
2176
|
+
maxReturn: 12,
|
|
2177
|
+
mmr: true,
|
|
2178
|
+
mmrLambda: 0.5,
|
|
2179
|
+
},
|
|
2180
|
+
summaryState: {
|
|
2181
|
+
includeSummary: true,
|
|
2182
|
+
includeConnectedModelSummary: true,
|
|
2183
|
+
summarySource: 'auto',
|
|
2184
|
+
connectedModelSummaryInputMaxChars: 4200,
|
|
2185
|
+
connectedModelSummaryMaxChars: 1200,
|
|
2186
|
+
includeActiveSummary: true,
|
|
2187
|
+
persistActiveSummary: true,
|
|
2188
|
+
activeSummaryMaxChars: 1800,
|
|
2189
|
+
activeSummaryRetentionDays: 30,
|
|
2190
|
+
enableTransientSummaryCache: true,
|
|
2191
|
+
transientSummaryCacheTTLSeconds: 300,
|
|
2192
|
+
transientSummaryCacheMaxItems: 50,
|
|
2193
|
+
summaryMaxFacts: 4,
|
|
2194
|
+
},
|
|
2195
|
+
diagnosticsAudit: {
|
|
2196
|
+
includeScores: false,
|
|
2197
|
+
includeDiagnostics: false,
|
|
2198
|
+
persistToolFactsToMem0: false,
|
|
2199
|
+
includeToolHistorySemanticFallback: false,
|
|
2200
|
+
toolHistoryLastN: 10,
|
|
2201
|
+
toolHistoryTTLSeconds: 3600,
|
|
2202
|
+
},
|
|
2203
|
+
},
|
|
2204
|
+
typeOptions: {
|
|
2205
|
+
multipleValues: false,
|
|
2206
|
+
},
|
|
2207
|
+
description: 'Grupos recomendados para producao. Todos os recursos continuam disponiveis, mas separados por finalidade.',
|
|
2208
|
+
options: [
|
|
2209
|
+
{
|
|
2210
|
+
name: 'essentials',
|
|
2211
|
+
displayName: 'Essenciais',
|
|
2212
|
+
values: [
|
|
2213
|
+
{
|
|
2214
|
+
displayName: 'Preset Operacional',
|
|
2215
|
+
name: 'operationPreset',
|
|
2216
|
+
type: 'options',
|
|
2217
|
+
options: [
|
|
2218
|
+
{ name: 'Custom', value: 'custom' },
|
|
2219
|
+
{ name: 'Diagnóstico Completo', value: 'diagnostic' },
|
|
2220
|
+
{ name: 'Produção Balanceada', value: 'productionBalanced' },
|
|
2221
|
+
{ name: 'Produção Econômica', value: 'productionCheap' },
|
|
2222
|
+
{ name: 'Produção Nano/SLM', value: 'productionNano' },
|
|
2223
|
+
{ name: 'Auditoria', value: 'audit' },
|
|
2224
|
+
],
|
|
2225
|
+
default: 'productionBalanced',
|
|
2226
|
+
description: 'Preenche defaults seguros para contexto, historico de tools e memoria ativa.',
|
|
2227
|
+
},
|
|
2228
|
+
{ displayName: 'Incluir Cabeçalho de Contexto', name: 'includeContextHeader', type: 'boolean', default: true },
|
|
2229
|
+
{ displayName: 'Organizar Seções de Produção', name: 'compactStateSections', type: 'boolean', default: true },
|
|
2230
|
+
{ displayName: 'Máximo de Caracteres do Contexto', name: 'contextMaxChars', type: 'number', default: 10000 },
|
|
2231
|
+
{ displayName: 'Incluir Tool History', name: 'includeToolHistory', type: 'boolean', default: true },
|
|
2232
|
+
{ displayName: 'Incluir Resultado Das Tools', name: 'includeToolResults', type: 'boolean', default: true },
|
|
2233
|
+
{ displayName: 'Incluir Working Memory', name: 'includeWorkingMemory', type: 'boolean', default: true },
|
|
2234
|
+
{ displayName: 'Incluir Decision State', name: 'includeDecisionState', type: 'boolean', default: true },
|
|
2235
|
+
{ displayName: 'Incluir Estado Operacional', name: 'includeOperationalState', type: 'boolean', default: true },
|
|
2236
|
+
{ displayName: 'Incluir Compressão de Memória', name: 'includeMemoryCompression', type: 'boolean', default: true },
|
|
2237
|
+
],
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
name: 'intelligence',
|
|
2241
|
+
displayName: 'Mais Inteligência',
|
|
2242
|
+
values: [
|
|
2243
|
+
{ displayName: 'Incluir Profile Facts', name: 'includeProfileFacts', type: 'boolean', default: true },
|
|
2244
|
+
{ displayName: 'Incluir Mensagens Recentes', name: 'includeRecentMessages', type: 'boolean', default: true },
|
|
2245
|
+
{ displayName: 'Últimas N Mensagens', name: 'recentMessagesLastN', type: 'number', default: 6 },
|
|
2246
|
+
{ displayName: 'Incluir Highlights Recentes', name: 'includeRecentHighlights', type: 'boolean', default: true },
|
|
2247
|
+
{ displayName: 'Máximo de Highlights', name: 'recentHighlightsMaxItems', type: 'number', default: 6 },
|
|
2248
|
+
{ displayName: 'Incluir Grafo', name: 'includeRelations', type: 'boolean', default: true },
|
|
2249
|
+
{ displayName: 'Máximo de Relações', name: 'maxRelations', type: 'number', default: 10 },
|
|
2250
|
+
{ displayName: 'Incluir Action Ledger', name: 'includeActionLedger', type: 'boolean', default: true },
|
|
2251
|
+
{ displayName: 'Incluir Entity Timeline', name: 'includeEntityTimeline', type: 'boolean', default: true },
|
|
2252
|
+
],
|
|
2253
|
+
},
|
|
2254
|
+
{
|
|
2255
|
+
name: 'retrievalControls',
|
|
2256
|
+
displayName: 'Controles Avançados de Busca',
|
|
2257
|
+
values: [
|
|
2258
|
+
{ displayName: 'Top K', name: 'topK', type: 'number', typeOptions: { minValue: 1 }, default: 6 },
|
|
2259
|
+
{ displayName: 'Rerank', name: 'rerank', type: 'boolean', default: true },
|
|
2260
|
+
{ displayName: 'Fields (lista separada por vírgula)', name: 'fields', type: 'string', default: '' },
|
|
2261
|
+
{ displayName: 'Filters (JSON)', name: 'filters', type: 'json', default: '{}' },
|
|
2262
|
+
{ displayName: 'Last N (recentes)', name: 'lastN', type: 'number', default: 8 },
|
|
2263
|
+
{ displayName: 'Alpha (peso semântico)', name: 'alpha', type: 'number', typeOptions: { minValue: 0, maxValue: 1, numberPrecision: 2 }, default: 0.65 },
|
|
2264
|
+
{ displayName: 'Half-life (horas)', name: 'halfLifeHours', type: 'number', typeOptions: { minValue: 1 }, default: 48 },
|
|
2265
|
+
{ displayName: 'Máximo a retornar', name: 'maxReturn', type: 'number', typeOptions: { minValue: 1 }, default: 12 },
|
|
2266
|
+
{ displayName: 'MMR (diversidade)', name: 'mmr', type: 'boolean', default: true },
|
|
2267
|
+
{ displayName: 'MMR Lambda', name: 'mmrLambda', type: 'number', typeOptions: { minValue: 0, maxValue: 1, numberPrecision: 2 }, default: 0.5 },
|
|
2268
|
+
{ displayName: 'Compactar Contexto Para Agente', name: 'compactForAgent', type: 'boolean', default: false },
|
|
2269
|
+
],
|
|
2270
|
+
},
|
|
2271
|
+
{
|
|
2272
|
+
name: 'summaryState',
|
|
2273
|
+
displayName: 'Resumo e Estado Persistente',
|
|
2274
|
+
values: [
|
|
2275
|
+
{ displayName: 'Incluir Resumo', name: 'includeSummary', type: 'boolean', default: true },
|
|
2276
|
+
{ displayName: 'Incluir Resumo do SLM', name: 'includeConnectedModelSummary', type: 'boolean', default: true },
|
|
2277
|
+
{
|
|
2278
|
+
displayName: 'Fonte do Resumo do SLM',
|
|
2279
|
+
name: 'summarySource',
|
|
2280
|
+
type: 'options',
|
|
2281
|
+
options: [
|
|
2282
|
+
{ name: 'Automático', value: 'auto' },
|
|
2283
|
+
{ name: 'Contexto Ativo', value: 'activeContext' },
|
|
2284
|
+
{ name: 'Somente Vetores', value: 'vectorOnly' },
|
|
2285
|
+
{ name: 'Desligado', value: 'off' },
|
|
2286
|
+
],
|
|
2287
|
+
default: 'auto',
|
|
2288
|
+
},
|
|
2289
|
+
{ displayName: 'Máximo de Caracteres de Entrada do SLM', name: 'connectedModelSummaryInputMaxChars', type: 'number', default: 4200 },
|
|
2290
|
+
{ displayName: 'Máximo de Caracteres do Resumo do SLM', name: 'connectedModelSummaryMaxChars', type: 'number', default: 1200 },
|
|
2291
|
+
{ displayName: 'Incluir Active Summary', name: 'includeActiveSummary', type: 'boolean', default: true },
|
|
2292
|
+
{ displayName: 'Persistir Active Summary', name: 'persistActiveSummary', type: 'boolean', default: true },
|
|
2293
|
+
{ displayName: 'Máximo de Caracteres do Active Summary', name: 'activeSummaryMaxChars', type: 'number', default: 1800 },
|
|
2294
|
+
{ displayName: 'Retenção do Active Summary (Dias)', name: 'activeSummaryRetentionDays', type: 'number', default: 30 },
|
|
2295
|
+
{ displayName: 'Ativar Cache Técnico do Resumo SLM', name: 'enableTransientSummaryCache', type: 'boolean', default: true },
|
|
2296
|
+
{ displayName: 'TTL do Cache Técnico SLM (Segundos)', name: 'transientSummaryCacheTTLSeconds', type: 'number', default: 300 },
|
|
2297
|
+
{ displayName: 'Máximo de Itens no Cache Técnico SLM', name: 'transientSummaryCacheMaxItems', type: 'number', default: 50 },
|
|
2298
|
+
{ displayName: 'Máximo de Fatos no Resumo', name: 'summaryMaxFacts', type: 'number', default: 4 },
|
|
2299
|
+
],
|
|
2300
|
+
},
|
|
2301
|
+
{
|
|
2302
|
+
name: 'diagnosticsAudit',
|
|
2303
|
+
displayName: 'Diagnóstico e Auditoria',
|
|
2304
|
+
values: [
|
|
2305
|
+
{ displayName: 'Incluir Scores', name: 'includeScores', type: 'boolean', default: false },
|
|
2306
|
+
{ displayName: 'Incluir Diagnóstico', name: 'includeDiagnostics', type: 'boolean', default: false },
|
|
2307
|
+
{ displayName: 'Últimas N Tools', name: 'toolHistoryLastN', type: 'number', default: 10 },
|
|
2308
|
+
{ displayName: 'TTL Das Tools (Segundos)', name: 'toolHistoryTTLSeconds', type: 'number', default: 3600 },
|
|
2309
|
+
{ displayName: 'Persistir Tool Facts no Backend', name: 'persistToolFactsToMem0', type: 'boolean', default: false },
|
|
2310
|
+
{ displayName: 'Fallback Semântico Para Tools', name: 'includeToolHistorySemanticFallback', type: 'boolean', default: false },
|
|
2311
|
+
],
|
|
2312
|
+
},
|
|
2313
|
+
],
|
|
2314
|
+
},
|
|
2315
|
+
{
|
|
2316
|
+
displayName: 'Avançado Legado (Compatibilidade)',
|
|
2119
2317
|
name: 'advanced',
|
|
2120
2318
|
type: 'collection',
|
|
2121
2319
|
placeholder: 'Opções',
|
|
2122
2320
|
default: {},
|
|
2321
|
+
description: 'Campos legados preservados para workflows existentes. Para novas configuracoes, use Configuração Tembory.',
|
|
2123
2322
|
options: [
|
|
2124
2323
|
{ displayName: 'User ID', name: 'userId', type: 'string', default: '' },
|
|
2125
2324
|
{
|
|
@@ -2134,7 +2333,7 @@ class Mem0Memory {
|
|
|
2134
2333
|
{ name: 'Produção Nano/SLM', value: 'productionNano' },
|
|
2135
2334
|
{ name: 'Auditoria', value: 'audit' },
|
|
2136
2335
|
],
|
|
2137
|
-
default: '
|
|
2336
|
+
default: 'productionBalanced',
|
|
2138
2337
|
description: 'Preenche defaults seguros para contexto, diagnostico, historico de tools e mensagens recentes. Valores definidos manualmente continuam tendo prioridade.',
|
|
2139
2338
|
},
|
|
2140
2339
|
{ displayName: 'Agent ID', name: 'agentId', type: 'string', default: '' },
|
|
@@ -2332,7 +2531,7 @@ class Mem0Memory {
|
|
|
2332
2531
|
async saveContextForItem(itemIndex, inputValues = {}, outputValues = {}) {
|
|
2333
2532
|
const threadId = this.getNodeParameter('threadId', itemIndex);
|
|
2334
2533
|
const project = this.getNodeParameter('project', itemIndex, '');
|
|
2335
|
-
const adv = applyOperationalPreset(this
|
|
2534
|
+
const adv = applyOperationalPreset(readAdvancedOptions(this, itemIndex));
|
|
2336
2535
|
const store = getMemoryStore(this);
|
|
2337
2536
|
const key = userKeyFrom(threadId, adv, project);
|
|
2338
2537
|
const input = pickText(inputValues, ['input', 'chatInput', 'text', 'query', 'question']);
|
|
@@ -2536,7 +2735,7 @@ class Mem0Memory {
|
|
|
2536
2735
|
let payloadFormat = this.getNodeParameter('payloadFormat', itemIndex, 'structured');
|
|
2537
2736
|
const threadId = this.getNodeParameter('threadId', itemIndex);
|
|
2538
2737
|
const project = this.getNodeParameter('project', itemIndex, '');
|
|
2539
|
-
const adv = applyOperationalPreset(this
|
|
2738
|
+
const adv = applyOperationalPreset(readAdvancedOptions(this, itemIndex));
|
|
2540
2739
|
payloadFormat = adv.payloadFormat || payloadFormat;
|
|
2541
2740
|
const store = getMemoryStore(this);
|
|
2542
2741
|
const key = userKeyFrom(threadId, adv, project);
|
|
@@ -3080,7 +3279,7 @@ class Mem0Memory {
|
|
|
3080
3279
|
const retrievalMode = this.getNodeParameter('retrievalMode', i);
|
|
3081
3280
|
const threadId = this.getNodeParameter('threadId', i);
|
|
3082
3281
|
const project = this.getNodeParameter('project', i, '');
|
|
3083
|
-
const adv = applyOperationalPreset(this
|
|
3282
|
+
const adv = applyOperationalPreset(readAdvancedOptions(this, i));
|
|
3084
3283
|
const key = userKeyFrom(threadId, adv, project);
|
|
3085
3284
|
const query = asSearchQuery(this.getNodeParameter('query', i, ''));
|
|
3086
3285
|
const connectedEmbedding = await getConnectedEmbedding(this, i);
|
|
@@ -3162,6 +3361,7 @@ exports.__private = {
|
|
|
3162
3361
|
encodeRecentMessage,
|
|
3163
3362
|
userKeyFrom,
|
|
3164
3363
|
applyOperationalPreset,
|
|
3364
|
+
flattenAdvancedGroups,
|
|
3165
3365
|
asSearchQuery,
|
|
3166
3366
|
canonicalToolInput,
|
|
3167
3367
|
buildContextMessages,
|
package/package.json
CHANGED