Files
Termind/Frameworks/TermindRemoteInfrastructure/SSH/RemoteMultiplexerService.swift
T
Kaede Akino 9da4b350cf refactor: register terminal backends and reuse shared workflows
Extract multiplexer dialect and resumable terminal engine registries while preserving session and checkpoint compatibility.

Share local-network and theme policies, add regression coverage, and update discovery actions to Cancel and Rescan with localized Telnet copy.
2026-10-16 20:02:13 +08:00

46 lines
2.0 KiB
Swift

import Foundation
import TermindApplication
import TermindDomain
/// A single service entry point; command dialects retain their native identity contracts.
public nonisolated struct RemoteMultiplexerService: RemoteSessionBackend {
public typealias Executor = RemoteSessionCommandExecutor
public let id: SessionPersistenceBackendID
private let implementation: (any RemoteSessionBackend)?
public init(backend: SessionPersistenceBackendID = .tmux, execute: @escaping Executor) {
id = backend
implementation = RemoteMultiplexerRegistry.dialect(backend)?.backend(execute: execute)
}
private var backend: any RemoteSessionBackend {
get throws {
guard let implementation else {
throw RemoteSessionFailure.unsupported
}
return implementation
}
}
public var capabilities: RemoteSessionCapabilities {
(try? backend.capabilities) ?? .init()
}
public func probe() async throws -> RemoteSessionCapabilities { try await backend.probe() }
public func sessions() async throws -> [RemoteSessionDescriptor] { try await backend.sessions() }
public func validate(_ reference: RemoteSessionReference) throws { try backend.validate(reference) }
public func matches(_ reference: RemoteSessionReference, session: RemoteSessionDescriptor) -> Bool {
(try? backend.matches(reference, session: session)) ?? false
}
public func create(
token: UUID, startupCommand: String?, shellIntegration: Bool, environment: [HostEnvironmentVariable] = []
) async throws -> RemoteSessionDescriptor {
try await backend.create(
token: token, startupCommand: startupCommand, shellIntegration: shellIntegration, environment: environment)
}
public func launch(_ attachment: RemoteSessionReference, created: Bool) throws -> RemoteSessionLaunch {
try backend.launch(attachment, created: created)
}
public func terminate(_ attachment: RemoteSessionReference) async throws { try await backend.terminate(attachment) }
}