diff --git a/src/message-agent-executor-paired.ts b/src/message-agent-executor-paired.ts index d2c30f0..446e594 100644 --- a/src/message-agent-executor-paired.ts +++ b/src/message-agent-executor-paired.ts @@ -182,7 +182,10 @@ export function createPairedExecutionLifecycle(args: { } const finishedTask = getPairedTaskById(pairedExecutionContext.task.id); - if (finishedTask?.status === 'completed' && finishedTask.completion_reason) { + if ( + finishedTask?.status === 'completed' && + finishedTask.completion_reason + ) { const sender = getLastHumanMessageSender(chatJid); const mention = sender ? `<@${sender}>` : ''; const notifications: Record = { diff --git a/src/message-agent-executor.ts b/src/message-agent-executor.ts index 8c9e1e0..b52c51c 100644 --- a/src/message-agent-executor.ts +++ b/src/message-agent-executor.ts @@ -26,14 +26,10 @@ import { import { GroupQueue } from './group-queue.js'; import { createScopedLogger } from './logger.js'; import { buildRoomMemoryBriefing } from './sqlite-memory-store.js'; -import { - preparePairedExecutionContext, -} from './paired-execution-context.js'; +import { preparePairedExecutionContext } from './paired-execution-context.js'; import { resolveCodexFallbackHandoff } from './paired-turn-fallback.js'; import { createPairedExecutionLifecycle } from './message-agent-executor-paired.js'; -import { - resolveExecutionTarget, -} from './message-runtime-rules.js'; +import { resolveExecutionTarget } from './message-runtime-rules.js'; import { buildRoomRoleContext } from './room-role-context.js'; import { type AgentTriggerReason } from './agent-error-detection.js'; import { @@ -539,7 +535,9 @@ export async function runAgentForGroup( outputText.length > 0 ) { try { - pairedExecutionLifecycle.recordFinalOutputBeforeDelivery(outputText); + pairedExecutionLifecycle.recordFinalOutputBeforeDelivery( + outputText, + ); } catch (err) { log.warn( { pairedTaskId: pairedExecutionContext?.task.id ?? null, err }, @@ -648,7 +646,7 @@ export async function runAgentForGroup( runId, }; - return runClaudeAttemptWithRotation({ + return runClaudeAttemptWithRotation({ initialTrigger, runAttempt: () => runAttempt('claude'), logContext: logCtx, @@ -811,9 +809,9 @@ export async function runAgentForGroup( const finalOutputText = getAgentOutputText(output); pairedExecutionLifecycle.updateSummary({ outputText: - (typeof finalOutputText === 'string' && finalOutputText.length > 0 - ? finalOutputText - : null), + typeof finalOutputText === 'string' && finalOutputText.length > 0 + ? finalOutputText + : null, errorText: typeof output.error === 'string' && output.error.length > 0 ? output.error diff --git a/src/message-runtime-delivery.ts b/src/message-runtime-delivery.ts index 81533eb..d64ac34 100644 --- a/src/message-runtime-delivery.ts +++ b/src/message-runtime-delivery.ts @@ -98,7 +98,10 @@ export async function deliverOpenWorkItem(args: { }), 'Attempting to deliver produced work item as a new message', ); - await args.channel.sendMessage(args.item.chat_jid, args.item.result_payload); + await args.channel.sendMessage( + args.item.chat_jid, + args.item.result_payload, + ); markWorkItemDelivered(args.item.id); args.openContinuation(args.item.chat_jid); args.log.info( diff --git a/src/message-runtime-dispatch.ts b/src/message-runtime-dispatch.ts index 03693ad..1659d96 100644 --- a/src/message-runtime-dispatch.ts +++ b/src/message-runtime-dispatch.ts @@ -1,8 +1,5 @@ import { logger } from './logger.js'; -import { - getLatestOpenPairedTaskForChat, - getMessagesSinceSeq, -} from './db.js'; +import { getLatestOpenPairedTaskForChat, getMessagesSinceSeq } from './db.js'; import { buildQueuedTurnDispatch, executeBotOnlyPairedFollowUpAction, @@ -17,7 +14,10 @@ import { resolveNextTurnAction, shouldSkipBotOnlyCollaboration, } from './message-runtime-rules.js'; -import { extractSessionCommand, isSessionCommandAllowed } from './session-commands.js'; +import { + extractSessionCommand, + isSessionCommandAllowed, +} from './session-commands.js'; import { isSessionCommandSenderAllowed } from './config.js'; import { hasReviewerLease } from './service-routing.js'; import type { ScheduledPairedFollowUpIntentKind } from './paired-follow-up-scheduler.js'; @@ -162,7 +162,10 @@ export async function processQueuedGroupDispatch(args: { ); const messagesToSend = pendingMessages.length > 0 ? pendingMessages : processableGroupMessages; - const labeledMessagesToSend = args.labelPairedSenders(chatJid, messagesToSend); + const labeledMessagesToSend = args.labelPairedSenders( + chatJid, + messagesToSend, + ); const { formatted, botOnlyFollowUpAction, diff --git a/src/message-runtime-gating.ts b/src/message-runtime-gating.ts index 387dea4..e06ab0d 100644 --- a/src/message-runtime-gating.ts +++ b/src/message-runtime-gating.ts @@ -1,6 +1,9 @@ import { logger } from './logger.js'; import { hasAllowedTrigger } from './message-runtime-rules.js'; -import { handleSessionCommand, type SessionCommandDeps } from './session-commands.js'; +import { + handleSessionCommand, + type SessionCommandDeps, +} from './session-commands.js'; import type { NewMessage, RegisteredGroup } from './types.js'; export async function handleQueuedRunGates(args: { diff --git a/src/message-runtime-loop.ts b/src/message-runtime-loop.ts index 064cb0f..2c9aa04 100644 --- a/src/message-runtime-loop.ts +++ b/src/message-runtime-loop.ts @@ -63,7 +63,10 @@ export async function processMessageLoopTick(args: { intentKind: ScheduledPairedFollowUpIntentKind; enqueue: () => void; }) => boolean; - enqueueScopedGroupMessageCheck: (chatJid: string, groupFolder: string) => void; + enqueueScopedGroupMessageCheck: ( + chatJid: string, + groupFolder: string, + ) => void; sendQueuedMessage: (chatJid: string, text: string) => boolean; closeStdin: (chatJid: string, reason: string) => void; labelPairedSenders: (chatJid: string, messages: NewMessage[]) => NewMessage[]; @@ -143,7 +146,10 @@ export function recoverPendingMessages(args: { getRegisteredGroups: () => Record; lastAgentTimestamps: Record; saveState: () => void; - enqueueScopedGroupMessageCheck: (chatJid: string, groupFolder: string) => void; + enqueueScopedGroupMessageCheck: ( + chatJid: string, + groupFolder: string, + ) => void; }): void { const registeredGroups = args.getRegisteredGroups(); for (const [chatJid, group] of Object.entries(registeredGroups)) { diff --git a/src/message-runtime-queue.ts b/src/message-runtime-queue.ts index 8336d11..96be6bb 100644 --- a/src/message-runtime-queue.ts +++ b/src/message-runtime-queue.ts @@ -1,7 +1,4 @@ -import { - getPairedTurnOutputs, - getRecentChatMessages, -} from './db.js'; +import { getPairedTurnOutputs, getRecentChatMessages } from './db.js'; import { logger } from './logger.js'; import { buildArbiterPromptForTask, @@ -45,7 +42,10 @@ type ExecuteTurnFn = (args: { visiblePhase: unknown; }>; -type RoleToChannelMap = Record<'owner' | 'reviewer' | 'arbiter', Channel | null>; +type RoleToChannelMap = Record< + 'owner' | 'reviewer' | 'arbiter', + Channel | null +>; export async function runPendingPairedTurnIfNeeded(args: { chatJid: string; diff --git a/src/message-runtime.ts b/src/message-runtime.ts index d560cee..391a28a 100644 --- a/src/message-runtime.ts +++ b/src/message-runtime.ts @@ -16,9 +16,7 @@ import { normalizeMessageForDedupe, } from './router.js'; import { isTriggerAllowed, loadSenderAllowlist } from './sender-allowlist.js'; -import { - enqueueGenericFollowUpAfterDeliveryRetry as enqueueDeliveryRetryFollowUp, -} from './message-runtime-dispatch.js'; +import { enqueueGenericFollowUpAfterDeliveryRetry as enqueueDeliveryRetryFollowUp } from './message-runtime-dispatch.js'; import { deliverOpenWorkItem, processOpenWorkItemDelivery, @@ -458,7 +456,10 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): { ); // Resolve the correct Discord channel for a given task status. - const roleToChannel: Record<'owner' | 'reviewer' | 'arbiter', Channel | null> = { + const roleToChannel: Record< + 'owner' | 'reviewer' | 'arbiter', + Channel | null + > = { owner: channel, reviewer: foundReviewerChannel || null, arbiter: foundArbiterChannel || null,