solrouter 0.3.4 → 0.3.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/providers.js +13 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solrouter",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Local privacy router for coding tools: pseudonymises every request before it leaves your machine, and sends work a frontier model would refuse to an uncensored open-weight model you control.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/providers.js CHANGED
@@ -25,9 +25,18 @@ const DROP = new Set([
25
25
  function authHeaders(leg, clientHeaders = {}) {
26
26
  const h = { "content-type": "application/json" };
27
27
 
28
- // 1. explicit key
28
+ // ALWAYS forward the client's non-auth headers first — especially every
29
+ // `anthropic-beta` flag. Claude Code enables body fields like `context_management`
30
+ // and 1M context via those headers; dropping them makes Anthropic reject the body
31
+ // ("Extra inputs are not permitted"). We overwrite only the auth header below.
32
+ for (const k of Object.keys(clientHeaders)) {
33
+ if (DROP.has(k) || k === "authorization" || k === "x-api-key") continue;
34
+ h[k] = clientHeaders[k];
35
+ }
36
+
37
+ // 1. explicit key — set auth, keep the forwarded beta headers
29
38
  if (leg.apiKey) {
30
- if (leg.dialect === "anthropic") { h["x-api-key"] = leg.apiKey; h["anthropic-version"] = "2023-06-01"; }
39
+ if (leg.dialect === "anthropic") { h["x-api-key"] = leg.apiKey; h["anthropic-version"] ||= "2023-06-01"; }
31
40
  else h["authorization"] = `Bearer ${leg.apiKey}`;
32
41
  return h;
33
42
  }
@@ -39,15 +48,10 @@ function authHeaders(leg, clientHeaders = {}) {
39
48
  return h;
40
49
  }
41
50
 
42
- // 2. pass-through (default): forward every client header verbatim
51
+ // 2. pass-through (default): forward the client's own auth too
43
52
  let forwarded = false;
44
- for (const k of Object.keys(clientHeaders)) {
45
- if (DROP.has(k)) continue;
46
- h[k] = clientHeaders[k];
47
- if (k === "authorization" || k === "x-api-key") forwarded = true;
48
- }
53
+ for (const k of ["authorization", "x-api-key"]) if (clientHeaders[k]) { h[k] = clientHeaders[k]; forwarded = true; }
49
54
  if (!forwarded) {
50
- // nothing to forward — fall back to the account token if we have one
51
55
  const auth = loadAuth();
52
56
  if (auth.access_token) h["authorization"] = `Bearer ${auth.access_token}`;
53
57
  }