n8n-nodes-tembory 1.0.48 → 1.0.50
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.
|
@@ -1444,7 +1444,12 @@ const applyOperationalPreset = (advanced = {}) => {
|
|
|
1444
1444
|
payloadFormat: 'auditJson',
|
|
1445
1445
|
},
|
|
1446
1446
|
};
|
|
1447
|
-
const
|
|
1447
|
+
const presetKey = preset === 'lab' ? 'diagnostic' : preset;
|
|
1448
|
+
const resolved = { ...(presets[presetKey] || {}), ...advanced };
|
|
1449
|
+
if (/^production/i.test(presetKey)) {
|
|
1450
|
+
resolved.compactForAgent = true;
|
|
1451
|
+
resolved.compactStateSections = true;
|
|
1452
|
+
}
|
|
1448
1453
|
if (resolved.useVectorMemory === false) {
|
|
1449
1454
|
resolved.includeRelations = false;
|
|
1450
1455
|
resolved.includeEntityTimeline = false;
|
|
@@ -1654,7 +1659,11 @@ const buildCurrentTurnFocus = ({ query = '', recentMessages = [], operationalSta
|
|
|
1654
1659
|
all_user_messages_chronological: recall ? userMessagesChronological : undefined,
|
|
1655
1660
|
tool_status: operationalStatus ? {
|
|
1656
1661
|
executed_tools: toolState.names || [],
|
|
1657
|
-
last_successful_tool: toolState.last_successful_tool
|
|
1662
|
+
last_successful_tool: toolState.last_successful_tool ? {
|
|
1663
|
+
name: toolState.last_successful_tool.name,
|
|
1664
|
+
at: toolState.last_successful_tool.at,
|
|
1665
|
+
status: toolState.last_successful_tool.status || (toolState.last_successful_tool.ok === false ? 'failed' : 'ok'),
|
|
1666
|
+
} : null,
|
|
1658
1667
|
failed_by_name: toolState.failed_by_name || {},
|
|
1659
1668
|
} : undefined,
|
|
1660
1669
|
instruction: recall
|
|
@@ -2306,7 +2315,11 @@ const buildContextMessages = ({ payloadFormat, query, userId, profileFacts, work
|
|
|
2306
2315
|
sections.push({
|
|
2307
2316
|
section: 'conversation_frame',
|
|
2308
2317
|
title: 'Conversation frame',
|
|
2309
|
-
value: buildConversationFrame({
|
|
2318
|
+
value: buildConversationFrame({
|
|
2319
|
+
query,
|
|
2320
|
+
recentMessages: compactForAgent ? pruneByLimit(recentMessages || [], Number(adv.agentRecentMessagesLastN || 20)) : recentMessages,
|
|
2321
|
+
workingMemory,
|
|
2322
|
+
}),
|
|
2310
2323
|
});
|
|
2311
2324
|
const currentTurnFocus = buildCurrentTurnFocus({ query, recentMessages, operationalState, workingMemory });
|
|
2312
2325
|
if (currentTurnFocus) {
|
|
@@ -2371,6 +2384,25 @@ const buildContextMessages = ({ payloadFormat, query, userId, profileFacts, work
|
|
|
2371
2384
|
sections,
|
|
2372
2385
|
diagnostics,
|
|
2373
2386
|
};
|
|
2387
|
+
const sectionValue = (name) => {
|
|
2388
|
+
const found = sections.find((section) => section.section === name);
|
|
2389
|
+
return found ? found.value : undefined;
|
|
2390
|
+
};
|
|
2391
|
+
const compactJson = cleanContextValue({
|
|
2392
|
+
kind: 'tembory.agent_context.v1',
|
|
2393
|
+
instruction: includeHeader ? sectionValue('context_header') : undefined,
|
|
2394
|
+
conversation: sectionValue('conversation_frame'),
|
|
2395
|
+
current_turn_focus: sectionValue('current_turn_focus'),
|
|
2396
|
+
action_directive: sectionValue('action_directive'),
|
|
2397
|
+
summary: {
|
|
2398
|
+
vector_facts: sectionValue('summary'),
|
|
2399
|
+
slm: sectionValue('connected_model_summary') || sectionValue('active_summary'),
|
|
2400
|
+
},
|
|
2401
|
+
working_memory: sectionValue('working_memory'),
|
|
2402
|
+
profile: sectionValue('profile_facts'),
|
|
2403
|
+
tools: sectionValue('tool_ledger'),
|
|
2404
|
+
next_action: sectionValue('next_action'),
|
|
2405
|
+
});
|
|
2374
2406
|
const renderCompactSection = (section) => {
|
|
2375
2407
|
if (section.value === null || section.value === undefined)
|
|
2376
2408
|
return `## ${section.title}\n${section.why_null || 'empty'}`;
|
|
@@ -2384,18 +2416,7 @@ const buildContextMessages = ({ payloadFormat, query, userId, profileFacts, work
|
|
|
2384
2416
|
return [{ role: 'system', content: JSON.stringify(audit, null, 2) }];
|
|
2385
2417
|
if (payloadFormat === 'auditBlocks')
|
|
2386
2418
|
return sections.map((section) => ({ role: 'system', content: renderCompactSection(section) }));
|
|
2387
|
-
|
|
2388
|
-
if (section.section === 'summary' && !section.value)
|
|
2389
|
-
return false;
|
|
2390
|
-
if (section.value === null || section.value === undefined)
|
|
2391
|
-
return false;
|
|
2392
|
-
if (Array.isArray(section.value) && section.value.length === 0)
|
|
2393
|
-
return false;
|
|
2394
|
-
if (typeof section.value === 'object' && !Array.isArray(section.value) && Object.keys(section.value).length === 0)
|
|
2395
|
-
return false;
|
|
2396
|
-
return true;
|
|
2397
|
-
});
|
|
2398
|
-
return [{ role: 'system', content: truncate(renderableSections.map(renderCompactSection).join('\n\n'), Number(adv.contextMaxChars || 6000)) }];
|
|
2419
|
+
return [{ role: 'system', content: JSON.stringify(compactJson) }];
|
|
2399
2420
|
}
|
|
2400
2421
|
if (includeSummary) {
|
|
2401
2422
|
const summary = compactStateSections
|
package/package.json
CHANGED