Termux (Android)
KosmoKrator runs on Android via Termux, a terminal emulator that provides a full Linux environment without root. This guide covers all three installation methods — static binary, PHAR, and source — with Termux-specific tips and workarounds.
Prerequisites
Section titled “Prerequisites”Install Termux from F-Droid. The Google Play version is outdated and no longer receives updates — always use the F-Droid release.
Once Termux is open, update the package index:
pkg update && pkg upgrade -yStatic Binary (Recommended)
Section titled “Static Binary (Recommended)”The fastest path. Most Android devices use ARM, so download the aarch64 binary. No PHP installation required.
pkg install -y curl
curl -fSL https://github.com/OpenCompanyApp/kosmokrator/releases/latest/download/kosmokrator-linux-aarch64 \ -o $PREFIX/bin/kosmo \ && chmod +x $PREFIX/bin/kosmoVerify:
kosmo --versionTip: Termux uses $PREFIX/bin (typically /data/data/com.termux/files/usr/bin) instead of /usr/local/bin. There is no sudo — Termux packages are installed in user space.
PHAR Package
Section titled “PHAR Package”If you prefer the PHAR, install PHP first:
pkg install -y php curl
curl -fSL https://github.com/OpenCompanyApp/kosmokrator/releases/latest/download/kosmokrator.phar \ -o $PREFIX/bin/kosmo \ && chmod +x $PREFIX/bin/kosmoTermux’s PHP package ships with curl, mbstring, openssl, and pdo_sqlite built in. Verify with:
php -m | grep -E 'curl|mbstring|openssl|pdo_sqlite|pcntl|readline'If any extensions are missing, install the matching Termux package:
pkg install -y php-pdo php-sqliteFrom Source
Section titled “From Source”A source checkout gives you the full development environment.
Install packages
Section titled “Install packages”pkg install -y php git composer opensshClone and install
Section titled “Clone and install”git clone https://github.com/OpenCompanyApp/kosmokrator.gitcd kosmokratorcomposer installRun directly from the checkout:
php bin/kosmo --renderer=ansiOr symlink for convenience:
ln -s "$(pwd)/bin/kosmo" $PREFIX/bin/kosmoTip: If Composer runs out of memory, set COMPOSER_MEMORY_LIMIT=-1 composer install to remove the cap.
First Run
Section titled “First Run”Run the setup wizard to configure your LLM provider:
kosmo setupThen start a session. Use ANSI mode for the most reliable experience:
kosmo --renderer=ansiThe ANSI renderer works well in Termux and does not depend on stty or pcntl features that may behave differently on Android.
Choosing a Renderer
Section titled “Choosing a Renderer”| Renderer | Termux Support | Notes |
|---|---|---|
ansi | Recommended | Pure escape codes, works everywhere, readline input |
tui | Experimental | Requires stty and a terminal that correctly reports size. May work in Termux but can be glitchy on some devices. |
If you want to try the TUI renderer, launch with kosmo --renderer=tui and fall back to ANSI if you encounter display issues.
Keyboard Tips
Section titled “Keyboard Tips”A hardware keyboard or Hacker’s Keyboard makes the experience much better. If you are using the default Termux soft keyboard:
- Swipe the extra-keys bar left/right to access
Ctrl,Tab,Esc, and arrow keys - Long-press the volume-down key while typing for
Ctrlcombos Ctrl+Ccancels a running tool,Ctrl+Dexits the session
Storage & Sessions
Section titled “Storage & Sessions”By default, KosmoKrator stores its SQLite database and configuration in ~/.kosmo/. In Termux, ~ resolves to /data/data/com.termux/files/home, which is private to the Termux app.
If you need to access project files on shared storage (Downloads, Documents, etc.), grant Termux storage access first:
termux-setup-storageThis creates ~/storage/ with symlinks to shared directories. You can then cd ~/storage/downloads to work on files there.
Troubleshooting
Section titled “Troubleshooting”stty: stdin not a terminal
Section titled “stty: stdin not a terminal”This warning is harmless. The ANSI renderer handles it gracefully. If you see persistent issues, force ANSI mode with --renderer=ansi.
SQLite errors or permission denied
Section titled “SQLite errors or permission denied”Ensure the storage directory is writable:
chmod -R 775 ~/.kosmo/If running from source, also check the project’s storage/ directory:
chmod -R 775 storage/Composer memory errors
Section titled “Composer memory errors”Termux’s default memory limit may be too low for Composer on some devices. Override it:
COMPOSER_MEMORY_LIMIT=-1 composer installProcess killed by Android
Section titled “Process killed by Android”Android may kill background Termux processes to reclaim memory. To keep sessions alive:
- Run
termux-wake-lockto acquire a wake lock - In Android settings, disable battery optimization for the Termux app
- Use Termux:API with
termux-notificationfor persistent foreground notifications
pcntl extension not available
Section titled “pcntl extension not available”The pcntl extension may not be available in Termux’s PHP build. KosmoKrator’s ANSI renderer works without it — Revolt’s event loop falls back to stream_select. You can safely ignore pcntl-related warnings when using ANSI mode.