n8n-nodes-tembory 1.0.33 → 1.0.34
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.
|
@@ -597,10 +597,14 @@ const encodeToolCall = (tool, threadId) => `${TOOL_HISTORY_MARKER}${safeStringif
|
|
|
597
597
|
source: tool.source || 'n8n',
|
|
598
598
|
thread_id: threadId,
|
|
599
599
|
})}`;
|
|
600
|
-
const encodeToolLedger = (tools = [], threadId) =>
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
600
|
+
const encodeToolLedger = (tools = [], threadId) => {
|
|
601
|
+
const orderedTools = sortToolHistory(tools || []);
|
|
602
|
+
const names = orderedTools.map((tool) => tool.name || tool.tool || tool.toolName || 'tool').filter(Boolean);
|
|
603
|
+
const readable = `Tool history ledger. Tools called in this thread: ${names.join(', ')}. Use this ledger to answer questions about called tools, tool inputs, tool outputs, tool status and tool order. `;
|
|
604
|
+
return `${readable}${TOOL_LEDGER_MARKER}${safeStringify({
|
|
605
|
+
thread_id: threadId,
|
|
606
|
+
generated_at: nowIso(),
|
|
607
|
+
tools: orderedTools.map((tool, index) => ({
|
|
604
608
|
id: tool.id || tool.callId || tool.call_id || '',
|
|
605
609
|
turn_id: tool.turnId || tool.turn_id || '',
|
|
606
610
|
sequence: tool.sequence || index + 1,
|
|
@@ -611,7 +615,8 @@ const encodeToolLedger = (tools = [], threadId) => `${TOOL_LEDGER_MARKER}${safeS
|
|
|
611
615
|
at: tool.at || nowIso(),
|
|
612
616
|
source: tool.source || 'n8n',
|
|
613
617
|
})),
|
|
614
|
-
})}`;
|
|
618
|
+
})}`;
|
|
619
|
+
};
|
|
615
620
|
const parseRecentMessageMarker = (text) => {
|
|
616
621
|
if (!text || typeof text !== 'string' || !text.startsWith(RECENT_MESSAGE_MARKER))
|
|
617
622
|
return null;
|
|
@@ -653,10 +658,13 @@ const parseToolHistoryMarker = (text) => {
|
|
|
653
658
|
}
|
|
654
659
|
};
|
|
655
660
|
const parseToolLedgerMarker = (text) => {
|
|
656
|
-
if (!text || typeof text !== 'string'
|
|
661
|
+
if (!text || typeof text !== 'string')
|
|
662
|
+
return [];
|
|
663
|
+
const markerIndex = text.indexOf(TOOL_LEDGER_MARKER);
|
|
664
|
+
if (markerIndex < 0)
|
|
657
665
|
return [];
|
|
658
666
|
try {
|
|
659
|
-
const parsed = JSON.parse(text.slice(TOOL_LEDGER_MARKER.length));
|
|
667
|
+
const parsed = JSON.parse(text.slice(markerIndex + TOOL_LEDGER_MARKER.length));
|
|
660
668
|
const tools = Array.isArray(parsed?.tools) ? parsed.tools : [];
|
|
661
669
|
return tools
|
|
662
670
|
.filter((tool) => tool && tool.name)
|
package/package.json
CHANGED