mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* fix: deliver OMP generation prompts through owned files * test: preserve the OMP contract suite entry point * Preserve complete OMP generation prompts and retry owned cleanup * Load OMP cleanup fixture module outside test timeout * Deliver WSL generation prompts inside the execution guest * Cover deadline expiry before WSL generation authorization
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { spawn, type ChildProcess, type SpawnOptions } from 'node:child_process'
|
|
import { recordSubprocessSpawn } from '../../diagnostics/main-thread-churn-probe'
|
|
import {
|
|
commandLineLength,
|
|
MAX_COMMAND_LINE_CHARS,
|
|
WindowsCommandLineBudgetError
|
|
} from '../../../shared/windows-command-line-budget'
|
|
import { resolveCommand, withWslPreparation } from './wsl-command-resolution'
|
|
|
|
export function wslAwareSpawn(
|
|
command: string,
|
|
args: string[],
|
|
options: SpawnOptions & {
|
|
cwd?: string
|
|
wslDistro?: string
|
|
useWslLoginShell?: boolean
|
|
wslShellCommand?: string
|
|
cwdFailureExitCode?: number
|
|
preparation?: { script: string; args: string[] }
|
|
}
|
|
): ChildProcess {
|
|
const {
|
|
wslDistro,
|
|
useWslLoginShell,
|
|
wslShellCommand,
|
|
cwdFailureExitCode,
|
|
preparation,
|
|
...spawnOptions
|
|
} = options
|
|
let resolved = resolveCommand(command, args, options.cwd, wslDistro, {
|
|
useWslLoginShell,
|
|
wslShellCommand,
|
|
...(cwdFailureExitCode === undefined ? {} : { cwdFailureExitCode })
|
|
})
|
|
if (preparation && resolved.wsl) {
|
|
resolved = withWslPreparation(resolved, preparation)
|
|
if (commandLineLength([resolved.binary, ...resolved.args]) > MAX_COMMAND_LINE_CHARS) {
|
|
throw new WindowsCommandLineBudgetError()
|
|
}
|
|
}
|
|
const spawnStartedAt = performance.now()
|
|
const child = spawn(resolved.binary, resolved.args, {
|
|
...spawnOptions,
|
|
windowsHide: true,
|
|
cwd: resolved.cwd
|
|
})
|
|
recordSubprocessSpawn(resolved.binary, resolved.args, performance.now() - spawnStartedAt)
|
|
return child
|
|
}
|