"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WORKFLOW_REPLANNING_REQUIRED_PROCEED_RULE = exports.WORKFLOW_PLANNING_REQUIRED_PROCEED_RULE = exports.WORKFLOW_PLANNING_EXAMPLE_FIELDS = exports.WORKFLOW_PLANNING_ONLY_FIELD_NAMES = exports.WORKFLOW_REPLANNING_REQUIRED_PROCEED_FIELD_NAMES = exports.WORKFLOW_PLANNING_REQUIRED_PROCEED_FIELD_NAMES = exports.WORKFLOW_PLANNING_TOP_LEVEL_FIELD_NAMES = void 0;
exports.formatWorkflowPlanningFieldList = formatWorkflowPlanningFieldList;
exports.getWorkflowPlanningRequiredProceedFieldNames = getWorkflowPlanningRequiredProceedFieldNames;
exports.isAdaptiveWorkflowStartApprovalMode = isAdaptiveWorkflowStartApprovalMode;
exports.WORKFLOW_PLANNING_TOP_LEVEL_FIELD_NAMES = [
    "issueTitle",
    "contract",
    "plan",
    "planPatch",
    "executionGuidance",
    "predictedTouchedPaths",
    "priorityRank",
    "workflowStartApproval",
];
exports.WORKFLOW_PLANNING_REQUIRED_PROCEED_FIELD_NAMES = [
    "issueTitle",
    "contract",
    "plan",
    "executionGuidance",
    "predictedTouchedPaths",
];
exports.WORKFLOW_REPLANNING_REQUIRED_PROCEED_FIELD_NAMES = [
    "planPatch",
];
exports.WORKFLOW_PLANNING_ONLY_FIELD_NAMES = [
    "priorityRank",
    ...exports.WORKFLOW_PLANNING_REQUIRED_PROCEED_FIELD_NAMES,
    ...exports.WORKFLOW_REPLANNING_REQUIRED_PROCEED_FIELD_NAMES,
    "workflowStartApproval",
];
exports.WORKFLOW_PLANNING_EXAMPLE_FIELDS = {
    issueTitle: "Short planned issue title",
    executionGuidance: [
        "Apply workflow-level human handoff, notification, side-effect, and evidence rules to every execution step.",
    ],
    predictedTouchedPaths: ["src/example.ts"],
};
function formatWorkflowPlanningFieldList(fields) {
    if (fields.length <= 1) {
        return fields[0] ?? "";
    }
    return `${fields.slice(0, -1).join(", ")}, and ${fields.at(-1)}`;
}
exports.WORKFLOW_PLANNING_REQUIRED_PROCEED_RULE = `Proceed decisions must include ${formatWorkflowPlanningFieldList(exports.WORKFLOW_PLANNING_REQUIRED_PROCEED_FIELD_NAMES)}.`;
exports.WORKFLOW_REPLANNING_REQUIRED_PROCEED_RULE = `Replan and revise_plan proceed decisions must include ${formatWorkflowPlanningFieldList(exports.WORKFLOW_REPLANNING_REQUIRED_PROCEED_FIELD_NAMES)} and must omit plan. Include workflowStartApproval when workflow.startApprovalMode is conservative or aggressive.`;
function getWorkflowPlanningRequiredProceedFieldNames(workflow) {
    return workflow?.planningIntent === "replan" ||
        workflow?.planningIntent === "revise_plan"
        ? exports.WORKFLOW_REPLANNING_REQUIRED_PROCEED_FIELD_NAMES
        : exports.WORKFLOW_PLANNING_REQUIRED_PROCEED_FIELD_NAMES;
}
function isAdaptiveWorkflowStartApprovalMode(mode) {
    return mode === "conservative" || mode === "aggressive";
}
