mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:21:23 +00:00
fix(auto-reply): expand standalone stop phrases
This commit is contained in:
@@ -23,15 +23,47 @@ import type { FinalizedMsgContext, MsgContext } from "../templating.js";
|
||||
import { stripMentions, stripStructuralPrefixes } from "./mentions.js";
|
||||
import { clearSessionQueues } from "./queue.js";
|
||||
|
||||
const ABORT_TRIGGERS = new Set(["stop", "esc", "abort", "wait", "exit", "interrupt"]);
|
||||
const ABORT_TRIGGERS = new Set([
|
||||
"stop",
|
||||
"esc",
|
||||
"abort",
|
||||
"wait",
|
||||
"exit",
|
||||
"interrupt",
|
||||
"stop openclaw",
|
||||
"openclaw stop",
|
||||
"stop action",
|
||||
"stop current action",
|
||||
"stop run",
|
||||
"stop current run",
|
||||
"stop agent",
|
||||
"stop the agent",
|
||||
"stop don't do anything",
|
||||
"stop dont do anything",
|
||||
"stop do not do anything",
|
||||
"stop doing anything",
|
||||
"please stop",
|
||||
"stop please",
|
||||
]);
|
||||
const ABORT_MEMORY = new Map<string, boolean>();
|
||||
const ABORT_MEMORY_MAX = 2000;
|
||||
const TRAILING_ABORT_PUNCTUATION_RE = /[.!?…,,。;;::'"’”)\]}]+$/u;
|
||||
|
||||
function normalizeAbortTriggerText(text: string): string {
|
||||
return text
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[’`]/g, "'")
|
||||
.replace(/\s+/g, " ")
|
||||
.replace(TRAILING_ABORT_PUNCTUATION_RE, "")
|
||||
.trim();
|
||||
}
|
||||
|
||||
export function isAbortTrigger(text?: string): boolean {
|
||||
if (!text) {
|
||||
return false;
|
||||
}
|
||||
const normalized = text.trim().toLowerCase();
|
||||
const normalized = normalizeAbortTriggerText(text);
|
||||
return ABORT_TRIGGERS.has(normalized);
|
||||
}
|
||||
|
||||
@@ -43,7 +75,12 @@ export function isAbortRequestText(text?: string, options?: CommandNormalizeOpti
|
||||
if (!normalized) {
|
||||
return false;
|
||||
}
|
||||
return normalized.toLowerCase() === "/stop" || isAbortTrigger(normalized);
|
||||
const normalizedLower = normalized.toLowerCase();
|
||||
return (
|
||||
normalizedLower === "/stop" ||
|
||||
normalizeAbortTriggerText(normalizedLower) === "/stop" ||
|
||||
isAbortTrigger(normalizedLower)
|
||||
);
|
||||
}
|
||||
|
||||
export function getAbortMemory(key: string): boolean | undefined {
|
||||
|
||||
Reference in New Issue
Block a user