"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionInput = void 0;
const typeorm_1 = require("typeorm");
const swagger_1 = require("@nestjs/swagger");
const base_entity_1 = require("./base.entity");
const session_entity_1 = require("./session.entity");
const context_template_entity_1 = require("./context-template.entity");
const ai_action_entity_1 = require("./ai-action.entity");
const enums_1 = require("./enums");
let SessionInput = class SessionInput extends base_entity_1.BaseEntity {
};
exports.SessionInput = SessionInput;
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Sequence number within session (for ordering)',
        example: 1,
    }),
    (0, typeorm_1.Column)({ type: 'integer', nullable: true }),
    __metadata("design:type", Number)
], SessionInput.prototype, "sequence_number", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'UUID of the parent session',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid' }),
    __metadata("design:type", String)
], SessionInput.prototype, "session_id", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'The parent session entity',
        type: () => session_entity_1.Session,
    }),
    (0, typeorm_1.ManyToOne)(() => session_entity_1.Session, (session) => session.sessionInputs, {
        nullable: false,
        onDelete: 'CASCADE',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'session_id' }),
    __metadata("design:type", session_entity_1.Session)
], SessionInput.prototype, "session", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'The user prompt text sent to the LLM',
        example: 'Create a new authentication module with JWT support',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "user_prompt", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'UUID of the context template used for context generation',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "context_template_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'The context template entity used',
        type: () => context_template_entity_1.ContextTemplate,
    }),
    (0, typeorm_1.ManyToOne)(() => context_template_entity_1.ContextTemplate, (ct) => ct.sessionInputs, {
        nullable: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'context_template_id' }),
    __metadata("design:type", context_template_entity_1.ContextTemplate)
], SessionInput.prototype, "contextTemplate", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Ad-hoc context definition (JSON or TEXT) for custom file/folder selection',
        example: '{"files": ["src/auth.ts"], "folders": ["src/utils"]}',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "ad_hoc_context_definition", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'The rendered context string sent to the LLM',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "generated_context_string", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'How actions from this input should be processed',
        enum: enums_1.ExecutionStrategy,
        enumName: 'ExecutionStrategy',
        example: enums_1.ExecutionStrategy.REVIEW_FIRST,
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "execution_strategy", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Raw LLM response text (for debugging and history)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "raw_llm_response", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Explanation text from the LLM response',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "llm_response_explanation", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Whether this input carries context without a prompt (for context-only turns)',
        example: false,
        default: false,
    }),
    (0, typeorm_1.Column)({ type: 'boolean', default: false }),
    __metadata("design:type", Boolean)
], SessionInput.prototype, "is_context_carrier", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'AI actions generated from this input',
        type: () => [ai_action_entity_1.AIAction],
    }),
    (0, typeorm_1.OneToMany)(() => ai_action_entity_1.AIAction, (aiAction) => aiAction.sessionInput),
    __metadata("design:type", Array)
], SessionInput.prototype, "aiActions", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Thinking/reasoning content from the LLM (for models that support it)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "thoughts", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Role of this message in conversation (user or model)',
        enum: enums_1.MessageRole,
        enumName: 'MessageRole',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "role", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Number of input tokens used in this request',
        example: 5000,
    }),
    (0, typeorm_1.Column)({ type: 'integer', nullable: true }),
    __metadata("design:type", Number)
], SessionInput.prototype, "input_token_count", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Number of cached tokens used (for context caching)',
        example: 3000,
    }),
    (0, typeorm_1.Column)({ type: 'integer', nullable: true }),
    __metadata("design:type", Number)
], SessionInput.prototype, "cached_token_count", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Number of output tokens generated',
        example: 800,
    }),
    (0, typeorm_1.Column)({ type: 'integer', nullable: true }),
    __metadata("design:type", Number)
], SessionInput.prototype, "output_token_count", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Error message if LLM request failed',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "error_message", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Native tool calls from LLM response (JSON string)',
        example: '[{"name": "create_file", "arguments": {"file_path": "src/auth.ts"}}]',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], SessionInput.prototype, "tool_calls", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Whether this input is excluded from LLM context (discarded by user)',
        example: false,
        default: false,
    }),
    (0, typeorm_1.Column)({ type: 'boolean', default: false }),
    __metadata("design:type", Boolean)
], SessionInput.prototype, "is_discarded", void 0);
exports.SessionInput = SessionInput = __decorate([
    (0, typeorm_1.Entity)('session_inputs'),
    (0, typeorm_1.Index)(['session_id']),
    (0, typeorm_1.Index)(['session_id', 'created_at'])
], SessionInput);
//# sourceMappingURL=session-input.entity.js.map