refactor: land approved runtime cleanup and room binding cutover

This commit is contained in:
ejclaw
2026-04-10 21:04:23 +09:00
parent ce3854745d
commit 4e05f60400
45 changed files with 636 additions and 637 deletions

View File

@@ -12,7 +12,6 @@ import {
clearChannelOwnerLease,
getAllChannelOwnerLeases,
getEffectiveRuntimeRoomMode,
getRegisteredAgentTypesForJid,
getStoredRoomSettings,
type ChannelOwnerLeaseRow,
} from './db.js';
@@ -103,32 +102,14 @@ function normalizeLeaseRow(
};
}
function inferFallbackOwnerAgentType(
hasClaude: boolean,
hasCodex: boolean,
): AgentType | undefined {
if (hasClaude && hasCodex) return OWNER_AGENT_TYPE;
if (hasCodex) return 'codex';
if (hasClaude) return 'claude-code';
return undefined;
}
function resolveDefaultOwnerAgentType(chatJid: string): AgentType | undefined {
const storedOwnerAgentType = getStoredRoomSettings(chatJid)?.ownerAgentType;
if (storedOwnerAgentType) {
return storedOwnerAgentType;
}
const types = getRegisteredAgentTypesForJid(chatJid);
const hasClaude = types.includes('claude-code');
const hasCodex = types.includes('codex');
return inferFallbackOwnerAgentType(hasClaude, hasCodex);
return getStoredRoomSettings(chatJid)?.ownerAgentType;
}
function getDefaultLease(chatJid: string): EffectiveChannelLease {
const roomMode = getEffectiveRuntimeRoomMode(chatJid);
const ownerAgentType = resolveDefaultOwnerAgentType(chatJid) ?? 'claude-code';
const ownerAgentType =
resolveDefaultOwnerAgentType(chatJid) ?? OWNER_AGENT_TYPE;
const rolePlan = resolveRoleAgentPlan({
paired: roomMode === 'tribunal',
groupAgentType: ownerAgentType,