chore: fix lint warnings

main
Vignesh Natarajan 2026-02-02 21:15:43 -08:00 committed by Vignesh
parent f72214725d
commit 30098b04d7
5 changed files with 80 additions and 29 deletions

View File

@ -18,9 +18,13 @@ function buildSkillsSection(params: {
isMinimal: boolean;
readToolName: string;
}) {
if (params.isMinimal) return [];
if (params.isMinimal) {
return [];
}
const trimmed = params.skillsPrompt?.trim();
if (!trimmed) return [];
if (!trimmed) {
return [];
}
return [
"## Skills (mandatory)",
"Before replying: scan <available_skills> <description> entries.",
@ -38,7 +42,9 @@ function buildMemorySection(params: {
availableTools: Set<string>;
citationsMode?: MemoryCitationsMode;
}) {
if (params.isMinimal) return [];
if (params.isMinimal) {
return [];
}
if (!params.availableTools.has("memory_search") && !params.availableTools.has("memory_get")) {
return [];
}
@ -60,17 +66,23 @@ function buildMemorySection(params: {
}
function buildUserIdentitySection(ownerLine: string | undefined, isMinimal: boolean) {
if (!ownerLine || isMinimal) return [];
if (!ownerLine || isMinimal) {
return [];
}
return ["## User Identity", ownerLine, ""];
}
function buildTimeSection(params: { userTimezone?: string }) {
if (!params.userTimezone) return [];
if (!params.userTimezone) {
return [];
}
return ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""];
}
function buildReplyTagsSection(isMinimal: boolean) {
if (isMinimal) return [];
if (isMinimal) {
return [];
}
return [
"## Reply Tags",
"To request a native reply/quote on supported surfaces, include one tag in your reply:",
@ -90,7 +102,9 @@ function buildMessagingSection(params: {
runtimeChannel?: string;
messageToolHints?: string[];
}) {
if (params.isMinimal) return [];
if (params.isMinimal) {
return [];
}
return [
"## Messaging",
"- Reply in current session → automatically routes to the source channel (Signal, Telegram, etc.)",
@ -119,15 +133,21 @@ function buildMessagingSection(params: {
}
function buildVoiceSection(params: { isMinimal: boolean; ttsHint?: string }) {
if (params.isMinimal) return [];
if (params.isMinimal) {
return [];
}
const hint = params.ttsHint?.trim();
if (!hint) return [];
if (!hint) {
return [];
}
return ["## Voice (TTS)", hint, ""];
}
function buildDocsSection(params: { docsPath?: string; isMinimal: boolean; readToolName: string }) {
const docsPath = params.docsPath?.trim();
if (!docsPath || params.isMinimal) return [];
if (!docsPath || params.isMinimal) {
return [];
}
return [
"## Documentation",
`OpenClaw docs: ${docsPath}`,
@ -268,7 +288,9 @@ export function buildAgentSystemPrompt(params: {
const externalToolSummaries = new Map<string, string>();
for (const [key, value] of Object.entries(params.toolSummaries ?? {})) {
const normalized = key.trim().toLowerCase();
if (!normalized || !value?.trim()) continue;
if (!normalized || !value?.trim()) {
continue;
}
externalToolSummaries.set(normalized, value.trim());
}
const extraTools = Array.from(
@ -280,7 +302,7 @@ export function buildAgentSystemPrompt(params: {
const name = resolveToolName(tool);
return summary ? `- ${name}: ${summary}` : `- ${name}`;
});
for (const tool of extraTools.sort()) {
for (const tool of extraTools.toSorted()) {
const summary = coreToolSummaries[tool] ?? externalToolSummaries.get(tool);
const name = resolveToolName(tool);
toolLines.push(summary ? `- ${name}: ${summary}` : `- ${name}`);

View File

@ -27,12 +27,16 @@ export function createMemorySearchTool(options: {
agentSessionKey?: string;
}): AnyAgentTool | null {
const cfg = options.config;
if (!cfg) return null;
if (!cfg) {
return null;
}
const agentId = resolveSessionAgentId({
sessionKey: options.agentSessionKey,
config: cfg,
});
if (!resolveMemorySearchConfig(cfg, agentId)) return null;
if (!resolveMemorySearchConfig(cfg, agentId)) {
return null;
}
return {
label: "Memory Search",
name: "memory_search",
@ -88,12 +92,16 @@ export function createMemoryGetTool(options: {
agentSessionKey?: string;
}): AnyAgentTool | null {
const cfg = options.config;
if (!cfg) return null;
if (!cfg) {
return null;
}
const agentId = resolveSessionAgentId({
sessionKey: options.agentSessionKey,
config: cfg,
});
if (!resolveMemorySearchConfig(cfg, agentId)) return null;
if (!resolveMemorySearchConfig(cfg, agentId)) {
return null;
}
return {
label: "Memory Get",
name: "memory_get",
@ -199,11 +207,16 @@ function deriveChatTypeFromSessionKey(sessionKey?: string): "direct" | "group" |
if (!parsed?.rest) {
return "direct";
}
const tokens = parsed.rest.toLowerCase().split(":").filter(Boolean);
if (tokens.includes("channel")) {
const tokens = new Set(
parsed.rest
.toLowerCase()
.split(":")
.filter(Boolean),
);
if (tokens.has("channel")) {
return "channel";
}
if (tokens.includes("group")) {
if (tokens.has("group")) {
return "group";
}
return "direct";

View File

@ -28,7 +28,9 @@ type MemoryPluginStatus = {
function resolveMemoryPluginStatus(cfg: ReturnType<typeof loadConfig>): MemoryPluginStatus {
const pluginsEnabled = cfg.plugins?.enabled !== false;
if (!pluginsEnabled) return { enabled: false, slot: null, reason: "plugins disabled" };
if (!pluginsEnabled) {
return { enabled: false, slot: null, reason: "plugins disabled" };
}
const raw = typeof cfg.plugins?.slots?.memory === "string" ? cfg.plugins.slots.memory.trim() : "";
if (raw && raw.toLowerCase() === "none") {
return { enabled: false, slot: null, reason: 'plugins.slots.memory="none"' };
@ -126,7 +128,7 @@ export async function scanStatus(
progress.setLabel("Querying channel status…");
const channelsStatus = gatewayReachable
? await callGateway<Record<string, unknown>>({
? await callGateway({
method: "channels.status",
params: {
probe: false,
@ -149,11 +151,17 @@ export async function scanStatus(
progress.setLabel("Checking memory…");
const memoryPlugin = resolveMemoryPluginStatus(cfg);
const memory = await (async (): Promise<MemoryStatusSnapshot | null> => {
if (!memoryPlugin.enabled) return null;
if (memoryPlugin.slot !== "memory-core") return null;
if (!memoryPlugin.enabled) {
return null;
}
if (memoryPlugin.slot !== "memory-core") {
return null;
}
const agentId = agentStatus.defaultId ?? "main";
const { manager } = await getMemorySearchManager({ cfg, agentId });
if (!manager) return null;
if (!manager) {
return null;
}
try {
await manager.probeVectorAvailability();
} catch {}

View File

@ -592,15 +592,23 @@ export const OpenClawSchema = z
.strict()
.superRefine((cfg, ctx) => {
const agents = cfg.agents?.list ?? [];
if (agents.length === 0) return;
if (agents.length === 0) {
return;
}
const agentIds = new Set(agents.map((agent) => agent.id));
const broadcast = cfg.broadcast;
if (!broadcast) return;
if (!broadcast) {
return;
}
for (const [peerId, ids] of Object.entries(broadcast)) {
if (peerId === "strategy") continue;
if (!Array.isArray(ids)) continue;
if (peerId === "strategy") {
continue;
}
if (!Array.isArray(ids)) {
continue;
}
for (let idx = 0; idx < ids.length; idx += 1) {
const agentId = ids[idx];
if (!agentIds.has(agentId)) {

View File

@ -204,7 +204,7 @@ function sortValue(value: unknown): unknown {
}
if (value && typeof value === "object") {
const sortedEntries = Object.keys(value as Record<string, unknown>)
.sort((a, b) => a.localeCompare(b))
.toSorted((a, b) => a.localeCompare(b))
.map((key) => [key, sortValue((value as Record<string, unknown>)[key])]);
return Object.fromEntries(sortedEntries);
}