mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:31:23 +00:00
chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.
This commit is contained in:
@@ -35,19 +35,15 @@ function ensureAgentRunListener() {
|
||||
if (evt.stream !== "lifecycle") return;
|
||||
const phase = evt.data?.phase;
|
||||
if (phase === "start") {
|
||||
const startedAt =
|
||||
typeof evt.data?.startedAt === "number" ? (evt.data.startedAt as number) : undefined;
|
||||
const startedAt = typeof evt.data?.startedAt === "number" ? evt.data.startedAt : undefined;
|
||||
agentRunStarts.set(evt.runId, startedAt ?? Date.now());
|
||||
return;
|
||||
}
|
||||
if (phase !== "end" && phase !== "error") return;
|
||||
const startedAt =
|
||||
typeof evt.data?.startedAt === "number"
|
||||
? (evt.data.startedAt as number)
|
||||
: agentRunStarts.get(evt.runId);
|
||||
const endedAt =
|
||||
typeof evt.data?.endedAt === "number" ? (evt.data.endedAt as number) : undefined;
|
||||
const error = typeof evt.data?.error === "string" ? (evt.data.error as string) : undefined;
|
||||
typeof evt.data?.startedAt === "number" ? evt.data.startedAt : agentRunStarts.get(evt.runId);
|
||||
const endedAt = typeof evt.data?.endedAt === "number" ? evt.data.endedAt : undefined;
|
||||
const error = typeof evt.data?.error === "string" ? evt.data.error : undefined;
|
||||
agentRunStarts.delete(evt.runId);
|
||||
recordAgentRunSnapshot({
|
||||
runId: evt.runId,
|
||||
@@ -96,11 +92,10 @@ export async function waitForAgentJob(params: {
|
||||
}
|
||||
const startedAt =
|
||||
typeof evt.data?.startedAt === "number"
|
||||
? (evt.data.startedAt as number)
|
||||
? evt.data.startedAt
|
||||
: agentRunStarts.get(evt.runId);
|
||||
const endedAt =
|
||||
typeof evt.data?.endedAt === "number" ? (evt.data.endedAt as number) : undefined;
|
||||
const error = typeof evt.data?.error === "string" ? (evt.data.error as string) : undefined;
|
||||
const endedAt = typeof evt.data?.endedAt === "number" ? evt.data.endedAt : undefined;
|
||||
const error = typeof evt.data?.error === "string" ? evt.data.error : undefined;
|
||||
const snapshot: AgentRunSnapshot = {
|
||||
runId: evt.runId,
|
||||
status: phase === "error" ? "error" : "ok",
|
||||
|
||||
@@ -44,7 +44,7 @@ import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
export const agentHandlers: GatewayRequestHandlers = {
|
||||
agent: async ({ params, respond, context }) => {
|
||||
const p = params as Record<string, unknown>;
|
||||
const p = params;
|
||||
if (!validateAgentParams(p)) {
|
||||
respond(
|
||||
false,
|
||||
@@ -430,7 +430,7 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as AgentIdentityParams;
|
||||
const p = params;
|
||||
const agentIdRaw = typeof p.agentId === "string" ? p.agentId.trim() : "";
|
||||
const sessionKeyRaw = typeof p.sessionKey === "string" ? p.sessionKey.trim() : "";
|
||||
let agentId = agentIdRaw ? normalizeAgentId(agentIdRaw) : undefined;
|
||||
@@ -471,7 +471,7 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as AgentWaitParams;
|
||||
const p = params;
|
||||
const runId = p.runId.trim();
|
||||
const timeoutMs =
|
||||
typeof p.timeoutMs === "number" && Number.isFinite(p.timeoutMs)
|
||||
|
||||
@@ -89,7 +89,7 @@ export const cronHandlers: GatewayRequestHandlers = {
|
||||
const normalizedPatch = normalizeCronJobPatch((params as { patch?: unknown } | null)?.patch);
|
||||
const candidate =
|
||||
normalizedPatch && typeof params === "object" && params !== null
|
||||
? { ...(params as Record<string, unknown>), patch: normalizedPatch }
|
||||
? { ...params, patch: normalizedPatch }
|
||||
: params;
|
||||
if (!validateCronUpdateParams(candidate)) {
|
||||
respond(
|
||||
|
||||
@@ -43,7 +43,7 @@ async function resolveLogFile(file: string): Promise<string> {
|
||||
);
|
||||
const sorted = candidates
|
||||
.filter((entry): entry is NonNullable<typeof entry> => Boolean(entry))
|
||||
.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
||||
.toSorted((a, b) => b.mtimeMs - a.mtimeMs);
|
||||
return sorted[0]?.path ?? file;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export function uniqueSortedStrings(values: unknown[]) {
|
||||
return [...new Set(values.filter((v) => typeof v === "string"))]
|
||||
.map((v) => v.trim())
|
||||
.filter(Boolean)
|
||||
.sort();
|
||||
.toSorted();
|
||||
}
|
||||
|
||||
export function safeParseJson(value: string | null | undefined): unknown {
|
||||
|
||||
@@ -46,7 +46,7 @@ const getInflightMap = (context: GatewayRequestContext) => {
|
||||
|
||||
export const sendHandlers: GatewayRequestHandlers = {
|
||||
send: async ({ params, respond, context }) => {
|
||||
const p = params as Record<string, unknown>;
|
||||
const p = params;
|
||||
if (!validateSendParams(p)) {
|
||||
respond(
|
||||
false,
|
||||
@@ -104,8 +104,8 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
typeof request.accountId === "string" && request.accountId.trim().length
|
||||
? request.accountId.trim()
|
||||
: undefined;
|
||||
const outboundChannel = channel as Exclude<OutboundChannel, "none">;
|
||||
const plugin = getChannelPlugin(channel as ChannelId);
|
||||
const outboundChannel = channel;
|
||||
const plugin = getChannelPlugin(channel);
|
||||
if (!plugin) {
|
||||
respond(
|
||||
false,
|
||||
@@ -237,7 +237,7 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
}
|
||||
},
|
||||
poll: async ({ params, respond, context }) => {
|
||||
const p = params as Record<string, unknown>;
|
||||
const p = params;
|
||||
if (!validatePollParams(p)) {
|
||||
respond(
|
||||
false,
|
||||
@@ -290,7 +290,7 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
? request.accountId.trim()
|
||||
: undefined;
|
||||
try {
|
||||
const plugin = getChannelPlugin(channel as ChannelId);
|
||||
const plugin = getChannelPlugin(channel);
|
||||
const outbound = plugin?.outbound;
|
||||
if (!outbound?.sendPoll) {
|
||||
respond(
|
||||
@@ -302,7 +302,7 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
}
|
||||
const cfg = loadConfig();
|
||||
const resolved = resolveOutboundTarget({
|
||||
channel: channel as Exclude<OutboundChannel, "none">,
|
||||
channel: channel,
|
||||
to,
|
||||
cfg,
|
||||
accountId,
|
||||
|
||||
@@ -53,7 +53,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as import("../protocol/index.js").SessionsListParams;
|
||||
const p = params;
|
||||
const cfg = loadConfig();
|
||||
const { storePath, store } = loadCombinedSessionStoreForGateway(cfg);
|
||||
const result = listSessionsFromStore({
|
||||
@@ -78,7 +78,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as import("../protocol/index.js").SessionsPreviewParams;
|
||||
const p = params;
|
||||
const keysRaw = Array.isArray(p.keys) ? p.keys : [];
|
||||
const keys = keysRaw
|
||||
.map((key) => String(key ?? "").trim())
|
||||
@@ -144,7 +144,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as import("../protocol/index.js").SessionsResolveParams;
|
||||
const p = params;
|
||||
const cfg = loadConfig();
|
||||
|
||||
const resolved = resolveSessionKeyFromResolveParams({ cfg, p });
|
||||
@@ -166,7 +166,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as import("../protocol/index.js").SessionsPatchParams;
|
||||
const p = params;
|
||||
const key = String(p.key ?? "").trim();
|
||||
if (!key) {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "key required"));
|
||||
@@ -215,7 +215,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as import("../protocol/index.js").SessionsResetParams;
|
||||
const p = params;
|
||||
const key = String(p.key ?? "").trim();
|
||||
if (!key) {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "key required"));
|
||||
@@ -273,7 +273,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as import("../protocol/index.js").SessionsDeleteParams;
|
||||
const p = params;
|
||||
const key = String(p.key ?? "").trim();
|
||||
if (!key) {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "key required"));
|
||||
@@ -359,7 +359,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as import("../protocol/index.js").SessionsCompactParams;
|
||||
const p = params;
|
||||
const key = String(p.key ?? "").trim();
|
||||
if (!key) {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "key required"));
|
||||
|
||||
@@ -52,7 +52,7 @@ function collectSkillBins(entries: SkillEntry[]): string[] {
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...bins].sort();
|
||||
return [...bins].toSorted();
|
||||
}
|
||||
|
||||
export const skillsHandlers: GatewayRequestHandlers = {
|
||||
@@ -95,7 +95,7 @@ export const skillsHandlers: GatewayRequestHandlers = {
|
||||
const entries = loadWorkspaceSkillEntries(workspaceDir, { config: cfg });
|
||||
for (const bin of collectSkillBins(entries)) bins.add(bin);
|
||||
}
|
||||
respond(true, { bins: [...bins].sort() }, undefined);
|
||||
respond(true, { bins: [...bins].toSorted() }, undefined);
|
||||
},
|
||||
"skills.install": async ({ params, respond }) => {
|
||||
if (!validateSkillsInstallParams(params)) {
|
||||
|
||||
@@ -54,15 +54,15 @@ export const systemHandlers: GatewayRequestHandlers = {
|
||||
const reason = typeof params.reason === "string" ? params.reason : undefined;
|
||||
const roles =
|
||||
Array.isArray(params.roles) && params.roles.every((t) => typeof t === "string")
|
||||
? (params.roles as string[])
|
||||
? params.roles
|
||||
: undefined;
|
||||
const scopes =
|
||||
Array.isArray(params.scopes) && params.scopes.every((t) => typeof t === "string")
|
||||
? (params.scopes as string[])
|
||||
? params.scopes
|
||||
: undefined;
|
||||
const tags =
|
||||
Array.isArray(params.tags) && params.tags.every((t) => typeof t === "string")
|
||||
? (params.tags as string[])
|
||||
? params.tags
|
||||
: undefined;
|
||||
const presenceUpdate = updateSystemPresence({
|
||||
text,
|
||||
|
||||
@@ -33,7 +33,7 @@ export const wizardHandlers: GatewayRequestHandlers = {
|
||||
}
|
||||
const sessionId = randomUUID();
|
||||
const opts = {
|
||||
mode: params.mode as "local" | "remote" | undefined,
|
||||
mode: params.mode,
|
||||
workspace: typeof params.workspace === "string" ? params.workspace : undefined,
|
||||
};
|
||||
const session = new WizardSession((prompter) =>
|
||||
@@ -58,7 +58,7 @@ export const wizardHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const sessionId = params.sessionId as string;
|
||||
const sessionId = params.sessionId;
|
||||
const session = context.wizardSessions.get(sessionId);
|
||||
if (!session) {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "wizard not found"));
|
||||
@@ -95,7 +95,7 @@ export const wizardHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const sessionId = params.sessionId as string;
|
||||
const sessionId = params.sessionId;
|
||||
const session = context.wizardSessions.get(sessionId);
|
||||
if (!session) {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "wizard not found"));
|
||||
@@ -121,7 +121,7 @@ export const wizardHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const sessionId = params.sessionId as string;
|
||||
const sessionId = params.sessionId;
|
||||
const session = context.wizardSessions.get(sessionId);
|
||||
if (!session) {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "wizard not found"));
|
||||
|
||||
Reference in New Issue
Block a user