iTerm2
iTerm2 is a terminal emulator for Mac OS X that does amazing things
...) and supports scripting and automation via an API (including a Python library in the api/library/python/iterm2 path). To build it, you can compile the Xcode project included, and there is documentation and instructions linked from the project’s README (note: issue tracking is handled via GitLab, as the repository refers issues there). The code is organized into modular parts (resources, UI, helpers, submodules), and the project is actively maintained with many releases and tags.