billion-context 0.1.95-pr.641.461 → 0.1.95-pr.643.462

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 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 codebuddy`)
161
+ ### Option 1 — Launcher (`bili pi` / `bili codex` / `bili claude` / `bili omp` / `bili opencode` / `bili hermes` / `bili dsh`)
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,6 @@ 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 codebuddy # Tencent CodeBuddy Code CLI: CODEBUDDY_BASE_URL /bili/ rewrite (Anthropic protocol), budget aligned via CODEBUDDY_AUTO_COMPACT_WINDOW; real ~/.codebuddy untouched
181
180
  bili pi --mitm-domain api.foo.com # add a domain to the MITM whitelist
182
181
  ```
183
182
 
package/dist/index.js CHANGED
@@ -56835,98 +56835,6 @@ function resolveDshHome(env) {
56835
56835
  const h = os.homedir();
56836
56836
  return nonEmpty2(env.DSH_HOME) ? env.DSH_HOME : path10.join(h, ".dsh");
56837
56837
  }
56838
- function resolveCodebuddyHome(env) {
56839
- const h = os.homedir();
56840
- return nonEmpty2(env.CODEBUDDY_CONFIG_DIR) ? env.CODEBUDDY_CONFIG_DIR : path10.join(h, ".codebuddy");
56841
- }
56842
- function parseCodebuddyModelsJson(obj) {
56843
- const out = { models: [], urls: [] };
56844
- const seenUrl = /* @__PURE__ */ new Set();
56845
- const collect = (id, entry) => {
56846
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) return;
56847
- const e = entry;
56848
- const url = e.url;
56849
- if (typeof url === "string" && url.length > 0 && !seenUrl.has(url)) {
56850
- seenUrl.add(url);
56851
- out.urls.push(url);
56852
- }
56853
- const win = toModelWindow(id, e.maxInputTokens);
56854
- if (win) out.models.push(win);
56855
- };
56856
- if (!obj) return out;
56857
- if (Array.isArray(obj)) {
56858
- for (const item of obj) {
56859
- if (!item || typeof item !== "object" || Array.isArray(item)) continue;
56860
- const it2 = item;
56861
- collect(it2.id ?? it2.name, it2);
56862
- }
56863
- return out;
56864
- }
56865
- if (typeof obj !== "object") return out;
56866
- const root = obj;
56867
- const modelsField = root.models;
56868
- if (Array.isArray(modelsField)) {
56869
- for (const item of modelsField) {
56870
- if (!item || typeof item !== "object" || Array.isArray(item)) continue;
56871
- const it2 = item;
56872
- collect(it2.id ?? it2.name, it2);
56873
- }
56874
- return out;
56875
- }
56876
- if (modelsField && typeof modelsField === "object") {
56877
- for (const [id, val] of Object.entries(modelsField)) collect(id, val);
56878
- return out;
56879
- }
56880
- for (const [id, val] of Object.entries(root)) collect(id, val);
56881
- return out;
56882
- }
56883
- function readJsonFile(filePath) {
56884
- try {
56885
- return JSON.parse(fs6.readFileSync(filePath, "utf8"));
56886
- } catch {
56887
- return null;
56888
- }
56889
- }
56890
- function readCodebuddyConfig(codebuddyHome, cwd, env = process.env) {
56891
- let codebuddyBaseUrl;
56892
- let model;
56893
- let autoCompactWindow;
56894
- const settings = readJsonObject(path10.join(codebuddyHome, "settings.json"));
56895
- const settingsEnv = settings?.env;
56896
- if (settingsEnv && typeof settingsEnv === "object" && !Array.isArray(settingsEnv)) {
56897
- const e = settingsEnv;
56898
- const v2 = e.CODEBUDDY_BASE_URL;
56899
- if (nonEmpty2(v2)) codebuddyBaseUrl = v2;
56900
- }
56901
- const tm = settings?.model;
56902
- if (nonEmpty2(tm)) model = String(tm);
56903
- const tacw = Number(settings?.autoCompactWindow);
56904
- if (Number.isFinite(tacw) && tacw > 0) autoCompactWindow = tacw;
56905
- if (!codebuddyBaseUrl && nonEmpty2(env.CODEBUDDY_BASE_URL)) codebuddyBaseUrl = env.CODEBUDDY_BASE_URL;
56906
- const windowByModel = /* @__PURE__ */ new Map();
56907
- const urls = [];
56908
- const seenUrl = /* @__PURE__ */ new Set();
56909
- for (const f2 of [
56910
- path10.join(codebuddyHome, "models.json"),
56911
- path10.join(cwd, ".codebuddy", "models.json")
56912
- ]) {
56913
- const parsed = parseCodebuddyModelsJson(readJsonFile(f2));
56914
- for (const w2 of parsed.models) windowByModel.set(w2.id, w2.contextWindow);
56915
- for (const u2 of parsed.urls) {
56916
- if (!seenUrl.has(u2)) {
56917
- seenUrl.add(u2);
56918
- urls.push(u2);
56919
- }
56920
- }
56921
- }
56922
- return {
56923
- ...codebuddyBaseUrl ? { codebuddyBaseUrl } : {},
56924
- ...model ? { model } : {},
56925
- ...autoCompactWindow ? { autoCompactWindow } : {},
56926
- ...windowByModel.size > 0 ? { models: [...windowByModel.entries()].map(([id, contextWindow]) => ({ id, contextWindow })) } : {},
56927
- ...urls.length > 0 ? { modelUrls: urls } : {}
56928
- };
56929
- }
56930
56838
  function parseDshSettingsYaml(text) {
56931
56839
  const out = [];
56932
56840
  const seen = /* @__PURE__ */ new Set();
@@ -57300,7 +57208,6 @@ function loadClientConfig(env, cwd) {
57300
57208
  config.opencode = readOpencodeConfig(resolveOpencodeConfigFile(env));
57301
57209
  config.hermes = readHermesConfig(resolveHermesHome(env));
57302
57210
  config.dsh = readDshConfig(resolveDshHome(env));
57303
- config.codebuddy = readCodebuddyConfig(resolveCodebuddyHome(env), cwd, env);
57304
57211
  return config;
57305
57212
  }
57306
57213
  function collectModelWindows(config, scope) {
@@ -57315,14 +57222,12 @@ function collectModelWindows(config, scope) {
57315
57222
  else if (scope === "pi") for (const p2 of Object.values(config.pi?.providers ?? {})) add(p2.models);
57316
57223
  else if (scope === "omp") for (const p2 of Object.values(config.omp?.providers ?? {})) add(p2.models);
57317
57224
  else if (scope === "opencode") for (const p2 of Object.values(config.opencode?.providers ?? {})) add(p2.models);
57318
- else if (scope === "codebuddy") add(config.codebuddy?.models);
57319
57225
  return out;
57320
57226
  }
57321
57227
  for (const p2 of Object.values(config.pi?.providers ?? {})) add(p2.models);
57322
57228
  for (const p2 of Object.values(config.omp?.providers ?? {})) add(p2.models);
57323
57229
  for (const p2 of Object.values(config.opencode?.providers ?? {})) add(p2.models);
57324
57230
  add(config.codex?.modelWindows);
57325
- add(config.codebuddy?.models);
57326
57231
  return out;
57327
57232
  }
57328
57233
 
@@ -57360,26 +57265,18 @@ function extractHttpsHosts(config) {
57360
57265
  if (config.zcode) {
57361
57266
  for (const prov of Object.values(config.zcode.providers)) push(prov.baseURL);
57362
57267
  }
57363
- if (config.codebuddy) {
57364
- push(config.codebuddy.codebuddyBaseUrl);
57365
- for (const u2 of config.codebuddy.modelUrls ?? []) push(u2);
57366
- }
57367
57268
  return out;
57368
57269
  }
57369
57270
  function configFilePaths(env) {
57370
57271
  const home = os2.homedir();
57371
57272
  const codexHome = nonEmpty2(env.CODEX_HOME) ? env.CODEX_HOME : path11.join(home, ".codex");
57372
57273
  const zcodeHome = nonEmpty2(env.ZCODE_DATA_BASE_DIR) ? env.ZCODE_DATA_BASE_DIR : path11.join(home, ".zcode");
57373
- const codebuddyHome = resolveCodebuddyHome(env);
57374
57274
  return [
57375
57275
  path11.join(home, ".claude", "settings.json"),
57376
57276
  path11.join(process.cwd(), ".claude", "settings.json"),
57377
57277
  path11.join(codexHome, "config.toml"),
57378
57278
  path11.join(resolvePiHome(env), "models.json"),
57379
- path11.join(zcodeHome, "v2", "config.json"),
57380
- path11.join(codebuddyHome, "settings.json"),
57381
- path11.join(codebuddyHome, "models.json"),
57382
- path11.join(process.cwd(), ".codebuddy", "models.json")
57279
+ path11.join(zcodeHome, "v2", "config.json")
57383
57280
  ];
57384
57281
  }
57385
57282
  function readMtimes(paths) {
@@ -64905,7 +64802,7 @@ function selfDistFile(name) {
64905
64802
  return path15.join(selfPackageRoot(), "dist", name);
64906
64803
  }
64907
64804
  var LAUNCHER_DEFAULT_HOST = "127.0.0.1";
64908
- var LAUNCH_CLIENTS = ["pi", "codex", "claude", "omp", "opencode", "hermes", "dsh", "codebuddy", "pi-test"];
64805
+ var LAUNCH_CLIENTS = ["pi", "codex", "claude", "omp", "opencode", "hermes", "dsh", "pi-test"];
64909
64806
  var HEALTH_PATH = "/__bili/health";
64910
64807
  var HEALTH_POLL_INTERVAL_MS = 200;
64911
64808
  var SPAWN_WAIT_MS = 2e4;
@@ -64993,29 +64890,6 @@ function discoverRoutes(client, config) {
64993
64890
  }
64994
64891
  } catch {
64995
64892
  }
64996
- } else if (client === "codebuddy") {
64997
- const raw = nonEmpty2(config.codebuddy?.codebuddyBaseUrl) ? config.codebuddy.codebuddyBaseUrl : "https://tencent.sso.codebuddy.cn/v2";
64998
- const real = unwrapUpstream2(raw);
64999
- try {
65000
- const url = new URL(real);
65001
- if ((url.protocol === "https:" || url.protocol === "http:") && !rewriteKeys.has("CODEBUDDY_BASE_URL")) {
65002
- rewriteKeys.add("CODEBUDDY_BASE_URL");
65003
- httpRewrites.push({ key: "CODEBUDDY_BASE_URL", realUpstream: real });
65004
- }
65005
- } catch {
65006
- }
65007
- for (const rawModelUrl of config.codebuddy?.modelUrls ?? []) {
65008
- try {
65009
- const url = new URL(unwrapUpstream2(rawModelUrl));
65010
- if (url.protocol !== "https:") continue;
65011
- const host = url.hostname;
65012
- if (host && !httpsSeen.has(host.toLowerCase())) {
65013
- httpsSeen.add(host.toLowerCase());
65014
- httpsDomains.push(host);
65015
- }
65016
- } catch {
65017
- }
65018
- }
65019
64893
  } else if (client === "pi") {
65020
64894
  for (const [name, prov] of Object.entries(config.pi?.providers ?? {})) {
65021
64895
  classify(prov.baseUrl, name);
@@ -65159,21 +65033,6 @@ function buildClaudeEnv(origin, caPath, httpRewrites, httpsRewrites, baseEnv) {
65159
65033
  if (hr2) env.ANTHROPIC_BASE_URL = hr2.realUpstream;
65160
65034
  return env;
65161
65035
  }
65162
- async function resolveCodebuddyBudgetEnv(opts) {
65163
- const { model, userAutoCompactWindow, shellAutoCompactWindow, routes, upstreamUrl } = opts;
65164
- if (!model || userAutoCompactWindow !== void 0 || nonEmpty2(shellAutoCompactWindow)) return {};
65165
- const window2 = await resolveLauncherWindow(model, routes, upstreamUrl);
65166
- if (!window2) return {};
65167
- return { CODEBUDDY_AUTO_COMPACT_WINDOW: String(window2) };
65168
- }
65169
- function buildCodebuddyEnv(origin, caPath, httpRewrites, httpsRewrites, baseEnv) {
65170
- const env = { ...baseEnv, HTTPS_PROXY: origin, NODE_EXTRA_CA_CERTS: caPath, BILLION_CONTEXT_PROXY: origin };
65171
- const r = httpRewrites.find((rw) => rw.key === "CODEBUDDY_BASE_URL");
65172
- if (r) env.CODEBUDDY_BASE_URL = wrapUpstream(origin, r.realUpstream);
65173
- const hr2 = httpsRewrites.find((rw) => rw.key === "CODEBUDDY_BASE_URL");
65174
- if (hr2) env.CODEBUDDY_BASE_URL = hr2.realUpstream;
65175
- return env;
65176
- }
65177
65036
  function launcherDirectUrl(env) {
65178
65037
  return env.BILI_LAUNCHER_DIRECT === "1";
65179
65038
  }
@@ -65214,7 +65073,7 @@ function isPrivateIPv4(host) {
65214
65073
  return false;
65215
65074
  }
65216
65075
  function launcherInjectMcp(env, base, codexUpstream) {
65217
- if (base === "pi" || base === "omp" || base === "opencode" || base === "hermes" || base === "dsh" || base === "codebuddy") return false;
65076
+ if (base === "pi" || base === "omp" || base === "opencode" || base === "hermes" || base === "dsh") return false;
65218
65077
  if (env.BILI_LAUNCHER_PLUGIN === "0") return false;
65219
65078
  if (base === "codex" && env.BILI_LAUNCHER_PLUGIN === void 0 && codexUpstream !== void 0 && isPrivateUpstreamHost(codexUpstream)) {
65220
65079
  return false;
@@ -65969,10 +65828,6 @@ function resolveClientCommand(client, env) {
65969
65828
  );
65970
65829
  return { command: process.execPath, prefixArgs: [cli] };
65971
65830
  }
65972
- if (client === "codebuddy") {
65973
- const resolved2 = resolveOnPath("codebuddy", env) ?? resolveOnPath("cbc", env);
65974
- return { command: resolved2 ?? "codebuddy", prefixArgs: [] };
65975
- }
65976
65831
  const resolved = resolveOnPath(client, env);
65977
65832
  return { command: resolved ?? client, prefixArgs: [] };
65978
65833
  }
@@ -66129,19 +65984,6 @@ async function runLaunch(params, deps = {}) {
66129
65984
  }
66130
65985
  if (injectMcp && codexConversationId) clientArgs = [...buildCodexMcpArgs(origin, codexConversationId), ...clientArgs];
66131
65986
  }
66132
- } else if (base === "codebuddy") {
66133
- env = buildCodebuddyEnv(origin, ca, routes.httpRewrites, routes.httpsRewrites, process.env);
66134
- const codebuddyBudget = await resolveCodebuddyBudgetEnv({
66135
- model: config.codebuddy?.model,
66136
- userAutoCompactWindow: config.codebuddy?.autoCompactWindow,
66137
- shellAutoCompactWindow: process.env.CODEBUDDY_AUTO_COMPACT_WINDOW,
66138
- routes: biliRoutes,
66139
- upstreamUrl: config.codebuddy?.codebuddyBaseUrl ?? "https://tencent.sso.codebuddy.cn/v2"
66140
- });
66141
- Object.assign(env, codebuddyBudget);
66142
- if (codebuddyBudget.CODEBUDDY_AUTO_COMPACT_WINDOW !== void 0) {
66143
- console.error(`bili: codebuddy budget aligned \u2014 CODEBUDDY_AUTO_COMPACT_WINDOW=${codebuddyBudget.CODEBUDDY_AUTO_COMPACT_WINDOW}`);
66144
- }
66145
65987
  } else {
66146
65988
  env = directUrl ? buildClaudePluginEnv(origin, true, process.env) : buildClaudeEnv(origin, ca, routes.httpRewrites, routes.httpsRewrites, process.env);
66147
65989
  if (directUrl) env.BILLION_CONTEXT_PROXY = origin;
@@ -66396,7 +66238,6 @@ Usage:
66396
66238
  bili opencode [opts --] [args] start a proxy + launch opencode against it (cert-MITM)
66397
66239
  bili hermes [opts --] [args] start a proxy + launch hermes-agent against it (/bili/ rewrite)
66398
66240
  bili dsh [opts --] [args] start a proxy + launch deepseek-harness against it (/bili/ rewrite)
66399
- bili codebuddy [opts --] [args] start a proxy + launch codebuddy against it (/bili/ rewrite)
66400
66241
  bili test pi non-polluting pi smoke test through the proxy
66401
66242
  bili export [session] [--full] list sessions / export one as a Markdown handoff
66402
66243
  (--full includes original messages; --output FILE)
@@ -66411,7 +66252,7 @@ Usage:
66411
66252
  bili --version print version
66412
66253
  bili --help show this help
66413
66254
 
66414
- Launcher (bili pi / bili codex / bili claude / bili omp / bili opencode / bili hermes / bili dsh / bili codebuddy):
66255
+ Launcher (bili pi / bili codex / bili claude / bili omp / bili opencode / bili hermes / bili dsh):
66415
66256
  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
66416
66257
  MITM CA \u2014 no config-file edits. Discovered HTTPS upstream domains are
66417
66258
  auto-whitelisted for MITM so the proxy TLS-terminates exactly the hosts the
@@ -66427,7 +66268,6 @@ Launcher (bili pi / bili codex / bili claude / bili omp / bili opencode / bili h
66427
66268
  bili omp # launch omp through the proxy (pi-based; /bili/ rewrite)
66428
66269
  bili hermes # launch hermes-agent through the proxy (/bili/ rewrite of ~/.hermes/config.yaml)
66429
66270
  bili dsh --profile web "task" # launch deepseek-harness through the proxy (/bili/ rewrite of ~/.dsh/settings.yaml)
66430
- bili codebuddy # launch codebuddy through the proxy (CODEBUDDY_BASE_URL /bili/ rewrite)
66431
66271
  bili test pi # quick end-to-end check of the pi path
66432
66272
  bili --mitm-domain api.foo.com pi # add a domain to the MITM whitelist (flags precede the client)
66433
66273
  bili -F http://127.0.0.1:7897 codex # route bili's upstream through a proxy (gost-style -F)