From 6efb44944c1b92e78672b7a88075a078b52ffd09 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 1 May 2026 09:24:37 +0100 Subject: [PATCH] refactor: prune unused extension helpers --- extensions/bluebubbles/src/accounts.ts | 6 --- extensions/bluebubbles/src/probe.ts | 5 --- extensions/bluebubbles/src/runtime.ts | 4 -- extensions/bluebubbles/src/types.ts | 13 ------- extensions/discord/src/approval-native.ts | 16 -------- .../src/engine/messaging/media-type-detect.ts | 37 +------------------ extensions/tlon/src/monitor/utils.ts | 9 ----- 7 files changed, 2 insertions(+), 88 deletions(-) diff --git a/extensions/bluebubbles/src/accounts.ts b/extensions/bluebubbles/src/accounts.ts index 2ce35a8a06a..85ef4d61aa7 100644 --- a/extensions/bluebubbles/src/accounts.ts +++ b/extensions/bluebubbles/src/accounts.ts @@ -92,9 +92,3 @@ export function resolveBlueBubblesEffectiveAllowPrivateNetwork(params: { }): boolean { return resolveBlueBubblesEffectiveAllowPrivateNetworkFromConfig(params); } - -export function listEnabledBlueBubblesAccounts(cfg: OpenClawConfig): ResolvedBlueBubblesAccount[] { - return listBlueBubblesAccountIds(cfg) - .map((accountId) => resolveBlueBubblesAccount({ cfg, accountId })) - .filter((account) => account.enabled); -} diff --git a/extensions/bluebubbles/src/probe.ts b/extensions/bluebubbles/src/probe.ts index 638c3ae59d3..b8b13d545e1 100644 --- a/extensions/bluebubbles/src/probe.ts +++ b/extensions/bluebubbles/src/probe.ts @@ -133,11 +133,6 @@ export function isMacOS26OrHigher(accountId?: string): boolean { return major !== null && major >= 26; } -/** Clear the server info cache (for testing) */ -export function clearServerInfoCache(): void { - serverInfoCache.clear(); -} - export async function probeBlueBubbles(params: { baseUrl?: string | null; password?: string | null; diff --git a/extensions/bluebubbles/src/runtime.ts b/extensions/bluebubbles/src/runtime.ts index 88eb3038b5a..f8b1098ec1a 100644 --- a/extensions/bluebubbles/src/runtime.ts +++ b/extensions/bluebubbles/src/runtime.ts @@ -12,10 +12,6 @@ export function clearBlueBubblesRuntime(): void { runtimeStore.clearRuntime(); } -export function tryGetBlueBubblesRuntime(): PluginRuntime | null { - return runtimeStore.tryGetRuntime(); -} - export function getBlueBubblesRuntime(): PluginRuntime { return runtimeStore.getRuntime(); } diff --git a/extensions/bluebubbles/src/types.ts b/extensions/bluebubbles/src/types.ts index e8266963ce2..e3922c4877c 100644 --- a/extensions/bluebubbles/src/types.ts +++ b/extensions/bluebubbles/src/types.ts @@ -173,19 +173,6 @@ export function normalizeBlueBubblesServerUrl(raw: string): string { return withScheme.replace(/\/+$/, ""); } -export function buildBlueBubblesApiUrl(params: { - baseUrl: string; - path: string; - password?: string; -}): string { - const normalized = normalizeBlueBubblesServerUrl(params.baseUrl); - const url = new URL(params.path, `${normalized}/`); - if (params.password) { - url.searchParams.set("password", params.password); - } - return url.toString(); -} - // Overridable guard for testing; production code uses fetchWithSsrFGuard. let _fetchGuard = fetchWithSsrFGuard; diff --git a/extensions/discord/src/approval-native.ts b/extensions/discord/src/approval-native.ts index 75a22b75d90..8da99704446 100644 --- a/extensions/discord/src/approval-native.ts +++ b/extensions/discord/src/approval-native.ts @@ -32,14 +32,6 @@ export function extractDiscordChannelId(sessionKey?: string | null): string | nu return match ? match[1] : null; } -export function extractDiscordThreadId(sessionKey?: string | null): string | null { - if (!sessionKey) { - return null; - } - const match = sessionKey.match(/discord:(?:channel|group):\d+:thread:(\d+)/); - return match ? match[1] : null; -} - function extractDiscordSessionKind(sessionKey?: string | null): "channel" | "group" | "dm" | null { if (!sessionKey) { return null; @@ -220,16 +212,8 @@ export function createDiscordNativeApprovalAdapter( } let cachedDiscordApprovalCapability: ReturnType | undefined; -let cachedDiscordNativeApprovalAdapter: - | ReturnType - | undefined; export function getDiscordApprovalCapability() { cachedDiscordApprovalCapability ??= createDiscordApprovalCapability(); return cachedDiscordApprovalCapability; } - -export function getDiscordNativeApprovalAdapter() { - cachedDiscordNativeApprovalAdapter ??= createDiscordNativeApprovalAdapter(); - return cachedDiscordNativeApprovalAdapter; -} diff --git a/extensions/qqbot/src/engine/messaging/media-type-detect.ts b/extensions/qqbot/src/engine/messaging/media-type-detect.ts index f3365b795af..469d03703c6 100644 --- a/extensions/qqbot/src/engine/messaging/media-type-detect.ts +++ b/extensions/qqbot/src/engine/messaging/media-type-detect.ts @@ -1,30 +1,12 @@ /** * Media type detection — pure functions for classifying files by MIME or extension. * - * These replace the inline `isImageFile`, `isVideoFile`, `isAudioFile` helpers - * scattered across `outbound.ts`. Centralizing them here ensures consistent - * detection across both the built-in and standalone versions. + * These replace the inline `isImageFile` and `isVideoFile` helpers scattered + * across `outbound.ts`. Centralizing them here keeps detection consistent. */ -/** Supported media kind for QQ Bot outbound routing. */ -export type MediaKind = "image" | "voice" | "video" | "file"; - const IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp"]); const VIDEO_EXTENSIONS = new Set([".mp4", ".mov", ".avi", ".mkv", ".webm", ".flv", ".wmv"]); -const AUDIO_EXTENSIONS = new Set([ - ".mp3", - ".wav", - ".ogg", - ".flac", - ".aac", - ".m4a", - ".wma", - ".opus", - ".amr", - ".silk", - ".slk", - ".pcm", -]); /** * Extract a lowercase file extension from a path or URL, ignoring query and hash. @@ -53,18 +35,3 @@ export function isVideoFile(filePath: string, mimeType?: string): boolean { } return VIDEO_EXTENSIONS.has(getCleanExtension(filePath)); } - -/** Check whether a file is audio using MIME first and extension as fallback. */ -export function isAudioFile(filePath: string, mimeType?: string): boolean { - if (mimeType) { - if ( - mimeType.startsWith("audio/") || - mimeType === "voice" || - mimeType.includes("silk") || - mimeType.includes("amr") - ) { - return true; - } - } - return AUDIO_EXTENSIONS.has(getCleanExtension(filePath)); -} diff --git a/extensions/tlon/src/monitor/utils.ts b/extensions/tlon/src/monitor/utils.ts index c84aa096ad9..cd99e709b17 100644 --- a/extensions/tlon/src/monitor/utils.ts +++ b/extensions/tlon/src/monitor/utils.ts @@ -385,12 +385,3 @@ export function isSummarizationRequest(messageText: string): boolean { ]; return patterns.some((pattern) => pattern.test(messageText)); } - -export function formatChangesDate(daysAgo = 5): string { - const now = new Date(); - const targetDate = new Date(now.getTime() - daysAgo * 24 * 60 * 60 * 1000); - const year = targetDate.getFullYear(); - const month = targetDate.getMonth() + 1; - const day = targetDate.getDate(); - return `~${year}.${month}.${day}..20.19.51..9b9d`; -}