"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.Session = void 0;
const typeorm_1 = require("typeorm");
const swagger_1 = require("@nestjs/swagger");
const base_entity_1 = require("./base.entity");
const project_entity_1 = require("./project.entity");
const context_template_entity_1 = require("./context-template.entity");
const session_input_entity_1 = require("./session-input.entity");
const system_prompt_entity_1 = require("./system-prompt.entity");
const sub_agent_entity_1 = require("../sub-agents/sub-agent.entity");
const enums_1 = require("./enums");
let Session = class Session extends base_entity_1.BaseEntity {
};
exports.Session = Session;
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'UUID of the associated project',
        format: 'uuid',
        example: '550e8400-e29b-41d4-a716-446655440001',
    }),
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "project_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'The project this session belongs to',
        type: () => project_entity_1.Project,
    }),
    (0, typeorm_1.ManyToOne)(() => project_entity_1.Project, (project) => project.sessions, {
        nullable: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'project_id' }),
    __metadata("design:type", project_entity_1.Project)
], Session.prototype, "project", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Human-readable title for the session',
        example: 'Refactor authentication module',
        maxLength: 255,
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "session_title", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Timestamp when the session ended',
        type: 'string',
        format: 'date-time',
    }),
    (0, typeorm_1.Column)({ type: 'datetime', nullable: true }),
    __metadata("design:type", Date)
], Session.prototype, "end_time", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'Current status of the session',
        enum: enums_1.SessionStatus,
        example: enums_1.SessionStatus.ACTIVE,
        enumName: 'SessionStatus',
    }),
    (0, typeorm_1.Column)({ type: 'text' }),
    __metadata("design:type", String)
], Session.prototype, "status", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'UUID of the system prompt configuration used',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "system_prompt_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'The system prompt entity used for this session',
        type: () => system_prompt_entity_1.SystemPrompt,
    }),
    (0, typeorm_1.ManyToOne)(() => system_prompt_entity_1.SystemPrompt, (sp) => sp.sessions, {
        nullable: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'system_prompt_id' }),
    __metadata("design:type", system_prompt_entity_1.SystemPrompt)
], Session.prototype, "systemPrompt", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'UUID of default context template for initial prompts',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "default_initial_context_template_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Default context template for initial prompts in this session',
        type: () => context_template_entity_1.ContextTemplate,
    }),
    (0, typeorm_1.ManyToOne)(() => context_template_entity_1.ContextTemplate, (ct) => ct.sessionsAsInitialDefault, {
        nullable: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'default_initial_context_template_id' }),
    __metadata("design:type", context_template_entity_1.ContextTemplate)
], Session.prototype, "defaultInitialContextTemplate", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'UUID of default context template for follow-up prompts',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "default_followup_context_template_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Default context template for follow-up prompts in this session',
        type: () => context_template_entity_1.ContextTemplate,
    }),
    (0, typeorm_1.ManyToOne)(() => context_template_entity_1.ContextTemplate, (ct) => ct.sessionsAsFollowupDefault, {
        nullable: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'default_followup_context_template_id' }),
    __metadata("design:type", context_template_entity_1.ContextTemplate)
], Session.prototype, "defaultFollowupContextTemplate", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'External URL link',
        example: 'https://claude.ai/chat/abc123',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "url", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Model identifier used for this session',
        example: 'ollama/glm-5.1:cloud',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "model_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Reasoning effort level for the model',
        enum: enums_1.ReasoningEffort,
        enumName: 'ReasoningEffort',
        example: enums_1.ReasoningEffort.MEDIUM,
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "reasoning_effort", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'UUID of the sub-agent assigned to this session',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "sub_agent_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'The sub-agent entity assigned to this session',
        type: () => sub_agent_entity_1.SubAgent,
    }),
    (0, typeorm_1.ManyToOne)(() => sub_agent_entity_1.SubAgent, {
        nullable: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'sub_agent_id' }),
    __metadata("design:type", sub_agent_entity_1.SubAgent)
], Session.prototype, "subAgent", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'UUID of parent session (for follow-up/spawned sessions)',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], Session.prototype, "parent_session_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'The parent session this was spawned from',
        type: () => Session,
    }),
    (0, typeorm_1.ManyToOne)(() => Session, {
        nullable: true,
        onDelete: 'SET NULL',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'parent_session_id' }),
    __metadata("design:type", Session)
], Session.prototype, "parentSession", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'All input prompts in this session',
        type: () => [session_input_entity_1.SessionInput],
    }),
    (0, typeorm_1.OneToMany)(() => session_input_entity_1.SessionInput, (sessionInput) => sessionInput.session),
    __metadata("design:type", Array)
], Session.prototype, "sessionInputs", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Child sessions spawned from this session',
        type: () => [Session],
    }),
    (0, typeorm_1.OneToMany)(() => Session, 'parent_session_id'),
    __metadata("design:type", Array)
], Session.prototype, "childSessions", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Count of inputs in this session (computed field)',
        example: 5,
    }),
    __metadata("design:type", Number)
], Session.prototype, "sessionInputCount", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'Whether the LLM is currently generating a response for this session',
        example: false,
    }),
    (0, typeorm_1.Column)({ type: 'boolean', default: false }),
    __metadata("design:type", Boolean)
], Session.prototype, "is_running", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Summary of the latest input in this session (computed field)',
    }),
    __metadata("design:type", Object)
], Session.prototype, "latestInput", void 0);
exports.Session = Session = __decorate([
    (0, typeorm_1.Entity)('sessions')
], Session);
//# sourceMappingURL=session.entity.js.map