Пример #1
0
    def provide_command_runner(self, command: str,
                               selected_agent: AgentRunner) -> CommandRunner:
        if command.startswith(CLAI_COMMAND_NAME):
            clai_command_name = command.replace(CLAI_COMMAND_NAME, "",
                                                1).strip()
            return self.__get_clai_command_runner(clai_command_name,
                                                  selected_agent)

        return AgentCommandRunner(selected_agent,
                                  self.server_status_datasource)
Пример #2
0
    def __get_clai_post_command_runner(
            self, clai_command_name: str,
            selected_agent: AgentRunner) -> PostCommandRunner:
        clai_post_commands_names = self.clai_post_commands.keys()

        commands_filtered = filter(clai_command_name.startswith,
                                   clai_post_commands_names)
        command_found = next(commands_filtered, None)

        if command_found:
            return self.clai_post_commands[command_found]

        return ClaiDelegateToAgentCommandRunner(
            AgentCommandRunner(selected_agent, self.server_status_datasource))