virouter 0.2.0 → 0.2.1

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/bin/virouter.mjs +18 -2
  2. package/package.json +1 -1
package/bin/virouter.mjs CHANGED
@@ -73,10 +73,23 @@ async function chooseOs(input) {
73
73
  return answer;
74
74
  }
75
75
 
76
+ /**
77
+ * Claude Code needs ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY.
78
+ *
79
+ * ANTHROPIC_API_KEY is reserved for a real Anthropic-issued key: Claude Code validates it
80
+ * against its own auth and, on a machine with a logged-in session, sends the OAuth token to
81
+ * the configured base URL instead of our key. The gateway then rejects a token it has never
82
+ * issued, and the user is told to run /login. ANTHROPIC_AUTH_TOKEN is the third-party
83
+ * gateway path — it is forwarded verbatim as `Authorization: Bearer`.
84
+ *
85
+ * The unset matters: an ANTHROPIC_API_KEY left over from an earlier install keeps
86
+ * shadowing the token, so the fix has to remove it rather than just add the right variable.
87
+ */
76
88
  function configLines(apiKey) {
77
89
  return [
90
+ 'unset ANTHROPIC_API_KEY',
78
91
  `export ANTHROPIC_BASE_URL="${API_ORIGIN}"`,
79
- `export ANTHROPIC_API_KEY="${apiKey}"`,
92
+ `export ANTHROPIC_AUTH_TOKEN="${apiKey}"`,
80
93
  'export ANTHROPIC_MODEL="viro-max"',
81
94
  'export ANTHROPIC_SMALL_FAST_MODEL="viro-speed"',
82
95
  ];
@@ -94,9 +107,12 @@ function updateProfile(path, lines) {
94
107
  function configureWindows(apiKey) {
95
108
  const values = {
96
109
  ANTHROPIC_BASE_URL: API_ORIGIN,
97
- ANTHROPIC_API_KEY: apiKey,
110
+ ANTHROPIC_AUTH_TOKEN: apiKey,
98
111
  ANTHROPIC_MODEL: 'viro-max',
99
112
  ANTHROPIC_SMALL_FAST_MODEL: 'viro-speed',
113
+ // Blanked rather than left alone — see configLines. A value here shadows the token and
114
+ // sends the user round the /login loop. `setx` has no delete, so empty is the removal.
115
+ ANTHROPIC_API_KEY: '',
100
116
  };
101
117
 
102
118
  for (const [name, value] of Object.entries(values)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virouter",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Configure Claude Code to use the VIROUTER API gateway",
5
5
  "keywords": ["claude-code", "anthropic", "openai", "api-gateway", "cli"],
6
6
  "license": "MIT",