billion-context 0.1.50-pr.230.70 → 0.1.50
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 +3 -3
- package/dist/index.js +67 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,9 +132,9 @@ bili pi -- print "hi" # args after the client are passed through
|
|
|
132
132
|
bili pi-test # clean pi (extensions off) — proxy owns compression, no double-compress
|
|
133
133
|
bili codex # launch codex through the proxy
|
|
134
134
|
bili claude # launch claude through the proxy
|
|
135
|
-
bili omp # pi-style: MITM env +
|
|
135
|
+
bili omp # pi-style: MITM env + isolated temp models.yml
|
|
136
136
|
bili opencode # MITM for HTTPS + temp opencode.json (/bili/ for HTTP) + thin /acp plugin
|
|
137
|
-
bili hermes # no MITM possible (certifi CA) —
|
|
137
|
+
bili hermes # no MITM possible (certifi CA) — isolated HERMES_HOME, all traffic /bili/
|
|
138
138
|
bili test pi # quick end-to-end smoke test of the pi path
|
|
139
139
|
bili pi --mitm-domain api.foo.com # add a domain to the MITM whitelist
|
|
140
140
|
```
|
|
@@ -177,7 +177,7 @@ How the client is pointed at the proxy (set automatically in the child env):
|
|
|
177
177
|
| codex | `HTTPS_PROXY` | `SSL_CERT_FILE` |
|
|
178
178
|
| omp | `HTTPS_PROXY` | `NODE_EXTRA_CA_CERTS` |
|
|
179
179
|
| opencode | `HTTPS_PROXY` | `NODE_EXTRA_CA_CERTS` |
|
|
180
|
-
| hermes | `HERMES_HOME` (
|
|
180
|
+
| hermes | `HERMES_HOME` (temp `config.yaml`, every upstream `/bili/`) | — (no MITM: httpx builds its own CA bundle) |
|
|
181
181
|
|
|
182
182
|
`NODE_EXTRA_CA_CERTS` *appends* to the built-in trust store, so it points at
|
|
183
183
|
the MITM root alone (`root-ca.pem`). `SSL_CERT_FILE` *replaces* the default
|
package/dist/index.js
CHANGED
|
@@ -58926,92 +58926,6 @@ function buildCodexMcpArgs(origin, conversationId2) {
|
|
|
58926
58926
|
`mcp_servers.bili.env.BILI_CONVERSATION_ID=${JSON.stringify(conversationId2)}`
|
|
58927
58927
|
];
|
|
58928
58928
|
}
|
|
58929
|
-
function refreshOverlayHome(realHome, overlay, generatedFile) {
|
|
58930
|
-
try {
|
|
58931
|
-
fs10.mkdirSync(overlay, { recursive: true });
|
|
58932
|
-
} catch {
|
|
58933
|
-
return false;
|
|
58934
|
-
}
|
|
58935
|
-
const realEntries = /* @__PURE__ */ new Set();
|
|
58936
|
-
try {
|
|
58937
|
-
for (const entry of fs10.readdirSync(realHome)) realEntries.add(entry);
|
|
58938
|
-
} catch {
|
|
58939
|
-
}
|
|
58940
|
-
try {
|
|
58941
|
-
for (const entry of fs10.readdirSync(overlay)) {
|
|
58942
|
-
if (entry === generatedFile) continue;
|
|
58943
|
-
const overlayPath = path13.join(overlay, entry);
|
|
58944
|
-
if (entry.startsWith(`.${generatedFile}.`) && entry.endsWith(".tmp")) {
|
|
58945
|
-
try {
|
|
58946
|
-
fs10.unlinkSync(overlayPath);
|
|
58947
|
-
} catch {
|
|
58948
|
-
}
|
|
58949
|
-
continue;
|
|
58950
|
-
}
|
|
58951
|
-
let st2;
|
|
58952
|
-
try {
|
|
58953
|
-
st2 = fs10.lstatSync(overlayPath);
|
|
58954
|
-
} catch {
|
|
58955
|
-
continue;
|
|
58956
|
-
}
|
|
58957
|
-
if (st2.isSymbolicLink()) {
|
|
58958
|
-
let target;
|
|
58959
|
-
try {
|
|
58960
|
-
target = fs10.readlinkSync(overlayPath);
|
|
58961
|
-
} catch {
|
|
58962
|
-
}
|
|
58963
|
-
const wanted = realEntries.has(entry) ? path13.join(realHome, entry) : void 0;
|
|
58964
|
-
if (!wanted || target !== wanted) {
|
|
58965
|
-
try {
|
|
58966
|
-
fs10.unlinkSync(overlayPath);
|
|
58967
|
-
} catch {
|
|
58968
|
-
}
|
|
58969
|
-
}
|
|
58970
|
-
} else if (realEntries.has(entry)) {
|
|
58971
|
-
if (st2.isDirectory()) mergeOverlayDir(overlayPath, path13.join(realHome, entry));
|
|
58972
|
-
try {
|
|
58973
|
-
fs10.rmSync(overlayPath, { recursive: true, force: true });
|
|
58974
|
-
} catch {
|
|
58975
|
-
}
|
|
58976
|
-
}
|
|
58977
|
-
}
|
|
58978
|
-
for (const entry of realEntries) {
|
|
58979
|
-
if (entry === generatedFile) continue;
|
|
58980
|
-
try {
|
|
58981
|
-
fs10.symlinkSync(path13.join(realHome, entry), path13.join(overlay, entry));
|
|
58982
|
-
} catch {
|
|
58983
|
-
}
|
|
58984
|
-
}
|
|
58985
|
-
} catch {
|
|
58986
|
-
}
|
|
58987
|
-
return true;
|
|
58988
|
-
}
|
|
58989
|
-
function mergeOverlayDir(fromDir, toDir) {
|
|
58990
|
-
try {
|
|
58991
|
-
fs10.mkdirSync(toDir, { recursive: true });
|
|
58992
|
-
for (const child of fs10.readdirSync(fromDir)) {
|
|
58993
|
-
const dst = path13.join(toDir, child);
|
|
58994
|
-
if (fs10.existsSync(dst)) continue;
|
|
58995
|
-
try {
|
|
58996
|
-
fs10.renameSync(path13.join(fromDir, child), dst);
|
|
58997
|
-
} catch {
|
|
58998
|
-
}
|
|
58999
|
-
}
|
|
59000
|
-
} catch {
|
|
59001
|
-
}
|
|
59002
|
-
}
|
|
59003
|
-
function writeOverlayFileAtomic(overlay, fileName, contents) {
|
|
59004
|
-
const draft = path13.join(overlay, `.${fileName}.${process.pid}.tmp`);
|
|
59005
|
-
try {
|
|
59006
|
-
fs10.writeFileSync(draft, contents);
|
|
59007
|
-
fs10.renameSync(draft, path13.join(overlay, fileName));
|
|
59008
|
-
} catch {
|
|
59009
|
-
try {
|
|
59010
|
-
fs10.rmSync(draft, { force: true });
|
|
59011
|
-
} catch {
|
|
59012
|
-
}
|
|
59013
|
-
}
|
|
59014
|
-
}
|
|
59015
58929
|
function preparePiHttpRewrite(piHome, origin, httpRewrites, httpsRewrites) {
|
|
59016
58930
|
if (httpRewrites.length === 0 && httpsRewrites.length === 0) return void 0;
|
|
59017
58931
|
const modelsPath = path13.join(piHome, "models.json");
|
|
@@ -59048,10 +58962,19 @@ function preparePiHttpRewrite(piHome, origin, httpRewrites, httpsRewrites) {
|
|
|
59048
58962
|
}
|
|
59049
58963
|
}
|
|
59050
58964
|
}
|
|
59051
|
-
const
|
|
59052
|
-
|
|
59053
|
-
|
|
59054
|
-
|
|
58965
|
+
const tmp = fs10.mkdtempSync(path13.join(os5.tmpdir(), "bili-pi-"));
|
|
58966
|
+
try {
|
|
58967
|
+
for (const entry of fs10.readdirSync(piHome)) {
|
|
58968
|
+
if (entry === "models.json") continue;
|
|
58969
|
+
try {
|
|
58970
|
+
fs10.symlinkSync(path13.join(piHome, entry), path13.join(tmp, entry));
|
|
58971
|
+
} catch {
|
|
58972
|
+
}
|
|
58973
|
+
}
|
|
58974
|
+
} catch {
|
|
58975
|
+
}
|
|
58976
|
+
fs10.writeFileSync(path13.join(tmp, "models.json"), JSON.stringify(root));
|
|
58977
|
+
return tmp;
|
|
59055
58978
|
}
|
|
59056
58979
|
function prepareOmpHttpRewrite(ompHome, origin, httpRewrites, httpsRewrites) {
|
|
59057
58980
|
if (httpRewrites.length === 0 && httpsRewrites.length === 0) return void 0;
|
|
@@ -59095,10 +59018,19 @@ function prepareOmpHttpRewrite(ompHome, origin, httpRewrites, httpsRewrites) {
|
|
|
59095
59018
|
}
|
|
59096
59019
|
}
|
|
59097
59020
|
}
|
|
59098
|
-
const
|
|
59099
|
-
|
|
59100
|
-
|
|
59101
|
-
|
|
59021
|
+
const tmp = fs10.mkdtempSync(path13.join(os5.tmpdir(), "bili-omp-"));
|
|
59022
|
+
try {
|
|
59023
|
+
for (const entry of fs10.readdirSync(ompHome)) {
|
|
59024
|
+
if (entry === "models.yml") continue;
|
|
59025
|
+
try {
|
|
59026
|
+
fs10.symlinkSync(path13.join(ompHome, entry), path13.join(tmp, entry));
|
|
59027
|
+
} catch {
|
|
59028
|
+
}
|
|
59029
|
+
}
|
|
59030
|
+
} catch {
|
|
59031
|
+
}
|
|
59032
|
+
fs10.writeFileSync(path13.join(tmp, "models.yml"), lines.join("\n"));
|
|
59033
|
+
return tmp;
|
|
59102
59034
|
}
|
|
59103
59035
|
function prepareHermesHome(hermesHome, origin, rewrites) {
|
|
59104
59036
|
if (rewrites.length === 0) return void 0;
|
|
@@ -59125,10 +59057,19 @@ function prepareHermesHome(hermesHome, origin, rewrites) {
|
|
|
59125
59057
|
changed = true;
|
|
59126
59058
|
}
|
|
59127
59059
|
if (!changed) return void 0;
|
|
59128
|
-
const
|
|
59129
|
-
|
|
59130
|
-
|
|
59131
|
-
|
|
59060
|
+
const tmp = fs10.mkdtempSync(path13.join(os5.tmpdir(), "bili-hermes-"));
|
|
59061
|
+
try {
|
|
59062
|
+
for (const entry of fs10.readdirSync(hermesHome)) {
|
|
59063
|
+
if (entry === "config.yaml") continue;
|
|
59064
|
+
try {
|
|
59065
|
+
fs10.symlinkSync(path13.join(hermesHome, entry), path13.join(tmp, entry));
|
|
59066
|
+
} catch {
|
|
59067
|
+
}
|
|
59068
|
+
}
|
|
59069
|
+
} catch {
|
|
59070
|
+
}
|
|
59071
|
+
fs10.writeFileSync(path13.join(tmp, "config.yaml"), lines.join(eol));
|
|
59072
|
+
return tmp;
|
|
59132
59073
|
}
|
|
59133
59074
|
function prepareOpencodeHttpRewrite(configFile2, origin, httpRewrites, httpsRewrites, pluginPath) {
|
|
59134
59075
|
if (httpRewrites.length === 0 && httpsRewrites.length === 0 && !pluginPath) return void 0;
|
|
@@ -59365,10 +59306,10 @@ async function runLaunch(params, deps = {}) {
|
|
|
59365
59306
|
const ca = resolveCaCertPath(process.env);
|
|
59366
59307
|
let env;
|
|
59367
59308
|
let clientArgs = params.clientArgs;
|
|
59368
|
-
let
|
|
59369
|
-
let
|
|
59309
|
+
let piTmpHome;
|
|
59310
|
+
let ompTmpHome;
|
|
59370
59311
|
let opencodeTmpFile;
|
|
59371
|
-
let
|
|
59312
|
+
let hermesTmpHome;
|
|
59372
59313
|
const tmpFiles = [];
|
|
59373
59314
|
const directUrl = launcherDirectUrl(process.env);
|
|
59374
59315
|
if (directUrl) {
|
|
@@ -59389,12 +59330,12 @@ async function runLaunch(params, deps = {}) {
|
|
|
59389
59330
|
const origin = handle2.origin;
|
|
59390
59331
|
if (base === "pi") {
|
|
59391
59332
|
env = buildPiEnv(origin, ca, process.env);
|
|
59392
|
-
|
|
59393
|
-
if (
|
|
59333
|
+
piTmpHome = preparePiHttpRewrite(resolvePiHome(process.env), origin, routes.httpRewrites, routes.httpsRewrites);
|
|
59334
|
+
if (piTmpHome) env.PI_CODING_AGENT_DIR = piTmpHome;
|
|
59394
59335
|
} else if (base === "omp") {
|
|
59395
59336
|
env = buildPiEnv(origin, ca, process.env);
|
|
59396
|
-
|
|
59397
|
-
if (
|
|
59337
|
+
ompTmpHome = prepareOmpHttpRewrite(resolveOmpHome(process.env), origin, routes.httpRewrites, routes.httpsRewrites);
|
|
59338
|
+
if (ompTmpHome) env.PI_CODING_AGENT_DIR = ompTmpHome;
|
|
59398
59339
|
} else if (base === "opencode") {
|
|
59399
59340
|
env = { ...process.env, HTTPS_PROXY: origin, NODE_EXTRA_CA_CERTS: ca, BILLION_CONTEXT_PROXY: origin };
|
|
59400
59341
|
const opencodePlugin = selfDistFile("agent/opencode.js");
|
|
@@ -59403,9 +59344,9 @@ async function runLaunch(params, deps = {}) {
|
|
|
59403
59344
|
if (opencodeTmpFile) env.OPENCODE_CONFIG = opencodeTmpFile;
|
|
59404
59345
|
} else if (base === "hermes") {
|
|
59405
59346
|
env = { ...process.env };
|
|
59406
|
-
|
|
59407
|
-
if (
|
|
59408
|
-
env.HERMES_HOME =
|
|
59347
|
+
hermesTmpHome = prepareHermesHome(resolveHermesHome(process.env), origin, routes.httpRewrites);
|
|
59348
|
+
if (hermesTmpHome) {
|
|
59349
|
+
env.HERMES_HOME = hermesTmpHome;
|
|
59409
59350
|
} else {
|
|
59410
59351
|
console.error(
|
|
59411
59352
|
routes.httpRewrites.length === 0 ? "bili: no hermes providers found in ~/.hermes/config.yaml \u2014 traffic will NOT go through the proxy (configure a provider first)." : "bili: hermes config.yaml could not be rewritten (unreadable or no matching provider endpoints) \u2014 traffic will NOT go through the proxy."
|
|
@@ -59443,6 +59384,24 @@ async function runLaunch(params, deps = {}) {
|
|
|
59443
59384
|
code = 1;
|
|
59444
59385
|
} finally {
|
|
59445
59386
|
stopProxy(handle2);
|
|
59387
|
+
if (piTmpHome) {
|
|
59388
|
+
try {
|
|
59389
|
+
fs10.rmSync(piTmpHome, { recursive: true, force: true });
|
|
59390
|
+
} catch {
|
|
59391
|
+
}
|
|
59392
|
+
}
|
|
59393
|
+
if (ompTmpHome) {
|
|
59394
|
+
try {
|
|
59395
|
+
fs10.rmSync(ompTmpHome, { recursive: true, force: true });
|
|
59396
|
+
} catch {
|
|
59397
|
+
}
|
|
59398
|
+
}
|
|
59399
|
+
if (hermesTmpHome) {
|
|
59400
|
+
try {
|
|
59401
|
+
fs10.rmSync(hermesTmpHome, { recursive: true, force: true });
|
|
59402
|
+
} catch {
|
|
59403
|
+
}
|
|
59404
|
+
}
|
|
59446
59405
|
if (opencodeTmpFile) {
|
|
59447
59406
|
try {
|
|
59448
59407
|
fs10.rmSync(path13.dirname(opencodeTmpFile), { recursive: true, force: true });
|