Files
codewhale/npm/deepseek-tui
Hunter Bown 229f02ea2c feat(npm): install.js network resilience for slow / firewalled networks
A community user from China reported `npm install deepseek-tui`
took 18 minutes through a CN npm mirror. The bottleneck is the
GitHub Releases binary fetch (~46 MB across two binaries), not the
npm tarball (which is 6.9 kB). The CN mirror does NOT proxy GitHub
release downloads, so any user behind a slow or lossy connection
is hitting the GitHub fetch directly with no resilience.

Four behaviors added to `npm/deepseek-tui/scripts/install.js`:

1. **Retry with exponential backoff.** Up to 5 attempts on network
   errors (ECONNRESET, ECONNREFUSED, ETIMEDOUT, EAI_AGAIN,
   network/host unreachable, EPIPE, ECONNABORTED) and 5xx upstream
   responses. Backoff `1s, 2s, 4s, 8s, 16s` with ±20% jitter. 4xx
   and checksum-mismatch are flagged non-retryable so we don't
   thrash on permanent failures. Final error includes the underlying
   message and the attempt count.

2. **Per-attempt total timeout + stall detector.** Total timeout
   defaults to 5 minutes per attempt (`DEEPSEEK_TUI_DOWNLOAD_TIMEOUT_MS`,
   alias `DEEPSEEK_DOWNLOAD_TIMEOUT_MS`). A stall detector aborts
   the request when no bytes arrive for 30 s
   (`DEEPSEEK_TUI_DOWNLOAD_STALL_MS`, alias
   `DEEPSEEK_DOWNLOAD_STALL_MS`) so a hung connection doesn't waste
   the whole timeout. Both budgets are surfaced in the error so the
   user can dial them up if they're on a slow pipe.

3. **HTTPS_PROXY / HTTP_PROXY support — pure Node, no new
   dependencies.** Detects `HTTPS_PROXY` / `HTTP_PROXY` (and the
   lowercase variants) and routes through the proxy via CONNECT
   tunneling. `NO_PROXY` exclusion list honored, with `*` and dotted-
   suffix matching. Proxy auth via standard `user:pass@` URL form is
   passed through as `Proxy-Authorization: Basic ...`. Pure-Node
   implementation using `net` + `tls` + `http` + `https` builtins —
   no `https-proxy-agent` dependency added.

4. **Download progress indicator.** Writes to stderr every ~1 MB
   or every 2 s in TTY mode using `\r` to overwrite a single line.
   Non-TTY mode (CI, piped) emits one line per 5 MB so logs stay
   reasonable. Suppressed when `DEEPSEEK_TUI_QUIET_INSTALL=1` or
   when `npm_config_loglevel` is `silent` or `error`. Falls back to
   `N MB downloaded` when the response has no `Content-Length`.

Public API unchanged: existing callers of `getBinaryPath` and `run`
keep working identically when no new env vars are set. The escape
hatch `DEEPSEEK_TUI_DISABLE_INSTALL=1` still exits cleanly.

Verified locally:

* `node -c install.js` and module-load syntax checks.
* `DEEPSEEK_TUI_FORCE_DOWNLOAD=1 DEEPSEEK_TUI_VERSION=0.8.10 node
  install.js` — real GitHub Releases download succeeded with
  visible progress, both binaries landed.
* `HTTPS_PROXY=http://invalid.proxy.local:9999 ... node install.js`
  — proxy path exercised, fails cleanly with the bad host named
  in the error message after retries exhausted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 22:19:34 -05:00
..

deepseek-tui

Install and run the deepseek and deepseek-tui binaries from GitHub release artifacts.

Install

npm install -g deepseek-tui
# or
pnpm add -g deepseek-tui

For project-local usage:

npm install deepseek-tui
npx deepseek-tui --help

postinstall downloads platform binaries into bin/downloads/ and exposes deepseek and deepseek-tui commands.

First run

deepseek login --api-key "YOUR_DEEPSEEK_API_KEY"
deepseek doctor
deepseek

The deepseek facade and deepseek-tui binary share ~/.deepseek/config.toml for DeepSeek auth and default model settings. Common TUI commands are available directly through the facade, including deepseek doctor, deepseek models, deepseek sessions, and deepseek resume --last.

The app talks to DeepSeek's documented OpenAI-compatible Chat Completions API. Set DEEPSEEK_BASE_URL only if you need the China endpoint or DeepSeek beta features such as strict tool mode, chat prefix completion, or FIM completion.

NVIDIA NIM-hosted DeepSeek V4 Pro is also supported:

deepseek auth set --provider nvidia-nim --api-key "YOUR_NVIDIA_API_KEY"
deepseek --provider nvidia-nim

For a single process, set DEEPSEEK_PROVIDER=nvidia-nim and NVIDIA_API_KEY or NVIDIA_NIM_API_KEY (with DEEPSEEK_API_KEY as a compatibility fallback). The NIM default model is deepseek-ai/deepseek-v4-pro and the default base URL is https://integrate.api.nvidia.com/v1. With --provider nvidia-nim, --model deepseek-v4-flash maps to deepseek-ai/deepseek-v4-flash.

Supported platforms

Prebuilt binaries for the GitHub release are downloaded automatically:

  • Linux x64
  • Linux arm64 (v0.8.8+)
  • macOS x64 / arm64
  • Windows x64

Other platform/architecture combinations (musl, riscv64, FreeBSD, …) aren't shipped as prebuilts. The postinstall will exit with a clear error pointing you at cargo install deepseek-tui-cli deepseek-tui --locked and the full docs/INSTALL.md build-from-source guide.

Configuration

  • Default binary version comes from deepseekBinaryVersion in package.json.
  • Set DEEPSEEK_TUI_VERSION or DEEPSEEK_VERSION to override the release version.
  • Set DEEPSEEK_TUI_GITHUB_REPO or DEEPSEEK_GITHUB_REPO to override the source repo (defaults to Hmbown/DeepSeek-TUI).
  • Set DEEPSEEK_TUI_FORCE_DOWNLOAD=1 to force download even when the cached binary is already present.
  • Set DEEPSEEK_TUI_DISABLE_INSTALL=1 to skip install-time download.
  • Set DEEPSEEK_TUI_OPTIONAL_INSTALL=1 to make the postinstall step warn and exit 0 on download/extract errors instead of failing npm install (useful in CI matrices).

Release integrity

  • npm publish runs a release-asset check to ensure all required binary assets exist for the target GitHub release before publishing.
  • Install-time downloads are verified against the release checksum manifest before the wrapper marks them executable.
  • Set DEEPSEEK_TUI_RELEASE_BASE_URL to point the installer at a local or staged release-asset directory for smoke tests.