UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

62 lines (61 loc) • 2.55 kB
import { t as formatErrorMessage } from "./errors-O33D01XW.mjs"; import { G as isSystemdUserServiceAvailable } from "./systemd-service-files-Cc5QKjzs.mjs"; import { n as resolveGatewayService } from "./service-C5e3lih7.mjs"; import "./systemd-Ch3siJBj.mjs"; import { n as gatewayInstallErrorHint } from "./daemon-install-helpers-Dr3Z2yOJ.mjs"; import { t as resolveGatewayInstallToken } from "./gateway-install-token-BN102WV5.mjs"; import { n as prepareGatewayServiceInstall, t as resolveGatewaySetupRuntime } from "./gateway-setup-runtime-B34d6q8G.mjs"; import { n as ensureSystemdUserLingerNonInteractive } from "./systemd-linger-pt8d1njG.mjs"; //#region src/commands/onboard-non-interactive/local/daemon-install.ts /** Installs the managed gateway daemon when non-interactive setup requested it. */ async function installGatewayDaemonNonInteractive(params) { const { opts, runtime, port } = params; const systemdAvailable = process.platform === "linux" ? await isSystemdUserServiceAvailable() : true; if (process.platform === "linux" && !systemdAvailable) { runtime.log("Systemd user services are unavailable; skipping service install. Use a direct shell run (`openclaw gateway run`) or rerun without --install-daemon on this session."); return { installed: false, skippedReason: "systemd-user-unavailable" }; } const service = resolveGatewayService(); const tokenResolution = await resolveGatewayInstallToken({ config: params.nextConfig, env: process.env }); for (const warning of tokenResolution.warnings) runtime.log(warning); if (tokenResolution.unavailableReason) { runtime.error([ "Gateway install blocked:", tokenResolution.unavailableReason, "Fix gateway auth config/token input and rerun setup." ].join(" ")); runtime.exit(1); return { installed: false }; } const existingCommand = await service.readCommand(process.env); const selection = await resolveGatewaySetupRuntime({ env: process.env, existingCommand, runtime: opts.daemonRuntime }); const installation = await prepareGatewayServiceInstall({ service, selection, port, existingCommand, warn: (message) => runtime.log(message), config: params.nextConfig }); try { await installation.install(); } catch (err) { runtime.error(`Gateway service install failed: ${formatErrorMessage(err)}`); runtime.log(gatewayInstallErrorHint()); return { installed: false }; } await ensureSystemdUserLingerNonInteractive({ runtime }); return { installed: true }; } //#endregion export { installGatewayDaemonNonInteractive };