Files
orca/src/main/ipc/preflight-runtime-target.ts
T
0ec3882cb8 Add project Windows runtime selection (#5519)
* Add project Windows runtime selection

* Fix project Windows runtime selection

Co-authored-by: Orca <help@stably.ai>

* fix: preserve WSL shell variables

---------

Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Neil <neil@stably.ai>
2026-06-17 16:08:14 -07:00

33 lines
1007 B
TypeScript

import type { ProjectExecutionRuntimeResolution } from '../../shared/project-execution-runtime'
import type { WslPreflightTarget } from './preflight-wsl-agent-detection'
export type PreflightRuntimeContext = {
wslDistro?: string | null
wslDefault?: boolean
projectRuntime?: ProjectExecutionRuntimeResolution
}
export function getPreflightWslTarget(
context?: PreflightRuntimeContext,
platform: string = process.platform
): WslPreflightTarget | null {
if (platform !== 'win32') {
return null
}
if (context?.projectRuntime) {
if (context.projectRuntime.status === 'repair-required') {
throw new Error(
`Project runtime requires repair before preflight: ${context.projectRuntime.repair.reason}`
)
}
return context.projectRuntime.runtime.kind === 'wsl'
? { distro: context.projectRuntime.runtime.distro }
: null
}
const distro = context?.wslDistro?.trim()
if (distro) {
return { distro }
}
return context?.wslDefault ? {} : null
}