Commands & shell
SSHCommand
public final class SSHCommand: @unchecked Sendable {
public let events: AsyncStream<SSHCommandEvent>
public func write(_ data: Data) async throws
public func write(_ string: String, encoding: String.Encoding = .utf8) async throws
public func sendEOF() async throws
public func close() async throws
}
Callback overloads exist for write(_ data:), sendEOF, and close.
SSHCommandEvent
public enum SSHCommandEvent: Equatable, Sendable {
case standardOutput(Data)
case standardError(Data)
case closed(Int32, exitSignal: String? = nil)
}
SSHCommandResult
public struct SSHCommandResult: Equatable, Sendable {
public var standardOutput: Data
public var standardError: Data
public var exitStatus: Int32
public var exitSignal: String?
public init(
standardOutput: Data,
standardError: Data,
exitStatus: Int32,
exitSignal: String? = nil
)
}
SSHShell
public final class SSHShell: @unchecked Sendable {
public func write(_ data: Data) async throws
public func write(_ string: String, encoding: String.Encoding = .utf8) async throws
public func resize(columns: UInt16, rows: UInt16) async throws
public func close() async throws
}
Callback overloads exist for write(_ data:), resize, and close.
The PTY is requested with a fixed, conservative mode set — echo is on, the line discipline is canonical, signals and software flow control are enabled, CR/LF is translated both ways, and UTF-8 input is on. The public API only exposes terminalType, columns, and rows; the rest of the line discipline is not currently configurable. See PTY modes in the shell guide for the full table and the implications for terminal-view integrations.
SSHShellEvent
public enum SSHShellEvent: Equatable, Sendable {
case standardOutput(Data)
case standardError(Data) // reserved; PTY-backed shells merge stderr into stdout
case closed(Int32)
}