openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
81 lines (80 loc) • 2.38 kB
JavaScript
import { p as resolveGatewayProfileSuffix, s as NODE_SERVICE_KIND, y as resolveNodeServiceIdentityEnvironment } from "./constants-BZisy3jr.mjs";
import { n as resolveGatewayService } from "./service-hQiIzcTo.mjs";
//#region 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 () => {
await t.beforeMutation?.();
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.`);
}
});
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)
};
}
//#endregion
export { resolveNodeService as t };