n8n-nodes-tembory 1.0.58 → 1.1.0
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 +1 -1
- package/dist/credentials/{Mem0Api.credentials.d.ts → TemboryApi.credentials.d.ts} +1 -1
- package/dist/credentials/{Mem0Api.credentials.js → TemboryApi.credentials.js} +4 -4
- package/dist/nodes/Tembory/GenericFunctions.d.ts +3 -0
- package/dist/nodes/{Mem0 → Tembory}/GenericFunctions.js +3 -3
- package/dist/nodes/{Mem0/Mem0Memory.node.d.ts → Tembory/TemboryMemory.node.d.ts} +1 -1
- package/dist/nodes/{Mem0/Mem0Memory.node.js → Tembory/TemboryMemory.node.js} +48 -48
- package/package.json +3 -3
- package/scripts/simulate-agent-context.js +1 -1
- package/scripts/simulate-n8n-agent-agenda.js +1 -1
- package/scripts/smoke-n8n-multiturn-tools.js +1 -1
- package/dist/nodes/Mem0/GenericFunctions.d.ts +0 -3
- /package/dist/nodes/{Mem0 → Tembory}/tembory-brain.svg +0 -0
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ Versao atual: `1.0.31`.
|
|
|
62
62
|
## 1.0.22
|
|
63
63
|
|
|
64
64
|
- Corrige persistencia do transcript quando ha embedding conectado: mensagens recentes tambem sao gravadas como markers estruturados em `/v1/memories/`.
|
|
65
|
-
- Persiste tool history estruturado por padrao quando `includeToolHistory` esta ativo, mesmo sem `
|
|
65
|
+
- Persiste tool history estruturado por padrao quando `includeToolHistory` esta ativo, mesmo sem `persistToolFactsToTembory`.
|
|
66
66
|
- Resolve falha real em n8n onde cada execucao carregava apenas a mensagem atual no `Conversation frame`.
|
|
67
67
|
|
|
68
68
|
## 1.0.21
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class TemboryApi implements ICredentialType {
|
|
3
3
|
name: string;
|
|
4
4
|
displayName: string;
|
|
5
5
|
documentationUrl: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.TemboryApi = void 0;
|
|
4
|
+
class TemboryApi {
|
|
5
5
|
constructor() {
|
|
6
|
-
this.name = '
|
|
6
|
+
this.name = 'temboryApi';
|
|
7
7
|
this.displayName = 'Tembory API';
|
|
8
8
|
this.documentationUrl = 'https://tembory.com';
|
|
9
9
|
this.properties = [
|
|
@@ -34,4 +34,4 @@ class Mem0Api {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
exports.
|
|
37
|
+
exports.TemboryApi = TemboryApi;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IExecuteFunctions, ILoadOptionsFunctions, IHookFunctions, IWebhookFunctions, IHttpRequestMethods } from 'n8n-workflow';
|
|
2
|
+
export declare function temboryApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: IHttpRequestMethods, endpoint: string, body?: any, qs?: any): Promise<any>;
|
|
3
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.temboryApiRequest = temboryApiRequest;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
async function
|
|
6
|
-
const credentials = await this.getCredentials('
|
|
5
|
+
async function temboryApiRequest(method, endpoint, body = {}, qs = {}) {
|
|
6
|
+
const credentials = await this.getCredentials('temboryApi');
|
|
7
7
|
const baseUrl = 'https://api.tembory.com';
|
|
8
8
|
const operation = resolveGatewayOperation(method, endpoint);
|
|
9
9
|
const payload = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ISupplyDataFunctions, IExecuteFunctions, INodeType, INodeTypeDescription, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class TemboryMemory implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<{
|
|
5
5
|
response: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TemboryMemory = void 0;
|
|
4
4
|
const GenericFunctions_1 = require("./GenericFunctions");
|
|
5
5
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
6
|
let LangChainMessages = {};
|
|
@@ -53,7 +53,7 @@ const saveClientVectorMemories = async (ctx, memories, ids = {}) => {
|
|
|
53
53
|
const valid = memories.filter((memory) => String(memory === null || memory === void 0 ? void 0 : memory.text || '').trim());
|
|
54
54
|
if (!valid.length)
|
|
55
55
|
return null;
|
|
56
|
-
return GenericFunctions_1.
|
|
56
|
+
return GenericFunctions_1.temboryApiRequest.call(ctx, 'POST', '/tembory/v1/vector-memories', {
|
|
57
57
|
memories: valid,
|
|
58
58
|
user_id: ids.user_id,
|
|
59
59
|
agent_id: ids.agent_id,
|
|
@@ -64,7 +64,7 @@ const searchClientVectorMemories = async (ctx, embedding, query, body = {}) => {
|
|
|
64
64
|
const text = String(query || '').trim();
|
|
65
65
|
if (!text)
|
|
66
66
|
return { results: [] };
|
|
67
|
-
return GenericFunctions_1.
|
|
67
|
+
return GenericFunctions_1.temboryApiRequest.call(ctx, 'POST', '/tembory/v1/vector-memories/search', {
|
|
68
68
|
...body,
|
|
69
69
|
query: text,
|
|
70
70
|
embedding: await embedQueryCached(embedding, text),
|
|
@@ -72,7 +72,7 @@ const searchClientVectorMemories = async (ctx, embedding, query, body = {}) => {
|
|
|
72
72
|
};
|
|
73
73
|
const safePersistLegacyMemory = async (ctx, body, diagnostics = {}) => {
|
|
74
74
|
try {
|
|
75
|
-
return await GenericFunctions_1.
|
|
75
|
+
return await GenericFunctions_1.temboryApiRequest.call(ctx, 'POST', '/v1/memories/', body);
|
|
76
76
|
}
|
|
77
77
|
catch (error) {
|
|
78
78
|
try {
|
|
@@ -695,7 +695,7 @@ const parseToolHistoryMarker = (text) => {
|
|
|
695
695
|
ok: parsed.ok !== false,
|
|
696
696
|
result: truncate(parsed.result || '', 1000),
|
|
697
697
|
at: parsed.at || nowIso(),
|
|
698
|
-
source: parsed.source || '
|
|
698
|
+
source: parsed.source || 'tembory_marker',
|
|
699
699
|
};
|
|
700
700
|
}
|
|
701
701
|
catch {
|
|
@@ -1187,7 +1187,7 @@ const userKeyFrom = (threadId, adv, project = '') => {
|
|
|
1187
1187
|
};
|
|
1188
1188
|
const loadThreadState = async (ctx, key, threadId, project) => {
|
|
1189
1189
|
try {
|
|
1190
|
-
const res = await GenericFunctions_1.
|
|
1190
|
+
const res = await GenericFunctions_1.temboryApiRequest.call(ctx, 'GET', '/v1/tembory/thread-state/load', {}, {
|
|
1191
1191
|
user_id: key,
|
|
1192
1192
|
thread_id: threadId,
|
|
1193
1193
|
project: project || undefined,
|
|
@@ -1200,7 +1200,7 @@ const loadThreadState = async (ctx, key, threadId, project) => {
|
|
|
1200
1200
|
};
|
|
1201
1201
|
const saveThreadState = async (ctx, key, threadId, project, state) => {
|
|
1202
1202
|
try {
|
|
1203
|
-
await GenericFunctions_1.
|
|
1203
|
+
await GenericFunctions_1.temboryApiRequest.call(ctx, 'POST', '/v1/tembory/thread-state', {
|
|
1204
1204
|
user_id: key,
|
|
1205
1205
|
thread_id: threadId,
|
|
1206
1206
|
project: project || undefined,
|
|
@@ -1255,7 +1255,7 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1255
1255
|
includeRelations: false,
|
|
1256
1256
|
includeToolHistory: true,
|
|
1257
1257
|
includeToolResults: true,
|
|
1258
|
-
|
|
1258
|
+
persistToolFactsToTembory: false,
|
|
1259
1259
|
includeToolHistorySemanticFallback: false,
|
|
1260
1260
|
includeProfileFacts: true,
|
|
1261
1261
|
includeOperationalState: true,
|
|
@@ -1286,7 +1286,7 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1286
1286
|
includeRelations: false,
|
|
1287
1287
|
includeToolHistory: true,
|
|
1288
1288
|
includeToolResults: true,
|
|
1289
|
-
|
|
1289
|
+
persistToolFactsToTembory: true,
|
|
1290
1290
|
includeToolHistorySemanticFallback: true,
|
|
1291
1291
|
includeProfileFacts: true,
|
|
1292
1292
|
includeOperationalState: true,
|
|
@@ -1320,7 +1320,7 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1320
1320
|
includeRelations: false,
|
|
1321
1321
|
includeToolHistory: true,
|
|
1322
1322
|
includeToolResults: true,
|
|
1323
|
-
|
|
1323
|
+
persistToolFactsToTembory: false,
|
|
1324
1324
|
includeToolHistorySemanticFallback: false,
|
|
1325
1325
|
includeProfileFacts: true,
|
|
1326
1326
|
includeOperationalState: true,
|
|
@@ -1358,7 +1358,7 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1358
1358
|
includeRelations: false,
|
|
1359
1359
|
includeToolHistory: true,
|
|
1360
1360
|
includeToolResults: false,
|
|
1361
|
-
|
|
1361
|
+
persistToolFactsToTembory: false,
|
|
1362
1362
|
includeToolHistorySemanticFallback: false,
|
|
1363
1363
|
includeProfileFacts: true,
|
|
1364
1364
|
includeOperationalState: true,
|
|
@@ -1395,7 +1395,7 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1395
1395
|
includeRelations: false,
|
|
1396
1396
|
includeToolHistory: true,
|
|
1397
1397
|
includeToolResults: true,
|
|
1398
|
-
|
|
1398
|
+
persistToolFactsToTembory: false,
|
|
1399
1399
|
includeToolHistorySemanticFallback: false,
|
|
1400
1400
|
includeProfileFacts: true,
|
|
1401
1401
|
includeOperationalState: true,
|
|
@@ -1426,7 +1426,7 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1426
1426
|
includeRelations: false,
|
|
1427
1427
|
includeToolHistory: true,
|
|
1428
1428
|
includeToolResults: true,
|
|
1429
|
-
|
|
1429
|
+
persistToolFactsToTembory: true,
|
|
1430
1430
|
includeToolHistorySemanticFallback: true,
|
|
1431
1431
|
includeProfileFacts: true,
|
|
1432
1432
|
includeOperationalState: true,
|
|
@@ -2637,7 +2637,7 @@ const buildContextMessages = ({ payloadFormat, query, userId, profileFacts, work
|
|
|
2637
2637
|
}
|
|
2638
2638
|
return [{ role: 'system', content: truncate(text, maxChars) }];
|
|
2639
2639
|
};
|
|
2640
|
-
class
|
|
2640
|
+
class TemboryMemory {
|
|
2641
2641
|
constructor() {
|
|
2642
2642
|
this.description = {
|
|
2643
2643
|
displayName: 'Tembory',
|
|
@@ -2666,7 +2666,7 @@ class Mem0Memory {
|
|
|
2666
2666
|
},
|
|
2667
2667
|
credentials: [
|
|
2668
2668
|
{
|
|
2669
|
-
name: '
|
|
2669
|
+
name: 'temboryApi',
|
|
2670
2670
|
required: true,
|
|
2671
2671
|
},
|
|
2672
2672
|
],
|
|
@@ -2846,7 +2846,7 @@ class Mem0Memory {
|
|
|
2846
2846
|
{ displayName: 'Incluir Diagnóstico', name: 'includeDiagnostics', type: 'boolean', default: false },
|
|
2847
2847
|
{ displayName: 'Últimas N Tools', name: 'toolHistoryLastN', type: 'number', default: 10 },
|
|
2848
2848
|
{ displayName: 'TTL Das Tools (Segundos)', name: 'toolHistoryTTLSeconds', type: 'number', default: 3600 },
|
|
2849
|
-
{ displayName: 'Persistir Tool Facts no Backend', name: '
|
|
2849
|
+
{ displayName: 'Persistir Tool Facts no Backend', name: 'persistToolFactsToTembory', type: 'boolean', default: false },
|
|
2850
2850
|
{ displayName: 'Fallback Semântico Para Tools', name: 'includeToolHistorySemanticFallback', type: 'boolean', default: false },
|
|
2851
2851
|
],
|
|
2852
2852
|
},
|
|
@@ -2930,7 +2930,7 @@ class Mem0Memory {
|
|
|
2930
2930
|
{ displayName: 'Incluir Resultado Das Tools', name: 'includeToolResults', type: 'boolean', default: true },
|
|
2931
2931
|
{ displayName: 'Últimas N Tools', name: 'toolHistoryLastN', type: 'number', default: 15 },
|
|
2932
2932
|
{ displayName: 'TTL Das Tools (Segundos)', name: 'toolHistoryTTLSeconds', type: 'number', default: 3600 },
|
|
2933
|
-
{ displayName: 'Persistir Tool Facts no Backend', name: '
|
|
2933
|
+
{ displayName: 'Persistir Tool Facts no Backend', name: 'persistToolFactsToTembory', type: 'boolean', default: false },
|
|
2934
2934
|
{ displayName: 'Fallback Semântico Para Tools', name: 'includeToolHistorySemanticFallback', type: 'boolean', default: false, description: 'Usa memórias vetoriais para tentar inferir histórico de tools quando não houver eventos estruturados. Útil em laboratório, não recomendado como fonte primária em produção.' },
|
|
2935
2935
|
{ displayName: 'Incluir Profile Facts', name: 'includeProfileFacts', type: 'boolean', default: true, description: 'Extrai e injeta fatos estáveis do lead/cliente como nome, empresa, email, telefone, preferências, interesses e contexto comercial.' },
|
|
2936
2936
|
{ displayName: 'Incluir Working Memory', name: 'includeWorkingMemory', type: 'boolean', default: true, description: 'Injeta objetivo atual, intenção recente, entidades ativas, último erro e próxima ação esperada.' },
|
|
@@ -2975,24 +2975,24 @@ class Mem0Memory {
|
|
|
2975
2975
|
getMessages: async () => currentMessages,
|
|
2976
2976
|
addMessage: async (message) => {
|
|
2977
2977
|
currentMessages.push(message);
|
|
2978
|
-
const saved = await
|
|
2978
|
+
const saved = await TemboryMemory.prototype.saveMessagesForItem.call(this, itemIndex, [message]);
|
|
2979
2979
|
recordMemoryEvent('chatHistory.addMessage', { saved: Boolean(saved && saved.saved), toolCalls: (saved && saved.toolCalls) || [], messages: 1 });
|
|
2980
2980
|
},
|
|
2981
2981
|
addUserMessage: async (message) => {
|
|
2982
2982
|
const baseMessage = toBaseMessage({ role: 'user', content: message });
|
|
2983
2983
|
currentMessages.push(baseMessage);
|
|
2984
|
-
const saved = await
|
|
2984
|
+
const saved = await TemboryMemory.prototype.saveMessagesForItem.call(this, itemIndex, [baseMessage]);
|
|
2985
2985
|
recordMemoryEvent('chatHistory.addUserMessage', { saved: Boolean(saved && saved.saved), toolCalls: (saved && saved.toolCalls) || [], messages: 1 });
|
|
2986
2986
|
},
|
|
2987
2987
|
addAIChatMessage: async (message) => {
|
|
2988
2988
|
const baseMessage = toBaseMessage({ role: 'assistant', content: message });
|
|
2989
2989
|
currentMessages.push(baseMessage);
|
|
2990
|
-
const saved = await
|
|
2990
|
+
const saved = await TemboryMemory.prototype.saveMessagesForItem.call(this, itemIndex, [baseMessage]);
|
|
2991
2991
|
recordMemoryEvent('chatHistory.addAIChatMessage', { saved: Boolean(saved && saved.saved), toolCalls: (saved && saved.toolCalls) || [], messages: 1 });
|
|
2992
2992
|
},
|
|
2993
2993
|
addMessages: async (messages) => {
|
|
2994
2994
|
currentMessages.push(...messages);
|
|
2995
|
-
const saved = await
|
|
2995
|
+
const saved = await TemboryMemory.prototype.saveMessagesForItem.call(this, itemIndex, messages);
|
|
2996
2996
|
recordMemoryEvent('chatHistory.addMessages', { saved: Boolean(saved && saved.saved), toolCalls: (saved && saved.toolCalls) || [], messages: Array.isArray(messages) ? messages.length : 0 });
|
|
2997
2997
|
},
|
|
2998
2998
|
clear: async () => {
|
|
@@ -3025,7 +3025,7 @@ class Mem0Memory {
|
|
|
3025
3025
|
delete result.response.temboryContextText;
|
|
3026
3026
|
}
|
|
3027
3027
|
else {
|
|
3028
|
-
result = await
|
|
3028
|
+
result = await TemboryMemory.prototype.loadMemoryVariablesForItem.call(this, itemIndex, inputValues);
|
|
3029
3029
|
loadCache.set(cacheKey, snapshotJson(result));
|
|
3030
3030
|
if (loadCache.size > 20) {
|
|
3031
3031
|
const firstKey = loadCache.keys().next().value;
|
|
@@ -3050,7 +3050,7 @@ class Mem0Memory {
|
|
|
3050
3050
|
currentMessages.push(toBaseMessage({ role: 'user', content: input }));
|
|
3051
3051
|
if (output)
|
|
3052
3052
|
currentMessages.push(toBaseMessage({ role: 'assistant', content: output }));
|
|
3053
|
-
await
|
|
3053
|
+
await TemboryMemory.prototype.saveContextForItem.call(this, itemIndex, inputValues, outputValues);
|
|
3054
3054
|
},
|
|
3055
3055
|
};
|
|
3056
3056
|
return { response: wrapTemboryMemory(memory, this, memoryKey) };
|
|
@@ -3079,7 +3079,7 @@ class Mem0Memory {
|
|
|
3079
3079
|
if (toolContext.length)
|
|
3080
3080
|
outputValues.__temboryToolCalls = toolContext;
|
|
3081
3081
|
if (inputValues.input || outputValues.output || toolContext.length) {
|
|
3082
|
-
await
|
|
3082
|
+
await TemboryMemory.prototype.saveContextForItem.call(this, itemIndex, inputValues, outputValues);
|
|
3083
3083
|
return { saved: true, input: inputValues, output: outputValues, toolCalls: toolContext };
|
|
3084
3084
|
}
|
|
3085
3085
|
return { saved: false, input: inputValues, output: outputValues, toolCalls: toolContext };
|
|
@@ -3102,7 +3102,7 @@ class Mem0Memory {
|
|
|
3102
3102
|
last_save_tool_names: toolCalls.map((tool) => tool.name).filter(Boolean).slice(0, 20),
|
|
3103
3103
|
last_save_capture_sources: Array.from(new Set(toolCalls.map((tool) => tool.source).filter(Boolean))),
|
|
3104
3104
|
};
|
|
3105
|
-
const
|
|
3105
|
+
const recentForTembory = [];
|
|
3106
3106
|
const profileFromTurn = extractProfileFactsFromText(input, 'user_message', nowIso());
|
|
3107
3107
|
if (Object.keys(profileFromTurn).length) {
|
|
3108
3108
|
store.profileFacts[key] = mergeProfileFacts(store.profileFacts[key], profileFromTurn);
|
|
@@ -3126,12 +3126,12 @@ class Mem0Memory {
|
|
|
3126
3126
|
if (input) {
|
|
3127
3127
|
const item = { role: 'user', content: truncate(input, 2000), at: nowIso() };
|
|
3128
3128
|
recent.push(item);
|
|
3129
|
-
|
|
3129
|
+
recentForTembory.push(item);
|
|
3130
3130
|
}
|
|
3131
3131
|
if (output) {
|
|
3132
3132
|
const item = { role: 'assistant', content: truncate(output, 2000), at: nowIso() };
|
|
3133
3133
|
recent.push(item);
|
|
3134
|
-
|
|
3134
|
+
recentForTembory.push(item);
|
|
3135
3135
|
}
|
|
3136
3136
|
store.recentMessages[key] = pruneByLimit(recent, adv.recentMessagesLastN || 8);
|
|
3137
3137
|
try {
|
|
@@ -3231,8 +3231,8 @@ class Mem0Memory {
|
|
|
3231
3231
|
latest_tool: toolHistoryForTurn.at(-1)?.name || null,
|
|
3232
3232
|
}, ids),
|
|
3233
3233
|
], ids);
|
|
3234
|
-
if (adv.includeRecentMessages !== false &&
|
|
3235
|
-
for (const recent of
|
|
3234
|
+
if (adv.includeRecentMessages !== false && recentForTembory.length) {
|
|
3235
|
+
for (const recent of recentForTembory) {
|
|
3236
3236
|
await safePersistLegacyMemory(this, {
|
|
3237
3237
|
messages: [{ role: 'system', content: encodeRecentMessage(recent, threadId) }],
|
|
3238
3238
|
infer: false,
|
|
@@ -3320,10 +3320,10 @@ class Mem0Memory {
|
|
|
3320
3320
|
return;
|
|
3321
3321
|
}
|
|
3322
3322
|
if (messages.length)
|
|
3323
|
-
await GenericFunctions_1.
|
|
3324
|
-
if (adv.includeRecentMessages !== false &&
|
|
3325
|
-
for (const recent of
|
|
3326
|
-
await GenericFunctions_1.
|
|
3323
|
+
await GenericFunctions_1.temboryApiRequest.call(this, 'POST', '/v1/memories/', body);
|
|
3324
|
+
if (adv.includeRecentMessages !== false && recentForTembory.length) {
|
|
3325
|
+
for (const recent of recentForTembory) {
|
|
3326
|
+
await GenericFunctions_1.temboryApiRequest.call(this, 'POST', '/v1/memories/', {
|
|
3327
3327
|
messages: [{ role: 'system', content: encodeRecentMessage(recent, threadId) }],
|
|
3328
3328
|
infer: false,
|
|
3329
3329
|
user_id: body.user_id,
|
|
@@ -3339,7 +3339,7 @@ class Mem0Memory {
|
|
|
3339
3339
|
},
|
|
3340
3340
|
});
|
|
3341
3341
|
}
|
|
3342
|
-
await GenericFunctions_1.
|
|
3342
|
+
await GenericFunctions_1.temboryApiRequest.call(this, 'POST', '/v1/memories/', {
|
|
3343
3343
|
messages: [{ role: 'system', content: encodeConversationLedger(recentForTurn, threadId) }],
|
|
3344
3344
|
infer: false,
|
|
3345
3345
|
user_id: body.user_id,
|
|
@@ -3354,9 +3354,9 @@ class Mem0Memory {
|
|
|
3354
3354
|
},
|
|
3355
3355
|
});
|
|
3356
3356
|
}
|
|
3357
|
-
if (adv.includeToolHistory !== false && !adv.
|
|
3357
|
+
if (adv.includeToolHistory !== false && !adv.persistToolFactsToTembory && toolCalls.length) {
|
|
3358
3358
|
for (const tool of toolCalls) {
|
|
3359
|
-
await GenericFunctions_1.
|
|
3359
|
+
await GenericFunctions_1.temboryApiRequest.call(this, 'POST', '/v1/memories/', {
|
|
3360
3360
|
messages: [{ role: 'system', content: encodeToolCall(tool, threadId) }],
|
|
3361
3361
|
infer: false,
|
|
3362
3362
|
user_id: body.user_id,
|
|
@@ -3378,7 +3378,7 @@ class Mem0Memory {
|
|
|
3378
3378
|
},
|
|
3379
3379
|
});
|
|
3380
3380
|
}
|
|
3381
|
-
await GenericFunctions_1.
|
|
3381
|
+
await GenericFunctions_1.temboryApiRequest.call(this, 'POST', '/v1/memories/', {
|
|
3382
3382
|
messages: [{ role: 'system', content: encodeToolLedger(toolHistoryForTurn, threadId) }],
|
|
3383
3383
|
infer: false,
|
|
3384
3384
|
user_id: body.user_id,
|
|
@@ -3393,16 +3393,16 @@ class Mem0Memory {
|
|
|
3393
3393
|
},
|
|
3394
3394
|
});
|
|
3395
3395
|
}
|
|
3396
|
-
if (adv.
|
|
3396
|
+
if (adv.persistToolFactsToTembory && toolCalls.length) {
|
|
3397
3397
|
const facts = toolCalls.map((tool) => `Tool ${tool.name} input=${tool.input}${tool.result ? ` result=${tool.result}` : ''}`).join('\n');
|
|
3398
|
-
await GenericFunctions_1.
|
|
3398
|
+
await GenericFunctions_1.temboryApiRequest.call(this, 'POST', '/v1/memories/', {
|
|
3399
3399
|
messages: [{ role: 'system', content: `Tool facts (read-only):\n${truncate(facts, 2000)}` }],
|
|
3400
3400
|
infer: false,
|
|
3401
3401
|
user_id: body.user_id,
|
|
3402
3402
|
metadata: { kind: 'tool_facts' },
|
|
3403
3403
|
});
|
|
3404
3404
|
for (const tool of toolCalls) {
|
|
3405
|
-
await GenericFunctions_1.
|
|
3405
|
+
await GenericFunctions_1.temboryApiRequest.call(this, 'POST', '/v1/memories/', {
|
|
3406
3406
|
messages: [{ role: 'system', content: encodeToolCall(tool, threadId) }],
|
|
3407
3407
|
infer: false,
|
|
3408
3408
|
user_id: body.user_id,
|
|
@@ -3513,7 +3513,7 @@ class Mem0Memory {
|
|
|
3513
3513
|
const semRes = hasQuery && connectedEmbedding
|
|
3514
3514
|
? await searchClientVectorMemories(this, connectedEmbedding, query, body)
|
|
3515
3515
|
: hasQuery
|
|
3516
|
-
? await GenericFunctions_1.
|
|
3516
|
+
? await GenericFunctions_1.temboryApiRequest.call(this, 'POST', url, body)
|
|
3517
3517
|
: { results: [] };
|
|
3518
3518
|
let semMemories = normalizeResults(semRes);
|
|
3519
3519
|
if (retrievalMode === 'hybrid' || !hasQuery) {
|
|
@@ -3526,7 +3526,7 @@ class Mem0Memory {
|
|
|
3526
3526
|
qs.app_id = String(adv.appId);
|
|
3527
3527
|
if (adv.runId)
|
|
3528
3528
|
qs.run_id = String(adv.runId);
|
|
3529
|
-
const recRes = await GenericFunctions_1.
|
|
3529
|
+
const recRes = await GenericFunctions_1.temboryApiRequest.call(this, 'GET', '/v1/memories/', {}, qs);
|
|
3530
3530
|
let recents = normalizeResults(recRes);
|
|
3531
3531
|
const lastN = Number((_a = adv.lastN) !== null && _a !== void 0 ? _a : 20);
|
|
3532
3532
|
if (lastN > 0)
|
|
@@ -3628,7 +3628,7 @@ class Mem0Memory {
|
|
|
3628
3628
|
qs.app_id = String(adv.appId);
|
|
3629
3629
|
if (adv.runId)
|
|
3630
3630
|
qs.run_id = String(adv.runId);
|
|
3631
|
-
const res = await GenericFunctions_1.
|
|
3631
|
+
const res = await GenericFunctions_1.temboryApiRequest.call(this, 'GET', '/v1/memories/', {}, qs);
|
|
3632
3632
|
let memories = normalizeResults(res);
|
|
3633
3633
|
// lastN limit
|
|
3634
3634
|
if (adv.lastN && Number(adv.lastN) > 0)
|
|
@@ -3648,7 +3648,7 @@ class Mem0Memory {
|
|
|
3648
3648
|
let graph = [];
|
|
3649
3649
|
if (adv.includeRelations !== false) {
|
|
3650
3650
|
try {
|
|
3651
|
-
const entityRes = await GenericFunctions_1.
|
|
3651
|
+
const entityRes = await GenericFunctions_1.temboryApiRequest.call(this, 'GET', '/entities/relations', {}, { user_id: key, agent_id: adv.agentId || undefined, run_id: adv.runId || undefined, limit: Number(adv.maxRelations || 10) });
|
|
3652
3652
|
graph = normalizeResults(entityRes).slice(0, Number(adv.maxRelations || 10));
|
|
3653
3653
|
}
|
|
3654
3654
|
catch (error) {
|
|
@@ -3735,7 +3735,7 @@ class Mem0Memory {
|
|
|
3735
3735
|
qs.agent_id = String(adv.agentId);
|
|
3736
3736
|
if (adv.runId)
|
|
3737
3737
|
qs.run_id = String(adv.runId);
|
|
3738
|
-
const persistedRes = await GenericFunctions_1.
|
|
3738
|
+
const persistedRes = await GenericFunctions_1.temboryApiRequest.call(this, 'GET', '/v1/memories/', {}, qs);
|
|
3739
3739
|
persistedMemoryItems = normalizeResults(persistedRes);
|
|
3740
3740
|
}
|
|
3741
3741
|
catch (error) {
|
|
@@ -4092,7 +4092,7 @@ class Mem0Memory {
|
|
|
4092
4092
|
const url = retrievalMode === 'semanticV2' ? '/v2/memories/search/' : '/v1/memories/search/';
|
|
4093
4093
|
const res = connectedEmbedding
|
|
4094
4094
|
? await searchClientVectorMemories(this, connectedEmbedding, query, body)
|
|
4095
|
-
: await GenericFunctions_1.
|
|
4095
|
+
: await GenericFunctions_1.temboryApiRequest.call(this, 'POST', url, body);
|
|
4096
4096
|
const memories = Array.isArray(res) ? res : [res];
|
|
4097
4097
|
payload = memories.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) }); });
|
|
4098
4098
|
}
|
|
@@ -4105,7 +4105,7 @@ class Mem0Memory {
|
|
|
4105
4105
|
qs.app_id = String(adv.appId);
|
|
4106
4106
|
if (adv.runId)
|
|
4107
4107
|
qs.run_id = String(adv.runId);
|
|
4108
|
-
const res = await GenericFunctions_1.
|
|
4108
|
+
const res = await GenericFunctions_1.temboryApiRequest.call(this, 'GET', '/v1/memories/', {}, qs);
|
|
4109
4109
|
let memories = Array.isArray(res) ? res : [res];
|
|
4110
4110
|
if (adv.lastN && Number(adv.lastN) > 0)
|
|
4111
4111
|
memories = memories.slice(-Number(adv.lastN));
|
|
@@ -4127,7 +4127,7 @@ class Mem0Memory {
|
|
|
4127
4127
|
return [returnData];
|
|
4128
4128
|
}
|
|
4129
4129
|
}
|
|
4130
|
-
exports.
|
|
4130
|
+
exports.TemboryMemory = TemboryMemory;
|
|
4131
4131
|
exports.__private = {
|
|
4132
4132
|
extractToolCallsFromText,
|
|
4133
4133
|
extractToolCalls,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-tembory",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"n8n": {
|
|
39
39
|
"n8nNodesApiVersion": 1,
|
|
40
40
|
"credentials": [
|
|
41
|
-
"dist/credentials/
|
|
41
|
+
"dist/credentials/TemboryApi.credentials.js"
|
|
42
42
|
],
|
|
43
43
|
"nodes": [
|
|
44
|
-
"dist/nodes/
|
|
44
|
+
"dist/nodes/Tembory/TemboryMemory.node.js"
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
@@ -23,7 +23,7 @@ Module._load = function patchedLoad(request, parent, isMain) {
|
|
|
23
23
|
return originalLoad.call(this, request, parent, isMain);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const core = require('../dist/nodes/
|
|
26
|
+
const core = require('../dist/nodes/Tembory/TemboryMemory.node.js').__private;
|
|
27
27
|
|
|
28
28
|
const toolHistory = [
|
|
29
29
|
{
|
|
@@ -26,7 +26,7 @@ Module._load = function patchedLoad(request, parent, isMain) {
|
|
|
26
26
|
return originalLoad.call(this, request, parent, isMain);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const core = require('../dist/nodes/
|
|
29
|
+
const core = require('../dist/nodes/Tembory/TemboryMemory.node.js').__private;
|
|
30
30
|
|
|
31
31
|
const BASE_TIME = Date.parse('2026-05-16T12:00:00.000Z');
|
|
32
32
|
|
|
@@ -26,7 +26,7 @@ Module._load = function patchedLoad(request, parent, isMain) {
|
|
|
26
26
|
return originalLoad.call(this, request, parent, isMain);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const core = require('../dist/nodes/
|
|
29
|
+
const core = require('../dist/nodes/Tembory/TemboryMemory.node.js').__private;
|
|
30
30
|
|
|
31
31
|
const turns = [
|
|
32
32
|
{
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { IExecuteFunctions, ILoadOptionsFunctions, IHookFunctions, IWebhookFunctions, IHttpRequestMethods } from 'n8n-workflow';
|
|
2
|
-
export declare function mem0ApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: IHttpRequestMethods, endpoint: string, body?: any, qs?: any): Promise<any>;
|
|
3
|
-
|
|
File without changes
|