snow-ai 0.3.5 → 0.3.6
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.
|
@@ -531,10 +531,24 @@ export async function handleConversationWithTools(options) {
|
|
|
531
531
|
for (const result of toolResults) {
|
|
532
532
|
const toolCall = receivedToolCalls.find(tc => tc.id === result.tool_call_id);
|
|
533
533
|
if (toolCall) {
|
|
534
|
-
//
|
|
535
|
-
//
|
|
534
|
+
// Special handling for sub-agent tools - show completion message
|
|
535
|
+
// Pass the full JSON result to ToolResultPreview for proper parsing
|
|
536
536
|
if (toolCall.function.name.startsWith('subagent-')) {
|
|
537
|
-
|
|
537
|
+
const isError = result.content.startsWith('Error:');
|
|
538
|
+
const statusIcon = isError ? '✗' : '✓';
|
|
539
|
+
const statusText = isError ? `\n └─ ${result.content}` : '';
|
|
540
|
+
// Display subagent completion message in main flow
|
|
541
|
+
setMessages(prev => [
|
|
542
|
+
...prev,
|
|
543
|
+
{
|
|
544
|
+
role: 'assistant',
|
|
545
|
+
content: `${statusIcon} ${toolCall.function.name}${statusText}`,
|
|
546
|
+
streaming: false,
|
|
547
|
+
// Pass the full result.content for ToolResultPreview to parse
|
|
548
|
+
toolResult: !isError ? result.content : undefined,
|
|
549
|
+
},
|
|
550
|
+
]);
|
|
551
|
+
// Save the tool result to conversation history
|
|
538
552
|
conversationMessages.push(result);
|
|
539
553
|
saveMessage(result).catch(error => {
|
|
540
554
|
console.error('Failed to save tool result:', error);
|
|
@@ -9,7 +9,10 @@ export default function ToolResultPreview({ toolName, result, maxLines = 5 }) {
|
|
|
9
9
|
// Try to parse JSON result
|
|
10
10
|
const data = JSON.parse(result);
|
|
11
11
|
// Handle different tool types
|
|
12
|
-
if (toolName
|
|
12
|
+
if (toolName.startsWith('subagent-')) {
|
|
13
|
+
return renderSubAgentPreview(data, maxLines);
|
|
14
|
+
}
|
|
15
|
+
else if (toolName === 'filesystem-read') {
|
|
13
16
|
return renderReadPreview(data, maxLines);
|
|
14
17
|
}
|
|
15
18
|
else if (toolName === 'filesystem-list') {
|
|
@@ -40,6 +43,23 @@ export default function ToolResultPreview({ toolName, result, maxLines = 5 }) {
|
|
|
40
43
|
return null;
|
|
41
44
|
}
|
|
42
45
|
}
|
|
46
|
+
function renderSubAgentPreview(data, maxLines) {
|
|
47
|
+
// Sub-agent results have format: { success: boolean, result: string }
|
|
48
|
+
if (!data.result)
|
|
49
|
+
return null;
|
|
50
|
+
// Split the result into lines
|
|
51
|
+
const lines = data.result.split('\n').filter((line) => line.trim());
|
|
52
|
+
const previewLines = lines.slice(0, maxLines);
|
|
53
|
+
const hasMore = lines.length > maxLines;
|
|
54
|
+
return (React.createElement(Box, { flexDirection: "column", marginLeft: 2 },
|
|
55
|
+
previewLines.map((line, idx) => (React.createElement(Text, { key: idx, color: "gray", dimColor: true },
|
|
56
|
+
idx === previewLines.length - 1 && !hasMore ? '└─ ' : '├─ ',
|
|
57
|
+
line.length > 80 ? line.slice(0, 80) + '...' : line))),
|
|
58
|
+
hasMore && (React.createElement(Text, { color: "gray", dimColor: true },
|
|
59
|
+
"\u2514\u2500 ... (",
|
|
60
|
+
lines.length - maxLines,
|
|
61
|
+
" more lines)"))));
|
|
62
|
+
}
|
|
43
63
|
function renderReadPreview(data, maxLines) {
|
|
44
64
|
if (!data.content)
|
|
45
65
|
return null;
|