Files
openclaw/src/auto-reply/reply/btw-command.ts
T
2026-06-04 02:29:18 -04:00

29 lines
900 B
TypeScript

// Runs background side-question commands against the active agent context.
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
import { normalizeCommandBody, type CommandNormalizeOptions } from "../commands-registry.js";
const BTW_COMMAND_RE = /^\/btw(?::|\s|$)/i;
export function isBtwRequestText(text?: string, options?: CommandNormalizeOptions): boolean {
if (!text) {
return false;
}
const normalized = normalizeCommandBody(text, options).trim();
return BTW_COMMAND_RE.test(normalized);
}
export function extractBtwQuestion(
text?: string,
options?: CommandNormalizeOptions,
): string | null {
if (!text) {
return null;
}
const normalized = normalizeCommandBody(text, options).trim();
const match = normalized.match(/^\/btw(?:\s+(.*))?$/i);
if (!match) {
return null;
}
return normalizeOptionalString(match[1]) ?? "";
}