Files
gitmost/apps/server/src/core/ai-chat/ai-chat.module.ts
T
agent_coder 68899a2c2e feat(ai-chat): durable detached agent runs — phase 1 (#184/#234)
Squashed for a clean rebase onto develop (was 19 commits; the reviewer approved
the net diff at fb246080). Detaches an agent run from the HTTP request/browser
window: a run is a first-class lifecycle object (ai_chat_runs), a browser
disconnect no longer kills it, a concurrent-run insert-gate prevents double runs,
and a reopened chat live-follows a still-running run via a polled observer merge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-04 23:35:26 +03:00

54 lines
2.2 KiB
TypeScript

import { Module } from '@nestjs/common';
import { AiModule } from '../../integrations/ai/ai.module';
import { TokenModule } from '../auth/token.module';
import { AiChatController } from './ai-chat.controller';
import { AiChatService } from './ai-chat.service';
import { AiChatRunService } from './ai-chat-run.service';
import { AiTranscriptionService } from './ai-transcription.service';
import { AiChatToolsService } from './tools/ai-chat-tools.service';
import { EmbeddingModule } from './embedding/embedding.module';
import { ExternalMcpModule } from './external-mcp/external-mcp.module';
import { AiAgentRolesModule } from './roles/ai-agent-roles.module';
import { ShareModule } from '../share/share.module';
import { SearchModule } from '../search/search.module';
import { PublicShareChatController } from './public-share-chat.controller';
import { PublicShareChatService } from './public-share-chat.service';
import { PublicShareChatToolsService } from './tools/public-share-chat-tools.service';
/**
* Per-user AI chat module (§6.1).
*
* AiModule supplies AiService + AiSettingsService. TokenModule supplies
* TokenService for minting the per-user loopback access token (§15[C1]). The
* AiChatRepo / AiChatMessageRepo / PageEmbeddingRepo / SpaceMemberRepo /
* PagePermissionRepo come from the global DatabaseModule; the UserThrottlerGuard
* + AI_CHAT throttler come from the global ThrottleModule registered in
* AppModule. EmbeddingModule hosts the vector-RAG indexer + AI_QUEUE consumer
* (§6.7 stage D); importing it here boots the processor with the app.
*
* ShareModule (ShareService) + SearchModule (SearchService) are imported for the
* ANONYMOUS public-share assistant (PublicShareChatController), whose read-only
* tools scope every lookup to a single share tree.
*/
@Module({
imports: [
AiModule,
TokenModule,
EmbeddingModule,
ExternalMcpModule,
AiAgentRolesModule,
ShareModule,
SearchModule,
],
controllers: [AiChatController, PublicShareChatController],
providers: [
AiChatService,
AiChatRunService,
AiTranscriptionService,
AiChatToolsService,
PublicShareChatService,
PublicShareChatToolsService,
],
})
export class AiChatModule {}