fix(tasks): tighten task-flow CLI surface (#59757)

* fix(tasks): tighten task-flow CLI surface

* fix(tasks): sanitize task-flow CLI text output
This commit is contained in:
Vincent Koc
2026-04-03 00:25:10 +09:00
committed by GitHub
parent 0a76780f57
commit efe9464f5f
4 changed files with 93 additions and 133 deletions

View File

@@ -238,34 +238,6 @@ describe("registerStatusHealthSessionsCommands", () => {
);
});
it("runs flows subcommands with forwarded options", async () => {
await runCli(["flows", "list", "--json", "--status", "blocked"]);
expect(flowsListCommand).toHaveBeenCalledWith(
expect.objectContaining({
json: true,
status: "blocked",
}),
runtime,
);
await runCli(["flows", "show", "flow-123", "--json"]);
expect(flowsShowCommand).toHaveBeenCalledWith(
expect.objectContaining({
lookup: "flow-123",
json: true,
}),
runtime,
);
await runCli(["flows", "cancel", "flow-123"]);
expect(flowsCancelCommand).toHaveBeenCalledWith(
expect.objectContaining({
lookup: "flow-123",
}),
runtime,
);
});
it("forwards parent-level all-agents to cleanup subcommand", async () => {
await runCli(["sessions", "--all-agents", "cleanup", "--dry-run"]);
@@ -382,20 +354,10 @@ describe("registerStatusHealthSessionsCommands", () => {
);
});
it("uses TaskFlow wording for the alias command help", () => {
it("does not register the legacy top-level flows command", () => {
const program = new Command();
registerStatusHealthSessionsCommands(program);
const flowsCommand = program.commands.find((command) => command.name() === "flows");
expect(flowsCommand?.description()).toContain("TaskFlow");
expect(flowsCommand?.commands.find((command) => command.name() === "list")?.description()).toBe(
"List tracked TaskFlows",
);
expect(flowsCommand?.commands.find((command) => command.name() === "show")?.description()).toBe(
"Show one TaskFlow by flow id or owner key",
);
expect(
flowsCommand?.commands.find((command) => command.name() === "cancel")?.description(),
).toBe("Cancel a running TaskFlow");
expect(program.commands.find((command) => command.name() === "flows")).toBeUndefined();
});
});

View File

@@ -436,79 +436,4 @@ export function registerStatusHealthSessionsCommands(program: Command) {
);
});
});
const flowsCmd = program
.command("flows")
.description("Inspect durable TaskFlow state (alias for `openclaw tasks flow`)")
.option("--json", "Output as JSON", false)
.option(
"--status <name>",
"Filter by status (queued, running, waiting, blocked, succeeded, failed, cancelled, lost)",
)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
await flowsListCommand(
{
json: Boolean(opts.json),
status: opts.status as string | undefined,
},
defaultRuntime,
);
});
});
flowsCmd.enablePositionalOptions();
flowsCmd
.command("list")
.description("List tracked TaskFlows")
.option("--json", "Output as JSON", false)
.option(
"--status <name>",
"Filter by status (queued, running, waiting, blocked, succeeded, failed, cancelled, lost)",
)
.action(async (opts, command) => {
const parentOpts = command.parent?.opts() as { json?: boolean; status?: string } | undefined;
await runCommandWithRuntime(defaultRuntime, async () => {
await flowsListCommand(
{
json: Boolean(opts.json || parentOpts?.json),
status: (opts.status as string | undefined) ?? parentOpts?.status,
},
defaultRuntime,
);
});
});
flowsCmd
.command("show")
.description("Show one TaskFlow by flow id or owner key")
.argument("<lookup>", "Flow id or owner key")
.option("--json", "Output as JSON", false)
.action(async (lookup, opts, command) => {
const parentOpts = command.parent?.opts() as { json?: boolean } | undefined;
await runCommandWithRuntime(defaultRuntime, async () => {
await flowsShowCommand(
{
lookup,
json: Boolean(opts.json || parentOpts?.json),
},
defaultRuntime,
);
});
});
flowsCmd
.command("cancel")
.description("Cancel a running TaskFlow")
.argument("<lookup>", "Flow id or owner key")
.action(async (lookup) => {
await runCommandWithRuntime(defaultRuntime, async () => {
await flowsCancelCommand(
{
lookup,
},
defaultRuntime,
);
});
});
}