"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var StreamingController_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamingController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const chat_service_1 = require("./chat.service");
let StreamingController = StreamingController_1 = class StreamingController {
    constructor(chatService) {
        this.chatService = chatService;
        this.logger = new common_1.Logger(StreamingController_1.name);
    }
    async stopStreaming(sessionId) {
        const aborted = this.chatService.abortStreaming(sessionId);
        return { success: true, aborted };
    }
    async cancelRequest(sessionId) {
        this.logger.log(`Cancel request received for session: ${sessionId}`);
        const cancelled = this.chatService.cancelRequest(sessionId);
        this.logger.log(`Cancel request result: ${cancelled}`);
        return { success: true, cancelled };
    }
};
exports.StreamingController = StreamingController;
__decorate([
    (0, common_1.Post)(':sessionId/stop'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({
        summary: 'Stop streaming response',
        description: 'Stops the active LLM streaming response for a session. The current chunk will complete but no new chunks will be sent.',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Streaming stopped',
        schema: {
            properties: {
                success: { type: 'boolean', example: true },
                aborted: {
                    type: 'boolean',
                    description: 'Whether streaming was active and aborted',
                },
            },
        },
    }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], StreamingController.prototype, "stopStreaming", null);
__decorate([
    (0, common_1.Post)(':sessionId/cancel'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({
        summary: 'Cancel LLM request',
        description: 'Cancels the ongoing LLM request for a session. More aggressive than stop - aborts the entire request.',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Request cancelled',
        schema: {
            properties: {
                success: { type: 'boolean', example: true },
                cancelled: {
                    type: 'boolean',
                    description: 'Whether a request was active and cancelled',
                },
            },
        },
    }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], StreamingController.prototype, "cancelRequest", null);
exports.StreamingController = StreamingController = StreamingController_1 = __decorate([
    (0, swagger_1.ApiTags)('streaming'),
    (0, common_1.Controller)('streaming'),
    __metadata("design:paramtypes", [chat_service_1.ChatService])
], StreamingController);
//# sourceMappingURL=streaming.controller.js.map