All files / src/llm-responses llm-responses.controller.ts

82.35% Statements 14/17
100% Branches 0/0
50% Functions 2/4
80% Lines 12/15

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 676x 6x 6x 6x 6x 6x       6x 6x                       6x 2x                           6x                                         6x                
import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { LlmResponsesService } from './llm-responses.service';
import { SubmitLlmResponseDto } from './dto/submit-llm-response.dto';
import { SessionInput } from '../core-entities';
import { SyncConversationDto } from './dto/sync-conversation.dto';
 
@ApiTags('llm-responses')
@Controller('llm-responses')
export class LlmResponsesController {
  constructor(private readonly llmResponsesService: LlmResponsesService) {}
 
  @Post('submit')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({
    summary: 'Submit LLM response from integrated provider for orchestration',
  })
  @ApiResponse({
    status: 200,
    description: 'Response processed and actions created',
    type: SessionInput,
  })
  async submit(@Body() dto: SubmitLlmResponseDto): Promise<SessionInput> {
    return this.llmResponsesService.submit(dto);
  }
 
  @Post('submit-external')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({
    summary:
      'Submit LLM response from external source (userscript/manual mode)',
  })
  @ApiResponse({
    status: 200,
    description: 'External response processed',
    type: SessionInput,
  })
  async submitExternal(
    @Body() dto: SubmitLlmResponseDto,
  ): Promise<SessionInput> {
    return this.llmResponsesService.submitExternal(dto);
  }
 
  @Post('sync-conversation')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({
    summary: 'Sync full conversation history from external source',
  })
  @ApiResponse({
    status: 200,
    description: 'Conversation synced',
    schema: {
      properties: {
        status: { type: 'string' },
        sessionId: { type: 'string', format: 'uuid' },
      },
    },
  })
  async syncConversation(@Body() dto: SyncConversationDto): Promise<{
    status: string;
    sessionId: string;
  }> {
    const sessionId = await this.llmResponsesService.syncConversation(dto);
    return { status: 'ok', sessionId };
  }
}