feat(ms22-p2): add Discord channel → agent routing
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

- Add DISCORD_AGENT_CHANNELS env var for channel-to-agent mapping
- Route messages in agent channels to specific agents via ChatProxyService
- Handle SSE streaming responses and Discord's 2000 char limit
- Add workspace owner lookup for chat proxy authentication
- Add comprehensive unit tests for agent channel routing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 08:02:10 -06:00
parent e85fb11f03
commit c53a4a4c7d
6 changed files with 438 additions and 5 deletions

View File

@@ -28,6 +28,7 @@ import { StitcherService } from "../../stitcher/stitcher.service";
import { HeraldService } from "../../herald/herald.service";
import { PrismaService } from "../../prisma/prisma.service";
import { BullMqService } from "../../bullmq/bullmq.service";
import { ChatProxyService } from "../../chat-proxy/chat-proxy.service";
import type { IChatProvider } from "../interfaces";
import { JOB_CREATED, JOB_STARTED } from "../../job-events/event-types";
@@ -192,6 +193,7 @@ function setDiscordEnv(): void {
function setEncryptionKey(): void {
process.env.ENCRYPTION_KEY = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
process.env.MOSAIC_SECRET_KEY = "test-mosaic-secret-key-minimum-32-characters-long";
}
/**
@@ -205,6 +207,10 @@ async function compileBridgeModule(): Promise<TestingModule> {
.useValue({})
.overrideProvider(BullMqService)
.useValue({})
.overrideProvider(ChatProxyService)
.useValue({
proxyChat: vi.fn().mockResolvedValue(new Response()),
})
.compile();
}