| 370 | |
| 371 | // Download execution logs |
| 372 | export async function fetchLogsZip(sessionId) { |
| 373 | try { |
| 374 | const response = await fetch(apiUrl(`/api/sessions/${encodeURIComponent(sessionId)}/download`)) |
| 375 | |
| 376 | if (!response.ok) { |
| 377 | throw new Error(`Download failed: ${response.status} ${response.statusText}`) |
| 378 | } |
| 379 | |
| 380 | // Get zip file data |
| 381 | const blob = await response.blob() |
| 382 | const url = window.URL.createObjectURL(blob) |
| 383 | |
| 384 | // Create a download link and trigger download |
| 385 | const link = document.createElement('a') |
| 386 | link.href = url |
| 387 | link.download = `execution_logs_${sessionId}.zip` |
| 388 | document.body.appendChild(link) |
| 389 | link.click() |
| 390 | |
| 391 | // Cleanup |
| 392 | document.body.removeChild(link) |
| 393 | window.URL.revokeObjectURL(url) |
| 394 | |
| 395 | return { success: true } |
| 396 | } catch (error) { |
| 397 | console.error('Failed to download execution logs:', error) |
| 398 | throw error |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | // Fetch session attachments |
| 403 | export async function getAttachment(sessionId, attachmentId) { |