mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* refactor: import journal queue state from defining owners * refactor(shared): organize execution and automation owners * fix: retain type imports used by surviving test cases * refactor: finish work item owners and refresh validation metadata * test: infer reconnect status fixture type * test(claude): resolve source files beside same-named directories * test(runtime): group repository creation mock registrations
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import type { GlobalSettings } from './global-settings-types'
|
|
import { normalizeGlobalWindowsRuntimeDefault } from './execution-host/project-runtime-preference'
|
|
|
|
export type LocalAccountRuntimeTarget = {
|
|
runtime: 'host' | 'wsl'
|
|
wslDistro: string | null
|
|
}
|
|
|
|
type LocalAccountRuntimeSettings = Pick<
|
|
GlobalSettings,
|
|
'localAccountRuntime' | 'localAccountWslDistro' | 'localWindowsRuntimeDefault'
|
|
>
|
|
|
|
/** Resolves the persisted account policy to a concrete host or WSL target. */
|
|
export function resolveLocalAccountRuntimeTarget(
|
|
settings: LocalAccountRuntimeSettings,
|
|
platform: NodeJS.Platform = process.platform
|
|
): LocalAccountRuntimeTarget {
|
|
if (settings.localAccountRuntime === 'host') {
|
|
return { runtime: 'host', wslDistro: null }
|
|
}
|
|
if (settings.localAccountRuntime === 'wsl') {
|
|
return { runtime: 'wsl', wslDistro: normalizeDistro(settings.localAccountWslDistro) }
|
|
}
|
|
|
|
// 'auto' (or any unset legacy value): follow the global Windows runtime default.
|
|
if (platform !== 'win32') {
|
|
return { runtime: 'host', wslDistro: null }
|
|
}
|
|
const runtimeDefault = normalizeGlobalWindowsRuntimeDefault(settings.localWindowsRuntimeDefault)
|
|
if (runtimeDefault.kind === 'wsl') {
|
|
return { runtime: 'wsl', wslDistro: runtimeDefault.distro }
|
|
}
|
|
return { runtime: 'host', wslDistro: null }
|
|
}
|
|
|
|
/** Usage pollers read the host off Windows, where a synced WSL policy has no distro to reach. */
|
|
export function resolveLocalAccountUsageTarget(
|
|
settings: LocalAccountRuntimeSettings,
|
|
platform: NodeJS.Platform = process.platform
|
|
): LocalAccountRuntimeTarget {
|
|
return platform === 'win32'
|
|
? resolveLocalAccountRuntimeTarget(settings, platform)
|
|
: { runtime: 'host', wslDistro: null }
|
|
}
|
|
|
|
export function localAccountRuntimeTargetKey(target: LocalAccountRuntimeTarget): string {
|
|
return target.runtime === 'wsl' ? `wsl:${target.wslDistro?.trim().toLowerCase() ?? ''}` : 'host'
|
|
}
|
|
|
|
function normalizeDistro(value: string | null | undefined): string | null {
|
|
const trimmed = value?.trim()
|
|
return trimmed ? trimmed : null
|
|
}
|