billion-context 0.1.102-pr.641.521 → 0.1.102-pr.669.519
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -1
- package/dist/index.js +48 -168
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -158,7 +158,7 @@ rewrite until dsh gains a settings-path env or an upstream loopback opt-out.
|
|
|
158
158
|
Overlay dirs created by older versions are left in place and never merged back
|
|
159
159
|
into the real home.
|
|
160
160
|
|
|
161
|
-
### Option 1 — Launcher (`bili pi` / `bili codex` / `bili claude` / `bili omp` / `bili opencode` / `bili hermes` / `bili dsh` / `bili
|
|
161
|
+
### Option 1 — Launcher (`bili pi` / `bili codex` / `bili claude` / `bili omp` / `bili opencode` / `bili hermes` / `bili dsh` / `bili trae`)
|
|
162
162
|
|
|
163
163
|
The launcher wraps a client in one command: it starts a proxy on an
|
|
164
164
|
independent port (a fresh instance is always spawned — a port is never
|
|
@@ -177,7 +177,7 @@ bili omp # pi-style, file-free (#535): env + extens
|
|
|
177
177
|
bili opencode # MITM for HTTPS + temp opencode.json (/bili/ for HTTP) + thin /acp plugin
|
|
178
178
|
bili hermes # file-free (#535): hermes proxy env (HTTPS_PROXY + HERMES_CA_BUNDLE) — https via CONNECT MITM, http via absolute-form forward proxy; real ~/.hermes untouched
|
|
179
179
|
bili dsh # deepseek-harness: non-loopback upstreams ride proxy envs (https MITM, http absolute-form), loopback keeps the overlay DSH_HOME (~/.dsh-bili) rewrite (#535), built-in deepseek route via DEEPSEEK_BASE_URL, native /acp command injected via --patch
|
|
180
|
-
bili
|
|
180
|
+
bili trae # Trae CLI (ByteDance, closed Go binary, no base-URL override) — cert-MITM via HTTPS_PROXY + SSL_CERT_FILE, model host from TRAE_CLI_API_HOST or the default enterprise gateway (#655)
|
|
181
181
|
bili pi --mitm-domain api.foo.com # add a domain to the MITM whitelist
|
|
182
182
|
```
|
|
183
183
|
|
package/README.zh-CN.md
CHANGED
|
@@ -84,7 +84,7 @@ npm install -g billion-context
|
|
|
84
84
|
|
|
85
85
|
bili 永不拥有用户数据:每个被启动的客户端都跑在**真实 home** 上,运行期写入落在用户预期的位置。把客户端指向代理时,启动器按优先级选择——**优先 env 变量**(hermes/dsh/codex 的代理/CA env;pi/omp 的 `BILI_PROVIDER_REWRITES` URL 清单,由扩展加载时经 `registerProvider` 消费),其次 **CLI 参数或扩展 API**(codex `-c key=value`、opencode 插件),最后才是**生成文件**——目前仅剩 opencode 的临时 `opencode.json`(退出即删)和 dsh 的回环例外:dsh 的 fetch 栈对回环目标无条件绕过代理 env,所以本地上游保留持久 `~/.dsh-bili` overlay 改写,直到 dsh 提供 settings-path env 或上游支持回环 opt-out。旧版本创建的 overlay 目录原地保留,绝不合并回真实 home。
|
|
86
86
|
|
|
87
|
-
### 方式 1 —— 启动器(`bili pi` / `bili codex` / `bili claude` / `bili omp` / `bili opencode` / `bili hermes` / `bili dsh`)
|
|
87
|
+
### 方式 1 —— 启动器(`bili pi` / `bili codex` / `bili claude` / `bili omp` / `bili opencode` / `bili hermes` / `bili dsh` / `bili trae`)
|
|
88
88
|
|
|
89
89
|
启动器把客户端包进一条命令:在独立端口拉起一个代理(总是全新实例,绝不复用端口),再按客户端支持的机制把它指向代理 —— 能吃代理/CA 环境变量的走**证书 MITM**,不吃的走隔离的**`/bili/` 配置重写**。真实配置文件从不被修改;客户端自己的配置只被**读取**,用来发现它实际连接的 HTTPS 上游主机,把这些主机加入 MITM 白名单 —— 代理只 TLS 终结它们,其余流量盲透传。
|
|
90
90
|
|
|
@@ -96,6 +96,7 @@ bili omp # pi 同款,file-free(#535):环境变量 +
|
|
|
96
96
|
bili opencode # HTTPS 走 MITM + 临时 opencode.json(HTTP 走 /bili/)+ 轻量 /acp 插件
|
|
97
97
|
bili hermes # file-free(#535):hermes 代理环境变量(HTTPS_PROXY + HERMES_CA_BUNDLE)—— https 走 CONNECT MITM,http 走绝对形式转发;真实 ~/.hermes 不动
|
|
98
98
|
bili dsh # deepseek-harness:非回环上游走代理 env(https MITM、http absolute-form),回环上游保留 overlay DSH_HOME(~/.dsh-bili)改写(#535),内置 deepseek 路由走 DEEPSEEK_BASE_URL,经 --patch 注入原生 /acp 命令
|
|
99
|
+
bili trae # Trae CLI(字节跳动,闭源 Go 二进制,无 base-URL 覆盖)—— 证书 MITM(HTTPS_PROXY + SSL_CERT_FILE),模型主机取 TRAE_CLI_API_HOST 或默认企业网关(#655)
|
|
99
100
|
bili pi --mitm-domain api.foo.com # 向 MITM 白名单追加域名
|
|
100
101
|
```
|
|
101
102
|
|
package/dist/index.js
CHANGED
|
@@ -57314,98 +57314,6 @@ function resolveCodexHome(env) {
|
|
|
57314
57314
|
const h = os.homedir();
|
|
57315
57315
|
return nonEmpty2(env.CODEX_HOME) ? env.CODEX_HOME : path10.join(h, ".codex");
|
|
57316
57316
|
}
|
|
57317
|
-
function resolveCodebuddyHome(env) {
|
|
57318
|
-
const h = os.homedir();
|
|
57319
|
-
return nonEmpty2(env.CODEBUDDY_CONFIG_DIR) ? env.CODEBUDDY_CONFIG_DIR : path10.join(h, ".codebuddy");
|
|
57320
|
-
}
|
|
57321
|
-
function parseCodebuddyModelsJson(obj) {
|
|
57322
|
-
const out = { models: [], urls: [] };
|
|
57323
|
-
const seenUrl = /* @__PURE__ */ new Set();
|
|
57324
|
-
const collect = (id, entry) => {
|
|
57325
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return;
|
|
57326
|
-
const e = entry;
|
|
57327
|
-
const url = e.url;
|
|
57328
|
-
if (typeof url === "string" && url.length > 0 && !seenUrl.has(url)) {
|
|
57329
|
-
seenUrl.add(url);
|
|
57330
|
-
out.urls.push(url);
|
|
57331
|
-
}
|
|
57332
|
-
const win = toModelWindow(id, e.maxInputTokens);
|
|
57333
|
-
if (win) out.models.push(win);
|
|
57334
|
-
};
|
|
57335
|
-
if (!obj) return out;
|
|
57336
|
-
if (Array.isArray(obj)) {
|
|
57337
|
-
for (const item of obj) {
|
|
57338
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
|
57339
|
-
const it2 = item;
|
|
57340
|
-
collect(it2.id ?? it2.name, it2);
|
|
57341
|
-
}
|
|
57342
|
-
return out;
|
|
57343
|
-
}
|
|
57344
|
-
if (typeof obj !== "object") return out;
|
|
57345
|
-
const root = obj;
|
|
57346
|
-
const modelsField = root.models;
|
|
57347
|
-
if (Array.isArray(modelsField)) {
|
|
57348
|
-
for (const item of modelsField) {
|
|
57349
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
|
57350
|
-
const it2 = item;
|
|
57351
|
-
collect(it2.id ?? it2.name, it2);
|
|
57352
|
-
}
|
|
57353
|
-
return out;
|
|
57354
|
-
}
|
|
57355
|
-
if (modelsField && typeof modelsField === "object") {
|
|
57356
|
-
for (const [id, val] of Object.entries(modelsField)) collect(id, val);
|
|
57357
|
-
return out;
|
|
57358
|
-
}
|
|
57359
|
-
for (const [id, val] of Object.entries(root)) collect(id, val);
|
|
57360
|
-
return out;
|
|
57361
|
-
}
|
|
57362
|
-
function readJsonFile(filePath) {
|
|
57363
|
-
try {
|
|
57364
|
-
return JSON.parse(fs6.readFileSync(filePath, "utf8"));
|
|
57365
|
-
} catch {
|
|
57366
|
-
return null;
|
|
57367
|
-
}
|
|
57368
|
-
}
|
|
57369
|
-
function readCodebuddyConfig(codebuddyHome, cwd, env = process.env) {
|
|
57370
|
-
let codebuddyBaseUrl;
|
|
57371
|
-
let model;
|
|
57372
|
-
let autoCompactWindow;
|
|
57373
|
-
const settings = readJsonObject(path10.join(codebuddyHome, "settings.json"));
|
|
57374
|
-
const settingsEnv = settings?.env;
|
|
57375
|
-
if (settingsEnv && typeof settingsEnv === "object" && !Array.isArray(settingsEnv)) {
|
|
57376
|
-
const e = settingsEnv;
|
|
57377
|
-
const v2 = e.CODEBUDDY_BASE_URL;
|
|
57378
|
-
if (nonEmpty2(v2)) codebuddyBaseUrl = v2;
|
|
57379
|
-
}
|
|
57380
|
-
const tm = settings?.model;
|
|
57381
|
-
if (nonEmpty2(tm)) model = String(tm);
|
|
57382
|
-
const tacw = Number(settings?.autoCompactWindow);
|
|
57383
|
-
if (Number.isFinite(tacw) && tacw > 0) autoCompactWindow = tacw;
|
|
57384
|
-
if (!codebuddyBaseUrl && nonEmpty2(env.CODEBUDDY_BASE_URL)) codebuddyBaseUrl = env.CODEBUDDY_BASE_URL;
|
|
57385
|
-
const windowByModel = /* @__PURE__ */ new Map();
|
|
57386
|
-
const urls = [];
|
|
57387
|
-
const seenUrl = /* @__PURE__ */ new Set();
|
|
57388
|
-
for (const f2 of [
|
|
57389
|
-
path10.join(codebuddyHome, "models.json"),
|
|
57390
|
-
path10.join(cwd, ".codebuddy", "models.json")
|
|
57391
|
-
]) {
|
|
57392
|
-
const parsed = parseCodebuddyModelsJson(readJsonFile(f2));
|
|
57393
|
-
for (const w2 of parsed.models) windowByModel.set(w2.id, w2.contextWindow);
|
|
57394
|
-
for (const u2 of parsed.urls) {
|
|
57395
|
-
if (!seenUrl.has(u2)) {
|
|
57396
|
-
seenUrl.add(u2);
|
|
57397
|
-
urls.push(u2);
|
|
57398
|
-
}
|
|
57399
|
-
}
|
|
57400
|
-
}
|
|
57401
|
-
return {
|
|
57402
|
-
...codebuddyBaseUrl ? { codebuddyBaseUrl } : {},
|
|
57403
|
-
...model ? { model } : {},
|
|
57404
|
-
...autoCompactWindow ? { autoCompactWindow } : {},
|
|
57405
|
-
...windowByModel.size > 0 ? { models: [...windowByModel.entries()].map(([id, contextWindow]) => ({ id, contextWindow })) } : {},
|
|
57406
|
-
...urls.length > 0 ? { modelUrls: urls } : {}
|
|
57407
|
-
};
|
|
57408
|
-
}
|
|
57409
57317
|
function parseDshSettingsYaml(text) {
|
|
57410
57318
|
const out = [];
|
|
57411
57319
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -57429,6 +57337,20 @@ function readDshConfig(dshHome) {
|
|
|
57429
57337
|
}
|
|
57430
57338
|
return { baseUrls: parseDshSettingsYaml(text) };
|
|
57431
57339
|
}
|
|
57340
|
+
var TRAE_DEFAULT_MODEL_HOSTS = [
|
|
57341
|
+
"console.enterprise.trae.cn",
|
|
57342
|
+
"www.trae.cn"
|
|
57343
|
+
];
|
|
57344
|
+
function resolveTraeHome(env) {
|
|
57345
|
+
const h = os.homedir();
|
|
57346
|
+
return nonEmpty2(env.TRAE_CONFIG_DIR) ? env.TRAE_CONFIG_DIR : path10.join(h, ".trae");
|
|
57347
|
+
}
|
|
57348
|
+
function readTraeConfig(env) {
|
|
57349
|
+
const result = {};
|
|
57350
|
+
const host = nonEmpty2(env.TRAE_CLI_API_HOST) ? env.TRAE_CLI_API_HOST.replace(/^https?:\/\//i, "").replace(/\/+$/, "") : void 0;
|
|
57351
|
+
if (host) result.modelApiHost = host;
|
|
57352
|
+
return result;
|
|
57353
|
+
}
|
|
57432
57354
|
function readClaudeSettings(homeDir, cwd, env = process.env) {
|
|
57433
57355
|
const files = [
|
|
57434
57356
|
path10.join(homeDir, ".claude", "settings.json"),
|
|
@@ -57779,7 +57701,7 @@ function loadClientConfig(env, cwd) {
|
|
|
57779
57701
|
config.opencode = readOpencodeConfig(resolveOpencodeConfigFile(env));
|
|
57780
57702
|
config.hermes = readHermesConfig(resolveHermesHome(env));
|
|
57781
57703
|
config.dsh = readDshConfig(resolveDshHome(env));
|
|
57782
|
-
config.
|
|
57704
|
+
config.trae = readTraeConfig(env);
|
|
57783
57705
|
return config;
|
|
57784
57706
|
}
|
|
57785
57707
|
function collectModelWindows(config, scope) {
|
|
@@ -57794,14 +57716,12 @@ function collectModelWindows(config, scope) {
|
|
|
57794
57716
|
else if (scope === "pi") for (const p2 of Object.values(config.pi?.providers ?? {})) add(p2.models);
|
|
57795
57717
|
else if (scope === "omp") for (const p2 of Object.values(config.omp?.providers ?? {})) add(p2.models);
|
|
57796
57718
|
else if (scope === "opencode") for (const p2 of Object.values(config.opencode?.providers ?? {})) add(p2.models);
|
|
57797
|
-
else if (scope === "codebuddy") add(config.codebuddy?.models);
|
|
57798
57719
|
return out;
|
|
57799
57720
|
}
|
|
57800
57721
|
for (const p2 of Object.values(config.pi?.providers ?? {})) add(p2.models);
|
|
57801
57722
|
for (const p2 of Object.values(config.omp?.providers ?? {})) add(p2.models);
|
|
57802
57723
|
for (const p2 of Object.values(config.opencode?.providers ?? {})) add(p2.models);
|
|
57803
57724
|
add(config.codex?.modelWindows);
|
|
57804
|
-
add(config.codebuddy?.models);
|
|
57805
57725
|
return out;
|
|
57806
57726
|
}
|
|
57807
57727
|
|
|
@@ -57839,9 +57759,9 @@ function extractHttpsHosts(config) {
|
|
|
57839
57759
|
if (config.zcode) {
|
|
57840
57760
|
for (const prov of Object.values(config.zcode.providers)) push(prov.baseURL);
|
|
57841
57761
|
}
|
|
57842
|
-
if (config.
|
|
57843
|
-
|
|
57844
|
-
for (const
|
|
57762
|
+
if (config.trae) {
|
|
57763
|
+
const hosts = nonEmpty2(config.trae.modelApiHost) ? [config.trae.modelApiHost] : TRAE_DEFAULT_MODEL_HOSTS;
|
|
57764
|
+
for (const h of hosts) push(`https://${h}`);
|
|
57845
57765
|
}
|
|
57846
57766
|
return out;
|
|
57847
57767
|
}
|
|
@@ -57849,16 +57769,13 @@ function configFilePaths(env) {
|
|
|
57849
57769
|
const home = os2.homedir();
|
|
57850
57770
|
const codexHome = nonEmpty2(env.CODEX_HOME) ? env.CODEX_HOME : path11.join(home, ".codex");
|
|
57851
57771
|
const zcodeHome = nonEmpty2(env.ZCODE_DATA_BASE_DIR) ? env.ZCODE_DATA_BASE_DIR : path11.join(home, ".zcode");
|
|
57852
|
-
const codebuddyHome = resolveCodebuddyHome(env);
|
|
57853
57772
|
return [
|
|
57854
57773
|
path11.join(home, ".claude", "settings.json"),
|
|
57855
57774
|
path11.join(process.cwd(), ".claude", "settings.json"),
|
|
57856
57775
|
path11.join(codexHome, "config.toml"),
|
|
57857
57776
|
path11.join(resolvePiHome(env), "models.json"),
|
|
57858
57777
|
path11.join(zcodeHome, "v2", "config.json"),
|
|
57859
|
-
path11.join(
|
|
57860
|
-
path11.join(codebuddyHome, "models.json"),
|
|
57861
|
-
path11.join(process.cwd(), ".codebuddy", "models.json")
|
|
57778
|
+
path11.join(resolveTraeHome(env), "traecli.yaml")
|
|
57862
57779
|
];
|
|
57863
57780
|
}
|
|
57864
57781
|
function readMtimes(paths) {
|
|
@@ -58904,7 +58821,7 @@ function logUnrecognizedPath(log2, url) {
|
|
|
58904
58821
|
const n = (unrecognizedPathCounts.get(key) ?? 0) + 1;
|
|
58905
58822
|
unrecognizedPathCounts.set(key, n);
|
|
58906
58823
|
if (n <= 3) {
|
|
58907
|
-
log2("warn", `unrecognized path ${key} \u2014 not a known protocol (/chat/completions, /v1/messages, /responses, /responses/compact); forwarding unchanged`);
|
|
58824
|
+
log2("warn", `unrecognized path ${key} \u2014 not a known protocol (/chat/completions, /llm_raw_chat, /v1/messages, /responses, /responses/compact); forwarding unchanged`);
|
|
58908
58825
|
} else if (n === 4) {
|
|
58909
58826
|
log2("info", `unrecognized path ${key}: forwarding unchanged; further occurrences suppressed`);
|
|
58910
58827
|
}
|
|
@@ -59457,7 +59374,7 @@ async function handle(req, res, opts, core, config, log2, instanceId, instanceSt
|
|
|
59457
59374
|
}
|
|
59458
59375
|
}
|
|
59459
59376
|
upstreamOrigin = route ? route.upstream : /^https?:\/\//i.test(url) ? new URL(url).origin : opts.upstream;
|
|
59460
|
-
protocol = route?.explicitProtocol ?? (req.method === "POST" && bodyBuffer.length > 0 ? urlPath.endsWith("/chat/completions") ? "openai" : urlPath.endsWith("/v1/messages") || urlPath.endsWith("/messages") ? "anthropic" : urlPath.endsWith("/responses") || responsesCompact ? "responses" : null : null);
|
|
59377
|
+
protocol = route?.explicitProtocol ?? (req.method === "POST" && bodyBuffer.length > 0 ? urlPath.endsWith("/chat/completions") || urlPath.endsWith("/llm_raw_chat") ? "openai" : urlPath.endsWith("/v1/messages") || urlPath.endsWith("/messages") ? "anthropic" : urlPath.endsWith("/responses") || responsesCompact ? "responses" : null : null);
|
|
59461
59378
|
if (protocol !== null && bodyBuffer.length > 0) {
|
|
59462
59379
|
try {
|
|
59463
59380
|
const decoded = await decodeRequestBody(headerValue2(req, "content-encoding"), bodyBuffer, MAX_REQUEST_BYTES);
|
|
@@ -60539,7 +60456,7 @@ function logUpstreamProxyDecision(opts, upstreamUrl, decision) {
|
|
|
60539
60456
|
}
|
|
60540
60457
|
function inferWireProtocol(path18) {
|
|
60541
60458
|
const p2 = path18.split("?", 2)[0];
|
|
60542
|
-
if (p2.endsWith("/chat/completions")) return "openai";
|
|
60459
|
+
if (p2.endsWith("/chat/completions") || p2.endsWith("/llm_raw_chat")) return "openai";
|
|
60543
60460
|
if (p2.endsWith("/responses") || p2.endsWith("/responses/compact")) return "responses";
|
|
60544
60461
|
return null;
|
|
60545
60462
|
}
|
|
@@ -65486,7 +65403,7 @@ function selfDistFile(name) {
|
|
|
65486
65403
|
return path15.join(selfPackageRoot(), "dist", name);
|
|
65487
65404
|
}
|
|
65488
65405
|
var LAUNCHER_DEFAULT_HOST = "127.0.0.1";
|
|
65489
|
-
var LAUNCH_CLIENTS = ["pi", "codex", "claude", "omp", "opencode", "hermes", "dsh", "
|
|
65406
|
+
var LAUNCH_CLIENTS = ["pi", "codex", "claude", "omp", "opencode", "hermes", "dsh", "trae", "pi-test"];
|
|
65490
65407
|
var HEALTH_PATH = "/__bili/health";
|
|
65491
65408
|
var HEALTH_POLL_INTERVAL_MS = 200;
|
|
65492
65409
|
var SPAWN_WAIT_MS = 2e4;
|
|
@@ -65574,29 +65491,6 @@ function discoverRoutes(client, config) {
|
|
|
65574
65491
|
}
|
|
65575
65492
|
} catch {
|
|
65576
65493
|
}
|
|
65577
|
-
} else if (client === "codebuddy") {
|
|
65578
|
-
const raw = nonEmpty2(config.codebuddy?.codebuddyBaseUrl) ? config.codebuddy.codebuddyBaseUrl : "https://tencent.sso.codebuddy.cn/v2";
|
|
65579
|
-
const real = unwrapUpstream2(raw);
|
|
65580
|
-
try {
|
|
65581
|
-
const url = new URL(real);
|
|
65582
|
-
if ((url.protocol === "https:" || url.protocol === "http:") && !rewriteKeys.has("CODEBUDDY_BASE_URL")) {
|
|
65583
|
-
rewriteKeys.add("CODEBUDDY_BASE_URL");
|
|
65584
|
-
httpRewrites.push({ key: "CODEBUDDY_BASE_URL", realUpstream: real });
|
|
65585
|
-
}
|
|
65586
|
-
} catch {
|
|
65587
|
-
}
|
|
65588
|
-
for (const rawModelUrl of config.codebuddy?.modelUrls ?? []) {
|
|
65589
|
-
try {
|
|
65590
|
-
const url = new URL(unwrapUpstream2(rawModelUrl));
|
|
65591
|
-
if (url.protocol !== "https:") continue;
|
|
65592
|
-
const host = url.hostname;
|
|
65593
|
-
if (host && !httpsSeen.has(host.toLowerCase())) {
|
|
65594
|
-
httpsSeen.add(host.toLowerCase());
|
|
65595
|
-
httpsDomains.push(host);
|
|
65596
|
-
}
|
|
65597
|
-
} catch {
|
|
65598
|
-
}
|
|
65599
|
-
}
|
|
65600
65494
|
} else if (client === "pi") {
|
|
65601
65495
|
for (const [name, prov] of Object.entries(config.pi?.providers ?? {})) {
|
|
65602
65496
|
classify(prov.baseUrl, name);
|
|
@@ -65658,6 +65552,15 @@ function discoverRoutes(client, config) {
|
|
|
65658
65552
|
} catch {
|
|
65659
65553
|
}
|
|
65660
65554
|
}
|
|
65555
|
+
} else if (client === "trae") {
|
|
65556
|
+
const hosts = nonEmpty2(config.trae?.modelApiHost) ? [config.trae.modelApiHost] : TRAE_DEFAULT_MODEL_HOSTS;
|
|
65557
|
+
for (const h of hosts) {
|
|
65558
|
+
const host = h.split(":", 2)[0].toLowerCase();
|
|
65559
|
+
if (host && !httpsSeen.has(host)) {
|
|
65560
|
+
httpsSeen.add(host);
|
|
65561
|
+
httpsDomains.push(host);
|
|
65562
|
+
}
|
|
65563
|
+
}
|
|
65661
65564
|
} else {
|
|
65662
65565
|
for (const [name, prov] of Object.entries(config.codex?.providers ?? {})) {
|
|
65663
65566
|
classify(prov.baseUrl, `model_providers.${name}.base_url`);
|
|
@@ -65690,6 +65593,9 @@ function buildPiEnv(origin, caPath, baseEnv, httpRewrites = [], httpsRewrites =
|
|
|
65690
65593
|
function buildCodexEnv(origin, caPath, baseEnv) {
|
|
65691
65594
|
return { ...baseEnv, HTTPS_PROXY: origin, SSL_CERT_FILE: caPath, BILLION_CONTEXT_PROXY: origin };
|
|
65692
65595
|
}
|
|
65596
|
+
function buildTraeEnv(origin, caPath, baseEnv) {
|
|
65597
|
+
return { ...baseEnv, HTTPS_PROXY: origin, SSL_CERT_FILE: caPath, BILLION_CONTEXT_PROXY: origin };
|
|
65598
|
+
}
|
|
65693
65599
|
function buildCodexArgs(origin, httpRewrites, httpsRewrites, extra) {
|
|
65694
65600
|
const args = [];
|
|
65695
65601
|
for (const r of httpRewrites) {
|
|
@@ -65740,21 +65646,6 @@ function buildClaudeEnv(origin, caPath, httpRewrites, httpsRewrites, baseEnv) {
|
|
|
65740
65646
|
if (hr2) env.ANTHROPIC_BASE_URL = hr2.realUpstream;
|
|
65741
65647
|
return env;
|
|
65742
65648
|
}
|
|
65743
|
-
async function resolveCodebuddyBudgetEnv(opts) {
|
|
65744
|
-
const { model, userAutoCompactWindow, shellAutoCompactWindow, routes, upstreamUrl } = opts;
|
|
65745
|
-
if (!model || userAutoCompactWindow !== void 0 || nonEmpty2(shellAutoCompactWindow)) return {};
|
|
65746
|
-
const window2 = await resolveLauncherWindow(model, routes, upstreamUrl);
|
|
65747
|
-
if (!window2) return {};
|
|
65748
|
-
return { CODEBUDDY_AUTO_COMPACT_WINDOW: String(window2) };
|
|
65749
|
-
}
|
|
65750
|
-
function buildCodebuddyEnv(origin, caPath, httpRewrites, httpsRewrites, baseEnv) {
|
|
65751
|
-
const env = { ...baseEnv, HTTPS_PROXY: origin, NODE_EXTRA_CA_CERTS: caPath, BILLION_CONTEXT_PROXY: origin };
|
|
65752
|
-
const r = httpRewrites.find((rw) => rw.key === "CODEBUDDY_BASE_URL");
|
|
65753
|
-
if (r) env.CODEBUDDY_BASE_URL = wrapUpstream(origin, r.realUpstream);
|
|
65754
|
-
const hr2 = httpsRewrites.find((rw) => rw.key === "CODEBUDDY_BASE_URL");
|
|
65755
|
-
if (hr2) env.CODEBUDDY_BASE_URL = hr2.realUpstream;
|
|
65756
|
-
return env;
|
|
65757
|
-
}
|
|
65758
65649
|
function launcherDirectUrl(env) {
|
|
65759
65650
|
return env.BILI_LAUNCHER_DIRECT === "1";
|
|
65760
65651
|
}
|
|
@@ -65795,7 +65686,7 @@ function isPrivateIPv4(host) {
|
|
|
65795
65686
|
return false;
|
|
65796
65687
|
}
|
|
65797
65688
|
function launcherInjectMcp(env, base, codexUpstream) {
|
|
65798
|
-
if (base === "pi" || base === "omp" || base === "opencode" || base === "hermes" || base === "dsh" || base === "
|
|
65689
|
+
if (base === "pi" || base === "omp" || base === "opencode" || base === "hermes" || base === "dsh" || base === "trae") return false;
|
|
65799
65690
|
if (env.BILI_LAUNCHER_PLUGIN === "0") return false;
|
|
65800
65691
|
if (base === "codex" && env.BILI_LAUNCHER_PLUGIN === void 0 && codexUpstream !== void 0 && isPrivateUpstreamHost(codexUpstream)) {
|
|
65801
65692
|
return false;
|
|
@@ -66618,9 +66509,9 @@ function resolveClientCommand(client, env) {
|
|
|
66618
66509
|
);
|
|
66619
66510
|
return { command: process.execPath, prefixArgs: [cli] };
|
|
66620
66511
|
}
|
|
66621
|
-
if (client === "
|
|
66622
|
-
const
|
|
66623
|
-
return { command:
|
|
66512
|
+
if (client === "trae") {
|
|
66513
|
+
const traeBin = resolveOnPath("traecli", env) ?? resolveOnPath("trae-cli", env) ?? resolveOnPath("trae", env);
|
|
66514
|
+
return { command: traeBin ?? "traecli", prefixArgs: [] };
|
|
66624
66515
|
}
|
|
66625
66516
|
const resolved = resolveOnPath(client, env);
|
|
66626
66517
|
return { command: resolved ?? client, prefixArgs: [] };
|
|
@@ -66757,6 +66648,8 @@ async function runLaunch(params, deps = {}) {
|
|
|
66757
66648
|
}
|
|
66758
66649
|
const dshAcpPatch = writeDshAcpPatch(dshHomeDir);
|
|
66759
66650
|
if (dshAcpPatch) clientArgs = dshArgsWithPatch(clientArgs, dshAcpPatch);
|
|
66651
|
+
} else if (base === "trae") {
|
|
66652
|
+
env = buildTraeEnv(origin, resolveCombinedCaPath(process.env), stripInheritedProxy(process.env));
|
|
66760
66653
|
} else if (base === "codex") {
|
|
66761
66654
|
const codexConversationId = injectMcp ? randomUUID5() : void 0;
|
|
66762
66655
|
if (directUrl) {
|
|
@@ -66787,19 +66680,6 @@ async function runLaunch(params, deps = {}) {
|
|
|
66787
66680
|
Object.assign(env, inj.envPatch);
|
|
66788
66681
|
if (inj.warning) console.error(`bili: ${inj.warning}`);
|
|
66789
66682
|
}
|
|
66790
|
-
} else if (base === "codebuddy") {
|
|
66791
|
-
env = buildCodebuddyEnv(origin, ca, routes.httpRewrites, routes.httpsRewrites, process.env);
|
|
66792
|
-
const codebuddyBudget = await resolveCodebuddyBudgetEnv({
|
|
66793
|
-
model: config.codebuddy?.model,
|
|
66794
|
-
userAutoCompactWindow: config.codebuddy?.autoCompactWindow,
|
|
66795
|
-
shellAutoCompactWindow: process.env.CODEBUDDY_AUTO_COMPACT_WINDOW,
|
|
66796
|
-
routes: biliRoutes,
|
|
66797
|
-
upstreamUrl: config.codebuddy?.codebuddyBaseUrl ?? "https://tencent.sso.codebuddy.cn/v2"
|
|
66798
|
-
});
|
|
66799
|
-
Object.assign(env, codebuddyBudget);
|
|
66800
|
-
if (codebuddyBudget.CODEBUDDY_AUTO_COMPACT_WINDOW !== void 0) {
|
|
66801
|
-
console.error(`bili: codebuddy budget aligned \u2014 CODEBUDDY_AUTO_COMPACT_WINDOW=${codebuddyBudget.CODEBUDDY_AUTO_COMPACT_WINDOW}`);
|
|
66802
|
-
}
|
|
66803
66683
|
} else {
|
|
66804
66684
|
env = directUrl ? buildClaudePluginEnv(origin, true, process.env) : buildClaudeEnv(origin, ca, routes.httpRewrites, routes.httpsRewrites, process.env);
|
|
66805
66685
|
if (directUrl) env.BILLION_CONTEXT_PROXY = origin;
|
|
@@ -67054,7 +66934,7 @@ Usage:
|
|
|
67054
66934
|
bili opencode [opts --] [args] start a proxy + launch opencode against it (cert-MITM)
|
|
67055
66935
|
bili hermes [opts --] [args] start a proxy + launch hermes-agent against it (/bili/ rewrite)
|
|
67056
66936
|
bili dsh [opts --] [args] start a proxy + launch deepseek-harness against it (/bili/ rewrite)
|
|
67057
|
-
bili
|
|
66937
|
+
bili trae [opts --] [args] start a proxy + launch Trae CLI against it (cert-MITM)
|
|
67058
66938
|
bili test pi non-polluting pi smoke test through the proxy
|
|
67059
66939
|
bili export [session] [--full] list sessions / export one as a Markdown handoff
|
|
67060
66940
|
(--full includes original messages; --output FILE)
|
|
@@ -67069,12 +66949,12 @@ Usage:
|
|
|
67069
66949
|
bili --version print version
|
|
67070
66950
|
bili --help show this help
|
|
67071
66951
|
|
|
67072
|
-
Launcher (bili pi / bili codex / bili claude / bili omp / bili opencode / bili hermes / bili dsh / bili
|
|
66952
|
+
Launcher (bili pi / bili codex / bili claude / bili omp / bili opencode / bili hermes / bili dsh / bili trae):
|
|
67073
66953
|
Brings up a proxy on an independent port (a fresh instance every launch), then runs the client pointed at it via HTTPS_PROXY + the proxy's
|
|
67074
66954
|
MITM CA \u2014 no config-file edits. Discovered HTTPS upstream domains are
|
|
67075
66955
|
auto-whitelisted for MITM so the proxy TLS-terminates exactly the hosts the
|
|
67076
|
-
|
|
67077
|
-
|
|
66956
|
+
client uses; HTTP / localhost providers go direct. pi/claude trust the CA
|
|
66957
|
+
via NODE_EXTRA_CA_CERTS, codex/trae via SSL_CERT_FILE. Proxy killed on client exit.
|
|
67078
66958
|
bili flags (-F, --mitm-domain, --port, ...) must precede the client name;
|
|
67079
66959
|
everything after the client name is passed through to the client.
|
|
67080
66960
|
bili pi # launch pi through the proxy
|
|
@@ -67084,9 +66964,9 @@ Launcher (bili pi / bili codex / bili claude / bili omp / bili opencode / bili h
|
|
|
67084
66964
|
bili claude # launch claude through the proxy
|
|
67085
66965
|
bili omp # launch omp through the proxy (pi-based; /bili/ rewrite)
|
|
67086
66966
|
bili hermes # launch hermes-agent through the proxy (/bili/ rewrite of ~/.hermes/config.yaml)
|
|
67087
|
-
|
|
67088
|
-
|
|
67089
|
-
|
|
66967
|
+
bili dsh --profile web "task" # launch deepseek-harness through the proxy (/bili/ rewrite of ~/.dsh/settings.yaml)
|
|
66968
|
+
bili trae # launch Trae CLI through the proxy (cert-MITM; model host via TRAE_CLI_API_HOST or --mitm-domain)
|
|
66969
|
+
bili test pi # quick end-to-end check of the pi path
|
|
67090
66970
|
bili --mitm-domain api.foo.com pi # add a domain to the MITM whitelist (flags precede the client)
|
|
67091
66971
|
bili -F http://127.0.0.1:7897 codex # route bili's upstream through a proxy (gost-style -F)
|
|
67092
66972
|
|