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:
@@ -203,7 +203,6 @@ class ClaudeQueryRunner {
|
||||
ejclaw: buildEjclawMcpServerConfig(this.args.mcpServerPath, {
|
||||
chatJid: this.args.runnerInput.chatJid,
|
||||
groupFolder: this.args.runnerInput.groupFolder,
|
||||
isMain: this.args.runnerInput.isMain,
|
||||
agentType: process.env[EJCLAW_ENV.agentType] || 'claude-code',
|
||||
roomRole: this.args.runnerInput.roomRoleContext?.role || '',
|
||||
ipcDir: process.env[EJCLAW_ENV.ipcDir],
|
||||
|
||||
@@ -45,7 +45,6 @@ const REPO_ROOT = process.env[EJCLAW_ENV.workDir] || process.cwd();
|
||||
// Context from environment variables (set by the agent runner)
|
||||
const chatJid = process.env[EJCLAW_ENV.chatJid]!;
|
||||
const groupFolder = process.env[EJCLAW_ENV.groupFolder]!;
|
||||
const isMain = process.env[EJCLAW_ENV.isMain] === '1';
|
||||
const agentType = process.env[EJCLAW_ENV.agentType] || 'claude-code';
|
||||
const roomRole = process.env[EJCLAW_ENV.roomRole];
|
||||
const runtimeTaskId = process.env[EJCLAW_ENV.runtimeTaskId];
|
||||
@@ -152,12 +151,6 @@ SCHEDULE VALUE FORMAT (all times are LOCAL timezone):
|
||||
.describe(
|
||||
'group=runs with chat history and memory, isolated=fresh session (include context in prompt). Default: group.',
|
||||
),
|
||||
target_group_jid: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
'(Main group only) JID of the group to schedule the task for. Defaults to the current group.',
|
||||
),
|
||||
},
|
||||
async (args) => {
|
||||
// Validate schedule_value before writing IPC
|
||||
@@ -217,9 +210,8 @@ SCHEDULE VALUE FORMAT (all times are LOCAL timezone):
|
||||
}
|
||||
}
|
||||
|
||||
// Non-main groups can only schedule for themselves
|
||||
const targetJid =
|
||||
isMain && args.target_group_jid ? args.target_group_jid : chatJid;
|
||||
// A room can only schedule tasks for itself.
|
||||
const targetJid = chatJid;
|
||||
|
||||
const taskId = `task-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
||||
|
||||
@@ -310,12 +302,6 @@ server.tool(
|
||||
.describe(
|
||||
'group=runs with chat history and memory, isolated=fresh session (include all context in check_instructions). Default: isolated.',
|
||||
),
|
||||
target_group_jid: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
'(Main group only) JID of the group to schedule the watcher for. Defaults to the current group.',
|
||||
),
|
||||
},
|
||||
async (args) => {
|
||||
if (roomRole && roomRole !== 'owner') {
|
||||
@@ -398,8 +384,7 @@ server.tool(
|
||||
};
|
||||
}
|
||||
|
||||
const targetJid =
|
||||
isMain && args.target_group_jid ? args.target_group_jid : chatJid;
|
||||
const targetJid = chatJid;
|
||||
const taskId = `task-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
||||
const prompt = buildCiWatchPrompt({
|
||||
target,
|
||||
@@ -511,7 +496,7 @@ registerRepoEvidenceTool(server, REPO_ROOT);
|
||||
|
||||
server.tool(
|
||||
'list_tasks',
|
||||
"List all scheduled tasks. From main: shows all tasks. From other groups: shows only that group's tasks.",
|
||||
'List the scheduled tasks of this room.',
|
||||
{},
|
||||
async () => {
|
||||
const tasksFile = path.join(IPC_DIR, 'current_tasks.json');
|
||||
@@ -527,11 +512,9 @@ server.tool(
|
||||
|
||||
const allTasks = JSON.parse(fs.readFileSync(tasksFile, 'utf-8'));
|
||||
|
||||
const tasks = isMain
|
||||
? allTasks
|
||||
: allTasks.filter(
|
||||
(t: { groupFolder: string }) => t.groupFolder === groupFolder,
|
||||
);
|
||||
const tasks = allTasks.filter(
|
||||
(t: { groupFolder: string }) => t.groupFolder === groupFolder,
|
||||
);
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return {
|
||||
@@ -582,7 +565,6 @@ server.tool(
|
||||
type: 'pause_task',
|
||||
taskId: args.task_id,
|
||||
groupFolder,
|
||||
isMain,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
|
||||
@@ -608,7 +590,6 @@ server.tool(
|
||||
type: 'resume_task',
|
||||
taskId: args.task_id,
|
||||
groupFolder,
|
||||
isMain,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
|
||||
@@ -652,7 +633,6 @@ server.tool(
|
||||
type: 'cancel_task',
|
||||
taskId: resolvedId,
|
||||
groupFolder,
|
||||
isMain,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
|
||||
@@ -728,7 +708,6 @@ if (allowGenericScheduling) {
|
||||
type: 'update_task',
|
||||
taskId: args.task_id,
|
||||
groupFolder,
|
||||
isMain: String(isMain),
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
if (args.prompt !== undefined) data.prompt = args.prompt;
|
||||
@@ -751,113 +730,6 @@ if (allowGenericScheduling) {
|
||||
);
|
||||
}
|
||||
|
||||
server.tool(
|
||||
'assign_room',
|
||||
`Assign or update a room using room-level settings. Main group only.
|
||||
|
||||
If folder is omitted, the host generates one automatically.`,
|
||||
{
|
||||
jid: z
|
||||
.string()
|
||||
.describe(
|
||||
'The chat JID (e.g., "120363336345536173@g.us", "tg:-1001234567890", "dc:1234567890123456")',
|
||||
),
|
||||
name: z.string().describe('Display name for the room'),
|
||||
room_mode: z
|
||||
.enum(['single', 'tribunal'])
|
||||
.default('tribunal')
|
||||
.describe(
|
||||
'single=owner only, tribunal=owner/reviewer roles enabled (default)',
|
||||
),
|
||||
owner_agent_type: z
|
||||
.enum(['claude-code', 'codex'])
|
||||
.optional()
|
||||
.describe('Preferred owner agent type for the room'),
|
||||
reviewer_agent_type: z
|
||||
.enum(['claude-code', 'codex'])
|
||||
.optional()
|
||||
.describe('Optional reviewer agent type override for tribunal rooms'),
|
||||
arbiter_agent_type: z
|
||||
.enum(['claude-code', 'codex'])
|
||||
.optional()
|
||||
.describe('Optional arbiter agent type override for tribunal rooms'),
|
||||
folder: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
'Optional folder override. If omitted, the host generates one automatically.',
|
||||
),
|
||||
trigger: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe('Optional canonical trigger label to store for the room'),
|
||||
requires_trigger: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe('Whether direct trigger mention is required'),
|
||||
is_main: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe('Whether this room is the privileged main control room'),
|
||||
work_dir: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe('Optional working directory override'),
|
||||
},
|
||||
async (args: {
|
||||
jid: string;
|
||||
name: string;
|
||||
room_mode?: 'single' | 'tribunal';
|
||||
owner_agent_type?: 'claude-code' | 'codex';
|
||||
reviewer_agent_type?: 'claude-code' | 'codex';
|
||||
arbiter_agent_type?: 'claude-code' | 'codex';
|
||||
folder?: string;
|
||||
trigger?: string;
|
||||
requires_trigger?: boolean;
|
||||
is_main?: boolean;
|
||||
work_dir?: string;
|
||||
}) => {
|
||||
if (!isMain) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text' as const,
|
||||
text: 'Only the main group can assign rooms.',
|
||||
},
|
||||
],
|
||||
isError: true,
|
||||
};
|
||||
}
|
||||
|
||||
const data = {
|
||||
type: 'assign_room',
|
||||
jid: args.jid,
|
||||
name: args.name,
|
||||
room_mode: args.room_mode || 'tribunal',
|
||||
owner_agent_type: args.owner_agent_type,
|
||||
reviewer_agent_type: args.reviewer_agent_type,
|
||||
arbiter_agent_type: args.arbiter_agent_type,
|
||||
folder: args.folder,
|
||||
trigger: args.trigger,
|
||||
requiresTrigger: args.requires_trigger,
|
||||
isMain: args.is_main,
|
||||
workDir: args.work_dir,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
|
||||
writeIpcFile(TASKS_DIR, data);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text' as const,
|
||||
text: `Room "${args.name}" assignment requested.`,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
// Start the stdio transport
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
|
||||
@@ -4,7 +4,6 @@ import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
||||
export interface EjclawMcpServerConfigInput {
|
||||
chatJid: string;
|
||||
groupFolder: string;
|
||||
isMain: boolean;
|
||||
agentType: string;
|
||||
roomRole: string;
|
||||
ipcDir?: string;
|
||||
@@ -22,7 +21,6 @@ export function buildEjclawMcpServerConfig(
|
||||
env: {
|
||||
[EJCLAW_ENV.chatJid]: input.chatJid,
|
||||
[EJCLAW_ENV.groupFolder]: input.groupFolder,
|
||||
[EJCLAW_ENV.isMain]: input.isMain ? '1' : '0',
|
||||
[EJCLAW_ENV.agentType]: input.agentType,
|
||||
[EJCLAW_ENV.roomRole]: input.roomRole,
|
||||
...(input.ipcDir && {
|
||||
|
||||
@@ -5,7 +5,6 @@ export interface RunnerInput {
|
||||
sessionId?: string;
|
||||
groupFolder: string;
|
||||
chatJid: string;
|
||||
isMain: boolean;
|
||||
isScheduledTask?: boolean;
|
||||
assistantName?: string;
|
||||
secrets?: Record<string, string>;
|
||||
|
||||
Reference in New Issue
Block a user