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.

fix(lume): use Xcode 16.2 (Swift 6.2) in CI workflows (#948)

Francesco Bonaccibb83a83f65ba
diff --git a/.github/workflows/cd-swift-lume.yml b/.github/workflows/cd-swift-lume.yml
index de57a86017..eae3a973ff 100644
--- a/.github/workflows/cd-swift-lume.yml
+++ b/.github/workflows/cd-swift-lume.yml
@@ -53,9 +53,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- - name: Select Xcode 16
+ - name: Select Xcode 16.2
run: |
- sudo xcode-select -s /Applications/Xcode_16.app
+ sudo xcode-select -s /Applications/Xcode_16.2.app
xcodebuild -version
- name: Install dependencies
diff --git a/.github/workflows/ci-swift-lume.yml b/.github/workflows/ci-swift-lume.yml
index 0c121215bb..4cfa569bb0 100644
--- a/.github/workflows/ci-swift-lume.yml
+++ b/.github/workflows/ci-swift-lume.yml
@@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: uname -a
- - run: sudo xcode-select -s /Applications/Xcode_16.app # Swift 6.0
+ - run: sudo xcode-select -s /Applications/Xcode_16.2.app # Swift 6.2
- run: swift test
working-directory: ./libs/lume
build:
@@ -27,6 +27,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: uname -a
- - run: sudo xcode-select -s /Applications/Xcode_16.app # Swift 6.0
+ - run: sudo xcode-select -s /Applications/Xcode_16.2.app # Swift 6.2
- run: swift build --configuration release
working-directory: ./libs/lume
diff --git a/docs/content/docs/lume/guide/getting-started/installation.mdx b/docs/content/docs/lume/guide/getting-started/installation.mdx
index bf4ce242cf..f6cb63021b 100644
--- a/docs/content/docs/lume/guide/getting-started/installation.mdx
+++ b/docs/content/docs/lume/guide/getting-started/installation.mdx
@@ -104,29 +104,24 @@ rm ~/Library/LaunchAgents/com.trycua.lume_updater.plist
## Uninstall
-Remove Lume completely:
+Remove Lume with a single command:
```bash
-# Stop and remove background service
-launchctl unload ~/Library/LaunchAgents/com.trycua.lume_daemon.plist 2>/dev/null
-rm -f ~/Library/LaunchAgents/com.trycua.lume_daemon.plist
-
-# Stop and remove auto-updater
-launchctl unload ~/Library/LaunchAgents/com.trycua.lume_updater.plist 2>/dev/null
-rm -f ~/Library/LaunchAgents/com.trycua.lume_updater.plist
-rm -f ~/.local/bin/lume-update
+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/uninstall.sh)"
+```
-# Optional: Remove cached images (run before removing binary)
-lume prune
+This stops all services, removes the binary, and cleans up LaunchAgents while preserving your VMs and configuration.
-# Remove Lume binary
-rm -f $(which lume)
+To also remove all VMs and data, use the `--purge` flag:
-# Optional: Remove VMs and config
-rm -rf ~/.lume
-rm -rf ~/.config/lume
+```bash
+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/uninstall.sh)" -- --purge
```
+<Callout type="warn">
+The `--purge` flag permanently deletes all VMs in `~/.lume/` and configuration in `~/.config/lume/`. This cannot be undone.
+</Callout>
+
## Troubleshooting
**`lume: command not found`** — The install location (`~/.local/bin`) isn't in your PATH. Add it and reload:
diff --git a/docs/content/docs/lume/reference/cli-reference.mdx b/docs/content/docs/lume/reference/cli-reference.mdx
index 1a04ae127f..800ea54aec 100644
--- a/docs/content/docs/lume/reference/cli-reference.mdx
+++ b/docs/content/docs/lume/reference/cli-reference.mdx
@@ -156,6 +156,24 @@ List virtual machines
- `-f, --format` - Output format (json or text) (default: text)
- `--storage` - Filter by storage location name
+## Remote Access
+
+### lume ssh
+
+Connect to a VM via SSH or execute commands remotely
+
+**Arguments:**
+
+- `<name>` - Name of the virtual machine
+- `<command>` - Command to execute (omit for interactive shell) (optional)
+
+**Options:**
+
+- `-u, --user` - SSH username (default: lume)
+- `-p, --password` - SSH password (default: lume)
+- `--storage` - Storage location name or path
+- `-t, --timeout` - Command timeout in seconds (0 for no timeout) (default: 60)
+
## Image Management
### lume pull
diff --git a/libs/lume/src/SSH/SSHClient.swift b/libs/lume/src/SSH/SSHClient.swift
index d1566b82d9..911bc8efb5 100644
--- a/libs/lume/src/SSH/SSHClient.swift
+++ b/libs/lume/src/SSH/SSHClient.swift
@@ -1,8 +1,8 @@
import Foundation
-import NIOCore
-import NIOConcurrencyHelpers
-import NIOPosix
-import NIOSSH
+@preconcurrency import NIOCore
+@preconcurrency import NIOConcurrencyHelpers
+@preconcurrency import NIOPosix
+@preconcurrency import NIOSSH
/// Result of an SSH command execution
public struct SSHResult: Sendable {
@@ -48,7 +48,8 @@ public actor SSHClient {
let resultPromise = channel.eventLoop.makePromise(of: SSHResult.self)
// Create the SSH child channel for command execution
- let sshHandler = try await channel.pipeline.handler(type: NIOSSHHandler.self).get()
+ // nonisolated(unsafe) is safe because NIOSSHHandler is confined to its event loop
+ nonisolated(unsafe) let sshHandler = try await channel.pipeline.handler(type: NIOSSHHandler.self).get()
let childChannelPromise = channel.eventLoop.makePromise(of: Channel.self)
sshHandler.createChannel(childChannelPromise) { childChannel, channelType in
@@ -92,7 +93,8 @@ public actor SSHClient {
let channel = try await connect()
// Create the SSH child channel for interactive session
- let sshHandler = try await channel.pipeline.handler(type: NIOSSHHandler.self).get()
+ // nonisolated(unsafe) is safe because NIOSSHHandler is confined to its event loop
+ nonisolated(unsafe) let sshHandler = try await channel.pipeline.handler(type: NIOSSHHandler.self).get()
let childChannelPromise = channel.eventLoop.makePromise(of: Channel.self)
let sessionCompletePromise = channel.eventLoop.makePromise(of: Void.self)
@@ -217,7 +219,8 @@ private final class PasswordAuthDelegate: NIOSSHClientUserAuthenticationDelegate
// MARK: - Command Execution Handler
/// Handles command execution on an SSH channel
-private final class CommandExecHandler: ChannelDuplexHandler {
+/// Note: @unchecked Sendable is safe because this handler is only used on a single event loop
+private final class CommandExecHandler: ChannelDuplexHandler, @unchecked Sendable {
typealias InboundIn = SSHChannelData
typealias InboundOut = ByteBuffer
typealias OutboundIn = ByteBuffer
@@ -236,16 +239,20 @@ private final class CommandExecHandler: ChannelDuplexHandler {
}
func handlerAdded(context: ChannelHandlerContext) {
+ // nonisolated(unsafe) is safe here because we're on the channel's event loop
+ nonisolated(unsafe) let ctx = context
context.channel.setOption(ChannelOptions.allowRemoteHalfClosure, value: true).whenFailure { error in
- context.fireErrorCaught(error)
+ ctx.fireErrorCaught(error)
}
}
func channelActive(context: ChannelHandlerContext) {
// Send exec request
+ // nonisolated(unsafe) is safe here because we're on the channel's event loop
+ nonisolated(unsafe) let ctx = context
let execRequest = SSHChannelRequestEvent.ExecRequest(command: command, wantReply: true)
context.triggerUserOutboundEvent(execRequest).whenFailure { [weak self] error in
- self?.failWithError(error, context: context)
+ self?.failWithError(error, context: ctx)
}
}
@@ -325,7 +332,8 @@ private final class CommandExecHandler: ChannelDuplexHandler {
// MARK: - Interactive Session Handler
/// Handles interactive SSH sessions with stdin/stdout passthrough
-private final class InteractiveSessionHandler: ChannelDuplexHandler {
+/// Note: @unchecked Sendable is safe because this handler is only used on a single event loop
+private final class InteractiveSessionHandler: ChannelDuplexHandler, @unchecked Sendable {
typealias InboundIn = SSHChannelData
typealias InboundOut = ByteBuffer
typealias OutboundIn = ByteBuffer
@@ -341,12 +349,17 @@ private final class InteractiveSessionHandler: ChannelDuplexHandler {
}
func handlerAdded(context: ChannelHandlerContext) {
+ // nonisolated(unsafe) is safe here because we're on the channel's event loop
+ nonisolated(unsafe) let ctx = context
context.channel.setOption(ChannelOptions.allowRemoteHalfClosure, value: true).whenFailure { error in
- context.fireErrorCaught(error)
+ ctx.fireErrorCaught(error)
}
}
func channelActive(context: ChannelHandlerContext) {
+ // nonisolated(unsafe) is safe here because we're on the channel's event loop
+ nonisolated(unsafe) let ctx = context
+
// Request a pseudo-terminal
let ptyRequest = SSHChannelRequestEvent.PseudoTerminalRequest(
wantReply: true,
@@ -361,13 +374,17 @@ private final class InteractiveSessionHandler: ChannelDuplexHandler {
context.triggerUserOutboundEvent(ptyRequest).flatMap {
// Request a shell
let shellRequest = SSHChannelRequestEvent.ShellRequest(wantReply: true)
- return context.triggerUserOutboundEvent(shellRequest)
+ return ctx.triggerUserOutboundEvent(shellRequest)
}.whenComplete { [weak self] result in
- switch result {
- case .success:
- self?.setupTerminalAndStdin(context: context)
- case .failure(let error):
- self?.failWithError(error, context: context)
+ // Ensure we're on the event loop for NIOLoopBound creation
+ guard let self = self else { return }
+ ctx.eventLoop.execute { [weak self] in
+ switch result {
+ case .success:
+ self?.setupTerminalAndStdin(context: ctx)
+ case .failure(let error):
+ self?.failWithError(error, context: ctx)
+ }
}
}
}
@@ -385,7 +402,10 @@ private final class InteractiveSessionHandler: ChannelDuplexHandler {
let source = DispatchSource.makeReadSource(fileDescriptor: stdinFD, queue: .global())
stdinSource = source
- let loopBoundContext = NIOLoopBound(context, eventLoop: context.eventLoop)
+ // Capture channel and eventLoop directly (both are Sendable)
+ // Don't use NIOLoopBound as accessing .value requires being on the event loop
+ let channel = context.channel
+ let eventLoop = context.eventLoop
let fd = stdinFD
source.setEventHandler { [weak self] in
@@ -396,16 +416,16 @@ private final class InteractiveSessionHandler: ChannelDuplexHandler {
if bytesRead > 0 {
let data = Data(buffer[0..<bytesRead])
- loopBoundContext.value.eventLoop.execute {
- var byteBuffer = loopBoundContext.value.channel.allocator.buffer(capacity: bytesRead)
+ eventLoop.execute {
+ var byteBuffer = channel.allocator.buffer(capacity: bytesRead)
byteBuffer.writeBytes(data)
let channelData = SSHChannelData(type: .channel, data: .byteBuffer(byteBuffer))
- loopBoundContext.value.writeAndFlush(NIOAny(channelData), promise: nil)
+ channel.writeAndFlush(NIOAny(channelData), promise: nil)
}
} else if bytesRead == 0 {
// EOF on stdin
- loopBoundContext.value.eventLoop.execute {
- loopBoundContext.value.close(mode: .output, promise: nil)
+ eventLoop.execute {
+ channel.close(mode: .output, promise: nil)
}
}
}
@@ -486,7 +506,8 @@ private final class InteractiveSessionHandler: ChannelDuplexHandler {
// MARK: - Error Handler
/// Handles errors in the SSH pipeline
-private final class SSHErrorHandler: ChannelInboundHandler {
+/// Note: @unchecked Sendable is safe because this handler is only used on a single event loop
+private final class SSHErrorHandler: ChannelInboundHandler, @unchecked Sendable {
typealias InboundIn = Any
func errorCaught(context: ChannelHandlerContext, error: Error) {
diff --git a/libs/lume/src/Utils/CommandDocExtractor.swift b/libs/lume/src/Utils/CommandDocExtractor.swift
index 5479e2fb2a..f0e52a56ec 100644
--- a/libs/lume/src/Utils/CommandDocExtractor.swift
+++ b/libs/lume/src/Utils/CommandDocExtractor.swift
@@ -80,6 +80,7 @@ enum CommandDocExtractor {
listDoc,
runDoc,
stopDoc,
+ sshDoc,
ipswDoc,
serveDoc,
deleteDoc,
@@ -307,6 +308,28 @@ enum CommandDocExtractor {
)
}
+ // MARK: - SSH
+
+ private static var sshDoc: CommandDoc {
+ CommandDoc(
+ name: "ssh",
+ abstract: "Connect to a VM via SSH or execute commands remotely",
+ discussion: "Requires Remote Login to be enabled on the VM (System Settings > General > Sharing > Remote Login). VMs created with --unattended have this enabled automatically with credentials lume/lume.",
+ arguments: [
+ ArgumentDoc(name: "name", help: "Name of the virtual machine", type: "String", isOptional: false),
+ ArgumentDoc(name: "command", help: "Command to execute (omit for interactive shell)", type: "[String]", isOptional: true),
+ ],
+ options: [
+ OptionDoc(name: "user", shortName: "u", help: "SSH username", type: "String", defaultValue: "lume", isOptional: false),
+ OptionDoc(name: "password", shortName: "p", help: "SSH password", type: "String", defaultValue: "lume", isOptional: false),
+ OptionDoc(name: "storage", shortName: nil, help: "Storage location name or path", type: "String", defaultValue: nil, isOptional: true),
+ OptionDoc(name: "timeout", shortName: "t", help: "Command timeout in seconds (0 for no timeout)", type: "Int", defaultValue: "60", isOptional: false),
+ ],
+ flags: [],
+ subcommands: []
+ )
+ }
+
// MARK: - IPSW
private static var ipswDoc: CommandDoc {
diff --git a/scripts/docs-generators/lume.ts b/scripts/docs-generators/lume.ts
index 823d0887a3..fb5efdcbef 100644
--- a/scripts/docs-generators/lume.ts
+++ b/scripts/docs-generators/lume.ts
@@ -257,6 +257,7 @@ function generateCLIReferenceMDX(docs: CLIDocumentation): string {
// Group commands by category
const vmManagement = ['create', 'run', 'stop', 'delete', 'clone'];
const vmInfo = ['ls', 'get', 'set'];
+ const remoteAccess = ['ssh'];
const imageManagement = ['images', 'pull', 'push', 'ipsw', 'prune'];
const configuration = ['config', 'serve', 'logs', 'setup'];
@@ -272,6 +273,12 @@ function generateCLIReferenceMDX(docs: CLIDocumentation): string {
lines.push(...generateCommandDoc(cmd, '###'));
}
+ lines.push('## Remote Access');
+ lines.push('');
+ for (const cmd of docs.commands.filter((c) => remoteAccess.includes(c.name))) {
+ lines.push(...generateCommandDoc(cmd, '###'));
+ }
+
lines.push('## Image Management');
lines.push('');
for (const cmd of docs.commands.filter((c) => imageManagement.includes(c.name))) {