Skip to content

About

Launcher for running pi on the AntSeed network in Termux on Android

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

antseed-pi-termux

Launcher for running the pi coding agent (@earendil-works/pi-coding-agent) on the AntSeed network inside Termux on Android.

It installs everything you need, starts the AntSeed buyer proxy on http://localhost:8377, loads the pi-antseed extension, and drops you into pi with every discovered AntSeed route available in the model selector.

What you get

  • install.sh — one-shot installer for all dependencies (Termux packages, npm CLIs, the launcher, the pi extension).
  • antseed-pi — launcher on your $PATH: starts the buyer proxy if it isn't running, waits for it to answer, then execs pi. Also manages the proxy (status / stop / logs / peers) and ships a free-route model picker (pick / models) that bypasses pi's own (slow, sometimes freezing) selector.
  • antseed-pi-routes — the dependency-free Node helper the picker uses; also usable standalone for scripts (--tsv, --json, --all, --refresh).

Prerequisites

  • Termux installed from F-Droid or the GitHub releases page. Do not use the Play Store build — it's outdated and unmaintained.
  • Android 7+ recommended; a few hundred MB of free storage.
  • An AntSeed identity: a secp256k1 private key in hex (ANTSEED_IDENTITY_HEX).
  • USDC on Base to pay providers — deposit after install (antseed buyer deposit or antseed payments).

Install

pkg update -y && pkg install -y git
git clone https://github.com/CommunityPokeOrg/antseed-pi-termux
cd antseed-pi-termux
./install.sh

One-shot alternative (installs the launcher without cloning):

curl -fsSL https://raw.githubusercontent.com/CommunityPokeOrg/antseed-pi-termux/main/install.sh | bash

The installer:

  1. probes a small set of official Termux mirrors and points apt at the fastest one, pinning it via TERMUX_PKG_NO_MIRROR_SELECT so pkg's own mirror rotation doesn't override it (keeps the default if probing fails — no prompts, safe under curl | bash)
  2. pkg/apt-get installs nodejs, git, jq, curl, coreutils, procps plus the native-build toolchain (python, build-essential, openssl-static) — better-sqlite3 and node-datachannel ship no Android prebuilds and compile from source
  3. npm install -g --ignore-scripts @antseed/cli @earendil-works/pi-coding-agent, then replays the native builds npm's lifecycle scripts can't do under Node >= 26 (node-datachannel is built directly with cmake-js)
  4. installs bin/antseed-pi and bin/antseed-pi-routes to $PREFIX/bin
  5. creates ~/.antseed-pi/env for your identity
  6. runs pi install git:github.com/AntSeed/pi-antseed so the extension loads every time pi starts

Configure your identity

Either edit ~/.antseed-pi/env:

ANTSEED_IDENTITY_HEX=<your-private-key-hex>

or just run antseed-pi — it prompts for the key on first run and saves it (mode 0600). You can also export ANTSEED_IDENTITY_HEX=... in your shell.

Run

termux-wake-lock   # recommended: stops Android killing the proxy
antseed-pi pick

antseed-pi pick lists the free routes (zero-priced input/output on every provider that can serve them — unknown or missing prices are never shown as free), you pick a number, and it launches pi directly with pi --model antseed/<service-id>@<peer>. This avoids pi's built-in model selector entirely, which can hang or freeze on Termux when the network has many routes.

  1) minimax-m2.7 @ some-peer (bbbbbbbb) · rep 78  [openai-responses]
  2) img-gen @ eeeeeeeeeeee                        [openai-completions]
Pick a route [1-2] (q to quit):

To see every route (paid and unknown-price too):

antseed-pi models          # free routes only
antseed-pi models --all    # all routes, with a price column
antseed-pi models --refresh   # force a DHT re-scan first

Or skip the picker: antseed-pi launches pi as before and you can use the in-app selector (Ctrl+L or /model) with ids of the form antseed/<service-id>@<peer-prefix>[-<peer-name>][-rep<score>] (e.g. antseed/minimax-m2.7@bbbbbbbbbbbb-rep5), or pass the id directly:

antseed-pi --model antseed/minimax-m2.7@bbbbbbbbbbbb-rep5

Routes are discovered from /_antseed/peers and ordered by peer reputation. To restrict what's offered, set e.g. ANTSEED_MODELS="minimax-m2.7,arcee-trinity-thinking" before launching.

Anything you pass to antseed-pi that isn't a subcommand is forwarded to pi (antseed-pi --help, antseed-pi -p "hello", ...). Use antseed-pi -- <args> to force passthrough — and inside pick, anything after -- is forwarded too (antseed-pi pick -- -p "hello").

Helper commands

Command What it does
antseed-pi / antseed-pi start start proxy if needed + launch pi
antseed-pi pick pick a free route from a numbered menu, launch pi with --model
antseed-pi models [--all] list routes as pi registers them (default: free only)
antseed-pi status proxy / identity / CLI status
antseed-pi stop stop the managed buyer proxy
antseed-pi logs [N] tail the proxy log (~/.antseed-pi/buyer.log)
antseed-pi peers pretty-print /_antseed/peers

Useful antseed commands

antseed network browse --services      # who's on the network + pricing
antseed buyer status                   # connection + deposit state
antseed buyer balance                  # USDC balance
antseed buyer deposit                  # funding address + QR
antseed payments                       # local funding portal on :3118

How it works

antseed buyer start runs a buyer proxy on 127.0.0.1:8377 — it handles peer discovery, routing, payment channels, and protocol adaptation. The pi-antseed extension registers an antseed provider in pi, reads each peer's advertised API protocol from /_antseed/peers, registers every service/peer pair as a pi model, and sends x-antseed-pin-peer: <peer> on each request. You never need a session-wide antseed buyer connection set pin.

antseed-pi-routes replicates that discovery (same /_antseed/peers data, same service@peer12[-name][-repN] id format, same reputation precedence via ~/.antseed/buyer.state.json, same ANTSEED_MODELS allow-list) and resolves each route's advertised price from providerPricing / unit-billing metadata. A route counts as free only when every provider that can serve it prices input, output, cached input, and per-image units at exactly $0; missing or partial pricing is reported as unknown, never free.

Tests

bash tests/run.sh

Offline suite: boots a stub buyer proxy with fixture peers, verifies free/paid/unknown classification, route id formatting (slug + rep suffix), reputation precedence, the ANTSEED_MODELS allow-list, and an end-to-end antseed-pi pick run against stub antseed/pi binaries.

Configuration

Env var Default Purpose
ANTSEED_IDENTITY_HEX — (required) secp256k1 buyer identity key
ANTSEED_BASE_URL http://localhost:8377 buyer proxy URL
ANTSEED_API_KEY unset only if the proxy sits behind auth
ANTSEED_MODELS all discovered comma-separated route/service allow-list
ANTSEED_PI_HOME ~/.antseed-pi launcher state dir (env, pid, log)
ANTSEED_PI_READY_TIMEOUT 60 seconds to wait for the proxy

Troubleshooting

  • Android kills the proxy in the background → run termux-wake-lock, and disable battery optimization for Termux in system settings.
  • antseed-pi dies with "antseed buyer start failed" → antseed-pi logs for the proxy log; check ANTSEED_IDENTITY_HEX is set.
  • No antseed/... models in pi → proxy isn't up or sees no peers: antseed-pi status, antseed network browse --services, then /reload in pi.
  • Connection state: idle in antseed buyer status → the proxy isn't running; launch via antseed-pi or run antseed buyer start yourself.
  • Insufficient deposits → antseed buyer balance; top up with antseed buyer deposit.
  • 5xx on a request → the pinned peer went offline; re-run antseed-pi peers, /reload, pick another route.
  • npm install fails on old Android → pkg upgrade nodejs or switch to pkg install nodejs-lts.

References

License

MIT

About

Launcher for running pi on the AntSeed network in Termux on Android

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages