CLI: avoid plugin preload for health --json route (#31108)

* CLI routes: skip plugin preload for health --json

* CLI routes tests: cover health --json plugin preload
This commit is contained in:
Vincent Koc
2026-03-01 17:13:58 -08:00
committed by GitHub
parent 155118751f
commit e07c51b045
2 changed files with 8 additions and 5 deletions

View File

@@ -18,9 +18,12 @@ describe("program routes", () => {
expect(route?.loadPlugins).toBe(true);
});
it("matches health route and preloads plugins for channel diagnostics", () => {
it("matches health route and preloads plugins only for text output", () => {
const route = expectRoute(["health"]);
expect(route?.loadPlugins).toBe(true);
expect(typeof route?.loadPlugins).toBe("function");
const shouldLoad = route?.loadPlugins as (argv: string[]) => boolean;
expect(shouldLoad(["node", "openclaw", "health"])).toBe(true);
expect(shouldLoad(["node", "openclaw", "health", "--json"])).toBe(false);
});
it("returns false when status timeout flag value is missing", async () => {

View File

@@ -9,9 +9,9 @@ export type RouteSpec = {
const routeHealth: RouteSpec = {
match: (path) => path[0] === "health",
// Health output uses channel plugin metadata for account fallback/log details.
// Keep routed behavior aligned with non-routed command execution.
loadPlugins: true,
// `health --json` only relays gateway RPC output and does not need local plugin metadata.
// Keep plugin preload for text output where channel diagnostics/logSelfId are rendered.
loadPlugins: (argv) => !hasFlag(argv, "--json"),
run: async (argv) => {
const json = hasFlag(argv, "--json");
const verbose = getVerboseFlag(argv, { includeDebug: true });