public struct ShellDefinition: Sendable {
public let prompt: String
public let welcomeMessage: String
public let fallbackMessage: @Sendable (String) -> String
public init(
prompt: String = "$ ",
welcomeMessage: String? = nil,
fallback: (@Sendable (String) -> String)? = nil,
@ShellCommandBuilder _ build: () -> [ShellCommand]
)
}
ShellCommand
public enum CommandResult: Sendable {
case output(String)
case clear
case exit
}
public struct CommandContext: Sendable {
public let command: String
public let arguments: String
public let username: String
public let terminalSize: InMemoryTerminalViewport
}
public struct ShellCommand: Sendable {
public let name: String
public let summary: String
public init(
_ name: String,
summary: String = "",
handler: @escaping @Sendable (CommandContext) -> CommandResult
)
}
ShellSession
public final class ShellSession {
public let terminalSession: InMemoryTerminalSession
public init(shell: ShellDefinition)
public func start()
}
public let defaultSandboxShell: ShellDefinition
public let sandboxShell: ShellDefinition