openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 1.86 kB
JavaScript
import{a as extractErrorCode}from"./error-coercion-DlKnt6w-.mjs";import"./errors-D37BJTfI.mjs";import{i as withChildProcessOperation}from"./spawn-diagnostics-C-LTFiNq.mjs";import{a as hasCommandProcessCleanupError,i as createSanitizedCommandError,t as CommandProcessCleanupError}from"./exec-result-TD4w1Z1i.mjs";import{t as resolveServiceManagerEnv}from"./service-process-env-CqJdumJx.mjs";import{n as runCommandWithTimeout}from"./exec-runner-BiCq-T1F.mjs";import"./exec-c5tqm8tb.mjs";import{a as getGatewayServiceUpdateNativeCommand,i as assertGatewayServiceUpdateCurrent,n as GatewayServiceAuthorityError}from"./service-update-authority-DqjrBTQ9.mjs";
//!src/daemon/exec-file.ts
async function execFileUtf8(e,t,n={}){const r=getGatewayServiceUpdateNativeCommand();const i=r?true:assertGatewayServiceUpdateCurrent();let a;const o=n.beforeEffect?()=>{try{n.beforeEffect?.()}catch(e){a={error:e};throw e}}:void 0;try{o?.();const a=r??runCommandWithTimeout;const{stdout:s,stderr:c,code:l,termination:u,signal:d,cleanup:f}=await withChildProcessOperation(`service.manager`,()=>a([e,...t],{baseEnv:resolveServiceManagerEnv(n.env),cwd:n.cwd??(process.platform===`win32`?void 0:`/`),killSignal:n.killSignal,maxOutputBytes:1048576,timeoutMs:n.timeout,...r&&o?{beforeInput:o}:{}}));if(i&&f===`uncertain`)throw new CommandProcessCleanupError;if(!r)assertGatewayServiceUpdateCurrent();return{stdout:s,stderr:[c,u===`exit`?``:createSanitizedCommandError({timedOut:u===`timeout`||u===`no-output-timeout`,isTerminated:true,signal:d}).message].filter(Boolean).join(`
`),code:u===`exit`?l??1:l||1,termination:u}}catch(e){if(e instanceof GatewayServiceAuthorityError||hasCommandProcessCleanupError(e))throw e;if(a)throw a.error;return{stdout:``,stderr:e instanceof Error?e.message:String(e),code:1,termination:`error`,errorCode:extractErrorCode(e)}}}export{execFileUtf8 as t};