mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 23:16:46 +00:00
214984f398
Adds an in-app assistant that reads and plans the open trip. Users connect their own provider (Sign in with ChatGPT, or an Anthropic, OpenAI, Gemini or OpenRouter key) or use the one the admin set up, including a custom OpenAI-compatible server. It is an addon and only shows while a connection is usable. The chat runs on the existing MCP tools, pinned to the trip. Every change is held as a change card the user applies or discards, and applied changes can be undone. On the desktop it is a floating window that can be moved and resized; on the phone it is fullscreen. Search results show as place cards that can go onto a day, weather lookups as a strip, proposed places as ghost markers on the map with a before/after switch, and an answer can be shared into the trip chat. Booking files can be dropped in and are read into change cards.
64 lines
3.0 KiB
TypeScript
64 lines
3.0 KiB
TypeScript
import { AssistantMessages } from '../../db/entities/AssistantMessages.entity';
|
|
import { AssistantThreads } from '../../db/entities/AssistantThreads.entity';
|
|
import { AssistantToolCalls } from '../../db/entities/AssistantToolCalls.entity';
|
|
import { AddonsModule } from '../addons/addons.module';
|
|
import { AiConnectionsModule } from '../ai-connections/ai-connections.module';
|
|
import { AuditModule } from '../audit/audit.module';
|
|
import { BookingImportModule } from '../booking-import/booking-import.module';
|
|
import { CollabModule } from '../collab/collab.module';
|
|
import { RateLimitModule } from '../common/rate-limit.module';
|
|
import { McpSharedModule } from '../mcp-shared/mcp-shared.module';
|
|
import { PermissionsModule } from '../permissions/permissions.module';
|
|
import { SchedulingModule } from '../scheduling/scheduling.module';
|
|
import { SettingsModule } from '../settings/settings.module';
|
|
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
|
|
import { AssistantAttachmentsController } from './assistant-attachments.controller';
|
|
import { AssistantBookingImportService } from './assistant-booking-import.service';
|
|
import { AssistantFoundPlacesService } from './assistant-found-places.service';
|
|
import { AssistantRetentionJob } from './assistant-retention.job';
|
|
import { AssistantShareService } from './assistant-share.service';
|
|
import { AssistantStreamRegistry, InMemoryAssistantStreamRegistry } from './assistant-stream.registry';
|
|
import { AssistantToolsService } from './assistant-tools.service';
|
|
import { AssistantController } from './assistant.controller';
|
|
import { AssistantService } from './assistant.service';
|
|
import { MikroOrmModule } from '@mikro-orm/nestjs';
|
|
import { Module } from '@nestjs/common';
|
|
|
|
/**
|
|
* The trip assistant: conversations about a trip, answered by the language
|
|
* model the user's connection reaches (AiConnectionsModule), working the trip
|
|
* through the MCP tools of the global registry. A file attached in the chat
|
|
* is read through the booking import, and an answer shared in the trip's
|
|
* chat is posted through the collab chat. Its conversations are kept per user
|
|
* and trip and swept by the retention job.
|
|
*/
|
|
@Module({
|
|
imports: [
|
|
AddonsModule,
|
|
AiConnectionsModule,
|
|
AuditModule,
|
|
BookingImportModule,
|
|
CollabModule,
|
|
McpSharedModule,
|
|
PermissionsModule,
|
|
RateLimitModule,
|
|
SchedulingModule,
|
|
SettingsModule,
|
|
TripMembershipModule,
|
|
MikroOrmModule.forFeature([AssistantThreads, AssistantMessages, AssistantToolCalls]),
|
|
],
|
|
controllers: [AssistantController, AssistantAttachmentsController],
|
|
// The running turns stay in this process's memory; a registry shared
|
|
// between processes would be provided here instead.
|
|
providers: [
|
|
AssistantService,
|
|
AssistantToolsService,
|
|
AssistantBookingImportService,
|
|
AssistantFoundPlacesService,
|
|
AssistantShareService,
|
|
AssistantRetentionJob,
|
|
{ provide: AssistantStreamRegistry, useClass: InMemoryAssistantStreamRegistry },
|
|
],
|
|
})
|
|
export class AssistantModule {}
|