Files
openclaw/src/auto-reply/reply/debug-commands.ts
2026-02-18 17:48:01 +00:00

30 lines
931 B
TypeScript

import { parseSlashCommandWithSetUnset } from "./commands-setunset.js";
export type DebugCommand =
| { action: "show" }
| { action: "reset" }
| { action: "set"; path: string; value: unknown }
| { action: "unset"; path: string }
| { action: "error"; message: string };
export function parseDebugCommand(raw: string): DebugCommand | null {
return parseSlashCommandWithSetUnset<DebugCommand>({
raw,
slash: "/debug",
invalidMessage: "Invalid /debug syntax.",
usageMessage: "Usage: /debug show|set|unset|reset",
onKnownAction: (action) => {
if (action === "show") {
return { action: "show" };
}
if (action === "reset") {
return { action: "reset" };
}
return undefined;
},
onSet: (path, value) => ({ action: "set", path, value }),
onUnset: (path) => ({ action: "unset", path }),
onError: (message) => ({ action: "error", message }),
});
}