Repository navigation
fix: discover opencode/omp declared provider hosts for the MITM whitelist (#1411) - #1413
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1413Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1413.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Reviewed #1413 end-to-end — pulled head ① Direction (issue #1411) — spot on. Two root causes, both fixed at the source rather than masked:
② Regression — purely additive, no existing behavior touched:
Completeness: after this PR, every file-backed source feeding Subtle win worth calling out: ③ Code — the mirror holds on the resolution logic: ④ Test validity — good teeth, and they reproduce the real defects (would fail on master):
⑤ Diff cleanliness — 3 files, +151/-4, every line on-purpose. The Behavior change (confirming your flag): old → declared opencode/omp provider hosts were never whitelisted (blind tunnel, zero compression) and edited aider conf stayed stale; new → those hosts are cert-MITM'd like pi/zcode/codex and edited aider conf is picked up within one ~2 s TTL. Bounded to hosts the user explicitly declared in configs bili already reads. Intended and appropriate. Coordination note stands: independent of open #1409 (static zen host CI on head 中文摘要:修复了 opencode/omp(及顺带同根因的 aider)自定义 provider 主机从未进入 MITM 白名单、且其配置文件编辑后 mtime 缓存不失效导致盲区隧道的问题——按根因补上了发现分支与监听清单,并加了能在 master 上复现原缺陷的回归测试;代码与测试均正确、diff 干净,可合并(待 CI 剩余 3 个测试 job 转绿)。 |
[bot] 🏷 Follow-up — added local execution evidence on head |
opencode's built-in zen gateway (opencode auth login) resolves its baseURL from the models.dev catalog, so it lands in no local config file and discovery never sees it — traffic blind-tunnelled with zero compression. Seed OPENCODE_DEFAULT_MODEL_HOSTS in extractHttpsHosts for the opencode/omp lanes, following the qoder/trae/aider stock-gateway precedent. Explicit provider base URLs coexist (union, not replace). Fixes #1405
…covery and config-files order note - tests/discover.test.ts: the union of #1409 (zen seed) + #1413 (declared hosts) dropped the closing '});' of the #1411 partial-configs test — restore it (tsc TS1005 at EOF). - CONFIGURATION.md + zh-CN: one sentence on opencode/omp declared-provider MITM discovery (#1411) next to the existing bili opencode line. - src/client-config.ts: note that opencodeConfigFiles order is irrelevant (first parse wins per key).
0571f37 to
ecd496a
Compare
|
#1417 深审 + rebase + union 交付(详表见追踪板)。栈序:#1409 先合,本 PR 后合。head=ecd496a(force 重放到当前 master)。 #1413 是什么:① 发现 opencode/omp 配置里已声明的 provider 上游域(opencode.json 的 providers[].baseURL、models.json 的 provider baseUrl)进 MITM 白名单——自定义中继用户不再需要手配;② 行为影响:feat(MITM 白名单来源扩容)——声明即信任:用户自己写进客户端配置的 https 域现在自动进白名单。宿主匹配 rebase 冲突(与 #1409 同文件):union 解——本 PR 的 partial-configs 测试断言 顺带三处小修:① CONFIGURATION.md/zh-CN 补一句声明式发现(挂在既有 bili opencode 行旁);② client-config.ts 补 opencodeConfigFiles 顺序无关注释;③ TTL 测试的 2×2.1s sleep 留作注记未改(非阻塞)。 |
[bot] 🏷 Re-verified the rebased head Stack state (confirmed via git): Union coherence (what actually changed): verified the two halves coexist without conflict —
Behavior change — stated precisely for the record: One non-blocking doc nit (CONFIGURATION.md + .zh-CN.md): the omp row points at Evidence (head Verdict unchanged: mergeable. Only open item is the trivial omp-path doc string. 中文摘要:rebase+union 后的新 head |
Closes #1411
Problem
opencode/omp lanes ride the HTTPS_PROXY cert-MITM path, so the auto-discovered host whitelist (
discoverMitmDomains) is the only mechanism whitelisting their provider relays. ButextractHttpsHostshad no opencode/omp branch — even thoughloadClientConfigalready parsesOpencodeProvider.baseURLandOmpProvider.baseUrl(bili uses them for context windows) — and the discovery mtime-cache watchlist contained no opencode config file nor omp'smodels.yml. Result: a custom provider declared in config was blindly tunnelled (BLIND TUNNEL WARNING, zero compression) despite bili having read the very same config; and because the unlisted files never invalidated the cache, even a one-time discovery would go stale on edit.Changes
Commit 1 — discover opencode/omp declared provider hosts (#1411)
src/discover.ts:extractHttpsHostsnow pushesconfig.opencode.providers[*].baseURLandconfig.omp.providers[*].baseUrl(pi/zcode-style, https-only, lowercased hostname).src/client-config.ts: new exportedopencodeConfigFiles(env)returning exactly whatreadOpencodeConfigRootreads:<XDG_CONFIG_HOME|~/.config>/opencode/{opencode.jsonc,opencode.json,config.json}plus$OPENCODE_CONFIGwhen set.src/discover.ts:configFilePaths()now watches those files +<omp home>/models.yml, so mid-run config edits invalidate the mtime cache. Both halves of root cause 2 ship together — adding only the push branches would make discovery return stale results forever after the first TTL cycle.Commit 2 — same root cause, aider instance (labeled bonus fix)
.aider.conf.ymlcandidates (home > git-root > cwd, feedingconfig.aider.baseUrls) were equally absent from the watchlist: first discovery happened to read them, later edits went stale. The candidate walk is extracted asaiderConfFiles()fromreadAiderConfUrlsand added to the watchlist. Per owner policy 2026-09-25 (one issue per root cause, all instances fixed in the SAME PR), this ships here rather than as a separate issue.Behavior change (flagged per policy)
Coordination with #1409 (open)
#1409 seeds the static zen host (
opencode.ai) into the same function. Independent changes; either merge order works and a conflict would be a trivial union (keep both blocks). This PR builds on master without #1409, so its coexistence test asserts cross-lane discovery rather than the zen host.Tests
6 new tests in
tests/discover.test.ts: unit (opencode+omp extraction incl. http-dropped/lowercasing/coexistence with other lanes; partial configs safe) + integration (opencode.json custom provider discovered & coexists with another lane; ompmodels.ymldiscovered;$OPENCODE_CONFIGdiscovered; opencode.json edit invalidates cache after TTL;.aider.conf.ymledit invalidates cache after TTL).withTempHomehardened to pinXDG_CONFIG_HOMEand drop ambientOPENCODE_CONFIG.Pre-flight (final head)
npm run typecheck✓npm test: 2807 tests, 2795 pass, 0 fail, 12 skipped (gated e2e)npm run build✓E2E codex suite not run: diff touches none of the request-pipeline hot files listed in AGENTS.md §3 (no server/loop/adapter/stream/persist/agent changes).