UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

25 lines • 1.54 kB
/** * The `launch-shim` role (senpi#3566, plan todo 4, Windows): started by a tool child for an explicit `detached: true` * launch. It starts the command outside the child's Job Object, writes `{"pid":N}` on fd 3 so the child can report * `command_started{breakaway:true}`, waits, and exits with the command's exit code. The shim itself stays in the job. */ import { writeSync } from "node:fs"; import { optOutChildPowerThrottling } from "../../../core/windows-power-throttling.js"; import { LAUNCH_SHIM_COMMAND_LINE_ENV } from "./launch-env-names.js"; import { loadKernel32Process, startBreakaway } from "./windows-breakaway.js"; const PID_FD = 3; export function runLaunchShimRole(env = process.env) { const commandLine = env[LAUNCH_SHIM_COMMAND_LINE_ENV]; const kernel = loadKernel32Process(); if (commandLine === undefined || commandLine === "" || kernel === undefined) { process.stderr.write(`launch-shim: ${kernel === undefined ? "kernel32 unavailable" : "command line unavailable"}\n`); process.exit(70); } // startBreakaway hands the command an environment without the shim's own role and command line. const command = startBreakaway(kernel, commandLine, env); // CreateProcessW is not a wrapped launcher, and the command leaves the job, so it needs its own EcoQoS opt-out (senpi#6125). optOutChildPowerThrottling(command.pid); writeSync(PID_FD, `${JSON.stringify({ pid: command.pid })}\n`); process.exit(command.wait()); } //# sourceMappingURL=launch-shim-role.js.map