feat(sessions): wire Agents 2-4 into the pipeline orchestration

confirmObjective() now chains Agent 2 (mapping) then starts Agent 3
(level) synchronously after Agent 1 confirms - by the time the HTTP
response returns, session.status is already "level_assessment" and
the response carries Agent 3's first question in a new "nextPrompt"
field, to be spoken aloud (never displayed as text).

New endpoints: POST /sessions/:id/level/confirm (runs Agent 4, advances
to "planning") and POST /sessions/:id/level/dispute. routeIncomingMessage
dispatches "level_assessment" sessions to LevelAgent.converse(), same
single entry point used for text and voice.

RouteMessageResponseDto gains levelDone/levelProfile fields: every
response field is a structured, typed signal the frontend's main
process can branch on to decide whether to open a result window - never
an instruction embedded in the LLM's reply text.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-11-02 09:48:10 +01:00
co-authored by Claude Sonnet 5
parent 5c00976e8f
commit 755bc07d18
10 changed files with 459 additions and 7 deletions
@@ -18,6 +18,8 @@ import {
} from '@nestjs/swagger';
import type { AuthenticatedRequest } from '../auth/jwt-auth.guard';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { LevelDisputeDto } from './dto/level-dispute.dto';
import { LevelProfileResponseDto } from './dto/level-profile-response.dto';
import { ObjectiveMessageResponseDto } from './dto/objective-message-response.dto';
import { RouteMessageResponseDto } from './dto/route-message-response.dto';
import { SendObjectiveMessageDto } from './dto/send-objective-message.dto';
@@ -112,4 +114,40 @@ export class SessionsController {
): Promise<SessionObjectiveResponseDto> {
return this.sessionsService.confirmObjective(id, request.user.sub);
}
@Post(':id/level/confirm')
@HttpCode(HttpStatus.OK)
@ApiOperation({
summary:
"Confirmer le profil de niveau (Agent 3) et declencher l'Agent 4 (Recherche Approfondie)",
})
@ApiResponse({ status: HttpStatus.OK })
@ApiResponse({
status: HttpStatus.CONFLICT,
description: "Cette session n'est plus a l'etape d'evaluation de niveau",
})
confirmLevel(
@Param('id', ParseIntPipe) id: number,
@Req() request: AuthenticatedRequest,
): Promise<void> {
return this.sessionsService.confirmLevel(id, request.user.sub);
}
@Post(':id/level/dispute')
@ApiOperation({
summary:
'Contester un concept du profil de niveau (Agent 3) avec une reponse argumentee, met a jour le profil stocke',
})
@ApiResponse({ status: HttpStatus.CREATED, type: LevelProfileResponseDto })
@ApiResponse({
status: HttpStatus.CONFLICT,
description: "Cette session n'est plus a l'etape d'evaluation de niveau",
})
disputeLevel(
@Param('id', ParseIntPipe) id: number,
@Body() dto: LevelDisputeDto,
@Req() request: AuthenticatedRequest,
): Promise<LevelProfileResponseDto> {
return this.sessionsService.disputeLevel(id, request.user.sub, dto);
}
}