Repository navigation
fix: route profile/CLI-selected codex providers through bili (#2197) - #2210
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2290-pr.2210.9dcc37bThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2210.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…i-line constructs (#2197) Review finding on #2210: codexTomlProblem false-positived on VALID TOML — a multi-line array (notify = [ ... ]) or inline table spanning lines made every body line fail the single-line structure check, so bili refused to launch (exit 2) profiles that codex itself accepts. The gate is stricter than codex, contradicting its own contract (broken => loud, valid-but- unread => silent). Fix: follow bracket depth across lines with a quote/comment-aware scanner (double-quote backslash escapes, literal-string '' doubling, # comments), so array/inline-table bodies are consumed as continuations; also report genuinely broken EOF states that previously passed silently (unterminated multi-line string, unclosed array/inline table — both hard-fail in codex).
[bot] 🏷 PR review 完成(按结构化七问)。方向关、回归关、代码关、测试关、diff 整洁度全部过审;review 中发现一个本 PR 引入的小缺陷,已按「小问题直接修」直接补 commit 到 PR 分支。 ① 是什么问题:Codex 0.160 ② 什么原因导致的: ③ 怎么修复的:在 ④ 是否有回归问题(逐项过既有行为):
⑤ 是否破坏缓存:不涉及。改动全在 launcher 启动期路由发现,不触碰会话状态、压缩管线、prefix cache、去重键。 ⑥ 是否改了设计方向:不涉及架构转向。「effective view 单一消费点」遵循现有 discovery→rewrite 数据流,只是把消费源从单文件换成合并视图;wire 面两种压缩模式均未触碰(launcher 层在请求管线之外)。 ⑦ 是否引入了新的配置:无。无新 config 字段、env var、CLI flag(diff 未触碰 knobs/CONFIGURATION.md)。 测试有效性:16 个单测有牙——优先级错序、发现退回 base-only(即原 bug)、路径穿越、透传形状各有专门断言抓得住回归;3 个 hermetic e2e 用 PLAIN base_url(无 Review 中发现并已修的小缺陷(commit 另注:新 Windows lane 首跑即绿,按 #686 分阶段门禁约定,一次干净运行后可择机把 判定:可合并(待新 head CI 转绿;merge 由人执行:#2210 )。 |
[bot] 🏷 收工确认(本 issue 全部工作已完成并复核):PR #2197 review 已完成——方向/回归/代码/测试有效性/diff 整洁五关全过,结论见上方第 4 层(结构化七问)。可合并。 Review 中发现并已直接修掉一个小缺陷(commit 当前状态:PR open、head |
66bfd8c to
d2d38c2
Compare
#2197) Codex 0.160 -p overlays $CODEX_HOME/<name>.config.toml onto the base config, but bili discovered providers only from the base file — a provider living only in the selected profile (or only in -c/-m CLI overrides) answered fine yet bypassed the proxy entirely. Build this launch's effective view (base + profile overlay + CLI overrides, in codex's verified precedence) in client-config and use it for discovery, budget alignment and the MCP decision; append the generated -c rewrites AFTER user argv so a same-key user override can no longer clobber the transport substitution (codex applies repeated -c last-wins). Missing profile mirrors codex (base-only + visible notice); malformed profile or invalid name fails loudly pre-spawn.
…y resolution Three real-launcher cases (plain base_url, isolated homes, local fakes): profile-only provider, CLI-selected provider, and user -c base_url override — each must carry bili ACP tags upstream plus the session write-back. Resolve the codex binary through PATH/PATHEXT instead of a bare spawnSync name; with the gate enabled on win32 an unresolvable binary now fails loudly instead of silently skipping. New windows-latest CI job runs exactly these cases against pinned @openai/codex@0.147.0 (staged-gate convention per #686).
d2d38c2 to
41be1b2
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.65-master.11a6c21 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2197
What was wrong
Codex 0.160
-p <name>overlays$CODEX_HOME/<name>.config.tomlonto the baseconfig.toml(verified against local codex-cli 0.147.0; matches the 0.160--helptext). bili discovered providers ONLY from the base file, so a provider living only in the selected profile — or only in-c model_provider=.../-c model_providers.<id>.base_url=...CLI overrides — answered fine yet bypassed the proxy entirely: no/bili/rewrite, no ACP tags upstream, no session record.Fix
src/client-config.ts):resolveCodexEffectiveView(codexHome, base, clientArgs)merges base config + selected profile overlay +-c/-mCLI overrides in codex's verified precedence (CLI > profile > base). Current codex hard-rejects legacy[profiles.x]tables (verified), so no legacy support. Profile name is validated ([A-Za-z0-9._-], blocks path escape); a missing profile mirrors codex (base-only + visible notice); a malformed profile fails loudly pre-spawn with file + line.runLaunch,src/launcher.ts): the merged view replacesconfig.codexbeforediscoverRoutes, so rewrite discovery, budget alignment and the MCP-vs-flat-tools decision all use the same view. Fatal refusal exits beforeensureProxyRunning(no detached proxy child).-crewrites now append AFTER user argv. Codex applies repeated-cleft-to-right, last wins (verified empirically on 0.147.0); previously prepended rewrites could be clobbered by a same-key user override → silent bypass. The target itself is chosen from the merged view, so appending never hides a user-selected endpoint.Behavior change (old → new)
buildCodexArgs: bili-crewrites moved from BEFORE to AFTER user args (codex-clast-wins). Only observable when a user passes-cfor a key bili rewrites: previously that silently bypassed the proxy; now the user's endpoint stays the target AND the transport substitution still applies.bili codexwhen a profile is loaded or missing (routing correctness only).Tests
tests/codex-profile-effective.test.ts(new, 16 unit tests): profile extraction forms, CLI override parsing (incl. prompt-word safety), merge precedence, TOML structural gate, effective-view fixtures (profile-only takeover, CLI>profile>base, missing/malformed/traversal names).tests/e2e/e2e-codex-fake.test.ts: three hermetic real-launcher cases with PLAIN base_url (no/bili/pre-bake), isolated CODEX_HOME/XDG, local fake upstreams: profile-only provider, CLI-selected provider, user-c base_urloverride. Each asserts ACP tags in the upstream payload + session write-back. The codex binary is now resolved via PATH/PATHEXT (a barespawnSync("codex")misses Windows.cmdshims); with the gate enabled on win32 an unresolvable binary fails loudly instead of silently skipping..github/workflows/ci-windows-codex.yml: new windows-latest job running exactly these [Bug][Codex 0.160] -p profile 供应商未参与路由发现,bili codex 正常回答但请求绕过代理 #2197 e2e cases against pinned@openai/codex@0.147.0(same pin as the ubuntu lane). Staged-gate convention per E2E verify on real Windows: codex accepts CODEX_HOME overlay and registers the bili MCP server (#681 / PR #683) #686:continue-on-error+ transcript artifact until one clean run proves the lane, then promote to a hard gate.