mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-21 07:44:59 +00:00
CLI: route sessions cleanup through subcommand parser
This commit is contained in:
@@ -68,6 +68,7 @@ describe("command-registry", () => {
|
||||
expect(names).toContain("memory");
|
||||
expect(names).toContain("agents");
|
||||
expect(names).toContain("browser");
|
||||
expect(names).toContain("sessions");
|
||||
expect(names).not.toContain("agent");
|
||||
expect(names).not.toContain("status");
|
||||
expect(names).not.toContain("doctor");
|
||||
|
||||
@@ -181,7 +181,7 @@ const coreEntries: CoreCliEntry[] = [
|
||||
{
|
||||
name: "sessions",
|
||||
description: "List stored conversation sessions",
|
||||
hasSubcommands: false,
|
||||
hasSubcommands: true,
|
||||
},
|
||||
],
|
||||
register: async ({ program }) => {
|
||||
|
||||
@@ -30,6 +30,10 @@ describe("program routes", () => {
|
||||
await expectRunFalse(["sessions"], ["node", "openclaw", "sessions", "--active"]);
|
||||
});
|
||||
|
||||
it("does not fast-route sessions subcommands", () => {
|
||||
expect(findRoutedCommand(["sessions", "cleanup"])).toBeNull();
|
||||
});
|
||||
|
||||
it("does not match unknown routes", () => {
|
||||
expect(findRoutedCommand(["definitely-not-real"])).toBeNull();
|
||||
});
|
||||
|
||||
@@ -43,7 +43,9 @@ const routeStatus: RouteSpec = {
|
||||
};
|
||||
|
||||
const routeSessions: RouteSpec = {
|
||||
match: (path) => path[0] === "sessions",
|
||||
// Fast-path only bare `sessions`; subcommands (e.g. `sessions cleanup`)
|
||||
// must fall through to Commander so nested handlers run.
|
||||
match: (path) => path[0] === "sessions" && !path[1],
|
||||
run: async (argv) => {
|
||||
const json = hasFlag(argv, "--json");
|
||||
const store = getFlagValue(argv, "--store");
|
||||
|
||||
Reference in New Issue
Block a user