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:
@@ -4,7 +4,7 @@
|
||||
* channel record (chats) and its message history (messages).
|
||||
*
|
||||
* Usage:
|
||||
* bun scripts/deregister-room.ts [--dry-run] [--force] [--no-backup] <channelId|jid> [more...]
|
||||
* bun scripts/deregister-room.ts [--dry-run] [--no-backup] <channelId|jid> [more...]
|
||||
*
|
||||
* What it removes for each target chat:
|
||||
* - room registration + role/skill overrides + channel owner lease
|
||||
@@ -20,7 +20,6 @@
|
||||
* startup), e.g. `systemctl --user restart ejclaw.service`.
|
||||
*
|
||||
* Safety:
|
||||
* - refuses to deregister a main room unless --force
|
||||
* - a group folder shared by another remaining room is NOT deleted on disk
|
||||
* (only that chat's DB rows are removed)
|
||||
* - --dry-run reports what would change without writing anything
|
||||
@@ -38,13 +37,12 @@ import { signalEjclawReload } from '../src/runtime-reload-signal.js';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const dryRun = args.includes('--dry-run');
|
||||
const force = args.includes('--force');
|
||||
const noBackup = args.includes('--no-backup');
|
||||
const ids = args.filter((a) => !a.startsWith('--'));
|
||||
|
||||
if (ids.length === 0) {
|
||||
console.error(
|
||||
'Usage: bun scripts/deregister-room.ts [--dry-run] [--force] [--no-backup] <channelId|jid> [more...]',
|
||||
'Usage: bun scripts/deregister-room.ts [--dry-run] [--no-backup] <channelId|jid> [more...]',
|
||||
);
|
||||
process.exit(2);
|
||||
}
|
||||
@@ -62,7 +60,6 @@ const db = new Database(path.join(STORE_DIR, 'messages.db'));
|
||||
interface Target {
|
||||
jid: string;
|
||||
folders: string[];
|
||||
isMain: boolean;
|
||||
name: string | null;
|
||||
registered: boolean;
|
||||
}
|
||||
@@ -92,30 +89,17 @@ function backtraceFolders(jid: string): string[] {
|
||||
|
||||
const targets: Target[] = jids.map((jid) => {
|
||||
const r = db
|
||||
.query('SELECT folder, is_main, name FROM room_settings WHERE chat_jid=?')
|
||||
.get(jid) as
|
||||
| { folder: string | null; is_main: number | null; name: string | null }
|
||||
| undefined;
|
||||
.query('SELECT folder, name FROM room_settings WHERE chat_jid=?')
|
||||
.get(jid) as { folder: string | null; name: string | null } | undefined;
|
||||
const folders = r?.folder ? [r.folder] : backtraceFolders(jid);
|
||||
return {
|
||||
jid,
|
||||
folders,
|
||||
isMain: r?.is_main === 1,
|
||||
name: r?.name ?? null,
|
||||
registered: Boolean(r),
|
||||
};
|
||||
});
|
||||
|
||||
const mainTargets = targets.filter((t) => t.isMain);
|
||||
if (mainTargets.length && !force) {
|
||||
console.error(
|
||||
'Refusing to deregister main room(s):',
|
||||
mainTargets.map((t) => t.jid).join(', '),
|
||||
'\nPass --force only if you really intend to unregister the main control room.',
|
||||
);
|
||||
process.exit(3);
|
||||
}
|
||||
|
||||
const targetJidSet = new Set(jids);
|
||||
function folderShared(folder: string): boolean {
|
||||
const rows = db
|
||||
@@ -136,7 +120,7 @@ for (const t of targets) {
|
||||
console.log('=== targets ===');
|
||||
for (const t of targets) {
|
||||
console.log(
|
||||
` ${t.jid} | name=${t.name ?? '(unregistered)'} | folder=${t.folders.length ? t.folders.join(',') : '-'} | registered=${t.registered}${t.isMain ? ' | MAIN' : ''}`,
|
||||
` ${t.jid} | name=${t.name ?? '(unregistered)'} | folder=${t.folders.length ? t.folders.join(',') : '-'} | registered=${t.registered}`,
|
||||
);
|
||||
}
|
||||
if (sharedFolders.size) {
|
||||
@@ -165,7 +149,7 @@ const scheduledTaskIds = (
|
||||
const qS = scheduledTaskIds.map(() => '?').join(',');
|
||||
const safeFolderList = [...safeFolders];
|
||||
|
||||
const count = (t: string, where: string, a: unknown[]): number =>
|
||||
const count = (t: string, where: string, a: string[]): number =>
|
||||
(
|
||||
db.query(`SELECT COUNT(*) n FROM ${t} WHERE ${where}`).get(...a) as {
|
||||
n: number;
|
||||
|
||||
Reference in New Issue
Block a user