feat(sessions): add unified /sessions/messages entry point

Add SessionsService#routeIncomingMessage: if the user has an active
non-completed session, route to its agent by status (only
objective_discovery is implemented so far - any other status rejects
with a clear 409 rather than failing silently); otherwise run the
intent router first and only create a session + start Agent 1 when it
detects a learning intent, replying as plain conversational Max
(PERSONALITY_PROMPT only, no session) otherwise.

Exposed as POST /sessions/messages (JWT-protected), the new single
entry point the chat window should call instead of unconditionally
creating a session on every message.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-11-01 08:57:29 +01:00
co-authored by Claude Sonnet 5
parent dc368a32f0
commit ce25d3f290
6 changed files with 237 additions and 2 deletions
@@ -0,0 +1,26 @@
import { ApiProperty } from '@nestjs/swagger';
import { ObjectiveDraftDto } from './objective-message-response.dto';
export class RouteMessageResponseDto {
@ApiProperty({
enum: ['chat', 'learn'],
description:
'"chat" : reponse conversationnelle, aucune session creee. "learn" : une session de formation est active (nouvelle ou existante).',
})
type!: 'chat' | 'learn';
@ApiProperty({ description: 'Reponse de Max a afficher dans le chat.' })
reply!: string;
@ApiProperty({
required: false,
description: 'Present uniquement si type="learn".',
})
sessionId?: number;
@ApiProperty({ required: false })
ready?: boolean;
@ApiProperty({ type: ObjectiveDraftDto, required: false })
draft?: ObjectiveDraftDto;
}