n8n-nodes-tembory 1.0.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 +75 -0
- package/dist/credentials/Mem0Api.credentials.d.ts +10 -0
- package/dist/credentials/Mem0Api.credentials.js +52 -0
- package/dist/credentials/Mem0SelfHostedApi.credentials.d.ts +10 -0
- package/dist/credentials/Mem0SelfHostedApi.credentials.js +45 -0
- package/dist/nodes/Mem0/GenericFunctions.d.ts +3 -0
- package/dist/nodes/Mem0/GenericFunctions.js +48 -0
- package/dist/nodes/Mem0/Mem0Memory.node.d.ts +15 -0
- package/dist/nodes/Mem0/Mem0Memory.node.js +2564 -0
- package/dist/nodes/Mem0/tembory-brain.svg +23 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +70 -0
- package/scripts/smoke-n8n-multiturn-tools.js +138 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Tembory
|
|
2
|
+
|
|
3
|
+
Node de memoria operacional da Tembory para agentes de IA no n8n.
|
|
4
|
+
|
|
5
|
+
Versao atual: `1.0.0`.
|
|
6
|
+
|
|
7
|
+
O Tembory entrega contexto rico para o AI Agent sem depender apenas do historico textual da conversa. Ele combina memoria semantica, working memory, decision state, fatos estaveis do lead, historico de tools, estado operacional, action ledger, timeline de entidades, compressao de memoria, grafo, mensagens recentes e diagnosticos.
|
|
8
|
+
|
|
9
|
+
## Smoke tecnico
|
|
10
|
+
|
|
11
|
+
Antes de publicar uma versao, rode:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm run smoke:n8n:multiturn
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
O smoke simula 12 trocas com tools de agenda, valida tool history, working memory, decision state, memory compression e exige `contextHealth` com score minimo de `970/1000`.
|
|
18
|
+
|
|
19
|
+
## Principais recursos
|
|
20
|
+
|
|
21
|
+
- Porta `ai_memory` para conectar direto no AI Agent do n8n.
|
|
22
|
+
- Campo `Projeto` para isolar memórias por cliente/workspace mesmo quando a origem repete o mesmo ID de conversa.
|
|
23
|
+
- Entradas opcionais `ai_languageModel` e `ai_embedding` para usar os modelos conectados pelo cliente no proprio n8n.
|
|
24
|
+
- Profile facts: nome, empresa, email, telefone, preferencias e contexto comercial.
|
|
25
|
+
- Tool history: quais tools foram chamadas, quando, com qual status e resultado.
|
|
26
|
+
- Tool guard: bloqueia acoes dependentes quando falta contexto previo.
|
|
27
|
+
- Working memory: objetivo atual, intencao recente, entidades ativas, ultimo erro e proxima acao esperada.
|
|
28
|
+
- Decision state: decisoes ativas, ferramentas que nao devem ser repetidas e politica de resolucao de conflitos.
|
|
29
|
+
- Operational state: resumo deterministico do estado atual das tools e do proximo passo seguro.
|
|
30
|
+
- Action ledger: linha cronologica das acoes executadas pelo agente.
|
|
31
|
+
- Entity timeline: evolucao compacta de entidades, fatos, relacoes e eventos relevantes.
|
|
32
|
+
- Memory compression: resumos de turno, sessao, entidades e workflow para reduzir ruido e aproximar o contexto do comportamento do ChatGPT/Codex.
|
|
33
|
+
- Vector memories com scores, recent messages, highlights, graph e resumo.
|
|
34
|
+
|
|
35
|
+
## Custo de IA
|
|
36
|
+
|
|
37
|
+
O node nao fornece LLM nem embedding gerenciados pela Tembory. Todo uso de LLM e embedding deve vir dos nodes/modelos conectados no cluster do n8n do cliente. O backend do Tembory armazena e consulta os vetores recebidos prontos.
|
|
38
|
+
|
|
39
|
+
## Presets operacionais
|
|
40
|
+
|
|
41
|
+
O campo avancado `Preset Operacional` preenche defaults sem sobrescrever valores configurados manualmente:
|
|
42
|
+
|
|
43
|
+
- `Custom`: comportamento manual.
|
|
44
|
+
- `Diagnóstico Completo`: diagnostico completo para teste e auditoria.
|
|
45
|
+
- `Producao Balanceada`: contexto rico com menos ruido.
|
|
46
|
+
- `Producao Economica`: reduz secoes e resultados para economizar tokens.
|
|
47
|
+
- `Auditoria`: payload detalhado para depuracao.
|
|
48
|
+
|
|
49
|
+
## Blocos de contexto
|
|
50
|
+
|
|
51
|
+
Quando habilitados, o agente recebe:
|
|
52
|
+
|
|
53
|
+
- `Profile facts`
|
|
54
|
+
- `Working memory`
|
|
55
|
+
- `Decision state`
|
|
56
|
+
- `Operational state`
|
|
57
|
+
- `Action ledger`
|
|
58
|
+
- `Entity timeline`
|
|
59
|
+
- `Memory compression`
|
|
60
|
+
- `Tool guard`
|
|
61
|
+
- `Vector memories`
|
|
62
|
+
- `Graph`
|
|
63
|
+
- `Recent messages`
|
|
64
|
+
- `Recent highlights`
|
|
65
|
+
- `Tool history`
|
|
66
|
+
- `Diagnostics`
|
|
67
|
+
|
|
68
|
+
## Teste local
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm test
|
|
72
|
+
npm pack --dry-run
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Site: https://tembory.com
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class Mem0Api implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
10
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mem0Api = void 0;
|
|
4
|
+
class Mem0Api {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'mem0Api';
|
|
7
|
+
this.displayName = 'Tembory Cloud API';
|
|
8
|
+
this.documentationUrl = 'https://tembory.com';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'API Key',
|
|
12
|
+
name: 'apiKey',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: { password: true },
|
|
15
|
+
default: '',
|
|
16
|
+
required: true,
|
|
17
|
+
description: 'API key for the managed Tembory memory backend.',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'Organization ID',
|
|
21
|
+
name: 'orgId',
|
|
22
|
+
type: 'string',
|
|
23
|
+
default: '',
|
|
24
|
+
description: 'Optional: Organization ID',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
displayName: 'Project ID',
|
|
28
|
+
name: 'projectId',
|
|
29
|
+
type: 'string',
|
|
30
|
+
default: '',
|
|
31
|
+
description: 'Optional: Project ID',
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
this.authenticate = {
|
|
35
|
+
type: 'generic',
|
|
36
|
+
properties: {
|
|
37
|
+
headers: {
|
|
38
|
+
'Authorization': '=Token {{$credentials.apiKey}}',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
this.test = {
|
|
43
|
+
request: {
|
|
44
|
+
baseURL: 'https://api.mem0.ai',
|
|
45
|
+
url: '/v1/entities/',
|
|
46
|
+
method: 'GET',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Mem0Api = Mem0Api;
|
|
52
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class Mem0SelfHostedApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
10
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mem0SelfHostedApi = void 0;
|
|
4
|
+
class Mem0SelfHostedApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'mem0SelfHostedApi';
|
|
7
|
+
this.displayName = 'Tembory Self-Hosted API';
|
|
8
|
+
this.documentationUrl = 'https://tembory.com';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Base URL',
|
|
12
|
+
name: 'baseUrl',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: 'http://localhost:8000',
|
|
15
|
+
required: true,
|
|
16
|
+
description: 'The base URL of your self-hosted Tembory memory backend',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'API Key',
|
|
20
|
+
name: 'apiKey',
|
|
21
|
+
type: 'string',
|
|
22
|
+
typeOptions: { password: true },
|
|
23
|
+
default: '',
|
|
24
|
+
description: 'API key if authentication enabled',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
this.authenticate = {
|
|
28
|
+
type: 'generic',
|
|
29
|
+
properties: {
|
|
30
|
+
headers: {
|
|
31
|
+
'Authorization': '={{$credentials.apiKey ? "Token " + $credentials.apiKey : ""}}',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
this.test = {
|
|
36
|
+
request: {
|
|
37
|
+
baseURL: '={{$credentials.baseUrl}}',
|
|
38
|
+
url: '/v1/entities/',
|
|
39
|
+
method: 'GET',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.Mem0SelfHostedApi = Mem0SelfHostedApi;
|
|
45
|
+
|
|
@@ -0,0 +1,3 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mem0ApiRequest = mem0ApiRequest;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
async function mem0ApiRequest(method, endpoint, body = {}, qs = {}) {
|
|
6
|
+
// Support both Portuguese parameter name used in CRUD node and English used in Memory node
|
|
7
|
+
let authenticationType;
|
|
8
|
+
try {
|
|
9
|
+
authenticationType = this.getNodeParameter('tipoAutenticacao', 0);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
authenticationType = this.getNodeParameter('authType', 0) || 'nuvem';
|
|
13
|
+
// Map to legacy values used below
|
|
14
|
+
if (authenticationType === 'cloud')
|
|
15
|
+
authenticationType = 'nuvem';
|
|
16
|
+
if (authenticationType === 'selfHosted')
|
|
17
|
+
authenticationType = 'selfHosted';
|
|
18
|
+
}
|
|
19
|
+
let credentials;
|
|
20
|
+
let baseUrl;
|
|
21
|
+
if (authenticationType === 'nuvem') {
|
|
22
|
+
credentials = await this.getCredentials('mem0Api');
|
|
23
|
+
baseUrl = 'https://api.mem0.ai';
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
credentials = await this.getCredentials('mem0SelfHostedApi');
|
|
27
|
+
baseUrl = credentials.baseUrl.replace(/\/$/, ''); // Remove trailing slash
|
|
28
|
+
}
|
|
29
|
+
const options = {
|
|
30
|
+
method,
|
|
31
|
+
body,
|
|
32
|
+
qs,
|
|
33
|
+
url: `${baseUrl}${endpoint}`,
|
|
34
|
+
json: true,
|
|
35
|
+
};
|
|
36
|
+
if (credentials.apiKey) {
|
|
37
|
+
options.headers = {
|
|
38
|
+
'Authorization': `Token ${credentials.apiKey}`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
return await this.helpers.request(options);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ISupplyDataFunctions, IExecuteFunctions, INodeType, INodeTypeDescription, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
export declare class Mem0Memory implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<{
|
|
5
|
+
response: any;
|
|
6
|
+
}>;
|
|
7
|
+
saveContextForItem(this: ISupplyDataFunctions, itemIndex: number, inputValues?: Record<string, unknown>, outputValues?: Record<string, unknown>): Promise<void>;
|
|
8
|
+
loadMemoryVariablesForItem(this: ISupplyDataFunctions, itemIndex: number, inputValues?: Record<string, unknown>): Promise<{
|
|
9
|
+
response: {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
14
|
+
}
|
|
15
|
+
|