"use strict";
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpeculativeRequestsAutoExpandEditWindowLines = exports.SpeculativeRequestsCursorPlacement = exports.DuplicateAdditionsMode = exports.SpeculativeRequestsEnablement = exports.USER_HAPPINESS_SCORE_CONFIGURATION_VALIDATOR = exports.DEFAULT_USER_HAPPINESS_SCORE_CONFIGURATION = exports.MODEL_CONFIGURATION_VALIDATOR = exports.LINT_OPTIONS_VALIDATOR = exports.LANGUAGE_CONTEXT_ENABLED_LANGUAGES = exports.DEFAULT_CURSOR_PREDICTION_LINT_OPTIONS = exports.DEFAULT_OPTIONS = exports.ResponseFormat = exports.PromptingStrategy = exports.EditIntent = exports.EarlyDivergenceCancellationMode = exports.AggressivenessLevel = exports.AggressivenessSetting = exports.LintOptionShowCode = exports.LintOptionWarning = exports.CurrentFileOptions = exports.GlobalBudgetOptions = exports.NeighborFilesOptions = exports.RecentlyViewedDocumentsOptions = exports.RecentFileClippingStrategy = exports.IncludeLineNumbersOption = void 0;
exports.isPromptingStrategy = isPromptingStrategy;
exports.isAggressivenessStrategy = isAggressivenessStrategy;
exports.parseLintOptionString = parseLintOptionString;
exports.parseUserHappinessScoreConfigurationString = parseUserHappinessScoreConfigurationString;
const assert_1 = require("../../../../util/vs/base/common/assert");
const validator_1 = require("../../../configuration/common/validator");
var IncludeLineNumbersOption;
(function (IncludeLineNumbersOption) {
    IncludeLineNumbersOption["WithSpaceAfter"] = "withSpaceAfter";
    IncludeLineNumbersOption["WithoutSpace"] = "withoutSpaceAfter";
    IncludeLineNumbersOption["None"] = "none";
})(IncludeLineNumbersOption || (exports.IncludeLineNumbersOption = IncludeLineNumbersOption = {}));
var RecentFileClippingStrategy;
(function (RecentFileClippingStrategy) {
    /** Center clipping around the edit location in each file (greedy budget). */
    RecentFileClippingStrategy["AroundEditRange"] = "aroundEditRange";
    /** Proportionally allocate budget across files, centered on edit locations. */
    RecentFileClippingStrategy["Proportional"] = "proportional";
})(RecentFileClippingStrategy || (exports.RecentFileClippingStrategy = RecentFileClippingStrategy = {}));
(function (RecentFileClippingStrategy) {
    RecentFileClippingStrategy.VALIDATOR = (0, validator_1.vEnum)(RecentFileClippingStrategy.AroundEditRange, RecentFileClippingStrategy.Proportional);
})(RecentFileClippingStrategy || (exports.RecentFileClippingStrategy = RecentFileClippingStrategy = {}));
var RecentlyViewedDocumentsOptions;
(function (RecentlyViewedDocumentsOptions) {
    RecentlyViewedDocumentsOptions.VALIDATOR = (0, validator_1.vObj)({
        'nDocuments': (0, validator_1.vNumber)(),
        'maxTokens': (0, validator_1.vNumber)(),
        'includeViewedFiles': (0, validator_1.vBoolean)(),
        'includeLineNumbers': (0, validator_1.vEnum)(IncludeLineNumbersOption.WithSpaceAfter, IncludeLineNumbersOption.WithoutSpace, IncludeLineNumbersOption.None),
        'clippingStrategy': (0, validator_1.vEnum)(RecentFileClippingStrategy.AroundEditRange, RecentFileClippingStrategy.Proportional),
    });
})(RecentlyViewedDocumentsOptions || (exports.RecentlyViewedDocumentsOptions = RecentlyViewedDocumentsOptions = {}));
var NeighborFilesOptions;
(function (NeighborFilesOptions) {
    NeighborFilesOptions.VALIDATOR = (0, validator_1.vObj)({
        'enabled': (0, validator_1.vBoolean)(),
        'maxTokens': (0, validator_1.vNumber)(),
    });
})(NeighborFilesOptions || (exports.NeighborFilesOptions = NeighborFilesOptions = {}));
var GlobalBudgetOptions;
(function (GlobalBudgetOptions) {
    /**
     * Default cascade: language context donates first (often disabled), then
     * recently-viewed documents (always-on, accepts most of the surplus), then
     * neighbor files (must run after recently-viewed because it consults
     * `docsInPrompt` to avoid duplicating recently-viewed documents), then
     * diff history.
     */
    GlobalBudgetOptions.DEFAULT_ORDER = [
        'languageContext',
        'recentlyViewedDocuments',
        'neighborFiles',
        'diffHistory',
    ];
    /** Shares matching today's per-part `maxTokens` ratios (volume-neutral baseline). */
    GlobalBudgetOptions.DEFAULT_SHARES = {
        recentlyViewedDocuments: 2 / 6,
        languageContext: 2 / 6,
        neighborFiles: 1 / 6,
        diffHistory: 1 / 6,
    };
    GlobalBudgetOptions.DEFAULT_TOTAL_TOKENS = 6000;
})(GlobalBudgetOptions || (exports.GlobalBudgetOptions = GlobalBudgetOptions = {}));
var CurrentFileOptions;
(function (CurrentFileOptions) {
    CurrentFileOptions.VALIDATOR = (0, validator_1.vObj)({
        'maxTokens': (0, validator_1.vNumber)(),
        'includeTags': (0, validator_1.vBoolean)(),
        'includeLineNumbers': (0, validator_1.vEnum)(IncludeLineNumbersOption.WithSpaceAfter, IncludeLineNumbersOption.WithoutSpace, IncludeLineNumbersOption.None),
        'includeCursorTag': (0, validator_1.vBoolean)(),
        'prioritizeAboveCursor': (0, validator_1.vBoolean)(),
    });
})(CurrentFileOptions || (exports.CurrentFileOptions = CurrentFileOptions = {}));
var LintOptionWarning;
(function (LintOptionWarning) {
    LintOptionWarning["YES"] = "yes";
    LintOptionWarning["NO"] = "no";
    LintOptionWarning["YES_IF_NO_ERRORS"] = "yesIfNoErrors";
})(LintOptionWarning || (exports.LintOptionWarning = LintOptionWarning = {}));
var LintOptionShowCode;
(function (LintOptionShowCode) {
    LintOptionShowCode["YES"] = "yes";
    LintOptionShowCode["NO"] = "no";
    LintOptionShowCode["YES_WITH_SURROUNDING"] = "yesWithSurroundingLines";
})(LintOptionShowCode || (exports.LintOptionShowCode = LintOptionShowCode = {}));
/**
 * The raw user-facing aggressiveness setting. Includes `Default` to distinguish
 * "user didn't change" from "user explicitly chose medium".
 */
var AggressivenessSetting;
(function (AggressivenessSetting) {
    AggressivenessSetting["Default"] = "auto";
    AggressivenessSetting["Low"] = "low";
    AggressivenessSetting["Medium"] = "medium";
    AggressivenessSetting["High"] = "high";
})(AggressivenessSetting || (exports.AggressivenessSetting = AggressivenessSetting = {}));
/**
 * The resolved aggressiveness level used in prompts and edit-intent filtering.
 * Does not include `Default` — that is resolved before reaching this type.
 */
var AggressivenessLevel;
(function (AggressivenessLevel) {
    AggressivenessLevel["Low"] = "low";
    AggressivenessLevel["Medium"] = "medium";
    AggressivenessLevel["High"] = "high";
})(AggressivenessLevel || (exports.AggressivenessLevel = AggressivenessLevel = {}));
/**
 * Controls the scope of the early divergence cancellation check.
 *
 * - `Off`: disable early divergence cancellation checks.
 * - `Cursor`: only check the cursor line for divergence (original behavior).
 * - `EditWindow`: check every line in the edit window for divergence.
 */
var EarlyDivergenceCancellationMode;
(function (EarlyDivergenceCancellationMode) {
    EarlyDivergenceCancellationMode["Cursor"] = "cursor";
    EarlyDivergenceCancellationMode["EditWindow"] = "editWindow";
    EarlyDivergenceCancellationMode["Off"] = "off";
})(EarlyDivergenceCancellationMode || (exports.EarlyDivergenceCancellationMode = EarlyDivergenceCancellationMode = {}));
(function (EarlyDivergenceCancellationMode) {
    EarlyDivergenceCancellationMode.VALIDATOR = (0, validator_1.vEnum)(EarlyDivergenceCancellationMode.Cursor, EarlyDivergenceCancellationMode.EditWindow, EarlyDivergenceCancellationMode.Off);
})(EarlyDivergenceCancellationMode || (exports.EarlyDivergenceCancellationMode = EarlyDivergenceCancellationMode = {}));
(function (AggressivenessSetting) {
    AggressivenessSetting.VALIDATOR = (0, validator_1.vEnum)(AggressivenessSetting.Default, AggressivenessSetting.Low, AggressivenessSetting.Medium, AggressivenessSetting.High);
    /** Resolves a non-default setting value to an AggressivenessLevel. Returns undefined for Default. */
    function toLevel(setting) {
        switch (setting) {
            case AggressivenessSetting.Low: return AggressivenessLevel.Low;
            case AggressivenessSetting.Medium: return AggressivenessLevel.Medium;
            case AggressivenessSetting.High: return AggressivenessLevel.High;
            case AggressivenessSetting.Default: return undefined;
        }
    }
    AggressivenessSetting.toLevel = toLevel;
})(AggressivenessSetting || (exports.AggressivenessSetting = AggressivenessSetting = {}));
/**
 * EditIntent indicates the model's confidence level for the suggested edit.
 * The model returns this as <|edit_intent|>value<|/edit_intent|> in the response.
 */
var EditIntent;
(function (EditIntent) {
    EditIntent["NoEdit"] = "no_edit";
    EditIntent["Low"] = "low";
    EditIntent["Medium"] = "medium";
    EditIntent["High"] = "high";
})(EditIntent || (exports.EditIntent = EditIntent = {}));
(function (EditIntent) {
    /**
     * Converts a string value to EditIntent enum.
     * Returns High (most permissive) for invalid values.
     */
    function fromString(value) {
        switch (value) {
            case 'no_edit':
                return EditIntent.NoEdit;
            case 'low':
                return EditIntent.Low;
            case 'medium':
                return EditIntent.Medium;
            case 'high':
                return EditIntent.High;
            default:
                // For unknown values, default to High (always show)
                return EditIntent.High;
        }
    }
    EditIntent.fromString = fromString;
    /**
     * Converts a short name (N, L, M, H) to EditIntent enum.
     * Only uppercase letters are accepted.
     * Returns undefined for invalid values.
     */
    function fromShortName(value) {
        switch (value) {
            case 'N':
                return EditIntent.NoEdit;
            case 'L':
                return EditIntent.Low;
            case 'M':
                return EditIntent.Medium;
            case 'H':
                return EditIntent.High;
            default:
                return undefined;
        }
    }
    EditIntent.fromShortName = fromShortName;
    /**
     * Determines if the edit should be shown based on the edit intent
     * and the user's aggressiveness level.
     *
     * Filtering logic (edit_intent vs user aggressiveness):
     * - no_edit: Never show the edit
     * - high confidence: Show for all aggressiveness levels (high confidence = always show)
     * - medium confidence: Show only if user aggressiveness is medium or high
     * - low confidence: Show only if user aggressiveness is high
     */
    function shouldShowEdit(editIntent, aggressivenessLevel) {
        switch (editIntent) {
            case EditIntent.NoEdit:
                return false;
            case EditIntent.High:
                // High confidence edits show for all aggressiveness levels
                return true;
            case EditIntent.Medium:
                // Medium confidence edits show for medium or high aggressiveness
                return aggressivenessLevel === AggressivenessLevel.Medium ||
                    aggressivenessLevel === AggressivenessLevel.High;
            case EditIntent.Low:
                // Low confidence edits only show for high aggressiveness
                return aggressivenessLevel === AggressivenessLevel.High;
            default:
                (0, assert_1.assertNever)(editIntent);
        }
    }
    EditIntent.shouldShowEdit = shouldShowEdit;
})(EditIntent || (exports.EditIntent = EditIntent = {}));
/**
 * Prompt strategies that tweak prompt in a way that's different from current prod prompting strategy.
 */
var PromptingStrategy;
(function (PromptingStrategy) {
    /**
     * Original Xtab unified model prompting strategy.
     */
    PromptingStrategy["CopilotNesXtab"] = "copilotNesXtab";
    PromptingStrategy["UnifiedModel"] = "xtabUnifiedModel";
    PromptingStrategy["Codexv21NesUnified"] = "codexv21nesUnified";
    PromptingStrategy["Nes41Miniv3"] = "nes41miniv3";
    PromptingStrategy["SimplifiedSystemPrompt"] = "simplifiedSystemPrompt";
    PromptingStrategy["Xtab275"] = "xtab275";
    PromptingStrategy["XtabAggressiveness"] = "xtabAggressiveness";
    /**
     * Xtab275 prompt + aggressiveness level tag.
     */
    PromptingStrategy["Xtab275Aggressiveness"] = "xtab275Aggressiveness";
    PromptingStrategy["PatchBased"] = "patchBased";
    PromptingStrategy["PatchBased01"] = "patchBased01";
    PromptingStrategy["PatchBased02"] = "patchBased02";
    /**
     * Xtab275-based strategy with edit intent tag parsing.
     * Response format: <|edit_intent|>low|medium|high|no_edit<|/edit_intent|>
     * followed by the edit window content.
     */
    PromptingStrategy["Xtab275EditIntent"] = "xtab275EditIntent";
    /**
     * Xtab275-based strategy with short edit intent parsing.
     * Response format: N|L|M|H (single character on first line)
     * followed by the edit window content.
     */
    PromptingStrategy["Xtab275EditIntentShort"] = "xtab275EditIntentShort";
})(PromptingStrategy || (exports.PromptingStrategy = PromptingStrategy = {}));
function isPromptingStrategy(value) {
    return Object.values(PromptingStrategy).includes(value);
}
function isAggressivenessStrategy(strategy) {
    return strategy === PromptingStrategy.XtabAggressiveness
        || strategy === PromptingStrategy.Xtab275Aggressiveness
        || strategy === PromptingStrategy.Xtab275EditIntent
        || strategy === PromptingStrategy.Xtab275EditIntentShort;
}
var ResponseFormat;
(function (ResponseFormat) {
    ResponseFormat["CodeBlock"] = "codeBlock";
    ResponseFormat["UnifiedWithXml"] = "unifiedWithXml";
    ResponseFormat["EditWindowOnly"] = "editWindowOnly";
    ResponseFormat["CustomDiffPatch"] = "customDiffPatch";
    ResponseFormat["EditWindowWithEditIntent"] = "editWindowWithEditIntent";
    ResponseFormat["EditWindowWithEditIntentShort"] = "editWindowWithEditIntentShort";
})(ResponseFormat || (exports.ResponseFormat = ResponseFormat = {}));
(function (ResponseFormat) {
    function fromPromptingStrategy(strategy) {
        switch (strategy) {
            case PromptingStrategy.UnifiedModel:
            case PromptingStrategy.Codexv21NesUnified:
            case PromptingStrategy.Nes41Miniv3:
                return ResponseFormat.UnifiedWithXml;
            case PromptingStrategy.Xtab275:
            case PromptingStrategy.XtabAggressiveness:
            case PromptingStrategy.Xtab275Aggressiveness:
                return ResponseFormat.EditWindowOnly;
            case PromptingStrategy.PatchBased:
            case PromptingStrategy.PatchBased01:
            case PromptingStrategy.PatchBased02:
                return ResponseFormat.CustomDiffPatch;
            case PromptingStrategy.Xtab275EditIntent:
                return ResponseFormat.EditWindowWithEditIntent;
            case PromptingStrategy.Xtab275EditIntentShort:
                return ResponseFormat.EditWindowWithEditIntentShort;
            case PromptingStrategy.SimplifiedSystemPrompt:
            case PromptingStrategy.CopilotNesXtab:
            case undefined:
                return ResponseFormat.CodeBlock;
            default:
                (0, assert_1.assertNever)(strategy);
        }
    }
    ResponseFormat.fromPromptingStrategy = fromPromptingStrategy;
})(ResponseFormat || (exports.ResponseFormat = ResponseFormat = {}));
exports.DEFAULT_OPTIONS = {
    promptingStrategy: undefined,
    currentFile: {
        maxTokens: 2000,
        includeTags: true,
        includeLineNumbers: IncludeLineNumbersOption.None,
        includeCursorTag: false,
        prioritizeAboveCursor: false,
    },
    pagedClipping: {
        pageSize: 10,
    },
    recentlyViewedDocuments: {
        nDocuments: 5,
        maxTokens: 2000,
        includeViewedFiles: false,
        includeLineNumbers: IncludeLineNumbersOption.None,
        clippingStrategy: RecentFileClippingStrategy.AroundEditRange,
    },
    languageContext: {
        enabled: false,
        maxTokens: 2000,
        traitPosition: 'after',
    },
    neighborFiles: {
        enabled: false,
        maxTokens: 1000,
    },
    diffHistory: {
        nEntries: 25,
        maxTokens: 1000,
        onlyForDocsInPrompt: false,
        useRelativePaths: false,
    },
    lintOptions: undefined,
    includePostScript: true,
};
exports.DEFAULT_CURSOR_PREDICTION_LINT_OPTIONS = {
    maxLineDistance: 1000,
    maxLints: 5,
    showCode: LintOptionShowCode.YES_WITH_SURROUNDING,
    tagName: 'linter',
    warnings: LintOptionWarning.YES_IF_NO_ERRORS,
    nRecentFiles: 0,
};
// TODO: consider a better per language setting/experiment approach
exports.LANGUAGE_CONTEXT_ENABLED_LANGUAGES = {
    'prompt': true,
    'instructions': true,
    'chatagent': true,
};
exports.LINT_OPTIONS_VALIDATOR = (0, validator_1.vObj)({
    'tagName': (0, validator_1.vString)(),
    'warnings': (0, validator_1.vEnum)(LintOptionWarning.YES, LintOptionWarning.NO, LintOptionWarning.YES_IF_NO_ERRORS),
    'showCode': (0, validator_1.vEnum)(LintOptionShowCode.NO, LintOptionShowCode.YES, LintOptionShowCode.YES_WITH_SURROUNDING),
    'maxLints': (0, validator_1.vNumber)(),
    'maxLineDistance': (0, validator_1.vNumber)(),
    'nRecentFiles': (0, validator_1.vNumber)(),
});
exports.MODEL_CONFIGURATION_VALIDATOR = (0, validator_1.vObj)({
    'modelName': (0, validator_1.vRequired)((0, validator_1.vString)()),
    'promptingStrategy': (0, validator_1.vUnion)((0, validator_1.vEnum)(...Object.values(PromptingStrategy)), (0, validator_1.vUndefined)()),
    'includeTagsInCurrentFile': (0, validator_1.vRequired)((0, validator_1.vBoolean)()),
    'includePostScript': (0, validator_1.vUnion)((0, validator_1.vBoolean)(), (0, validator_1.vUndefined)()),
    'currentFile': (0, validator_1.vUnion)(CurrentFileOptions.VALIDATOR, (0, validator_1.vUndefined)()),
    'recentlyViewedDocuments': (0, validator_1.vUnion)(RecentlyViewedDocumentsOptions.VALIDATOR, (0, validator_1.vUndefined)()),
    'lintOptions': (0, validator_1.vUnion)(exports.LINT_OPTIONS_VALIDATOR, (0, validator_1.vUndefined)()),
    'supportsNextCursorLinePrediction': (0, validator_1.vUnion)((0, validator_1.vBoolean)(), (0, validator_1.vUndefined)()),
});
function parseLintOptionString(optionString, defaults) {
    try {
        const parsed = JSON.parse(optionString);
        const lintValidation = exports.LINT_OPTIONS_VALIDATOR.validate(parsed);
        if (lintValidation.error) {
            throw new Error(`Lint options validation failed: ${lintValidation.error.message}`);
        }
        return { ...defaults, ...lintValidation.content };
    }
    catch (e) {
        throw new Error(`Failed to parse lint options string: ${e}`);
    }
}
/**
 * Default configuration for user happiness score calculation. Mimics v1 behavior.
 */
exports.DEFAULT_USER_HAPPINESS_SCORE_CONFIGURATION = {
    acceptedScore: 1,
    rejectedScore: 0,
    ignoredScore: 0.5,
    highThreshold: 0.7,
    mediumThreshold: 0.4,
    includeIgnored: false,
    ignoredLimit: 0,
    limitConsecutiveIgnored: false,
    limitTotalIgnored: true,
};
/**
 * Basic type validation for happiness config.
 */
const USER_HAPPINESS_SCORE_CONFIGURATION_BASE_VALIDATOR = (0, validator_1.vObj)({
    'acceptedScore': (0, validator_1.vRequired)((0, validator_1.vNumber)()),
    'rejectedScore': (0, validator_1.vRequired)((0, validator_1.vNumber)()),
    'ignoredScore': (0, validator_1.vRequired)((0, validator_1.vNumber)()),
    'highThreshold': (0, validator_1.vRequired)((0, validator_1.vNumber)()),
    'mediumThreshold': (0, validator_1.vRequired)((0, validator_1.vNumber)()),
    'includeIgnored': (0, validator_1.vRequired)((0, validator_1.vBoolean)()),
    'ignoredLimit': (0, validator_1.vRequired)((0, validator_1.vNumber)()),
    'limitConsecutiveIgnored': (0, validator_1.vRequired)((0, validator_1.vBoolean)()),
    'limitTotalIgnored': (0, validator_1.vRequired)((0, validator_1.vBoolean)()),
});
function isInRange(value, min, max) {
    return value >= min && value <= max;
}
/**
 * Value checking for happiness config.
 */
exports.USER_HAPPINESS_SCORE_CONFIGURATION_VALIDATOR = {
    validate(content) {
        const baseResult = USER_HAPPINESS_SCORE_CONFIGURATION_BASE_VALIDATOR.validate(content);
        if (baseResult.error) {
            return baseResult;
        }
        const config = baseResult.content;
        // Validate score ranges [0, 1]
        if (!isInRange(config.acceptedScore, 0, 1)) {
            return { content: undefined, error: { message: 'acceptedScore must be in range [0, 1]' } };
        }
        if (!isInRange(config.rejectedScore, 0, 1)) {
            return { content: undefined, error: { message: 'rejectedScore must be in range [0, 1]' } };
        }
        if (!isInRange(config.ignoredScore, 0, 1)) {
            return { content: undefined, error: { message: 'ignoredScore must be in range [0, 1]' } };
        }
        // Validate threshold ranges [0, 1]
        if (!isInRange(config.highThreshold, 0, 1)) {
            return { content: undefined, error: { message: 'highThreshold must be in range [0, 1]' } };
        }
        if (!isInRange(config.mediumThreshold, 0, 1)) {
            return { content: undefined, error: { message: 'mediumThreshold must be in range [0, 1]' } };
        }
        // Validate acceptedScore > rejectedScore to prevent division by zero
        if (config.acceptedScore <= config.rejectedScore) {
            return { content: undefined, error: { message: 'acceptedScore must be greater than rejectedScore to prevent division by zero' } };
        }
        // Validate acceptedScore >= ignoredScore >= rejectedScore to prevent exceeding bounds
        if (config.ignoredScore < config.rejectedScore) {
            return { content: undefined, error: { message: 'ignoredScore must be greater than or equal to rejectedScore to prevent exceeding bounds' } };
        }
        if (config.acceptedScore < config.ignoredScore) {
            return { content: undefined, error: { message: 'acceptedScore must be greater than or equal to ignoredScore to prevent exceeding bounds' } };
        }
        // Validate highThreshold > mediumThreshold for logical consistency
        if (config.highThreshold <= config.mediumThreshold) {
            return { content: undefined, error: { message: 'highThreshold must be greater than mediumThreshold' } };
        }
        // Validate ignoredLimit >= 0
        if (config.ignoredLimit < 0) {
            return { content: undefined, error: { message: 'ignoredLimit must be non-negative' } };
        }
        return { content: config, error: undefined };
    },
    toSchema() {
        return USER_HAPPINESS_SCORE_CONFIGURATION_BASE_VALIDATOR.toSchema();
    }
};
function parseUserHappinessScoreConfigurationString(optionString) {
    try {
        const parsed = JSON.parse(optionString);
        const validation = exports.USER_HAPPINESS_SCORE_CONFIGURATION_VALIDATOR.validate(parsed);
        if (validation.error) {
            throw new Error(`User happiness score configuration validation failed: ${validation.error.message}`);
        }
        return validation.content;
    }
    catch (e) {
        throw new Error(`Failed to parse user happiness score configuration string: ${e}`);
    }
}
var SpeculativeRequestsEnablement;
(function (SpeculativeRequestsEnablement) {
    SpeculativeRequestsEnablement["On"] = "on";
    SpeculativeRequestsEnablement["Off"] = "off";
})(SpeculativeRequestsEnablement || (exports.SpeculativeRequestsEnablement = SpeculativeRequestsEnablement = {}));
(function (SpeculativeRequestsEnablement) {
    SpeculativeRequestsEnablement.VALIDATOR = (0, validator_1.vEnum)(SpeculativeRequestsEnablement.On, SpeculativeRequestsEnablement.Off);
})(SpeculativeRequestsEnablement || (exports.SpeculativeRequestsEnablement = SpeculativeRequestsEnablement = {}));
/**
 * What `XtabCustomDiffPatchResponseHandler` should do when the dedup
 * heuristic detects that a patch's additions duplicate the file content
 * immediately following the deleted range.
 *
 * - `Off`: do not run the detector at all.
 * - `Log`: run the detector and report each detection (tracer + telemetry
 *   callback) but yield the patch unchanged. Lets us measure the
 *   heuristic's firing rate before flipping user-visible behavior.
 * - `DropPatch`: drop just the offending patch and continue processing
 *   the rest of the stream. Use when we want to suppress individual bad
 *   patches but trust the rest of the model's output.
 * - `DropAllRemaining`: drop the offending patch AND every subsequent
 *   patch from the same response. Use when a duplicate inside the stream
 *   is treated as a signal that the response has gone off the rails.
 *   Patches already yielded before the detection are kept.
 * - `TrimDuplicate`: trim just the duplicated lines from the patch's
 *   additions and yield the (possibly shorter) patch. If the trim leaves
 *   the patch with no additions and no removals, the patch is dropped.
 *   This is the most aggressive about salvaging the model's intent.
 */
var DuplicateAdditionsMode;
(function (DuplicateAdditionsMode) {
    DuplicateAdditionsMode["Off"] = "off";
    DuplicateAdditionsMode["Log"] = "log";
    DuplicateAdditionsMode["DropPatch"] = "dropPatch";
    DuplicateAdditionsMode["DropAllRemaining"] = "dropAllRemaining";
    DuplicateAdditionsMode["TrimDuplicate"] = "trimDuplicate";
})(DuplicateAdditionsMode || (exports.DuplicateAdditionsMode = DuplicateAdditionsMode = {}));
(function (DuplicateAdditionsMode) {
    DuplicateAdditionsMode.VALIDATOR = (0, validator_1.vEnum)(DuplicateAdditionsMode.Off, DuplicateAdditionsMode.Log, DuplicateAdditionsMode.DropPatch, DuplicateAdditionsMode.DropAllRemaining, DuplicateAdditionsMode.TrimDuplicate);
})(DuplicateAdditionsMode || (exports.DuplicateAdditionsMode = DuplicateAdditionsMode = {}));
var SpeculativeRequestsCursorPlacement;
(function (SpeculativeRequestsCursorPlacement) {
    SpeculativeRequestsCursorPlacement["AfterEditApplied"] = "afterEditApplied";
    SpeculativeRequestsCursorPlacement["AfterEditWindow"] = "afterEditWindow";
})(SpeculativeRequestsCursorPlacement || (exports.SpeculativeRequestsCursorPlacement = SpeculativeRequestsCursorPlacement = {}));
(function (SpeculativeRequestsCursorPlacement) {
    SpeculativeRequestsCursorPlacement.VALIDATOR = (0, validator_1.vEnum)(SpeculativeRequestsCursorPlacement.AfterEditApplied, SpeculativeRequestsCursorPlacement.AfterEditWindow);
})(SpeculativeRequestsCursorPlacement || (exports.SpeculativeRequestsCursorPlacement = SpeculativeRequestsCursorPlacement = {}));
var SpeculativeRequestsAutoExpandEditWindowLines;
(function (SpeculativeRequestsAutoExpandEditWindowLines) {
    SpeculativeRequestsAutoExpandEditWindowLines["Off"] = "off";
    SpeculativeRequestsAutoExpandEditWindowLines["Smart"] = "smart";
    SpeculativeRequestsAutoExpandEditWindowLines["Always"] = "always";
})(SpeculativeRequestsAutoExpandEditWindowLines || (exports.SpeculativeRequestsAutoExpandEditWindowLines = SpeculativeRequestsAutoExpandEditWindowLines = {}));
(function (SpeculativeRequestsAutoExpandEditWindowLines) {
    SpeculativeRequestsAutoExpandEditWindowLines.VALIDATOR = (0, validator_1.vEnum)(SpeculativeRequestsAutoExpandEditWindowLines.Off, SpeculativeRequestsAutoExpandEditWindowLines.Smart, SpeculativeRequestsAutoExpandEditWindowLines.Always);
})(SpeculativeRequestsAutoExpandEditWindowLines || (exports.SpeculativeRequestsAutoExpandEditWindowLines = SpeculativeRequestsAutoExpandEditWindowLines = {}));
//# sourceMappingURL=xtabPromptOptions.js.map