billion-context 0.1.35 → 0.1.37

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/dist/index.js CHANGED
@@ -1141,14 +1141,14 @@ var require_util = __commonJS({
1141
1141
  }
1142
1142
  const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
1143
1143
  let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
1144
- let path9 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
1144
+ let path11 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
1145
1145
  if (origin[origin.length - 1] === "/") {
1146
1146
  origin = origin.slice(0, origin.length - 1);
1147
1147
  }
1148
- if (path9 && path9[0] !== "/") {
1149
- path9 = `/${path9}`;
1148
+ if (path11 && path11[0] !== "/") {
1149
+ path11 = `/${path11}`;
1150
1150
  }
1151
- return new URL(`${origin}${path9}`);
1151
+ return new URL(`${origin}${path11}`);
1152
1152
  }
1153
1153
  if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
1154
1154
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -1969,9 +1969,9 @@ var require_diagnostics = __commonJS({
1969
1969
  "undici:client:sendHeaders",
1970
1970
  (evt) => {
1971
1971
  const {
1972
- request: { method, path: path9, origin }
1972
+ request: { method, path: path11, origin }
1973
1973
  } = evt;
1974
- debugLog("sending request to %s %s%s", method, origin, path9);
1974
+ debugLog("sending request to %s %s%s", method, origin, path11);
1975
1975
  }
1976
1976
  );
1977
1977
  }
@@ -1989,14 +1989,14 @@ var require_diagnostics = __commonJS({
1989
1989
  "undici:request:headers",
1990
1990
  (evt) => {
1991
1991
  const {
1992
- request: { method, path: path9, origin },
1992
+ request: { method, path: path11, origin },
1993
1993
  response: { statusCode }
1994
1994
  } = evt;
1995
1995
  debugLog(
1996
1996
  "received response to %s %s%s - HTTP %d",
1997
1997
  method,
1998
1998
  origin,
1999
- path9,
1999
+ path11,
2000
2000
  statusCode
2001
2001
  );
2002
2002
  }
@@ -2005,23 +2005,23 @@ var require_diagnostics = __commonJS({
2005
2005
  "undici:request:trailers",
2006
2006
  (evt) => {
2007
2007
  const {
2008
- request: { method, path: path9, origin }
2008
+ request: { method, path: path11, origin }
2009
2009
  } = evt;
2010
- debugLog("trailers received from %s %s%s", method, origin, path9);
2010
+ debugLog("trailers received from %s %s%s", method, origin, path11);
2011
2011
  }
2012
2012
  );
2013
2013
  diagnosticsChannel.subscribe(
2014
2014
  "undici:request:error",
2015
2015
  (evt) => {
2016
2016
  const {
2017
- request: { method, path: path9, origin },
2017
+ request: { method, path: path11, origin },
2018
2018
  error
2019
2019
  } = evt;
2020
2020
  debugLog(
2021
2021
  "request to %s %s%s errored - %s",
2022
2022
  method,
2023
2023
  origin,
2024
- path9,
2024
+ path11,
2025
2025
  error.message
2026
2026
  );
2027
2027
  }
@@ -2136,7 +2136,7 @@ var require_request = __commonJS({
2136
2136
  var kHandler = /* @__PURE__ */ Symbol("handler");
2137
2137
  var Request = class {
2138
2138
  constructor(origin, {
2139
- path: path9,
2139
+ path: path11,
2140
2140
  method,
2141
2141
  body,
2142
2142
  headers,
@@ -2153,11 +2153,11 @@ var require_request = __commonJS({
2153
2153
  maxRedirections,
2154
2154
  typeOfService
2155
2155
  }, handler) {
2156
- if (typeof path9 !== "string") {
2156
+ if (typeof path11 !== "string") {
2157
2157
  throw new InvalidArgumentError("path must be a string");
2158
- } else if (path9[0] !== "/" && !(path9.startsWith("http://") || path9.startsWith("https://")) && method !== "CONNECT") {
2158
+ } else if (path11[0] !== "/" && !(path11.startsWith("http://") || path11.startsWith("https://")) && method !== "CONNECT") {
2159
2159
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
2160
- } else if (invalidPathRegex.test(path9)) {
2160
+ } else if (invalidPathRegex.test(path11)) {
2161
2161
  throw new InvalidArgumentError("invalid request path");
2162
2162
  }
2163
2163
  if (typeof method !== "string") {
@@ -2232,7 +2232,7 @@ var require_request = __commonJS({
2232
2232
  this.completed = false;
2233
2233
  this.aborted = false;
2234
2234
  this.upgrade = upgrade || null;
2235
- this.path = query ? serializePathWithQuery(path9, query) : path9;
2235
+ this.path = query ? serializePathWithQuery(path11, query) : path11;
2236
2236
  this.origin = origin;
2237
2237
  this.protocol = getProtocolFromUrlString(origin);
2238
2238
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
@@ -7415,7 +7415,7 @@ var require_client_h1 = __commonJS({
7415
7415
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
7416
7416
  }
7417
7417
  function writeH1(client, request) {
7418
- const { method, path: path9, host, upgrade, blocking, reset } = request;
7418
+ const { method, path: path11, host, upgrade, blocking, reset } = request;
7419
7419
  let { body, headers, contentLength } = request;
7420
7420
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
7421
7421
  if (util.isFormDataLike(body)) {
@@ -7493,7 +7493,7 @@ var require_client_h1 = __commonJS({
7493
7493
  if (socket.setTypeOfService) {
7494
7494
  socket.setTypeOfService(request.typeOfService);
7495
7495
  }
7496
- let header = `${method} ${path9} HTTP/1.1\r
7496
+ let header = `${method} ${path11} HTTP/1.1\r
7497
7497
  `;
7498
7498
  if (typeof host === "string") {
7499
7499
  header += `host: ${host}\r
@@ -8146,7 +8146,7 @@ var require_client_h2 = __commonJS({
8146
8146
  function writeH2(client, request) {
8147
8147
  const requestTimeout = request.bodyTimeout ?? client[kBodyTimeout];
8148
8148
  const session = client[kHTTP2Session];
8149
- const { method, path: path9, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request;
8149
+ const { method, path: path11, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request;
8150
8150
  let { body } = request;
8151
8151
  if (upgrade != null && upgrade !== "websocket") {
8152
8152
  util.errorRequest(client, request, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
@@ -8214,7 +8214,7 @@ var require_client_h2 = __commonJS({
8214
8214
  }
8215
8215
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
8216
8216
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
8217
- headers[HTTP2_HEADER_PATH] = path9;
8217
+ headers[HTTP2_HEADER_PATH] = path11;
8218
8218
  if (protocol === "ws:" || protocol === "wss:") {
8219
8219
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
8220
8220
  } else {
@@ -8255,7 +8255,7 @@ var require_client_h2 = __commonJS({
8255
8255
  stream2.setTimeout(requestTimeout);
8256
8256
  return true;
8257
8257
  }
8258
- headers[HTTP2_HEADER_PATH] = path9;
8258
+ headers[HTTP2_HEADER_PATH] = path11;
8259
8259
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
8260
8260
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
8261
8261
  if (body && typeof body.read === "function") {
@@ -10598,10 +10598,10 @@ var require_proxy_agent = __commonJS({
10598
10598
  };
10599
10599
  const {
10600
10600
  origin,
10601
- path: path9 = "/",
10601
+ path: path11 = "/",
10602
10602
  headers = {}
10603
10603
  } = opts;
10604
- opts.path = origin + path9;
10604
+ opts.path = origin + path11;
10605
10605
  if (!("host" in headers) && !("Host" in headers)) {
10606
10606
  const { host } = new URL(origin);
10607
10607
  headers.host = host;
@@ -12684,20 +12684,20 @@ var require_mock_utils = __commonJS({
12684
12684
  }
12685
12685
  return normalizedQp;
12686
12686
  }
12687
- function safeUrl(path9) {
12688
- if (typeof path9 !== "string") {
12689
- return path9;
12687
+ function safeUrl(path11) {
12688
+ if (typeof path11 !== "string") {
12689
+ return path11;
12690
12690
  }
12691
- const pathSegments = path9.split("?", 3);
12691
+ const pathSegments = path11.split("?", 3);
12692
12692
  if (pathSegments.length !== 2) {
12693
- return path9;
12693
+ return path11;
12694
12694
  }
12695
12695
  const qp = new URLSearchParams(pathSegments.pop());
12696
12696
  qp.sort();
12697
12697
  return [...pathSegments, qp.toString()].join("?");
12698
12698
  }
12699
- function matchKey(mockDispatch2, { path: path9, method, body, headers }) {
12700
- const pathMatch = matchValue(mockDispatch2.path, path9);
12699
+ function matchKey(mockDispatch2, { path: path11, method, body, headers }) {
12700
+ const pathMatch = matchValue(mockDispatch2.path, path11);
12701
12701
  const methodMatch = matchValue(mockDispatch2.method, method);
12702
12702
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
12703
12703
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -12722,8 +12722,8 @@ var require_mock_utils = __commonJS({
12722
12722
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
12723
12723
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
12724
12724
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
12725
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path9, ignoreTrailingSlash }) => {
12726
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path9)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path9), resolvedPath);
12725
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path11, ignoreTrailingSlash }) => {
12726
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path11)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path11), resolvedPath);
12727
12727
  });
12728
12728
  if (matchedMockDispatches.length === 0) {
12729
12729
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -12762,19 +12762,19 @@ var require_mock_utils = __commonJS({
12762
12762
  mockDispatches.splice(index, 1);
12763
12763
  }
12764
12764
  }
12765
- function removeTrailingSlash(path9) {
12766
- while (path9.endsWith("/")) {
12767
- path9 = path9.slice(0, -1);
12765
+ function removeTrailingSlash(path11) {
12766
+ while (path11.endsWith("/")) {
12767
+ path11 = path11.slice(0, -1);
12768
12768
  }
12769
- if (path9.length === 0) {
12770
- path9 = "/";
12769
+ if (path11.length === 0) {
12770
+ path11 = "/";
12771
12771
  }
12772
- return path9;
12772
+ return path11;
12773
12773
  }
12774
12774
  function buildKey(opts) {
12775
- const { path: path9, method, body, headers, query } = opts;
12775
+ const { path: path11, method, body, headers, query } = opts;
12776
12776
  return {
12777
- path: path9,
12777
+ path: path11,
12778
12778
  method,
12779
12779
  body,
12780
12780
  headers,
@@ -13464,10 +13464,10 @@ var require_pending_interceptors_formatter = __commonJS({
13464
13464
  }
13465
13465
  format(pendingInterceptors) {
13466
13466
  const withPrettyHeaders = pendingInterceptors.map(
13467
- ({ method, path: path9, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13467
+ ({ method, path: path11, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13468
13468
  Method: method,
13469
13469
  Origin: origin,
13470
- Path: path9,
13470
+ Path: path11,
13471
13471
  "Status code": statusCode,
13472
13472
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
13473
13473
  Invocations: timesInvoked,
@@ -13549,9 +13549,9 @@ var require_mock_agent = __commonJS({
13549
13549
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
13550
13550
  const dispatchOpts = { ...opts };
13551
13551
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
13552
- const [path9, searchParams] = dispatchOpts.path.split("?");
13552
+ const [path11, searchParams] = dispatchOpts.path.split("?");
13553
13553
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
13554
- dispatchOpts.path = `${path9}?${normalizedSearchParams}`;
13554
+ dispatchOpts.path = `${path11}?${normalizedSearchParams}`;
13555
13555
  }
13556
13556
  return this[kAgent].dispatch(dispatchOpts, handler);
13557
13557
  }
@@ -13952,12 +13952,12 @@ var require_snapshot_recorder = __commonJS({
13952
13952
  * @return {Promise<void>} - Resolves when snapshots are loaded
13953
13953
  */
13954
13954
  async loadSnapshots(filePath) {
13955
- const path9 = filePath || this.#snapshotPath;
13956
- if (!path9) {
13955
+ const path11 = filePath || this.#snapshotPath;
13956
+ if (!path11) {
13957
13957
  throw new InvalidArgumentError("Snapshot path is required");
13958
13958
  }
13959
13959
  try {
13960
- const data = await readFile3(resolve(path9), "utf8");
13960
+ const data = await readFile3(resolve(path11), "utf8");
13961
13961
  const parsed = JSON.parse(data);
13962
13962
  if (Array.isArray(parsed)) {
13963
13963
  this.#snapshots.clear();
@@ -13971,7 +13971,7 @@ var require_snapshot_recorder = __commonJS({
13971
13971
  if (error.code === "ENOENT") {
13972
13972
  this.#snapshots.clear();
13973
13973
  } else {
13974
- throw new UndiciError(`Failed to load snapshots from ${path9}`, { cause: error });
13974
+ throw new UndiciError(`Failed to load snapshots from ${path11}`, { cause: error });
13975
13975
  }
13976
13976
  }
13977
13977
  }
@@ -13982,11 +13982,11 @@ var require_snapshot_recorder = __commonJS({
13982
13982
  * @returns {Promise<void>} - Resolves when snapshots are saved
13983
13983
  */
13984
13984
  async saveSnapshots(filePath) {
13985
- const path9 = filePath || this.#snapshotPath;
13986
- if (!path9) {
13985
+ const path11 = filePath || this.#snapshotPath;
13986
+ if (!path11) {
13987
13987
  throw new InvalidArgumentError("Snapshot path is required");
13988
13988
  }
13989
- const resolvedPath = resolve(path9);
13989
+ const resolvedPath = resolve(path11);
13990
13990
  await mkdir3(dirname6(resolvedPath), { recursive: true });
13991
13991
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
13992
13992
  hash,
@@ -14618,15 +14618,15 @@ var require_redirect_handler = __commonJS({
14618
14618
  return;
14619
14619
  }
14620
14620
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
14621
- const path9 = search ? `${pathname}${search}` : pathname;
14622
- const redirectUrlString = `${origin}${path9}`;
14621
+ const path11 = search ? `${pathname}${search}` : pathname;
14622
+ const redirectUrlString = `${origin}${path11}`;
14623
14623
  for (const historyUrl of this.history) {
14624
14624
  if (historyUrl.toString() === redirectUrlString) {
14625
14625
  throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
14626
14626
  }
14627
14627
  }
14628
14628
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
14629
- this.opts.path = path9;
14629
+ this.opts.path = path11;
14630
14630
  this.opts.origin = origin;
14631
14631
  this.opts.query = null;
14632
14632
  }
@@ -16395,10 +16395,10 @@ var require_cache_handler = __commonJS({
16395
16395
  }
16396
16396
  return locationUrl.pathname + locationUrl.search;
16397
16397
  }
16398
- function deleteCachedUri(store, cacheKey, path9) {
16398
+ function deleteCachedUri(store, cacheKey, path11) {
16399
16399
  deleteCachedValue(store, {
16400
16400
  ...cacheKey,
16401
- path: path9
16401
+ path: path11
16402
16402
  });
16403
16403
  for (let i = 0; i < util.safeHTTPMethods.length; i++) {
16404
16404
  const method = util.safeHTTPMethods[i];
@@ -16406,7 +16406,7 @@ var require_cache_handler = __commonJS({
16406
16406
  deleteCachedValue(store, {
16407
16407
  ...cacheKey,
16408
16408
  method,
16409
- path: path9
16409
+ path: path11
16410
16410
  });
16411
16411
  }
16412
16412
  }
@@ -16417,9 +16417,9 @@ var require_cache_handler = __commonJS({
16417
16417
  }
16418
16418
  const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
16419
16419
  for (let i = 0; i < values.length; i++) {
16420
- const path9 = getSameOriginPath(cacheKey, values[i]);
16421
- if (path9 !== void 0) {
16422
- deleteCachedUri(store, cacheKey, path9);
16420
+ const path11 = getSameOriginPath(cacheKey, values[i]);
16421
+ if (path11 !== void 0) {
16422
+ deleteCachedUri(store, cacheKey, path11);
16423
16423
  }
16424
16424
  }
16425
16425
  }
@@ -21297,11 +21297,11 @@ var require_fetch = __commonJS({
21297
21297
  function dispatch({ body }) {
21298
21298
  const url = requestCurrentURL(request);
21299
21299
  const agent = fetchParams.controller.dispatcher;
21300
- const path9 = url.pathname + url.search;
21300
+ const path11 = url.pathname + url.search;
21301
21301
  const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
21302
21302
  return new Promise((resolve, reject) => agent.dispatch(
21303
21303
  {
21304
- path: hasTrailingQuestionMark ? `${path9}?` : path9,
21304
+ path: hasTrailingQuestionMark ? `${path11}?` : path11,
21305
21305
  origin: url.origin,
21306
21306
  method: request.method,
21307
21307
  body: agent.isMockActive ? request.body && (request.body.source || request.body.stream) : body,
@@ -21851,8 +21851,8 @@ var require_cache3 = __commonJS({
21851
21851
  * @returns {requestResponseList}
21852
21852
  */
21853
21853
  #batchCacheOperations(operations) {
21854
- const cache2 = this.#relevantRequestResponseList;
21855
- const backupCache = [...cache2];
21854
+ const cache3 = this.#relevantRequestResponseList;
21855
+ const backupCache = [...cache3];
21856
21856
  const addedItems = [];
21857
21857
  const resultList = [];
21858
21858
  try {
@@ -21879,9 +21879,9 @@ var require_cache3 = __commonJS({
21879
21879
  return [];
21880
21880
  }
21881
21881
  for (const requestResponse of requestResponses) {
21882
- const idx = cache2.indexOf(requestResponse);
21882
+ const idx = cache3.indexOf(requestResponse);
21883
21883
  assert(idx !== -1);
21884
- cache2.splice(idx, 1);
21884
+ cache3.splice(idx, 1);
21885
21885
  }
21886
21886
  } else if (operation.type === "put") {
21887
21887
  if (operation.response == null) {
@@ -21911,11 +21911,11 @@ var require_cache3 = __commonJS({
21911
21911
  }
21912
21912
  requestResponses = this.#queryCache(operation.request);
21913
21913
  for (const requestResponse of requestResponses) {
21914
- const idx = cache2.indexOf(requestResponse);
21914
+ const idx = cache3.indexOf(requestResponse);
21915
21915
  assert(idx !== -1);
21916
- cache2.splice(idx, 1);
21916
+ cache3.splice(idx, 1);
21917
21917
  }
21918
- cache2.push([operation.request, operation.response]);
21918
+ cache3.push([operation.request, operation.response]);
21919
21919
  addedItems.push([operation.request, operation.response]);
21920
21920
  }
21921
21921
  resultList.push([operation.request, operation.response]);
@@ -22092,13 +22092,13 @@ var require_cachestorage = __commonJS({
22092
22092
  if (options.cacheName != null) {
22093
22093
  if (this.#caches.has(options.cacheName)) {
22094
22094
  const cacheList = this.#caches.get(options.cacheName);
22095
- const cache2 = new Cache(kConstruct, cacheList);
22096
- return await cache2.match(request, options);
22095
+ const cache3 = new Cache(kConstruct, cacheList);
22096
+ return await cache3.match(request, options);
22097
22097
  }
22098
22098
  } else {
22099
22099
  for (const cacheList of this.#caches.values()) {
22100
- const cache2 = new Cache(kConstruct, cacheList);
22101
- const response = await cache2.match(request, options);
22100
+ const cache3 = new Cache(kConstruct, cacheList);
22101
+ const response = await cache3.match(request, options);
22102
22102
  if (response !== void 0) {
22103
22103
  return response;
22104
22104
  }
@@ -22128,12 +22128,12 @@ var require_cachestorage = __commonJS({
22128
22128
  webidl.argumentLengthCheck(arguments, 1, prefix);
22129
22129
  cacheName = webidl.converters.DOMString(cacheName, prefix, "cacheName");
22130
22130
  if (this.#caches.has(cacheName)) {
22131
- const cache3 = this.#caches.get(cacheName);
22132
- return new Cache(kConstruct, cache3);
22131
+ const cache4 = this.#caches.get(cacheName);
22132
+ return new Cache(kConstruct, cache4);
22133
22133
  }
22134
- const cache2 = [];
22135
- this.#caches.set(cacheName, cache2);
22136
- return new Cache(kConstruct, cache2);
22134
+ const cache3 = [];
22135
+ this.#caches.set(cacheName, cache3);
22136
+ return new Cache(kConstruct, cache3);
22137
22137
  }
22138
22138
  /**
22139
22139
  * @see https://w3c.github.io/ServiceWorker/#cache-storage-delete
@@ -22248,9 +22248,9 @@ var require_util4 = __commonJS({
22248
22248
  }
22249
22249
  }
22250
22250
  }
22251
- function validateCookiePath(path9) {
22252
- for (let i = 0; i < path9.length; ++i) {
22253
- const code = path9.charCodeAt(i);
22251
+ function validateCookiePath(path11) {
22252
+ for (let i = 0; i < path11.length; ++i) {
22253
+ const code = path11.charCodeAt(i);
22254
22254
  if (code < 32 || // exclude CTLs (0-31)
22255
22255
  code > 126 || // exclude DEL and non-ascii
22256
22256
  code === 59) {
@@ -25487,11 +25487,11 @@ var require_undici = __commonJS({
25487
25487
  if (typeof opts.path !== "string") {
25488
25488
  throw new InvalidArgumentError("invalid opts.path");
25489
25489
  }
25490
- let path9 = opts.path;
25490
+ let path11 = opts.path;
25491
25491
  if (!opts.path.startsWith("/")) {
25492
- path9 = `/${path9}`;
25492
+ path11 = `/${path11}`;
25493
25493
  }
25494
- url = new URL(util.parseOrigin(url).origin + path9);
25494
+ url = new URL(util.parseOrigin(url).origin + path11);
25495
25495
  } else {
25496
25496
  if (!opts) {
25497
25497
  opts = typeof url === "object" ? url : {};
@@ -39943,20 +39943,20 @@ var require_tls = __commonJS({
39943
39943
  }
39944
39944
  return !c.fail;
39945
39945
  };
39946
- tls4.createSessionCache = function(cache2, capacity) {
39946
+ tls4.createSessionCache = function(cache3, capacity) {
39947
39947
  var rval = null;
39948
- if (cache2 && cache2.getSession && cache2.setSession && cache2.order) {
39949
- rval = cache2;
39948
+ if (cache3 && cache3.getSession && cache3.setSession && cache3.order) {
39949
+ rval = cache3;
39950
39950
  } else {
39951
39951
  rval = {};
39952
- rval.cache = cache2 || {};
39952
+ rval.cache = cache3 || {};
39953
39953
  rval.capacity = Math.max(capacity || 100, 1);
39954
39954
  rval.order = [];
39955
- for (var key2 in cache2) {
39955
+ for (var key2 in cache3) {
39956
39956
  if (rval.order.length <= capacity) {
39957
39957
  rval.order.push(key2);
39958
39958
  } else {
39959
- delete cache2[key2];
39959
+ delete cache3[key2];
39960
39960
  }
39961
39961
  }
39962
39962
  rval.getSession = function(sessionId) {
@@ -46252,13 +46252,13 @@ function getUpstreamConnectionStatus() {
46252
46252
  }
46253
46253
 
46254
46254
  // src/config.ts
46255
- function safeReadJson(path9) {
46255
+ function safeReadJson(path11) {
46256
46256
  try {
46257
- const raw = readFileSync(path9, "utf8").replace(/^\uFEFF/, "");
46257
+ const raw = readFileSync(path11, "utf8").replace(/^\uFEFF/, "");
46258
46258
  return JSON.parse(raw);
46259
46259
  } catch (e) {
46260
46260
  if (e.code !== "ENOENT") {
46261
- log("error", `[acp-config] failed to parse ${path9}: ${String(e)}`);
46261
+ log("error", `[acp-config] failed to parse ${path11}: ${String(e)}`);
46262
46262
  }
46263
46263
  return void 0;
46264
46264
  }
@@ -46481,7 +46481,7 @@ function rejectLegacyRoute(key, value) {
46481
46481
 
46482
46482
  // src/server.ts
46483
46483
  import http from "http";
46484
- import fs3 from "fs";
46484
+ import fs5 from "fs";
46485
46485
 
46486
46486
  // src/registry.ts
46487
46487
  import { readFile, writeFile, mkdir } from "fs/promises";
@@ -48576,8 +48576,10 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
48576
48576
  if (signal?.aborted) break;
48577
48577
  if (ev.kind === "text") {
48578
48578
  assistantText += ev.delta;
48579
- if (!ctx.textProtocol && round === 1 && ev.raw) {
48579
+ if (!ctx.textProtocol && ev.raw) {
48580
48580
  yield ev.raw;
48581
+ } else if (!ctx.textProtocol && round > 1 && ev.delta.length > 0) {
48582
+ yield adapter.emitText(ev.delta);
48581
48583
  }
48582
48584
  } else if (ev.kind === "tool_call") {
48583
48585
  calls.push({ name: ev.name, callId: ev.callId, arguments: ev.arguments });
@@ -48608,8 +48610,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
48608
48610
  const functionCallIds = new Set(calls.map((c) => c.callId));
48609
48611
  if (ctx.textProtocol && resolvedText.length > 0) {
48610
48612
  yield adapter.emitText(resolvedText);
48611
- } else if (!ctx.textProtocol && round > 1 && resolvedText.length > 0) {
48612
- yield adapter.emitText(resolvedText);
48613
48613
  }
48614
48614
  let realCalls = 0;
48615
48615
  const realToolCalls = [];
@@ -48708,11 +48708,11 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
48708
48708
  const newBody = adapter.buildRequest(coreMessages, systemPrompt, requestBody);
48709
48709
  if (process.env.ACP_DUMP_REQ !== "0" && ctx.debug) {
48710
48710
  try {
48711
- const fs6 = await import("fs");
48711
+ const fs8 = await import("fs");
48712
48712
  const dumpDir = process.env.ACP_DUMP_DIR || `${process.env.HOME}/.local/state/billion-context/dumps`;
48713
- fs6.mkdirSync(dumpDir, { recursive: true });
48713
+ fs8.mkdirSync(dumpDir, { recursive: true });
48714
48714
  const sid = ctx.session.id ?? "unknown";
48715
- fs6.writeFileSync(`${dumpDir}/req-${Date.now()}-${sid}-REREQUEST.json`, JSON.stringify(newBody, null, 2));
48715
+ fs8.writeFileSync(`${dumpDir}/req-${Date.now()}-${sid}-REREQUEST.json`, JSON.stringify(newBody, null, 2));
48716
48716
  } catch {
48717
48717
  }
48718
48718
  }
@@ -49487,10 +49487,10 @@ ${systemPrompt}` : systemPrompt;
49487
49487
  const name = typeof block.name === "string" ? block.name : "";
49488
49488
  const id = typeof block.id === "string" ? block.id : `toolu_${upstreamIndex}`;
49489
49489
  pending.set(upstreamIndex, { id, name, json: "" });
49490
- } else if (round === 1) {
49490
+ } else {
49491
49491
  const ci2 = clientIndex++;
49492
49492
  indexMap.set(upstreamIndex, ci2);
49493
- yield { kind: "meta", chunk: remapIndexInEvent(eventStr, ci2), firstRoundOnly: true };
49493
+ yield { kind: "meta", chunk: remapIndexInEvent(eventStr, ci2), firstRoundOnly: round === 1 };
49494
49494
  }
49495
49495
  } else if (type === "content_block_delta") {
49496
49496
  const upstreamIndex = data.index ?? 0;
@@ -49500,12 +49500,8 @@ ${systemPrompt}` : systemPrompt;
49500
49500
  pending.get(upstreamIndex).json += delta.partial_json;
49501
49501
  }
49502
49502
  } else if (delta.type === "text_delta" && typeof delta.text === "string") {
49503
- if (round === 1) {
49504
- const ci2 = indexMap.get(upstreamIndex) ?? upstreamIndex;
49505
- yield { kind: "text", delta: delta.text, raw: remapIndexInEvent(eventStr, ci2) };
49506
- } else {
49507
- yield { kind: "text", delta: delta.text };
49508
- }
49503
+ const ci2 = indexMap.get(upstreamIndex) ?? upstreamIndex;
49504
+ yield { kind: "text", delta: delta.text, raw: remapIndexInEvent(eventStr, ci2) };
49509
49505
  } else if (round === 1) {
49510
49506
  const ci2 = indexMap.get(upstreamIndex) ?? upstreamIndex;
49511
49507
  yield { kind: "meta", chunk: remapIndexInEvent(eventStr, ci2), firstRoundOnly: true };
@@ -49521,9 +49517,9 @@ ${systemPrompt}` : systemPrompt;
49521
49517
  callId: tb.id,
49522
49518
  arguments: tb.json
49523
49519
  };
49524
- } else if (round === 1) {
49520
+ } else {
49525
49521
  const ci2 = indexMap.get(upstreamIndex) ?? upstreamIndex;
49526
- yield { kind: "meta", chunk: remapIndexInEvent(eventStr, ci2), firstRoundOnly: true };
49522
+ yield { kind: "meta", chunk: remapIndexInEvent(eventStr, ci2), firstRoundOnly: round === 1 };
49527
49523
  }
49528
49524
  } else if (type === "message_delta") {
49529
49525
  const u2 = data.usage ?? {};
@@ -50008,17 +50004,239 @@ function getSecureContext(host) {
50008
50004
  return ctx;
50009
50005
  }
50010
50006
 
50007
+ // src/discover.ts
50008
+ import fs4 from "fs";
50009
+ import os2 from "os";
50010
+ import path7 from "path";
50011
+
50012
+ // src/client-config.ts
50013
+ import fs3 from "fs";
50014
+ import os from "os";
50015
+ import path6 from "path";
50016
+ function nonEmpty2(s3) {
50017
+ return typeof s3 === "string" && s3.trim().length > 0;
50018
+ }
50019
+ function readJsonObject(filePath) {
50020
+ try {
50021
+ const txt = fs3.readFileSync(filePath, "utf8");
50022
+ const parsed = JSON.parse(txt);
50023
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
50024
+ } catch {
50025
+ return null;
50026
+ }
50027
+ }
50028
+ function resolvePiHome(env) {
50029
+ const h = os.homedir();
50030
+ return nonEmpty2(env.PI_CODING_AGENT_DIR) ? env.PI_CODING_AGENT_DIR : nonEmpty2(env.PI_HOME) ? env.PI_HOME : path6.join(h, ".pi", "agent");
50031
+ }
50032
+ function readClaudeSettings(homeDir, cwd) {
50033
+ const files = [
50034
+ path6.join(homeDir, ".claude", "settings.json"),
50035
+ path6.join(cwd, ".claude", "settings.json")
50036
+ ];
50037
+ let anthropicBaseUrl;
50038
+ for (const f2 of files) {
50039
+ const obj = readJsonObject(f2);
50040
+ const env = obj?.env;
50041
+ if (env && typeof env === "object" && !Array.isArray(env)) {
50042
+ const v2 = env.ANTHROPIC_BASE_URL;
50043
+ if (nonEmpty2(v2)) anthropicBaseUrl = v2;
50044
+ }
50045
+ }
50046
+ return anthropicBaseUrl ? { anthropicBaseUrl } : {};
50047
+ }
50048
+ function parseCodexToml(text) {
50049
+ const result = { providers: {} };
50050
+ let table = "";
50051
+ let curProvider = null;
50052
+ for (const rawLine of text.split(/\r?\n/)) {
50053
+ const line = rawLine.trim();
50054
+ if (!line || line.startsWith("#")) continue;
50055
+ const tableMatch = /^\[([^\]]+)\]$/.exec(line);
50056
+ if (tableMatch) {
50057
+ table = tableMatch[1].trim();
50058
+ curProvider = table.startsWith("model_providers.") ? table.slice("model_providers.".length).trim() : null;
50059
+ if (curProvider && !result.providers[curProvider]) {
50060
+ result.providers[curProvider] = {};
50061
+ }
50062
+ continue;
50063
+ }
50064
+ const m2 = /^([A-Za-z0-9_.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(line);
50065
+ if (!m2) continue;
50066
+ const key = m2[1];
50067
+ const val = m2[2] !== void 0 ? m2[2] : m2[3];
50068
+ if (table === "") {
50069
+ if (key === "model_provider") result.modelProvider = val;
50070
+ else if (key === "openai_base_url") result.openaiBaseUrl = val;
50071
+ } else if (curProvider && key === "base_url") {
50072
+ result.providers[curProvider].baseUrl = val;
50073
+ }
50074
+ }
50075
+ return result;
50076
+ }
50077
+ function readCodexConfig(codexHome) {
50078
+ const cfgPath = path6.join(codexHome, "config.toml");
50079
+ let text;
50080
+ try {
50081
+ text = fs3.readFileSync(cfgPath, "utf8");
50082
+ } catch {
50083
+ return { providers: {} };
50084
+ }
50085
+ return parseCodexToml(text);
50086
+ }
50087
+ function readPiConfig(piHome) {
50088
+ const cfgPath = path6.join(piHome, "models.json");
50089
+ const obj = readJsonObject(cfgPath);
50090
+ const providers = {};
50091
+ const rawProviders = obj?.providers;
50092
+ if (rawProviders && typeof rawProviders === "object" && !Array.isArray(rawProviders)) {
50093
+ for (const [name, val] of Object.entries(rawProviders)) {
50094
+ if (val && typeof val === "object" && !Array.isArray(val)) {
50095
+ const baseUrl = val.baseUrl;
50096
+ providers[name] = typeof baseUrl === "string" ? { baseUrl } : {};
50097
+ }
50098
+ }
50099
+ }
50100
+ return { providers };
50101
+ }
50102
+ function parseZcodeConfig(obj) {
50103
+ const result = { providers: {} };
50104
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) return result;
50105
+ const root = obj;
50106
+ const providerField = root.provider;
50107
+ if (!providerField || typeof providerField !== "object" || Array.isArray(providerField)) return result;
50108
+ const providerMap = providerField;
50109
+ for (const [name, val] of Object.entries(providerMap)) {
50110
+ if (!val || typeof val !== "object" || Array.isArray(val)) continue;
50111
+ const options = val.options;
50112
+ if (!options || typeof options !== "object" || Array.isArray(options)) continue;
50113
+ const baseURL = options.baseURL;
50114
+ if (typeof baseURL === "string") result.providers[name] = { baseURL };
50115
+ }
50116
+ return result;
50117
+ }
50118
+ function readZcodeConfig(zcodeHome) {
50119
+ const cfgPath = path6.join(zcodeHome, "v2", "config.json");
50120
+ let txt;
50121
+ try {
50122
+ txt = fs3.readFileSync(cfgPath, "utf8");
50123
+ } catch {
50124
+ return { providers: {} };
50125
+ }
50126
+ let parsed;
50127
+ try {
50128
+ parsed = JSON.parse(txt);
50129
+ } catch {
50130
+ return { providers: {} };
50131
+ }
50132
+ return parseZcodeConfig(parsed);
50133
+ }
50134
+ function loadClientConfig(env, cwd) {
50135
+ const home = os.homedir();
50136
+ const config = {};
50137
+ config.claude = readClaudeSettings(home, cwd);
50138
+ const codexHome = nonEmpty2(env.CODEX_HOME) ? env.CODEX_HOME : path6.join(home, ".codex");
50139
+ config.codex = readCodexConfig(codexHome);
50140
+ config.pi = readPiConfig(resolvePiHome(env));
50141
+ const zcodeHome = nonEmpty2(env.ZCODE_DATA_BASE_DIR) ? env.ZCODE_DATA_BASE_DIR : path6.join(home, ".zcode");
50142
+ config.zcode = readZcodeConfig(zcodeHome);
50143
+ return config;
50144
+ }
50145
+
50146
+ // src/discover.ts
50147
+ var TTL_MS2 = 2e3;
50148
+ function unwrapUpstream(url) {
50149
+ const idx = url.indexOf("/bili/");
50150
+ return idx >= 0 ? url.slice(idx + "/bili/".length) : url;
50151
+ }
50152
+ function extractHttpsHosts(config) {
50153
+ const seen = /* @__PURE__ */ new Set();
50154
+ const out = [];
50155
+ const push = (raw) => {
50156
+ if (typeof raw !== "string" || raw.length === 0) return;
50157
+ let url;
50158
+ try {
50159
+ url = new URL(unwrapUpstream(raw));
50160
+ } catch {
50161
+ return;
50162
+ }
50163
+ if (url.protocol !== "https:") return;
50164
+ const host = url.hostname.toLowerCase();
50165
+ if (!host || seen.has(host)) return;
50166
+ seen.add(host);
50167
+ out.push(host);
50168
+ };
50169
+ if (nonEmpty2(config.claude?.anthropicBaseUrl)) push(config.claude.anthropicBaseUrl);
50170
+ if (config.codex) {
50171
+ for (const prov of Object.values(config.codex.providers)) push(prov.baseUrl);
50172
+ push(config.codex.openaiBaseUrl);
50173
+ }
50174
+ if (config.pi) {
50175
+ for (const prov of Object.values(config.pi.providers)) push(prov.baseUrl);
50176
+ }
50177
+ if (config.zcode) {
50178
+ for (const prov of Object.values(config.zcode.providers)) push(prov.baseURL);
50179
+ }
50180
+ return out;
50181
+ }
50182
+ function configFilePaths(env) {
50183
+ const home = os2.homedir();
50184
+ const codexHome = nonEmpty2(env.CODEX_HOME) ? env.CODEX_HOME : path7.join(home, ".codex");
50185
+ const zcodeHome = nonEmpty2(env.ZCODE_DATA_BASE_DIR) ? env.ZCODE_DATA_BASE_DIR : path7.join(home, ".zcode");
50186
+ return [
50187
+ path7.join(home, ".claude", "settings.json"),
50188
+ path7.join(process.cwd(), ".claude", "settings.json"),
50189
+ path7.join(codexHome, "config.toml"),
50190
+ path7.join(resolvePiHome(env), "models.json"),
50191
+ path7.join(zcodeHome, "v2", "config.json")
50192
+ ];
50193
+ }
50194
+ function readMtimes(paths) {
50195
+ const mtimes = /* @__PURE__ */ new Map();
50196
+ for (const p2 of paths) {
50197
+ try {
50198
+ const st2 = fs4.statSync(p2);
50199
+ mtimes.set(p2, st2.mtimeMs);
50200
+ } catch {
50201
+ }
50202
+ }
50203
+ return mtimes;
50204
+ }
50205
+ function mtimesEqual(a, b2) {
50206
+ if (a.size !== b2.size) return false;
50207
+ for (const [k2, v2] of a) {
50208
+ if (b2.get(k2) !== v2) return false;
50209
+ }
50210
+ return true;
50211
+ }
50212
+ var cache2 = null;
50213
+ function discoverMitmDomains(env = process.env) {
50214
+ const now = Date.now();
50215
+ if (cache2 && now - cache2.checkedAt < TTL_MS2) {
50216
+ return cache2.domains;
50217
+ }
50218
+ const paths = configFilePaths(env);
50219
+ const mtimes = readMtimes(paths);
50220
+ if (cache2 && mtimesEqual(mtimes, cache2.mtimes)) {
50221
+ cache2.checkedAt = now;
50222
+ return cache2.domains;
50223
+ }
50224
+ const config = loadClientConfig(env, process.cwd());
50225
+ const domains = extractHttpsHosts(config);
50226
+ cache2 = { checkedAt: now, mtimes, domains };
50227
+ return domains;
50228
+ }
50229
+
50011
50230
  // src/mitm.ts
50012
50231
  var DEFAULT_MITM_DOMAINS = [
50013
- "open.bigmodel.cn",
50014
50232
  "api.anthropic.com",
50015
50233
  "api.openai.com",
50016
50234
  "chatgpt.com"
50017
50235
  ];
50018
50236
  var MITM_UPSTREAM_KEY = "__biliMitmUpstream";
50019
- function isMitmHost(host, extra = []) {
50237
+ function isMitmHost(host, extraDomains = []) {
50020
50238
  const h = host.toLowerCase();
50021
- const all = [...DEFAULT_MITM_DOMAINS, ...extra].map((d) => d.toLowerCase());
50239
+ const all = [...DEFAULT_MITM_DOMAINS, ...extraDomains, ...discoverMitmDomains()].map((d) => d.toLowerCase());
50022
50240
  return all.some((d) => h === d || h.endsWith("." + d));
50023
50241
  }
50024
50242
  function setupMitm(server, extraDomains = [], log2 = () => {
@@ -51084,7 +51302,7 @@ async function handle(req, res, opts, core, config, log2) {
51084
51302
  urlPath = url.split("?", 2)[0];
51085
51303
  responsesCompact = urlPath.endsWith("/responses/compact");
51086
51304
  route = resolveUpstream(opts, req.url ?? "", req);
51087
- upstreamOrigin = route ? route.upstream : opts.upstream;
51305
+ upstreamOrigin = route ? route.upstream : /^https?:\/\//i.test(url) ? new URL(url).origin : opts.upstream;
51088
51306
  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);
51089
51307
  if (protocol !== null && bodyBuffer.length > 0) {
51090
51308
  const decoded = await decodeRequestBody(headerValue(req, "content-encoding"), bodyBuffer, MAX_REQUEST_BYTES);
@@ -51120,11 +51338,11 @@ async function handle(req, res, opts, core, config, log2) {
51120
51338
  log2("info", `[debug] INCOMING previous_response_id=${hasPrev ? String(p2.previous_response_id).slice(0, 16) : "absent"} input_items=${inLen} instructions=${p2.instructions !== void 0 ? "present" : "absent"}`);
51121
51339
  const rawDir = `${stateDir()}/raw`;
51122
51340
  try {
51123
- fs3.mkdirSync(rawDir, { recursive: true });
51341
+ fs5.mkdirSync(rawDir, { recursive: true });
51124
51342
  } catch {
51125
51343
  }
51126
51344
  const hdrs = Object.entries(req.headers).filter(([k2]) => !/authorization|x-api-key|cookie/i.test(k2)).map(([k2, v2]) => `${k2}: ${Array.isArray(v2) ? v2.join(",") : v2}`).join("\n");
51127
- fs3.writeFileSync(`${rawDir}/${Date.now()}-INCOMING.txt`, `${req.method} ${req.url}
51345
+ fs5.writeFileSync(`${rawDir}/${Date.now()}-INCOMING.txt`, `${req.method} ${req.url}
51128
51346
  ${hdrs}
51129
51347
 
51130
51348
  ${bodyBuffer.toString("utf8")}`);
@@ -51506,7 +51724,9 @@ function injectResponsesTool(tools, toolsToAdd = ACP_TOOLS_RESPONSES) {
51506
51724
  return [...tools, ...additions];
51507
51725
  }
51508
51726
  async function forward(req, res, opts, body, prepared, core, config, log2, route, affinity) {
51509
- const rewritten = route ? route.rewrittenUrl : opts.upstream + (req.url ?? "");
51727
+ const reqUrl = req.url ?? "";
51728
+ const isAbsoluteUrl = /^https?:\/\//i.test(reqUrl);
51729
+ const rewritten = route ? route.rewrittenUrl : isAbsoluteUrl ? reqUrl : opts.upstream + reqUrl;
51510
51730
  const upstreamUrl = rewritten.replace(/^mitm:\/\//, "https://");
51511
51731
  log2("info", `forward ${req.method} \u2192 ${upstreamUrl}`);
51512
51732
  if (process.env.ACP_DEBUG && prepared) {
@@ -51533,16 +51753,16 @@ async function forward(req, res, opts, body, prepared, core, config, log2, route
51533
51753
  if (process.env.ACP_DUMP_REQ !== "0") {
51534
51754
  const dumpDir = process.env.ACP_DUMP_DIR || `${stateDir()}/dumps`;
51535
51755
  try {
51536
- fs3.mkdirSync(dumpDir, { recursive: true });
51756
+ fs5.mkdirSync(dumpDir, { recursive: true });
51537
51757
  } catch {
51538
51758
  }
51539
51759
  const sid = prepared?.session.id ?? "unknown";
51540
51760
  const out = `${dumpDir}/req-${Date.now()}-${sid}.json`;
51541
51761
  try {
51542
51762
  const pretty = JSON.stringify(JSON.parse(body), null, 2);
51543
- fs3.writeFileSync(out, pretty);
51763
+ fs5.writeFileSync(out, pretty);
51544
51764
  } catch {
51545
- fs3.writeFileSync(out, body);
51765
+ fs5.writeFileSync(out, body);
51546
51766
  }
51547
51767
  log2("info", `[debug] forwarded body written to ${out}`);
51548
51768
  }
@@ -51554,7 +51774,7 @@ async function forward(req, res, opts, body, prepared, core, config, log2, route
51554
51774
  if (UPSTREAM_HOP_HEADERS.has(k2.toLowerCase()) || v2 === void 0) continue;
51555
51775
  headers[k2] = Array.isArray(v2) ? v2.join(", ") : v2;
51556
51776
  }
51557
- headers["host"] = new URL(route ? route.upstream : opts.upstream).host;
51777
+ headers["host"] = new URL(upstreamUrl).host;
51558
51778
  const betaKey = Object.keys(headers).find((h) => h.toLowerCase() === "x-codex-beta-features");
51559
51779
  if (betaKey) {
51560
51780
  const kept = headers[betaKey].split(",").map((s3) => s3.trim()).filter((f2) => f2 && f2 !== "remote_compaction_v2");
@@ -51575,7 +51795,7 @@ async function forward(req, res, opts, body, prepared, core, config, log2, route
51575
51795
  const rawBase = opts.debug ? (() => {
51576
51796
  try {
51577
51797
  const rawDir = process.env.ACP_RAW_DUMP_DIR || `${stateDir()}/raw`;
51578
- fs3.mkdirSync(rawDir, { recursive: true });
51798
+ fs5.mkdirSync(rawDir, { recursive: true });
51579
51799
  return `${rawDir}/${Date.now()}-${prepared?.session.id ?? "unknown"}`;
51580
51800
  } catch {
51581
51801
  return "";
@@ -51587,7 +51807,7 @@ async function forward(req, res, opts, body, prepared, core, config, log2, route
51587
51807
  const hdrText = Object.entries(headers).map(([k2, v2]) => `${k2}: ${maskHdr(k2, String(v2))}`).join("\n");
51588
51808
  const bodyText = req.method === "GET" || req.method === "HEAD" ? "" : typeof body === "string" ? body : Buffer.from(body).toString("utf8");
51589
51809
  const reqPath = `${rawBase}-REQ.txt`;
51590
- fs3.writeFileSync(reqPath, `${req.method ?? "POST"} ${upstreamUrl}
51810
+ fs5.writeFileSync(reqPath, `${req.method ?? "POST"} ${upstreamUrl}
51591
51811
  ${hdrText}
51592
51812
 
51593
51813
  ${bodyText}`);
@@ -51629,7 +51849,7 @@ ${bodyText}`);
51629
51849
  const maskHdr = (k2, v2) => /key|auth|token/i.test(k2) ? `<masked ${v2.length} chars>` : v2;
51630
51850
  const hdrText = Object.entries(respHeaders).map(([k2, v2]) => `${k2}: ${maskHdr(k2, v2)}`).join("\n");
51631
51851
  const resPath = `${rawBase}-RES.txt`;
51632
- fs3.writeFileSync(resPath, `${upstream.status}
51852
+ fs5.writeFileSync(resPath, `${upstream.status}
51633
51853
  ${hdrText}
51634
51854
  `);
51635
51855
  log2("info", `[debug] RAW response dump: ${resPath}`);
@@ -53360,7 +53580,7 @@ var ss = /* @__PURE__ */ Symbol("lstat");
53360
53580
  var si = /* @__PURE__ */ Symbol("onlstat");
53361
53581
  var rs = /* @__PURE__ */ Symbol("onread");
53362
53582
  var ns = /* @__PURE__ */ Symbol("onreadlink");
53363
- var os = /* @__PURE__ */ Symbol("openfile");
53583
+ var os3 = /* @__PURE__ */ Symbol("openfile");
53364
53584
  var hs = /* @__PURE__ */ Symbol("onopenfile");
53365
53585
  var pt = /* @__PURE__ */ Symbol("close");
53366
53586
  var ri = /* @__PURE__ */ Symbol("mode");
@@ -53475,9 +53695,9 @@ var de = class extends A {
53475
53695
  this.linkCache.set(t, this.absolute);
53476
53696
  }
53477
53697
  if (this[fe](), this.stat.size === 0) return this.end();
53478
- this[os]();
53698
+ this[os3]();
53479
53699
  }
53480
- [os]() {
53700
+ [os3]() {
53481
53701
  X.open(this.absolute, "r", (t, e) => {
53482
53702
  if (t) return this.emit("error", t);
53483
53703
  this[hs](e);
@@ -53540,7 +53760,7 @@ var ni = class extends de {
53540
53760
  [is]() {
53541
53761
  this[ns](X.readlinkSync(this.absolute));
53542
53762
  }
53543
- [os]() {
53763
+ [os3]() {
53544
53764
  this[hs](X.openSync(this.absolute, "r"));
53545
53765
  }
53546
53766
  [ii]() {
@@ -53827,7 +54047,7 @@ var hr = /* @__PURE__ */ Symbol("entry");
53827
54047
  var cs = /* @__PURE__ */ Symbol("entryOpt");
53828
54048
  var ui = /* @__PURE__ */ Symbol("writeEntryClass");
53829
54049
  var lr = /* @__PURE__ */ Symbol("write");
53830
- var fs4 = /* @__PURE__ */ Symbol("ondrain");
54050
+ var fs6 = /* @__PURE__ */ Symbol("ondrain");
53831
54051
  var wt = class extends A {
53832
54052
  sync = false;
53833
54053
  opt;
@@ -53861,8 +54081,8 @@ var wt = class extends A {
53861
54081
  if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
53862
54082
  if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = true), this.zip = new ze(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new We(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ye(t.zstd)), !this.zip) throw new Error("impossible");
53863
54083
  let e = this.zip;
53864
- e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[fs4]()), this.on("resume", () => e.resume());
53865
- } else this.on("drain", this[fs4]);
54084
+ e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[fs6]()), this.on("resume", () => e.resume());
54085
+ } else this.on("drain", this[fs6]);
53866
54086
  this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => true, this[W] = new hi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[Ee] = false, this[me] = false;
53867
54087
  }
53868
54088
  [lr](t) {
@@ -53975,7 +54195,7 @@ var wt = class extends A {
53975
54195
  this.emit("error", e);
53976
54196
  }
53977
54197
  }
53978
- [fs4]() {
54198
+ [fs6]() {
53979
54199
  this[Et] && this[Et].entry && this[Et].entry.resume();
53980
54200
  }
53981
54201
  [di](t) {
@@ -54860,12 +55080,12 @@ var To = (s3) => {
54860
55080
  };
54861
55081
 
54862
55082
  // src/update.ts
54863
- import path6 from "path";
55083
+ import path8 from "path";
54864
55084
  import { fileURLToPath as fileURLToPath2 } from "url";
54865
55085
  var REGISTRY_BASE = "https://registry.npmjs.org";
54866
55086
  var CHECK_INTERVAL_MS = 3 * 60 * 1e3;
54867
- var THROTTLE_FILE = path6.join(cacheDir(), ".update-check");
54868
- var LOCK_FILE = path6.join(cacheDir(), ".update-lock");
55087
+ var THROTTLE_FILE = path8.join(cacheDir(), ".update-check");
55088
+ var LOCK_FILE = path8.join(cacheDir(), ".update-lock");
54869
55089
  var LOCK_STALE_MS = 2 * 60 * 1e3;
54870
55090
  var timer;
54871
55091
  var inFlight = false;
@@ -54894,27 +55114,27 @@ async function readLastCheck() {
54894
55114
  }
54895
55115
  async function writeLastCheck(ts2) {
54896
55116
  try {
54897
- await mkdir2(path6.dirname(THROTTLE_FILE), { recursive: true });
55117
+ await mkdir2(path8.dirname(THROTTLE_FILE), { recursive: true });
54898
55118
  await writeFile2(THROTTLE_FILE, String(ts2), "utf-8");
54899
55119
  } catch {
54900
55120
  }
54901
55121
  }
54902
55122
  async function findInstallDir(packageName) {
54903
- let dir = path6.dirname(fileURLToPath2(import.meta.url));
55123
+ let dir = path8.dirname(fileURLToPath2(import.meta.url));
54904
55124
  for (; ; ) {
54905
55125
  try {
54906
- const pkg = JSON.parse(await readFile2(path6.join(dir, "package.json"), "utf-8"));
55126
+ const pkg = JSON.parse(await readFile2(path8.join(dir, "package.json"), "utf-8"));
54907
55127
  if (pkg.name === packageName) return dir;
54908
55128
  } catch {
54909
55129
  }
54910
- const parent = path6.dirname(dir);
55130
+ const parent = path8.dirname(dir);
54911
55131
  if (parent === dir) return void 0;
54912
55132
  dir = parent;
54913
55133
  }
54914
55134
  }
54915
55135
  async function readDiskVersion(installDir) {
54916
55136
  try {
54917
- const pkg = JSON.parse(await readFile2(path6.join(installDir, "package.json"), "utf-8"));
55137
+ const pkg = JSON.parse(await readFile2(path8.join(installDir, "package.json"), "utf-8"));
54918
55138
  return pkg.version;
54919
55139
  } catch {
54920
55140
  return void 0;
@@ -55088,14 +55308,14 @@ async function installViaTarball(version2, tarballUrl, installDir) {
55088
55308
  } catch (e) {
55089
55309
  return { ok: false, error: `tarball download failed: ${String(e)}` };
55090
55310
  }
55091
- const tmpFile = path6.join(cacheDir(), `.update-${version2}.tgz`);
55311
+ const tmpFile = path8.join(cacheDir(), `.update-${version2}.tgz`);
55092
55312
  try {
55093
55313
  await mkdir2(cacheDir(), { recursive: true });
55094
55314
  await writeFile2(tmpFile, tgzBuffer);
55095
55315
  } catch (e) {
55096
55316
  return { ok: false, error: `failed to write temp file ${tmpFile}: ${String(e)}` };
55097
55317
  }
55098
- const stagingDir = path6.join(cacheDir(), `.update-staging-${version2}`);
55318
+ const stagingDir = path8.join(cacheDir(), `.update-staging-${version2}`);
55099
55319
  try {
55100
55320
  await rm(stagingDir, { recursive: true, force: true });
55101
55321
  await mkdir2(stagingDir, { recursive: true });
@@ -55138,10 +55358,10 @@ function startAutoUpdate(opts) {
55138
55358
  }
55139
55359
 
55140
55360
  // src/launcher.ts
55141
- import fs5 from "fs";
55361
+ import fs7 from "fs";
55142
55362
  import net2 from "net";
55143
- import os2 from "os";
55144
- import path7 from "path";
55363
+ import os4 from "os";
55364
+ import path9 from "path";
55145
55365
  import { spawn } from "child_process";
55146
55366
  var LAUNCHER_DEFAULT_HOST = "127.0.0.1";
55147
55367
  var LAUNCHER_DEFAULT_PORT = 8787;
@@ -55180,20 +55400,13 @@ function wrapUpstream(origin, upstream) {
55180
55400
  if (u2.startsWith(prefix)) return u2;
55181
55401
  return prefix + u2;
55182
55402
  }
55183
- function unwrapUpstream(url) {
55403
+ function unwrapUpstream2(url) {
55184
55404
  const idx = url.indexOf("/bili/");
55185
55405
  return idx >= 0 ? url.slice(idx + "/bili/".length) : url;
55186
55406
  }
55187
- function nonEmpty2(s3) {
55188
- return typeof s3 === "string" && s3.trim().length > 0;
55189
- }
55190
55407
  function resolveCaCertPath(env) {
55191
- const base = env.XDG_DATA_HOME || path7.join(os2.homedir(), ".local/share");
55192
- return path7.join(base, "billion-context", "ca", "root-ca.pem");
55193
- }
55194
- function resolvePiHome(env) {
55195
- const h = os2.homedir();
55196
- return nonEmpty2(env.PI_CODING_AGENT_DIR) ? env.PI_CODING_AGENT_DIR : nonEmpty2(env.PI_HOME) ? env.PI_HOME : path7.join(h, ".pi", "agent");
55408
+ const base = env.XDG_DATA_HOME || path9.join(os4.homedir(), ".local/share");
55409
+ return path9.join(base, "billion-context", "ca", "root-ca.pem");
55197
55410
  }
55198
55411
  function discoverRoutes(client, config) {
55199
55412
  const httpsDomains = [];
@@ -55206,7 +55419,7 @@ function discoverRoutes(client, config) {
55206
55419
  if (!nonEmpty2(raw)) return;
55207
55420
  let url;
55208
55421
  try {
55209
- url = new URL(unwrapUpstream(raw));
55422
+ url = new URL(unwrapUpstream2(raw));
55210
55423
  } catch {
55211
55424
  return;
55212
55425
  }
@@ -55216,14 +55429,14 @@ function discoverRoutes(client, config) {
55216
55429
  httpsSeen.add(host.toLowerCase());
55217
55430
  httpsDomains.push(host);
55218
55431
  }
55219
- if (raw !== unwrapUpstream(raw) && !httpsRewriteKeys.has(key)) {
55432
+ if (raw !== unwrapUpstream2(raw) && !httpsRewriteKeys.has(key)) {
55220
55433
  httpsRewriteKeys.add(key);
55221
- httpsRewrites.push({ key, realUpstream: unwrapUpstream(raw) });
55434
+ httpsRewrites.push({ key, realUpstream: unwrapUpstream2(raw) });
55222
55435
  }
55223
55436
  } else if (url.protocol === "http:") {
55224
55437
  if (!rewriteKeys.has(key)) {
55225
55438
  rewriteKeys.add(key);
55226
- httpRewrites.push({ key, realUpstream: unwrapUpstream(raw) });
55439
+ httpRewrites.push({ key, realUpstream: unwrapUpstream2(raw) });
55227
55440
  }
55228
55441
  }
55229
55442
  };
@@ -55273,10 +55486,10 @@ function buildClaudeEnv(origin, caPath, httpRewrites, httpsRewrites, baseEnv) {
55273
55486
  }
55274
55487
  function preparePiHttpRewrite(piHome, origin, httpRewrites, httpsRewrites) {
55275
55488
  if (httpRewrites.length === 0 && httpsRewrites.length === 0) return void 0;
55276
- const modelsPath = path7.join(piHome, "models.json");
55489
+ const modelsPath = path9.join(piHome, "models.json");
55277
55490
  let txt;
55278
55491
  try {
55279
- txt = fs5.readFileSync(modelsPath, "utf8");
55492
+ txt = fs7.readFileSync(modelsPath, "utf8");
55280
55493
  } catch {
55281
55494
  return void 0;
55282
55495
  }
@@ -55296,7 +55509,7 @@ function preparePiHttpRewrite(piHome, origin, httpRewrites, httpsRewrites) {
55296
55509
  if (prov && typeof prov === "object" && !Array.isArray(prov)) {
55297
55510
  const p2 = prov;
55298
55511
  const existing = typeof p2.baseUrl === "string" ? p2.baseUrl : r.realUpstream;
55299
- p2.baseUrl = wrapUpstream(origin, unwrapUpstream(existing));
55512
+ p2.baseUrl = wrapUpstream(origin, unwrapUpstream2(existing));
55300
55513
  }
55301
55514
  }
55302
55515
  for (const r of httpsRewrites) {
@@ -55307,18 +55520,18 @@ function preparePiHttpRewrite(piHome, origin, httpRewrites, httpsRewrites) {
55307
55520
  }
55308
55521
  }
55309
55522
  }
55310
- const tmp = fs5.mkdtempSync(path7.join(os2.tmpdir(), "bili-pi-"));
55523
+ const tmp = fs7.mkdtempSync(path9.join(os4.tmpdir(), "bili-pi-"));
55311
55524
  try {
55312
- for (const entry of fs5.readdirSync(piHome)) {
55525
+ for (const entry of fs7.readdirSync(piHome)) {
55313
55526
  if (entry === "models.json") continue;
55314
55527
  try {
55315
- fs5.symlinkSync(path7.join(piHome, entry), path7.join(tmp, entry));
55528
+ fs7.symlinkSync(path9.join(piHome, entry), path9.join(tmp, entry));
55316
55529
  } catch {
55317
55530
  }
55318
55531
  }
55319
55532
  } catch {
55320
55533
  }
55321
- fs5.writeFileSync(path7.join(tmp, "models.json"), JSON.stringify(root));
55534
+ fs7.writeFileSync(path9.join(tmp, "models.json"), JSON.stringify(root));
55322
55535
  return tmp;
55323
55536
  }
55324
55537
  function dedupeInOrder(list) {
@@ -55399,8 +55612,8 @@ async function ensureProxyRunning(opts, deps = {}) {
55399
55612
  const spawnedOrigin = proxyOrigin(opts.host, port);
55400
55613
  const script = process.argv[1];
55401
55614
  if (!script) throw new Error("bili: cannot resolve launcher script path");
55402
- const logPath2 = path7.join(os2.tmpdir(), `bili-proxy-${port}.log`);
55403
- const logFd = fs5.openSync(logPath2, "a");
55615
+ const logPath2 = path9.join(os4.tmpdir(), `bili-proxy-${port}.log`);
55616
+ const logFd = fs7.openSync(logPath2, "a");
55404
55617
  let child;
55405
55618
  try {
55406
55619
  child = spawnImpl(
@@ -55417,7 +55630,7 @@ async function ensureProxyRunning(opts, deps = {}) {
55417
55630
  );
55418
55631
  } finally {
55419
55632
  try {
55420
- fs5.closeSync(logFd);
55633
+ fs7.closeSync(logFd);
55421
55634
  } catch {
55422
55635
  }
55423
55636
  }
@@ -55466,8 +55679,8 @@ function isOnPath(name, env) {
55466
55679
  return p2.split(":").some((dir) => {
55467
55680
  if (!dir) return false;
55468
55681
  try {
55469
- const f2 = path7.join(dir, name);
55470
- return fs5.existsSync(f2) && fs5.statSync(f2).isFile();
55682
+ const f2 = path9.join(dir, name);
55683
+ return fs7.existsSync(f2) && fs7.statSync(f2).isFile();
55471
55684
  } catch {
55472
55685
  return false;
55473
55686
  }
@@ -55478,102 +55691,14 @@ function resolveClientCommand(client, env) {
55478
55691
  const piBin = env.PI_BIN?.trim();
55479
55692
  if (piBin) return { command: piBin, prefixArgs: [] };
55480
55693
  if (isOnPath("pi", env)) return { command: "pi", prefixArgs: [] };
55481
- const cli = path7.join(
55482
- os2.homedir(),
55694
+ const cli = path9.join(
55695
+ os4.homedir(),
55483
55696
  ".pi/agent/npm/node_modules/@earendil-works/pi-coding-agent/dist/cli.js"
55484
55697
  );
55485
55698
  return { command: process.execPath, prefixArgs: [cli] };
55486
55699
  }
55487
55700
  return { command: client, prefixArgs: [] };
55488
55701
  }
55489
- function readJsonObject(filePath) {
55490
- try {
55491
- const txt = fs5.readFileSync(filePath, "utf8");
55492
- const parsed = JSON.parse(txt);
55493
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
55494
- } catch {
55495
- return null;
55496
- }
55497
- }
55498
- function readClaudeSettings(homeDir, cwd) {
55499
- const files = [
55500
- path7.join(homeDir, ".claude", "settings.json"),
55501
- path7.join(cwd, ".claude", "settings.json")
55502
- ];
55503
- let anthropicBaseUrl;
55504
- for (const f2 of files) {
55505
- const obj = readJsonObject(f2);
55506
- const env = obj?.env;
55507
- if (env && typeof env === "object" && !Array.isArray(env)) {
55508
- const v2 = env.ANTHROPIC_BASE_URL;
55509
- if (nonEmpty2(v2)) anthropicBaseUrl = v2;
55510
- }
55511
- }
55512
- return anthropicBaseUrl ? { anthropicBaseUrl } : {};
55513
- }
55514
- function parseCodexToml(text) {
55515
- const result = { providers: {} };
55516
- let table = "";
55517
- let curProvider = null;
55518
- for (const rawLine of text.split(/\r?\n/)) {
55519
- const line = rawLine.trim();
55520
- if (!line || line.startsWith("#")) continue;
55521
- const tableMatch = /^\[([^\]]+)\]$/.exec(line);
55522
- if (tableMatch) {
55523
- table = tableMatch[1].trim();
55524
- curProvider = table.startsWith("model_providers.") ? table.slice("model_providers.".length).trim() : null;
55525
- if (curProvider && !result.providers[curProvider]) {
55526
- result.providers[curProvider] = {};
55527
- }
55528
- continue;
55529
- }
55530
- const m2 = /^([A-Za-z0-9_.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(line);
55531
- if (!m2) continue;
55532
- const key = m2[1];
55533
- const val = m2[2] !== void 0 ? m2[2] : m2[3];
55534
- if (table === "") {
55535
- if (key === "model_provider") result.modelProvider = val;
55536
- else if (key === "openai_base_url") result.openaiBaseUrl = val;
55537
- } else if (curProvider && key === "base_url") {
55538
- result.providers[curProvider].baseUrl = val;
55539
- }
55540
- }
55541
- return result;
55542
- }
55543
- function readCodexConfig(codexHome) {
55544
- const cfgPath = path7.join(codexHome, "config.toml");
55545
- let text;
55546
- try {
55547
- text = fs5.readFileSync(cfgPath, "utf8");
55548
- } catch {
55549
- return { providers: {} };
55550
- }
55551
- return parseCodexToml(text);
55552
- }
55553
- function readPiConfig(piHome) {
55554
- const cfgPath = path7.join(piHome, "models.json");
55555
- const obj = readJsonObject(cfgPath);
55556
- const providers = {};
55557
- const rawProviders = obj?.providers;
55558
- if (rawProviders && typeof rawProviders === "object" && !Array.isArray(rawProviders)) {
55559
- for (const [name, val] of Object.entries(rawProviders)) {
55560
- if (val && typeof val === "object" && !Array.isArray(val)) {
55561
- const baseUrl = val.baseUrl;
55562
- providers[name] = typeof baseUrl === "string" ? { baseUrl } : {};
55563
- }
55564
- }
55565
- }
55566
- return { providers };
55567
- }
55568
- function loadClientConfig(env, cwd) {
55569
- const home = os2.homedir();
55570
- const config = {};
55571
- config.claude = readClaudeSettings(home, cwd);
55572
- const codexHome = nonEmpty2(env.CODEX_HOME) ? env.CODEX_HOME : path7.join(home, ".codex");
55573
- config.codex = readCodexConfig(codexHome);
55574
- config.pi = readPiConfig(resolvePiHome(env));
55575
- return config;
55576
- }
55577
55702
  function parsePort(raw) {
55578
55703
  const port = raw && raw.trim() ? parseInt(raw, 10) : LAUNCHER_DEFAULT_PORT;
55579
55704
  if (!Number.isFinite(port) || port <= 0 || port > 65535) {
@@ -55626,7 +55751,7 @@ async function runLaunch(params, deps = {}) {
55626
55751
  if (!handle2.reused) stopProxy(handle2);
55627
55752
  if (piTmpHome) {
55628
55753
  try {
55629
- fs5.rmSync(piTmpHome, { recursive: true, force: true });
55754
+ fs7.rmSync(piTmpHome, { recursive: true, force: true });
55630
55755
  } catch {
55631
55756
  }
55632
55757
  }
@@ -55652,8 +55777,8 @@ async function runTestPi(params, deps = {}) {
55652
55777
  }
55653
55778
  const ca = resolveCaCertPath(process.env);
55654
55779
  const env = buildPiEnv(handle2.origin, ca, process.env);
55655
- const sessionDir = path7.join(os2.tmpdir(), `bili-pi-test-${Date.now()}`);
55656
- fs5.mkdirSync(sessionDir, { recursive: true });
55780
+ const sessionDir = path9.join(os4.tmpdir(), `bili-pi-test-${Date.now()}`);
55781
+ fs7.mkdirSync(sessionDir, { recursive: true });
55657
55782
  const args = [
55658
55783
  "-p",
55659
55784
  "--no-session",
@@ -55682,11 +55807,11 @@ async function runTestPi(params, deps = {}) {
55682
55807
  // src/cli.ts
55683
55808
  import { readFileSync as readFileSync5 } from "fs";
55684
55809
  import { fileURLToPath as fileURLToPath3 } from "url";
55685
- import path8 from "path";
55810
+ import path10 from "path";
55686
55811
  var VERSION = (() => {
55687
55812
  try {
55688
55813
  const here = fileURLToPath3(import.meta.url);
55689
- const pkg = path8.join(path8.dirname(here), "..", "package.json");
55814
+ const pkg = path10.join(path10.dirname(here), "..", "package.json");
55690
55815
  return JSON.parse(readFileSync5(pkg, "utf8")).version ?? "dev";
55691
55816
  } catch {
55692
55817
  return "dev";
@@ -55695,7 +55820,7 @@ var VERSION = (() => {
55695
55820
  var PACKAGE_NAME = (() => {
55696
55821
  try {
55697
55822
  const here = fileURLToPath3(import.meta.url);
55698
- const pkg = path8.join(path8.dirname(here), "..", "package.json");
55823
+ const pkg = path10.join(path10.dirname(here), "..", "package.json");
55699
55824
  return JSON.parse(readFileSync5(pkg, "utf8")).name ?? "billion-context";
55700
55825
  } catch {
55701
55826
  return "billion-context";