mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
6dc77a37d9
* refactor(agents): centralize failover user copy * refactor(agents): route failure callers through user copy * refactor(qa): carry typed reply failure markers * refactor(agents): keep failover copy import-light * refactor(agents): pass structured failure copy context * refactor(agents): isolate copy rendering from runtime state * refactor(agents): separate copy rendering from sanitization * refactor(agents): keep failover copy internals private * fix(qa-channel): type failure markers on bus sends * style(agents): brace failover copy conditions * test(qa-lab): avoid map spread in failure cases * chore(plugin-sdk): refresh failover closure hashes * fix(agents): preserve generic runner fallback * fix(qa): preserve text-only failure markers * test(qa): type failure delivery fixture
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
// Qa Lab plugin module implements reply failure behavior.
|
|
const VISIBLE_REPLY_LEAK_PATTERNS = [
|
|
/\bchecking thread context\b/i,
|
|
/\bthread context thin\b/i,
|
|
/\bpost a tight progress reply here\b/i,
|
|
/\bposting a coordination nudge\b/i,
|
|
/\bposted a short coordination reply\b/i,
|
|
/\bnot inventing status\b/i,
|
|
];
|
|
|
|
const TOOL_BACKED_FAILURE_PATTERNS = [
|
|
/\btool\s+[a-z0-9_.-]+\s+not found\b/i,
|
|
/^status:\s*blocked\b/im,
|
|
];
|
|
|
|
export function extractQaVisibleReplyLeakText(text: string): string | undefined {
|
|
const trimmed = text.trim();
|
|
if (!trimmed) {
|
|
return undefined;
|
|
}
|
|
if (VISIBLE_REPLY_LEAK_PATTERNS.some((pattern) => pattern.test(trimmed))) {
|
|
return trimmed;
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
export function extractQaFailureReplyText(message: {
|
|
text: string;
|
|
isError?: boolean;
|
|
}): string | undefined {
|
|
const trimmed = message.text.trim();
|
|
if (!trimmed) {
|
|
return undefined;
|
|
}
|
|
if (message.isError === true) {
|
|
return trimmed;
|
|
}
|
|
const visibleReplyLeak = extractQaVisibleReplyLeakText(trimmed);
|
|
if (visibleReplyLeak) {
|
|
return visibleReplyLeak;
|
|
}
|
|
if (TOOL_BACKED_FAILURE_PATTERNS.some((pattern) => pattern.test(trimmed))) {
|
|
return trimmed;
|
|
}
|
|
return undefined;
|
|
}
|