mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-21 01:51:39 -06:00
341551937e
* fix(agents): preserve empty CLI subagent completions * chore(qa): remove retired Matrix coverage leaf * refactor: consolidate shared runtime ownership * fix(scripts): keep runtime build coercion dependency-light * chore: remove release-owned changelog entry
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
// Typed bridge to the plain-Node Windows command helpers.
|
|
import { isRecord } from "./record-shared.mjs";
|
|
|
|
const runtimeSpecifier = "../windows-cmd-helpers.mjs";
|
|
const runtime: unknown = await import(runtimeSpecifier);
|
|
|
|
function runtimeFunction(name: string): (...args: unknown[]) => unknown {
|
|
if (!isRecord(runtime) || !(name in runtime)) {
|
|
throw new Error(`windows command helper is missing ${name}`);
|
|
}
|
|
const value = runtime[name];
|
|
if (typeof value !== "function") {
|
|
throw new Error(`windows command helper ${name} is not callable`);
|
|
}
|
|
return (...args) => value(...args);
|
|
}
|
|
|
|
const buildCmdExeCommandLineImpl = runtimeFunction("buildCmdExeCommandLine");
|
|
const resolvePathEnvKeyImpl = runtimeFunction("resolvePathEnvKey");
|
|
const resolveWindowsCmdExePathImpl = runtimeFunction("resolveWindowsCmdExePath");
|
|
|
|
export function buildCmdExeCommandLine(command: string, args: string[]): string {
|
|
const result = buildCmdExeCommandLineImpl(command, args);
|
|
if (typeof result !== "string") {
|
|
throw new Error("buildCmdExeCommandLine returned a non-string result");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function resolvePathEnvKey(env: NodeJS.ProcessEnv): string {
|
|
const result = resolvePathEnvKeyImpl(env);
|
|
if (typeof result !== "string") {
|
|
throw new Error("resolvePathEnvKey returned a non-string result");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function resolveWindowsCmdExePath(env: NodeJS.ProcessEnv = process.env): string {
|
|
const result = resolveWindowsCmdExePathImpl(env);
|
|
if (typeof result !== "string") {
|
|
throw new Error("resolveWindowsCmdExePath returned a non-string result");
|
|
}
|
|
return result;
|
|
}
|