feat: add status dashboard for live agent monitoring

Dedicated Discord channel shows per-group agent status with live
elapsed time. Single message is edited every 10s instead of spamming.

- GroupQueue tracks startedAt timestamps and exposes getStatuses()
- Channel interface gets editMessage/sendAndTrack for message editing
- STATUS_CHANNEL_ID env var to configure the dashboard channel
- Shows processing/idle/waiting/inactive per registered group
This commit is contained in:
Eyejoker
2026-03-13 23:05:32 +09:00
parent 6a65136ff2
commit 27d4ea05dc
6 changed files with 175 additions and 0 deletions

View File

@@ -423,6 +423,37 @@ export class DiscordChannel implements Channel {
await sendOnce();
this.typingIntervals.set(jid, setInterval(sendOnce, 8000));
}
async sendAndTrack(jid: string, text: string): Promise<string | null> {
if (!this.client) return null;
try {
const channelId = jid.replace(/^dc:/, '');
const channel = await this.client.channels.fetch(channelId);
if (!channel || !('send' in channel)) return null;
const msg = await (channel as TextChannel).send(text);
return msg.id;
} catch (err) {
logger.error({ jid, err }, 'Failed to send tracked Discord message');
return null;
}
}
async editMessage(
jid: string,
messageId: string,
text: string,
): Promise<void> {
if (!this.client) return;
try {
const channelId = jid.replace(/^dc:/, '');
const channel = await this.client.channels.fetch(channelId);
if (!channel || !('messages' in channel)) return;
const msg = await (channel as TextChannel).messages.fetch(messageId);
await msg.edit(text);
} catch (err) {
logger.debug({ jid, messageId, err }, 'Failed to edit Discord message');
}
}
}
registerChannel('discord', (opts: ChannelOpts) => {