mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:10:43 +00:00
chore: remove unused flow and daemon helpers
This commit is contained in:
@@ -12,9 +12,7 @@ export const NODE_WINDOWS_TASK_NAME = "OpenClaw Node";
|
||||
export const NODE_SERVICE_MARKER = "openclaw";
|
||||
export const NODE_SERVICE_KIND = "node";
|
||||
export const NODE_WINDOWS_TASK_SCRIPT_NAME = "node.cmd";
|
||||
export const LEGACY_GATEWAY_LAUNCH_AGENT_LABELS: string[] = [];
|
||||
export const LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES: string[] = ["clawdbot-gateway"];
|
||||
export const LEGACY_GATEWAY_WINDOWS_TASK_NAMES: string[] = [];
|
||||
|
||||
export function normalizeGatewayProfile(profile?: string): string | null {
|
||||
const trimmed = profile?.trim();
|
||||
|
||||
@@ -345,74 +345,6 @@ export async function repairLaunchAgentBootstrap(args: {
|
||||
return { ok: true, status: repairStatus };
|
||||
}
|
||||
|
||||
export type LegacyLaunchAgent = {
|
||||
label: string;
|
||||
plistPath: string;
|
||||
loaded: boolean;
|
||||
exists: boolean;
|
||||
};
|
||||
|
||||
export async function findLegacyLaunchAgents(env: GatewayServiceEnv): Promise<LegacyLaunchAgent[]> {
|
||||
const domain = resolveGuiDomain();
|
||||
const results: LegacyLaunchAgent[] = [];
|
||||
for (const label of resolveLegacyGatewayLaunchAgentLabels(env.OPENCLAW_PROFILE)) {
|
||||
const plistPath = resolveLaunchAgentPlistPathForLabel(env, label);
|
||||
const res = await execLaunchctl(["print", `${domain}/${label}`]);
|
||||
const loaded = res.code === 0;
|
||||
let exists = false;
|
||||
try {
|
||||
await fs.access(plistPath);
|
||||
exists = true;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
if (loaded || exists) {
|
||||
results.push({ label, plistPath, loaded, exists });
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
export async function uninstallLegacyLaunchAgents({
|
||||
env,
|
||||
stdout,
|
||||
}: GatewayServiceManageArgs): Promise<LegacyLaunchAgent[]> {
|
||||
const domain = resolveGuiDomain();
|
||||
const agents = await findLegacyLaunchAgents(env);
|
||||
if (agents.length === 0) {
|
||||
return agents;
|
||||
}
|
||||
|
||||
const home = toPosixPath(resolveHomeDir(env));
|
||||
const trashDir = path.posix.join(home, ".Trash");
|
||||
try {
|
||||
await fs.mkdir(trashDir, { recursive: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
for (const agent of agents) {
|
||||
await execLaunchctl(["bootout", domain, agent.plistPath]);
|
||||
await execLaunchctl(["unload", agent.plistPath]);
|
||||
|
||||
try {
|
||||
await fs.access(agent.plistPath);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
const dest = path.join(trashDir, `${agent.label}.plist`);
|
||||
try {
|
||||
await fs.rename(agent.plistPath, dest);
|
||||
stdout.write(`${formatLine("Moved legacy LaunchAgent to Trash", dest)}\n`);
|
||||
} catch {
|
||||
stdout.write(`Legacy LaunchAgent remains at ${agent.plistPath} (could not move)\n`);
|
||||
}
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
export async function uninstallLaunchAgent({
|
||||
env,
|
||||
stdout,
|
||||
|
||||
@@ -63,15 +63,6 @@ function resolveProviderDocsById(params?: {
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveProviderSetupFlowOptions(params?: {
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
scope?: ProviderFlowScope;
|
||||
}): ProviderSetupFlowOption[] {
|
||||
return resolveProviderSetupFlowContributions(params).map((contribution) => contribution.option);
|
||||
}
|
||||
|
||||
export function resolveProviderSetupFlowContributions(params?: {
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
|
||||
@@ -31,22 +31,6 @@ export type FlowContribution<Value extends string = string> = {
|
||||
source?: string;
|
||||
};
|
||||
|
||||
export function mergeFlowContributions<T extends FlowContribution>(params: {
|
||||
primary: readonly T[];
|
||||
fallbacks?: readonly T[];
|
||||
}): T[] {
|
||||
const contributionByValue = new Map<string, T>();
|
||||
for (const contribution of params.primary) {
|
||||
contributionByValue.set(contribution.option.value, contribution);
|
||||
}
|
||||
for (const contribution of params.fallbacks ?? []) {
|
||||
if (!contributionByValue.has(contribution.option.value)) {
|
||||
contributionByValue.set(contribution.option.value, contribution);
|
||||
}
|
||||
}
|
||||
return [...contributionByValue.values()];
|
||||
}
|
||||
|
||||
export function sortFlowContributionsByLabel<T extends FlowContribution>(
|
||||
contributions: readonly T[],
|
||||
): T[] {
|
||||
|
||||
Reference in New Issue
Block a user