n8n-nodes-tembory 1.1.22 → 1.1.23
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.
|
@@ -2292,6 +2292,35 @@ const compactMessageForSideChannel = (message = {}) => {
|
|
|
2292
2292
|
preview: role === 'system' ? '[system context hidden]' : truncate(content, 280),
|
|
2293
2293
|
});
|
|
2294
2294
|
};
|
|
2295
|
+
const normalizeConversationRoleForSideChannel = (role = '') => {
|
|
2296
|
+
const normalized = String(role || '').toLowerCase();
|
|
2297
|
+
if (normalized === 'human' || normalized === 'user')
|
|
2298
|
+
return 'user';
|
|
2299
|
+
if (normalized === 'ai' || normalized === 'assistant' || normalized === 'agent')
|
|
2300
|
+
return 'agent';
|
|
2301
|
+
if (normalized === 'system')
|
|
2302
|
+
return 'system';
|
|
2303
|
+
if (normalized === 'tool')
|
|
2304
|
+
return 'tool';
|
|
2305
|
+
return normalized || 'message';
|
|
2306
|
+
};
|
|
2307
|
+
const compactConversationTimelineForSideChannel = (conversation = {}, maxItems = 12) => {
|
|
2308
|
+
const chronological = Array.isArray(conversation.conversation_history_chronological)
|
|
2309
|
+
? conversation.conversation_history_chronological
|
|
2310
|
+
: [];
|
|
2311
|
+
return pruneByLimit(chronological, maxItems).map((message, index) => {
|
|
2312
|
+
const role = normalizeConversationRoleForSideChannel(message.role || message.type);
|
|
2313
|
+
const content = String(message.content || message.text || message.message || '');
|
|
2314
|
+
return cleanContextValue({
|
|
2315
|
+
index,
|
|
2316
|
+
role,
|
|
2317
|
+
speaker: role,
|
|
2318
|
+
at: message.at || message.timestamp || message.created_at || message.createdAt,
|
|
2319
|
+
chars: content.length,
|
|
2320
|
+
content: truncate(content, 700),
|
|
2321
|
+
});
|
|
2322
|
+
});
|
|
2323
|
+
};
|
|
2295
2324
|
const summarizeSaveContextForSideChannel = (input = {}, output = {}, chatHistory = []) => {
|
|
2296
2325
|
const inputMessage = input?.input || input?.chatInput || input?.query || input?.question || input?.text || input?.message || '';
|
|
2297
2326
|
const outputMessage = output?.output || output?.response || output?.text || output?.message || output?.answer || '';
|
|
@@ -2356,6 +2385,7 @@ const summarizeMemoryMessagesForSideChannel = (messages = []) => {
|
|
|
2356
2385
|
summary.intent = parsed.observations?.inferred_intent?.label || parsed.workingMemory?.last_user_intent || parsed.decisionState?.current_intent || undefined;
|
|
2357
2386
|
summary.currentUserMessage = conversation.current_user_message ? truncate(conversation.current_user_message, 180) : undefined;
|
|
2358
2387
|
summary.recentMessages = Array.isArray(conversation.conversation_history_chronological) ? conversation.conversation_history_chronological.length : undefined;
|
|
2388
|
+
summary.conversationTimeline = compactConversationTimelineForSideChannel(conversation, 12);
|
|
2359
2389
|
summary.toolCount = toolItems.length || tools.count || parsed.operationalState?.tool_counts?.total || undefined;
|
|
2360
2390
|
summary.toolNames = toolItems.map((tool) => tool.name || tool.tool_name).filter(Boolean).slice(0, 20);
|
|
2361
2391
|
summary.toolEvents = toolItems
|
|
@@ -4295,6 +4325,7 @@ exports.__private = {
|
|
|
4295
4325
|
cleanModelSummaryText,
|
|
4296
4326
|
invokeConnectedModelSummary,
|
|
4297
4327
|
compactMemoryEventPayload,
|
|
4328
|
+
compactConversationTimelineForSideChannel,
|
|
4298
4329
|
summarizeMemoryMessagesForSideChannel,
|
|
4299
4330
|
summarizeSaveContextForSideChannel,
|
|
4300
4331
|
};
|
package/package.json
CHANGED