n8n-nodes-tembory 1.1.23 → 1.1.24
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.
|
@@ -143,6 +143,48 @@ const asSearchQuery = (value) => {
|
|
|
143
143
|
return String(value);
|
|
144
144
|
return pickText(value, ['query', 'input', 'chatInput', 'text', 'message', 'consolidated_text', 'lastUserMessage']);
|
|
145
145
|
};
|
|
146
|
+
const currentInputJsonFromContext = (ctx, itemIndex = 0) => {
|
|
147
|
+
try {
|
|
148
|
+
const inputData = typeof (ctx === null || ctx === void 0 ? void 0 : ctx.getInputData) === 'function' ? ctx.getInputData() : [];
|
|
149
|
+
const item = (Array.isArray(inputData) && (inputData[itemIndex] || inputData[0])) || {};
|
|
150
|
+
return item && typeof item.json === 'object' && item.json ? item.json : {};
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return {};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const resolveCurrentTurnQuery = (ctx, itemIndex = 0, inputValues = {}, queryParam = '') => {
|
|
157
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
158
|
+
const inputJson = currentInputJsonFromContext(ctx, itemIndex);
|
|
159
|
+
const candidates = [
|
|
160
|
+
queryParam,
|
|
161
|
+
inputValues.query,
|
|
162
|
+
inputValues.input,
|
|
163
|
+
inputValues.chatInput,
|
|
164
|
+
inputValues.text,
|
|
165
|
+
inputValues.question,
|
|
166
|
+
inputValues.message,
|
|
167
|
+
inputJson.query,
|
|
168
|
+
inputJson.lastUserMessage,
|
|
169
|
+
inputJson.chatInput,
|
|
170
|
+
inputJson.input,
|
|
171
|
+
inputJson.text,
|
|
172
|
+
inputJson.message,
|
|
173
|
+
(_a = inputJson.body) === null || _a === void 0 ? void 0 : _a.consolidated_text,
|
|
174
|
+
(_b = inputJson.body) === null || _b === void 0 ? void 0 : _b.chatInput,
|
|
175
|
+
(_c = inputJson.body) === null || _c === void 0 ? void 0 : _c.message,
|
|
176
|
+
(_d = inputJson.body) === null || _d === void 0 ? void 0 : _d.text,
|
|
177
|
+
(_e = inputJson.body) === null || _e === void 0 ? void 0 : _e.input,
|
|
178
|
+
(_h = (_g = (_f = inputJson.body) === null || _f === void 0 ? void 0 : _f.messages) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.text,
|
|
179
|
+
(_k = (_j = inputJson.body) === null || _j === void 0 ? void 0 : _j.messages) === null || _k === void 0 ? void 0 : _k[0],
|
|
180
|
+
];
|
|
181
|
+
for (const candidate of candidates) {
|
|
182
|
+
const query = asSearchQuery(candidate).trim();
|
|
183
|
+
if (query)
|
|
184
|
+
return stripThreadTestPrefix(query);
|
|
185
|
+
}
|
|
186
|
+
return '';
|
|
187
|
+
};
|
|
146
188
|
const memoryText = (memory) => {
|
|
147
189
|
if (!memory)
|
|
148
190
|
return '';
|
|
@@ -1224,6 +1266,8 @@ const mergeRemoteThreadState = (store, key, state) => {
|
|
|
1224
1266
|
store.decisionState[key] = { ...(store.decisionState[key] || {}), ...state.decisionState };
|
|
1225
1267
|
if (state.memoryCompression && typeof state.memoryCompression === 'object')
|
|
1226
1268
|
store.memoryCompression[key] = state.memoryCompression;
|
|
1269
|
+
if (state.captureState && typeof state.captureState === 'object')
|
|
1270
|
+
store.captureState[key] = { ...(store.captureState[key] || {}), ...state.captureState };
|
|
1227
1271
|
if (typeof state.activeSummary === 'string' && state.activeSummary)
|
|
1228
1272
|
store.activeSummary[key] = state.activeSummary;
|
|
1229
1273
|
};
|
|
@@ -2932,12 +2976,7 @@ class TemboryMemory {
|
|
|
2932
2976
|
name: 'query',
|
|
2933
2977
|
type: 'string',
|
|
2934
2978
|
default: '={{ $json.query || $json.lastUserMessage || $json.chatInput || $json.body?.consolidated_text || $json.body?.message || $json.body?.text || "" }}',
|
|
2935
|
-
description: '
|
|
2936
|
-
displayOptions: {
|
|
2937
|
-
show: {
|
|
2938
|
-
retrievalMode: ['semantic', 'semanticV2', 'hybrid'],
|
|
2939
|
-
},
|
|
2940
|
-
},
|
|
2979
|
+
description: 'Mensagem atual usada para montar o contexto operacional, inferir intenção e recuperar memórias relevantes. Em AI Agent, mantenha a expressão padrão para ler o chatInput do item.',
|
|
2941
2980
|
},
|
|
2942
2981
|
{
|
|
2943
2982
|
displayName: 'Chave de Memória',
|
|
@@ -3294,6 +3333,19 @@ class TemboryMemory {
|
|
|
3294
3333
|
body.app_id = String(adv.appId);
|
|
3295
3334
|
if (adv.runId)
|
|
3296
3335
|
body.run_id = String(adv.runId);
|
|
3336
|
+
const nextCaptureState = cleanContextValue({
|
|
3337
|
+
...(store.captureState[key] || {}),
|
|
3338
|
+
last_save_status: 'saved',
|
|
3339
|
+
last_save_saved: true,
|
|
3340
|
+
last_save_conversation_messages_after_save: recentForTurn.length,
|
|
3341
|
+
last_save_tool_history_after_save: toolHistoryForTurn.length,
|
|
3342
|
+
last_save_thread_state_saved: true,
|
|
3343
|
+
last_save_backend_memory_persistence: adv.persistBackendMemories === false
|
|
3344
|
+
? 'disabled'
|
|
3345
|
+
: adv.useVectorMemory === false
|
|
3346
|
+
? 'thread_state_only'
|
|
3347
|
+
: 'enabled',
|
|
3348
|
+
});
|
|
3297
3349
|
const threadStateSaved = await saveThreadState(this, key, threadId, project, {
|
|
3298
3350
|
kind: 'tembory.thread_state.v1',
|
|
3299
3351
|
threadId,
|
|
@@ -3306,20 +3358,12 @@ class TemboryMemory {
|
|
|
3306
3358
|
decisionState: decisionStateForTurn,
|
|
3307
3359
|
memoryCompression: compressionForTurn,
|
|
3308
3360
|
operationalState: operationalStateForTurn,
|
|
3361
|
+
captureState: nextCaptureState,
|
|
3309
3362
|
activeSummary: store.activeSummary[key] || '',
|
|
3310
3363
|
});
|
|
3311
3364
|
store.captureState[key] = cleanContextValue({
|
|
3312
|
-
...
|
|
3313
|
-
last_save_status: 'saved',
|
|
3314
|
-
last_save_saved: true,
|
|
3315
|
-
last_save_conversation_messages_after_save: recentForTurn.length,
|
|
3316
|
-
last_save_tool_history_after_save: toolHistoryForTurn.length,
|
|
3365
|
+
...nextCaptureState,
|
|
3317
3366
|
last_save_thread_state_saved: threadStateSaved,
|
|
3318
|
-
last_save_backend_memory_persistence: adv.persistBackendMemories === false
|
|
3319
|
-
? 'disabled'
|
|
3320
|
-
: adv.useVectorMemory === false
|
|
3321
|
-
? 'thread_state_only'
|
|
3322
|
-
: 'enabled',
|
|
3323
3367
|
});
|
|
3324
3368
|
try {
|
|
3325
3369
|
const globalData = this.getWorkflowStaticData('global');
|
|
@@ -3586,7 +3630,7 @@ class TemboryMemory {
|
|
|
3586
3630
|
const store = getMemoryStore(this);
|
|
3587
3631
|
const key = userKeyFrom(threadId, adv, project);
|
|
3588
3632
|
const queryParam = this.getNodeParameter('query', itemIndex, '');
|
|
3589
|
-
const query =
|
|
3633
|
+
const query = resolveCurrentTurnQuery(this, itemIndex, inputValues, queryParam);
|
|
3590
3634
|
const remoteThreadState = await loadThreadState(this, key, threadId, project);
|
|
3591
3635
|
mergeRemoteThreadState(store, key, remoteThreadState);
|
|
3592
3636
|
let connectedLanguageModel;
|
|
@@ -4030,7 +4074,7 @@ class TemboryMemory {
|
|
|
4030
4074
|
last_save_conversation_messages_after_save: 0,
|
|
4031
4075
|
last_save_tool_history_after_save: 0,
|
|
4032
4076
|
last_save_thread_state_saved: false,
|
|
4033
|
-
last_save_backend_memory_persistence: backendPersistenceEnabled ? 'enabled' : 'disabled',
|
|
4077
|
+
last_save_backend_memory_persistence: backendPersistenceEnabled ? (vectorMemoryEnabled ? 'enabled' : 'thread_state_only') : 'disabled',
|
|
4034
4078
|
},
|
|
4035
4079
|
connectedAi,
|
|
4036
4080
|
activeSummary: summaryDiagnostics,
|
|
@@ -4288,6 +4332,8 @@ exports.__private = {
|
|
|
4288
4332
|
applyOperationalPreset,
|
|
4289
4333
|
flattenAdvancedGroups,
|
|
4290
4334
|
asSearchQuery,
|
|
4335
|
+
currentInputJsonFromContext,
|
|
4336
|
+
resolveCurrentTurnQuery,
|
|
4291
4337
|
safePersistLegacyMemory,
|
|
4292
4338
|
stripThreadTestPrefix,
|
|
4293
4339
|
canonicalToolInput,
|
package/package.json
CHANGED