mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:07:39 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -60,7 +60,9 @@ const ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL = "ANTHROPIC_MAGIC_STRING_TRIGGER_R
|
||||
const ANTHROPIC_MAGIC_STRING_REPLACEMENT = "ANTHROPIC MAGIC STRING TRIGGER REFUSAL (redacted)";
|
||||
|
||||
function scrubAnthropicRefusalMagic(prompt: string): string {
|
||||
if (!prompt.includes(ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL)) return prompt;
|
||||
if (!prompt.includes(ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL)) {
|
||||
return prompt;
|
||||
}
|
||||
return prompt.replaceAll(
|
||||
ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL,
|
||||
ANTHROPIC_MAGIC_STRING_REPLACEMENT,
|
||||
@@ -174,7 +176,9 @@ export async function runEmbeddedPiAgent(
|
||||
allInCooldown: boolean;
|
||||
message: string;
|
||||
}): FailoverReason => {
|
||||
if (params.allInCooldown) return "rate_limit";
|
||||
if (params.allInCooldown) {
|
||||
return "rate_limit";
|
||||
}
|
||||
const classified = classifyFailoverReason(params.message);
|
||||
return classified ?? "auth";
|
||||
};
|
||||
@@ -202,7 +206,9 @@ export async function runEmbeddedPiAgent(
|
||||
cause: params.error,
|
||||
});
|
||||
}
|
||||
if (params.error instanceof Error) throw params.error;
|
||||
if (params.error instanceof Error) {
|
||||
throw params.error;
|
||||
}
|
||||
throw new Error(message);
|
||||
};
|
||||
|
||||
@@ -242,7 +248,9 @@ export async function runEmbeddedPiAgent(
|
||||
};
|
||||
|
||||
const advanceAuthProfile = async (): Promise<boolean> => {
|
||||
if (lockedProfileId) return false;
|
||||
if (lockedProfileId) {
|
||||
return false;
|
||||
}
|
||||
let nextIndex = profileIndex + 1;
|
||||
while (nextIndex < profileCandidates.length) {
|
||||
const candidate = profileCandidates[nextIndex];
|
||||
@@ -257,7 +265,9 @@ export async function runEmbeddedPiAgent(
|
||||
attemptedThinking.clear();
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (candidate && candidate === lockedProfileId) throw err;
|
||||
if (candidate && candidate === lockedProfileId) {
|
||||
throw err;
|
||||
}
|
||||
nextIndex += 1;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +292,9 @@ export async function runEmbeddedPiAgent(
|
||||
throwAuthProfileFailover({ allInCooldown: true });
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof FailoverError) throw err;
|
||||
if (err instanceof FailoverError) {
|
||||
throw err;
|
||||
}
|
||||
if (profileCandidates[profileIndex] === lockedProfileId) {
|
||||
throwAuthProfileFailover({ allInCooldown: false, error: err });
|
||||
}
|
||||
@@ -578,7 +590,9 @@ export async function runEmbeddedPiAgent(
|
||||
}
|
||||
|
||||
const rotated = await advanceAuthProfile();
|
||||
if (rotated) continue;
|
||||
if (rotated) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fallbackConfigured) {
|
||||
// Prefer formatted error message (user-friendly) over raw errorMessage
|
||||
|
||||
Reference in New Issue
Block a user