diff --git a/CHANGELOG.md b/CHANGELOG.md index ba11e6299b..971f00118d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag ## [Unreleased] ### Changed +- **pi 内联压缩通道默认开启(#5428,取代 #4687 的手动开启规则)**:装了 bili 扩展的裸 `pi`(没设任何环境变量、没写配置)现在直接跑**进程内引擎**,不再自己派生代理进程。新优先级:kill-switch > /bili/ 改写启动 > 显式内联(`BILI_PI_INLINE=1/on/yes/TRUE` 或 `"pi": {"inline": true}`)> 宣告的附着目标(launcher 预置的 `BILLION_CONTEXT_PROXY/ATTACH`,`bili pi` 照旧用自己的 launcher 代理)> **默认内联** > spawn。**人类入口(短旗标,必须放在子命令前)**:`bili -i pi`(≡ `bili pi-inline`,强制内联+预检扩展+清理继承代理变量)与 `bili -s pi`(钉死代理姿态:子进程预置 `BILI_PI_INLINE=0`,压过继承的内联变量;opencode 同理)。不想用内联:`bili -s pi`、`BILI_PI_INLINE=0/false/no/off` 或 `"pi": {"inline": false}`——都恢复旧的 attach/spawn 姿态(有宣告代理就附着,否则自己派生代理)。`bili pi-inline` 一键车道保留(同 `-i pi`);空白 `BILI_PI_INLINE=""` 按未设置折叠。opencode 通道的默认不变(仍手动开启,`-i/-s` 两个旗标对它可用)。 - **The full-resend watermark fastpath (#5403/#5418) is now ON by default (GA)** after its §7.4 human review: plugin-lane chat-completions turns whose prefix is byte-stable skip the full history re-parse/re-pin on hit (the #5403 OOM producer), any doubt still falls back to the untouched full-parse path per turn. Opt out per install with `rollout.features.pluginFullResendWatermark: false` (or a percent) or `BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK=0`. ### Fixed diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 0c1e12f501..fe422b9461 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -139,7 +139,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed | `native.attachUrl` | string | unset (discover per lane) | BILI_MCP_PROXY | Explicit target origin for native-hook attach (any URL). When set, a hook attaches ONLY to that exact origin instead of auto-discovering, and spawns its own if it is not live; it must still be code-compatible and pass the lifecycle gate. The BILI_MCP_PROXY env var (also set by CLI --origin) takes precedence over this file value; empty/whitespace means unset. | | `claude.nativePort` | number | unset (lane sticky zone port) | BILI_CLAUDE_NATIVE_PORT | Exact port pin for the claude native lane's hook-spawned proxy (strict-port: squatters are refused loudly). | | `pi.subagents` | object \| boolean | {} (acp_delegate enabled with package defaults) | PI_ACP_DELEGATE_FORCE_ENABLE, PI_ACP_DELEGATE_MAX_DEPTH, PI_ACP_DELEGATE_SYNC_TIMEOUT_MINUTES, PI_ACP_DELEGATE_IDLE_TIMEOUT_MINUTES, PI_ACP_DELEGATE_ASYNC_TIMEOUT_MINUTES, PI_ACP_DELEGATE_MAX_CONCURRENT | Built-in pi-lane sub-agents (acp_delegate) surface, #2230 config-home. The pi.subagents section of billion-context.json owns the delegate config; the four acp.json keys (delegate/delegatePrompt/displayUsage/debug) are a deprecated fallback read only while the section is absent. prompt replaces delegatePrompt; debug is scoped to the sub-agent subsystem. Boolean shorthand subagents: false disables the whole surface. Full field table: the pi section in CONFIGURATION.md. | -| `pi.inline` | boolean | false | BILI_PI_INLINE | Pi inline lane (#3278; OPT-IN — #4687 reverts the #4571 default flip, default stays the spawned proxy): the pi extension's compression runs IN-PROCESS — no spawned proxy, no ephemeral port; model traffic and the /__bili//__acp tool surface are served by an in-process engine through a pseudo-origin, the codex Responses WebSocket lane by a loopback-only WS bridge, and the Web UI by a loopback-only web listener booted with the engine. Set true (or BILI_PI_INLINE=1/on/yes/TRUE) to enable. Resolved env > file; an explicit inline choice always beats an announced attach target (launcher-set BILLION_CONTEXT_PROXY/ATTACH); when unset the lane behaves exactly as before (attach/spawn). `bili pi-inline` presets the env for the one-command lane. | +| `pi.inline` | boolean | true (unset env+file runs inline) | BILI_PI_INLINE | Pi inline lane (#3278; DEFAULT-ON since #5428, superseding the #4687 opt-in rule): the pi extension's compression runs IN-PROCESS — no spawned proxy, no ephemeral port; model traffic and the /__bili//__acp tool surface are served by an in-process engine through a pseudo-origin, the codex Responses WebSocket lane by a loopback-only WS bridge, and the Web UI by a loopback-only web listener booted with the engine. Unset env+file now runs INLINE; an ANNOUNCED attach target (launcher-set BILLION_CONTEXT_PROXY/ATTACH) still beats the default, so `bili pi` keeps its launcher proxy. Opt OUT with BILI_PI_INLINE=0/false/no/off or this key set false — restores the old attach/spawn posture. Resolved env > file > default; an explicit inline choice always beats an announced attach target. Human surface: `bili -i/--inline pi` (≡ the one-command lane) and `bili -s/--server pi` (pin the proxy posture, beats an inherited inline env). | | `opencode.inline` | boolean | false | BILI_OPENCODE_INLINE | OpenCode inline lane (#3278 port; OPT-IN — the default stays the spawned proxy, per owner decision on #4687): the opencode plugin's compression runs IN-PROCESS — no spawned proxy, no ephemeral port, no MITM certs; model traffic and the /__bili/ tool surface are served by an in-process engine through a pseudo-origin (verified on the Bun host). Set true (or BILI_OPENCODE_INLINE=1) to enable. Resolved env > file; an explicit inline choice always beats an announced attach target, an absent choice falls back to attach/spawn as before. `bili opencode-inline` is the one-command lane. | **MITM lane** @@ -413,7 +413,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed | `BILI_NATIVE_OMP` | boolean-ish | off | — | Host posture: marks an omp-native plugin process. | | `BILI_NATIVE_OPENCODE` | boolean-ish | off | — | Host posture: marks an opencode-native plugin process. | | `BILI_NATIVE_PI` | boolean-ish | off | — | Host posture: marks a pi-native plugin process. | -| `BILI_PI_INLINE` | boolean-ish | off (opt-in) | — | Host posture: pi inline lane (#3278) — the pi extension compresses IN-PROCESS through the pseudo-origin instead of spawning its own proxy; outranks a preset BILLION_CONTEXT_PROXY attach target. OPT-IN: #4687 reverts the #4571 default flip — unset env/file behaves exactly as before (attach/spawn). Truthy = any non-empty value except 0/false/no/off (on/yes/TRUE all enable). Codex Responses WS traffic is routed through a loopback-only bridge booted with the engine; if that bridge fails, the WS lane degrades DIRECT (warned) while HTTP compression stays in-process. | +| `BILI_PI_INLINE` | boolean-ish | inline when unset (DEFAULT-ON since #5428; explicit 0/false/no/off opts out) | — | Host posture: pi inline lane (#3278) — the pi extension compresses IN-PROCESS through the pseudo-origin instead of spawning its own proxy; outranks a preset BILLION_CONTEXT_PROXY attach target. DEFAULT-ON since #5428 (supersedes the #4687 opt-in rule): unset env+file runs inline; an announced attach target still beats the DEFAULT, so `bili pi` keeps its launcher proxy. Explicit OPT-OUT = 0/false/no/off (or `"pi": {"inline": false}`) — restores the old attach/spawn posture. Human surface: `bili -i/--inline pi` forces inline, `bili -s/--server pi` pins the proxy posture (beats an inherited inline env). Truthy = any non-empty value except 0/false/no/off (on/yes/TRUE all enable). Codex Responses WS traffic is routed through a loopback-only bridge booted with the engine; if that bridge fails, the WS lane degrades DIRECT (warned) while HTTP compression stays in-process. | | `BILI_OPENCODE_INLINE` | boolean-ish | off (opt-in) | — | Host posture: opencode inline lane (#3278 port) — the opencode plugin compresses IN-PROCESS through the pseudo-origin instead of spawning its own proxy; outranks a preset BILLION_CONTEXT_PROXY attach target. OPT-IN: the opencode lane keeps its legacy default (spawned proxy) unless this env or "opencode": {"inline": true} explicitly enables it (owner decision on #4687). Truthy = any non-empty value except 0/false/no/off (on/yes/TRUE all enable). Verified on the Bun host (engine boots and dispatches without node:sqlite). | | `BILI_INLINE_DEBUG` | boolean-ish | off | — | Inline lane (#3278) only: keep the engine's log lines on stderr after muting them (the inline engine runs inside the pi process, where stderr is the interactive TUI — every [persist]/[storage]/[inline] line would scroll the input box away; default keeps them in bili.log only). | | `BILI_NATIVE_ZCODE` | boolean-ish | off | — | Host posture: marks a zcode-native plugin process. | @@ -1914,7 +1914,7 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes | `BILI_PERSIST_TAIL_TOKENS` | `persist.tailTokens` | 16384 (0 disables message persistence) | | `BILI_PERSIST_ZSTD` | `persist.zstd` | false | | `BILI_PERSONA_SPLIT` | `personaSplit` | true | -| `BILI_PI_INLINE` | `pi.inline` | false | +| `BILI_PI_INLINE` | `pi.inline` | true (unset env+file runs inline) | | `BILI_POST_RESPONSE_LINGER_MS` | `network.postResponseLingerMs` | 5000 | | `BILI_PREFLIGHT_DEAD_END_COOLDOWN_MS` | `network.preflightDeadEndCooldownMs` | 300000 | | `BILI_PREFLIGHT_HOLD_MS` | `network.preflightHoldMs` | 30000 | diff --git a/CONFIGURATION.zh-CN.md b/CONFIGURATION.zh-CN.md index fb81808171..116ca6fe51 100644 --- a/CONFIGURATION.zh-CN.md +++ b/CONFIGURATION.zh-CN.md @@ -139,7 +139,7 @@ | `native.attachUrl` | string | unset (discover per lane) | BILI_MCP_PROXY | native hook 附着的显式目标源(任意 URL)。设置后,hook 只附着到该精确 origin 而不是自动发现,若其不在线则自行派生;仍需代码兼容并通过生命周期门禁。BILI_MCP_PROXY 环境变量(CLI --origin 亦会设置它)优先于此文件值;空/空白视为未设置。 | | `claude.nativePort` | number | unset (lane sticky zone port) | BILI_CLAUDE_NATIVE_PORT | claude 原生车道钩子派生代理的精确端口钉死(严格端口:被占用时响亮拒绝而非跳端口)。 | | `pi.subagents` | object \| boolean | {} (acp_delegate enabled with package defaults) | PI_ACP_DELEGATE_FORCE_ENABLE, PI_ACP_DELEGATE_MAX_DEPTH, PI_ACP_DELEGATE_SYNC_TIMEOUT_MINUTES, PI_ACP_DELEGATE_IDLE_TIMEOUT_MINUTES, PI_ACP_DELEGATE_ASYNC_TIMEOUT_MINUTES, PI_ACP_DELEGATE_MAX_CONCURRENT | 内置 pi lane 子代理(acp_delegate)面(#2230 配置搬家)。billion-context.json 的 pi.subagents 段拥有 delegate 配置;acp.json 四键(delegate/delegatePrompt/displayUsage/debug)为已废弃回退源,仅段缺失时读取。prompt 取代 delegatePrompt;debug 限定子代理子系统。布尔简写 subagents: false 整体关闭。完整字段表见 CONFIGURATION.md 的 pi 段。 | -| `pi.inline` | boolean | false | BILI_PI_INLINE | pi 内联压缩通道(#3278;需手动开启——#4687 收回 #4571 的默认翻转,默认仍是派生代理):pi 扩展的压缩在进程内完成——不派生代理进程、无临时端口;模型流量与 /__bili//__acp 工具面由进程内引擎经伪源站服务,codex 的 Responses WebSocket 通道走随引擎启动的仅回环 WS 桥,Web UI 走随引擎启动的仅回环监听。设 true(或 BILI_PI_INLINE=1/on/yes/TRUE)开启。解析顺序 env > 文件;显式开启永远压过附着目标,未设置时行为与旧版一致(attach/spawn)。`bili pi-inline` 一键车道会预置该变量。 | +| `pi.inline` | boolean | true (unset env+file runs inline) | BILI_PI_INLINE | pi 内联压缩通道(#3278;自 #5428 起默认开启,取代 #4687 的手动开启规则):pi 扩展的压缩在进程内完成——不派生代理进程、无临时端口;模型流量与 /__bili//__acp 工具面由进程内引擎经伪源站服务,codex 的 Responses WebSocket 通道走随引擎启动的仅回环 WS 桥,Web UI 走随引擎启动的仅回环监听。未设置 env+文件时默认内联;显式宣告的附着目标(launcher 预置的 BILLION_CONTEXT_PROXY/ATTACH)仍压过默认,`bili pi` 照旧用 launcher 代理。不想用就 BILI_PI_INLINE=0/false/no/off 或本键设 false——恢复旧的 attach/spawn 姿态。解析顺序 env > 文件 > 默认;显式开启永远压过附着目标。人类入口:`bili -i/--inline pi`(≡ 一键车道)与 `bili -s/--server pi`(钉死代理姿态,压过继承的内联变量)。 | | `opencode.inline` | boolean | false | BILI_OPENCODE_INLINE | opencode 内联压缩通道(#3278 移植;需手动开启——按 #4687 决定,默认仍是派生代理):opencode 插件的压缩在进程内完成——不派生代理进程、无临时端口、无 MITM 证书;模型流量与 /__bili/ 工具面由进程内引擎经伪源站服务(已在 Bun 宿主验证)。设 true(或 BILI_OPENCODE_INLINE=1)开启。解析顺序 env > 文件;显式开启永远压过附着目标,未设置时行为与旧版一致(attach/spawn)。`bili opencode-inline` 一键车道。 | **MITM 通道** @@ -413,7 +413,7 @@ | `BILI_NATIVE_OMP` | boolean-ish | off | — | 宿主姿态:标记 omp 原生插件进程。 | | `BILI_NATIVE_OPENCODE` | boolean-ish | off | — | 宿主姿态:标记 opencode 原生插件进程。 | | `BILI_NATIVE_PI` | boolean-ish | off | — | 宿主姿态:标记 pi 原生插件进程。 | -| `BILI_PI_INLINE` | boolean-ish | off (opt-in) | — | 宿主姿态:pi 内联压缩通道(#3278)——pi 扩展在进程内通过伪源站直接压缩,不再另起代理进程;优先于预置的 BILLION_CONTEXT_PROXY 附着目标。需手动开启:#4687 收回 #4571 的默认翻转,不设置时行为与旧版完全一致(attach/spawn);除 0/false/no/off 外任何非空值均算开启(on/yes/TRUE 均可)。codex 的 Responses WS 流量改走随引擎启动的仅回环桥;桥起不来时该通道退回直连(打 warn),HTTP 压缩仍留在进程内。 | +| `BILI_PI_INLINE` | boolean-ish | inline when unset (DEFAULT-ON since #5428; explicit 0/false/no/off opts out) | — | 宿主姿态:pi 内联压缩通道(#3278)——pi 扩展在进程内通过伪源站直接压缩,不再另起代理进程;优先于预置的 BILLION_CONTEXT_PROXY 附着目标。自 #5428 起默认开启(取代 #4687 的手动开启规则):未设置 env+文件时走内联;显式宣告的附着目标仍压过默认,`bili pi` 照旧用 launcher 代理。显式关闭 = 0/false/no/off(或 `"pi": {"inline": false}`)——恢复旧的 attach/spawn 姿态。人类入口:`bili -i/--inline pi` 强制内联,`bili -s/--server pi` 钉死代理姿态(压过继承的内联变量)。除 0/false/no/off 外任何非空值均算开启(on/yes/TRUE 均可)。codex 的 Responses WS 流量改走随引擎启动的仅回环桥;桥起不来时该通道退回直连(打 warn),HTTP 压缩仍留在进程内。 | | `BILI_OPENCODE_INLINE` | boolean-ish | off (opt-in) | — | 宿主姿态:opencode 内联压缩通道(#3278 移植)——opencode 插件在进程内通过伪源站直接压缩,不再另起代理进程;优先于预置的 BILLION_CONTEXT_PROXY 附着目标。需手动开启:按 #4687 决定,opencode 通道默认保持旧行为(另起代理),只有本环境变量或 "opencode": {"inline": true} 显式开启才切换;除 0/false/no/off 外任何非空值均算开启(on/yes/TRUE 均可)。已在 Bun 宿主上验证(无 node:sqlite 时引擎 boot/dispatch 正常)。 | | `BILI_INLINE_DEBUG` | boolean-ish | off | — | 仅内联通道(#3278):把引擎日志保留在 stderr 上(默认关闭——内联引擎跑在 pi 进程里,stderr 就是交互终端,每行 [persist]/[storage]/[inline] 都会把输入框挤掉;默认只写 bili.log)。 | | `BILI_NATIVE_ZCODE` | boolean-ish | off | — | 宿主姿态:标记 zcode 原生插件进程。 | @@ -1891,7 +1891,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报 | `BILI_PERSIST_TAIL_TOKENS` | `persist.tailTokens` | 16384 (0 disables message persistence) | | `BILI_PERSIST_ZSTD` | `persist.zstd` | false | | `BILI_PERSONA_SPLIT` | `personaSplit` | true | -| `BILI_PI_INLINE` | `pi.inline` | false | +| `BILI_PI_INLINE` | `pi.inline` | true (unset env+file runs inline) | | `BILI_POST_RESPONSE_LINGER_MS` | `network.postResponseLingerMs` | 5000 | | `BILI_PREFLIGHT_DEAD_END_COOLDOWN_MS` | `network.preflightDeadEndCooldownMs` | 300000 | | `BILI_PREFLIGHT_HOLD_MS` | `network.preflightHoldMs` | 30000 | diff --git a/src/agent/pi-native.ts b/src/agent/pi-native.ts index 1523afa8a9..d839e4f0dc 100644 --- a/src/agent/pi-native.ts +++ b/src/agent/pi-native.ts @@ -50,7 +50,7 @@ export function shouldBootstrapNative(env: NodeJS.ProcessEnv): boolean { /** Decide this process's native posture (#886/#983 mechanism, ported to the pi * lane in #1795). Precedence kill-switch > /bili/ rewrite launch > explicit - * inline > attach > spawn (DEFAULT). A preset BILLION_CONTEXT_PROXY is an ATTACH target, not a + * inline > attach > inline (DEFAULT since #5428) > spawn. A preset BILLION_CONTEXT_PROXY is an ATTACH target, not a * stand-down: the pseudo-attach hole (preset env + bare pi) used to disarm * routing entirely while tools still found the proxy through the env — model * traffic went direct and uncompressed, the proxy never saw the session, and @@ -59,12 +59,15 @@ export function shouldBootstrapNative(env: NodeJS.ProcessEnv): boolean { * /bili/ launch (BILI_PROVIDER_REWRITES) still stands us down — its URLs are * already proxy-shaped. BILI_PI_INLINE (#3278) outranks ambient attach envs: * it is a deliberate choice about WHERE compression runs (in this process), - * not just which proxy to use. Resolved env > file > default(off): the + * not just which proxy to use. Resolved env > file > default: the * config-file home is `"pi": {"inline": true}`; an explicit BILI_PI_INLINE=0/ - * false disables over the file. OPT-IN ONLY (owner decision on #4687: - * never flip defaults) — unset env/file behaves exactly as before the - * #4571 default flip (attach > spawned proxy); `bili pi-inline` presets - * BILI_PI_INLINE=1 for the one-command lane. */ + * false disables over the file. DEFAULT INLINE since #5428 (supersedes the + * #4687 opt-in rule): unset env+file runs the in-process lane — opt out + * with BILI_PI_INLINE=0/false/no/off or `"pi": {"inline": false}` to + * restore the old attach/spawn posture. An ANNOUNCED attach target + * (launcher-set BILLION_CONTEXT_PROXY/ATTACH) still beats the default — + * `bili pi` keeps its launcher proxy; only explicit inline outranks attach. + * `bili pi-inline` presets BILI_PI_INLINE=1 for the one-command lane. */ export function planNativePi(env: NodeJS.ProcessEnv, fileInline: boolean | undefined = undefined): { mode: "off" | "attach" | "spawn" | "inline"; attachOrigin?: string } { if (env.BILLION_CONTEXT_PLUGIN === "0" || env.BILI_NATIVE_PI === "0") return { mode: "off" }; if (env.BILI_PROVIDER_REWRITES !== undefined) return { mode: "off" }; @@ -78,10 +81,16 @@ export function planNativePi(env: NodeJS.ProcessEnv, fileInline: boolean | undef // still suppresses a file-true value (env > file, #3278 contract): if (!inlineEnvOff && (inlineEnvOn || fileInline === true)) return { mode: "inline" }; const attachOrigin = nativeAttachOrigin(env) ?? proxyEnvOrigin(env); + // An ANNOUNCED attach target beats the #5428 inline default: `bili pi` + // sets BILLION_CONTEXT_PROXY before the child starts, and its launcher + // proxy must keep serving that child. if (attachOrigin !== undefined) return { mode: "attach", attachOrigin }; - // …then spawn: the historical default (owner decision on #4687 — inline - // is opt-in only, the #4571 default flip is reverted; a proxy server is - // spawned unless BILI_PI_INLINE / pi.inline=true opted into in-process). + // #5428 default flip (supersedes #4687): with NO explicit choice anywhere + // (env unset/blank AND file unset) the lane runs INLINE in-process. Reach + // spawn only via explicit opt-out — BILI_PI_INLINE=0/false/no/off or + // "pi": {"inline": false} — which restores the pre-#5428 posture above + // (attach when announced, else a spawned proxy). + if ((inlineEnv === undefined || inlineEnv === "") && fileInline === undefined) return { mode: "inline" }; return { mode: "spawn" }; } diff --git a/src/cli.ts b/src/cli.ts index d34e3cff4f..45166f5fc8 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -11,6 +11,8 @@ * bili start --config FILE path to config file (default: XDG) * bili start --passthrough forward without compression * bili pi/codex/claude/omp [args] start a proxy + launch a client via cert-MITM + * bili -i pi launch pi on the IN-PROCESS engine (≡ bili pi-inline) + * bili -s pi force the proxy posture: spawn/attach, never inline * bili export [id] [--full] export a persisted session as a handoff doc * (--jsonl: deterministic JSONL dump #2671) * bili acp-cache diff attribute cache breaks from ACP_DUMP_BODY dumps @@ -179,6 +181,10 @@ Launcher (bili pi / bili codex / bili claude / bili omp / bili opencode / bili h bili -F http://127.0.0.1:7897 codex # route bili's upstream through a proxy (gost-style -F) Options (override config file / env): + -i, --inline run the client's compression IN-PROCESS (pi/opencode; + same as "bili pi-inline"; must precede the client name) + -s, --server force the proxy posture — spawn/attach, never inline + (pi/opencode; overrides an inherited BILI_PI_INLINE=1) -F upstream proxy to forward through (gost-style; http://host:port; must precede the client name) --port listen port (start: 8787; launcher default: random free port) @@ -239,6 +245,7 @@ export function parseArgs(argv: string[]): Parsed { const positional: string[] = []; let client: ClientName | undefined; let clientArgs: string[] = []; + let posture: "inline" | "server" | undefined; const mitmDomains: string[] = []; let exportSelector: string | undefined; let registerConversationId: string | undefined; @@ -288,6 +295,22 @@ export function parseArgs(argv: string[]): Parsed { case "-V": command = "version"; break; + case "-i": + case "--inline": + if (posture === "server") { + console.error("bili: -i/--inline and -s/--server are mutually exclusive — pick one"); + process.exit(2); + } + posture = "inline"; + break; + case "-s": + case "--server": + if (posture === "inline") { + console.error("bili: -i/--inline and -s/--server are mutually exclusive — pick one"); + process.exit(2); + } + posture = "server"; + break; case "--debug": overrides.ACP_DEBUG = "1"; break; @@ -551,6 +574,32 @@ export function parseArgs(argv: string[]): Parsed { } } + // -i/-s posture flags (#5428): translate onto the existing lanes so the + // launcher needs no new plumbing — `-i pi` IS `bili pi-inline` (env scrub + // + extension preflight + BILI_PI_INLINE=1, no proxy spawned), and + // `-s pi` pins BILI_PI_INLINE=0 on the child so an inherited/ambient + // inline env can't flip it while the launcher proxy runs. + if (posture !== undefined) { + if (!client) { + console.error(`bili: ${posture === "inline" ? "-i/--inline" : "-s/--server"} needs a client lane — e.g. \`bili -${posture === "inline" ? "i" : "s"} pi\``); + process.exit(2); + } + const inlineVariant = client === "pi" || client === "pi-inline" ? "pi-inline" : client === "opencode" || client === "opencode-inline" ? "opencode-inline" : undefined; + if (inlineVariant === undefined) { + console.error(`bili: -i/-s only apply to the pi and opencode lanes (got "${client}")`); + process.exit(2); + } + if (posture === "inline") { + client = inlineVariant; + } else if (client === inlineVariant) { + console.error(`bili: ${client} IS the inline lane — use \`bili -s ${inlineVariant === "pi-inline" ? "pi" : "opencode"}\``); + process.exit(2); + } else { + if (inlineVariant === "pi-inline") overrides.BILI_PI_INLINE = "0"; + else overrides.BILI_OPENCODE_INLINE = "0"; + } + } + return { command, client, clientArgs, mitmDomains, overrides, exportSelector, exportOutput, exportFull, exportJsonl, registerConversationId, pluginAction, pluginAgent, pluginWithMcp, acpCacheDir, acpCacheLog, acpCacheNoLog, acpCacheSession, sessionsSub, sessionsTarget, sessionsNoVacuum, sessionsApply, sessionsRestoreTarget, storageDays, storageVacuum, storageDryRun, jsonOutput, doctorJson, doctorFix, packAction, packSpec, packProject, packForce }; } diff --git a/src/config.ts b/src/config.ts index 578b479c7b..b910a1605b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2056,13 +2056,14 @@ type FileConfig = { * `"pi": {"subagents": false}` disables the whole surface. The four * acp.json keys (delegate/delegatePrompt/displayUsage/debug) are a * deprecated fallback, read only while this section is absent. - * `inline` (#3278, OPT-IN — default stays the spawned proxy, #4687 - * reverts the #4571 default flip): run the pi lane's compression - * IN-PROCESS — no proxy server spawned. Enable with `true` (or - * BILI_PI_INLINE=1/on/yes/TRUE). Resolved env > file; an explicit - * inline choice beats an announced attach target (launcher-set - * BILLION_CONTEXT_PROXY/ATTACH); when unset the lane behaves exactly - * as before (attach/spawn). */ + * `inline` (#3278, DEFAULT-ON since #5428 — supersedes the #4687 opt-in + * rule): run the pi lane's compression IN-PROCESS — no proxy server + * spawned. Unset env+file runs INLINE; an announced attach target + * (launcher-set BILLION_CONTEXT_PROXY/ATTACH) still beats the default, + * so `bili pi` keeps its launcher proxy. Opt OUT with `false` (or + * BILI_PI_INLINE=0/false/no/off) — restores attach/spawn. Resolved + * env > file > default; an explicit inline choice beats an announced + * attach target. */ pi?: { subagents?: PiSubagentsFileConfig | boolean; inline?: boolean }; /** Built-in opencode-lane inline switch (#3278 port, OPT-IN — default * stays the spawned proxy, per owner decision on #4687): run the diff --git a/src/launcher.ts b/src/launcher.ts index ed8149f0fd..da099db8f8 100644 --- a/src/launcher.ts +++ b/src/launcher.ts @@ -6155,11 +6155,24 @@ function parsePort(raw: string | undefined): number { return port; } +/** -s/--server posture pins (#5491): parseArgs records them in overrides, but + * the launch path skips the generic env merge the start/update lanes use — + * mirror that merge for these keys so each lane's child-env spread delivers + * the pin to the child. Without this, an ambient BILI_PI_INLINE=1 flips a + * `-s pi` launch onto the inline lane and the launcher proxy idles. */ +export function applyPosturePins(overrides: Record): void { + for (const key of ["BILI_PI_INLINE", "BILI_OPENCODE_INLINE"]) { + const v = overrides[key]; + if (v !== undefined) process.env[key] = v; + } +} + export async function runLaunch(params: RunLaunchParams, deps: LauncherDeps = {}): Promise { const host = params.overrides.ACP_HOST?.trim() || LAUNCHER_DEFAULT_HOST; const port = parsePort(params.overrides.ACP_PORT ?? process.env.ACP_PORT); const passthrough = params.overrides.ACP_PASSTHROUGH === "1"; const debug = params.overrides.ACP_DEBUG === "1"; + applyPosturePins(params.overrides); const base = baseClientName(params.client); // #535: for pi and omp, discovery must read the REAL home — a stale @@ -7086,6 +7099,7 @@ export async function runTestPi(params: RunTestPiParams, deps: LauncherDeps = {} const port = parsePort(params.overrides.ACP_PORT ?? process.env.ACP_PORT); const passthrough = params.overrides.ACP_PASSTHROUGH === "1"; const debug = params.overrides.ACP_DEBUG === "1"; + applyPosturePins(params.overrides); const config = loadClientConfig(process.env, process.cwd()); const domains = dedupeInOrder([ diff --git a/tests/cli-parseargs.test.ts b/tests/cli-parseargs.test.ts index ca74517a59..dfb6c0d8d2 100644 --- a/tests/cli-parseargs.test.ts +++ b/tests/cli-parseargs.test.ts @@ -1,6 +1,7 @@ import test from "node:test"; import assert from "node:assert/strict"; import { parseArgs } from "../src/cli.ts"; +import { applyPosturePins } from "../src/launcher.ts"; // #346: the gost-style `-F ` (forward) flag sets bili's upstream proxy. // bili flags must precede the client name; everything after the client name is @@ -65,6 +66,79 @@ test("parseArgs: doctor is a command and --json sets doctorJson (#1235)", () => assert.equal(f.doctorFix, true); }); +// #5428: -i/--inline and -s/--server posture flags precede the client name. +// `-i pi` IS `bili pi-inline` (same lane remap); `-s pi` pins the proxy +// posture on the child so an inherited inline env can't flip it. +test("parseArgs: -i/--inline remaps pi/opencode onto their inline lanes (#5428)", () => { + assert.equal(parseArgs(["-i", "pi"]).client, "pi-inline"); + assert.equal(parseArgs(["--inline", "pi"]).client, "pi-inline"); + assert.equal(parseArgs(["-i", "opencode"]).client, "opencode-inline"); + assert.equal(parseArgs(["-i", "pi-inline"]).client, "pi-inline", "-i on the inline lane is a no-op"); + // client args after the client token stay verbatim + const r = parseArgs(["-i", "pi", "--foo", "bar"]); + assert.equal(r.client, "pi-inline"); + assert.deepEqual(r.clientArgs, ["--foo", "bar"]); +}); + +test("parseArgs: -s/--server pins BILI_PI_INLINE=0 / BILI_OPENCODE_INLINE=0 on the child (#5428)", () => { + const pi = parseArgs(["-s", "pi"]); + assert.equal(pi.client, "pi"); + assert.equal(pi.overrides.BILI_PI_INLINE, "0"); + const oc = parseArgs(["--server", "opencode"]); + assert.equal(oc.client, "opencode"); + assert.equal(oc.overrides.BILI_OPENCODE_INLINE, "0"); +}); + +test("parseArgs: -i/-s misuse exits 2 with a pointed message (#5428)", () => { + const cases: Array<[string[], RegExp]> = [ + [["-i", "codex"], /only apply to the pi and opencode lanes/], + [["-s", "codex"], /only apply to the pi and opencode lanes/], + [["-s", "pi-inline"], /pi-inline IS the inline lane/], + [["-i", "-s", "pi"], /mutually exclusive/], + [["-s", "-i", "pi"], /mutually exclusive/], + [["-i", "start"], /needs a client lane/], + ]; + for (const [argv, re] of cases) { + const origExit = process.exit; + const origError = console.error; + let code: string | number | undefined; + let printed = ""; + // biome-ignore lint/suspicious/noExplicitAny: test stub + (process as any).exit = ((c: number) => { code = c; throw new Error(`exit ${c}`); }) as any; + console.error = ((...args: unknown[]) => { printed += args.join(" ") + "\n"; }) as typeof console.error; + try { + parseArgs(argv); + assert.fail(`expected ${argv.join(" ")} to exit 2`); + } catch (err) { + assert.match(String(err), /exit 2/); + assert.equal(code, 2); + assert.match(printed, re); + } finally { + // biome-ignore lint/suspicious/noExplicitAny: test stub + (process as any).exit = origExit; + console.error = origError; + } + } +}); + +test("parseArgs+applyPosturePins: -s pins reach the launcher env the child inherits (#5491)", () => { + const origPi = process.env.BILI_PI_INLINE; + const origOc = process.env.BILI_OPENCODE_INLINE; + try { + delete process.env.BILI_PI_INLINE; + delete process.env.BILI_OPENCODE_INLINE; + applyPosturePins(parseArgs(["-s", "pi"]).overrides); + assert.equal(process.env.BILI_PI_INLINE, "0"); + assert.equal(process.env.BILI_OPENCODE_INLINE, undefined, "only the pinned lane's key is set"); + delete process.env.BILI_PI_INLINE; + applyPosturePins(parseArgs(["pi"]).overrides); + assert.equal(process.env.BILI_PI_INLINE, undefined, "no -s → no pin → env untouched"); + } finally { + if (origPi === undefined) delete process.env.BILI_PI_INLINE; else process.env.BILI_PI_INLINE = origPi; + if (origOc === undefined) delete process.env.BILI_OPENCODE_INLINE; else process.env.BILI_OPENCODE_INLINE = origOc; + } +}); + test("parseArgs: informational flags take precedence over subcommand dispatch (#5606)", () => { const commands = [ ["start"], ["update"], ["doctor"], ["export"], ["plugin-register", "example"], diff --git a/tests/launcher.test.ts b/tests/launcher.test.ts index 4c26fa930e..53f7fd7915 100644 --- a/tests/launcher.test.ts +++ b/tests/launcher.test.ts @@ -556,6 +556,99 @@ test("runLaunch pi: native -e plugin injected only when not installed", async () } }); +// #5428: -s pi pins the proxy posture on the child. cli.ts records the pin as +// overrides.BILI_PI_INLINE="0"; the launch path must layer it onto the child +// env — stripInheritedProxy does NOT touch BILI_PI_INLINE, so without this a +// hostile inherited BILI_PI_INLINE=1 would still arm the in-process engine in +// the child while THIS launch's proxy sits idle. +test("runLaunch pi #5428: -s posture override reaches the child env over a hostile inherited inline var", async () => { + const home = fs.mkdtempSync(path.join(os.tmpdir(), "bili-pis-")); + const prevHome = process.env.HOME; + const prevUserProfile = process.env.USERPROFILE; + const prevPiBin = process.env.PI_BIN; + const prevPiDir = process.env.PI_CODING_AGENT_DIR; + const prevInline = process.env.BILI_PI_INLINE; + process.env.HOME = home; + if (prevUserProfile !== undefined) process.env.USERPROFILE = home; + delete process.env.PI_CODING_AGENT_DIR; + // Hostile inheritance: the user's shell exported the inline opt-in. + process.env.BILI_PI_INLINE = "1"; + const fakePi = path.join(home, process.platform === "win32" ? "fake-pi.exe" : "fake-pi"); + fs.writeFileSync(fakePi, ""); + process.env.PI_BIN = fakePi; + const piHome = path.join(home, ".pi/agent"); + fs.mkdirSync(piHome, { recursive: true }); + fs.writeFileSync(path.join(piHome, "models.json"), JSON.stringify({ providers: {} })); + + // runLaunch only injects -e when dist/agent/pi.js exists; create a stub + // when running tests from a checkout without a prior build. + const root = selfPackageRoot(); + const distAgent = path.join(root, "dist", "agent", "pi.js"); + const stubbed = !fs.existsSync(distAgent); + if (stubbed) { + fs.mkdirSync(path.dirname(distAgent), { recursive: true }); + fs.writeFileSync(distAgent, ""); + } + + const childEnvs: NodeJS.ProcessEnv[] = []; + const spawnImpl: SpawnFn = (cmd, _args, options) => { + if (cmd === fakePi) { + childEnvs.push({ ...(options?.env ?? {}) }); + // runClient resolves on "exit" — fire it on next tick. + const child = makeFakeChild(0); + const orig = child.on!.bind(child); + (child as { on: SpawnChild["on"] }).on = (event, listener) => { + orig(event, listener); + if (event === "exit") setTimeout(() => listener(0, null), 0); + return child; + }; + return child; + } + return makeFakeChild(42422); + }; + const fetchImpl = async () => ({ ok: true }); + const fetchHealthInfo = async () => ({ ok: true, pid: 42422 }); + + // runLaunch ends with process.exit() — stub it or it kills the test + // runner and every test registered after this one silently never runs. + const prevExit = process.exit; + const exitCalls: number[] = []; + process.exit = ((code?: number) => { + exitCalls.push(code ?? 0); + return undefined as never; + }) as typeof process.exit; + + try { + // Control: without the pin the hostile inheritance reaches the child. + await runLaunch( + { client: "pi", clientArgs: [], overrides: {} }, + { fetchImpl, fetchHealthInfo, spawnImpl, sleep: () => Promise.resolve() }, + ); + assert.equal(childEnvs[0]?.BILI_PI_INLINE, "1", "inherited inline var still reaches the child without -s"); + + // -s pi: the pin must beat the inheritance in the child env. + await runLaunch( + { client: "pi", clientArgs: [], overrides: { BILI_PI_INLINE: "0" } }, + { fetchImpl, fetchHealthInfo, spawnImpl, sleep: () => Promise.resolve() }, + ); + assert.equal(childEnvs[1]?.BILI_PI_INLINE, "0", "-s pin overrides the inherited inline var for the child"); + assert.deepEqual(exitCalls, [0, 0]); + } finally { + process.exit = prevExit; + process.env.HOME = prevHome; + if (prevUserProfile === undefined) delete process.env.USERPROFILE; + else process.env.USERPROFILE = prevUserProfile; + if (prevPiBin === undefined) delete process.env.PI_BIN; + else process.env.PI_BIN = prevPiBin; + if (prevPiDir === undefined) delete process.env.PI_CODING_AGENT_DIR; + else process.env.PI_CODING_AGENT_DIR = prevPiDir; + if (prevInline === undefined) delete process.env.BILI_PI_INLINE; + else process.env.BILI_PI_INLINE = prevInline; + if (stubbed) fs.rmSync(distAgent, { force: true }); + rmrf(home); + } +}); + test("runLaunch pi #535: refuses launch when http rewrites needed and extension cannot load; no overlay files written", async () => { const home = fs.mkdtempSync(path.join(os.tmpdir(), "bili-pirefuse-")); const prevHome = process.env.HOME; diff --git a/tests/pi-inline-ws.test.ts b/tests/pi-inline-ws.test.ts index d96fe00542..5c64149ba2 100644 --- a/tests/pi-inline-ws.test.ts +++ b/tests/pi-inline-ws.test.ts @@ -255,9 +255,9 @@ test("inline WS: planNativePi accepts the widened truthy/falsy BILI_PI_INLINE se // file config still honored when env unset, overridden when env off assert.equal(planNativePi({}, true).mode, "inline"); assert.equal(planNativePi({ BILI_PI_INLINE: "false" }, true).mode, "spawn"); - // #4687: no signals at all = the spawned server (default flip reverted; - // inline is opt-in only); explicit file opt-out also plans the server - assert.equal(planNativePi({}).mode, "spawn"); - assert.equal(planNativePi({}, undefined).mode, "spawn"); + // #5428: no signals at all = the in-process inline lane (default flipped + // back on); explicit file opt-out still plans the server + assert.equal(planNativePi({}).mode, "inline"); + assert.equal(planNativePi({}, undefined).mode, "inline"); assert.equal(planNativePi({}, false).mode, "spawn"); }); diff --git a/tests/pi-native.test.ts b/tests/pi-native.test.ts index e1479a31d9..e17d58da5d 100644 --- a/tests/pi-native.test.ts +++ b/tests/pi-native.test.ts @@ -134,11 +134,13 @@ test("legacyBcpEntriesIn: reads packages[], tolerates missing/broken files", () assert.deepEqual(legacyBcpEntriesIn(path.join(dir, "missing.json")), []); }); -test("planNativePi: default is the in-process inline lane (#4571); opt-out and /bili/ launches are off", () => { - // plain `pi` with the plugin and no signals plans the spawned proxy — - // inline is OPT-IN (#4687 reverts the #4571 default flip; owner rule: - // never change defaults). Explicit opt-out paths also plan the server. - assert.deepEqual(planNativePi({}), { mode: "spawn" }, "default stays spawn (no default flip)"); +test("planNativePi: default is the in-process inline lane (#5428 restores the #4571 posture); explicit opt-out and /bili/ launches leave it", () => { + // plain `pi` with the plugin and no signals plans the IN-PROCESS lane — + // inline is the DEFAULT since #5428 (supersedes the #4687 opt-in rule). + // Explicit opt-out (env off / file false) plans the spawned server, and + // an ANNOUNCED attach target still beats the default (see next test). + assert.deepEqual(planNativePi({}), { mode: "inline" }, "default is inline (#5428 default flip)"); + assert.deepEqual(planNativePi({ BILI_PI_INLINE: "" }), { mode: "inline" }, "blank env folds to unset → default inline"); assert.deepEqual(planNativePi({ BILI_PI_INLINE: "0" }), { mode: "spawn" }); assert.deepEqual(planNativePi({}, false), { mode: "spawn" }); assert.deepEqual(planNativePi({}, true), { mode: "inline" }); @@ -162,10 +164,10 @@ test("planNativePi: a preset BILLION_CONTEXT_PROXY is an attach target, not a st // kill switches and a /bili/ launch still win over the preset assert.deepEqual(planNativePi({ BILLION_CONTEXT_PROXY: "http://127.0.0.1:36485", BILLION_CONTEXT_PLUGIN: "0" }), { mode: "off" }); assert.deepEqual(planNativePi({ BILLION_CONTEXT_PROXY: "http://127.0.0.1:36485", BILI_PROVIDER_REWRITES: "{}" }), { mode: "off" }); - // a garbage / blank preset falls back to self-managed — the spawned - // server (historical default), never dead-off - assert.deepEqual(planNativePi({ BILLION_CONTEXT_PROXY: "garbage" }), { mode: "spawn" }); - assert.deepEqual(planNativePi({ BILLION_CONTEXT_PROXY: " " }), { mode: "spawn" }); + // a garbage / blank preset is no attach origin at all — the #5428 inline + // DEFAULT arms, never dead-off + assert.deepEqual(planNativePi({ BILLION_CONTEXT_PROXY: "garbage" }), { mode: "inline" }); + assert.deepEqual(planNativePi({ BILLION_CONTEXT_PROXY: " " }), { mode: "inline" }); }); test("planNativePi: explicit BILLION_CONTEXT_ATTACH wins over the env preset", () => { @@ -192,9 +194,9 @@ test("#3278: BILI_PI_INLINE plans the no-server lane and outranks ambient attach assert.deepEqual(planNativePi({ BILI_PI_INLINE: "1", BILLION_CONTEXT_PLUGIN: "0" }), { mode: "off" }); assert.deepEqual(planNativePi({ BILI_PI_INLINE: "1", BILI_NATIVE_PI: "0" }), { mode: "off" }); assert.deepEqual(planNativePi({ BILI_PI_INLINE: "1", BILI_PROVIDER_REWRITES: "{}" }), { mode: "off" }); - // unset / off values keep today's postures untouched + // unset / off values: unset = the #5428 inline default; explicit off = spawn assert.deepEqual(planNativePi({ BILI_PI_INLINE: "0" }), { mode: "spawn" }); - assert.deepEqual(planNativePi({}), { mode: "spawn" }, "default stays spawn (no default flip)"); + assert.deepEqual(planNativePi({}), { mode: "inline" }, "default is inline (#5428 default flip)"); }); test("#3278: pi.inline (config file) enables the lane; env resolves over it", () => { @@ -209,7 +211,7 @@ test("#3278: pi.inline (config file) enables the lane; env resolves over it", () assert.deepEqual(planNativePi({ BILI_PI_INLINE: "false" }, true), { mode: "spawn" }); // explicit env on enables over a false file value assert.deepEqual(planNativePi({ BILI_PI_INLINE: "1" }, false), { mode: "inline" }); - assert.deepEqual(planNativePi({}, false), { mode: "spawn" }); + assert.deepEqual(planNativePi({}, false), { mode: "spawn" }, "explicit file false opts out of the #5428 inline default"); // kill switches and /bili/ launches still win over the file assert.deepEqual(planNativePi({ BILLION_CONTEXT_PLUGIN: "0" }, true), { mode: "off" }); assert.deepEqual(planNativePi({ BILI_NATIVE_PI: "0" }, true), { mode: "off" }); diff --git a/website/config-reference/env-only.yaml b/website/config-reference/env-only.yaml index 9c20d49708..635c399999 100644 --- a/website/config-reference/env-only.yaml +++ b/website/config-reference/env-only.yaml @@ -372,12 +372,12 @@ entries: desc_zh: "宿主姿态:标记 pi 原生插件进程。" - key: BILI_PI_INLINE type: boolean-ish - default: "off (opt-in)" + default: "inline when unset (DEFAULT-ON since #5428; explicit 0/false/no/off opts out)" kind: env-only audience: internal group: envonly - desc_en: "Host posture: pi inline lane (#3278) — the pi extension compresses IN-PROCESS through the pseudo-origin instead of spawning its own proxy; outranks a preset BILLION_CONTEXT_PROXY attach target. OPT-IN: #4687 reverts the #4571 default flip — unset env/file behaves exactly as before (attach/spawn). Truthy = any non-empty value except 0/false/no/off (on/yes/TRUE all enable). Codex Responses WS traffic is routed through a loopback-only bridge booted with the engine; if that bridge fails, the WS lane degrades DIRECT (warned) while HTTP compression stays in-process." - desc_zh: "宿主姿态:pi 内联压缩通道(#3278)——pi 扩展在进程内通过伪源站直接压缩,不再另起代理进程;优先于预置的 BILLION_CONTEXT_PROXY 附着目标。需手动开启:#4687 收回 #4571 的默认翻转,不设置时行为与旧版完全一致(attach/spawn);除 0/false/no/off 外任何非空值均算开启(on/yes/TRUE 均可)。codex 的 Responses WS 流量改走随引擎启动的仅回环桥;桥起不来时该通道退回直连(打 warn),HTTP 压缩仍留在进程内。" + desc_en: "Host posture: pi inline lane (#3278) — the pi extension compresses IN-PROCESS through the pseudo-origin instead of spawning its own proxy; outranks a preset BILLION_CONTEXT_PROXY attach target. DEFAULT-ON since #5428 (supersedes the #4687 opt-in rule): unset env+file runs inline; an announced attach target still beats the DEFAULT, so `bili pi` keeps its launcher proxy. Explicit OPT-OUT = 0/false/no/off (or `\"pi\": {\"inline\": false}`) — restores the old attach/spawn posture. Human surface: `bili -i/--inline pi` forces inline, `bili -s/--server pi` pins the proxy posture (beats an inherited inline env). Truthy = any non-empty value except 0/false/no/off (on/yes/TRUE all enable). Codex Responses WS traffic is routed through a loopback-only bridge booted with the engine; if that bridge fails, the WS lane degrades DIRECT (warned) while HTTP compression stays in-process." + desc_zh: "宿主姿态:pi 内联压缩通道(#3278)——pi 扩展在进程内通过伪源站直接压缩,不再另起代理进程;优先于预置的 BILLION_CONTEXT_PROXY 附着目标。自 #5428 起默认开启(取代 #4687 的手动开启规则):未设置 env+文件时走内联;显式宣告的附着目标仍压过默认,`bili pi` 照旧用 launcher 代理。显式关闭 = 0/false/no/off(或 `\"pi\": {\"inline\": false}`)——恢复旧的 attach/spawn 姿态。人类入口:`bili -i/--inline pi` 强制内联,`bili -s/--server pi` 钉死代理姿态(压过继承的内联变量)。除 0/false/no/off 外任何非空值均算开启(on/yes/TRUE 均可)。codex 的 Responses WS 流量改走随引擎启动的仅回环桥;桥起不来时该通道退回直连(打 warn),HTTP 压缩仍留在进程内。" - key: BILI_OPENCODE_INLINE type: boolean-ish default: "off (opt-in)" diff --git a/website/config-reference/server.yaml b/website/config-reference/server.yaml index eefc1275cc..eaa1525977 100644 --- a/website/config-reference/server.yaml +++ b/website/config-reference/server.yaml @@ -502,11 +502,11 @@ entries: desc_zh: "内置 pi lane 子代理(acp_delegate)面(#2230 配置搬家)。billion-context.json 的 pi.subagents 段拥有 delegate 配置;acp.json 四键(delegate/delegatePrompt/displayUsage/debug)为已废弃回退源,仅段缺失时读取。prompt 取代 delegatePrompt;debug 限定子代理子系统。布尔简写 subagents: false 整体关闭。完整字段表见 CONFIGURATION.md 的 pi 段。" - key: pi.inline type: boolean - default: "false" + default: "true (unset env+file runs inline)" env: BILI_PI_INLINE group: behavior - desc_en: "Pi inline lane (#3278; OPT-IN — #4687 reverts the #4571 default flip, default stays the spawned proxy): the pi extension's compression runs IN-PROCESS — no spawned proxy, no ephemeral port; model traffic and the /__bili//__acp tool surface are served by an in-process engine through a pseudo-origin, the codex Responses WebSocket lane by a loopback-only WS bridge, and the Web UI by a loopback-only web listener booted with the engine. Set true (or BILI_PI_INLINE=1/on/yes/TRUE) to enable. Resolved env > file; an explicit inline choice always beats an announced attach target (launcher-set BILLION_CONTEXT_PROXY/ATTACH); when unset the lane behaves exactly as before (attach/spawn). `bili pi-inline` presets the env for the one-command lane." - desc_zh: "pi 内联压缩通道(#3278;需手动开启——#4687 收回 #4571 的默认翻转,默认仍是派生代理):pi 扩展的压缩在进程内完成——不派生代理进程、无临时端口;模型流量与 /__bili//__acp 工具面由进程内引擎经伪源站服务,codex 的 Responses WebSocket 通道走随引擎启动的仅回环 WS 桥,Web UI 走随引擎启动的仅回环监听。设 true(或 BILI_PI_INLINE=1/on/yes/TRUE)开启。解析顺序 env > 文件;显式开启永远压过附着目标,未设置时行为与旧版一致(attach/spawn)。`bili pi-inline` 一键车道会预置该变量。" + desc_en: "Pi inline lane (#3278; DEFAULT-ON since #5428, superseding the #4687 opt-in rule): the pi extension's compression runs IN-PROCESS — no spawned proxy, no ephemeral port; model traffic and the /__bili//__acp tool surface are served by an in-process engine through a pseudo-origin, the codex Responses WebSocket lane by a loopback-only WS bridge, and the Web UI by a loopback-only web listener booted with the engine. Unset env+file now runs INLINE; an ANNOUNCED attach target (launcher-set BILLION_CONTEXT_PROXY/ATTACH) still beats the default, so `bili pi` keeps its launcher proxy. Opt OUT with BILI_PI_INLINE=0/false/no/off or this key set false — restores the old attach/spawn posture. Resolved env > file > default; an explicit inline choice always beats an announced attach target. Human surface: `bili -i/--inline pi` (≡ the one-command lane) and `bili -s/--server pi` (pin the proxy posture, beats an inherited inline env)." + desc_zh: "pi 内联压缩通道(#3278;自 #5428 起默认开启,取代 #4687 的手动开启规则):pi 扩展的压缩在进程内完成——不派生代理进程、无临时端口;模型流量与 /__bili//__acp 工具面由进程内引擎经伪源站服务,codex 的 Responses WebSocket 通道走随引擎启动的仅回环 WS 桥,Web UI 走随引擎启动的仅回环监听。未设置 env+文件时默认内联;显式宣告的附着目标(launcher 预置的 BILLION_CONTEXT_PROXY/ATTACH)仍压过默认,`bili pi` 照旧用 launcher 代理。不想用就 BILI_PI_INLINE=0/false/no/off 或本键设 false——恢复旧的 attach/spawn 姿态。解析顺序 env > 文件 > 默认;显式开启永远压过附着目标。人类入口:`bili -i/--inline pi`(≡ 一键车道)与 `bili -s/--server pi`(钉死代理姿态,压过继承的内联变量)。" - key: opencode.inline type: boolean default: "false"