Repository navigation
[PR] pi inline full rollout: fixed real-device stream drops + default to in-process engine (previously scattered across unmer | pi inline 全套落地:修好真机断流 + 默认走进程内引擎(之前散在未合并的 #4527/#4571 里) - #4669
Conversation
…ge in pi inline mode (#3278 follow-up) Inline mode froze state.origin to the never-dialable INLINE_ORIGIN and skipped installNativeWebSocketIntercept entirely, so codex WS traffic went DIRECT and bypassed compression with no ACP session. The inline engine now boots the same ws-bridge the spawned server serves, bound to 127.0.0.1:0 (loopback-only admission, tunnel guard, unref'd), the WS wrapper prefers state.wsOrigin over the pseudo-origin, and a failed or wedged bridge degrades that lane DIRECT (warned, 20s bound) while HTTP compression keeps running in-process. planNativePi now treats any non-empty BILI_PI_INLINE except 0/false/no/off as on: on/yes/TRUE used to miss the 1/true set and silently spawn a proxy server — the 'inline does not work' report.
…store the missing pluginLaneServerHistory seed (#4491 drift) docs-sync regenerates CONFIGURATION*.md from website/config-reference yaml seeds — hand edits to the generated blocks drift. The #4491 row was hand-added without its seed, so every generate run (incl. docs-sync in CI) wanted to delete it; seeding it keeps the row and the env index entry. Backticks are forbidden in seed descs, hence the de-ticked row text.
…oxy, BILI_PI_INLINE) - launcher: pi-inline ClientName; refuses (exit 2) when the bili pi extension cannot load (no wire-mode fallback without a proxy), strips inherited BILLION_CONTEXT_PROXY/HTTPS_PROXY/BILI_MITM_HOSTS so planNativePi arms the in-process engine instead of attaching, sets BILI_PI_INLINE=1, same -e single-load rule as the proxy lane - cli help + examples - scripts/ci-pretest-cache.d.mts: declare refreshDistMtimes (runtime export existed; the declaration file lagged and typecheck flagged the test) - tests/launcher-pi-inline.test.ts: no-proxy/no-fetch assertions, env stripping under a hostile inherited proxy posture, -e only when settings has no entry, refusal path spawns nothing
… terminal
Field report on bili pi-inline: at boot every [storage]/[persist]/[inline]
line scrolled the pi input box away ('启动的时候都是日志 输入框没了').
The tee logger's stderr leg exists for the foreground proxy process; in the
inline lane (#3278) the engine runs INSIDE the host agent, so stderr is the
interactive TUI. Mute the terminal leg at engine start (bili.log file leg
stays; the logger re-enables stderr itself if the file leg dies, #2864);
BILI_INLINE_DEBUG=1 opts back in for live troubleshooting (documented in the
env-only seed). Regression test: real engine boot under a stderr spy must
write zero bytes.
…inline lane's pseudo-origin rewrite was dying on real DNS (#4527) The native intercept rewrites model URLs to ${INLINE_ORIGIN}/bili/<upstream> and hands them DOWN its send() to the inline transport link. But the inline link's patched wrapper runs inside the #1662 depth protocol: depth===1 means 're-entry', so it skipped its own dispatch and the pseudo-origin URL fell through to the raw fetch — ENOTFOUND billion-context.inline. Every model AND management fetch in the real inline lane failed this way since #3278 (no e2e ever exercised the two links stacked like the production arm). Fix: each link's send() now stamps the exact downstream function it calls (chainHop AsyncLocalStorage); a patched wrapper entered with the hop pointing at ITSELF is a legitimate descent from the bili link directly above and runs its dispatch one level deeper. A foreign wrapper in between re-issues the call as its own hop, so the identity match fails and #1662 truncation keeps protecting the descent exactly as before. Adds the missing composition test: inline link + native intercept installed in production order; a plain model URL must land on the engine and the real upstream must stay untouched.
… a loopback listener (#4571) Field report: the inline status panel printed a dead 'Web UI: http://127.0.0.1:0/...' link (no listener exists inline — the fake request sockets hardcode localPort 0) and nothing in the panel said the engine was the in-process inline lane. - startInlineEngine now binds a loopback-only, unref'd, admin-only web listener (127.0.0.1:<ephemeral>) that drives the same pipeline; the panel's Web UI deep link becomes a real browser-clickable URL. Model lanes (/bili/...) are deliberately NOT exposed on it; bind failure is fail-soft (link hidden). - the fake inline sockets report the real port as localPort so admin routes compute the true origin even for in-process status calls. - ProxyOptions.inlineLane marks the lane at boot; /__bili/plugin/status and /__bili/plugin/tool pass it through and the panel version line appends ' · inline'. - webSessionUrl hides ':0' origins instead of printing dead links.
…ver spawn unless opted back in (#4571) Plain `pi` with the plugin installed now compresses IN-PROCESS (inline lane, #3278): no proxy server process, no ephemeral port. The spawned-server mode is one opt-away: "pi": {"inline": false} in billion-context.json, or BILI_PI_INLINE=0/false/no/off in the env. Precedence is otherwise unchanged: kill switches and /bili/ launches still stand down; an explicit env/config inline choice still outranks everything; an announced attach target (launcher-set BILLION_CONTEXT_PROXY/ATTACH) still beats the new DEFAULT — wrapped launches keep attaching to their server. An explicit env OFF still suppresses a file-true value (env > file). planNativePi's fileInline parameter becomes tri-state (true/false/undefined) so 'not configured' (default inline) and 'explicitly disabled' (server) are distinct. Config reference seeds + CONFIGURATION.md regenerated.
#4571) Field report: a pi session opened from the inline panel showed 基本信息 with no hint of which engine served it, so "这个是 inline 模式吧?" could only be answered from bili.log (the session in question had in fact attached to a running server, not gone inline). Stamps session.metadata.engineLane at request time (handle.ts, first hit wins like clientHint): "inline" when the engine runs in-process (opts.inlineLane), "server" for a standalone proxy process (spawned or attached). The web session list chips it beside the client hint (inline / srv) and 基本信息 gains an 引擎 row — in-process (inline) vs server process. Pre-stamp sessions render nothing (absent = unknown, not guessed). Tests: pi-inline.test.ts inline-web case now asserts the pi session carries engineLane:"inline" in /__bili/sessions.
…s own restampMtimes in #4599) + regen docs
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5714-pr.4669.da30606This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4669.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ow for the #4669 default flip lifecycle-ledger-guard red: BILI_INLINE_DEBUG was read from src/ but not in the ledger. While here, the BILI_PI_INLINE row still said 默认 off — this stack flips the default, so the row now says so (and the file/env opt-out spelling that gets the spawned server back).
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——本 PR 即 #4526/#4527/#4571 悬空工作的合并重提(三个原条目均已关闭,master 上一行没有,与 PR 描述一致)。但发现一个在途重叠:PR #4559(10-24 创建,open)做的是同一机制(codex Responses WS 在 inline 模式下的拦截/WS 桥),本 PR 第 1 个提交是其超集。已按政策给 #4559 打 标签:bug / pi / codex / scope/wiring / p1 —— 本 PR 含「inline 一开必炸」的断流根因修复(p1 级缺陷),且默认翻转波及全部 pi 车道用户,主域是协议接线。 开始审核:已拉取分支 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.833-master.fbfac66 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Owner rule (never change defaults): plain with no signals plans the spawned proxy again, exactly as before #4669. Inline arms only on BILI_PI_INLINE=1/on/yes/TRUE or {"pi":{"inline":true}} (explicit choice still beats an announced attach target). Seeds/docs/LIFECYCLE updated; plan matrices re-flipped ({}→spawn pinned in pi-native + pi-inline-ws tests). Real-machine check: bare import plans spawn (spawn attempt observed), env-on/file-true plan inline.
…route model traffic at fetch time (#5625) Rework of PR #4280 (reverted by c076614 over a master conflict; original report #4276) on top of current master. The opencode-lane http.request hook used to replace e.request with a new Request pointed at `${proxyOrigin}/bili/<originalUrl>`. opencode hands that one mutable event to every later http.request/http.response hook, including provider-scoped hooks from other plugins, so provider auth plugins validating the upstream URL broke: Kiro's bridge silently stopped engaging (empty responses after ~10 retries) and Antigravity threw "pool requests need the default Google base URL" before its own hook could run. The routes now only DISCOVER the proxy (state.proxyBase; oversize refusal / direct-degrade on death) and leave the hook-visible payload untouched. Both setup()s install the shared native fetch intercept chain, which performs the /bili/ rewrite at fetch time — the bytes other plugins see in their hooks are unchanged. The WS handshake hook builds its own tunnel URL instead of relying on the rewritten request. These lanes also honour providers.<url>.direct (#1622), previously implemented only in the ZCode lane: matching requests are marked biliDirect in the hook and sent direct by the chain. Behavior changes (disclosed per policy): - Provider plugins in opencode lanes see original upstream URLs again. - Signed-body model requests (x-goog-api-key / SDK-HMAC-SHA256) in V2 processes get the local #1884 refusal instead of unsigned-through-bili. - #3304 prepareDirectSend and #3248 onResponse acks activate in V2 processes (dead code before the chain existed there). - Launcher dead-origin handling moves from preemptive unwrap-to-upstream to the chain's recover/retry/give-up-direct path. - v1internal pool-shaped URLs (e.g. daily-cloudcode-pa.googleapis.com, recognized since #4256 for DSH Desktop Code-Assist traffic) ride the chain like any other model request: byte-preserving forward through bili, no bili identity headers invented. Hosts wanting such traffic fully off bili opt out per upstream via providers.<url>.direct. Tests: new tests/issue5625-opencode-v2-hook-payload.test.ts pins the hook payload contract (untouched request, fetch-time routing, pool dialect, direct exemption, install gate); launcher/native suites updated to the fetch-time contract; the #4669 inline-composition test installs the chain like its sibling and asserts the hook keeps the payload intact. Closes #5625
… the fetch-time contract (#5625) CI follow-up on PR #5626 head 58438f1: - unused-exports gate: replaceRequestTarget had no remaining callers once the routes stopped rewriting e.request — removed. - tests/opencode-native.test.ts: the #4669 V2-composition pin asserted the old hook-time rewrite; it now installs the chain like its sibling and asserts the hook keeps the payload intact while the chain rewrites at send time. - tests/issue5625-opencode-v2-hook-payload.test.ts: the pool-endpoint pin predated #4256's classifier arm for the v1internal dialect (DSH Desktop Code-Assist traffic rides exactly that URL); it now asserts the post-#4256 contract — the hook stays out of the provider plugin's way and the chain forwards the pool URL byte-preserving with no bili identity invented.
…route model traffic at fetch time (#5625) Rework of PR #4280 (reverted by c076614 over a master conflict; original report #4276) on top of current master. The opencode-lane http.request hook used to replace e.request with a new Request pointed at `${proxyOrigin}/bili/<originalUrl>`. opencode hands that one mutable event to every later http.request/http.response hook, including provider-scoped hooks from other plugins, so provider auth plugins validating the upstream URL broke: Kiro's bridge silently stopped engaging (empty responses after ~10 retries) and Antigravity threw "pool requests need the default Google base URL" before its own hook could run. The routes now only DISCOVER the proxy (state.proxyBase; oversize refusal / direct-degrade on death) and leave the hook-visible payload untouched. Both setup()s install the shared native fetch intercept chain, which performs the /bili/ rewrite at fetch time — the bytes other plugins see in their hooks are unchanged. The WS handshake hook builds its own tunnel URL instead of relying on the rewritten request. These lanes also honour providers.<url>.direct (#1622), previously implemented only in the ZCode lane: matching requests are marked biliDirect in the hook and sent direct by the chain. Behavior changes (disclosed per policy): - Provider plugins in opencode lanes see original upstream URLs again. - Signed-body model requests (x-goog-api-key / SDK-HMAC-SHA256) in V2 processes get the local #1884 refusal instead of unsigned-through-bili. - #3304 prepareDirectSend and #3248 onResponse acks activate in V2 processes (dead code before the chain existed there). - Launcher dead-origin handling moves from preemptive unwrap-to-upstream to the chain's recover/retry/give-up-direct path. - v1internal pool-shaped URLs (e.g. daily-cloudcode-pa.googleapis.com, recognized since #4256 for DSH Desktop Code-Assist traffic) ride the chain like any other model request: byte-preserving forward through bili, no bili identity headers invented. Hosts wanting such traffic fully off bili opt out per upstream via providers.<url>.direct. Tests: new tests/issue5625-opencode-v2-hook-payload.test.ts pins the hook payload contract (untouched request, fetch-time routing, pool dialect, direct exemption, install gate); launcher/native suites updated to the fetch-time contract; the #4669 inline-composition test installs the chain like its sibling and asserts the hook keeps the payload intact. Closes #5625
… the fetch-time contract (#5625) CI follow-up on PR #5626 head 58438f1: - unused-exports gate: replaceRequestTarget had no remaining callers once the routes stopped rewriting e.request — removed. - tests/opencode-native.test.ts: the #4669 V2-composition pin asserted the old hook-time rewrite; it now installs the chain like its sibling and asserts the hook keeps the payload intact while the chain rewrites at send time. - tests/issue5625-opencode-v2-hook-payload.test.ts: the pool-endpoint pin predated #4256's classifier arm for the v1internal dialect (DSH Desktop Code-Assist traffic rides exactly that URL); it now asserts the post-#4256 contract — the hook stays out of the provider plugin's way and the chain forwards the pool URL byte-preserving with no bili identity invented.
这是啥
之前以为 #4571 合了、inline 的活就进 master 了——其实不是:#4571 的基分支是 #4527 的分支,#4527 后来被关闭没合并,这一整套工作全部悬空,master 上一行都没有(本机能用只是因为全局装的是 worktree 构建)。这个 PR 把全部 10 个提交 rebase 到最新 master 重新提交。
里面有什么
按提交顺序:
bili pi-inline一条命令车道:直接用进程内引擎拉起 pi。"pi":{"inline":false}或环境变量 BILI_PI_INLINE=0 可退回。附着已运行的 server(启动器预置目标)仍优先于默认值。冲突处理
验证
pi -p默认 inline 返回正常、日志确认零代理进程;inline 会话在共享 index.db 落 engineLane=inline 徽章。Closes #4526