From 7cebe7a506fc0fd059a79ab62df102a877f86751 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 17 Jan 2026 07:59:53 +0000 Subject: [PATCH] style: run oxfmt --- src/agents/bash-tools.process.ts | 9 +--- src/agents/pty-keys.test.ts | 7 ++- src/agents/tools/sessions-list-tool.ts | 6 +-- src/auto-reply/reply/get-reply-run.ts | 4 +- src/auto-reply/reply/queue/enqueue.ts | 5 +- src/auto-reply/reply/session.ts | 6 +-- src/channels/command-gating.test.ts | 1 - src/channels/command-gating.ts | 1 - src/channels/plugins/discord.ts | 5 +- src/channels/plugins/signal.ts | 5 +- src/channels/plugins/telegram.ts | 5 +- src/channels/plugins/whatsapp.ts | 5 +- src/channels/registry.ts | 4 +- src/commands/agent/delivery.ts | 4 +- src/commands/message-format.ts | 5 +- src/config/zod-schema.core.ts | 6 +-- src/config/zod-schema.session.ts | 6 +-- .../monitor/message-handler.preflight.ts | 52 +++++++++---------- ...erver.agent.gateway-server-agent-b.test.ts | 24 ++++----- src/hooks/hooks-install.e2e.test.ts | 5 +- src/hooks/install.test.ts | 10 ++-- src/hooks/install.ts | 8 ++- src/hooks/loader.ts | 8 +-- src/hooks/workspace.ts | 6 ++- src/infra/archive.ts | 5 +- src/infra/outbound/agent-delivery.ts | 6 ++- src/media-understanding/apply.test.ts | 4 +- src/media-understanding/apply.ts | 5 +- src/media-understanding/resolve.test.ts | 5 +- src/media-understanding/runner.ts | 9 +++- src/security/audit.ts | 24 +++++---- src/telegram/bot-native-commands.ts | 4 +- src/utils/delivery-context.ts | 6 +-- src/web/auto-reply/monitor/process-message.ts | 10 +++- 34 files changed, 127 insertions(+), 148 deletions(-) diff --git a/src/agents/bash-tools.process.ts b/src/agents/bash-tools.process.ts index 6322fd202..1463df086 100644 --- a/src/agents/bash-tools.process.ts +++ b/src/agents/bash-tools.process.ts @@ -33,9 +33,7 @@ const processSchema = Type.Object({ keys: Type.Optional( Type.Array(Type.String(), { description: "Key tokens to send for send-keys" }), ), - hex: Type.Optional( - Type.Array(Type.String(), { description: "Hex bytes to send for send-keys" }), - ), + hex: Type.Optional(Type.Array(Type.String(), { description: "Hex bytes to send for send-keys" })), literal: Type.Optional(Type.String({ description: "Literal string for send-keys" })), text: Type.Optional(Type.String({ description: "Text to paste for paste" })), bracketed: Type.Optional(Type.Boolean({ description: "Wrap paste in bracketed mode" })), @@ -121,10 +119,7 @@ export function createProcessTool( .sort((a, b) => b.startedAt - a.startedAt) .map((s) => { const label = s.name ? truncateMiddle(s.name, 80) : truncateMiddle(s.command, 120); - return `${s.sessionId} ${pad( - s.status, - 9, - )} ${formatDuration(s.runtimeMs)} :: ${label}`; + return `${s.sessionId} ${pad(s.status, 9)} ${formatDuration(s.runtimeMs)} :: ${label}`; }); return { content: [ diff --git a/src/agents/pty-keys.test.ts b/src/agents/pty-keys.test.ts index b0a9350c4..f7464e5ca 100644 --- a/src/agents/pty-keys.test.ts +++ b/src/agents/pty-keys.test.ts @@ -1,6 +1,11 @@ import { expect, test } from "vitest"; -import { BRACKETED_PASTE_END, BRACKETED_PASTE_START, encodeKeySequence, encodePaste } from "./pty-keys.js"; +import { + BRACKETED_PASTE_END, + BRACKETED_PASTE_START, + encodeKeySequence, + encodePaste, +} from "./pty-keys.js"; test("encodeKeySequence maps common keys and modifiers", () => { const enter = encodeKeySequence({ keys: ["Enter"] }); diff --git a/src/agents/tools/sessions-list-tool.ts b/src/agents/tools/sessions-list-tool.ts index b00c65fdf..47566eefb 100644 --- a/src/agents/tools/sessions-list-tool.ts +++ b/src/agents/tools/sessions-list-tool.ts @@ -150,12 +150,12 @@ export function createSessionsListTool(opts?: { : undefined; const deliveryChannel = typeof deliveryContext?.channel === "string" ? deliveryContext.channel : undefined; - const deliveryTo = - typeof deliveryContext?.to === "string" ? deliveryContext.to : undefined; + const deliveryTo = typeof deliveryContext?.to === "string" ? deliveryContext.to : undefined; const deliveryAccountId = typeof deliveryContext?.accountId === "string" ? deliveryContext.accountId : undefined; const lastChannel = - deliveryChannel ?? (typeof entry.lastChannel === "string" ? entry.lastChannel : undefined); + deliveryChannel ?? + (typeof entry.lastChannel === "string" ? entry.lastChannel : undefined); const lastAccountId = deliveryAccountId ?? (typeof entry.lastAccountId === "string" ? entry.lastAccountId : undefined); diff --git a/src/auto-reply/reply/get-reply-run.ts b/src/auto-reply/reply/get-reply-run.ts index c6e5d1091..b554107af 100644 --- a/src/auto-reply/reply/get-reply-run.ts +++ b/src/auto-reply/reply/get-reply-run.ts @@ -297,9 +297,7 @@ export async function runPreparedReply( abortKey: command.abortKey, messageId: sessionCtx.MessageSid, }); - const isGroupSession = - sessionEntry?.chatType === "group" || - sessionEntry?.chatType === "channel"; + const isGroupSession = sessionEntry?.chatType === "group" || sessionEntry?.chatType === "channel"; const isMainSession = !isGroupSession && sessionKey === normalizeMainKey(sessionCfg?.mainKey); prefixedBodyBase = await prependSystemEvents({ cfg, diff --git a/src/auto-reply/reply/queue/enqueue.ts b/src/auto-reply/reply/queue/enqueue.ts index 040aeb54e..7b242adbc 100644 --- a/src/auto-reply/reply/queue/enqueue.ts +++ b/src/auto-reply/reply/queue/enqueue.ts @@ -1,7 +1,4 @@ -import { - applyQueueDropPolicy, - shouldSkipQueueItem, -} from "../../../utils/queue-helpers.js"; +import { applyQueueDropPolicy, shouldSkipQueueItem } from "../../../utils/queue-helpers.js"; import { FOLLOWUP_QUEUES, getFollowupQueue } from "./state.js"; import type { FollowupRun, QueueDedupeMode, QueueSettings } from "./types.js"; diff --git a/src/auto-reply/reply/session.ts b/src/auto-reply/reply/session.ts index 2d42f0f6d..dc209809d 100644 --- a/src/auto-reply/reply/session.ts +++ b/src/auto-reply/reply/session.ts @@ -193,11 +193,9 @@ export async function initSessionState(params: { const baseEntry = !isNewSession && freshEntry ? entry : undefined; // Track the originating channel/to for announce routing (subagent announce-back). - const lastChannelRaw = - (ctx.OriginatingChannel as string | undefined) || baseEntry?.lastChannel; + const lastChannelRaw = (ctx.OriginatingChannel as string | undefined) || baseEntry?.lastChannel; const lastToRaw = (ctx.OriginatingTo as string | undefined) || ctx.To || baseEntry?.lastTo; - const lastAccountIdRaw = - (ctx.AccountId as string | undefined) || baseEntry?.lastAccountId; + const lastAccountIdRaw = (ctx.AccountId as string | undefined) || baseEntry?.lastAccountId; const deliveryFields = normalizeSessionDeliveryFields({ deliveryContext: { channel: lastChannelRaw, diff --git a/src/channels/command-gating.test.ts b/src/channels/command-gating.test.ts index 03918589c..00aea968d 100644 --- a/src/channels/command-gating.test.ts +++ b/src/channels/command-gating.test.ts @@ -70,4 +70,3 @@ describe("resolveCommandAuthorizedFromAuthorizers", () => { ).toBe(true); }); }); - diff --git a/src/channels/command-gating.ts b/src/channels/command-gating.ts index 574819abc..d6690c667 100644 --- a/src/channels/command-gating.ts +++ b/src/channels/command-gating.ts @@ -21,4 +21,3 @@ export function resolveCommandAuthorizedFromAuthorizers(params: { } return authorizers.some((entry) => entry.configured && entry.allowed); } - diff --git a/src/channels/plugins/discord.ts b/src/channels/plugins/discord.ts index a3eddd5cc..254c764ba 100644 --- a/src/channels/plugins/discord.ts +++ b/src/channels/plugins/discord.ts @@ -26,10 +26,7 @@ import { } from "./config-helpers.js"; import { resolveDiscordGroupRequireMention } from "./group-mentions.js"; import { formatPairingApproveHint } from "./helpers.js"; -import { - looksLikeDiscordTargetId, - normalizeDiscordMessagingTarget, -} from "./normalize-target.js"; +import { looksLikeDiscordTargetId, normalizeDiscordMessagingTarget } from "./normalize-target.js"; import { discordOnboardingAdapter } from "./onboarding/discord.js"; import { PAIRING_APPROVED_MESSAGE } from "./pairing-message.js"; import { diff --git a/src/channels/plugins/signal.ts b/src/channels/plugins/signal.ts index 8b8d44719..5f0a27fb5 100644 --- a/src/channels/plugins/signal.ts +++ b/src/channels/plugins/signal.ts @@ -18,10 +18,7 @@ import { } from "./config-helpers.js"; import { formatPairingApproveHint } from "./helpers.js"; import { resolveChannelMediaMaxBytes } from "./media-limits.js"; -import { - looksLikeSignalTargetId, - normalizeSignalMessagingTarget, -} from "./normalize-target.js"; +import { looksLikeSignalTargetId, normalizeSignalMessagingTarget } from "./normalize-target.js"; import { signalOnboardingAdapter } from "./onboarding/signal.js"; import { PAIRING_APPROVED_MESSAGE } from "./pairing-message.js"; import { diff --git a/src/channels/plugins/telegram.ts b/src/channels/plugins/telegram.ts index eae94475a..6e1b7fb16 100644 --- a/src/channels/plugins/telegram.ts +++ b/src/channels/plugins/telegram.ts @@ -26,10 +26,7 @@ import { } from "./config-helpers.js"; import { resolveTelegramGroupRequireMention } from "./group-mentions.js"; import { formatPairingApproveHint } from "./helpers.js"; -import { - looksLikeTelegramTargetId, - normalizeTelegramMessagingTarget, -} from "./normalize-target.js"; +import { looksLikeTelegramTargetId, normalizeTelegramMessagingTarget } from "./normalize-target.js"; import { telegramOnboardingAdapter } from "./onboarding/telegram.js"; import { PAIRING_APPROVED_MESSAGE } from "./pairing-message.js"; import { diff --git a/src/channels/plugins/whatsapp.ts b/src/channels/plugins/whatsapp.ts index 125c74af6..3ee1179ed 100644 --- a/src/channels/plugins/whatsapp.ts +++ b/src/channels/plugins/whatsapp.ts @@ -26,10 +26,7 @@ import { buildChannelConfigSchema } from "./config-schema.js"; import { createWhatsAppLoginTool } from "./agent-tools/whatsapp-login.js"; import { resolveWhatsAppGroupRequireMention } from "./group-mentions.js"; import { formatPairingApproveHint } from "./helpers.js"; -import { - looksLikeWhatsAppTargetId, - normalizeWhatsAppMessagingTarget, -} from "./normalize-target.js"; +import { looksLikeWhatsAppTargetId, normalizeWhatsAppMessagingTarget } from "./normalize-target.js"; import { whatsappOnboardingAdapter } from "./onboarding/whatsapp.js"; import { applyAccountNameToChannelSection, diff --git a/src/channels/registry.ts b/src/channels/registry.ts index 9324a31f4..10c1106ab 100644 --- a/src/channels/registry.ts +++ b/src/channels/registry.ts @@ -129,7 +129,9 @@ export function normalizeAnyChannelId(raw?: string | null): ChannelId | null { if (!registry) return null; const hit = registry.channels.find((entry) => { - const id = String(entry.plugin.id ?? "").trim().toLowerCase(); + const id = String(entry.plugin.id ?? "") + .trim() + .toLowerCase(); if (id && id === key) return true; return (entry.plugin.meta.aliases ?? []).some((alias) => alias.trim().toLowerCase() === key); }); diff --git a/src/commands/agent/delivery.ts b/src/commands/agent/delivery.ts index bc3ac2985..77d1e013d 100644 --- a/src/commands/agent/delivery.ts +++ b/src/commands/agent/delivery.ts @@ -51,7 +51,9 @@ export async function deliverAgentCommandResult(params: { isInternalMessageChannel(deliveryChannel) || Boolean(deliveryPlugin); const targetMode = - opts.deliveryTargetMode ?? deliveryPlan.deliveryTargetMode ?? (opts.to ? "explicit" : "implicit"); + opts.deliveryTargetMode ?? + deliveryPlan.deliveryTargetMode ?? + (opts.to ? "explicit" : "implicit"); const resolvedAccountId = deliveryPlan.resolvedAccountId; const resolved = deliver && isDeliveryChannelKnown && deliveryChannel diff --git a/src/commands/message-format.ts b/src/commands/message-format.ts index 769e3b13a..e22baa85f 100644 --- a/src/commands/message-format.ts +++ b/src/commands/message-format.ts @@ -243,10 +243,7 @@ export function formatMessageCliText(result: MessageActionRunResult): string[] { const results = result.payload.results ?? []; const rows = results.map((entry) => ({ Channel: resolveChannelLabel(entry.channel), - Target: shortenText( - formatTargetDisplay({ channel: entry.channel, target: entry.to }), - 36, - ), + Target: shortenText(formatTargetDisplay({ channel: entry.channel, target: entry.to }), 36), Status: entry.ok ? "ok" : "error", Error: entry.ok ? "" : shortenText(entry.error ?? "unknown error", 48), })); diff --git a/src/config/zod-schema.core.ts b/src/config/zod-schema.core.ts index 03165f6a0..1922670be 100644 --- a/src/config/zod-schema.core.ts +++ b/src/config/zod-schema.core.ts @@ -251,11 +251,7 @@ export const MediaUnderstandingScopeSchema = z .object({ channel: z.string().optional(), chatType: z - .union([ - z.literal("direct"), - z.literal("group"), - z.literal("channel"), - ]) + .union([z.literal("direct"), z.literal("group"), z.literal("channel")]) .optional(), keyPrefix: z.string().optional(), }) diff --git a/src/config/zod-schema.session.ts b/src/config/zod-schema.session.ts index bba312ad0..34965def9 100644 --- a/src/config/zod-schema.session.ts +++ b/src/config/zod-schema.session.ts @@ -39,11 +39,7 @@ export const SessionSchema = z .object({ channel: z.string().optional(), chatType: z - .union([ - z.literal("direct"), - z.literal("group"), - z.literal("channel"), - ]) + .union([z.literal("direct"), z.literal("group"), z.literal("channel")]) .optional(), keyPrefix: z.string().optional(), }) diff --git a/src/discord/monitor/message-handler.preflight.ts b/src/discord/monitor/message-handler.preflight.ts index ad8d2afc7..9002b85c8 100644 --- a/src/discord/monitor/message-handler.preflight.ts +++ b/src/discord/monitor/message-handler.preflight.ts @@ -319,38 +319,38 @@ export async function preflightDiscordMessage( surface: "discord", }); - if (!isDirectMessage) { - const ownerAllowList = normalizeDiscordAllowList(params.allowFrom, ["discord:", "user:"]); - const ownerOk = ownerAllowList - ? allowListMatches(ownerAllowList, { + if (!isDirectMessage) { + const ownerAllowList = normalizeDiscordAllowList(params.allowFrom, ["discord:", "user:"]); + const ownerOk = ownerAllowList + ? allowListMatches(ownerAllowList, { id: author.id, name: author.username, tag: formatDiscordUserTag(author), }) : false; - const channelUsers = channelConfig?.users ?? guildInfo?.users; - const usersOk = - Array.isArray(channelUsers) && channelUsers.length > 0 - ? resolveDiscordUserAllowed({ - allowList: channelUsers, - userId: author.id, - userName: author.username, - userTag: formatDiscordUserTag(author), - }) - : false; - const useAccessGroups = params.cfg.commands?.useAccessGroups !== false; - commandAuthorized = resolveCommandAuthorizedFromAuthorizers({ - useAccessGroups, - authorizers: [ - { configured: ownerAllowList != null, allowed: ownerOk }, - { configured: Array.isArray(channelUsers) && channelUsers.length > 0, allowed: usersOk }, - ], - modeWhenAccessGroupsOff: "configured", - }); + const channelUsers = channelConfig?.users ?? guildInfo?.users; + const usersOk = + Array.isArray(channelUsers) && channelUsers.length > 0 + ? resolveDiscordUserAllowed({ + allowList: channelUsers, + userId: author.id, + userName: author.username, + userTag: formatDiscordUserTag(author), + }) + : false; + const useAccessGroups = params.cfg.commands?.useAccessGroups !== false; + commandAuthorized = resolveCommandAuthorizedFromAuthorizers({ + useAccessGroups, + authorizers: [ + { configured: ownerAllowList != null, allowed: ownerOk }, + { configured: Array.isArray(channelUsers) && channelUsers.length > 0, allowed: usersOk }, + ], + modeWhenAccessGroupsOff: "configured", + }); - if (allowTextCommands && hasControlCommand(baseText, params.cfg) && !commandAuthorized) { - logVerbose(`Blocked discord control command from unauthorized sender ${author.id}`); - return null; + if (allowTextCommands && hasControlCommand(baseText, params.cfg) && !commandAuthorized) { + logVerbose(`Blocked discord control command from unauthorized sender ${author.id}`); + return null; } } diff --git a/src/gateway/server.agent.gateway-server-agent-b.test.ts b/src/gateway/server.agent.gateway-server-agent-b.test.ts index fe4cf485e..f3c5ecad8 100644 --- a/src/gateway/server.agent.gateway-server-agent-b.test.ts +++ b/src/gateway/server.agent.gateway-server-agent-b.test.ts @@ -230,19 +230,19 @@ describe("gateway server agent", () => { await server.close(); }); - test("agent uses webchat for internal runs when last provider is webchat", async () => { - const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-gw-")); - testState.sessionStorePath = path.join(dir, "sessions.json"); - await writeSessionStore({ - entries: { - main: { - sessionId: "sess-main-webchat-internal", - updatedAt: Date.now(), - lastChannel: "webchat", - lastTo: "+1555", - }, + test("agent uses webchat for internal runs when last provider is webchat", async () => { + const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-gw-")); + testState.sessionStorePath = path.join(dir, "sessions.json"); + await writeSessionStore({ + entries: { + main: { + sessionId: "sess-main-webchat-internal", + updatedAt: Date.now(), + lastChannel: "webchat", + lastTo: "+1555", }, - }); + }, + }); const { server, ws } = await startServerWithClient(); await connectOk(ws); diff --git a/src/hooks/hooks-install.e2e.test.ts b/src/hooks/hooks-install.e2e.test.ts index 1070b4092..0d352c4e7 100644 --- a/src/hooks/hooks-install.e2e.test.ts +++ b/src/hooks/hooks-install.e2e.test.ts @@ -97,9 +97,8 @@ describe("hooks install (e2e)", () => { expect(installResult.ok).toBe(true); if (!installResult.ok) return; - const { clearInternalHooks, createInternalHookEvent, triggerInternalHook } = await import( - "./internal-hooks.js" - ); + const { clearInternalHooks, createInternalHookEvent, triggerInternalHook } = + await import("./internal-hooks.js"); const { loadInternalHooks } = await import("./loader.js"); clearInternalHooks(); diff --git a/src/hooks/install.test.ts b/src/hooks/install.test.ts index f34ea2b52..c1912eac3 100644 --- a/src/hooks/install.test.ts +++ b/src/hooks/install.test.ts @@ -62,7 +62,7 @@ describe("installHooksFromArchive", () => { "---", "name: zip-hook", "description: Zip hook", - "metadata: {\"clawdbot\":{\"events\":[\"command:new\"]}}", + 'metadata: {"clawdbot":{"events":["command:new"]}}', "---", "", "# Zip Hook", @@ -82,9 +82,7 @@ describe("installHooksFromArchive", () => { expect(result.hookPackId).toBe("zip-hooks"); expect(result.hooks).toContain("zip-hook"); expect(result.targetDir).toBe(path.join(stateDir, "hooks", "zip-hooks")); - expect( - fs.existsSync(path.join(result.targetDir, "hooks", "zip-hook", "HOOK.md")), - ).toBe(true); + expect(fs.existsSync(path.join(result.targetDir, "hooks", "zip-hook", "HOOK.md"))).toBe(true); }); it("installs hook packs from tar archives", async () => { @@ -109,7 +107,7 @@ describe("installHooksFromArchive", () => { "---", "name: tar-hook", "description: Tar hook", - "metadata: {\"clawdbot\":{\"events\":[\"command:new\"]}}", + 'metadata: {"clawdbot":{"events":["command:new"]}}', "---", "", "# Tar Hook", @@ -148,7 +146,7 @@ describe("installHooksFromPath", () => { "---", "name: my-hook", "description: My hook", - "metadata: {\"clawdbot\":{\"events\":[\"command:new\"]}}", + 'metadata: {"clawdbot":{"events":["command:new"]}}', "---", "", "# My Hook", diff --git a/src/hooks/install.ts b/src/hooks/install.ts index 51e5b1b86..a55fa09e3 100644 --- a/src/hooks/install.ts +++ b/src/hooks/install.ts @@ -134,7 +134,9 @@ async function installHookPackageFromDir(params: { }; } - const hooksDir = params.hooksDir ? resolveUserPath(params.hooksDir) : path.join(CONFIG_DIR, "hooks"); + const hooksDir = params.hooksDir + ? resolveUserPath(params.hooksDir) + : path.join(CONFIG_DIR, "hooks"); await fs.mkdir(hooksDir, { recursive: true }); const targetDir = resolveHookInstallDir(hookPackId, hooksDir); @@ -232,7 +234,9 @@ async function installHookFromDir(params: { }; } - const hooksDir = params.hooksDir ? resolveUserPath(params.hooksDir) : path.join(CONFIG_DIR, "hooks"); + const hooksDir = params.hooksDir + ? resolveUserPath(params.hooksDir) + : path.join(CONFIG_DIR, "hooks"); await fs.mkdir(hooksDir, { recursive: true }); const targetDir = resolveHookInstallDir(hookName, hooksDir); diff --git a/src/hooks/loader.ts b/src/hooks/loader.ts index 31042c911..35d7b7d50 100644 --- a/src/hooks/loader.ts +++ b/src/hooks/loader.ts @@ -79,9 +79,7 @@ export async function loadInternalHooks( // Register for all events listed in metadata const events = entry.clawdbot?.events ?? []; if (events.length === 0) { - console.warn( - `Hook warning: Hook '${entry.hook.name}' has no events defined in metadata`, - ); + console.warn(`Hook warning: Hook '${entry.hook.name}' has no events defined in metadata`); continue; } @@ -126,9 +124,7 @@ export async function loadInternalHooks( const handler = mod[exportName]; if (typeof handler !== "function") { - console.error( - `Hook error: Handler '${exportName}' from ${modulePath} is not a function`, - ); + console.error(`Hook error: Handler '${exportName}' from ${modulePath} is not a function`); continue; } diff --git a/src/hooks/workspace.ts b/src/hooks/workspace.ts index ea9d95393..bb5b3b9b5 100644 --- a/src/hooks/workspace.ts +++ b/src/hooks/workspace.ts @@ -48,7 +48,11 @@ function resolvePackageHooks(manifest: HookPackageManifest): string[] { return raw.map((entry) => (typeof entry === "string" ? entry.trim() : "")).filter(Boolean); } -function loadHookFromDir(params: { hookDir: string; source: string; nameHint?: string }): Hook | null { +function loadHookFromDir(params: { + hookDir: string; + source: string; + nameHint?: string; +}): Hook | null { const hookMdPath = path.join(params.hookDir, "HOOK.md"); if (!fs.existsSync(hookMdPath)) return null; diff --git a/src/infra/archive.ts b/src/infra/archive.ts index 7b0869ef9..35ad4fa04 100644 --- a/src/infra/archive.ts +++ b/src/infra/archive.ts @@ -61,10 +61,7 @@ export async function withTimeout( } } -async function extractZip(params: { - archivePath: string; - destDir: string; -}): Promise { +async function extractZip(params: { archivePath: string; destDir: string }): Promise { const buffer = await fs.readFile(params.archivePath); const zip = await JSZip.loadAsync(buffer); const entries = Object.values(zip.files); diff --git a/src/infra/outbound/agent-delivery.ts b/src/infra/outbound/agent-delivery.ts index 34db4042d..3477a161b 100644 --- a/src/infra/outbound/agent-delivery.ts +++ b/src/infra/outbound/agent-delivery.ts @@ -9,7 +9,11 @@ import { normalizeMessageChannel, type GatewayMessageChannel, } from "../../utils/message-channel.js"; -import { resolveOutboundTarget, resolveSessionDeliveryTarget, type SessionDeliveryTarget } from "./targets.js"; +import { + resolveOutboundTarget, + resolveSessionDeliveryTarget, + type SessionDeliveryTarget, +} from "./targets.js"; import type { ClawdbotConfig } from "../../config/config.js"; import type { OutboundTargetResolution } from "./targets.js"; diff --git a/src/media-understanding/apply.test.ts b/src/media-understanding/apply.test.ts index 9967f9209..e7bf08a24 100644 --- a/src/media-understanding/apply.test.ts +++ b/src/media-understanding/apply.test.ts @@ -121,9 +121,7 @@ describe("applyMediaUnderstanding", () => { expect(result.appliedAudio).toBe(true); expect(ctx.Transcript).toBe("transcribed text"); - expect(ctx.Body).toBe( - "[Audio]\nUser text:\n/capture status\nTranscript:\ntranscribed text", - ); + expect(ctx.Body).toBe("[Audio]\nUser text:\n/capture status\nTranscript:\ntranscribed text"); expect(ctx.CommandBody).toBe("/capture status"); expect(ctx.RawBody).toBe("/capture status"); expect(ctx.BodyForCommands).toBe("/capture status"); diff --git a/src/media-understanding/apply.ts b/src/media-understanding/apply.ts index d1197ba1a..ca6468295 100644 --- a/src/media-understanding/apply.ts +++ b/src/media-understanding/apply.ts @@ -78,10 +78,7 @@ export async function applyMediaUnderstanding(params: { } if (decisions.length > 0) { - ctx.MediaUnderstandingDecisions = [ - ...(ctx.MediaUnderstandingDecisions ?? []), - ...decisions, - ]; + ctx.MediaUnderstandingDecisions = [...(ctx.MediaUnderstandingDecisions ?? []), ...decisions]; } if (outputs.length > 0) { diff --git a/src/media-understanding/resolve.test.ts b/src/media-understanding/resolve.test.ts index f2a42c582..19519dab3 100644 --- a/src/media-understanding/resolve.test.ts +++ b/src/media-understanding/resolve.test.ts @@ -1,10 +1,7 @@ import { describe, expect, it } from "vitest"; import type { ClawdbotConfig } from "../config/config.js"; -import { - resolveEntriesWithActiveFallback, - resolveModelEntries, -} from "./resolve.js"; +import { resolveEntriesWithActiveFallback, resolveModelEntries } from "./resolve.js"; const providerRegistry = new Map([ ["openai", { capabilities: ["image"] }], diff --git a/src/media-understanding/runner.ts b/src/media-understanding/runner.ts index 675d47e37..10a976e59 100644 --- a/src/media-understanding/runner.ts +++ b/src/media-understanding/runner.ts @@ -100,7 +100,9 @@ function buildModelDecision(params: { function formatDecisionSummary(decision: MediaUnderstandingDecision): string { const total = decision.attachments.length; - const success = decision.attachments.filter((entry) => entry.chosen?.outcome === "success").length; + const success = decision.attachments.filter( + (entry) => entry.chosen?.outcome === "success", + ).length; const chosen = decision.attachments.find((entry) => entry.chosen)?.chosen; const provider = chosen?.provider?.trim(); const model = chosen?.model?.trim(); @@ -355,7 +357,10 @@ async function runAttachmentEntries(params: { cache: MediaAttachmentCache; entries: MediaUnderstandingModelConfig[]; config?: MediaUnderstandingConfig; -}): Promise<{ output: MediaUnderstandingOutput | null; attempts: MediaUnderstandingModelDecision[] }> { +}): Promise<{ + output: MediaUnderstandingOutput | null; + attempts: MediaUnderstandingModelDecision[]; +}> { const { entries, capability } = params; const attempts: MediaUnderstandingModelDecision[] = []; for (const entry of entries) { diff --git a/src/security/audit.ts b/src/security/audit.ts index 17c130e1d..0ae2f455b 100644 --- a/src/security/audit.ts +++ b/src/security/audit.ts @@ -474,10 +474,8 @@ async function collectChannelSecurityFindings(params: { if (plugin.id === "discord") { const discordCfg = - (account as { config?: Record } | null)?.config ?? ({} as Record< - string, - unknown - >); + (account as { config?: Record } | null)?.config ?? + ({} as Record); const nativeEnabled = resolveNativeCommandsEnabled({ providerId: "discord", providerSetting: coerceNativeSetting( @@ -516,15 +514,20 @@ async function collectChannelSecurityFindings(params: { normalizeAllowFromList([...dmAllowFrom, ...storeAllowFrom]).length > 0; const useAccessGroups = params.cfg.commands?.useAccessGroups !== false; - if (!useAccessGroups && groupPolicy !== "disabled" && guildsConfigured && !hasAnyUserAllowlist) { + if ( + !useAccessGroups && + groupPolicy !== "disabled" && + guildsConfigured && + !hasAnyUserAllowlist + ) { findings.push({ checkId: "channels.discord.commands.native.unrestricted", severity: "critical", title: "Discord slash commands are unrestricted", detail: - 'commands.useAccessGroups=false disables sender allowlists for Discord slash commands unless a per-guild/channel users allowlist is configured; with no users allowlist, any user in allowed guild channels can invoke /… commands.', + "commands.useAccessGroups=false disables sender allowlists for Discord slash commands unless a per-guild/channel users allowlist is configured; with no users allowlist, any user in allowed guild channels can invoke /… commands.", remediation: - 'Set commands.useAccessGroups=true (recommended), or configure channels.discord.guilds..users (or channels.discord.guilds..channels..users).', + "Set commands.useAccessGroups=true (recommended), or configure channels.discord.guilds..users (or channels.discord.guilds..channels..users).", }); } else if ( useAccessGroups && @@ -540,7 +543,7 @@ async function collectChannelSecurityFindings(params: { detail: "Discord slash commands are enabled, but neither an owner allowFrom list nor any per-guild/channel users allowlist is configured; /… commands will be rejected for everyone.", remediation: - 'Add your user id to channels.discord.dm.allowFrom (or approve yourself via pairing), or configure channels.discord.guilds..users.', + "Add your user id to channels.discord.dm.allowFrom (or approve yourself via pairing), or configure channels.discord.guilds..users.", }); } } @@ -567,7 +570,7 @@ async function collectChannelSecurityFindings(params: { const slashCommandEnabled = nativeEnabled || nativeSkillsEnabled || - ((slackCfg.slashCommand as { enabled?: unknown } | undefined)?.enabled === true); + (slackCfg.slashCommand as { enabled?: unknown } | undefined)?.enabled === true; if (slashCommandEnabled) { const useAccessGroups = params.cfg.commands?.useAccessGroups !== false; if (!useAccessGroups) { @@ -580,7 +583,8 @@ async function collectChannelSecurityFindings(params: { remediation: "Set commands.useAccessGroups=true (recommended).", }); } else { - const dmAllowFromRaw = (account as { dm?: { allowFrom?: unknown } } | null)?.dm?.allowFrom; + const dmAllowFromRaw = (account as { dm?: { allowFrom?: unknown } } | null)?.dm + ?.allowFrom; const dmAllowFrom = Array.isArray(dmAllowFromRaw) ? dmAllowFromRaw : []; const storeAllowFrom = await readChannelAllowFromStore("slack").catch(() => []); const ownerAllowFromConfigured = diff --git a/src/telegram/bot-native-commands.ts b/src/telegram/bot-native-commands.ts index 413fa95af..002d873b4 100644 --- a/src/telegram/bot-native-commands.ts +++ b/src/telegram/bot-native-commands.ts @@ -110,8 +110,8 @@ export const registerTelegramNativeCommands = ({ if (allCommands.length > 0) { bot.api.setMyCommands(allCommands).catch((err) => { - runtime.error?.(danger(`telegram setMyCommands failed: ${String(err)}`)); - }); + runtime.error?.(danger(`telegram setMyCommands failed: ${String(err)}`)); + }); if (typeof (bot as unknown as { command?: unknown }).command !== "function") { logVerbose("telegram: bot.command unavailable; skipping native handlers"); diff --git a/src/utils/delivery-context.ts b/src/utils/delivery-context.ts index e24e722f4..b05e2c6b0 100644 --- a/src/utils/delivery-context.ts +++ b/src/utils/delivery-context.ts @@ -19,7 +19,7 @@ export function normalizeDeliveryContext(context?: DeliveryContext): DeliveryCon if (!context) return undefined; const channel = typeof context.channel === "string" - ? normalizeMessageChannel(context.channel) ?? context.channel.trim() + ? (normalizeMessageChannel(context.channel) ?? context.channel.trim()) : undefined; const to = typeof context.to === "string" ? context.to.trim() : undefined; const accountId = normalizeAccountId(context.accountId); @@ -31,9 +31,7 @@ export function normalizeDeliveryContext(context?: DeliveryContext): DeliveryCon }; } -export function normalizeSessionDeliveryFields( - source?: DeliveryContextSessionSource, -): { +export function normalizeSessionDeliveryFields(source?: DeliveryContextSessionSource): { deliveryContext?: DeliveryContext; lastChannel?: string; lastTo?: string; diff --git a/src/web/auto-reply/monitor/process-message.ts b/src/web/auto-reply/monitor/process-message.ts index 5b70b64f8..5b00a957b 100644 --- a/src/web/auto-reply/monitor/process-message.ts +++ b/src/web/auto-reply/monitor/process-message.ts @@ -78,9 +78,15 @@ async function resolveWhatsAppCommandAuthorized(params: { } const storeAllowFrom = await readChannelAllowFromStore("whatsapp").catch(() => []); - const combinedAllowFrom = Array.from(new Set([...(configuredAllowFrom ?? []), ...storeAllowFrom])); + const combinedAllowFrom = Array.from( + new Set([...(configuredAllowFrom ?? []), ...storeAllowFrom]), + ); const allowFrom = - combinedAllowFrom.length > 0 ? combinedAllowFrom : params.msg.selfE164 ? [params.msg.selfE164] : []; + combinedAllowFrom.length > 0 + ? combinedAllowFrom + : params.msg.selfE164 + ? [params.msg.selfE164] + : []; if (allowFrom.some((v) => String(v).trim() === "*")) return true; return normalizeAllowFromE164(allowFrom).includes(senderE164); }