// Force strict mode and setup for ESM
"use strict";
import {
  getPlanModeSystemReminder
} from "./chunk-UQDFEU47.js";
import "./chunk-GOFAQQZA.js";
import "./chunk-5M6IDOMF.js";
import "./chunk-TWPJO254.js";
import "./chunk-H6XPXXMH.js";
import "./chunk-VA5NLVPT.js";
import "./chunk-I7JDGNG6.js";
import "./chunk-A6SX5TAH.js";
import "./chunk-33FNCQSY.js";
import "./chunk-6PVPNMXU.js";
import "./chunk-XUMAD5IT.js";
import "./chunk-IRH27ZC2.js";
import "./chunk-QHWCP53L.js";
import "./chunk-MOHAWIAW.js";
import "./chunk-X6QNZOTC.js";
import "./chunk-O6GEWCJA.js";
import "./chunk-T26EAKDL.js";
import "./chunk-ZPJWUGCS.js";
import "./chunk-CPBF7KYF.js";
import "./chunk-MISUEWB4.js";
import "./chunk-KRXPRVGL.js";
import "./chunk-A5YZ3FA2.js";
import "./chunk-YAVY33G4.js";
import "./chunk-2UISUFHQ.js";
import "./chunk-HFVW54NL.js";
import {
  buildSubagentPlanToolBlockedResult,
  isPlanLifecycleToolUnavailableInSubagent
} from "./chunk-TZTBZ25J.js";
import "./chunk-S6LOFUVP.js";
import "./chunk-SRY26X4H.js";
import "./chunk-K623ENWT.js";
import "./chunk-AQ37AY7B.js";
import "./chunk-432XCUHF.js";
import "./chunk-XC656O42.js";
import "./chunk-NAVJD2PQ.js";
import "./chunk-QYPT3QUD.js";
import "./chunk-QMBEW7EW.js";
import "./chunk-DGEIYUC3.js";
import "./chunk-MPHPFVKK.js";
import "./chunk-GLNBDYUX.js";
import "./chunk-DJ2GSRLV.js";
import "./chunk-EIMKVOSF.js";
import "./chunk-RPYYTL7E.js";
import "./chunk-2J3OJGTL.js";
import "./chunk-P3QQPMQA.js";
import "./chunk-6O5DVH27.js";
import "./chunk-GLCZKT5V.js";
import "./chunk-2DNKEBXY.js";
import "./chunk-4K3RV3OA.js";
import "./chunk-VGC4I5JJ.js";
import "./chunk-E4WHKETF.js";
import "./chunk-UEJESCS7.js";
import {
  BaseDeclarativeTool,
  BaseToolInvocation,
  ToolDisplayNames,
  ToolNames
} from "./chunk-CFDR3GNL.js";
import "./chunk-H35Q5CEG.js";
import "./chunk-46UV252V.js";
import "./chunk-ZBVS26BY.js";
import "./chunk-BFHXDAR7.js";
import "./chunk-TYERNYH4.js";
import "./chunk-UH7Z7Y45.js";
import "./chunk-O2ZYHG33.js";
import "./chunk-W4RQUHY3.js";
import "./chunk-G7XXKQYS.js";
import {
  createDebugLogger
} from "./chunk-3RXUYQJI.js";
import "./chunk-VOQXFAY5.js";
import "./chunk-75DOP5OR.js";
import "./chunk-DMTGGOSA.js";
import "./chunk-YQ3U5MUC.js";
import "./chunk-AMDSOFFV.js";
import "./chunk-QUGAUQGJ.js";
import {
  init_esbuild_shims
} from "./chunk-5O2XNYP6.js";
import {
  __name
} from "./chunk-J2S4EL5Y.js";

// packages/core/src/tools/enterPlanMode.ts
init_esbuild_shims();
var debugLogger = createDebugLogger("ENTER_PLAN_MODE");
var enterPlanModeToolDescription = `Use this tool only after the user explicitly asks to switch into plan mode or confirms they want plan mode. Entering plan mode is a privilege reduction, so it does not require user confirmation at execution time.

## When to Use This Tool
Use this tool when the user has opted into plan mode for a task that should be read-only while the plan is formed, such as multi-file changes, design choices, or ambiguous requirements.

## When NOT to Use This Tool
Do not use this tool just because a task involves planning, is complex, or requires investigation. In the current mode, you can still think, inspect files, ask clarifying questions, and present a plan without switching modes.

## Important
If plan mode seems helpful but the user has not asked for it, ask first. Do NOT use this tool if the user has explicitly asked you not to use plan mode.`;
var enterPlanModeToolSchemaData = {
  name: "enter_plan_mode",
  description: enterPlanModeToolDescription,
  parametersJsonSchema: {
    type: "object",
    properties: {
      userRequested: {
        type: "boolean",
        description: "Set to true ONLY when the user explicitly asked for plan mode in this turn, or explicitly confirmed they want it. Leave unset (or false) when you are deciding to plan on your own without the user asking. In YOLO mode, an explicit user request will not take effect unless this is true."
      }
    },
    additionalProperties: false,
    $schema: "http://json-schema.org/draft-07/schema#"
  }
};
var EnterPlanModeToolInvocation = class extends BaseToolInvocation {
  constructor(config, params) {
    super(params);
    this.config = config;
  }
  static {
    __name(this, "EnterPlanModeToolInvocation");
  }
  getDescription() {
    return "Enter plan mode";
  }
  /**
   * Entering plan mode lowers privileges, so it is always allowed without a
   * confirmation prompt.
   */
  async getDefaultPermission() {
    return "allow";
  }
  async execute(_signal) {
    if (isPlanLifecycleToolUnavailableInSubagent(ToolNames.ENTER_PLAN_MODE)) {
      return buildSubagentPlanToolBlockedResult(
        ToolNames.ENTER_PLAN_MODE,
        "EnterPlanModeTool",
        debugLogger
      );
    }
    if (this.config.getApprovalMode() === "yolo" /* YOLO */ && !this.params.userRequested) {
      debugLogger.info(
        "Blocked model-initiated plan entry from YOLO (userRequested=%s)",
        this.params.userRequested
      );
      return {
        llmContent: "Plan mode was not entered: the session is in YOLO mode, which the user explicitly chose for low-friction execution. Continue investigating and presenting your plan in the current mode without switching. If the user explicitly asked for plan mode in this turn, retry this tool call with userRequested: true.",
        returnDisplay: "Stayed in YOLO mode (plan mode not entered)."
      };
    }
    const isAcpMode = this.config.getExperimentalZedIntegration?.() || this.config.getInputFormat?.() === "stream-json" /* STREAM_JSON */;
    if (!this.config.isInteractive() && !isAcpMode) {
      return {
        llmContent: "Cannot enter plan mode in non-interactive mode without ACP support. The gate exit paths require user interaction.",
        returnDisplay: "Plan mode unavailable in non-interactive mode."
      };
    }
    try {
      if (this.config.getApprovalMode() !== "plan" /* PLAN */) {
        this.config.setApprovalMode("plan" /* PLAN */);
      }
    } catch (error) {
      const errorMessage = error instanceof Error ? error.message : String(error);
      debugLogger.error(
        `[EnterPlanModeTool] Failed to set approval mode to plan: ${errorMessage}`
      );
      return {
        llmContent: `Failed to enter plan mode: ${errorMessage}`,
        returnDisplay: `Error entering plan mode: ${errorMessage}`
      };
    }
    try {
      const registry = this.config.getToolRegistry();
      const exitPlanModeName = ToolNames.EXIT_PLAN_MODE;
      const revealedBefore = registry.isDeferredToolRevealed(exitPlanModeName);
      if (!revealedBefore) {
        registry.revealDeferredTool(exitPlanModeName);
        const geminiClient = this.config.getGeminiClient();
        if (geminiClient) {
          try {
            await geminiClient.setTools();
          } catch (setErr) {
            registry.unrevealDeferredTool(exitPlanModeName);
            debugLogger.error(
              `[EnterPlanModeTool] Failed to sync exit_plan_mode tool declaration: ${setErr instanceof Error ? setErr.message : String(setErr)}`
            );
          }
        }
      }
    } catch (error) {
      debugLogger.warn(
        `[EnterPlanModeTool] Failed to reveal exit_plan_mode: ${error instanceof Error ? error.message : String(error)}`
      );
    }
    return {
      llmContent: getPlanModeSystemReminder(this.config.getSdkMode()),
      returnDisplay: "Entered plan mode."
    };
  }
};
var EnterPlanModeTool = class _EnterPlanModeTool extends BaseDeclarativeTool {
  constructor(config) {
    super(
      _EnterPlanModeTool.Name,
      ToolDisplayNames.ENTER_PLAN_MODE,
      enterPlanModeToolDescription,
      "think" /* Think */,
      enterPlanModeToolSchemaData.parametersJsonSchema,
      true,
      // isOutputMarkdown
      false,
      // canUpdateOutput
      false,
      // shouldDefer — always visible so explicit plan-mode requests work
      false,
      // alwaysLoad
      "plan mode enter start"
    );
    this.config = config;
  }
  static {
    __name(this, "EnterPlanModeTool");
  }
  static Name = ToolNames.ENTER_PLAN_MODE;
  get maxOutputChars() {
    return Number.POSITIVE_INFINITY;
  }
  createInvocation(params) {
    return new EnterPlanModeToolInvocation(this.config, params);
  }
};
export {
  EnterPlanModeTool
};
/**
 * @license
 * Copyright 2025 Qwen
 * SPDX-License-Identifier: Apache-2.0
 */
