Download packages/util/native-command/src/runner.ts from SaylorTwift/deepseek-harness: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/SaylorTwift/deepseek-harness/resolve/main/packages/util/native-command/src/runner.ts
- Command line
-
hf download hf://SaylorTwift/deepseek-harness/packages/util/native-command/src/runner.ts
-
curl -L -o runner.ts https://huggingface.co/SaylorTwift/deepseek-harness/resolve/main/packages/util/native-command/src/runner.ts
1.27 kB
| /** | |
| * Shared no-shell `execFile` runner for host-native OS integrations. | |
| * @module @deepseek-ai/dsh-native-command/runner | |
| */ | |
| import { execFile } from 'node:child_process' | |
| /** Testable command boundary; native implementations never invoke a shell. */ | |
| export type NativeCommandRunner = ( | |
| command: string, | |
| args: readonly string[], | |
| signal: AbortSignal, | |
| ) => Promise<{ stdout: string; stderr: string }> | |
| /** | |
| * Run a host command with utf8 stdio, abort propagation, and Windows hide. | |
| * @param command - executable path or PATH name. | |
| * @param args - argv (never a shell string). | |
| * @param signal - caller/connection lifetime; abort terminates the child. | |
| * @returns captured stdout/stderr on exit 0. | |
| */ | |
| export const runNativeCommand: NativeCommandRunner = (command, args, signal) => | |
| new Promise((resolve, reject) => { | |
| execFile( | |
| command, | |
| [...args], | |
| { encoding: 'utf8', signal, windowsHide: true }, | |
| (error, stdout, stderr) => { | |
| if (error !== null) { | |
| const failure = Object.assign(new Error(error.message, { cause: error }), { | |
| code: error.code, | |
| stdout, | |
| stderr, | |
| }) | |
| reject(failure) | |
| return | |
| } | |
| resolve({ stdout, stderr }) | |
| }, | |
| ) | |
| }) | |