// Force strict mode and setup for ESM
"use strict";
import {
  listTasks
} from "./chunk-KKRTYONM.js";
import "./chunk-TV6K2FB4.js";
import "./chunk-E2UVIFI2.js";
import "./chunk-CPBF7KYF.js";
import {
  getTeamName,
  resolveActiveTeamName
} from "./chunk-6AM5D4ME.js";
import "./chunk-VGC4I5JJ.js";
import {
  BaseDeclarativeTool,
  BaseToolInvocation,
  ToolDisplayNames,
  ToolNames
} from "./chunk-JGUT3LWZ.js";
import "./chunk-WIEO4CWB.js";
import "./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/task-list.ts
init_esbuild_shims();
var TaskListInvocation = class extends BaseToolInvocation {
  constructor(config, params) {
    super(params);
    this.config = config;
  }
  static {
    __name(this, "TaskListInvocation");
  }
  getDescription() {
    const filters = [];
    if (this.params.status) {
      filters.push(`status=${this.params.status}`);
    }
    if (this.params.owner) {
      filters.push(`owner=${this.params.owner}`);
    }
    if (this.params.blockedBy) {
      filters.push(`blockedBy=${this.params.blockedBy}`);
    }
    return filters.length > 0 ? `List tasks (${filters.join(", ")})` : "List all tasks";
  }
  async execute() {
    const teamName = resolveActiveTeamName(
      this.config.getTeamContext()?.teamName
    );
    if (!teamName) {
      const msg = "No active team. Create a team first.";
      return {
        llmContent: msg,
        returnDisplay: msg,
        error: { message: msg }
      };
    }
    const tasks = await listTasks(teamName, {
      status: this.params.status,
      owner: this.params.owner,
      blockedBy: this.params.blockedBy
    });
    if (tasks.length === 0) {
      const llmContent2 = "No tasks found.";
      return { llmContent: llmContent2, returnDisplay: llmContent2 };
    }
    const lines = tasks.map(
      (t) => `#${t.id} [${t.status}]` + (t.owner ? ` @${t.owner}` : "") + ` \u2014 ${t.subject}`
    );
    const manager = this.config.getTeamManager();
    if (manager && !getTeamName()) {
      try {
        const msgs = await manager.getLeaderMessages();
        if (msgs.length > 0) {
          lines.push("");
          lines.push("--- Teammate messages ---");
          for (const wrapped of manager.formatLeaderEnvelope(msgs)) {
            lines.push(wrapped);
          }
        }
      } catch {
      }
      if (manager.hasActiveTeammates()) {
        lines.push("");
        lines.push(
          "NOTE: Teammates are still working. Their results will be delivered as messages \u2014 do NOT call task_list again to check. End your turn and wait for teammate messages."
        );
      }
    }
    const llmContent = lines.join("\n");
    const display = {
      type: "task_list",
      tasks: tasks.map((t) => ({
        id: t.id,
        subject: t.subject,
        status: t.status,
        owner: t.owner
      }))
    };
    return { llmContent, returnDisplay: display };
  }
};
var TaskListTool = class _TaskListTool extends BaseDeclarativeTool {
  constructor(config) {
    super(
      _TaskListTool.Name,
      ToolDisplayNames.TASK_LIST,
      "List tasks in the team task list. All filter parameters are optional.",
      "read" /* Read */,
      {
        type: "object",
        properties: {
          status: {
            type: "string",
            enum: ["pending", "in_progress", "completed"],
            description: "Filter by task status."
          },
          owner: {
            type: "string",
            description: "Filter by owner agent name."
          },
          blockedBy: {
            type: "string",
            description: "Filter for tasks blocked by this task ID."
          }
        },
        additionalProperties: false
      }
    );
    this.config = config;
  }
  static {
    __name(this, "TaskListTool");
  }
  static Name = ToolNames.TASK_LIST;
  createInvocation(params) {
    return new TaskListInvocation(this.config, params);
  }
};
export {
  TaskListTool
};
/**
 * @license
 * Copyright 2025 Qwen
 * SPDX-License-Identifier: Apache-2.0
 */
