feat: unify 3 bot services into single process

- Add UNIFIED_MODE flag (default on, disable with UNIFIED_MODE=0)
- Register all 3 Discord bots in one process (claude, codex, review)
- Load all registered groups regardless of agent_type (codex/owner priority)
- Start credential proxy and container cleanup at unified startup
- shouldServiceProcessChat returns true in unified mode
- Add findChannelByName for role-based response routing
- Backward compatible: UNIFIED_MODE=0 restores per-service behavior
This commit is contained in:
Eyejoker
2026-03-29 18:22:57 +09:00
parent fc9f2867b9
commit d01f98bd61
20 changed files with 118 additions and 759 deletions

View File

@@ -726,12 +726,18 @@ registerChannel('discord', (opts: ChannelOpts) => {
);
});
// Only register the secondary Codex bot channel when running as the primary (claude-code) service.
// The codex service uses its own DISCORD_BOT_TOKEN via systemd EnvironmentFile override.
if ((process.env.ASSISTANT_NAME || 'claude') !== 'codex') {
registerChannel('discord-codex', (opts: ChannelOpts) => {
const token = getEnv('DISCORD_CODEX_BOT_TOKEN') || '';
if (!token) return null; // Codex Discord bot is optional
return new DiscordChannel(token, opts, 'codex');
});
}
// Register the secondary Codex bot channel.
// In unified mode all bots register unconditionally; in legacy per-service mode
// the codex service uses its own DISCORD_BOT_TOKEN via systemd EnvironmentFile override.
registerChannel('discord-codex', (opts: ChannelOpts) => {
const token = getEnv('DISCORD_CODEX_BOT_TOKEN') || '';
if (!token) return null; // Codex Discord bot is optional
return new DiscordChannel(token, opts, 'codex');
});
// Register the review bot channel (codex agent type, separate token).
registerChannel('discord-review', (opts: ChannelOpts) => {
const token = getEnv('DISCORD_REVIEW_BOT_TOKEN') || '';
if (!token) return null; // Review Discord bot is optional
return new DiscordChannel(token, opts, 'codex');
});