Skip to content

feat: add qoder client support (bili qoder) - #654

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-09_qoder-client-support
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-09-09_qoder-client-support

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

bili qoder — qoder (Qoder CLI, npm @qoder-ai/qodercli / @qodercn-ai/qoderclicn) through the proxy, proxy mode (wire injection).

qoder's model endpoint scheme is hardcoded https with no base-URL override env, so /bili/ rewrites cannot reach it — cert-MITM is the only route (verified from the v1.1.47 bundles: qoder's built-in undici honors HTTPS_PROXY and NODE_EXTRA_CA_CERTS, which is additive, so the plain root CA suffices). OpenAI chat-completions wire → existing OpenAI compression pipeline.

Changes

  • src/client-config.ts: QoderConfig, qoderIsCnSite() (CN-site detection rule for the QODER_ vs QODERCN_ env prefix family — issue open question 4), resolveQoderHome() (QODER_CONFIG_DIR/QODERCN_CONFIG_DIR > *_CLI_HOME + dir name > ~/.qoder / ~/.qoder-cn), readQoderConfig() (read-only settings.json model discovery + QODER_MODEL_SERVER_HOST), QODER_DEFAULT_MODEL_HOSTS (prod + regional US/SG/JP + CN gateway; daily/test excluded).
  • src/launcher.ts: bili qoder in LAUNCH_CLIENTS; discoverRoutes qoder branch (default model hosts whitelisted for MITM, QODER_MODEL_SERVER_HOST replaces them per qoder's own resolution order); buildQoderEnv() (HTTPS_PROXY + NODE_EXTRA_CA_CERTS + BILLION_CONTEXT_PROXY, inherited proxy vars fully stripped); QODER_MODEL_TRANSPORT=http forced (default transport is a server feature gate whose legacy fallback wire is unverified — issue open question 1); REQ: codex 压缩预算协调 + 匿名代理模式拦截伪造(根本解决方案) #321 budget alignment via resolveQoderBudgetEnv()QODER_AUTOCOMPACT_WINDOW / QODERCN_AUTOCOMPACT_WINDOW (caps the effective window, so injection is always safe; no injection when the user self-aligned or the window is unresolvable — qoder's catalog is server-driven); resolveClientCommand qoderqodercli fallback; BILI_LAUNCHER_DIRECT warning.
  • src/discover.ts: qoder hosts in MITM domain auto-discovery + settings.json mtime watch.
  • src/cli.ts / README / AGENTS.md: help + docs.
  • Tests: 13 new (site detection, home resolution, config discovery, route discovery, env build, budget alignment, command resolution, full runLaunch integration).

v1 limitations (documented in code + issue)

  1. QODER_MODEL_TRANSPORT=http is forced — the legacy fallback wire is unverified on a real machine; revisit after verification (open question 1).
  2. CN-site detection: with BOTH intl and CN packages installed, a CN launch is detected as intl (degrades to no budget injection / intl-prefix transport env — never breaks the launch). QODERCLI_SITE=cn overrides.
  3. No MCP injection (proxy mode only; QODER_MCP_CONFIG compatibility unverified).
  4. Model window is server-driven and qoder model names are usually absent from bili's limits / models.dev registry — budget alignment is best-effort; the user's own QODER_AUTOCOMPACT_WINDOW remains the fallback (open question 3).

Pre-flight

  • npm run typecheck
  • npm test 1246/1247 — the single failure (resolveClientCommand: codex/claude resolve to themselves) is environmental and pre-existing: this sandbox has /usr/bin/codex installed; verified identical failure on clean master via git stash (passes on CI).
  • npm run build ✓; built CLI --help smoke-tested (qoder lines render).

Suggested real-machine verification (issue's first scenario): intl + PAT login, bili qoder — model traffic TLS-terminated via the proxy, /model/v1/chat/completions through the OpenAI pipeline, bili: qoder budget aligned — QODER_AUTOCOMPACT_WINDOW=... log, compression loop triggers.

Fixes #653

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

📦 Built Package Artifact

Branch: 2026-09-09_qoder-client-support (ba5377c)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-654

Each push to this PR publishes a new version under the pr-654 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr654.tgz
npm install -g package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewing PR #654 (qoder client support) now — checking out the branch, reading the full diff, and re-running pre-flight (typecheck / test / build). Will follow up with findings.

@ranxianglei

Copy link
Copy Markdown
Owner Author

解决冲突

qoder's model endpoint scheme is hardcoded https with no base-URL override
env, so /bili/ rewrites cannot reach it — cert-MITM is the only route
(qoder's built-in undici honors HTTPS_PROXY + NODE_EXTRA_CA_CERTS).

- client-config: QoderConfig, qoderIsCnSite (QODERCLI_SITE / CN-prefixed
  envs / on-disk config dir), resolveQoderHome, readQoderConfig
  (settings.json model, QODER_MODEL_SERVER_HOST), QODER_DEFAULT_MODEL_HOSTS
- launcher: bili qoder (proxy mode) — HTTPS_PROXY + NODE_EXTRA_CA_CERTS +
  BILLION_CONTEXT_PROXY, default model hosts whitelisted for MITM (or the
  QODER_MODEL_SERVER_HOST override), QODER_MODEL_TRANSPORT=http forced
  (legacy fallback wire unverified), #321 budget alignment via
  QODER_AUTOCOMPACT_WINDOW / QODERCN_AUTOCOMPACT_WINDOW, qoder/qodercli
  binary resolution
- discover: qoder hosts in MITM domain auto-discovery
- cli/README/AGENTS: help + docs

Fixes #653
@ranxianglei
ranxianglei force-pushed the 2026-09-09_qoder-client-support branch from f3c7a1d to ba5377c Compare September 10, 2026 15:39
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Conflicts resolved — branch rebased onto current master (v0.1.102, 9aa72ac) and force-pushed (f3c7a1dba5377c, --force-with-lease).

The conflict was a single one: the client-config.js import line in src/launcher.ts — master added resolveCodexHome (#681 Windows codex MCP overlay) while this PR added qoderIsCnSite, QODER_DEFAULT_MODEL_HOSTS. Resolved as the union of both. Everything else auto-merged cleanly; I verified the semantically-adjacent regions: the qoder branch in runLaunch sits intact ahead of master's restructured codex MCP-injection block (prepareCodexMcpInjection moved outside direct/else), and the export block carries both sides' additions. The rebased commit is still exactly the original 8 files / +454 −15.

Post-rebase pre-flight (all on the new commit):

  • npm run typecheck
  • npm test 1337 pass / 0 fail / 2 skipped (suite grew since your pre-flight as master landed more tests; the environmental resolveClientCommand: codex/claude resolve to themselves failure you flagged did not reproduce here)
  • npm run build ✓; built CLI --help smoke-tested — qoder lines render
  • GitHub reports the PR mergeable now (mergeable_state: blocked only for CI/review — merge stays yours)

One minor finding from the diff review (reporting only, no separate change): if a user sets QODER_MODEL_SERVER_HOST with an explicit port (e.g. my-relay.example.com:8443 — which readQoderConfig deliberately preserves), the MITM whitelist entry keeps the port, but isMitmHost() matches hostname-only (CONNECT parsing strips the port first) — so that host would silently fall back to a blind tunnel and compression would not apply. Default hosts are all bare domains, so this only affects custom-port relays. A one-line port-strip in the discoverRoutes qoder branch (and the matching extractHttpsHosts push in src/discover.ts) would close it — happy to add it as a follow-up commit if you want it in this PR.

中文摘要:已把 PR 分支 rebase 到最新 master(v0.1.102),唯一冲突是 launcher.ts 的 import 行(master 的 resolveCodexHome 与 qoder 新增导入取并集),rebase 后 typecheck / 全量测试(1337 通过 0 失败)/ build 全部通过并强推,PR 现已可合并;另发现一个仅影响"自定义端口 model server host"的小问题(MITM 白名单带端口导致匹配不上、静默退化为盲隧道),已在上方说明,可按需补一行修复。

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.

feat: 新增 qoder 客户端支持(bili qoder)

1 participant