mirror of https://github.com/kortix-ai/suna.git
fix daytona sandbox url
This commit is contained in:
parent
ddc4887627
commit
b71762bafd
|
@ -299,12 +299,29 @@ async def start_agent(
|
||||||
sandbox = create_sandbox(sandbox_pass)
|
sandbox = create_sandbox(sandbox_pass)
|
||||||
logger.info(f"Created new sandbox with preview: {sandbox.get_preview_link(6080)}/vnc_lite.html?password={sandbox_pass}")
|
logger.info(f"Created new sandbox with preview: {sandbox.get_preview_link(6080)}/vnc_lite.html?password={sandbox_pass}")
|
||||||
sandbox_id = sandbox.id
|
sandbox_id = sandbox.id
|
||||||
|
|
||||||
|
# Get preview links
|
||||||
|
vnc_link = sandbox.get_preview_link(6080)
|
||||||
|
website_link = sandbox.get_preview_link(8080)
|
||||||
|
|
||||||
|
# Extract the actual URLs and token from the preview link objects
|
||||||
|
vnc_url = vnc_link.url if hasattr(vnc_link, 'url') else str(vnc_link).split("url='")[1].split("'")[0]
|
||||||
|
website_url = website_link.url if hasattr(website_link, 'url') else str(website_link).split("url='")[1].split("'")[0]
|
||||||
|
|
||||||
|
# Extract token if available
|
||||||
|
token = None
|
||||||
|
if hasattr(vnc_link, 'token'):
|
||||||
|
token = vnc_link.token
|
||||||
|
elif "token='" in str(vnc_link):
|
||||||
|
token = str(vnc_link).split("token='")[1].split("'")[0]
|
||||||
|
|
||||||
await client.table('projects').update({
|
await client.table('projects').update({
|
||||||
'sandbox': {
|
'sandbox': {
|
||||||
'id': sandbox_id,
|
'id': sandbox_id,
|
||||||
'pass': sandbox_pass,
|
'pass': sandbox_pass,
|
||||||
'vnc_preview': str(sandbox.get_preview_link(6080)),
|
'vnc_preview': vnc_url,
|
||||||
'sandbox_url': str(sandbox.get_preview_link(8080))
|
'sandbox_url': website_url,
|
||||||
|
'token': token
|
||||||
}
|
}
|
||||||
}).eq('project_id', project_id).execute()
|
}).eq('project_id', project_id).execute()
|
||||||
|
|
||||||
|
|
|
@ -152,10 +152,15 @@ class SandboxToolsBase(Tool):
|
||||||
logger.error(f"Error retrieving sandbox: {str(e)}", exc_info=True)
|
logger.error(f"Error retrieving sandbox: {str(e)}", exc_info=True)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
# Get and log preview links
|
# Get preview links
|
||||||
vnc_url = self.sandbox.get_preview_link(6080)
|
vnc_link = self.sandbox.get_preview_link(6080)
|
||||||
website_url = self.sandbox.get_preview_link(8080)
|
website_link = self.sandbox.get_preview_link(8080)
|
||||||
|
|
||||||
|
# Extract the actual URLs from the preview link objects
|
||||||
|
vnc_url = vnc_link.url if hasattr(vnc_link, 'url') else str(vnc_link)
|
||||||
|
website_url = website_link.url if hasattr(website_link, 'url') else str(website_link)
|
||||||
|
|
||||||
|
# Log the actual URLs
|
||||||
logger.info(f"Sandbox VNC URL: {vnc_url}")
|
logger.info(f"Sandbox VNC URL: {vnc_url}")
|
||||||
logger.info(f"Sandbox Website URL: {website_url}")
|
logger.info(f"Sandbox Website URL: {website_url}")
|
||||||
|
|
||||||
|
|
|
@ -139,12 +139,12 @@ export function FileOperationToolView({
|
||||||
const isCsv = fileName.endsWith('.csv');
|
const isCsv = fileName.endsWith('.csv');
|
||||||
const language = getLanguageFromFileName(fileName);
|
const language = getLanguageFromFileName(fileName);
|
||||||
const hasHighlighting = language !== 'text';
|
const hasHighlighting = language !== 'text';
|
||||||
|
|
||||||
// Construct HTML file preview URL if we have a sandbox and the file is HTML
|
// Construct HTML file preview URL if we have a sandbox and the file is HTML
|
||||||
const htmlPreviewUrl = (isHtml && project?.sandbox?.sandbox_url && processedFilePath)
|
const htmlPreviewUrl = (isHtml && project?.sandbox?.sandbox_url && processedFilePath)
|
||||||
? `${project.sandbox.sandbox_url}/${processedFilePath}`
|
? `${project.sandbox.sandbox_url}/${processedFilePath}`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
console.log('HTML Preview URL:', htmlPreviewUrl);
|
||||||
// Add state for view mode toggle (code or preview)
|
// Add state for view mode toggle (code or preview)
|
||||||
const [viewMode, setViewMode] = useState<'code' | 'preview'>(isHtml || isMarkdown || isCsv ? 'preview' : 'code');
|
const [viewMode, setViewMode] = useState<'code' | 'preview'>(isHtml || isMarkdown || isCsv ? 'preview' : 'code');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue