mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 05:17:40 +00:00
Lint: add braces for single-line ifs
This commit is contained in:
committed by
Vignesh
parent
23cfcd60df
commit
e332a717a8
@@ -128,7 +128,9 @@ export function createMemoryGetTool(options: {
|
||||
|
||||
function resolveMemoryCitationsMode(cfg: MoltbotConfig): MemoryCitationsMode {
|
||||
const mode = cfg.memory?.citations;
|
||||
if (mode === "on" || mode === "off" || mode === "auto") return mode;
|
||||
if (mode === "on" || mode === "off" || mode === "auto") {
|
||||
return mode;
|
||||
}
|
||||
return "auto";
|
||||
}
|
||||
|
||||
@@ -155,11 +157,15 @@ function clampResultsByInjectedChars(
|
||||
results: MemorySearchResult[],
|
||||
budget?: number,
|
||||
): MemorySearchResult[] {
|
||||
if (!budget || budget <= 0) return results;
|
||||
if (!budget || budget <= 0) {
|
||||
return results;
|
||||
}
|
||||
let remaining = budget;
|
||||
const clamped: MemorySearchResult[] = [];
|
||||
for (const entry of results) {
|
||||
if (remaining <= 0) break;
|
||||
if (remaining <= 0) {
|
||||
break;
|
||||
}
|
||||
const snippet = entry.snippet ?? "";
|
||||
if (snippet.length <= remaining) {
|
||||
clamped.push(entry);
|
||||
@@ -177,16 +183,26 @@ function shouldIncludeCitations(params: {
|
||||
mode: MemoryCitationsMode;
|
||||
sessionKey?: string;
|
||||
}): boolean {
|
||||
if (params.mode === "on") return true;
|
||||
if (params.mode === "off") return false;
|
||||
if (params.mode === "on") {
|
||||
return true;
|
||||
}
|
||||
if (params.mode === "off") {
|
||||
return false;
|
||||
}
|
||||
// auto: show citations in direct chats; suppress in groups/channels by default.
|
||||
const chatType = deriveChatTypeFromSessionKey(params.sessionKey);
|
||||
return chatType === "direct";
|
||||
}
|
||||
|
||||
function deriveChatTypeFromSessionKey(sessionKey?: string): "direct" | "group" | "channel" {
|
||||
if (!sessionKey) return "direct";
|
||||
if (sessionKey.includes(":group:")) return "group";
|
||||
if (sessionKey.includes(":channel:")) return "channel";
|
||||
if (!sessionKey) {
|
||||
return "direct";
|
||||
}
|
||||
if (sessionKey.includes(":group:")) {
|
||||
return "group";
|
||||
}
|
||||
if (sessionKey.includes(":channel:")) {
|
||||
return "channel";
|
||||
}
|
||||
return "direct";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user