feat(sessions): implement Agent 1 (Objectif) of the coach pipeline
Add the sessions module (create/fetch session, Agent 1 conversation and confirmation endpoints, all JWT-protected) and a reusable OpenRouter client with DeepSeek/Qwen fallback + backoff on rate-limit/timeout. Agent 1 runs a Socratic dialogue to capture the 3 mandatory pillars (subject, professional goal, duration) and enforces two guardrail levels before any explicit user confirmation: level 1 is hard-coded length/format rules (objective-guardrails.ts), level 2 is an LLM coherence score across 3 dimensions (reject below 0.6). The objective is only persisted to session_objective, and the session only moves to objective_validated, once the user explicitly confirms via POST /sessions/:id/objective/confirm - never on the LLM's say-so alone. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b321dff3bd
commit
bae5ace70c
@@ -0,0 +1,24 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ObjectiveDraftDto {
|
||||
@ApiProperty() subject!: string;
|
||||
@ApiProperty() professionalGoal!: string;
|
||||
@ApiProperty() duration!: string;
|
||||
}
|
||||
|
||||
export class ObjectiveMessageResponseDto {
|
||||
@ApiProperty({
|
||||
description:
|
||||
"Prochaine question de Max, ou recapitulatif si l'objectif est pret.",
|
||||
})
|
||||
reply!: string;
|
||||
|
||||
@ApiProperty({
|
||||
description:
|
||||
'true si les 3 piliers sont valides (garde-fous niveau 1 et 2) et prets a etre confirmes via POST /sessions/:id/objective/confirm.',
|
||||
})
|
||||
ready!: boolean;
|
||||
|
||||
@ApiProperty({ type: ObjectiveDraftDto, required: false })
|
||||
draft?: ObjectiveDraftDto;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString, MaxLength, MinLength } from 'class-validator';
|
||||
|
||||
export class SendObjectiveMessageDto {
|
||||
@ApiProperty({
|
||||
example: 'Je voudrais apprendre a mieux facturer mes clients',
|
||||
})
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(2000)
|
||||
message!: string;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class SessionObjectiveResponseDto {
|
||||
@ApiProperty() id!: number;
|
||||
@ApiProperty() sessionId!: number;
|
||||
@ApiProperty() subject!: string;
|
||||
@ApiProperty() professionalGoal!: string;
|
||||
@ApiProperty() duration!: string;
|
||||
@ApiProperty() validatedAt!: Date;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { SessionStatus } from '@prisma/client';
|
||||
import { SessionObjectiveResponseDto } from './session-objective-response.dto';
|
||||
|
||||
export class SessionResponseDto {
|
||||
@ApiProperty() id!: number;
|
||||
@ApiProperty({ enum: SessionStatus }) status!: SessionStatus;
|
||||
@ApiProperty() createdAt!: Date;
|
||||
@ApiProperty() updatedAt!: Date;
|
||||
@ApiProperty({ type: SessionObjectiveResponseDto, required: false })
|
||||
objective?: SessionObjectiveResponseDto;
|
||||
}
|
||||
Reference in New Issue
Block a user