// Force strict mode and setup for ESM
"use strict";
import {
  disposeInboxLocks,
  unregisterLeader
} from "./chunk-TXVGVZYR.js";
import {
  deleteTeamDirs
} from "./chunk-2BIF2NVV.js";
import {
  isTeammate
} from "./chunk-LD2XBG6Z.js";
import "./chunk-OMX7CUOE.js";
import {
  BaseDeclarativeTool,
  BaseToolInvocation,
  ToolDisplayNames,
  ToolNames
} from "./chunk-PLY4F7QW.js";
import "./chunk-3UALQ56H.js";
import {
  createDebugLogger
} from "./chunk-C4K3FEQ2.js";
import "./chunk-Z2Z3GUXZ.js";
import {
  init_esbuild_shims
} from "./chunk-A4BMJM77.js";
import {
  __name
} from "./chunk-J2S4EL5Y.js";

// packages/core/src/tools/team-delete.ts
init_esbuild_shims();
var debug = createDebugLogger("TEAM_DELETE");
var TeamDeleteInvocation = class extends BaseToolInvocation {
  constructor(config, params) {
    super(params);
    this.config = config;
  }
  static {
    __name(this, "TeamDeleteInvocation");
  }
  getDescription() {
    return "Delete current team";
  }
  async execute() {
    if (isTeammate()) {
      const msg2 = "Only the team leader can delete the team.";
      return {
        llmContent: msg2,
        returnDisplay: msg2,
        error: { message: msg2 }
      };
    }
    const manager = this.config.getTeamManager();
    if (!manager) {
      const msg2 = "No active team to delete.";
      return {
        llmContent: msg2,
        returnDisplay: msg2,
        error: { message: msg2 }
      };
    }
    const teamFile = manager.getTeamFile();
    const teamName = teamFile.name;
    try {
      await manager.cleanup();
    } catch (err) {
      debug.warn("Team cleanup failed; resetting team state anyway:", err);
    }
    await deleteTeamDirs(teamName);
    await new Promise((r) => setTimeout(r, 250));
    await deleteTeamDirs(teamName);
    disposeInboxLocks(teamName);
    this.config.setTeamManager(null);
    this.config.setTeamContext(null);
    unregisterLeader();
    const display = {
      type: "team_result",
      teamName,
      action: "deleted"
    };
    const msg = `Team "${teamName}" deleted.`;
    return { llmContent: msg, returnDisplay: display };
  }
};
var TeamDeleteTool = class _TeamDeleteTool extends BaseDeclarativeTool {
  constructor(config) {
    super(
      _TeamDeleteTool.Name,
      ToolDisplayNames.TEAM_DELETE,
      "Delete the current team. Stops all teammates, cleans up team files, tasks, and inboxes. Only the team leader can use this.",
      "delete" /* Delete */,
      {
        type: "object",
        properties: {},
        additionalProperties: false
      }
    );
    this.config = config;
  }
  static {
    __name(this, "TeamDeleteTool");
  }
  static Name = ToolNames.TEAM_DELETE;
  createInvocation(params) {
    return new TeamDeleteInvocation(this.config, params);
  }
};
export {
  TeamDeleteTool
};
/**
 * @license
 * Copyright 2025 Qwen
 * SPDX-License-Identifier: Apache-2.0
 */
