All files / src/sessions/dto session.dto.ts

100% Statements 42/42
100% Branches 2/2
100% Functions 1/1
100% Lines 42/42

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 22919x               19x 19x   19x 19x 19x 19x 19x     19x             19x           19x               19x               19x               19x               19x               19x               19x               19x               19x     19x         19x               19x               19x               19x               19x               19x               19x               19x               19x               19x     19x               19x     19x   19x     19x     19x     19x           19x     19x         19x           19x           19x    
import {
  IsString,
  IsOptional,
  IsUUID,
  IsEnum,
  MaxLength,
  IsUrl,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ReasoningEffort } from '../../llm-provider/llm-provider.interface';
 
export enum SessionStatus {
  ACTIVE = 'active',
  COMPLETED = 'completed',
  ABORTED = 'aborted',
  FAILED = 'failed',
}
 
export class CreateSessionDto {
  @ApiPropertyOptional({
    description: 'UUID of the associated project',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  project_id?: string;
 
  @ApiPropertyOptional({ description: 'Title of the session', maxLength: 255 })
  @IsOptional()
  @IsString()
  @MaxLength(255)
  session_title?: string;
 
  @ApiPropertyOptional({
    description: 'UUID of the system prompt to use',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  system_prompt_id?: string;
 
  @ApiPropertyOptional({
    description: 'UUID of the default initial context template',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  default_initial_context_template_id?: string;
 
  @ApiPropertyOptional({
    description: 'UUID of the default followup context template',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  default_followup_context_template_id?: string;
 
  @ApiPropertyOptional({
    description: 'External URL (e.g., AI Studio or Claude chat URL)',
    example: 'https://claude.ai/chat/abc123',
  })
  @IsOptional()
  @IsUrl()
  url?: string;
 
  @ApiPropertyOptional({
    description: 'Model identifier to use for this session',
    example: 'gemini-2.0-flash',
  })
  @IsOptional()
  @IsString()
  model_id?: string;
 
  @ApiPropertyOptional({
    description: 'Reasoning effort level',
    enum: ReasoningEffort,
  })
  @IsOptional()
  @IsEnum(ReasoningEffort)
  reasoning_effort?: ReasoningEffort;
 
  @ApiPropertyOptional({
    description: 'UUID of the sub-agent to use',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  sub_agent_id?: string;
 
  @ApiPropertyOptional({
    description: 'UUID of the parent session (for follow-up sessions)',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  parent_session_id?: string;
}
 
export class UpdateSessionDto {
  @ApiPropertyOptional({ description: 'Title of the session', maxLength: 255 })
  @IsOptional()
  @IsString()
  @MaxLength(255)
  session_title?: string;
 
  @ApiPropertyOptional({
    description: 'Status of the session',
    enum: SessionStatus,
  })
  @IsOptional()
  @IsEnum(SessionStatus)
  status?: SessionStatus;
 
  @ApiPropertyOptional({
    description: 'UUID of the system prompt to use',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  system_prompt_id?: string;
 
  @ApiPropertyOptional({
    description: 'UUID of the default initial context template',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  default_initial_context_template_id?: string;
 
  @ApiPropertyOptional({
    description: 'UUID of the default followup context template',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  default_followup_context_template_id?: string;
 
  @ApiPropertyOptional({
    description: 'External URL (e.g., AI Studio or Claude chat URL)',
    example: 'https://claude.ai/chat/abc123',
  })
  @IsOptional()
  @IsUrl()
  url?: string;
 
  @ApiPropertyOptional({
    description: 'Model identifier to use for this session',
    example: 'gemini-2.0-flash',
  })
  @IsOptional()
  @IsString()
  model_id?: string;
 
  @ApiPropertyOptional({
    description: 'Reasoning effort level',
    enum: ReasoningEffort,
  })
  @IsOptional()
  @IsEnum(ReasoningEffort)
  reasoning_effort?: ReasoningEffort;
 
  @ApiPropertyOptional({
    description: 'UUID of the sub-agent to use',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  sub_agent_id?: string;
 
  @ApiPropertyOptional({
    description: 'UUID of the parent session (for follow-up sessions)',
    format: 'uuid',
  })
  @IsOptional()
  @IsUUID()
  parent_session_id?: string;
}
 
export class CreateSessionFromContextDto {
  @ApiPropertyOptional({
    description: 'Title for the new session',
    maxLength: 255,
  })
  @IsOptional()
  @IsString()
  @MaxLength(255)
  session_title?: string;
}
 
export class ImportSessionResponseDto {
  @ApiProperty({ description: 'Success message' })
  message: string;
 
  @ApiProperty({ description: 'UUID of the imported session', format: 'uuid' })
  session_id: string;
 
  @ApiProperty({ description: 'Number of messages imported' })
  message_count: number;
}
 
export class RevertFileDto {
  @ApiProperty({
    description: 'Path of the file to revert (relative to project root)',
    example: 'src/utils/auth.ts',
  })
  @IsString()
  file_path: string;
}
 
export class RevertSessionResponseDto {
  @ApiProperty({
    description: 'List of file paths that were successfully reverted',
    type: [String],
  })
  reverted: string[];
 
  @ApiProperty({
    description: 'List of file paths that failed to revert',
    type: [String],
  })
  failed: string[];
 
  @ApiProperty({
    description: 'Error messages for failed reverts',
    type: [String],
  })
  errors: string[];
}