fix(cli): load plugins for local JSON agent runs

This commit is contained in:
Peter Steinberger
2026-04-29 01:25:48 +01:00
parent c24c8bab13
commit e94e9347a4
3 changed files with 23 additions and 2 deletions

View File

@@ -52,7 +52,7 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
{
commandPath: ["agent"],
policy: {
loadPlugins: "text-only",
loadPlugins: ({ argv, jsonOutputMode }) => hasFlag(argv, "--local") || !jsonOutputMode,
networkProxy: ({ argv }) => (hasFlag(argv, "--local") ? "default" : "bypass"),
},
},

View File

@@ -70,7 +70,7 @@ describe("command-path-policy", () => {
expect(resolveCliCommandPathPolicy(["agent"])).toEqual({
bypassConfigGuard: false,
routeConfigGuard: "never",
loadPlugins: "text-only",
loadPlugins: expect.any(Function),
hideBanner: false,
ensureCliPath: true,
networkProxy: expect.any(Function),

View File

@@ -92,6 +92,27 @@ describe("command-startup-policy", () => {
jsonOutputMode: true,
}),
).toBe(false);
expect(
shouldLoadPluginsForCommandPath({
argv: ["node", "openclaw", "agent", "--json"],
commandPath: ["agent"],
jsonOutputMode: true,
}),
).toBe(false);
expect(
shouldLoadPluginsForCommandPath({
argv: ["node", "openclaw", "agent", "--json", "--local"],
commandPath: ["agent"],
jsonOutputMode: true,
}),
).toBe(true);
expect(
shouldLoadPluginsForCommandPath({
argv: ["node", "openclaw", "agent"],
commandPath: ["agent"],
jsonOutputMode: false,
}),
).toBe(true);
expect(
shouldLoadPluginsForCommandPath({
commandPath: ["agents", "list"],