mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-27 22:03:35 +00:00
* fix(cron): run legacy cron store migration in gateway fast path * fix(cli): run gateway startup migrations * fix(gateway): guard startup migrations and config selection * fix(gateway): reconcile final startup environment * fix(gateway): preserve guarded startup env semantics * fix(gateway): guard service-mode recovery candidates * fix(config): reconcile normalized env precedence * fix(cli): clear replaced proxy signal handlers * fix(gateway): reject invalid final config * test(gateway): cover invalid future config reset guard * test(cli): remove unused recovery state
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
// Shared command preflight: config readiness plus optional plugin registry activation.
|
|
import type { ConfigFileSnapshot } from "../config/types.js";
|
|
import type { RuntimeEnv } from "../runtime.js";
|
|
import { createLazyImportLoader } from "../shared/lazy-promise.js";
|
|
import type { CliPluginRegistryPolicy } from "./command-catalog.js";
|
|
import { resolveCliCommandPathPolicy } from "./command-path-policy.js";
|
|
import { ensureCliPluginRegistryLoaded } from "./plugin-registry-loader.js";
|
|
|
|
const configGuardModuleLoader = createLazyImportLoader(() => import("./program/config-guard.js"));
|
|
|
|
function loadConfigGuardModule() {
|
|
return configGuardModuleLoader.load();
|
|
}
|
|
|
|
/** Run the lazy command bootstrap steps selected by command policy. */
|
|
export async function ensureCliCommandBootstrap(params: {
|
|
runtime: RuntimeEnv;
|
|
commandPath: string[];
|
|
suppressDoctorStdout?: boolean;
|
|
skipConfigGuard?: boolean;
|
|
allowInvalid?: boolean;
|
|
beforeStateMigrations?: (snapshot?: ConfigFileSnapshot) => Promise<boolean>;
|
|
loadPlugins?: boolean;
|
|
pluginRegistry?: CliPluginRegistryPolicy;
|
|
}) {
|
|
if (!params.skipConfigGuard) {
|
|
const { ensureConfigReady } = await loadConfigGuardModule();
|
|
await ensureConfigReady({
|
|
runtime: params.runtime,
|
|
commandPath: params.commandPath,
|
|
...(params.allowInvalid ? { allowInvalid: true } : {}),
|
|
...(params.beforeStateMigrations
|
|
? { beforeStateMigrations: params.beforeStateMigrations }
|
|
: {}),
|
|
...(params.suppressDoctorStdout ? { suppressDoctorStdout: true } : {}),
|
|
});
|
|
}
|
|
if (!params.loadPlugins) {
|
|
return;
|
|
}
|
|
const pluginRegistryLoadPolicy =
|
|
params.pluginRegistry ?? resolveCliCommandPathPolicy(params.commandPath).pluginRegistry;
|
|
await ensureCliPluginRegistryLoaded({
|
|
scope: pluginRegistryLoadPolicy.scope,
|
|
routeLogsToStderr: params.suppressDoctorStdout,
|
|
});
|
|
}
|