diff --git a/src/agents/pi-embedded-runner.sanitize-session-history.test.ts b/src/agents/pi-embedded-runner.sanitize-session-history.test.ts index 6972f5111..0b4216872 100644 --- a/src/agents/pi-embedded-runner.sanitize-session-history.test.ts +++ b/src/agents/pi-embedded-runner.sanitize-session-history.test.ts @@ -3,7 +3,8 @@ import type { SessionManager } from "@mariozechner/pi-coding-agent"; import { beforeEach, describe, expect, it, vi } from "vitest"; import * as helpers from "./pi-embedded-helpers.js"; -type SanitizeSessionHistory = typeof import("./pi-embedded-runner/google.js").sanitizeSessionHistory; +type SanitizeSessionHistory = + typeof import("./pi-embedded-runner/google.js").sanitizeSessionHistory; let sanitizeSessionHistory: SanitizeSessionHistory; // Mock dependencies diff --git a/src/agents/pi-tools.ts b/src/agents/pi-tools.ts index 33622e2d2..97bcd9baa 100644 --- a/src/agents/pi-tools.ts +++ b/src/agents/pi-tools.ts @@ -262,20 +262,11 @@ export function createClawdbotCodingTools(options?: { toolMeta: (tool) => getPluginToolMeta(tool), }); const profilePolicyExpanded = expandPolicyWithPluginGroups(profilePolicy, pluginGroups); - const providerProfileExpanded = expandPolicyWithPluginGroups( - providerProfilePolicy, - pluginGroups, - ); + const providerProfileExpanded = expandPolicyWithPluginGroups(providerProfilePolicy, pluginGroups); const globalPolicyExpanded = expandPolicyWithPluginGroups(globalPolicy, pluginGroups); - const globalProviderExpanded = expandPolicyWithPluginGroups( - globalProviderPolicy, - pluginGroups, - ); + const globalProviderExpanded = expandPolicyWithPluginGroups(globalProviderPolicy, pluginGroups); const agentPolicyExpanded = expandPolicyWithPluginGroups(agentPolicy, pluginGroups); - const agentProviderExpanded = expandPolicyWithPluginGroups( - agentProviderPolicy, - pluginGroups, - ); + const agentProviderExpanded = expandPolicyWithPluginGroups(agentProviderPolicy, pluginGroups); const sandboxPolicyExpanded = expandPolicyWithPluginGroups(sandbox?.tools, pluginGroups); const subagentPolicyExpanded = expandPolicyWithPluginGroups(subagentPolicy, pluginGroups); diff --git a/src/agents/tool-policy.ts b/src/agents/tool-policy.ts index 72d27b182..4988c6877 100644 --- a/src/agents/tool-policy.ts +++ b/src/agents/tool-policy.ts @@ -109,9 +109,7 @@ export function expandToolGroups(list?: string[]) { return Array.from(new Set(expanded)); } -export function collectExplicitAllowlist( - policies: Array, -): string[] { +export function collectExplicitAllowlist(policies: Array): string[] { const entries: string[] = []; for (const policy of policies) { if (!policy?.allow) continue; @@ -124,9 +122,9 @@ export function collectExplicitAllowlist( return entries; } -export function buildPluginToolGroups(params: { - tools: Array<{ name: string }>; - toolMeta: (tool: { name: string }) => { pluginId: string } | undefined; +export function buildPluginToolGroups(params: { + tools: T[]; + toolMeta: (tool: T) => { pluginId: string } | undefined; }): PluginToolGroups { const all: string[] = []; const byPlugin = new Map(); diff --git a/src/config/sessions/metadata.ts b/src/config/sessions/metadata.ts index b22a110ef..1b70177d4 100644 --- a/src/config/sessions/metadata.ts +++ b/src/config/sessions/metadata.ts @@ -73,13 +73,11 @@ export function deriveGroupSessionPatch(params: { const normalizedChannel = normalizeChannelId(channel); const isChannelProvider = Boolean( normalizedChannel && - getChannelDock(normalizedChannel)?.capabilities.chatTypes.includes("channel"), + getChannelDock(normalizedChannel)?.capabilities.chatTypes.includes("channel"), ); const nextGroupChannel = explicitChannel ?? - ((resolution.chatType === "channel" || isChannelProvider) && - subject && - subject.startsWith("#") + ((resolution.chatType === "channel" || isChannelProvider) && subject && subject.startsWith("#") ? subject : undefined); const nextSubject = nextGroupChannel ? undefined : subject; diff --git a/src/config/sessions/store.ts b/src/config/sessions/store.ts index 971b90bf3..006acc9f7 100644 --- a/src/config/sessions/store.ts +++ b/src/config/sessions/store.ts @@ -406,7 +406,10 @@ export async function updateLastRoute(params: { lastTo: normalized.lastTo, lastAccountId: normalized.lastAccountId, }; - const next = mergeSessionEntry(existing, metaPatch ? { ...basePatch, ...metaPatch } : basePatch); + const next = mergeSessionEntry( + existing, + metaPatch ? { ...basePatch, ...metaPatch } : basePatch, + ); store[sessionKey] = next; await saveSessionStoreUnlocked(storePath, store); return next; diff --git a/src/plugin-sdk/index.ts b/src/plugin-sdk/index.ts index 2d64a65f2..8d0f75e47 100644 --- a/src/plugin-sdk/index.ts +++ b/src/plugin-sdk/index.ts @@ -107,9 +107,16 @@ export { } from "../channels/plugins/channel-config.js"; export type { AllowlistMatch } from "../channels/plugins/allowlist-match.js"; export { formatAllowlistMatchMeta } from "../channels/plugins/allowlist-match.js"; -export { readChannelAllowFromStore, upsertChannelPairingRequest } from "../pairing/pairing-store.js"; +export { + readChannelAllowFromStore, + upsertChannelPairingRequest, +} from "../pairing/pairing-store.js"; export { resolveAgentRoute } from "../routing/resolve-route.js"; -export { recordSessionMetaFromInbound, resolveStorePath, updateLastRoute } from "../config/sessions.js"; +export { + recordSessionMetaFromInbound, + resolveStorePath, + updateLastRoute, +} from "../config/sessions.js"; export { resolveStateDir } from "../config/paths.js"; export { loadConfig } from "../config/config.js"; export { danger } from "../globals.js"; @@ -130,7 +137,10 @@ export { deleteAccountFromConfigSection, setAccountEnabledInConfigSection, } from "../channels/plugins/config-helpers.js"; -export { applyAccountNameToChannelSection, migrateBaseNameToDefaultAccount } from "../channels/plugins/setup-helpers.js"; +export { + applyAccountNameToChannelSection, + migrateBaseNameToDefaultAccount, +} from "../channels/plugins/setup-helpers.js"; export { formatPairingApproveHint } from "../channels/plugins/helpers.js"; export { PAIRING_APPROVED_MESSAGE } from "../channels/plugins/pairing-message.js"; diff --git a/src/plugins/runtime/index.ts b/src/plugins/runtime/index.ts index 0ded31ea6..4939eeef9 100644 --- a/src/plugins/runtime/index.ts +++ b/src/plugins/runtime/index.ts @@ -2,20 +2,29 @@ import { createRequire } from "node:module"; import { chunkMarkdownText, resolveTextChunkLimit } from "../../auto-reply/chunk.js"; import { hasControlCommand } from "../../auto-reply/command-detection.js"; -import { createInboundDebouncer, resolveInboundDebounceMs } from "../../auto-reply/inbound-debounce.js"; +import { + createInboundDebouncer, + resolveInboundDebounceMs, +} from "../../auto-reply/inbound-debounce.js"; import { buildMentionRegexes, matchesMentionPatterns } from "../../auto-reply/reply/mentions.js"; import { dispatchReplyWithBufferedBlockDispatcher } from "../../auto-reply/reply/provider-dispatcher.js"; import { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-dispatcher.js"; import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js"; import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js"; -import { resolveChannelGroupPolicy, resolveChannelGroupRequireMention } from "../../config/group-policy.js"; +import { + resolveChannelGroupPolicy, + resolveChannelGroupRequireMention, +} from "../../config/group-policy.js"; import { resolveStateDir } from "../../config/paths.js"; import { shouldLogVerbose } from "../../globals.js"; import { getChildLogger } from "../../logging.js"; import { fetchRemoteMedia } from "../../media/fetch.js"; import { saveMediaBuffer } from "../../media/store.js"; import { buildPairingReply } from "../../pairing/pairing-messages.js"; -import { readChannelAllowFromStore, upsertChannelPairingRequest } from "../../pairing/pairing-store.js"; +import { + readChannelAllowFromStore, + upsertChannelPairingRequest, +} from "../../pairing/pairing-store.js"; import { resolveAgentRoute } from "../../routing/resolve-route.js"; import type { PluginRuntime } from "./types.js"; diff --git a/src/plugins/runtime/types.ts b/src/plugins/runtime/types.ts index 93b652030..c09a7cad1 100644 --- a/src/plugins/runtime/types.ts +++ b/src/plugins/runtime/types.ts @@ -51,7 +51,10 @@ export type PluginRuntime = { }; logging: { shouldLogVerbose: typeof import("../../globals.js").shouldLogVerbose; - getChildLogger: (bindings?: Record, opts?: { level?: LogLevel }) => RuntimeLogger; + getChildLogger: ( + bindings?: Record, + opts?: { level?: LogLevel }, + ) => RuntimeLogger; }; state: { resolveStateDir: typeof import("../../config/paths.js").resolveStateDir; diff --git a/src/plugins/tools.ts b/src/plugins/tools.ts index 7aba452cc..6935a8e6d 100644 --- a/src/plugins/tools.ts +++ b/src/plugins/tools.ts @@ -52,9 +52,7 @@ export function resolvePluginTools(params: { const tools: AnyAgentTool[] = []; const existing = params.existingToolNames ?? new Set(); - const existingNormalized = new Set( - Array.from(existing, (tool) => normalizeToolName(tool)), - ); + const existingNormalized = new Set(Array.from(existing, (tool) => normalizeToolName(tool))); const allowlist = normalizeAllowlist(params.toolAllowlist); const blockedPlugins = new Set(); diff --git a/src/web/auto-reply/monitor/process-message.ts b/src/web/auto-reply/monitor/process-message.ts index d1b592a81..9f90e7591 100644 --- a/src/web/auto-reply/monitor/process-message.ts +++ b/src/web/auto-reply/monitor/process-message.ts @@ -240,39 +240,39 @@ export async function processMessage(params: { }; const ctxPayload = finalizeInboundContext({ - Body: combinedBody, - RawBody: params.msg.body, - CommandBody: params.msg.body, - From: params.msg.from, - To: params.msg.to, - SessionKey: params.route.sessionKey, - AccountId: params.route.accountId, - MessageSid: params.msg.id, - ReplyToId: params.msg.replyToId, - ReplyToBody: params.msg.replyToBody, - ReplyToSender: params.msg.replyToSender, - MediaPath: params.msg.mediaPath, - MediaUrl: params.msg.mediaUrl, - MediaType: params.msg.mediaType, - ChatType: params.msg.chatType, - ConversationLabel: params.msg.chatType === "group" ? conversationId : params.msg.from, - GroupSubject: params.msg.groupSubject, - GroupMembers: formatGroupMembers({ - participants: params.msg.groupParticipants, - roster: params.groupMemberNames.get(params.groupHistoryKey), - fallbackE164: params.msg.senderE164, - }), - SenderName: params.msg.senderName, - SenderId: params.msg.senderJid?.trim() || params.msg.senderE164, - SenderE164: params.msg.senderE164, - CommandAuthorized: commandAuthorized, - WasMentioned: params.msg.wasMentioned, - ...(params.msg.location ? toLocationContext(params.msg.location) : {}), - Provider: "whatsapp", - Surface: "whatsapp", - OriginatingChannel: "whatsapp", - OriginatingTo: params.msg.from, - }); + Body: combinedBody, + RawBody: params.msg.body, + CommandBody: params.msg.body, + From: params.msg.from, + To: params.msg.to, + SessionKey: params.route.sessionKey, + AccountId: params.route.accountId, + MessageSid: params.msg.id, + ReplyToId: params.msg.replyToId, + ReplyToBody: params.msg.replyToBody, + ReplyToSender: params.msg.replyToSender, + MediaPath: params.msg.mediaPath, + MediaUrl: params.msg.mediaUrl, + MediaType: params.msg.mediaType, + ChatType: params.msg.chatType, + ConversationLabel: params.msg.chatType === "group" ? conversationId : params.msg.from, + GroupSubject: params.msg.groupSubject, + GroupMembers: formatGroupMembers({ + participants: params.msg.groupParticipants, + roster: params.groupMemberNames.get(params.groupHistoryKey), + fallbackE164: params.msg.senderE164, + }), + SenderName: params.msg.senderName, + SenderId: params.msg.senderJid?.trim() || params.msg.senderE164, + SenderE164: params.msg.senderE164, + CommandAuthorized: commandAuthorized, + WasMentioned: params.msg.wasMentioned, + ...(params.msg.location ? toLocationContext(params.msg.location) : {}), + Provider: "whatsapp", + Surface: "whatsapp", + OriginatingChannel: "whatsapp", + OriginatingTo: params.msg.from, + }); if (dmRouteTarget) { updateLastRouteInBackground({