def execute(self, state: State) -> Action: plugin_to_select = state.command.replace(f'{self.SELECT_DIRECTIVE}', '').strip() plugin_to_select = extract_quoted_agent_name(plugin_to_select) agent_descriptor = self.agent_datasource.get_agent_descriptor( plugin_to_select) plugins_config = self.config_storage.read_config(None) if not agent_descriptor: return create_error_select(plugin_to_select) if agent_descriptor and not agent_descriptor.installed: logger.info( f'installing dependencies of plugin {agent_descriptor.name}') command = f'$CLAI_PATH/fileExist.sh {agent_descriptor.pkg_name} $CLAI_PATH' \ f'{" --user" if plugins_config.user_install else ""}' action_selected_to_return = Action(suggested_command=command, execute=True) else: self.select_plugin(plugin_to_select, state) action_selected_to_return = Action(suggested_command=":", execute=True) action_selected_to_return.origin_command = state.command return action_selected_to_return
def execute(self, state: State) -> Action: orchestrator_to_select = state.command.replace( f'{self.SELECT_DIRECTIVE}', '').strip() verbose = False if self.__VERBOSE_MODE in orchestrator_to_select: verbose = True orchestrator_to_select = "" else: orchestrator_to_select = extract_quoted_agent_name( orchestrator_to_select) if orchestrator_to_select: self.orchestrator_provider.select_orchestrator( orchestrator_to_select) return create_orchestrator_list( self.orchestrator_provider.get_current_orchestrator_name(), self.orchestrator_provider.all_orchestrator(), verbose)
def execute(self, state: State) -> Action: plugin_to_select = state.command.replace(f'{self.UNSELECT_DIRECTIVE}', '').strip() plugin_to_select = extract_quoted_agent_name(plugin_to_select) selected = self.agent_datasource.unselect_plugin(plugin_to_select, state.user_name) if selected: self.stats_tracker.log_deactivate_skills(state.user_name, plugin_to_select) plugins_config = self.config_storage.read_config(state.user_name) if plugins_config.selected is not None and selected.name in plugins_config.selected: plugins_config.selected.remove(selected.name) self.config_storage.store_config(plugins_config, state.user_name) action_to_return = create_message_list( self.agent_datasource.get_current_plugin_name(state.user_name), self.agent_datasource.all_plugins() ) action_to_return.origin_command = state.command return action_to_return
def execute_post(self, state: State) -> Action: plugin_to_select = state.command.replace(f'{self.SELECT_DIRECTIVE}', '').strip() plugin_to_select = extract_quoted_agent_name(plugin_to_select) agent_descriptor = self.agent_datasource.get_agent_descriptor( plugin_to_select) if not agent_descriptor: return Action() if state.result_code == '0': self.agent_datasource.mark_plugins_as_installed( plugin_to_select, state.user_name) return self.select_plugin(plugin_to_select, state) return create_message_list( self.agent_datasource.get_current_plugin_name(state.user_name), self.agent_datasource.all_plugins())