main
py 34 lines 1.09 KB
Raw
1 import json
2 from typing import Any, TYPE_CHECKING
3 from helpers.files import VariablesPlugin
4 from helpers import files, projects, subagents
5 from helpers.print_style import PrintStyle
6
7 if TYPE_CHECKING:
8 from agent import Agent
9
10
11 class CallSubordinate(VariablesPlugin):
12 def get_variables(
13 self, file: str, backup_dirs: list[str] | None = None, **kwargs
14 ) -> dict[str, Any]:
15
16 # current agent instance
17 agent: Agent | None = kwargs.get("_agent", None)
18 # current project
19 project = projects.get_context_project_name(agent.context) if agent else None
20 # available agents in project (or global)
21 agents = subagents.get_available_agents_dict(project)
22
23 if agents:
24 profiles = {}
25 for name, subagent in agents.items():
26 profiles[name] = {
27 "title": subagent.title,
28 "description": subagent.description,
29 "context": subagent.context,
30 }
31 return {"agent_profiles": profiles}
32 else:
33 return {"agent_profiles": None}
34