mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 17:17:26 +00:00
* refactor: consolidate duplicate utility functions - Add escapeRegExp to src/utils.ts and remove 10 local duplicates - Rename bash-tools clampNumber to clampWithDefault (different signature) - Centralize formatError calls to use formatErrorMessage from infra/errors.ts - Re-export formatErrorMessage from cli/cli-utils.ts to preserve API * refactor: consolidate remaining escapeRegExp duplicates * refactor: consolidate sleep, stripAnsi, and clamp duplicates
21 lines
518 B
TypeScript
21 lines
518 B
TypeScript
import { escapeRegExp } from "../utils.js";
|
|
|
|
export const HEARTBEAT_TOKEN = "HEARTBEAT_OK";
|
|
export const SILENT_REPLY_TOKEN = "NO_REPLY";
|
|
|
|
export function isSilentReplyText(
|
|
text: string | undefined,
|
|
token: string = SILENT_REPLY_TOKEN,
|
|
): boolean {
|
|
if (!text) {
|
|
return false;
|
|
}
|
|
const escaped = escapeRegExp(token);
|
|
const prefix = new RegExp(`^\\s*${escaped}(?=$|\\W)`);
|
|
if (prefix.test(text)) {
|
|
return true;
|
|
}
|
|
const suffix = new RegExp(`\\b${escaped}\\b\\W*$`);
|
|
return suffix.test(text);
|
|
}
|