mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 13:41:40 +00:00
chore: fix lint warnings
This commit is contained in:
committed by
Vignesh
parent
f72214725d
commit
30098b04d7
@@ -18,9 +18,13 @@ function buildSkillsSection(params: {
|
|||||||
isMinimal: boolean;
|
isMinimal: boolean;
|
||||||
readToolName: string;
|
readToolName: string;
|
||||||
}) {
|
}) {
|
||||||
if (params.isMinimal) return [];
|
if (params.isMinimal) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const trimmed = params.skillsPrompt?.trim();
|
const trimmed = params.skillsPrompt?.trim();
|
||||||
if (!trimmed) return [];
|
if (!trimmed) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
"## Skills (mandatory)",
|
"## Skills (mandatory)",
|
||||||
"Before replying: scan <available_skills> <description> entries.",
|
"Before replying: scan <available_skills> <description> entries.",
|
||||||
@@ -38,7 +42,9 @@ function buildMemorySection(params: {
|
|||||||
availableTools: Set<string>;
|
availableTools: Set<string>;
|
||||||
citationsMode?: MemoryCitationsMode;
|
citationsMode?: MemoryCitationsMode;
|
||||||
}) {
|
}) {
|
||||||
if (params.isMinimal) return [];
|
if (params.isMinimal) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
if (!params.availableTools.has("memory_search") && !params.availableTools.has("memory_get")) {
|
if (!params.availableTools.has("memory_search") && !params.availableTools.has("memory_get")) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -60,17 +66,23 @@ function buildMemorySection(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildUserIdentitySection(ownerLine: string | undefined, isMinimal: boolean) {
|
function buildUserIdentitySection(ownerLine: string | undefined, isMinimal: boolean) {
|
||||||
if (!ownerLine || isMinimal) return [];
|
if (!ownerLine || isMinimal) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return ["## User Identity", ownerLine, ""];
|
return ["## User Identity", ownerLine, ""];
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTimeSection(params: { userTimezone?: string }) {
|
function buildTimeSection(params: { userTimezone?: string }) {
|
||||||
if (!params.userTimezone) return [];
|
if (!params.userTimezone) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""];
|
return ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""];
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildReplyTagsSection(isMinimal: boolean) {
|
function buildReplyTagsSection(isMinimal: boolean) {
|
||||||
if (isMinimal) return [];
|
if (isMinimal) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
"## Reply Tags",
|
"## Reply Tags",
|
||||||
"To request a native reply/quote on supported surfaces, include one tag in your reply:",
|
"To request a native reply/quote on supported surfaces, include one tag in your reply:",
|
||||||
@@ -90,7 +102,9 @@ function buildMessagingSection(params: {
|
|||||||
runtimeChannel?: string;
|
runtimeChannel?: string;
|
||||||
messageToolHints?: string[];
|
messageToolHints?: string[];
|
||||||
}) {
|
}) {
|
||||||
if (params.isMinimal) return [];
|
if (params.isMinimal) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
"## Messaging",
|
"## Messaging",
|
||||||
"- Reply in current session → automatically routes to the source channel (Signal, Telegram, etc.)",
|
"- 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 }) {
|
function buildVoiceSection(params: { isMinimal: boolean; ttsHint?: string }) {
|
||||||
if (params.isMinimal) return [];
|
if (params.isMinimal) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const hint = params.ttsHint?.trim();
|
const hint = params.ttsHint?.trim();
|
||||||
if (!hint) return [];
|
if (!hint) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return ["## Voice (TTS)", hint, ""];
|
return ["## Voice (TTS)", hint, ""];
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDocsSection(params: { docsPath?: string; isMinimal: boolean; readToolName: string }) {
|
function buildDocsSection(params: { docsPath?: string; isMinimal: boolean; readToolName: string }) {
|
||||||
const docsPath = params.docsPath?.trim();
|
const docsPath = params.docsPath?.trim();
|
||||||
if (!docsPath || params.isMinimal) return [];
|
if (!docsPath || params.isMinimal) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
"## Documentation",
|
"## Documentation",
|
||||||
`OpenClaw docs: ${docsPath}`,
|
`OpenClaw docs: ${docsPath}`,
|
||||||
@@ -268,7 +288,9 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
const externalToolSummaries = new Map<string, string>();
|
const externalToolSummaries = new Map<string, string>();
|
||||||
for (const [key, value] of Object.entries(params.toolSummaries ?? {})) {
|
for (const [key, value] of Object.entries(params.toolSummaries ?? {})) {
|
||||||
const normalized = key.trim().toLowerCase();
|
const normalized = key.trim().toLowerCase();
|
||||||
if (!normalized || !value?.trim()) continue;
|
if (!normalized || !value?.trim()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
externalToolSummaries.set(normalized, value.trim());
|
externalToolSummaries.set(normalized, value.trim());
|
||||||
}
|
}
|
||||||
const extraTools = Array.from(
|
const extraTools = Array.from(
|
||||||
@@ -280,7 +302,7 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
const name = resolveToolName(tool);
|
const name = resolveToolName(tool);
|
||||||
return summary ? `- ${name}: ${summary}` : `- ${name}`;
|
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 summary = coreToolSummaries[tool] ?? externalToolSummaries.get(tool);
|
||||||
const name = resolveToolName(tool);
|
const name = resolveToolName(tool);
|
||||||
toolLines.push(summary ? `- ${name}: ${summary}` : `- ${name}`);
|
toolLines.push(summary ? `- ${name}: ${summary}` : `- ${name}`);
|
||||||
|
|||||||
@@ -27,12 +27,16 @@ export function createMemorySearchTool(options: {
|
|||||||
agentSessionKey?: string;
|
agentSessionKey?: string;
|
||||||
}): AnyAgentTool | null {
|
}): AnyAgentTool | null {
|
||||||
const cfg = options.config;
|
const cfg = options.config;
|
||||||
if (!cfg) return null;
|
if (!cfg) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const agentId = resolveSessionAgentId({
|
const agentId = resolveSessionAgentId({
|
||||||
sessionKey: options.agentSessionKey,
|
sessionKey: options.agentSessionKey,
|
||||||
config: cfg,
|
config: cfg,
|
||||||
});
|
});
|
||||||
if (!resolveMemorySearchConfig(cfg, agentId)) return null;
|
if (!resolveMemorySearchConfig(cfg, agentId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
label: "Memory Search",
|
label: "Memory Search",
|
||||||
name: "memory_search",
|
name: "memory_search",
|
||||||
@@ -88,12 +92,16 @@ export function createMemoryGetTool(options: {
|
|||||||
agentSessionKey?: string;
|
agentSessionKey?: string;
|
||||||
}): AnyAgentTool | null {
|
}): AnyAgentTool | null {
|
||||||
const cfg = options.config;
|
const cfg = options.config;
|
||||||
if (!cfg) return null;
|
if (!cfg) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const agentId = resolveSessionAgentId({
|
const agentId = resolveSessionAgentId({
|
||||||
sessionKey: options.agentSessionKey,
|
sessionKey: options.agentSessionKey,
|
||||||
config: cfg,
|
config: cfg,
|
||||||
});
|
});
|
||||||
if (!resolveMemorySearchConfig(cfg, agentId)) return null;
|
if (!resolveMemorySearchConfig(cfg, agentId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
label: "Memory Get",
|
label: "Memory Get",
|
||||||
name: "memory_get",
|
name: "memory_get",
|
||||||
@@ -199,11 +207,16 @@ function deriveChatTypeFromSessionKey(sessionKey?: string): "direct" | "group" |
|
|||||||
if (!parsed?.rest) {
|
if (!parsed?.rest) {
|
||||||
return "direct";
|
return "direct";
|
||||||
}
|
}
|
||||||
const tokens = parsed.rest.toLowerCase().split(":").filter(Boolean);
|
const tokens = new Set(
|
||||||
if (tokens.includes("channel")) {
|
parsed.rest
|
||||||
|
.toLowerCase()
|
||||||
|
.split(":")
|
||||||
|
.filter(Boolean),
|
||||||
|
);
|
||||||
|
if (tokens.has("channel")) {
|
||||||
return "channel";
|
return "channel";
|
||||||
}
|
}
|
||||||
if (tokens.includes("group")) {
|
if (tokens.has("group")) {
|
||||||
return "group";
|
return "group";
|
||||||
}
|
}
|
||||||
return "direct";
|
return "direct";
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ type MemoryPluginStatus = {
|
|||||||
|
|
||||||
function resolveMemoryPluginStatus(cfg: ReturnType<typeof loadConfig>): MemoryPluginStatus {
|
function resolveMemoryPluginStatus(cfg: ReturnType<typeof loadConfig>): MemoryPluginStatus {
|
||||||
const pluginsEnabled = cfg.plugins?.enabled !== false;
|
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() : "";
|
const raw = typeof cfg.plugins?.slots?.memory === "string" ? cfg.plugins.slots.memory.trim() : "";
|
||||||
if (raw && raw.toLowerCase() === "none") {
|
if (raw && raw.toLowerCase() === "none") {
|
||||||
return { enabled: false, slot: null, reason: 'plugins.slots.memory="none"' };
|
return { enabled: false, slot: null, reason: 'plugins.slots.memory="none"' };
|
||||||
@@ -126,7 +128,7 @@ export async function scanStatus(
|
|||||||
|
|
||||||
progress.setLabel("Querying channel status…");
|
progress.setLabel("Querying channel status…");
|
||||||
const channelsStatus = gatewayReachable
|
const channelsStatus = gatewayReachable
|
||||||
? await callGateway<Record<string, unknown>>({
|
? await callGateway({
|
||||||
method: "channels.status",
|
method: "channels.status",
|
||||||
params: {
|
params: {
|
||||||
probe: false,
|
probe: false,
|
||||||
@@ -149,11 +151,17 @@ export async function scanStatus(
|
|||||||
progress.setLabel("Checking memory…");
|
progress.setLabel("Checking memory…");
|
||||||
const memoryPlugin = resolveMemoryPluginStatus(cfg);
|
const memoryPlugin = resolveMemoryPluginStatus(cfg);
|
||||||
const memory = await (async (): Promise<MemoryStatusSnapshot | null> => {
|
const memory = await (async (): Promise<MemoryStatusSnapshot | null> => {
|
||||||
if (!memoryPlugin.enabled) return null;
|
if (!memoryPlugin.enabled) {
|
||||||
if (memoryPlugin.slot !== "memory-core") return null;
|
return null;
|
||||||
|
}
|
||||||
|
if (memoryPlugin.slot !== "memory-core") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const agentId = agentStatus.defaultId ?? "main";
|
const agentId = agentStatus.defaultId ?? "main";
|
||||||
const { manager } = await getMemorySearchManager({ cfg, agentId });
|
const { manager } = await getMemorySearchManager({ cfg, agentId });
|
||||||
if (!manager) return null;
|
if (!manager) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await manager.probeVectorAvailability();
|
await manager.probeVectorAvailability();
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
@@ -592,15 +592,23 @@ export const OpenClawSchema = z
|
|||||||
.strict()
|
.strict()
|
||||||
.superRefine((cfg, ctx) => {
|
.superRefine((cfg, ctx) => {
|
||||||
const agents = cfg.agents?.list ?? [];
|
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 agentIds = new Set(agents.map((agent) => agent.id));
|
||||||
|
|
||||||
const broadcast = cfg.broadcast;
|
const broadcast = cfg.broadcast;
|
||||||
if (!broadcast) return;
|
if (!broadcast) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const [peerId, ids] of Object.entries(broadcast)) {
|
for (const [peerId, ids] of Object.entries(broadcast)) {
|
||||||
if (peerId === "strategy") continue;
|
if (peerId === "strategy") {
|
||||||
if (!Array.isArray(ids)) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (!Array.isArray(ids)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (let idx = 0; idx < ids.length; idx += 1) {
|
for (let idx = 0; idx < ids.length; idx += 1) {
|
||||||
const agentId = ids[idx];
|
const agentId = ids[idx];
|
||||||
if (!agentIds.has(agentId)) {
|
if (!agentIds.has(agentId)) {
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ function sortValue(value: unknown): unknown {
|
|||||||
}
|
}
|
||||||
if (value && typeof value === "object") {
|
if (value && typeof value === "object") {
|
||||||
const sortedEntries = Object.keys(value as Record<string, unknown>)
|
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])]);
|
.map((key) => [key, sortValue((value as Record<string, unknown>)[key])]);
|
||||||
return Object.fromEntries(sortedEntries);
|
return Object.fromEntries(sortedEntries);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user