xc-copilot-api 1.1.1 → 1.1.3

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/main.js CHANGED
@@ -17,10 +17,11 @@ import { cors } from "hono/cors";
17
17
  import { streamSSE } from "hono/streaming";
18
18
  import { events } from "fetch-event-stream";
19
19
  import { html } from "hono/html";
20
+ import "hono/logger";
20
21
 
21
22
  //#region package.json
22
23
  var name = "xc-copilot-api";
23
- var version = "1.1.1";
24
+ var version = "1.1.3";
24
25
  var description = "Turn GitHub Copilot into OpenAI/Anthropic API compatible server. Usable with Claude Code and Codex";
25
26
  var keywords = [
26
27
  "proxy",
@@ -1292,6 +1293,22 @@ const REQUEST_HEADERS_TO_FORWARD = [
1292
1293
  "anthropic-beta",
1293
1294
  "anthropic-version"
1294
1295
  ];
1296
+ const CONTEXT_1M_BETA = "context-1m-2025-08-07";
1297
+ const UNSUPPORTED_BETA_VALUES = new Set([CONTEXT_1M_BETA]);
1298
+ function hasContext1mBeta(headers) {
1299
+ const beta = headers.get("anthropic-beta");
1300
+ if (!beta) return false;
1301
+ return beta.split(",").map((v) => v.trim()).includes(CONTEXT_1M_BETA);
1302
+ }
1303
+ function sanitizeBetaHeader(headers) {
1304
+ const beta = headers.get("anthropic-beta");
1305
+ if (!beta) return headers;
1306
+ const filtered = beta.split(",").map((v) => v.trim()).filter((v) => !UNSUPPORTED_BETA_VALUES.has(v)).join(",");
1307
+ const newHeaders = new Headers(headers);
1308
+ if (filtered) newHeaders.set("anthropic-beta", filtered);
1309
+ else newHeaders.delete("anthropic-beta");
1310
+ return newHeaders;
1311
+ }
1295
1312
  /**
1296
1313
  * Parse body JSON and rebuild cache_control objects to only keep "type",
1297
1314
  * using JSON.parse reviver to avoid mutating input.
@@ -1317,6 +1334,11 @@ function stripUnsupportedFields(bodyText) {
1317
1334
  }
1318
1335
  }
1319
1336
  async function createMessages(bodyText, requestHeaders, path$1 = "/v1/messages") {
1337
+ consola.debug(`Original request headers: ${JSON.stringify([...requestHeaders])}`);
1338
+ if (hasContext1mBeta(requestHeaders)) {
1339
+ consola.debug("Request includes unsupported beta features. Stripping unsupported beta flags and fields.");
1340
+ requestHeaders = sanitizeBetaHeader(requestHeaders);
1341
+ }
1320
1342
  return postCopilotPassthrough({
1321
1343
  path: path$1,
1322
1344
  body: stripUnsupportedFields(bodyText),