diff --git a/CHANGELOG.md b/CHANGELOG.md index 50f93a4ea..a78bf3d6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Only write entries that are worth mentioning to users. ## Unreleased +- Web: Enable `trust_env` in aiohttp client session to respect proxy environment variables (`https_proxy`, `http_proxy`, etc.) + ## 1.30.0 (2026-04-02) - Shell: Refine idle background completion auto-trigger — resumed shell sessions no longer auto-start a foreground turn from stale pending background notifications before the user sends a message, and fresh background completions now wait briefly while the user is actively typing to avoid stealing the prompt or breaking CJK IME composition @@ -45,6 +47,7 @@ Only write entries that are worth mentioning to users. - Core: Add OS and shell information to the system prompt — the model now knows which platform it is running on and receives a Windows-specific instruction to prefer built-in tools over Shell commands, preventing Linux command errors in PowerShell - Shell: Fix `command` parameter description saying "bash command" regardless of platform — the description is now platform-neutral - Web: Fix auto-title overwriting manual session rename — when a user renames a session through the web UI, the new title is now preserved and no longer replaced by the auto-generated title + ## 1.28.0 (2026-03-30) - Core: Fix file write/replace tools freezing the event loop — diff computation (`build_diff_blocks`) is now offloaded to a thread via `asyncio.to_thread`, preventing the UI from hanging when editing large files diff --git a/docs/en/configuration/env-vars.md b/docs/en/configuration/env-vars.md index 5d4739607..0986e5e43 100644 --- a/docs/en/configuration/env-vars.md +++ b/docs/en/configuration/env-vars.md @@ -117,6 +117,35 @@ export OPENAI_API_KEY="sk-xxx" | `KIMI_CLI_PASTE_CHAR_THRESHOLD` | Character threshold for folding pasted text (default: `1000`) | | `KIMI_CLI_PASTE_LINE_THRESHOLD` | Line threshold for folding pasted text (default: `15`) | +### Proxy environment variables + +Kimi Code CLI supports configuring HTTP/HTTPS proxies through standard proxy environment variables. These variables affect all HTTP requests to external APIs (including Kimi API, OAuth services, web scraping, etc.). + +| Environment Variable | Description | +| --- | --- | +| `http_proxy` / `HTTP_PROXY` | HTTP proxy server address | +| `https_proxy` / `HTTPS_PROXY` | HTTPS proxy server address | +| `all_proxy` / `ALL_PROXY` | Proxy server address for all protocols | +| `no_proxy` / `NO_PROXY` | Comma-separated list of addresses that do not use proxy | + +**Proxy configuration examples** + +```sh +# Set HTTPS proxy +export https_proxy="http://proxy.example.com:8080" + +# Set proxy with authentication +export https_proxy="http://username:password@proxy.example.com:8080" + +# Bypass proxy for certain addresses +export no_proxy="localhost,127.0.0.1,api.moonshot.cn" +``` + +::: tip +- Setting both `http_proxy` and `https_proxy` ensures all types of requests go through the proxy +- `no_proxy` supports wildcards, e.g., `.example.com` matches all subdomains of `example.com` +::: + ### `KIMI_SHARE_DIR` Customize the share directory path for Kimi Code CLI. The default path is `~/.kimi`, where configuration, sessions, logs, and other runtime data are stored. diff --git a/docs/en/release-notes/changelog.md b/docs/en/release-notes/changelog.md index 4b0e3a2be..112d88206 100644 --- a/docs/en/release-notes/changelog.md +++ b/docs/en/release-notes/changelog.md @@ -4,6 +4,8 @@ This page documents the changes in each Kimi Code CLI release. ## Unreleased +- Web: Enable `trust_env` in aiohttp client session to respect proxy environment variables (`https_proxy`, `http_proxy`, etc.) + ## 1.30.0 (2026-04-02) - Shell: Refine idle background completion auto-trigger — resumed shell sessions no longer auto-start a foreground turn from stale pending background notifications before the user sends a message, and fresh background completions now wait briefly while the user is actively typing to avoid stealing the prompt or breaking CJK IME composition diff --git a/docs/zh/configuration/env-vars.md b/docs/zh/configuration/env-vars.md index 336f4cb81..140a37697 100644 --- a/docs/zh/configuration/env-vars.md +++ b/docs/zh/configuration/env-vars.md @@ -117,6 +117,35 @@ export OPENAI_API_KEY="sk-xxx" | `KIMI_CLI_PASTE_CHAR_THRESHOLD` | 粘贴文本折叠的字符数阈值(默认 `1000`) | | `KIMI_CLI_PASTE_LINE_THRESHOLD` | 粘贴文本折叠的行数阈值(默认 `15`) | +### 代理环境变量 + +Kimi Code CLI 支持通过标准的代理环境变量配置 HTTP/HTTPS 代理。这些变量会影响所有对外部 API 的 HTTP 请求(包括 Kimi API、OAuth 服务、网页抓取等)。 + +| 环境变量 | 说明 | +| --- | --- | +| `http_proxy` / `HTTP_PROXY` | HTTP 代理服务器地址 | +| `https_proxy` / `HTTPS_PROXY` | HTTPS 代理服务器地址 | +| `all_proxy` / `ALL_PROXY` | 所有协议的代理服务器地址 | +| `no_proxy` / `NO_PROXY` | 不使用代理的地址列表(逗号分隔) | + +**设置代理示例** + +```sh +# 设置 HTTPS 代理 +export https_proxy="http://proxy.example.com:8080" + +# 设置带有认证的代理 +export https_proxy="http://username:password@proxy.example.com:8080" + +# 对某些地址不使用代理 +export no_proxy="localhost,127.0.0.1,api.moonshot.cn" +``` + +::: tip 提示 +- 同时设置 `http_proxy` 和 `https_proxy` 可以确保所有类型的请求都经过代理 +- `no_proxy` 中的地址支持通配符,如 `.example.com` 会匹配所有 `example.com` 的子域名 +::: + ### `KIMI_SHARE_DIR` 自定义 Kimi Code CLI 的共享目录路径。默认路径为 `~/.kimi`,配置、会话、日志等运行时数据存储在此目录下。 diff --git a/docs/zh/release-notes/changelog.md b/docs/zh/release-notes/changelog.md index e88ceba79..3cbcd8bc4 100644 --- a/docs/zh/release-notes/changelog.md +++ b/docs/zh/release-notes/changelog.md @@ -4,6 +4,8 @@ ## 未发布 +- Web:在 aiohttp 客户端会话中启用 `trust_env`,以支持代理环境变量(`https_proxy`、`http_proxy` 等) + ## 1.30.0 (2026-04-02) - Shell:细化空闲时后台完成的自动触发行为——恢复的 Shell 会话在用户发送消息前,不会因为历史遗留的后台通知而自动启动新的前景轮次;当用户正在输入时,新的后台完成事件也会短暂延后触发,避免抢占提示符或打断 CJK 输入法组合态 diff --git a/src/kimi_cli/utils/aiohttp.py b/src/kimi_cli/utils/aiohttp.py index bff269076..410ba991b 100644 --- a/src/kimi_cli/utils/aiohttp.py +++ b/src/kimi_cli/utils/aiohttp.py @@ -19,6 +19,7 @@ def new_client_session( timeout: aiohttp.ClientTimeout | None = None, ) -> aiohttp.ClientSession: return aiohttp.ClientSession( + trust_env=True, connector=aiohttp.TCPConnector(ssl=_ssl_context), timeout=timeout or _DEFAULT_TIMEOUT, )