refactor: remove the main room concept
No room has room_settings.is_main = 1, so every main-only path was dead, and admin work is done from the host shell. Each room's agent may now only act on its own room: - IPC: messages/inbound injection only to the source room; schedule, update, pause, resume and cancel only for the source room's tasks; drop the assign_room and refresh_groups IPC tasks and the deps they needed (assignRoom/syncGroups/getAvailableGroups/writeGroupsSnapshot) - DB/host evidence is always scoped to the source group folder - runner MCP server: drop the assign_room tool, the target_group_jid parameters and the isMain flag; list_tasks shows only the room's tasks - drop EJCLAW_IS_MAIN, RunnerInput.isMain and AgentInput.isMain; the global CLAUDE.md memory is now included for every room - drop the available_groups.json snapshot (available-groups.ts), the inferred restart announcement that only went to the main room, and the unused Channel.syncGroups hook - setup register: drop --is-main; deregister-room: drop the main-room refusal and --force, and fix its unknown[] binding type error - remove the groups/main/ template The room_settings.is_main column and migrations are untouched; new rows get the column default (0) and nothing reads it anymore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
60
src/index.ts
60
src/index.ts
@@ -17,7 +17,6 @@ import {
|
||||
getChannelFactory,
|
||||
getRegisteredChannelNames,
|
||||
} from './channels/registry.js';
|
||||
import { writeGroupsSnapshot } from './agent-runner.js';
|
||||
import {
|
||||
hasRecentRestartAnnouncement,
|
||||
initDatabase,
|
||||
@@ -39,7 +38,6 @@ import {
|
||||
consumeRestartContext,
|
||||
getRecoverableInterruptedGroups,
|
||||
getInterruptedRecoveryCandidates,
|
||||
inferRecentRestartContext,
|
||||
type RestartContext,
|
||||
writeShutdownRestartContext,
|
||||
} from './restart-context.js';
|
||||
@@ -55,7 +53,7 @@ import {
|
||||
startUnifiedDashboard,
|
||||
} from './unified-dashboard.js';
|
||||
import { startUsagePrimer } from './usage-primer.js';
|
||||
import { Channel, NewMessage, RegisteredGroup } from './types.js';
|
||||
import { Channel, NewMessage } from './types.js';
|
||||
import { logger } from './logger.js';
|
||||
import { initCodexTokenRotation } from './codex-token-rotation.js';
|
||||
import {
|
||||
@@ -153,21 +151,6 @@ async function deliverFormattedCanonicalMessage(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available groups list for the agent.
|
||||
* Returns groups ordered by most recent activity.
|
||||
*/
|
||||
export function getAvailableGroups(): import('./agent-runner.js').AvailableGroup[] {
|
||||
return runtimeState.getAvailableGroups();
|
||||
}
|
||||
|
||||
/** @internal - exported for testing */
|
||||
export function _setRegisteredGroups(
|
||||
groups: Record<string, RegisteredGroup>,
|
||||
): void {
|
||||
runtimeState.setRoomBindings(groups);
|
||||
}
|
||||
|
||||
async function tryDeliverRestartAnnouncement(
|
||||
chatJid: string,
|
||||
rawText: string,
|
||||
@@ -225,31 +208,6 @@ async function announceRestartRecovery(
|
||||
return explicitContext;
|
||||
}
|
||||
|
||||
const inferred = inferRecentRestartContext(
|
||||
runtimeState.getRoomBindings(),
|
||||
processStartedAtMs,
|
||||
);
|
||||
if (!inferred) return null;
|
||||
|
||||
if (hasRecentRestartAnnouncement(inferred.chatJid, dedupeSince)) {
|
||||
logger.info(
|
||||
{ chatJid: inferred.chatJid },
|
||||
'Skipped duplicate inferred restart recovery announcement',
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
await tryDeliverRestartAnnouncement(
|
||||
inferred.chatJid,
|
||||
inferred.lines.join('\n'),
|
||||
)
|
||||
) {
|
||||
logger.info(
|
||||
{ chatJid: inferred.chatJid },
|
||||
'Sent inferred restart recovery announcement',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -335,11 +293,7 @@ async function main(): Promise<void> {
|
||||
pendingMessages: status.pendingMessages,
|
||||
pendingTasks: status.pendingTasks,
|
||||
}));
|
||||
const writtenPaths = writeShutdownRestartContext(
|
||||
roomBindings,
|
||||
interruptedGroups,
|
||||
signal,
|
||||
);
|
||||
const writtenPaths = writeShutdownRestartContext(interruptedGroups, signal);
|
||||
if (writtenPaths.length > 0) {
|
||||
logger.info(
|
||||
{
|
||||
@@ -508,16 +462,6 @@ async function main(): Promise<void> {
|
||||
},
|
||||
nudgeScheduler: nudgeSchedulerLoop,
|
||||
roomBindings: runtimeState.getRoomBindings,
|
||||
assignRoom: runtimeState.assignRoomForIpc,
|
||||
syncGroups: async (force: boolean) => {
|
||||
await Promise.all(
|
||||
channels
|
||||
.filter((ch) => ch.syncGroups)
|
||||
.map((ch) => ch.syncGroups!(force)),
|
||||
);
|
||||
},
|
||||
getAvailableGroups,
|
||||
writeGroupsSnapshot,
|
||||
});
|
||||
queue.setProcessMessagesFn(runtime.processGroupMessages);
|
||||
queue.enterRecoveryMode();
|
||||
|
||||
Reference in New Issue
Block a user