Format runtime refactor modules

This commit is contained in:
ejclaw
2026-04-07 23:46:36 +09:00
parent 2cea7ed94a
commit 6ea833c18a
8 changed files with 48 additions and 31 deletions

View File

@@ -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<string, string> = {

View File

@@ -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

View File

@@ -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(

View File

@@ -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,

View File

@@ -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: {

View File

@@ -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<string, RegisteredGroup>;
lastAgentTimestamps: Record<string, string>;
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)) {

View File

@@ -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;

View File

@@ -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,