openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.96 kB
JavaScript
import{b as resolveNodeServiceIdentityEnvironment,c as NODE_SERVICE_KIND,m as resolveGatewayProfileSuffix}from"./constants-tH5Q8GoI.mjs";import{n as resolveGatewayService}from"./service-Bz63n2ee.mjs";
//!src/daemon/node-service.ts
function withNodeServiceEnv(e){return{...e,...resolveNodeServiceIdentityEnvironment(e)}}function withNodeInstallEnv(e){const t=resolveNodeServiceIdentityEnvironment(e.env);return{...e,env:{...e.env,...t},environment:{...e.environment,...t}}}function resolveNodeService(){const e=resolveGatewayService(`node`);const{hasInstalledDefinition:t,isAbsent:n,readDefinitionMutationCapability:r}=e;const owned=t=>({...t,beforeMutation:async()=>{const n=await e.readCommand(t.env);const r=n?.environment?.OPENCLAW_SERVICE_KIND?.trim();if(n&&r!==`node`&&(r||resolveGatewayProfileSuffix(t.env.OPENCLAW_PROFILE)))throw new Error(`${n.sourcePath??`The selected service`} is not an OpenClaw node service. Node commands left it unchanged; move the conflicting service before managing this node.`);await t.beforeMutation?.()}});return{...e,stage:t=>e.stage(owned(withNodeInstallEnv(t))),install:t=>e.install(owned(withNodeInstallEnv(t))),uninstall:t=>e.uninstall(owned({...t,env:withNodeServiceEnv(t.env)})),start:t=>e.start(owned({...t,env:withNodeServiceEnv(t.env??{})})),stop:t=>e.stop(owned({...t,env:withNodeServiceEnv(t.env??{})})),restart:t=>e.restart(owned({...t,env:withNodeServiceEnv(t.env??{})})),isLoaded:t=>{return e.isLoaded({env:withNodeServiceEnv(t.env??{}),timeoutMs:t.timeoutMs})},hasInstalledDefinition:t?e=>t({...e,env:withNodeServiceEnv(e.env??{})}):void 0,isAbsent:n?e=>n({...e,env:withNodeServiceEnv(e.env??{})}):void 0,readDefinitionMutationCapability:r?e=>r({...e,env:withNodeServiceEnv(e.env??{}),environment:e.environment?withNodeServiceEnv(e.environment):void 0}):void 0,readCommand:(t,n)=>e.readCommand(withNodeServiceEnv(t),n),readRuntime:(t,n)=>e.readRuntime(withNodeServiceEnv(t),n)}}export{resolveNodeService as t};