from dataiku.llm.agent_tools import BaseAgentTool
from shortcut_api import pick, shortcut_get


class ListTeams(BaseAgentTool):
    def get_descriptor(self, tool):
        return {
            "description": "List Shortcut teams with their group IDs and workflow IDs.",
            "inputSchema": {"type": "object", "properties": {}, "additionalProperties": False},
        }

    def invoke(self, input, trace):
        return {"output": [
            pick(team, ("id", "name", "workflow_ids"))
            for team in shortcut_get("groups") if not team["archived"]
        ]}
