// Force strict mode and setup for ESM
"use strict";
import {
  disposeInboxLocks,
  unregisterLeader
} from "./chunk-RCEEXIOO.js";
import {
  deleteTeamDirs
} from "./chunk-TV6K2FB4.js";
import "./chunk-E2UVIFI2.js";
import "./chunk-CPBF7KYF.js";
import {
  isTeammate
} from "./chunk-6AM5D4ME.js";
import "./chunk-VGC4I5JJ.js";
import {
  BaseDeclarativeTool,
  BaseToolInvocation,
  ToolDisplayNames,
  ToolNames
} from "./chunk-JGUT3LWZ.js";
import "./chunk-WIEO4CWB.js";
import {
  createDebugLogger
} from "./chunk-7NFB7LBQ.js";
import "./chunk-TB6UDU4T.js";
import {
  init_esbuild_shims
} from "./chunk-5O2XNYP6.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
 */
