

























@@ -11,6 +11,7 @@ const tasksListJsonCommandMock = vi.hoisted(() => vi.fn(async () => {}));
1111const tasksAuditJsonCommandMock = vi.hoisted(() => vi.fn(async () => {}));
1212const channelsListCommandMock = vi.hoisted(() => vi.fn(async () => {}));
1313const channelsStatusCommandMock = vi.hoisted(() => vi.fn(async () => {}));
14+const agentsListCommandMock = vi.hoisted(() => vi.fn(async () => {}));
14151516vi.mock("../config-cli.js", () => ({
1617runConfigGet: runConfigGetMock,
@@ -49,6 +50,10 @@ vi.mock("../../commands/channels/status.js", () => ({
4950channelsStatusCommand: channelsStatusCommandMock,
5051}));
515253+vi.mock("../../commands/agents.js", () => ({
54+agentsListCommand: agentsListCommandMock,
55+}));
56+5257describe("program routes", () => {
5358beforeEach(() => {
5459vi.clearAllMocks();
@@ -80,6 +85,34 @@ describe("program routes", () => {
8085expect(expectRoute(["channels", "status"])?.loadPlugins).toBeUndefined();
8186});
828788+it("matches agents read-only routes without plugin preload", () => {
89+expect(expectRoute(["agents"])?.loadPlugins).toBeUndefined();
90+expect(expectRoute(["agents", "list"])?.loadPlugins).toBeUndefined();
91+});
92+93+it("passes parsed agents list flags through", async () => {
94+await expect(expectRoute(["agents"])?.run(["node", "openclaw", "agents"])).resolves.toBe(true);
95+expect(agentsListCommandMock).toHaveBeenCalledWith(
96+{ json: false, bindings: false },
97+expect.any(Object),
98+);
99+100+await expect(
101+expectRoute(["agents", "list"])?.run([
102+"node",
103+"openclaw",
104+"agents",
105+"list",
106+"--json",
107+"--bindings",
108+]),
109+).resolves.toBe(true);
110+expect(agentsListCommandMock).toHaveBeenLastCalledWith(
111+{ json: true, bindings: true },
112+expect.any(Object),
113+);
114+});
115+83116it("passes parsed channel read-only route flags through", async () => {
84117const listRoute = expectRoute(["channels", "list"]);
85118await expect(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。