Stabilize paired-room orchestration and Codex app-server flow
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
} from '../config.js';
|
||||
import { readEnvFile } from '../env.js';
|
||||
import { logger } from '../logger.js';
|
||||
import { formatOutbound } from '../router.js';
|
||||
|
||||
const ATTACHMENTS_DIR = path.join(DATA_DIR, 'attachments');
|
||||
const TRANSCRIPTION_CACHE_DIR = path.join(CACHE_DIR, 'transcriptions');
|
||||
@@ -158,6 +159,7 @@ import {
|
||||
AgentType,
|
||||
Channel,
|
||||
ChannelMeta,
|
||||
NewMessage,
|
||||
OnChatMetadata,
|
||||
OnInboundMessage,
|
||||
RegisteredGroup,
|
||||
@@ -446,6 +448,7 @@ export class DiscordChannel implements Channel {
|
||||
for (const [name, id] of Object.entries(mentionMap)) {
|
||||
cleaned = cleaned.replace(new RegExp(`@${name}`, 'g'), `<@${id}>`);
|
||||
}
|
||||
cleaned = formatOutbound(cleaned);
|
||||
|
||||
// Discord has a 2000 character limit per message — split if needed
|
||||
const MAX_LENGTH = 2000;
|
||||
@@ -454,6 +457,11 @@ export class DiscordChannel implements Channel {
|
||||
name: path.basename(f),
|
||||
}));
|
||||
|
||||
if (!cleaned && files.length === 0) {
|
||||
logger.debug({ jid }, 'Skipping empty Discord outbound message');
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaned.length <= MAX_LENGTH) {
|
||||
await textChannel.send({
|
||||
content: cleaned || undefined,
|
||||
@@ -490,6 +498,10 @@ export class DiscordChannel implements Channel {
|
||||
return groupType === this.agentTypeFilter;
|
||||
}
|
||||
|
||||
isOwnMessage(msg: NewMessage): boolean {
|
||||
return !!this.client?.user?.id && msg.sender === this.client.user.id;
|
||||
}
|
||||
|
||||
async disconnect(): Promise<void> {
|
||||
if (this.client) {
|
||||
this.client.destroy();
|
||||
|
||||
Reference in New Issue
Block a user