mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-10 00:31:22 +00:00
feat(tasks): add status health and maintenance command (#57423)
* feat(tasks): add status health and maintenance command * fix(tasks): address status and maintenance review feedback
This commit is contained in:
@@ -8,6 +8,7 @@ const sessionsCommand = vi.fn();
|
||||
const sessionsCleanupCommand = vi.fn();
|
||||
const tasksListCommand = vi.fn();
|
||||
const tasksAuditCommand = vi.fn();
|
||||
const tasksMaintenanceCommand = vi.fn();
|
||||
const tasksShowCommand = vi.fn();
|
||||
const tasksNotifyCommand = vi.fn();
|
||||
const tasksCancelCommand = vi.fn();
|
||||
@@ -34,6 +35,7 @@ vi.mock("../../commands/sessions-cleanup.js", () => ({
|
||||
vi.mock("../../commands/tasks.js", () => ({
|
||||
tasksListCommand,
|
||||
tasksAuditCommand,
|
||||
tasksMaintenanceCommand,
|
||||
tasksShowCommand,
|
||||
tasksNotifyCommand,
|
||||
tasksCancelCommand,
|
||||
@@ -70,6 +72,7 @@ describe("registerStatusHealthSessionsCommands", () => {
|
||||
sessionsCleanupCommand.mockResolvedValue(undefined);
|
||||
tasksListCommand.mockResolvedValue(undefined);
|
||||
tasksAuditCommand.mockResolvedValue(undefined);
|
||||
tasksMaintenanceCommand.mockResolvedValue(undefined);
|
||||
tasksShowCommand.mockResolvedValue(undefined);
|
||||
tasksNotifyCommand.mockResolvedValue(undefined);
|
||||
tasksCancelCommand.mockResolvedValue(undefined);
|
||||
@@ -245,6 +248,18 @@ describe("registerStatusHealthSessionsCommands", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("runs tasks maintenance subcommand with apply forwarding", async () => {
|
||||
await runCli(["tasks", "--json", "maintenance", "--apply"]);
|
||||
|
||||
expect(tasksMaintenanceCommand).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
json: true,
|
||||
apply: true,
|
||||
}),
|
||||
runtime,
|
||||
);
|
||||
});
|
||||
|
||||
it("runs tasks audit subcommand with filters", async () => {
|
||||
await runCli([
|
||||
"tasks",
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
tasksAuditCommand,
|
||||
tasksCancelCommand,
|
||||
tasksListCommand,
|
||||
tasksMaintenanceCommand,
|
||||
tasksNotifyCommand,
|
||||
tasksShowCommand,
|
||||
} from "../../commands/tasks.js";
|
||||
@@ -305,6 +306,24 @@ export function registerStatusHealthSessionsCommands(program: Command) {
|
||||
});
|
||||
});
|
||||
|
||||
tasksCmd
|
||||
.command("maintenance")
|
||||
.description("Preview or apply task ledger maintenance")
|
||||
.option("--json", "Output as JSON", false)
|
||||
.option("--apply", "Apply reconciliation, cleanup stamping, and pruning", false)
|
||||
.action(async (opts, command) => {
|
||||
const parentOpts = command.parent?.opts() as { json?: boolean } | undefined;
|
||||
await runCommandWithRuntime(defaultRuntime, async () => {
|
||||
await tasksMaintenanceCommand(
|
||||
{
|
||||
json: Boolean(opts.json || parentOpts?.json),
|
||||
apply: Boolean(opts.apply),
|
||||
},
|
||||
defaultRuntime,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
tasksCmd
|
||||
.command("show")
|
||||
.description("Show one background task by task id, run id, or session key")
|
||||
|
||||
Reference in New Issue
Block a user