Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Add support for ephemeral storage

f-trycuac88ef772cc3f
diff --git a/libs/lume/src/FileSystem/Home.swift b/libs/lume/src/FileSystem/Home.swift
index d83b39b09a..634e3bef3f 100644
--- a/libs/lume/src/FileSystem/Home.swift
+++ b/libs/lume/src/FileSystem/Home.swift
@@ -72,6 +72,22 @@ final class Home {
/// - Returns: A VMDirectory instance
/// - Throws: HomeError if location not found
func getVMDirectory(_ name: String, storage: String? = nil) throws -> VMDirectory {
+ // Special case for ephemeral storage using macOS temporary directory
+ if let storage = storage, storage == "ephemeral" {
+ // Get the current temporary directory
+ let tmpDir = ProcessInfo.processInfo.environment["TMPDIR"] ?? "/tmp"
+ // Remove trailing slash if present
+ let cleanPath = tmpDir.hasSuffix("/") ? String(tmpDir.dropLast()) : tmpDir
+
+ // Create the directory if it doesn't exist
+ if !fileExists(at: cleanPath) {
+ try createVMLocation(at: cleanPath)
+ }
+
+ let baseDir = Path(cleanPath)
+ return VMDirectory(baseDir.directory(name))
+ }
+
let location: VMLocation
if let storage = storage {
@@ -123,6 +139,55 @@ final class Home {
// Loop through all locations
let settings = settingsManager.getSettings()
+
+ // Also check ephemeral directory (macOS temporary directory)
+ let tmpDir = ProcessInfo.processInfo.environment["TMPDIR"] ?? "/tmp"
+ let cleanPath = tmpDir.hasSuffix("/") ? String(tmpDir.dropLast()) : tmpDir
+
+ // If tmp directory exists, check for VMs there
+ if fileExists(at: cleanPath) {
+ let tmpDirPath = Path(cleanPath)
+ do {
+ let directoryURL = URL(fileURLWithPath: cleanPath)
+ let contents = try FileManager.default.contentsOfDirectory(
+ at: directoryURL,
+ includingPropertiesForKeys: [.isDirectoryKey],
+ options: .skipsHiddenFiles
+ )
+
+ for subdir in contents {
+ do {
+ guard let isDirectory = try subdir.resourceValues(forKeys: [.isDirectoryKey]).isDirectory,
+ isDirectory else {
+ continue
+ }
+
+ let vmName = subdir.lastPathComponent
+ let vmDir = VMDirectory(tmpDirPath.directory(vmName))
+
+ // Only include if it's a valid VM directory
+ if vmDir.initialized() {
+ results.append(VMDirectoryWithLocation(
+ directory: vmDir,
+ locationName: "ephemeral"
+ ))
+ }
+ } catch {
+ // Skip any directories we can't access
+ continue
+ }
+ }
+ } catch {
+ Logger.error(
+ "Failed to access ephemeral directory",
+ metadata: [
+ "path": cleanPath,
+ "error": error.localizedDescription,
+ ]
+ )
+ // Continue to regular locations rather than failing completely
+ }
+ }
for location in settings.vmLocations {
let locationPath = Path(location.expandedPath)