mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 05:14:33 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import path from "node:path";
|
||||
|
||||
import type { MoltbotConfig } from "../config/config.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveGatewayPort, resolveIsNixMode } from "../config/paths.js";
|
||||
import { findExtraGatewayServices, renderGatewayServiceCleanupHints } from "../daemon/inspect.js";
|
||||
import { findLegacyGatewayServices, uninstallLegacyGatewayServices } from "../daemon/legacy.js";
|
||||
import { renderSystemNodeWarning, resolveSystemNodeInfo } from "../daemon/runtime-paths.js";
|
||||
import { resolveGatewayService } from "../daemon/service.js";
|
||||
import {
|
||||
@@ -13,12 +12,8 @@ import {
|
||||
} from "../daemon/service-audit.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { note } from "../terminal/note.js";
|
||||
import { buildGatewayInstallPlan, gatewayInstallErrorHint } from "./daemon-install-helpers.js";
|
||||
import {
|
||||
DEFAULT_GATEWAY_DAEMON_RUNTIME,
|
||||
GATEWAY_DAEMON_RUNTIME_OPTIONS,
|
||||
type GatewayDaemonRuntime,
|
||||
} from "./daemon-runtime.js";
|
||||
import { buildGatewayInstallPlan } from "./daemon-install-helpers.js";
|
||||
import { DEFAULT_GATEWAY_DAEMON_RUNTIME, type GatewayDaemonRuntime } from "./daemon-runtime.js";
|
||||
import type { DoctorOptions, DoctorPrompter } from "./doctor-prompter.js";
|
||||
|
||||
function detectGatewayRuntime(programArguments: string[] | undefined): GatewayDaemonRuntime {
|
||||
@@ -42,92 +37,8 @@ function normalizeExecutablePath(value: string): string {
|
||||
return path.resolve(value);
|
||||
}
|
||||
|
||||
export async function maybeMigrateLegacyGatewayService(
|
||||
cfg: MoltbotConfig,
|
||||
mode: "local" | "remote",
|
||||
runtime: RuntimeEnv,
|
||||
prompter: DoctorPrompter,
|
||||
) {
|
||||
const legacyServices = await findLegacyGatewayServices(process.env);
|
||||
if (legacyServices.length === 0) return;
|
||||
|
||||
note(
|
||||
legacyServices.map((svc) => `- ${svc.label} (${svc.platform}, ${svc.detail})`).join("\n"),
|
||||
"Legacy gateway services detected",
|
||||
);
|
||||
|
||||
const migrate = await prompter.confirmSkipInNonInteractive({
|
||||
message: "Migrate legacy gateway services to Moltbot now?",
|
||||
initialValue: true,
|
||||
});
|
||||
if (!migrate) return;
|
||||
|
||||
try {
|
||||
await uninstallLegacyGatewayServices({
|
||||
env: process.env,
|
||||
stdout: process.stdout,
|
||||
});
|
||||
} catch (err) {
|
||||
runtime.error(`Legacy service cleanup failed: ${String(err)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (resolveIsNixMode(process.env)) {
|
||||
note("Nix mode detected; skip installing services.", "Gateway");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === "remote") {
|
||||
note("Gateway mode is remote; skipped local service install.", "Gateway");
|
||||
return;
|
||||
}
|
||||
|
||||
const service = resolveGatewayService();
|
||||
const loaded = await service.isLoaded({ env: process.env });
|
||||
if (loaded) {
|
||||
note(`Moltbot ${service.label} already ${service.loadedText}.`, "Gateway");
|
||||
return;
|
||||
}
|
||||
|
||||
const install = await prompter.confirmSkipInNonInteractive({
|
||||
message: "Install Moltbot gateway service now?",
|
||||
initialValue: true,
|
||||
});
|
||||
if (!install) return;
|
||||
|
||||
const daemonRuntime = await prompter.select<GatewayDaemonRuntime>(
|
||||
{
|
||||
message: "Gateway service runtime",
|
||||
options: GATEWAY_DAEMON_RUNTIME_OPTIONS,
|
||||
initialValue: DEFAULT_GATEWAY_DAEMON_RUNTIME,
|
||||
},
|
||||
DEFAULT_GATEWAY_DAEMON_RUNTIME,
|
||||
);
|
||||
const port = resolveGatewayPort(cfg, process.env);
|
||||
const { programArguments, workingDirectory, environment } = await buildGatewayInstallPlan({
|
||||
env: process.env,
|
||||
port,
|
||||
token: cfg.gateway?.auth?.token ?? process.env.CLAWDBOT_GATEWAY_TOKEN,
|
||||
runtime: daemonRuntime,
|
||||
warn: (message, title) => note(message, title),
|
||||
config: cfg,
|
||||
});
|
||||
try {
|
||||
await service.install({
|
||||
env: process.env,
|
||||
stdout: process.stdout,
|
||||
programArguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
});
|
||||
} catch (err) {
|
||||
runtime.error(`Gateway service install failed: ${String(err)}`);
|
||||
note(gatewayInstallErrorHint(), "Gateway");
|
||||
}
|
||||
}
|
||||
|
||||
export async function maybeRepairGatewayServiceConfig(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
mode: "local" | "remote",
|
||||
runtime: RuntimeEnv,
|
||||
prompter: DoctorPrompter,
|
||||
@@ -174,7 +85,7 @@ export async function maybeRepairGatewayServiceConfig(
|
||||
const { programArguments, workingDirectory, environment } = await buildGatewayInstallPlan({
|
||||
env: process.env,
|
||||
port,
|
||||
token: cfg.gateway?.auth?.token ?? process.env.CLAWDBOT_GATEWAY_TOKEN,
|
||||
token: cfg.gateway?.auth?.token ?? process.env.OPENCLAW_GATEWAY_TOKEN,
|
||||
runtime: needsNodeRuntime && systemNodePath ? "node" : runtimeChoice,
|
||||
nodePath: systemNodePath ?? undefined,
|
||||
warn: (message, title) => note(message, title),
|
||||
|
||||
Reference in New Issue
Block a user