"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.START_TASK_PREFIX = exports.TrackableTestGenerationEvent = exports.AgentLogEntryType = exports.StatusesPreservingAgentState = exports.ActiveTestGenerationStatuses = exports.TestGenerationStatus = void 0;
exports.getFlowIdForRecordFlowStep = getFlowIdForRecordFlowStep;
exports.removeInternalContent = removeInternalContent;
exports.TestGenerationStatus = {
    NotStarted: 'not_started',
    V1GeneratingIntents: 'v1_generating_intents',
    GeneratingIntent: 'generating_intent',
    Off: 'off',
    Paused: 'paused',
    Failed: 'failed',
    LearningSteps: 'learning_steps',
    LearningStepsAwaitingAction: 'learning_steps_awaiting_action',
    Completed: 'completed',
};
exports.ActiveTestGenerationStatuses = [
    exports.TestGenerationStatus.LearningSteps,
    exports.TestGenerationStatus.Paused,
    exports.TestGenerationStatus.Failed,
    exports.TestGenerationStatus.LearningStepsAwaitingAction,
];
exports.StatusesPreservingAgentState = [
    exports.TestGenerationStatus.LearningStepsAwaitingAction,
];
exports.AgentLogEntryType = {
    GenerateStepResponse: 'generateStepResponse',
    TestGenerationStarted: 'testGenerationStarted',
    TestGenerationPaused: 'testGenerationPaused',
    ToolExecuted: 'toolExecuted',
    Message: 'message',
};
function getFlowIdForRecordFlowStep(toolCall) {
    const params = toolCall.toolParams;
    return params.flow_id;
}
var TrackableTestGenerationEvent;
(function (TrackableTestGenerationEvent) {
    TrackableTestGenerationEvent["AgentError"] = "Agent error";
    TrackableTestGenerationEvent["AgentModeManuallyPaused"] = "Agent mode manually paused";
    TrackableTestGenerationEvent["AgentModeStarted"] = "Agent mode started";
    TrackableTestGenerationEvent["AgentModeStopped"] = "Agent mode stopped";
    TrackableTestGenerationEvent["AgentPlanAvailable"] = "Plan available and displayed";
    TrackableTestGenerationEvent["AgentToolExecutorFailed"] = "Tool executor failed";
    TrackableTestGenerationEvent["AgentToolExecutorUsed"] = "Tool executor used by agent";
    TrackableTestGenerationEvent["MabltronTrainingSaveFailure"] = "Mabltron Training Save Failure";
    TrackableTestGenerationEvent["MabltronTrainingSaveSuccess"] = "Mabltron Training Save Success";
})(TrackableTestGenerationEvent || (exports.TrackableTestGenerationEvent = TrackableTestGenerationEvent = {}));
exports.START_TASK_PREFIX = '-->';
function removeInternalContent(message) {
    if (!message) {
        return message;
    }
    const logsRegex = /(?<message>.*\n*)\n(=* logs =*)/gm;
    const logsMatch = logsRegex.exec(message);
    if (logsMatch) {
        message = logsMatch.groups?.message ?? '';
    }
    const functionRegex = /(elementHandle|page|frame|browser|browserContext|jsHandle)\.(?<function>.*):(?<message>.*)/gm;
    const functionMatch = functionRegex.exec(message);
    if (functionMatch) {
        const functionName = functionMatch.groups?.function;
        const messageText = functionMatch.groups?.message;
        message = `${functionName} failed:${messageText}`;
    }
    return message;
}
