Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1015,13 +1015,14 @@ The launcher prefers file-free injection (env vars > CLI flags/extension APIs >
- **opencode** — a temp `opencode.json` pointed at by `OPENCODE_CONFIG` (removed when the client exits), with `/bili/`-rewritten plaintext baseURLs **plus the thin plugin appended** (`/acp` + `/acp-cache` commands). On OpenCode 1.x the `opencode-acp` entries are stripped from the clone (the host must not load it armed) and the thin plugin imports that same package as a library instead, gated on legacy sessions; the first stripped spec rides along via `BILI_OPENCODE_ACP_SPEC` so the bridge imports the exact copy the host would have loaded (#920). Relative local plugin specs (`./x`, `../x`) are re-anchored to absolute paths in the clone — opencode resolves them against the declaring config file's dir, which the clone no longer is (#826).
- **hermes** — nothing is written (#535): its httpx stack rides `HTTPS_PROXY` (+ `SSL_CERT_FILE` → `combined-ca.pem`; legacy `HERMES_CA_BUNDLE` stays set for older builds, #1375) — https via CONNECT cert-MITM, plain-http via absolute-form forward-proxy requests. If no providers are configured, the launcher prints a warning and hermes runs **unproxied** (compression off).
- **dsh** — split by destination (#535): dsh's fetch stack honors proxy envs except for an unconditional loopback bypass, so **non-loopback** upstreams ride `HTTPS_PROXY` (cert MITM) / `HTTP_PROXY` (absolute-form forward-proxy requests) with `SSL_CERT_FILE` → `combined-ca.pem`; only **loopback** upstreams keep the persistent overlay `DSH_HOME` (`~/.dsh-bili`) with a rewritten `settings.yaml` routing them through `/bili/`. `profiles/`, credentials and sessions are symlinked through; the real `~/.dsh` is never touched. The built-in `deepseek-official` route is captured separately via `$DEEPSEEK_BASE_URL` (dsh resolves `settings llm-deepseek.baseURL` ?? env ?? default, so a user setting wins and the env is the zero-config fallback) — with no custom providers the deepseek route is still proxied out of the box.
- **codex** — a persistent overlay `CODEX_HOME` (`~/.codex-bili`, or `<CODEX_HOME>-bili`) whose other entries (auth, sessions, model settings) stay shared links into the real home. Two generated files: (a) when MCP injection is on, a merged `config.toml` — real contents plus the per-spawn `[mcp_servers.bili]` block (inline `-c` values cannot survive cmd.exe quoting on Windows, #681); (b) since #1802, a generated `.env` (mode 0600) that re-pins THIS launch's `HTTP_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY` / `SSL_CERT_FILE` / `BILLION_CONTEXT_PROXY`: codex's own `load_dotenv()` overwrites the launcher's spawn env from `$CODEX_HOME/.env` **after** start, so a user `.env` pointing at e.g. a socks5h proxy would otherwise silently re-route codex off bili (and codex's custom-CA rustls HTTP stack cannot speak SOCKS at all). Your other `.env` variables are carried over verbatim; pre-existing shared `.env` links are migrated to an owned file; the real home's `.env` and every other real-home file are never touched. Direct-URL mode (`BILI_LAUNCHER_DIRECT=1`) generates no `.env` (there is no injected proxy to protect) and, without MCP, no overlay at all.

### Native tools in the launcher

- **pi** — if the plugin is NOT installed, the launcher rides pi's `-e <file>` flag to load `dist/agent/pi.js` for that run only (nothing is written): native tools + the `/acp`, `/acp-cache` and `/acp-rule` commands out of the box (`/acp-cache` defaults to the summary ledger — totals, verdicts, anomalies; append `full` (or `--full`) for the every-line listing, same as passing `detail: "full"` to the `acp_cache` tool). If it IS installed, the symlinked `settings.json` already loads it — no `-e` is added.
- **omp** — does NOT ship the plugin; the launcher auto-injects `-e dist/agent/omp.js` when the config carries no loadable bili entry (same zero-config ride as pi). Two omp-specific mechanics make the plugin fully native there: omp 17.x mounts extension tools that omit `loadMode` under its `xd://` device URLs (invisible to the model's main turn), so the plugin registers its tools with `loadMode: "essential"` — the model gets the four ACP tools natively; and since omp's fork emits no `before_provider_headers`, the plugin binds the conversation via the launcher identity register (`POST /__bili/plugin/register`, keyed by omp's session id = `prompt_cache_key`/`x-session-id`) — bound sessions run in plugin mode (wire injection suppressed) with the native `/acp`, `/acp-cache` and `/acp-rule` commands.
- **opencode** — the temp config appends the thin plugin automatically.
- **claude / codex** — on by default: the launcher injects a single `bili` MCP server (`--mcp-config` for claude, `-c mcp_servers.bili.*` for codex — both ephemeral, nothing written to host config), so the host gets native tools out of the box (verified with claude 2.1.227 / codex 0.147.0). `BILI_LAUNCHER_PLUGIN=0` falls back to plain wire mode — for hosts older than the verified builds that have not been tested against the injection flags.
- **claude / codex** — on by default: the launcher injects a single `bili` MCP server (an ephemeral `--mcp-config` file for claude; for codex the definition lives in the overlay's generated `config.toml`, see [Generated files](#generated-files-what-gets-written---last-resort-only--535) — nothing written to the real host config either way), so the host gets native tools out of the box (verified with claude 2.1.227 / codex 0.147.0). `BILI_LAUNCHER_PLUGIN=0` falls back to plain wire mode — for hosts older than the verified builds that have not been tested against the injection flags.
- **codex + self-hosted upstream auto-fallback** — codex 0.147 ships MCP tools to the model as a `namespace` tool type; self-hosted servers (sglang/vllm/ollama/llama.cpp) do not parse it, leaving the tools silently invisible. When the codex upstream host is loopback/private (`127.0.0.1`, RFC1918, ULA, `.local`, …) and `BILI_LAUNCHER_PLUGIN` is unset, bili automatically uses wire mode instead (flat tools every server understands) and says so on stderr. `BILI_LAUNCHER_PLUGIN=1` forces plugin mode regardless.
- **hermes** — no plugin API; always wire mode.
- **dsh** — the launcher always splices a `--patch <file>` flag into dsh's argv (written to `~/.dsh-bili/.bili-acp.patch.yml`), inserting `dist/agent/dsh-acp.js` into the profile's loader tree: the native `/acp` and `/acp-cache` commands, same shape as dsh's own `/compact` (`/acp-cache` shows the default summary ledger — dsh's command API passes no arguments, so there is no `full`). Works on every profile that composes the commands service (web/tui interactive surfaces; the `headless` one-shot driver sends its task straight to the model and parses no commands — `/compact` behaves the same there). Subcommand forms are handled: `dsh web` gets the flag after `web`, `dsh plugin`/`--dump-default-config` take none.
Expand Down
3 changes: 2 additions & 1 deletion CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -990,13 +990,14 @@ Claude Code 的 undici fetch 忽略 `HTTPS_PROXY`,所以证书 MITM 拦不到
- **opencode** —— 临时 `opencode.json`(由 `OPENCODE_CONFIG` 指向,客户端退出时删除),明文 `baseURL` 重写为 `/bili/` 形式,**并追加了薄插件**(`/acp` + `/acp-cache` 命令)。OpenCode 1.x 下 `opencode-acp` 条目会从副本中移除(主机不得以激活状态加载它),改由薄插件把同一个包作为库导入、仅对 legacy 会话生效;首个被移除的 spec 经 `BILI_OPENCODE_ACP_SPEC` 传递,保证 bridge 导入的正是主机本会加载的那份拷贝(#920)。
- **hermes** —— 不写任何文件(#535):其 httpx 栈走 `HTTPS_PROXY`(+ `SSL_CERT_FILE` → `combined-ca.pem`;旧版 `HERMES_CA_BUNDLE` 保留设置,#1375)—— https 经 CONNECT 证书 MITM,明文 http 经 absolute-form 正向代理请求。若没配置任何 provider,启动器打印警告,hermes 将**不经代理**运行(无压缩)。
- **dsh** —— 按目的地分流(#535):dsh 的 fetch 栈尊重代理 env,但对回环目标无条件绕过,所以**非回环**上游走 `HTTPS_PROXY`(证书 MITM)/ `HTTP_PROXY`(absolute-form 正向代理请求),`SSL_CERT_FILE` → `combined-ca.pem`;仅**回环**上游保留持久 overlay `DSH_HOME`(`~/.dsh-bili`),重写后的 `settings.yaml` 让它们走 `/bili/`。`profiles/`、凭据、会话符号链接共享;真实 `~/.dsh` 绝不触碰。内置 `deepseek-official` 路由另行经 `$DEEPSEEK_BASE_URL` 接管(dsh 解析顺序为 settings `llm-deepseek.baseURL` ?? 环境变量 ?? 默认值,用户配置优先,环境变量作零配置兜底)—— 即便没有任何自定义 provider,内置 deepseek 路由也照样走代理。
- **codex** —— 持久 overlay `CODEX_HOME`(`~/.codex-bili`,或 `<CODEX_HOME>-bili`),其余条目(凭据、会话、模型设置)保持指向真实主目录的共享链接。两个生成文件:(a) MCP 注入开启时,合并后的 `config.toml` —— 真实内容加上每次启动的 `[mcp_servers.bili]` 块(内联 `-c` 值在 Windows cmd.exe 引号处理下无法存活,#681);(b) #1802 起,生成的 `.env`(权限 0600),把**本次启动**的 `HTTP_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY` / `SSL_CERT_FILE` / `BILLION_CONTEXT_PROXY` 重新钉死:codex 自己的 `load_dotenv()` 会在启动**之后**用 `$CODEX_HOME/.env` 覆盖启动器注入的环境变量,否则用户 `.env` 里指向 socks5h 之类的代理会悄悄把 codex 重新路由出 bili(且 codex 自定义 CA 的 rustls HTTP 栈根本不支持 SOCKS)。你 `.env` 里的其他变量逐行原样保留;既有的共享 `.env` 链接会迁移为自有文件;真实主目录的 `.env` 及其他所有文件绝不触碰。direct-URL 模式(`BILI_LAUNCHER_DIRECT=1`)不生成 `.env`(没有需要保护的注入代理),且未开 MCP 时连 overlay 都不建。

### 启动器里的原生工具

- **pi** —— 未安装插件时,启动器借用 pi 的 `-e <file>` 参数为本次运行加载 `dist/agent/pi.js`(不写任何东西):开箱即原生工具 + `/acp`、`/acp-cache` 与 `/acp-rule` 命令(`/acp-cache` 默认总账摘要 —— 总计、判定、异常行;追加 `full`(或 `--full`)看全量明细,等价于 `acp_cache` 工具传 `detail: "full"`)。已安装则符号链接的 `settings.json` 已加载它 —— 不再加 `-e`。
- **omp** —— 发行版不自带插件;启动器在配置里没有可加载的 bili 条目时自动注入 `-e dist/agent/omp.js`(与 pi 相同的零配置搭车)。两个 omp 专属机制让插件在那里完全原生:omp 17.x 会把未声明 `loadMode` 的扩展工具挂到 `xd://` 设备 URL 下(模型主回合看不到),插件因此用 `loadMode: "essential"` 注册 —— 模型直接拿到四个 ACP 原生工具;omp 分叉不发 `before_provider_headers`,插件改走启动器身份注册(`POST /__bili/plugin/register`,以 omp 会话 id = `prompt_cache_key`/`x-session-id` 为键)绑定会话 —— 绑定后的会话进入插件模式(抑制 wire 注入)并带有原生 `/acp`、`/acp-cache` 与 `/acp-rule` 命令。
- **opencode** —— 临时配置自动追加薄插件。
- **claude / codex** —— 默认开启:启动器注入单个 `bili` MCP 服务器(claude 用 `--mcp-config`,codex 用 `-c mcp_servers.bili.*` —— 都是临时生效,不写宿主配置),开箱即原生工具(已在 claude 2.1.227 / codex 0.147.0 验证)。`BILI_LAUNCHER_PLUGIN=0` 退回纯 wire 模式 —— 适用于早于已验证版本、未针对注入参数测试的宿主。
- **claude / codex** —— 默认开启:启动器注入单个 `bili` MCP 服务器(claude 用临时 `--mcp-config` 文件;codex 的定义写在 overlay 生成的 `config.toml` 里,见[生成文件](#生成文件写了什么----最后手段--535) —— 两种情况都不写真实宿主配置),开箱即原生工具(已在 claude 2.1.227 / codex 0.147.0 验证)。`BILI_LAUNCHER_PLUGIN=0` 退回纯 wire 模式 —— 适用于早于已验证版本、未针对注入参数测试的宿主。
- **codex + 自建上游自动回退** —— codex 0.147 把 MCP 工具以 `namespace` 工具类型发给模型;自建推理服务(sglang/vllm/ollama/llama.cpp)不解析该类型,工具会静默失明。当 codex 上游主机是环回/私网地址(`127.0.0.1`、RFC1918、ULA、`.local` 等)且未设置 `BILI_LAUNCHER_PLUGIN` 时,bili 自动改用 wire 模式(扁平工具,所有服务都认识)并在 stderr 说明。`BILI_LAUNCHER_PLUGIN=1` 可强制插件模式。
- **hermes** —— 无插件 API;永远 wire 模式。
- **dsh** —— 启动器始终在 dsh 的 argv 里拼接 `--patch <file>`(写入 `~/.dsh-bili/.bili-acp.patch.yml`),把 `dist/agent/dsh-acp.js` 插进 profile 的加载树:原生 `/acp` 与 `/acp-cache` 命令,与 dsh 自带 `/compact` 同一形态(`/acp-cache` 显示默认总账摘要 —— dsh 的命令 API 不传参数,因此没有 `full`)。在任何组合了 commands 服务的 profile(web/tui 交互表面)都可用;`headless` 一次性驱动器把任务直接发给模型、不解析命令(原生 `/compact` 在那里同样不可用)。子命令形态已处理:`dsh web` 的 flag 插在 `web` 之后,`dsh plugin`/`--dump-default-config` 不注入。
Expand Down
Loading
Loading