mirror of https://github.com/kortix-ai/suna.git
Merge pull request #626 from kubet/fix/visual-redundancy
fix: tool view fixes
This commit is contained in:
commit
8ba053247d
|
@ -543,13 +543,16 @@ For casual conversation and social interactions:
|
|||
## 7.3 ATTACHMENT PROTOCOL
|
||||
- **CRITICAL: ALL VISUALIZATIONS MUST BE ATTACHED:**
|
||||
* When using the 'ask' tool <ask attachments="file1, file2, file3"></ask>, ALWAYS attach ALL visualizations, markdown files, charts, graphs, reports, and any viewable content created
|
||||
* **MANDATORY RULE: If you have created ANY files during this conversation, you MUST include them as attachments when using the ask tool**
|
||||
* This includes but is not limited to: HTML files, PDF documents, markdown files, images, data visualizations, presentations, reports, dashboards, and UI mockups
|
||||
* **NEVER use the ask tool without attachments if you have created files** - this is a critical error
|
||||
* NEVER mention a visualization or viewable content without attaching it
|
||||
* If you've created multiple visualizations, attach ALL of them
|
||||
* Always make visualizations available to the user BEFORE marking tasks as complete
|
||||
* For web applications or interactive content, always attach the main HTML file
|
||||
* When creating data analysis results, charts must be attached, not just described
|
||||
* Remember: If the user should SEE it, you must ATTACH it with the 'ask' tool
|
||||
* **EXAMPLE: If you create files like main.py, README.md, config.json, notes.txt, you MUST use: <ask attachments="main.py,README.md,config.json,notes.txt">**
|
||||
* Verify that ALL visual outputs have been attached before proceeding
|
||||
|
||||
- **Attachment Checklist:**
|
||||
|
@ -562,7 +565,7 @@ For casual conversation and social interactions:
|
|||
* Analysis results with visual components
|
||||
* UI designs and mockups
|
||||
* Any file intended for user viewing or interaction
|
||||
|
||||
* **ANY FILES CREATED DURING THE CONVERSATION - ALWAYS ATTACH THEM**
|
||||
|
||||
# 8. COMPLETION PROTOCOLS
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from typing import List, Optional, Union
|
||||
from agentpress.tool import Tool, ToolResult, openapi_schema, xml_schema
|
||||
from utils.logger import logger
|
||||
|
||||
class MessageTool(Tool):
|
||||
"""Tool for user communication and interaction.
|
||||
|
@ -68,11 +69,11 @@ This information will help me make sure the cake meets your expectations for the
|
|||
Returns:
|
||||
ToolResult indicating the question was successfully sent
|
||||
"""
|
||||
try:
|
||||
try:
|
||||
# Convert single attachment to list for consistent handling
|
||||
if attachments and isinstance(attachments, str):
|
||||
attachments = [attachments]
|
||||
|
||||
|
||||
return self.success_response({"status": "Awaiting user response..."})
|
||||
except Exception as e:
|
||||
return self.fail_response(f"Error asking user: {str(e)}")
|
||||
|
|
|
@ -107,7 +107,8 @@ class SandboxDeployTool(SandboxToolsBase):
|
|||
npx wrangler pages deploy {full_path} --project-name {project_name}))'''
|
||||
|
||||
# Execute the command directly using the sandbox's process.exec method
|
||||
response = self.sandbox.process.exec(deploy_cmd, timeout=300)
|
||||
response = self.sandbox.process.exec(f"/bin/sh -c \"{deploy_cmd}\"",
|
||||
timeout=300)
|
||||
|
||||
print(f"Deployment command output: {response.result}")
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ export function AskToolView({
|
|||
onFileClick,
|
||||
project,
|
||||
}: AskToolViewProps) {
|
||||
|
||||
|
||||
const {
|
||||
text,
|
||||
attachments,
|
||||
|
@ -190,12 +190,7 @@ export function AskToolView({
|
|||
})}
|
||||
</div>
|
||||
|
||||
{actualAssistantTimestamp && (
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<Clock className="h-3 w-3" />
|
||||
{formatTimestamp(actualAssistantTimestamp)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col items-center justify-center py-8 text-center">
|
||||
|
|
|
@ -68,16 +68,16 @@ export function CommandToolView({
|
|||
}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
|
||||
processedOutput = String(processedOutput);
|
||||
processedOutput = processedOutput.replace(/\\\\/g, '\\');
|
||||
|
||||
|
||||
processedOutput = processedOutput
|
||||
.replace(/\\n/g, '\n')
|
||||
.replace(/\\t/g, '\t')
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/\\'/g, "'");
|
||||
|
||||
|
||||
processedOutput = processedOutput.replace(/\\u([0-9a-fA-F]{4})/g, (match, group) => {
|
||||
return String.fromCharCode(parseInt(group, 16));
|
||||
});
|
||||
|
@ -102,13 +102,13 @@ export function CommandToolView({
|
|||
</CardTitle>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{!isStreaming && (
|
||||
<Badge
|
||||
variant="secondary"
|
||||
<Badge
|
||||
variant="secondary"
|
||||
className={
|
||||
actualIsSuccess
|
||||
? "bg-gradient-to-b from-emerald-200 to-emerald-100 text-emerald-700 dark:from-emerald-800/50 dark:to-emerald-900/60 dark:text-emerald-300"
|
||||
actualIsSuccess
|
||||
? "bg-gradient-to-b from-emerald-200 to-emerald-100 text-emerald-700 dark:from-emerald-800/50 dark:to-emerald-900/60 dark:text-emerald-300"
|
||||
: "bg-gradient-to-b from-rose-200 to-rose-100 text-rose-700 dark:from-rose-800/50 dark:to-rose-900/60 dark:text-rose-300"
|
||||
}
|
||||
>
|
||||
|
@ -117,8 +117,8 @@ export function CommandToolView({
|
|||
) : (
|
||||
<AlertTriangle className="h-3.5 w-3.5 mr-1" />
|
||||
)}
|
||||
{actualIsSuccess ?
|
||||
(name === 'check-command-output' ? 'Output retrieved successfully' : 'Command executed successfully') :
|
||||
{actualIsSuccess ?
|
||||
(name === 'check-command-output' ? 'Output retrieved successfully' : 'Command executed successfully') :
|
||||
(name === 'check-command-output' ? 'Failed to retrieve output' : 'Command failed')
|
||||
}
|
||||
</Badge>
|
||||
|
@ -128,7 +128,7 @@ export function CommandToolView({
|
|||
|
||||
<CardContent className="p-0 h-full flex-1 overflow-hidden relative">
|
||||
{isStreaming ? (
|
||||
<LoadingState
|
||||
<LoadingState
|
||||
icon={Terminal}
|
||||
iconColor="text-purple-500 dark:text-purple-400"
|
||||
bgColor="bg-gradient-to-b from-purple-100 to-purple-50 shadow-inner dark:from-purple-800/40 dark:to-purple-900/60 dark:shadow-purple-950/20"
|
||||
|
@ -139,52 +139,12 @@ export function CommandToolView({
|
|||
) : displayText ? (
|
||||
<ScrollArea className="h-full w-full">
|
||||
<div className="p-4">
|
||||
<div className="mb-4 bg-zinc-100 dark:bg-neutral-900 rounded-lg overflow-hidden border border-zinc-200 dark:border-zinc-800">
|
||||
<div className="bg-zinc-200 dark:bg-zinc-800 px-4 py-2 flex items-center gap-2">
|
||||
<Code className="h-4 w-4 text-zinc-600 dark:text-zinc-400" />
|
||||
<span className="text-sm font-medium text-zinc-700 dark:text-zinc-300">{displayLabel}</span>
|
||||
{sessionName && cwd && (
|
||||
<Badge variant="outline" className="text-xs ml-auto">
|
||||
{cwd}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className="p-4 font-mono text-sm text-zinc-700 dark:text-zinc-300 flex gap-2">
|
||||
<span className="text-purple-500 dark:text-purple-400 select-none">{displayPrefix}</span>
|
||||
<code className="flex-1 break-all">{displayText}</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{output && (
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<h3 className="text-sm font-medium text-zinc-700 dark:text-zinc-300 flex items-center">
|
||||
<ArrowRight className="h-4 w-4 mr-2 text-zinc-500 dark:text-zinc-400" />
|
||||
Output
|
||||
</h3>
|
||||
<div className="flex items-center gap-2">
|
||||
{completed !== null && (
|
||||
<Badge
|
||||
variant="outline"
|
||||
className="text-xs"
|
||||
>
|
||||
{completed ? 'Completed' : 'Running'}
|
||||
</Badge>
|
||||
)}
|
||||
{exitCode !== null && (
|
||||
<Badge
|
||||
className={cn(
|
||||
exitCode === 0
|
||||
? "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400"
|
||||
: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"
|
||||
)}
|
||||
>
|
||||
{exitCode === 0 ? 'Success' : `Exit ${exitCode}`}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div className="bg-zinc-100 dark:bg-neutral-900 rounded-lg overflow-hidden border border-zinc-200/20">
|
||||
<div className="bg-zinc-300 dark:bg-neutral-800 flex items-center justify-between dark:border-zinc-700/50">
|
||||
<div className="bg-zinc-200 w-full dark:bg-zinc-800 px-4 py-2 flex items-center gap-2">
|
||||
|
@ -201,8 +161,8 @@ export function CommandToolView({
|
|||
<div className="p-4 max-h-96 overflow-auto scrollbar-hide">
|
||||
<pre className="text-xs text-zinc-600 dark:text-zinc-300 font-mono whitespace-pre-wrap break-all overflow-visible">
|
||||
{linesToShow.map((line, index) => (
|
||||
<div
|
||||
key={index}
|
||||
<div
|
||||
key={index}
|
||||
className="py-0.5 bg-transparent"
|
||||
>
|
||||
{line || ' '}
|
||||
|
@ -218,7 +178,7 @@ export function CommandToolView({
|
|||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{!output && !isStreaming && (
|
||||
<div className="bg-black rounded-lg overflow-hidden border border-zinc-700/20 shadow-md p-6 flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
|
@ -238,7 +198,7 @@ export function CommandToolView({
|
|||
{name === 'check-command-output' ? 'No Session Found' : 'No Command Found'}
|
||||
</h3>
|
||||
<p className="text-sm text-zinc-500 dark:text-zinc-400 text-center max-w-md">
|
||||
{name === 'check-command-output'
|
||||
{name === 'check-command-output'
|
||||
? 'No session name was detected. Please provide a valid session name to check.'
|
||||
: 'No command was detected. Please provide a valid command to execute.'
|
||||
}
|
||||
|
@ -246,7 +206,7 @@ export function CommandToolView({
|
|||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
|
||||
|
||||
<div className="px-4 py-2 h-10 bg-gradient-to-r from-zinc-50/90 to-zinc-100/90 dark:from-zinc-900/90 dark:to-zinc-800/90 backdrop-blur-sm border-t border-zinc-200 dark:border-zinc-800 flex justify-between items-center gap-4">
|
||||
<div className="h-full flex items-center gap-2 text-sm text-zinc-500 dark:text-zinc-400">
|
||||
{!isStreaming && displayText && (
|
||||
|
@ -256,7 +216,7 @@ export function CommandToolView({
|
|||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
<div className="text-xs text-zinc-500 dark:text-zinc-400 flex items-center gap-2">
|
||||
<Clock className="h-3.5 w-3.5" />
|
||||
{actualToolTimestamp && !isStreaming
|
||||
|
|
Loading…
Reference in New Issue