chore(lint): enable readability lint rules

This commit is contained in:
Peter Steinberger
2026-05-31 07:17:44 +01:00
parent 0211a3aa9f
commit deb7bc6539
373 changed files with 766 additions and 825 deletions

View File

@@ -26,6 +26,7 @@
"eslint/no-sequences": "error",
"eslint/no-self-compare": "error",
"eslint/no-shadow": "off",
"eslint/no-implicit-coercion": "error",
"eslint/no-var": "error",
"eslint/no-useless-call": "error",
"eslint/no-useless-computed-key": "error",
@@ -41,6 +42,7 @@
"eslint/default-param-last": "error",
"eslint/prefer-exponentiation-operator": "error",
"eslint/prefer-numeric-literals": "error",
"eslint/prefer-object-has-own": "error",
"eslint/prefer-rest-params": "error",
"eslint/prefer-spread": "error",
"eslint/radix": "error",
@@ -66,6 +68,7 @@
"typescript/no-empty-object-type": ["error", { "allowInterfaces": "with-single-extends" }],
"typescript/no-explicit-any": "error",
"typescript/no-extraneous-class": "error",
"typescript/no-import-type-side-effects": "error",
"typescript/no-meaningless-void-operator": "error",
"typescript/no-non-null-asserted-nullish-coalescing": "error",
"typescript/no-unnecessary-qualifier": "error",
@@ -111,6 +114,7 @@
"unicorn/no-unnecessary-slice-end": "error",
"unicorn/no-useless-error-capture-stack-trace": "error",
"unicorn/no-useless-promise-resolve-reject": "error",
"unicorn/no-zero-fractions": "error",
"unicorn/prefer-date-now": "error",
"unicorn/prefer-dom-node-text-content": "error",
"unicorn/prefer-keyboard-event-key": "error",
@@ -183,6 +187,7 @@
"docs/_layouts/",
"extensions/diffs/assets/viewer-runtime.js",
"extensions/diffs-language-pack/assets/viewer-runtime.js",
"extensions/canvas/src/host/a2ui/a2ui.bundle.js",
"node_modules/",
"patches/",
"pnpm-lock.yaml",

View File

@@ -75,7 +75,7 @@ async function readLeaseFile(filePath: string): Promise<LeaseFile> {
leases: [],
});
const leases = Array.isArray(value.leases)
? value.leases.map(normalizeLease).filter((lease): lease is AcpxProcessLease => !!lease)
? value.leases.map(normalizeLease).filter((lease): lease is AcpxProcessLease => Boolean(lease))
: [];
return { version: 1, leases };
}

View File

@@ -127,9 +127,7 @@ function readRpcRequestBody(body: unknown):
request: {
id,
method: rpcBody.method.trim(),
...(Object.prototype.hasOwnProperty.call(rpcBody, "params")
? { params: rpcBody.params }
: {}),
...(Object.hasOwn(rpcBody, "params") ? { params: rpcBody.params } : {}),
},
};
}

View File

@@ -1,7 +1,7 @@
import {
type BedrockClient,
type ListFoundationModelsCommandOutput,
type ListInferenceProfilesCommandOutput,
import type {
BedrockClient,
ListFoundationModelsCommandOutput,
ListInferenceProfilesCommandOutput,
} from "@aws-sdk/client-bedrock";
import { createSubsystemLogger } from "openclaw/plugin-sdk/core";
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";

View File

@@ -26,7 +26,7 @@ export const ARCEE_MODEL_CATALOG: ModelDefinitionConfig[] = [
maxTokens: 16384,
cost: {
input: 0.25,
output: 1.0,
output: 1,
cacheRead: 0.25,
cacheWrite: 0.25,
},

View File

@@ -1,4 +1,4 @@
import { type WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-config-contract";
import type { WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-config-contract";
import { buildBraveWebSearchProviderBase } from "./web-search-shared.js";
export function createBraveWebSearchProvider(): WebSearchProviderPlugin {

View File

@@ -38,13 +38,10 @@ export default definePluginEntry({
) {
return null;
}
if (Object.prototype.hasOwnProperty.call(config, "browser")) {
if (Object.hasOwn(config, "browser")) {
return "browser configured";
}
if (
config.plugins?.entries &&
Object.prototype.hasOwnProperty.call(config.plugins.entries, "browser")
) {
if (config.plugins?.entries && Object.hasOwn(config.plugins.entries, "browser")) {
return "browser plugin configured";
}
if (hasBrowserToolReference(config)) {

View File

@@ -5,11 +5,7 @@ import {
normalizeOptionalString,
normalizeOptionalTrimmedStringList,
} from "openclaw/plugin-sdk/string-coerce-runtime";
import {
type BrowserConfig,
type BrowserProfileConfig,
type OpenClawConfig,
} from "../config/config.js";
import type { BrowserConfig, BrowserProfileConfig, OpenClawConfig } from "../config/config.js";
import { resolveGatewayPort } from "../config/paths.js";
import {
DEFAULT_BROWSER_CONTROL_PORT,

View File

@@ -269,7 +269,7 @@ async function runBrowserLiveProbe(req: BrowserRequest, ctx: BrowserRouteContext
}
function hasQueryKey(query: BrowserRequest["query"], key: string): boolean {
return Object.prototype.hasOwnProperty.call(query ?? {}, key);
return Object.hasOwn(query ?? {}, key);
}
function parseHeadlessStartOverride(params: {

View File

@@ -133,7 +133,7 @@ function isLegacyClawdProfileConfigured(cfg: OpenClawConfig, legacyProfileDir: s
if (!configuredProfiles) {
return false;
}
if (Object.prototype.hasOwnProperty.call(configuredProfiles, LEGACY_CLAWD_BROWSER_PROFILE_NAME)) {
if (Object.hasOwn(configuredProfiles, LEGACY_CLAWD_BROWSER_PROFILE_NAME)) {
return true;
}

View File

@@ -457,15 +457,15 @@ class OpenClawA2UIHost extends LitElement {
context[key] = resolved;
continue;
}
if (Object.prototype.hasOwnProperty.call(value, "literalString")) {
if (Object.hasOwn(value, "literalString")) {
context[key] = value.literalString ?? "";
continue;
}
if (Object.prototype.hasOwnProperty.call(value, "literalNumber")) {
if (Object.hasOwn(value, "literalNumber")) {
context[key] = value.literalNumber ?? 0;
continue;
}
if (Object.prototype.hasOwnProperty.call(value, "literalBoolean")) {
if (Object.hasOwn(value, "literalBoolean")) {
context[key] = value.literalBoolean ?? false;
continue;
}

View File

@@ -54,7 +54,7 @@ async function writeBase64ToTempFile(params: { base64: string; ext: string }): P
function isPathInsideRoot(root: string, candidate: string): boolean {
const relative = path.relative(root, candidate);
return (
relative === "" || (!!relative && !relative.startsWith("..") && !path.isAbsolute(relative))
relative === "" || (relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative))
);
}

View File

@@ -14,7 +14,7 @@ function asRecord(value: unknown): Record<string, unknown> | null {
}
function hasRetiredDynamicToolsProfile(value: unknown): boolean {
return Object.prototype.hasOwnProperty.call(asRecord(value) ?? {}, "codexDynamicToolsProfile");
return Object.hasOwn(asRecord(value) ?? {}, "codexDynamicToolsProfile");
}
export const legacyConfigRules: LegacyConfigRule[] = [

View File

@@ -2,16 +2,16 @@ import {
type JsonSchemaObject,
validateJsonSchemaValue,
} from "openclaw/plugin-sdk/json-schema-runtime";
import {
type ImagesDescriptionRequest,
type ImagesDescriptionResult,
type MediaUnderstandingProvider,
type StructuredExtractionRequest,
type StructuredExtractionResult,
import type {
ImagesDescriptionRequest,
ImagesDescriptionResult,
MediaUnderstandingProvider,
StructuredExtractionRequest,
StructuredExtractionResult,
} from "openclaw/plugin-sdk/media-understanding";
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
import { CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS } from "./provider-catalog.js";
import { type CodexAppServerClientFactory } from "./src/app-server/client-factory.js";
import type { CodexAppServerClientFactory } from "./src/app-server/client-factory.js";
import type { CodexAppServerClient } from "./src/app-server/client.js";
import { resolveCodexAppServerRuntimeOptions } from "./src/app-server/config.js";
import { readModelListResult } from "./src/app-server/models.js";

View File

@@ -1,5 +1,4 @@
import type { AgentToolResult } from "openclaw/plugin-sdk/agent-core";
import { emitTrustedDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
import {
createAgentToolResultMiddlewareRunner,
createCodexAppServerToolResultExtensionRunner,
@@ -21,6 +20,7 @@ import {
type MessagingToolSourceReplyPayload,
wrapToolWithBeforeToolCallHook,
} from "openclaw/plugin-sdk/agent-harness-runtime";
import { emitTrustedDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
import type { ImageContent, TextContent } from "openclaw/plugin-sdk/llm";
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
import {
@@ -29,13 +29,13 @@ import {
} from "openclaw/plugin-sdk/string-coerce-runtime";
import type { CodexDynamicToolsLoading } from "./config.js";
import { invalidInlineImageText, sanitizeInlineImageDataUrl } from "./image-payload-sanitizer.js";
import {
type CodexDynamicToolCallOutputContentItem,
type CodexDynamicToolCallParams,
type CodexDynamicToolCallResponse,
type CodexDynamicToolDiagnosticTerminalType,
type CodexDynamicToolSpec,
type JsonValue,
import type {
CodexDynamicToolCallOutputContentItem,
CodexDynamicToolCallParams,
CodexDynamicToolCallResponse,
CodexDynamicToolDiagnosticTerminalType,
CodexDynamicToolSpec,
JsonValue,
} from "./protocol.js";
type CodexDynamicToolHookContext = {

View File

@@ -508,7 +508,7 @@ function formatDisplayJsonValue(value: JsonValue, depth = MAX_DISPLAY_VALUE_DEPT
let count = 0;
let truncated = false;
for (const key in value) {
if (!Object.prototype.hasOwnProperty.call(value, key)) {
if (!Object.hasOwn(value, key)) {
continue;
}
if (count >= MAX_DISPLAY_VALUE_OBJECT_KEYS) {

View File

@@ -1,9 +1,6 @@
import fs from "node:fs/promises";
import path from "node:path";
import {
type CodexAppInventoryCache,
type CodexAppInventoryRequest,
} from "./app-inventory-cache.js";
import type { CodexAppInventoryCache, CodexAppInventoryRequest } from "./app-inventory-cache.js";
import { CODEX_PLUGINS_MARKETPLACE_NAME, type ResolvedCodexPluginPolicy } from "./config.js";
import {
findOpenAiCuratedPluginSummary,

View File

@@ -1,8 +1,8 @@
import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
import {
type CodexAppInventoryCache,
type CodexAppInventoryCacheRead,
type CodexAppInventoryRequest,
import type {
CodexAppInventoryCache,
CodexAppInventoryCacheRead,
CodexAppInventoryRequest,
} from "./app-inventory-cache.js";
import {
CODEX_PLUGINS_MARKETPLACE_NAME,

View File

@@ -107,7 +107,7 @@ function normalizeJsonSchemaNode(schema: unknown): unknown {
}
function readDefault(schema: unknown): unknown {
if (!isRecord(schema) || !Object.prototype.hasOwnProperty.call(schema, "default")) {
if (!isRecord(schema) || !Object.hasOwn(schema, "default")) {
return undefined;
}
return structuredClone(schema.default);
@@ -176,7 +176,7 @@ function applySchemaDefaults(
}
if (isRecord(schema.additionalProperties)) {
for (const key of Object.keys(nextValue)) {
if (Object.prototype.hasOwnProperty.call(schema.properties, key)) {
if (Object.hasOwn(schema.properties, key)) {
continue;
}
nextValue[key] = applySchemaDefaults(

View File

@@ -192,15 +192,15 @@ import {
assertCodexTurnStartResponse,
readCodexDynamicToolCallParams,
} from "./protocol-validators.js";
import {
type CodexSandboxPolicy,
type CodexTurnEnvironmentParams,
type CodexServerNotification,
type CodexDynamicToolCallParams,
type CodexDynamicToolCallResponse,
type CodexTurnStartResponse,
type JsonObject,
type JsonValue,
import type {
CodexSandboxPolicy,
CodexTurnEnvironmentParams,
CodexServerNotification,
CodexDynamicToolCallParams,
CodexDynamicToolCallResponse,
CodexTurnStartResponse,
JsonObject,
JsonValue,
} from "./protocol.js";
import { releaseCodexSandboxExecServerEnvironment } from "./sandbox-exec-server.js";
import {

View File

@@ -226,7 +226,7 @@ function resolveActiveProfileId(params: {
params.store.lastGood?.[OPENAI_CODEX_PROVIDER_ID],
].find(
(profileId): profileId is string =>
!!profileId &&
Boolean(profileId) &&
params.order.includes(profileId) &&
isActiveProfileCandidate(params, profileId),
);

View File

@@ -25,12 +25,12 @@ import {
type CodexAppServerSandboxMode,
type OpenClawExecPolicyForCodexAppServer,
} from "./app-server/config.js";
import {
type CodexServiceTier,
type CodexThreadResumeResponse,
type CodexThreadStartResponse,
type CodexTurnStartResponse,
type JsonValue,
import type {
CodexServiceTier,
CodexThreadResumeResponse,
CodexThreadStartResponse,
CodexTurnStartResponse,
JsonValue,
} from "./app-server/protocol.js";
import {
resolveCodexNativeExecutionBlock,

View File

@@ -3,7 +3,7 @@ import {
type ProviderCatalogContext,
type ProviderCatalogResult,
} from "openclaw/plugin-sdk/provider-catalog-shared";
import { type ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
import {
DEEPINFRA_BASE_URL,
DEEPINFRA_MODEL_CATALOG,

View File

@@ -1,4 +1,4 @@
import { type ProviderCatalogContext } from "openclaw/plugin-sdk/provider-catalog-shared";
import type { ProviderCatalogContext } from "openclaw/plugin-sdk/provider-catalog-shared";
import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared";
import { buildDeepInfraApiKeyCatalog, buildStaticDeepInfraProvider } from "./provider-catalog.js";

View File

@@ -293,13 +293,13 @@ const STATIC_NON_CHAT_FALLBACK: DeepInfraSurfaceModel[] = [
id: "ResembleAI/chatterbox-turbo",
name: "ResembleAI/chatterbox-turbo",
tags: ["tts"],
pricing: { input_characters: 1.0 },
pricing: { input_characters: 1 },
},
{
id: "sesame/csm-1b",
name: "sesame/csm-1b",
tags: ["tts"],
pricing: { input_characters: 7.0 },
pricing: { input_characters: 7 },
},
// stt
{

View File

@@ -33,8 +33,7 @@ export function inspectDiscordAccount(params: {
const enabled = params.cfg.channels?.discord?.enabled !== false && merged.enabled !== false;
const accountConfig = resolveDiscordAccountConfig(params.cfg, accountId);
const hasAccountToken = Boolean(
accountConfig &&
Object.prototype.hasOwnProperty.call(accountConfig as Record<string, unknown>, "token"),
accountConfig && Object.hasOwn(accountConfig as Record<string, unknown>, "token"),
);
const accountToken = inspectDiscordConfiguredToken(accountConfig?.token);
if (accountToken) {

View File

@@ -1,5 +1,5 @@
import { type ResolvedDiscordAccount } from "./accounts.js";
import { type ChannelPlugin } from "./channel-api.js";
import type { ResolvedDiscordAccount } from "./accounts.js";
import type { ChannelPlugin } from "./channel-api.js";
import { discordSetupWizard } from "./channel.runtime.js";
import { discordSetupAdapter } from "./setup-adapter.js";
import { createDiscordPluginBase } from "./shared.js";

View File

@@ -18,7 +18,7 @@ function hasLegacyTtsProviderKeys(value: unknown): boolean {
if (!tts) {
return false;
}
return LEGACY_TTS_PROVIDER_KEYS.some((key) => Object.prototype.hasOwnProperty.call(tts, key));
return LEGACY_TTS_PROVIDER_KEYS.some((key) => Object.hasOwn(tts, key));
}
function hasLegacyDiscordAccountTtsProviderKeys(value: unknown): boolean {
@@ -44,7 +44,7 @@ function hasLegacyDiscordGuildChannelAllowAlias(value: unknown): boolean {
return false;
}
return Object.values(channels).some((channel) =>
Object.prototype.hasOwnProperty.call(asObjectRecord(channel) ?? {}, "allow"),
Object.hasOwn(asObjectRecord(channel) ?? {}, "allow"),
);
});
}
@@ -60,7 +60,7 @@ function hasLegacyDiscordGuildChannelAgentId(value: unknown): boolean {
return false;
}
return Object.values(channels).some((channel) =>
Object.prototype.hasOwnProperty.call(asObjectRecord(channel) ?? {}, "agentId"),
Object.hasOwn(asObjectRecord(channel) ?? {}, "agentId"),
);
});
}
@@ -284,7 +284,7 @@ function normalizeDiscordGuildChannelAllowAliases(params: {
const nextChannels = { ...channels };
for (const [channelId, channelValue] of Object.entries(channels)) {
const channel = asObjectRecord(channelValue);
if (!channel || !Object.prototype.hasOwnProperty.call(channel, "allow")) {
if (!channel || !Object.hasOwn(channel, "allow")) {
continue;
}
const nextChannel = { ...channel };
@@ -359,7 +359,7 @@ function normalizeDiscordGuildChannelAgentIds(params: {
const nextChannels = { ...channels };
for (const [channelId, channelValue] of Object.entries(channels)) {
const channel = asObjectRecord(channelValue);
if (!channel || !Object.prototype.hasOwnProperty.call(channel, "agentId")) {
if (!channel || !Object.hasOwn(channel, "agentId")) {
continue;
}
const nextChannel = { ...channel };

View File

@@ -1,4 +1,4 @@
import { type ChannelDoctorAdapter } from "openclaw/plugin-sdk/channel-contract";
import type { ChannelDoctorAdapter } from "openclaw/plugin-sdk/channel-contract";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { collectProviderDangerousNameMatchingScopes } from "openclaw/plugin-sdk/runtime-doctor";
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";

View File

@@ -1,8 +1,8 @@
import {
type APIApplicationCommandInteractionDataBasicOption,
type APIApplicationCommandInteractionDataOption,
type APIChannel,
type APIInteractionDataResolvedChannel,
import type {
APIApplicationCommandInteractionDataBasicOption,
APIApplicationCommandInteractionDataOption,
APIChannel,
APIInteractionDataResolvedChannel,
} from "discord-api-types/v10";
import { channelFactory, type DiscordChannel, type StructureClient } from "./structures.js";

View File

@@ -1,4 +1,4 @@
import { type APIRole, type APIUser } from "discord-api-types/v10";
import type { APIRole, APIUser } from "discord-api-types/v10";
import { Role, User, type StructureClient } from "./structures.js";
type ModalResolvedData = {

View File

@@ -1,12 +1,12 @@
import {
type APIChannel,
type APIEmbed,
type APIGuild,
type APIGuildMember,
type APIMessage,
type APIRole,
type APIUser,
type MessageType,
import type {
APIChannel,
APIEmbed,
APIGuild,
APIGuildMember,
APIMessage,
APIRole,
APIUser,
MessageType,
} from "discord-api-types/v10";
import {
createChannelMessage,

View File

@@ -1,12 +1,12 @@
import { ChannelType } from "discord-api-types/v10";
import { logError } from "openclaw/plugin-sdk/logging-core";
import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
import {
type AgentComponentContext,
type AgentComponentInteraction,
type AgentComponentMessageInteraction,
type ComponentInteractionContext,
type DiscordChannelContext,
import type {
AgentComponentContext,
AgentComponentInteraction,
AgentComponentMessageInteraction,
ComponentInteractionContext,
DiscordChannelContext,
} from "./agent-components.types.js";
import { normalizeDiscordDisplaySlug, normalizeDiscordSlug } from "./allow-list.js";
import { resolveDiscordChannelInfoSafe } from "./channel-access.js";

View File

@@ -455,7 +455,7 @@ export async function preflightDiscordMessage(
})
: null;
logDebug(
`[discord-preflight] guild_id=${params.data.guild_id} guild_obj=${!!params.data.guild} guild_obj_id=${params.data.guild?.id} guildInfo=${!!guildInfo} guildEntries=${params.guildEntries ? Object.keys(params.guildEntries).join(",") : "none"}`,
`[discord-preflight] guild_id=${params.data.guild_id} guild_obj=${Boolean(params.data.guild)} guild_obj_id=${params.data.guild?.id} guildInfo=${Boolean(guildInfo)} guildEntries=${params.guildEntries ? Object.keys(params.guildEntries).join(",") : "none"}`,
);
if (
isGuildMessage &&

View File

@@ -2,7 +2,7 @@ import { ChannelType } from "discord-api-types/v10";
import type { DiscordAccountConfig, OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { buildPluginBindingApprovalCustomId } from "openclaw/plugin-sdk/conversation-runtime";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { type DiscordComponentEntry, type DiscordModalEntry } from "../components.js";
import type { DiscordComponentEntry, DiscordModalEntry } from "../components.js";
import type {
ButtonInteraction,
ComponentData,

View File

@@ -1,7 +1,7 @@
import type { CommandArgs } from "openclaw/plugin-sdk/command-auth-native";
import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-dispatch-runtime";
import { resolveDiscordConversationIdentity } from "../conversation-identity.js";
import { type DiscordChannelConfigResolved, type DiscordGuildEntryResolved } from "./allow-list.js";
import type { DiscordChannelConfigResolved, DiscordGuildEntryResolved } from "./allow-list.js";
import { buildDiscordInboundAccessContext } from "./inbound-context.js";
type BuildDiscordNativeCommandContextParams = {

View File

@@ -1,8 +1,8 @@
import {
type ChatCommandDefinition,
type CommandArgDefinition,
type CommandArgValues,
type NativeCommandSpec,
import type {
ChatCommandDefinition,
CommandArgDefinition,
CommandArgValues,
NativeCommandSpec,
} from "openclaw/plugin-sdk/native-command-registry";
import type { CommandInteraction } from "../internal/discord.js";
import type { DiscordCommandArgs } from "./native-command.types.js";

View File

@@ -5,11 +5,7 @@ import type { NativeCommandSpec } from "openclaw/plugin-sdk/command-auth-native"
import type { DiscordAccountConfig, OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
import { isDiscordExecApprovalClientEnabled } from "../exec-approvals.js";
import {
type BaseCommand,
type BaseMessageInteractiveComponent,
type Modal,
} from "../internal/discord.js";
import type { BaseCommand, BaseMessageInteractiveComponent, Modal } from "../internal/discord.js";
import { createDiscordVoiceCommand } from "../voice/command.js";
import {
createAgentComponentControls,

View File

@@ -53,8 +53,7 @@ export function inspectDiscordSetupAccount(params: {
const enabled = params.cfg.channels?.discord?.enabled !== false && config.enabled !== false;
const accountConfig = resolveDiscordAccountConfig(params.cfg, accountId);
const hasAccountToken = Boolean(
accountConfig &&
Object.prototype.hasOwnProperty.call(accountConfig as Record<string, unknown>, "token"),
accountConfig && Object.hasOwn(accountConfig as Record<string, unknown>, "token"),
);
const accountToken = inspectDiscordConfiguredToken(accountConfig?.token);
if (accountToken) {

View File

@@ -5,7 +5,7 @@ import { rememberDiscordDirectoryUser } from "./directory-cache.js";
import { listDiscordDirectoryPeersLive } from "./directory-live.js";
import { allowFromContainsDiscordUserId } from "./normalize.js";
import { parseDiscordSendTarget } from "./send-target-parsing.js";
import { type DiscordTargetParseOptions } from "./target-parsing.js";
import type { DiscordTargetParseOptions } from "./target-parsing.js";
/**
* Resolve a Discord username to user ID using the directory lookup.

View File

@@ -65,8 +65,7 @@ export function resolveDiscordToken(
const discordCfg = selectedCfg?.channels?.discord;
const accountCfg = resolveAccountEntry(discordCfg?.accounts, accountId);
const hasAccountToken = Boolean(
accountCfg &&
Object.prototype.hasOwnProperty.call(accountCfg as Record<string, unknown>, "token"),
accountCfg && Object.hasOwn(accountCfg as Record<string, unknown>, "token"),
);
const accountToken = resolveDiscordTokenValue({
cfg: selectedCfg,

View File

@@ -62,7 +62,7 @@ function hasLegacyTalkFields(value: unknown): value is JsonRecord {
if (!talk) {
return false;
}
return LEGACY_TALK_FIELD_KEYS.some((key) => Object.prototype.hasOwnProperty.call(talk, key));
return LEGACY_TALK_FIELD_KEYS.some((key) => Object.hasOwn(talk, key));
}
function resolveTalkMigrationTargetProviderId(talk: JsonRecord): string | null {
@@ -117,7 +117,7 @@ export function migrateElevenLabsLegacyTalkConfig<T>(raw: T): { config: T; chang
const movedKeys: string[] = [];
for (const key of LEGACY_TALK_FIELD_KEYS) {
if (!Object.prototype.hasOwnProperty.call(nextTalk, key)) {
if (!Object.hasOwn(nextTalk, key)) {
continue;
}
legacyFields[key] = nextTalk[key];

View File

@@ -9,7 +9,7 @@ export function hasLegacyTalkFields(value: unknown): boolean {
return false;
}
return ["voiceId", "voiceAliases", "modelId", "outputFormat", "apiKey"].some((key) =>
Object.prototype.hasOwnProperty.call(talk, key),
Object.hasOwn(talk, key),
);
}

View File

@@ -32,9 +32,9 @@ const DEFAULT_ELEVENLABS_MODEL_ID = "eleven_multilingual_v2";
const DEFAULT_ELEVENLABS_VOICE_SETTINGS = {
stability: 0.5,
similarityBoost: 0.75,
style: 0.0,
style: 0,
useSpeakerBoost: true,
speed: 1.0,
speed: 1,
};
const ELEVENLABS_TTS_MODELS = [

View File

@@ -18,7 +18,7 @@ describe("elevenlabs tts diagnostics", () => {
similarityBoost: 0.75,
style: 0,
useSpeakerBoost: true,
speed: 1.0,
speed: 1,
},
timeoutMs: 5_000,
};

View File

@@ -1,4 +1,4 @@
import { type AuthProfileStore, type OpenClawConfig } from "openclaw/plugin-sdk/provider-auth";
import type { AuthProfileStore, OpenClawConfig } from "openclaw/plugin-sdk/provider-auth";
import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
import {
resolveProviderHttpRequestConfig,

View File

@@ -258,7 +258,7 @@ export const FeishuConfigSchema = z
const defaultAccount = value.defaultAccount?.trim();
if (defaultAccount && value.accounts && Object.keys(value.accounts).length > 0) {
const normalizedDefaultAccount = normalizeAccountId(defaultAccount);
if (!Object.prototype.hasOwnProperty.call(value.accounts, normalizedDefaultAccount)) {
if (!Object.hasOwn(value.accounts, normalizedDefaultAccount)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["defaultAccount"],

View File

@@ -129,7 +129,7 @@ function isPathWithinRoot(targetPath: string, rootPath: string): boolean {
const resolvedTarget = path.resolve(targetPath);
const resolvedRoot = path.resolve(rootPath);
const relative = path.relative(resolvedRoot, resolvedTarget);
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
return relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
}
function formatDisplayPath(filePath: string): string {
@@ -740,7 +740,7 @@ async function repairFeishuDoctorState(params: {
(store) => {
const removed: typeof group.entries = [];
for (const key of keys) {
if (Object.prototype.hasOwnProperty.call(store, key)) {
if (Object.hasOwn(store, key)) {
delete store[key];
const entry = group.entries.find((candidate) => candidate.key === key);
if (entry) {

View File

@@ -41,7 +41,7 @@ export function extractMentionTargets(
return false;
}
// Must have open_id
return !!m.id.open_id;
return Boolean(m.id.open_id);
})
.map((m) => ({
openId: m.id.open_id!,

View File

@@ -39,7 +39,7 @@ const FEISHU_WS_AUTORECONNECT_DISABLED_ERROR =
"WebSocket connect failed and autoReconnect is disabled";
function isFeishuWebhookPayload(value: unknown): value is Record<string, unknown> {
return !!value && typeof value === "object" && !Array.isArray(value);
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
}
function buildFeishuWebhookEnvelope(

View File

@@ -257,7 +257,7 @@ export function hasExplicitFeishuGroupConfig(params: {
if (!groupId) {
return false;
}
if (Object.prototype.hasOwnProperty.call(groups, groupId) && groupId !== "*") {
if (Object.hasOwn(groups, groupId) && groupId !== "*") {
return true;
}

View File

@@ -55,8 +55,8 @@ function isFeishuConfigured(cfg: OpenClawConfig): boolean {
if (!account || typeof account !== "object") {
return false;
}
const hasOwnAppId = Object.prototype.hasOwnProperty.call(account, "appId");
const hasOwnAppSecret = Object.prototype.hasOwnProperty.call(account, "appSecret");
const hasOwnAppId = Object.hasOwn(account, "appId");
const hasOwnAppSecret = Object.hasOwn(account, "appSecret");
const accountAppIdConfigured = hasOwnAppId
? isAppIdConfigured((account as Record<string, unknown>).appId)
: isAppIdConfigured(feishuCfg?.appId);

View File

@@ -342,7 +342,7 @@ export class FeishuStreamingSession {
sequence: 1,
currentText: "",
sentText: "",
hasNote: !!options?.note,
hasNote: Boolean(options?.note),
};
this.log?.(`Started streaming: cardId=${cardId}, messageId=${sendRes.data.message_id}`);
}

View File

@@ -367,7 +367,7 @@ export async function persistAllowAlways(input: {
);
// Use hasOwnProperty so a node with displayName "constructor" doesn't
// accidentally hit Object.prototype.constructor and pretend to match.
let key = candidates.find((c) => Object.prototype.hasOwnProperty.call(fileTransfer, c));
let key = candidates.find((c) => Object.hasOwn(fileTransfer, c));
if (!key) {
key = assertSafeConfigKey(input.nodeDisplayName ?? input.nodeId);
fileTransfer[key] = {};

View File

@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs/promises";
import path from "node:path";
import { type AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import type { AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
import { appendFileTransferAudit } from "../shared/audit.js";
import { IMAGE_MIME_INLINE_SET, mimeFromExtension } from "../shared/mime.js";

View File

@@ -1,4 +1,4 @@
import { type AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import type { AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import { appendFileTransferAudit } from "../shared/audit.js";
import { readClampedInt } from "../shared/params.js";
import {

View File

@@ -1,5 +1,5 @@
import crypto from "node:crypto";
import { type AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import type { AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
import { readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers";
import { wrapExternalContent } from "openclaw/plugin-sdk/security-runtime";

View File

@@ -1,5 +1,5 @@
import crypto from "node:crypto";
import { type AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import type { AnyAgentTool } from "openclaw/plugin-sdk/agent-harness-runtime";
import { readMediaBuffer } from "openclaw/plugin-sdk/media-store";
import { appendFileTransferAudit } from "../shared/audit.js";
import { humanSize, readBoolean } from "../shared/params.js";

View File

@@ -1,5 +1,5 @@
import { readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers";
import { type WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-contract";
import type { WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-contract";
import { buildFirecrawlWebSearchProviderBase } from "../web-search-shared.js";
type FirecrawlClientModule = typeof import("./firecrawl-client.js");

View File

@@ -1,4 +1,4 @@
import { type WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-contract";
import type { WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-contract";
import { buildFirecrawlWebSearchProviderBase } from "./web-search-shared.js";
export function createFirecrawlWebSearchProvider(): WebSearchProviderPlugin {

View File

@@ -221,7 +221,9 @@ describeLive("github-copilot connection-bound Responses IDs live", () => {
const input = Array.isArray(capturedPayload?.input) ? capturedPayload.input : [];
const replayedAssistant = input.find(
(item): item is Record<string, unknown> =>
!!item && typeof item === "object" && (item as Record<string, unknown>).type === "message",
Boolean(item) &&
typeof item === "object" &&
(item as Record<string, unknown>).type === "message",
);
expect(replayedAssistant?.id).toMatch(/^msg_[a-f0-9]{16}$/);

View File

@@ -26,7 +26,7 @@ function deriveReplacementId(type: string | undefined, originalId: string): stri
type InputItem = Record<string, unknown> & { id?: unknown; type?: unknown };
function isInputItem(value: unknown): value is InputItem {
return !!value && typeof value === "object";
return Boolean(value) && typeof value === "object";
}
function isValidReasoningReplayId(id: unknown): id is string {

View File

@@ -11,7 +11,7 @@ type LegacyConfigRule = {
};
function hasOwn(record: Record<string, unknown>, key: string): boolean {
return Object.prototype.hasOwnProperty.call(record, key);
return Object.hasOwn(record, key);
}
function hasLegacyGoogleRealtimeProvider(value: unknown): boolean {

View File

@@ -16,9 +16,7 @@ function hasLegacyGoogleChatGroupAllowAlias(value: unknown): boolean {
if (!groups) {
return false;
}
return Object.values(groups).some((group) =>
Object.prototype.hasOwnProperty.call(asObjectRecord(group) ?? {}, "allow"),
);
return Object.values(groups).some((group) => Object.hasOwn(asObjectRecord(group) ?? {}, "allow"));
}
function hasLegacyAccountAliases(value: unknown, match: (entry: unknown) => boolean): boolean {
@@ -38,7 +36,7 @@ function normalizeGoogleChatGroups(params: {
const nextGroups = { ...params.groups };
for (const [groupId, groupValue] of Object.entries(params.groups)) {
const group = asObjectRecord(groupValue);
if (!group || !Object.prototype.hasOwnProperty.call(group, "allow")) {
if (!group || !Object.hasOwn(group, "allow")) {
continue;
}
const nextGroup = { ...group };

View File

@@ -9,9 +9,9 @@ import {
resolveInboundRouteEnvelopeBuilderWithRuntime,
resolveWebhookPath,
} from "../runtime-api.js";
import { type ResolvedGoogleChatAccount } from "./accounts.js";
import type { ResolvedGoogleChatAccount } from "./accounts.js";
import { downloadGoogleChatMedia, sendGoogleChatMessage } from "./api.js";
import { type GoogleChatAudienceType } from "./auth.js";
import type { GoogleChatAudienceType } from "./auth.js";
import { applyGoogleChatInboundAccessPolicy } from "./monitor-access.js";
import { resolveGoogleChatDurableReplyOptions } from "./monitor-durable.js";
import { deliverGoogleChatReply } from "./monitor-reply-delivery.js";

View File

@@ -47,7 +47,7 @@ export const HUGGINGFACE_MODEL_CATALOG: ModelDefinitionConfig[] = [
input: ["text"],
contextWindow: 131072,
maxTokens: 8192,
cost: { input: 3.0, output: 7.0, cacheRead: 3.0, cacheWrite: 3.0 },
cost: { input: 3, output: 7, cacheRead: 3, cacheWrite: 3 },
},
{
id: "deepseek-ai/DeepSeek-V3.1",

View File

@@ -8,9 +8,9 @@ import {
import { buildChannelApprovalNativeTargetKey } from "openclaw/plugin-sdk/approval-native-runtime";
import { buildApprovalReactionPendingContent } from "openclaw/plugin-sdk/approval-reaction-runtime";
import type { ExecApprovalReplyDecision } from "openclaw/plugin-sdk/approval-reply-runtime";
import {
type ExecApprovalRequest,
type PluginApprovalRequest,
import type {
ExecApprovalRequest,
PluginApprovalRequest,
} from "openclaw/plugin-sdk/approval-runtime";
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
import {

View File

@@ -1,5 +1,5 @@
import { type ResolvedIMessageAccount } from "./accounts.js";
import { type ChannelPlugin } from "./channel-api.js";
import type { ResolvedIMessageAccount } from "./accounts.js";
import type { ChannelPlugin } from "./channel-api.js";
import { imessageSetupAdapter } from "./setup-core.js";
import { createIMessagePluginBase, imessageSetupWizard } from "./shared.js";

View File

@@ -1,4 +1,4 @@
import { type ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
import {
discoverKilocodeModels,
KILOCODE_BASE_URL as LOCAL_KILOCODE_BASE_URL,

View File

@@ -196,8 +196,8 @@ describe("discoverKilocodeModels (fetch path)", () => {
expect(models.length).toBe(2);
const sonnet = requireModelById(models, "anthropic/claude-sonnet-4");
expect(sonnet.cost.input).toBeCloseTo(3.0);
expect(sonnet.cost.output).toBeCloseTo(15.0);
expect(sonnet.cost.input).toBeCloseTo(3);
expect(sonnet.cost.output).toBeCloseTo(15);
expect(sonnet.cost.cacheRead).toBeCloseTo(0.3);
expect(sonnet.cost.cacheWrite).toBeCloseTo(3.75);
expect(sonnet.input).toEqual(["text", "image"]);
@@ -329,7 +329,7 @@ describe("discoverKilocodeModels (fetch path)", () => {
const models = await discoverKilocodeModels();
const auto = requireModelById(models, "kilo/auto");
expect(auto.name).toBe("Kilo: Auto");
expect(auto.cost.input).toBeCloseTo(5.0);
expect(auto.cost.input).toBeCloseTo(5);
expect(requireModelById(models, "anthropic/claude-sonnet-4").id).toBe(
"anthropic/claude-sonnet-4",
);

View File

@@ -1,6 +1,6 @@
import { describeWebhookAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
import { hasLineCredentials } from "./account-helpers.js";
import { type ChannelPlugin, type ResolvedLineAccount } from "./channel-api.js";
import type { ChannelPlugin, ResolvedLineAccount } from "./channel-api.js";
import { lineConfigAdapter } from "./config-adapter.js";
import { LineChannelConfigSchema } from "./config-schema.js";

View File

@@ -1,4 +1,4 @@
import { type ChannelPlugin, type ResolvedLineAccount } from "./channel-api.js";
import type { ChannelPlugin, ResolvedLineAccount } from "./channel-api.js";
import { lineChannelPluginCommon } from "./channel-shared.js";
import { lineSetupAdapter } from "./setup-core.js";
import { lineSetupWizard } from "./setup-surface.js";

View File

@@ -5,7 +5,7 @@ import { createEmptyChannelDirectoryAdapter } from "openclaw/plugin-sdk/director
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
import { resolveLineAccount } from "./accounts.js";
import { lineBindingsAdapter } from "./bindings.js";
import { type ChannelPlugin, type ResolvedLineAccount } from "./channel-api.js";
import type { ChannelPlugin, ResolvedLineAccount } from "./channel-api.js";
import { lineChannelPluginCommon } from "./channel-shared.js";
import { lineGatewayAdapter } from "./gateway.js";
import { resolveLineGroupRequireMention } from "./group-policy.js";

View File

@@ -9,7 +9,7 @@ import {
} from "openclaw/plugin-sdk/channel-send-result";
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
import { resolveOutboundMediaUrls } from "openclaw/plugin-sdk/reply-payload";
import { type ChannelPlugin, type ResolvedLineAccount } from "./channel-api.js";
import type { ChannelPlugin, ResolvedLineAccount } from "./channel-api.js";
import { resolveLineOutboundMedia, type LineOutboundMediaResolved } from "./outbound-media.js";
import { buildLineQuickReplyFallbackText } from "./quick-reply-fallback.js";
import { getLineRuntime } from "./runtime.js";

View File

@@ -147,7 +147,7 @@ function supportsThinkingPolicyLevel(
policy: ThinkingPolicy,
level: ReturnType<OpenClawPluginApi["runtime"]["agent"]["normalizeThinkingLevel"]>,
): boolean {
return !!level && policy.levels.some((entry) => entry.id === level);
return Boolean(level) && policy.levels.some((entry) => entry.id === level);
}
export function createLlmTaskTool(api: OpenClawPluginApi) {

View File

@@ -1,4 +1,4 @@
import { type ChannelDoctorAdapter } from "openclaw/plugin-sdk/channel-contract";
import type { ChannelDoctorAdapter } from "openclaw/plugin-sdk/channel-contract";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import {
detectPluginInstallPathIssue,

View File

@@ -5,11 +5,7 @@ import {
} from "../reaction-common.js";
import { withResolvedRoomAction } from "./client.js";
import { resolveMatrixActionLimit } from "./limits.js";
import {
type MatrixActionClientOpts,
type MatrixRawEvent,
type MatrixReactionSummary,
} from "./types.js";
import type { MatrixActionClientOpts, MatrixRawEvent, MatrixReactionSummary } from "./types.js";
type ActionClient = NonNullable<MatrixActionClientOpts["client"]>;

View File

@@ -23,7 +23,7 @@ import {
createMatrixRoomMessageEvent,
createMatrixTextMessageEvent,
} from "./handler.test-helpers.js";
import { type MatrixRawEvent } from "./types.js";
import type { MatrixRawEvent } from "./types.js";
const deliverMatrixRepliesMock = vi.hoisted(() => vi.fn(async () => true));

View File

@@ -198,28 +198,20 @@ vi.mock("../../runtime-api.js", () => {
wildcardKey: string;
}) => {
for (const key of keys) {
if (Object.prototype.hasOwnProperty.call(entries, key)) {
if (Object.hasOwn(entries, key)) {
return {
entry: entries[key],
key,
wildcardEntry: Object.prototype.hasOwnProperty.call(entries, wildcardKey)
? entries[wildcardKey]
: undefined,
wildcardKey: Object.prototype.hasOwnProperty.call(entries, wildcardKey)
? wildcardKey
: undefined,
wildcardEntry: Object.hasOwn(entries, wildcardKey) ? entries[wildcardKey] : undefined,
wildcardKey: Object.hasOwn(entries, wildcardKey) ? wildcardKey : undefined,
};
}
}
return {
entry: undefined,
key: undefined,
wildcardEntry: Object.prototype.hasOwnProperty.call(entries, wildcardKey)
? entries[wildcardKey]
: undefined,
wildcardKey: Object.prototype.hasOwnProperty.call(entries, wildcardKey)
? wildcardKey
: undefined,
wildcardEntry: Object.hasOwn(entries, wildcardKey) ? entries[wildcardKey] : undefined,
wildcardKey: Object.hasOwn(entries, wildcardKey) ? wildcardKey : undefined,
};
},
resolveDefaultGroupPolicy: () => "allowlist",

View File

@@ -8,12 +8,12 @@ import type {
TimedFileInfo,
VideoFileInfo,
} from "../sdk.js";
import {
type MatrixMediaContent,
type MatrixMediaInfo,
type MatrixMediaMsgType,
type MatrixRelation,
type MediaKind,
import type {
MatrixMediaContent,
MatrixMediaInfo,
MatrixMediaMsgType,
MatrixRelation,
MediaKind,
} from "./types.js";
const getCore = () => getMatrixRuntime();

View File

@@ -23,10 +23,10 @@ function normalizeLowercaseStringOrEmpty(value) {
function hasTrustedOpenClawRootIndicator(packageRoot, packageJson) {
const packageExports = packageJson?.exports ?? {};
if (!Object.prototype.hasOwnProperty.call(packageExports, "./plugin-sdk")) {
if (!Object.hasOwn(packageExports, "./plugin-sdk")) {
return false;
}
const hasCliEntryExport = Object.prototype.hasOwnProperty.call(packageExports, "./cli-entry");
const hasCliEntryExport = Object.hasOwn(packageExports, "./cli-entry");
const hasOpenClawBin =
(typeof packageJson?.bin === "string" &&
normalizeLowercaseStringOrEmpty(packageJson.bin).includes("openclaw")) ||

View File

@@ -7,7 +7,7 @@ import {
resolveMattermostGatewayAuthBypassPaths,
} from "./channel-config-shared.js";
import { MattermostChannelConfigSchema } from "./config-surface.js";
import { type ResolvedMattermostAccount } from "./mattermost/accounts.js";
import type { ResolvedMattermostAccount } from "./mattermost/accounts.js";
import { mattermostSetupAdapter } from "./setup-core.js";
import { mattermostSetupWizard } from "./setup-surface.js";

View File

@@ -1,4 +1,4 @@
import { type IncomingMessage, type ServerResponse } from "node:http";
import type { IncomingMessage, ServerResponse } from "node:http";
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
import type { PluginRuntime } from "../../runtime-api.js";
import { setMattermostRuntime } from "../runtime.js";

View File

@@ -51,7 +51,7 @@ describe("memory hybrid helpers", () => {
endLine: 4,
source: "memory",
snippet: "kw-b",
textScore: 1.0,
textScore: 1,
},
],
});
@@ -62,9 +62,9 @@ describe("memory hybrid helpers", () => {
expect(a?.score).toBeCloseTo(0.7 * 0.9);
expect(a?.vectorScore).toBeCloseTo(0.9);
expect(a?.textScore).toBe(0);
expect(b?.score).toBeCloseTo(0.3 * 1.0);
expect(b?.score).toBeCloseTo(0.3 * 1);
expect(b?.vectorScore).toBe(0);
expect(b?.textScore).toBeCloseTo(1.0);
expect(b?.textScore).toBeCloseTo(1);
});
it("mergeHybridResults prefers keyword snippet when ids overlap", async () => {
@@ -90,15 +90,15 @@ describe("memory hybrid helpers", () => {
endLine: 2,
source: "memory",
snippet: "kw-a",
textScore: 1.0,
textScore: 1,
},
],
});
expect(merged).toHaveLength(1);
expect(merged[0]?.snippet).toBe("kw-a");
expect(merged[0]?.score).toBeCloseTo(0.5 * 0.2 + 0.5 * 1.0);
expect(merged[0]?.score).toBeCloseTo(0.5 * 0.2 + 0.5 * 1);
expect(merged[0]?.vectorScore).toBeCloseTo(0.2);
expect(merged[0]?.textScore).toBeCloseTo(1.0);
expect(merged[0]?.textScore).toBeCloseTo(1);
});
});

View File

@@ -1,4 +1,4 @@
import { type MemorySourceFileStateRow } from "./manager-source-state.js";
import type { MemorySourceFileStateRow } from "./manager-source-state.js";
export type MemorySessionStartupFileState = {
absPath: string;

View File

@@ -1,5 +1,5 @@
import type { DatabaseSync } from "node:sqlite";
import { type FSWatcher } from "chokidar";
import type { FSWatcher } from "chokidar";
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
import {
createSubsystemLogger,

View File

@@ -195,7 +195,7 @@ describe("computeMMRScore", () => {
expected: -0.5,
},
{ name: "lambda=0.5 mixed", relevance: 0.8, similarity: 0.6, lambda: 0.5, expected: 0.1 },
{ name: "default lambda math", relevance: 1.0, similarity: 0.5, lambda: 0.7, expected: 0.55 },
{ name: "default lambda math", relevance: 1, similarity: 0.5, lambda: 0.7, expected: 0.55 },
] as const;
for (const testCase of cases) {
@@ -239,7 +239,7 @@ describe("mmrRerank", () => {
describe("lambda edge cases", () => {
const diverseItems: MMRItem[] = [
{ id: "1", score: 1.0, content: "apple banana cherry" },
{ id: "1", score: 1, content: "apple banana cherry" },
{ id: "2", score: 0.9, content: "apple banana date" },
{ id: "3", score: 0.8, content: "elderberry fig grape" },
];
@@ -272,7 +272,7 @@ describe("mmrRerank", () => {
describe("diversity behavior", () => {
it("promotes diverse results over similar high-scoring ones", () => {
const items: MMRItem[] = [
{ id: "1", score: 1.0, content: "machine learning neural networks" },
{ id: "1", score: 1, content: "machine learning neural networks" },
{ id: "2", score: 0.95, content: "machine learning deep learning" },
{ id: "3", score: 0.9, content: "database systems sql queries" },
{ id: "4", score: 0.85, content: "machine learning algorithms" },
@@ -288,7 +288,7 @@ describe("mmrRerank", () => {
it("handles items with identical content", () => {
const items: MMRItem[] = [
{ id: "1", score: 1.0, content: "identical content" },
{ id: "1", score: 1, content: "identical content" },
{ id: "2", score: 0.9, content: "identical content" },
{ id: "3", score: 0.8, content: "different stuff" },
];
@@ -301,7 +301,7 @@ describe("mmrRerank", () => {
it("handles all identical content gracefully", () => {
const items: MMRItem[] = [
{ id: "1", score: 1.0, content: "same" },
{ id: "1", score: 1, content: "same" },
{ id: "2", score: 0.9, content: "same" },
{ id: "3", score: 0.8, content: "same" },
];
@@ -315,7 +315,7 @@ describe("mmrRerank", () => {
describe("tie-breaking", () => {
it("uses original score as tiebreaker", () => {
const items: MMRItem[] = [
{ id: "1", score: 1.0, content: "unique content one" },
{ id: "1", score: 1, content: "unique content one" },
{ id: "2", score: 0.9, content: "unique content two" },
{ id: "3", score: 0.8, content: "unique content three" },
];
@@ -352,7 +352,7 @@ describe("mmrRerank", () => {
it("handles negative scores", () => {
const items: MMRItem[] = [
{ id: "1", score: -0.5, content: "hello world" },
{ id: "2", score: -1.0, content: "foo bar" },
{ id: "2", score: -1, content: "foo bar" },
];
const result = mmrRerank(items, { lambda: 0.7 });
@@ -420,7 +420,7 @@ describe("applyMMRToHybridResults", () => {
path: "/a.ts",
startLine: 1,
endLine: 10,
score: 1.0,
score: 1,
snippet: "function add numbers together",
source: "memory",
},

View File

@@ -1024,7 +1024,7 @@ export default definePluginEntry({
return -1 * direction;
}
if (a[col] > b[col]) {
return 1 * direction;
return Number(direction);
}
return 0;
});

View File

@@ -13,7 +13,7 @@ function asRecord(value: unknown): Record<string, unknown> | null {
}
function hasLegacyBridgeArtifactToggle(value: unknown): boolean {
return Object.prototype.hasOwnProperty.call(asRecord(value) ?? {}, "readMemoryCore");
return Object.hasOwn(asRecord(value) ?? {}, "readMemoryCore");
}
export const legacyConfigRules: LegacyConfigRule[] = [
@@ -49,7 +49,7 @@ export function migrateMemoryWikiLegacyConfig(config: OpenClawConfig): {
nextPluginConfig.bridge = nextBridge;
const legacyValue = nextBridge.readMemoryCore;
const hasCanonical = Object.prototype.hasOwnProperty.call(nextBridge, "readMemoryArtifacts");
const hasCanonical = Object.hasOwn(nextBridge, "readMemoryArtifacts");
if (!hasCanonical) {
nextBridge.readMemoryArtifacts = legacyValue;
}

View File

@@ -168,7 +168,7 @@ describe("buildMinimaxSpeechProvider", () => {
model: "speech-01-240228",
voiceId: "Chinese (Mandarin)_Warm_Girl",
speed: 1.5,
vol: 2.0,
vol: 2,
pitch: 3,
},
},
@@ -180,7 +180,7 @@ describe("buildMinimaxSpeechProvider", () => {
expect(config.model).toBe("speech-01-240228");
expect(config.voiceId).toBe("Chinese (Mandarin)_Warm_Girl");
expect(config.speed).toBe(1.5);
expect(config.vol).toBe(2.0);
expect(config.vol).toBe(2);
expect(config.pitch).toBe(3);
});

View File

@@ -58,8 +58,8 @@ export async function minimaxTTS(params: {
baseUrl,
model,
voiceId,
speed = 1.0,
vol = 1.0,
speed = 1,
vol = 1,
pitch = 0,
format = "mp3",
sampleRate = 32000,

View File

@@ -472,9 +472,7 @@ export type MSTeamsAttachmentResolveFn = (hostname: string) => Promise<{ address
function isMockFetchFn(fetchFn: typeof fetch): boolean {
const candidate = fetchFn as unknown as { mock?: unknown };
return Boolean(
candidate.mock || Object.prototype.hasOwnProperty.call(candidate, "_isMockFunction"),
);
return Boolean(candidate.mock || Object.hasOwn(candidate, "_isMockFunction"));
}
function resolveGuardedFetchImpl(params: {

View File

@@ -84,7 +84,7 @@ export async function listChannelsMSTeams(
description: ch.description,
membershipType: ch.membershipType,
}));
return { channels, truncated: !!nextPath };
return { channels, truncated: Boolean(nextPath) };
}
// ---------------------------------------------------------------------------

View File

@@ -4,7 +4,7 @@ import path from "node:path";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig, PluginRuntime, RuntimeEnv } from "../runtime-api.js";
import { runMSTeamsFeedbackInvokeHandler } from "./feedback-invoke.js";
import { type MSTeamsMessageHandlerDeps } from "./monitor-handler.js";
import type { MSTeamsMessageHandlerDeps } from "./monitor-handler.js";
import { createMSTeamsMessageHandlerDeps } from "./monitor-handler.test-helpers.js";
import { setMSTeamsRuntime } from "./runtime.js";
import type { MSTeamsTurnContext } from "./sdk-types.js";

View File

@@ -1,4 +1,4 @@
import { type OpenClawConfig, type RuntimeEnv } from "../runtime-api.js";
import type { OpenClawConfig, RuntimeEnv } from "../runtime-api.js";
import type { MSTeamsConversationStore } from "./conversation-store.js";
import type { MSTeamsMonitorLogger } from "./monitor-types.js";
import type { MSTeamsPollStore } from "./polls.js";

View File

@@ -1,4 +1,4 @@
import { type AddressInfo } from "node:net";
import type { AddressInfo } from "node:net";
import { afterEach } from "vitest";
import { createNextcloudTalkWebhookServer } from "./monitor.js";
import type { NextcloudTalkWebhookServerOptions } from "./types.js";

View File

@@ -6,7 +6,7 @@ import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pair
import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { runStoppablePassiveMonitor } from "openclaw/plugin-sdk/extension-shared";
import { type ChannelOutboundAdapter, type ChannelPlugin } from "./channel-api.js";
import type { ChannelOutboundAdapter, ChannelPlugin } from "./channel-api.js";
import type { MetricEvent, MetricsSnapshot } from "./metrics.js";
import { startNostrBus, type NostrBusHandle } from "./nostr-bus.js";
import { normalizePubkey } from "./nostr-key-utils.js";

View File

@@ -113,7 +113,7 @@ function isOpenAIOrLegacyCodexProvider(provider: string | undefined): boolean {
function isLegacyCodexCompatBaseUrl(baseUrl?: string): boolean {
const trimmed = baseUrl?.trim();
return !!trimmed && /^https?:\/\/api\.githubcopilot\.com(?:\/v1)?\/?$/iu.test(trimmed);
return Boolean(trimmed) && /^https?:\/\/api\.githubcopilot\.com(?:\/v1)?\/?$/iu.test(trimmed);
}
function normalizeCodexTransportFields(params: {

View File

@@ -1,6 +1,6 @@
import {
type ProviderResolveDynamicModelContext,
type ProviderRuntimeModel,
import type {
ProviderResolveDynamicModelContext,
ProviderRuntimeModel,
} from "openclaw/plugin-sdk/plugin-entry";
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
import {

View File

@@ -1,6 +1,6 @@
import {
type UnifiedModelCatalogEntry,
type UnifiedModelCatalogProviderContext,
import type {
UnifiedModelCatalogEntry,
UnifiedModelCatalogProviderContext,
} from "openclaw/plugin-sdk/plugin-entry";
import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
import { getCachedLiveCatalogValue } from "openclaw/plugin-sdk/provider-catalog-shared";

Some files were not shown because too many files have changed in this diff Show More