Skip to content

feat: third-party API support and readline REPL fallback#1

Open
LHL3341 wants to merge 1 commit intoconghui:mainfrom
LHL3341:feat/third-party-api-and-repl
Open

feat: third-party API support and readline REPL fallback#1
LHL3341 wants to merge 1 commit intoconghui:mainfrom
LHL3341:feat/third-party-api-and-repl

Conversation

@LHL3341
Copy link
Copy Markdown

@LHL3341 LHL3341 commented Apr 2, 2026

Summary

  • Third-party API support (): auto-detect whether ANTHROPIC_BASE_URL points to the official api.anthropic.com or a third-party proxy. For proxies, automatically disable incompatible features (nonessential traffic, experimental betas, interleaved thinking, prompt caching, sandbox) and bypass system proxy env vars. For the official API, all settings remain at defaults.

  • Readline REPL fallback (src/cli/repl.ts): standalone readline-based interactive interface for environments where the Ink/React terminal UI is unavailable. Reuses ask() from QueryEngine for full multi-turn conversation, streams responses as they arrive, shows tool usage and per-turn cost summary.

Usage

# Default (official API)
ANTHROPIC_API_KEY=sk-ant-xxx ./run.sh

# Third-party proxy — extra compat flags applied automatically
ANTHROPIC_BASE_URL=http://your-proxy:port ANTHROPIC_API_KEY=xxx ./run.sh

## run.sh
- Auto-detect whether ANTHROPIC_BASE_URL points to the official API
  (api.anthropic.com) or a third-party proxy
- For third-party proxies: disable incompatible features
  (nonessential traffic, experimental betas, interleaved thinking,
  prompt caching, sandbox) and clear proxy env vars for direct connection
- For the official API: leave all settings at their defaults
- All three variables (ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL,
  ANTHROPIC_MODEL) can be overridden via environment variables before
  calling the script

## src/cli/repl.ts
- Add a standalone readline-based REPL as a fallback interactive
  interface for environments where the Ink/React terminal UI is
  unavailable
- Reuses ask() from QueryEngine for multi-turn conversation with full
  context persistence across turns
- Streams assistant text to stdout as it arrives
- Shows tool usage ([Tool: name] with brief input summary) in color
- Displays cost/turn summary after each response
- Handles Ctrl+C (abort current turn) and Ctrl+D / exit (quit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant