"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.AIAction = void 0;
const typeorm_1 = require("typeorm");
const swagger_1 = require("@nestjs/swagger");
const base_entity_1 = require("./base.entity");
const session_input_entity_1 = require("./session-input.entity");
const execution_log_entity_1 = require("./execution-log.entity");
const enums_1 = require("./enums");
let AIAction = class AIAction extends base_entity_1.BaseEntity {
    constructor() {
        super(...arguments);
        this.selections = null;
    }
};
exports.AIAction = AIAction;
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'UUID of the SessionInput this action belongs to',
        format: 'uuid',
    }),
    (0, typeorm_1.Column)({ type: 'uuid' }),
    __metadata("design:type", String)
], AIAction.prototype, "input_id", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'The SessionInput entity this action belongs to',
        type: () => session_input_entity_1.SessionInput,
    }),
    (0, typeorm_1.ManyToOne)(() => session_input_entity_1.SessionInput, (si) => si.aiActions, {
        nullable: false,
        onDelete: 'CASCADE',
    }),
    (0, typeorm_1.JoinColumn)({ name: 'input_id' }),
    __metadata("design:type", session_input_entity_1.SessionInput)
], AIAction.prototype, "sessionInput", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'Type of action (determines execution behavior)',
        enum: enums_1.AIActionType,
        enumName: 'AIActionType',
        example: enums_1.AIActionType.CREATE_FILE,
    }),
    (0, typeorm_1.Column)({ type: 'text' }),
    __metadata("design:type", String)
], AIAction.prototype, "action_type", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Target file path (relative to project root)',
        example: 'src/utils/auth.ts',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "file_path", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Content to write/create (for create_file, overwrite_file, patch, etc.)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "content", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Original file content before modification (used for revert)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "original_content_for_revert", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Shell command to execute (for run_command action type)',
        example: 'npm install lodash',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "command_string", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'JSON array of files to include in context (for request_context)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "files", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'JSON array of folders to include in context (for request_context)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "folders", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Reason/explanation for this action (from LLM)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "reason", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Handover prompt for spawning new session (for new_session action type)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "handover_string", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'Current lifecycle state of this action',
        enum: enums_1.AIActionStatus,
        enumName: 'AIActionStatus',
        example: enums_1.AIActionStatus.PROPOSED,
    }),
    (0, typeorm_1.Column)({ type: 'text' }),
    __metadata("design:type", String)
], AIAction.prototype, "status", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'Execution order within batch (actions sorted by this number)',
        example: 1,
    }),
    (0, typeorm_1.Column)({ type: 'integer' }),
    __metadata("design:type", Number)
], AIAction.prototype, "order_of_execution", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Execution logs showing output and errors from execution attempts',
        type: () => [execution_log_entity_1.ExecutionLog],
    }),
    (0, typeorm_1.OneToMany)(() => execution_log_entity_1.ExecutionLog, (executionLog) => executionLog.aiAction),
    __metadata("design:type", Array)
], AIAction.prototype, "executionLogs", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'MCP server name (for MCP tool actions with serverName__toolName pattern)',
        example: 'playwright',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "server_name", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'MCP tool name (for MCP tool actions with serverName__toolName pattern)',
        example: 'browser_navigate',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "tool_name", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Arguments for MCP tool call (JSON string)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "arguments", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Plain text explanation (for final action type)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "plain", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Native tool call ID from LLM response (for function calling mode)',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "tool_call_id", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'JSON array of selection groups for final action type. Each group has question and selections array.',
    }),
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], AIAction.prototype, "selections", void 0);
exports.AIAction = AIAction = __decorate([
    (0, typeorm_1.Entity)('ai_actions'),
    (0, typeorm_1.Index)(['input_id'])
], AIAction);
//# sourceMappingURL=ai-action.entity.js.map