Repository Public
1import Foundation2import ClaudeIntegration3import RemoteCore4import TerminalCore5import WorkspaceCore67/// Resolves every `SessionKind` into a concrete launch. Immutable snapshot: the controller rebuilds8/// it whenever the Claude CLI, hook settings or host list change.9struct CompositeLaunchPlanner: LaunchPlanning {10 let claudeCLIPath: String?11 let hooksSettingsPath: String?12 let hosts: [HostID: SSHHost]13 let local = LocalLaunchPlanner()1415 func launchSpec(for profile: SessionProfile, sessionID: SessionID) throws -> LaunchSpec {16 var env = ShellDiscovery.baseEnvironment(sessionID: sessionID)17 for (k, v) in profile.environment { env[k] = v }18 let cwd = profile.workingDirectory ?? ShellDiscovery.homeDirectory()19 switch profile.kind {20 case .claude(let claudeSessionID, let resume):21 guard let claudeCLIPath else { throw LaunchPlanningError.executableNotFound("claude") }22 let args = ClaudeLaunchBuilder.arguments(sessionID: claudeSessionID, resume: resume, hooksSettingsPath: hooksSettingsPath)23 return LaunchSpec(executable: claudeCLIPath, arguments: args, environment: env, workingDirectory: cwd)24 case .ssh(let hostID, let tmux):25 guard let host = hosts[hostID] else { throw LaunchPlanningError.unsupported("SSH host \(hostID.shortString) is no longer configured") }26 let args = SSHCommandBuilder.arguments(for: host, tmuxSession: tmux)27 return LaunchSpec(executable: SSHCommandBuilder.executable, arguments: args, environment: env, workingDirectory: cwd)28 default:29 return try local.launchSpec(for: profile, sessionID: sessionID)30 }31 }32}33