[docs]asyncdefget_missing_commands(agent_name=None,context=None):""" Identify commands that are used in agent instructions but not available in the system. Args: agent_name (str, optional): Name of the agent to check Returns: dict: Mapping of missing commands and potential plugins that provide them """ifcontextandnotagent_name:agent_name=context.agent_nameifnotagent_name:return{"error":"Agent name is required"}# Load agent datatry:agent_path=f"data/agents/local/{agent_name}/agent.json"ifnotos.path.exists(agent_path):agent_path=f"data/agents/shared/{agent_name}/agent.json"ifnotos.path.exists(agent_path):return{"error":f"Agent {agent_name} not found"}logger.info(f"missing commands: Loading agent data from {agent_path}")withopen(agent_path,'r')asf:agent_data=json.load(f)# Get all available commands from the provideravailable_commands=set(command_manager.functions.keys())logger.info(f"Available commands: {available_commands}")# Get agent's command listagent_commands=set(agent_data.get('commands',[]))logger.info(f"Agent commands: {agent_commands}")# Find commands that are mentioned but not availablemissing_commands=agent_commands-available_commandslogger.info(f"Missing commands: {missing_commands}")# Get command-plugin mappingcommand_plugin_mapping=awaitget_command_plugin_mapping()logger.info(f"Command-Plugin mapping: {command_plugin_mapping}")# Create result with missing commands and potential pluginsresult={}forcmdinmissing_commands:# If no plugins provide this command, still include it with an empty listifcmdnotincommand_plugin_mapping:result[cmd]=[]continueresult[cmd]=command_plugin_mapping.get(cmd,[])logger.info(f"Missing commands with plugins: {result}")returnresultexceptExceptionase:return{"error":str(e)}